Skip to content

nanocoai/nanoclaw / .claude/skills/add-onecli

add-onecli

Flagged

Install or refresh OneCLI as NanoClaw's gateway provider. Use when setup selects OneCLI, an existing OneCLI-backed install is migrated to the gateway seam, or its runtime, approval bridge, setup, and agent guidance must be restored from the in-tree package.

FileKindSize
REMOVE.mdmarkdown576 B
SKILL.mdskill md10.4 KB
apply-fixtures.jsonconfig1.9 KB
gateway.jsonconfig123 B
payload/docs/onecli-upgrades.mdmarkdown28.0 KB
payload/src/gateway-providers/onecli-chatgpt-stub.test.tsscript4.9 KB
payload/src/gateway-providers/onecli-chatgpt-stub.tsscript3.9 KB
payload/src/gateway-providers/onecli-files.test.tsscript4.4 KB
payload/src/gateway-providers/onecli-files.tsscript4.2 KB
payload/src/gateway-providers/onecli-install.test.tsscript1.1 KB
payload/src/gateway-providers/onecli-provider-credentials.test.tsscript7.6 KB
payload/src/gateway-providers/onecli-provider-credentials.tsscript9.6 KB
payload/src/gateway-providers/onecli.test.tsscript44.6 KB
payload/src/gateway-providers/onecli.tsscript18.2 KB
references/chatgpt-oauth-refresh.mdmarkdown1.1 KB
scripts/auth.test.tsscript10.1 KB
scripts/auth.tsscript7.5 KB
scripts/check-grants-gateway.shexecutablescript3.5 KB
scripts/credential-store.test.tsscript6.4 KB
scripts/credential-store.tsscript2.9 KB
scripts/detect.tsscript873 B
scripts/dial-key-check.shexecutablescript11.1 KB
scripts/install-claude.shexecutablescript1.6 KB
scripts/no-proxy.test.tsscript1.6 KB
scripts/post-upgrade-check.shexecutablescript2.7 KB
scripts/postgres-check.tsscript222 B
scripts/postgres-password.test.tsscript29.2 KB
scripts/postgres-password.tsscript20.2 KB
scripts/pre-upgrade-check.shexecutablescript2.9 KB
scripts/provider-credentials.test.tsscript21.9 KB
scripts/provider-credentials.tsscript12.7 KB
scripts/proxy-check.tsscript213 B
scripts/readiness.test.tsscript1.1 KB
scripts/register-claude-token.shexecutablescript4.0 KB
scripts/remote-proxy.test.tsscript10.9 KB
scripts/remote-proxy.tsscript4.2 KB
scripts/secret-input.test.tsscript10.4 KB
scripts/secret-input.tsscript4.9 KB
scripts/setup.tsscript23.1 KB
versions.jsonconfig84 B

scripts/secret-input.ts

View on GitHub
import { execFileSync } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

// Secrets reach onecli through a file or stdin, never argv: any local user can
// read a running command's arguments with `ps`. A failed call is rethrown
// redacted, since Node's error repeats the command line and stderr.

const MARK = '[redacted]';

// `text` without whitespace, then without backslash runs or the n/r/t a
// backslash escapes, with `\uXXXX` decoded and `%xx` upper-cased; plus the
// span each kept character came from, and the escape letters dropped just
// before it. A value wrapped across lines (even inside an escape), or escaped
// (JSON, shell) any number of times, reduces to the same characters.
type Dropped = { c: string; at: number };
function skeleton(text: string): { chars: string; from: number[]; to: number[]; dropped: Dropped[][] } {
  const at: number[] = [];
  for (let i = 0; i < text.length; i++) if (!/\s/.test(text[i])) at.push(i);
  const t = at.map((i) => text[i]).join('');
  let chars = '';
  const from: number[] = [];
  const to: number[] = [];
  const dropped: Dropped[][] = [];
  let pending: Dropped[] = [];
  const keep = (c: string, start: number, end: number) => {
    chars += c;
    from.push(at[start]);
    to.push(at[end] + 1);
    dropped.push(pending);
    pending = [];
  };
  for (let i = 0; i < t.length; i++) {
    const start = i;
    if (t[i] === '\\') {
      while (t[i + 1] === '\\') i++;
      const hex = /^u([0-9a-fA-F]{4})/.exec(t.slice(i + 1, i + 6));
      if (hex) {
        i += 5;
        const c = String.fromCharCode(parseInt(hex[1], 16));
        if (!/[\s\\]/.test(c)) keep(c, start, i);
      } else if (/[nrt]/.test(t[i + 1] ?? '')) pending.push({ c: t[++i], at: at[i] });
    } else if (/^%[0-9a-fA-F]{2}/.test(t.slice(i, i + 3))) {
      for (const j of [i, i + 1, i + 2]) keep(t[j].toUpperCase(), j, j);
      i += 2;
    } else keep(t[i], i, i);
  }
  return { chars, from, to, dropped };
}

/** `text` without any secret, raw, URL-encoded or base64, even wrapped or escaped. */
export function redact(text: string, secrets: string[]): string {
  const { chars, from, to, dropped } = skeleton(text);
  const spans: Array<[number, number]> = [];
  for (const secret of secrets) {
    const bytes = Buffer.from(secret);
    for (const form of [secret, encodeURIComponent(secret), bytes.toString('base64'), bytes.toString('base64url')]) {
      const needle = skeleton(form).chars;
      if (!needle) continue;
      // A leading n/r/t right after a raw backslash reads as an escape and drops
      // out, so also find the rest and take that letter back.
      const tail = /^[nrt]./.test(needle) ? needle.slice(1) : '';
      for (const n of tail ? [needle, tail] : [needle]) {
        for (let k = chars.indexOf(n); k !== -1; k = chars.indexOf(n, k + 1)) {
          const letter = n === tail ? dropped[k].find((d) => d.c === needle[0]) : undefined;
          if (n === tail && !letter) continue;
          spans.push([letter?.at ?? from[k], to[k + n.length - 1]]);
        }
      }
    }
  }
  let out = '';
  let pos = 0;
  for (const [start, end] of spans.sort((a, b) => a[0] - b[0])) {
    if (end <= pos) continue;
    out += start >= pos ? text.slice(pos, start) + MARK : '';
    pos = end;
  }
  return out + text.slice(pos);
}

/** A copy of a child-process error with only redacted text and the exit status; no `cause`. */
export function redactedError(error: unknown, secrets: string[]): Error {
  const source = (error ?? {}) as Record<string, unknown>;
  const text = (value: unknown) => (value === undefined || value === null ? undefined : redact(String(value), secrets));
  const copy = new Error(text(error instanceof Error ? error.message : error) ?? 'Command failed') as Error &
    Record<string, unknown>;
  for (const key of ['cmd', 'stdout', 'stderr']) if (source[key] !== undefined) copy[key] = text(source[key]);
  for (const key of ['status', 'signal', 'code']) if (source[key] !== undefined) copy[key] = source[key];
  return copy;
}

/** `onecli secrets create <args> --file <0600 file holding value>`; returns stdout. */
export function createSecret(args: string[], value: string, env?: NodeJS.ProcessEnv): string {
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'onecli-secret-'));
  const file = path.join(dir, 'value');
  try {
    fs.writeFileSync(file, value, { mode: 0o600 });
    return execFileSync('onecli', ['secrets', 'create', ...args, '--file', file], {
      encoding: 'utf8',
      env,
      stdio: ['ignore', 'pipe', 'pipe'],
    });
  } catch (error) {
    throw redactedError(error, [value]);
  } finally {
    fs.rmSync(dir, { recursive: true, force: true });
  }
}

/** `onecli auth login` with the API key on stdin. */
export function login(apiKey: string, env?: NodeJS.ProcessEnv): void {
  try {
    execFileSync('onecli', ['auth', 'login'], { input: `${apiKey}\n`, env, stdio: ['pipe', 'ignore', 'pipe'] });
  } catch (error) {
    throw redactedError(error, [apiKey]);
  }
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall