tenjin-cli 0.1.0-alpha.7 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -236
- package/dist/{buy-XVOMNWKN.js → buy-3PPC2SRQ.js} +24 -22
- package/dist/{candidate-DJB2NNTG.js → candidate-FCBWDN4Y.js} +10 -8
- package/dist/{chunk-PLU3E63S.js → chunk-3MQSXDWS.js} +10 -11
- package/dist/chunk-3MQSXDWS.js.map +1 -0
- package/dist/{chunk-DH6D6QIO.js → chunk-6DWKU4RH.js} +11 -9
- package/dist/{chunk-DH6D6QIO.js.map → chunk-6DWKU4RH.js.map} +1 -1
- package/dist/{chunk-WDJTGVKN.js → chunk-6L34JW52.js} +5 -2
- package/dist/chunk-6L34JW52.js.map +1 -0
- package/dist/{chunk-6S44OLND.js → chunk-6RODLWPQ.js} +101 -36
- package/dist/chunk-6RODLWPQ.js.map +1 -0
- package/dist/{chunk-VZ3AJCO5.js → chunk-75G4REUY.js} +2 -2
- package/dist/{chunk-PIIWLEEG.js → chunk-7MJCZ2OX.js} +12 -12
- package/dist/{chunk-2KIDDWQO.js → chunk-ATSCQETF.js} +5 -5
- package/dist/{chunk-ZFE7STX7.js → chunk-AX5WQ3H5.js} +7 -5
- package/dist/{chunk-ZFE7STX7.js.map → chunk-AX5WQ3H5.js.map} +1 -1
- package/dist/{chunk-WRWCDLVK.js → chunk-BFAFOBO3.js} +23 -4
- package/dist/chunk-BFAFOBO3.js.map +1 -0
- package/dist/{chunk-DAJ56EUU.js → chunk-CTFFFQFH.js} +3 -3
- package/dist/{chunk-5X4EBGGU.js → chunk-E5PZEPUO.js} +11 -11
- package/dist/{chunk-GABYDXWL.js → chunk-FFTWWJRW.js} +21 -5
- package/dist/{chunk-GABYDXWL.js.map → chunk-FFTWWJRW.js.map} +1 -1
- package/dist/{chunk-WI5EOAQQ.js → chunk-G7ECLIN6.js} +21 -21
- package/dist/{chunk-CYRYVZPN.js → chunk-GJKDWZ6X.js} +3 -3
- package/dist/{chunk-RGFBBNGP.js → chunk-I4WQXOEL.js} +16 -13
- package/dist/chunk-I4WQXOEL.js.map +1 -0
- package/dist/{chunk-OTDI5FXG.js → chunk-JURZ2T2I.js} +3 -3
- package/dist/{chunk-UYP7G3GZ.js → chunk-KRHUDEIQ.js} +10 -172
- package/dist/chunk-KRHUDEIQ.js.map +1 -0
- package/dist/{chunk-2L73UI6T.js → chunk-MHRREGGN.js} +5 -10
- package/dist/chunk-MHRREGGN.js.map +1 -0
- package/dist/chunk-OQXHNWM3.js +47 -0
- package/dist/chunk-OQXHNWM3.js.map +1 -0
- package/dist/chunk-P74I3WH4.js +204 -0
- package/dist/chunk-P74I3WH4.js.map +1 -0
- package/dist/{chunk-ZEWY3RJ3.js → chunk-PT2NJUGG.js} +6 -6
- package/dist/{chunk-J6CVKC4M.js → chunk-PZRAAAY2.js} +4 -46
- package/dist/chunk-PZRAAAY2.js.map +1 -0
- package/dist/{chunk-XBJ3VLWX.js → chunk-PZSUWDF2.js} +2 -2
- package/dist/{chunk-BBUYCDSG.js → chunk-R2VLGNFD.js} +7 -2
- package/dist/chunk-R2VLGNFD.js.map +1 -0
- package/dist/{chunk-KT2DGKFT.js → chunk-S4IKXAUA.js} +5 -9
- package/dist/chunk-S4IKXAUA.js.map +1 -0
- package/dist/{chunk-E6BNARCS.js → chunk-TMZIXYPL.js} +7 -7
- package/dist/{chunk-YBMMV4Y4.js → chunk-TYVLXAB5.js} +26 -4
- package/dist/chunk-TYVLXAB5.js.map +1 -0
- package/dist/{chunk-GXYNLMUQ.js → chunk-V7BWPOKT.js} +38 -19
- package/dist/chunk-V7BWPOKT.js.map +1 -0
- package/dist/{chunk-L6AV2Q73.js → chunk-VE5BALOI.js} +5 -5
- package/dist/{chunk-GM4RZUVU.js → chunk-WGXUVCUF.js} +8 -6
- package/dist/{chunk-GM4RZUVU.js.map → chunk-WGXUVCUF.js.map} +1 -1
- package/dist/chunk-X3OOVSPX.js +154 -0
- package/dist/chunk-X3OOVSPX.js.map +1 -0
- package/dist/{chunk-2YX6LTCD.js → chunk-XDW6GOHO.js} +5 -5
- package/dist/{cli-7B2QNJG3.js → cli-ATFP3O6Y.js} +42 -29
- package/dist/{cli-7B2QNJG3.js.map → cli-ATFP3O6Y.js.map} +1 -1
- package/dist/{config-SAQEQRFB.js → config-VT5WU47R.js} +9 -6
- package/dist/dist-U4M6QCKE.js +2842 -0
- package/dist/dist-U4M6QCKE.js.map +1 -0
- package/dist/doctor-6PEYDTB5.js +24 -0
- package/dist/{edit-2QO5GQDU.js → edit-GKI37CRM.js} +21 -19
- package/dist/index.js +1 -1
- package/dist/{inspect-IPKKQB2S.js → inspect-ITZIRZDV.js} +19 -16
- package/dist/install-BMMUPFOK.js +922 -0
- package/dist/install-BMMUPFOK.js.map +1 -0
- package/dist/outcome-F5KN3K3Y.js +23 -0
- package/dist/{publish-7WIFFNFG.js → publish-F5G5WIFI.js} +22 -20
- package/dist/{read-5TQR7LCF.js → read-II2ZO4II.js} +21 -19
- package/dist/{read-5TQR7LCF.js.map → read-II2ZO4II.js.map} +1 -1
- package/dist/{run-NPKIP26Y.js → run-FJWMRXZ7.js} +68 -45
- package/dist/run-FJWMRXZ7.js.map +1 -0
- package/dist/search-Z2YALF6S.js +26 -0
- package/dist/{send-ENE47KQE.js → send-RWOBFOBK.js} +20 -18
- package/dist/{send-ENE47KQE.js.map → send-RWOBFOBK.js.map} +1 -1
- package/dist/{session-FZU4VFFE.js → session-DJV5T3BG.js} +17 -15
- package/dist/{session-FZU4VFFE.js.map → session-DJV5T3BG.js.map} +1 -1
- package/dist/skill-heal-OK6YALW6.js +85 -0
- package/dist/skill-heal-OK6YALW6.js.map +1 -0
- package/dist/{wallet-RBDVNZVR.js → wallet-AB4ISFMY.js} +8 -7
- package/dist/{wallet-OCCGEH6H.js → wallet-XVRLJZ63.js} +12 -10
- package/docs/agent-permissions.md +255 -0
- package/package.json +4 -1
- package/skills/tenjin/SKILL.md +126 -47
- package/skills/tenjin-search/SKILL.md +10 -6
- package/dist/chunk-2L73UI6T.js.map +0 -1
- package/dist/chunk-6S44OLND.js.map +0 -1
- package/dist/chunk-BBUYCDSG.js.map +0 -1
- package/dist/chunk-GXYNLMUQ.js.map +0 -1
- package/dist/chunk-J6CVKC4M.js.map +0 -1
- package/dist/chunk-KT2DGKFT.js.map +0 -1
- package/dist/chunk-PLU3E63S.js.map +0 -1
- package/dist/chunk-RGFBBNGP.js.map +0 -1
- package/dist/chunk-UYP7G3GZ.js.map +0 -1
- package/dist/chunk-WDJTGVKN.js.map +0 -1
- package/dist/chunk-WRWCDLVK.js.map +0 -1
- package/dist/chunk-YBMMV4Y4.js.map +0 -1
- package/dist/doctor-ENJ22XWN.js +0 -22
- package/dist/install-7ZIYISQ7.js +0 -589
- package/dist/install-7ZIYISQ7.js.map +0 -1
- package/dist/outcome-NSDE2KAJ.js +0 -20
- package/dist/run-NPKIP26Y.js.map +0 -1
- package/dist/search-63ELMRZH.js +0 -24
- /package/dist/{buy-XVOMNWKN.js.map → buy-3PPC2SRQ.js.map} +0 -0
- /package/dist/{candidate-DJB2NNTG.js.map → candidate-FCBWDN4Y.js.map} +0 -0
- /package/dist/{chunk-VZ3AJCO5.js.map → chunk-75G4REUY.js.map} +0 -0
- /package/dist/{chunk-PIIWLEEG.js.map → chunk-7MJCZ2OX.js.map} +0 -0
- /package/dist/{chunk-2KIDDWQO.js.map → chunk-ATSCQETF.js.map} +0 -0
- /package/dist/{chunk-DAJ56EUU.js.map → chunk-CTFFFQFH.js.map} +0 -0
- /package/dist/{chunk-5X4EBGGU.js.map → chunk-E5PZEPUO.js.map} +0 -0
- /package/dist/{chunk-WI5EOAQQ.js.map → chunk-G7ECLIN6.js.map} +0 -0
- /package/dist/{chunk-CYRYVZPN.js.map → chunk-GJKDWZ6X.js.map} +0 -0
- /package/dist/{chunk-OTDI5FXG.js.map → chunk-JURZ2T2I.js.map} +0 -0
- /package/dist/{chunk-ZEWY3RJ3.js.map → chunk-PT2NJUGG.js.map} +0 -0
- /package/dist/{chunk-XBJ3VLWX.js.map → chunk-PZSUWDF2.js.map} +0 -0
- /package/dist/{chunk-E6BNARCS.js.map → chunk-TMZIXYPL.js.map} +0 -0
- /package/dist/{chunk-L6AV2Q73.js.map → chunk-VE5BALOI.js.map} +0 -0
- /package/dist/{chunk-2YX6LTCD.js.map → chunk-XDW6GOHO.js.map} +0 -0
- /package/dist/{config-SAQEQRFB.js.map → config-VT5WU47R.js.map} +0 -0
- /package/dist/{doctor-ENJ22XWN.js.map → doctor-6PEYDTB5.js.map} +0 -0
- /package/dist/{edit-2QO5GQDU.js.map → edit-GKI37CRM.js.map} +0 -0
- /package/dist/{inspect-IPKKQB2S.js.map → inspect-ITZIRZDV.js.map} +0 -0
- /package/dist/{outcome-NSDE2KAJ.js.map → outcome-F5KN3K3Y.js.map} +0 -0
- /package/dist/{publish-7WIFFNFG.js.map → publish-F5G5WIFI.js.map} +0 -0
- /package/dist/{search-63ELMRZH.js.map → search-Z2YALF6S.js.map} +0 -0
- /package/dist/{wallet-OCCGEH6H.js.map → wallet-AB4ISFMY.js.map} +0 -0
- /package/dist/{wallet-RBDVNZVR.js.map → wallet-XVRLJZ63.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"tenjin-cli\",\n \"version\": \"0.1.0-alpha.7\",\n \"type\": \"module\",\n \"description\": \"Tenjin agent CLI for the x402 knowledge marketplace.\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/BackTrackCo/tenjin-agent.git\"\n },\n \"homepage\": \"https://tenjin.blog/agents\",\n \"bugs\": \"https://github.com/BackTrackCo/tenjin-agent/issues\",\n \"keywords\": [\n \"x402\",\n \"usdc\",\n \"base\",\n \"ai-agents\",\n \"agent-payments\",\n \"mcp\",\n \"knowledge-marketplace\",\n \"micropayments\",\n \"claude\",\n \"codex\",\n \"cli\"\n ],\n \"bin\": {\n \"tenjin\": \"dist/index.js\"\n },\n \"engines\": {\n \"node\": \">=22\"\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"NOTICE.md\"\n ],\n \"packageManager\": \"pnpm@11.11.0\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"check\": \"pnpm run build && pnpm run test\",\n \"sync:skill\": \"node scripts/sync-skill.mjs\",\n \"pack-smoke\": \"bash scripts/pack-smoke.sh\",\n \"changeset\": \"changeset\",\n \"prepublishOnly\": \"pnpm run build\",\n \"prepare\": \"git config core.hooksPath .githooks || true\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.31.1\",\n \"@eslint/js\": \"^10\",\n \"@modelcontextprotocol/sdk\": \"1.29.0\",\n \"@types/node\": \"^25\",\n \"@x402/core\": \"2.17.0\",\n \"@x402/evm\": \"2.17.0\",\n \"@x402/extensions\": \"2.17.0\",\n \"commander\": \"^14.0.1\",\n \"eslint\": \"^10\",\n \"eslint-config-prettier\": \"^10\",\n \"ox\": \"0.14.30\",\n \"prettier\": \"^3\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^6\",\n \"typescript-eslint\": \"^8\",\n \"viem\": \"^2.53.1\",\n \"vitest\": \"^4.1.9\",\n \"zod\": \"^4.4.3\"\n }\n}\n"],"mappings":";;;AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,SAAW;AAAA,EACX,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,MAAQ;AAAA,EACR,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,QAAU;AAAA,EACZ;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAkB;AAAA,EAClB,SAAW;AAAA,IACT,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,WAAa;AAAA,IACb,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,OAAS;AAAA,IACT,cAAc;AAAA,IACd,cAAc;AAAA,IACd,WAAa;AAAA,IACb,gBAAkB;AAAA,IAClB,SAAW;AAAA,EACb;AAAA,EACA,iBAAmB;AAAA,IACjB,mBAAmB;AAAA,IACnB,cAAc;AAAA,IACd,6BAA6B;AAAA,IAC7B,eAAe;AAAA,IACf,cAAc;AAAA,IACd,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,WAAa;AAAA,IACb,QAAU;AAAA,IACV,0BAA0B;AAAA,IAC1B,IAAM;AAAA,IACN,UAAY;AAAA,IACZ,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,KAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/wallet/store.ts"],"sourcesContent":["import { readFile, stat } from 'node:fs/promises';\nimport { z } from 'zod';\nimport * as Keystore from 'ox/Keystore';\nimport { CliError } from '../errors';\nimport { writeFileAtomicExclusive } from '../atomic-json';\nimport { hasCode } from '../errno';\nimport { walletPath } from '../paths';\n\n/** A 0x-prefixed 32-byte hex private key (case-insensitive). */\nexport const PRIVATE_KEY_RE = /^0x[0-9a-f]{64}$/i;\nconst ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;\n\n/**\n * The at-rest shape of a Keystore v3 document (Web3 Secret Storage). Validated\n * structurally on read so an obviously-corrupt keystore fails as\n * WALLET_INVALID_KEY before we ever ask for a passphrase; the real integrity\n * check is the keystore's own MAC, verified by ox at decrypt time. `kdfparams`\n * stays an open object because scrypt and pbkdf2 carry different fields and only\n * ox needs to interpret them.\n */\nconst KeystoreV3Schema = z.object({\n crypto: z.object({\n cipher: z.literal('aes-128-ctr'),\n ciphertext: z.string(),\n cipherparams: z.object({ iv: z.string() }),\n kdf: z.enum(['scrypt', 'pbkdf2']),\n kdfparams: z.record(z.string(), z.unknown()),\n mac: z.string(),\n }),\n id: z.string(),\n version: z.literal(3),\n});\n\n/**\n * The persisted wallet record (schema v2). The private key is NEVER stored in\n * cleartext: `keystore` is a Keystore v3 document (scrypt + AES-128-CTR) and the\n * key is recovered only by decrypting it with the wallet passphrase. `address`\n * stays top-level in cleartext ON PURPOSE so `show`/`balance`/`doctor` keep\n * working without a passphrase; only signing decrypts. The `provider`\n * discriminator keeps the schema from implying every future wallet embeds a\n * keystore. Validated on read (a corrupt file is WALLET_INVALID_KEY, never a\n * silent partial parse).\n */\nexport const WalletRecordSchema = z.object({\n schemaVersion: z.literal(2),\n provider: z.literal('local'),\n address: z.string().regex(ADDRESS_RE, 'expected a 0x-prefixed 20-byte address'),\n keystore: KeystoreV3Schema,\n createdAt: z.string(),\n});\nexport type WalletRecord = Omit<z.infer<typeof WalletRecordSchema>, 'keystore'> & {\n keystore: Keystore.Keystore;\n};\n\nexport async function walletFileExists(dir: string): Promise<boolean> {\n return (await walletFileMode(dir)) !== null;\n}\n\n/** File permission bits (`mode & 0o777`), or null when the wallet file is absent. */\nexport async function walletFileMode(dir: string): Promise<number | null> {\n try {\n return (await stat(walletPath(dir))).mode & 0o777;\n } catch (err) {\n if (isNotFound(err)) return null;\n throw err;\n }\n}\n\n/** Read + validate the wallet record; null when absent, WALLET_INVALID_KEY when corrupt. */\nexport async function readWalletRecord(dir: string): Promise<WalletRecord | null> {\n const path = walletPath(dir);\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n if (isNotFound(err)) return null;\n throw new CliError('WALLET_INVALID_KEY', `Could not read the wallet file at ${path}.`, {\n fix: `Check file permissions on ${path}.`,\n cause: err,\n });\n }\n let json: unknown;\n try {\n json = JSON.parse(raw);\n } catch (err) {\n throw new CliError('WALLET_INVALID_KEY', `The wallet file at ${path} is not valid JSON.`, {\n fix: `Move ${path} aside, then run \\`tenjin wallet create\\`.`,\n cause: err,\n });\n }\n // A pre-encryption record (schema v1 stored the raw key). There is no in-place\n // migration: the old key must be swept and a fresh encrypted wallet created.\n if (isPreEncryptionRecord(json)) {\n throw new CliError(\n 'WALLET_INVALID_KEY',\n `The wallet file at ${path} predates encrypted storage.`,\n {\n fix: `Move ${path} aside and run \\`tenjin wallet create\\`; sweep any funds from the old address first.`,\n },\n );\n }\n const parsed = WalletRecordSchema.safeParse(json);\n if (!parsed.success) {\n throw new CliError(\n 'WALLET_INVALID_KEY',\n `The wallet file at ${path} is not a valid wallet record.`,\n {\n fix: `Move ${path} aside, then run \\`tenjin wallet create\\`.`,\n details: parsed.error.issues,\n },\n );\n }\n return parsed.data as WalletRecord;\n}\n\n/**\n * The one WALLET_EXISTS error, shared by the create pre-check and the exclusive\n * write's race loser so the two surfaces can never drift apart.\n */\nexport function walletExistsError(dir: string, cause?: unknown): CliError {\n const path = walletPath(dir);\n return new CliError('WALLET_EXISTS', `A wallet already exists at ${path}.`, {\n fix: `Run \\`tenjin wallet create --replace\\` to archive it and create a new one: its keystore is parked beside the new wallet and its passphrase stays preserved in the OS credential store (service tenjin-cli, account = its address), so its funds remain reachable. That passphrase is unrecoverable — never delete the credential-store entry, or the wallet's funds are stranded.`,\n ...(cause !== undefined ? { cause } : {}),\n });\n}\n\n/**\n * Persist a validated record at 0600 in a 0700 dir, NO-CLOBBER. The exclusive\n * write — not an earlier existence check — is the authority: two concurrent\n * `create` runs can both pass a pre-check, but only one can win the atomic\n * commit; the loser surfaces as WALLET_EXISTS instead of silently overwriting\n * (and losing) a non-recoverable key.\n */\nexport async function writeWalletRecord(dir: string, record: WalletRecord): Promise<void> {\n const validated = WalletRecordSchema.parse(record);\n const path = walletPath(dir);\n try {\n await writeFileAtomicExclusive(path, `${JSON.stringify(validated, null, 2)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n } catch (err) {\n if (hasCode(err, 'EEXIST')) throw walletExistsError(dir, err);\n throw err;\n }\n}\n\n/** A cleartext-key record from before encrypted storage: schema v1 or a bare `privateKey`. */\nfunction isPreEncryptionRecord(json: unknown): boolean {\n if (typeof json !== 'object' || json === null) return false;\n const rec = json as Record<string, unknown>;\n return rec.schemaVersion === 1 || 'privateKey' in rec;\n}\n\nfunction isNotFound(err: unknown): boolean {\n return hasCode(err, 'ENOENT');\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/lock.ts"],"sourcesContent":["import { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport interface FileLockOptions {\n /** Give up acquiring after this long (ms). */\n timeoutMs?: number;\n /** Poll interval between acquisition attempts (ms). */\n retryMs?: number;\n}\n\nconst DEFAULTS = { timeoutMs: 5000, retryMs: 25 };\n\n/** Thrown when the lock cannot be acquired within `timeoutMs`. Carries the lock\n * path so a caller can surface the manual-recovery step in its own error contract. */\nexport class LockTimeoutError extends Error {\n readonly lockPath: string;\n constructor(lockPath: string, timeoutMs: number) {\n super(\n `Timed out waiting for lock at ${lockPath} after ${timeoutMs}ms; if no other tenjin process is running, remove that directory and retry.`,\n );\n this.name = 'LockTimeoutError';\n this.lockPath = lockPath;\n }\n}\n\n/**\n * Minimal cross-process mutex: the lock IS a directory, and mkdir is atomic, so a\n * second holder gets EEXIST and retries with backoff until `timeoutMs`, then\n * throws LockTimeoutError. There is deliberately NO auto-steal of a \"stale\" lock:\n * concurrent waiters each judging a lock stale could remove a fresh holder's\n * directory and lose its update. A crashed holder's lock is recovered by hand (the\n * timeout error names the path); the pid+acquiredAt meta exists only to make that\n * manual call diagnosable. Always released in the finally.\n */\nexport async function withFileLock<T>(\n lockPath: string,\n fn: () => Promise<T>,\n opts: FileLockOptions = {},\n): Promise<T> {\n const { timeoutMs, retryMs } = { ...DEFAULTS, ...opts };\n const metaPath = join(lockPath, 'meta');\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n try {\n await mkdir(lockPath);\n break; // acquired\n } catch (err) {\n if (!isEexist(err)) throw err;\n if (Date.now() >= deadline) throw new LockTimeoutError(lockPath, timeoutMs);\n await delay(retryMs);\n }\n }\n await writeFile(metaPath, JSON.stringify({ pid: process.pid, acquiredAt: Date.now() })).catch(\n () => undefined,\n );\n try {\n return await fn();\n } finally {\n // With no stealing, nothing else ever removes or replaces this directory, so\n // the lock here is provably the one we created — the unconditional rm is sound.\n await rm(lockPath, { recursive: true, force: true }).catch(() => undefined);\n }\n}\n\nfunction isEexist(err: unknown): boolean {\n return typeof err === 'object' && err !== null && (err as { code?: unknown }).code === 'EEXIST';\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;;AAAA,SAAS,OAAO,IAAI,iBAAiB;AACrC,SAAS,YAAY;AASrB,IAAM,WAAW,EAAE,WAAW,KAAM,SAAS,GAAG;AAIzC,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACT,YAAY,UAAkB,WAAmB;AAC/C;AAAA,MACE,iCAAiC,QAAQ,UAAU,SAAS;AAAA,IAC9D;AACA,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;AAWA,eAAsB,aACpB,UACA,IACA,OAAwB,CAAC,GACb;AACZ,QAAM,EAAE,WAAW,QAAQ,IAAI,EAAE,GAAG,UAAU,GAAG,KAAK;AACtD,QAAM,WAAW,KAAK,UAAU,MAAM;AACtC,QAAM,WAAW,KAAK,IAAI,IAAI;AAC9B,aAAS;AACP,QAAI;AACF,YAAM,MAAM,QAAQ;AACpB;AAAA,IACF,SAAS,KAAK;AACZ,UAAI,CAAC,SAAS,GAAG,EAAG,OAAM;AAC1B,UAAI,KAAK,IAAI,KAAK,SAAU,OAAM,IAAI,iBAAiB,UAAU,SAAS;AAC1E,YAAM,MAAM,OAAO;AAAA,IACrB;AAAA,EACF;AACA,QAAM,UAAU,UAAU,KAAK,UAAU,EAAE,KAAK,QAAQ,KAAK,YAAY,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE;AAAA,IACtF,MAAM;AAAA,EACR;AACA,MAAI;AACF,WAAO,MAAM,GAAG;AAAA,EAClB,UAAE;AAGA,UAAM,GAAG,UAAU,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC,EAAE,MAAM,MAAM,MAAS;AAAA,EAC5E;AACF;AAEA,SAAS,SAAS,KAAuB;AACvC,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAS,IAA2B,SAAS;AACzF;AAEA,SAAS,MAAM,IAA2B;AACxC,SAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AACzD;","names":[]}
|
package/dist/doctor-ENJ22XWN.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
collectDoctorChecks,
|
|
4
|
-
renderDoctorHuman,
|
|
5
|
-
runDoctor
|
|
6
|
-
} from "./chunk-6S44OLND.js";
|
|
7
|
-
import "./chunk-GABYDXWL.js";
|
|
8
|
-
import "./chunk-WRWCDLVK.js";
|
|
9
|
-
import "./chunk-GXYNLMUQ.js";
|
|
10
|
-
import "./chunk-WDJTGVKN.js";
|
|
11
|
-
import "./chunk-XBJ3VLWX.js";
|
|
12
|
-
import "./chunk-2I4QTOLB.js";
|
|
13
|
-
import "./chunk-BBUYCDSG.js";
|
|
14
|
-
import "./chunk-UYP7G3GZ.js";
|
|
15
|
-
import "./chunk-J6CVKC4M.js";
|
|
16
|
-
import "./chunk-ZXTAQYNA.js";
|
|
17
|
-
export {
|
|
18
|
-
collectDoctorChecks,
|
|
19
|
-
renderDoctorHuman,
|
|
20
|
-
runDoctor
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=doctor-ENJ22XWN.js.map
|
package/dist/install-7ZIYISQ7.js
DELETED
|
@@ -1,589 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
runWalletCreate
|
|
4
|
-
} from "./chunk-DH6D6QIO.js";
|
|
5
|
-
import {
|
|
6
|
-
collectDoctorChecks,
|
|
7
|
-
recommendedPermissions,
|
|
8
|
-
renderPermissionsBlock
|
|
9
|
-
} from "./chunk-6S44OLND.js";
|
|
10
|
-
import "./chunk-GABYDXWL.js";
|
|
11
|
-
import {
|
|
12
|
-
promptYesNo
|
|
13
|
-
} from "./chunk-QW2Q2KAH.js";
|
|
14
|
-
import {
|
|
15
|
-
describeWallet,
|
|
16
|
-
resolveWalletProvider
|
|
17
|
-
} from "./chunk-RGFBBNGP.js";
|
|
18
|
-
import {
|
|
19
|
-
walletFileExists
|
|
20
|
-
} from "./chunk-WRWCDLVK.js";
|
|
21
|
-
import "./chunk-GXYNLMUQ.js";
|
|
22
|
-
import "./chunk-WDJTGVKN.js";
|
|
23
|
-
import "./chunk-XBJ3VLWX.js";
|
|
24
|
-
import "./chunk-2I4QTOLB.js";
|
|
25
|
-
import {
|
|
26
|
-
sanitizeForTerminal
|
|
27
|
-
} from "./chunk-BBUYCDSG.js";
|
|
28
|
-
import {
|
|
29
|
-
persistInstallHarness,
|
|
30
|
-
persistPublishMode
|
|
31
|
-
} from "./chunk-GM4RZUVU.js";
|
|
32
|
-
import "./chunk-DAJ56EUU.js";
|
|
33
|
-
import "./chunk-YBMMV4Y4.js";
|
|
34
|
-
import "./chunk-UO22YNY4.js";
|
|
35
|
-
import {
|
|
36
|
-
CLI_SKILL_NAMES,
|
|
37
|
-
CONFIG_DEFAULTS,
|
|
38
|
-
HARNESS_TARGETS,
|
|
39
|
-
HOSTED_SKILL_NAME,
|
|
40
|
-
PublishModeSchema,
|
|
41
|
-
SKILL_NAMES,
|
|
42
|
-
harnessDetectedBy,
|
|
43
|
-
harnessTargetDir,
|
|
44
|
-
isModelInvocationDisabled,
|
|
45
|
-
loadRawConfig,
|
|
46
|
-
onPath,
|
|
47
|
-
parsePublishModeFlag,
|
|
48
|
-
resolveSkillsSource
|
|
49
|
-
} from "./chunk-UYP7G3GZ.js";
|
|
50
|
-
import {
|
|
51
|
-
CliError,
|
|
52
|
-
external_exports,
|
|
53
|
-
writeFileAtomic
|
|
54
|
-
} from "./chunk-J6CVKC4M.js";
|
|
55
|
-
import "./chunk-MJZZTKCC.js";
|
|
56
|
-
import "./chunk-7FK2UN2T.js";
|
|
57
|
-
import "./chunk-M2O56UK7.js";
|
|
58
|
-
import "./chunk-UHTVXQ2O.js";
|
|
59
|
-
import "./chunk-W6R3HAAG.js";
|
|
60
|
-
import "./chunk-U5S527PP.js";
|
|
61
|
-
import "./chunk-47PP7TAG.js";
|
|
62
|
-
import "./chunk-XJN5WUKL.js";
|
|
63
|
-
import "./chunk-RBJPAZFI.js";
|
|
64
|
-
import "./chunk-KYQVEKP5.js";
|
|
65
|
-
import "./chunk-ZXTAQYNA.js";
|
|
66
|
-
|
|
67
|
-
// src/commands/install.ts
|
|
68
|
-
import { existsSync } from "fs";
|
|
69
|
-
import { readFile, readdir, rm } from "fs/promises";
|
|
70
|
-
import { createInterface } from "readline";
|
|
71
|
-
import { fileURLToPath } from "url";
|
|
72
|
-
import { join, relative } from "path";
|
|
73
|
-
import { homedir } from "os";
|
|
74
|
-
import { styleText } from "util";
|
|
75
|
-
import { Stream } from "stream";
|
|
76
|
-
var HARNESSES = HARNESS_TARGETS;
|
|
77
|
-
var InstallInputSchema = external_exports.object({
|
|
78
|
-
harness: external_exports.array(external_exports.string()).optional(),
|
|
79
|
-
dryRun: external_exports.boolean().optional(),
|
|
80
|
-
publishMode: external_exports.string().optional(),
|
|
81
|
-
noWallet: external_exports.boolean().optional(),
|
|
82
|
-
/** Tri-state opt-in for the ~/.claude/CLAUDE.md nudge: true (--claude-md), false
|
|
83
|
-
* (--no-claude-md), or undefined (ask interactively, else skip). */
|
|
84
|
-
claudeMd: external_exports.boolean().optional()
|
|
85
|
-
});
|
|
86
|
-
var SKILLS_MARKER = "<!-- tenjin-cli:skills -->";
|
|
87
|
-
function nudgeLine(skillsDir) {
|
|
88
|
-
return `${SKILLS_MARKER} Tenjin: before regenerating public research (version-specific compatibility, integration gotchas, benchmarks, dated probes), run 'tenjin search "<question>" --json' first; it is free and anonymous but sends the generalized question text to tenjin.blog, so strip private identifiers. Skills (tenjin-search, tenjin-publish, tenjin) are installed at ${skillsDir}; read the relevant SKILL.md before using the CLI.`;
|
|
89
|
-
}
|
|
90
|
-
function upsertMarkerLine(existing, line) {
|
|
91
|
-
const text = existing ?? "";
|
|
92
|
-
if (!text.includes(SKILLS_MARKER)) {
|
|
93
|
-
const prefix = text.length === 0 || text.endsWith("\n") ? "" : "\n";
|
|
94
|
-
return { content: `${text}${prefix}${line}
|
|
95
|
-
`, change: "append" };
|
|
96
|
-
}
|
|
97
|
-
const lines = text.split("\n");
|
|
98
|
-
const idx = lines.findIndex((l) => l.includes(SKILLS_MARKER));
|
|
99
|
-
if (lines[idx] === line) return { content: null, change: "none" };
|
|
100
|
-
lines[idx] = line;
|
|
101
|
-
return { content: lines.join("\n"), change: "replace" };
|
|
102
|
-
}
|
|
103
|
-
var CODEX_NETWORK_RULE = "[sandbox_workspace_write]\nnetwork_access = true";
|
|
104
|
-
async function runInstall(input, ctx, deps = {}) {
|
|
105
|
-
const parsed = InstallInputSchema.safeParse(input);
|
|
106
|
-
if (!parsed.success) {
|
|
107
|
-
throw new CliError("USAGE", "Invalid install options", {
|
|
108
|
-
fix: "Run `tenjin install --help`.",
|
|
109
|
-
details: parsed.error.issues
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
const dryRun = parsed.data.dryRun === true;
|
|
113
|
-
const noWallet = parsed.data.noWallet === true;
|
|
114
|
-
const claudeMdFlag = parsed.data.claudeMd;
|
|
115
|
-
const publishModeFlag = parsed.data.publishMode !== void 0 ? parseModeFlag(parsed.data.publishMode) : void 0;
|
|
116
|
-
const env = deps.env ?? process.env;
|
|
117
|
-
const home = deps.homeDir ?? homedir();
|
|
118
|
-
const which = deps.which ?? ((bin) => onPath(bin, env));
|
|
119
|
-
const humanOutput = ctx.flags.json === true ? false : deps.isInteractive ?? ctx.io.isTTY;
|
|
120
|
-
const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));
|
|
121
|
-
const skillsSource = deps.skillsSourceDir ?? resolveSkillsSource(fileURLToPath(new URL(".", import.meta.url)));
|
|
122
|
-
await assertSkillsSource(skillsSource);
|
|
123
|
-
const plans = resolvePlans(parsed.data.harness, home, which);
|
|
124
|
-
const explicitHarness = parsed.data.harness !== void 0 && parsed.data.harness.length > 0;
|
|
125
|
-
const claudeMdWrite = plans.some((p) => p.harness === "claude") ? await decideClaudeMd(claudeMdFlag, canPrompt, dryRun, deps) : false;
|
|
126
|
-
const harnesses = [];
|
|
127
|
-
for (const plan of plans) {
|
|
128
|
-
harnesses.push(await applyPlan(plan, skillsSource, dryRun, claudeMdWrite));
|
|
129
|
-
}
|
|
130
|
-
await assertSkillsLanded(plans, dryRun);
|
|
131
|
-
if (explicitHarness && !dryRun) {
|
|
132
|
-
await persistInstallHarness(
|
|
133
|
-
ctx.dataDir,
|
|
134
|
-
plans.map((p) => p.harness)
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
const doctorDeps = { ...deps.doctorDeps ?? {} };
|
|
138
|
-
doctorDeps.homeDir ??= home;
|
|
139
|
-
doctorDeps.which ??= which;
|
|
140
|
-
const collect = deps.collectChecks ?? ((c) => collectDoctorChecks(c, doctorDeps));
|
|
141
|
-
const doctor = await collect(ctx);
|
|
142
|
-
const publishMode = await selectPublishMode(publishModeFlag, ctx, deps, dryRun, canPrompt);
|
|
143
|
-
const data = {
|
|
144
|
-
dryRun,
|
|
145
|
-
skillsSource,
|
|
146
|
-
harnesses,
|
|
147
|
-
doctor: { status: doctor.failure !== void 0 ? "fail" : "pass", checks: doctor.checks },
|
|
148
|
-
publishMode,
|
|
149
|
-
// Shipped with the install rather than left for the operator to discover after
|
|
150
|
-
// their first auto-mode denial (#33). Static constants, no config key: see
|
|
151
|
-
// lib/permissions.ts for why this is deliberately not operator-editable state.
|
|
152
|
-
permissions: recommendedPermissions()
|
|
153
|
-
};
|
|
154
|
-
if (!humanOutput) return { data };
|
|
155
|
-
const humanLines = await buildWalkthrough(ctx, deps, {
|
|
156
|
-
dryRun,
|
|
157
|
-
noWallet,
|
|
158
|
-
canPrompt,
|
|
159
|
-
harnesses,
|
|
160
|
-
publishMode,
|
|
161
|
-
doctor
|
|
162
|
-
});
|
|
163
|
-
return { data, humanLines };
|
|
164
|
-
}
|
|
165
|
-
var EXAMPLE_QUESTION = "what actually changed in <library> v3's public API";
|
|
166
|
-
async function buildWalkthrough(ctx, deps, s) {
|
|
167
|
-
const io = ctx.io;
|
|
168
|
-
const lines = [];
|
|
169
|
-
if (s.dryRun) lines.push(paint(io, "yellow", "Dry run: nothing was written."));
|
|
170
|
-
lines.push(...skillsWalkthrough(io, s.harnesses, s.dryRun), "");
|
|
171
|
-
lines.push(
|
|
172
|
-
`${paint(io, "bold", `publish mode: ${s.publishMode.value}`)} ${paint(io, "dim", modeBlurb(s.publishMode.value))}`,
|
|
173
|
-
""
|
|
174
|
-
);
|
|
175
|
-
lines.push(...await walletWalkthrough(ctx, deps, s.dryRun || !s.canPrompt, s.noWallet, io), "");
|
|
176
|
-
lines.push(...doctorSummary(io, s.doctor), "");
|
|
177
|
-
lines.push(...permissionsWalkthrough(io), "");
|
|
178
|
-
lines.push(`Done. Try: tenjin search "${EXAMPLE_QUESTION}"`);
|
|
179
|
-
return lines;
|
|
180
|
-
}
|
|
181
|
-
function permissionsWalkthrough(io) {
|
|
182
|
-
const [heading, ...rest] = renderPermissionsBlock();
|
|
183
|
-
return [paint(io, "bold", heading ?? ""), ...rest];
|
|
184
|
-
}
|
|
185
|
-
function harnessLabel(h) {
|
|
186
|
-
return h === "claude" ? "Claude Code" : h === "codex" ? "Codex" : "Agent Skills";
|
|
187
|
-
}
|
|
188
|
-
function skillsWalkthrough(io, harnesses, dryRun) {
|
|
189
|
-
const lines = [];
|
|
190
|
-
for (const h of harnesses) {
|
|
191
|
-
const n = h.skills.length;
|
|
192
|
-
const changed = h.skills.some((s) => s.status !== "up-to-date");
|
|
193
|
-
const verb = dryRun ? "would install" : changed ? "installed" : "up to date";
|
|
194
|
-
const wired = [];
|
|
195
|
-
if (h.agentsMd !== void 0) wired.push("AGENTS.md nudge");
|
|
196
|
-
if (h.claudeMd !== void 0 && h.claudeMd.status !== "skipped") wired.push("CLAUDE.md nudge");
|
|
197
|
-
const suffix = wired.length > 0 ? ` + ${wired.join(" + ")}` : "";
|
|
198
|
-
lines.push(
|
|
199
|
-
`${paint(io, "green", "\u2713")} ${harnessLabel(h.harness)}: ${n} skills ${verb}${suffix}`
|
|
200
|
-
);
|
|
201
|
-
lines.push(paint(io, "dim", ` ${skillRoster(h)} in ${h.skillsDir}`));
|
|
202
|
-
if (h.hostedPreexisting) {
|
|
203
|
-
lines.push(
|
|
204
|
-
paint(
|
|
205
|
-
io,
|
|
206
|
-
"dim",
|
|
207
|
-
` The hosted ${HOSTED_SKILL_NAME} skill was already here: kept as the zero-install fallback, and the CLI skills now take precedence.`
|
|
208
|
-
)
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
const nudgePaths = nudgeFilesTouched(h);
|
|
212
|
-
if (nudgePaths.length > 0) {
|
|
213
|
-
lines.push(
|
|
214
|
-
paint(
|
|
215
|
-
io,
|
|
216
|
-
"dim",
|
|
217
|
-
" The nudge tells agents to run a free anonymous `tenjin search` before regenerating research; the generalized question text is sent to tenjin.blog."
|
|
218
|
-
)
|
|
219
|
-
);
|
|
220
|
-
lines.push(
|
|
221
|
-
paint(
|
|
222
|
-
io,
|
|
223
|
-
"dim",
|
|
224
|
-
` Undo anytime: delete the ${SKILLS_MARKER} line from ${nudgePaths.join(" and ")}.`
|
|
225
|
-
)
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
if (h.claudeMd?.status === "skipped") {
|
|
229
|
-
lines.push(
|
|
230
|
-
paint(
|
|
231
|
-
io,
|
|
232
|
-
"dim",
|
|
233
|
-
" Add a Tenjin search nudge to ~/.claude/CLAUDE.md later: tenjin install --harness claude --claude-md"
|
|
234
|
-
)
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
if (h.codexNetworkRule !== void 0) {
|
|
238
|
-
lines.push(
|
|
239
|
-
paint(io, "dim", " Codex blocks network by default; add to ~/.codex/config.toml:")
|
|
240
|
-
);
|
|
241
|
-
for (const rl of h.codexNetworkRule.split("\n")) lines.push(paint(io, "dim", ` ${rl}`));
|
|
242
|
-
}
|
|
243
|
-
for (const w of h.warnings) lines.push(paint(io, "yellow", ` ! ${w}`));
|
|
244
|
-
}
|
|
245
|
-
return lines;
|
|
246
|
-
}
|
|
247
|
-
function skillRoster(h) {
|
|
248
|
-
const cli = h.skills.filter((s) => s.cli).map((s) => s.name);
|
|
249
|
-
const hosted = h.skills.filter((s) => !s.cli).map((s) => s.name);
|
|
250
|
-
const parts = [];
|
|
251
|
-
if (cli.length > 0) parts.push(`${cli.join(", ")} (CLI)`);
|
|
252
|
-
if (hosted.length > 0) parts.push(`${hosted.join(", ")} (hosted, zero-install fallback)`);
|
|
253
|
-
return parts.join("; ");
|
|
254
|
-
}
|
|
255
|
-
function nudgeFilesTouched(h) {
|
|
256
|
-
const paths = [];
|
|
257
|
-
if (h.agentsMd !== void 0 && ["appended", "updated", "would-append", "would-update"].includes(h.agentsMd.status)) {
|
|
258
|
-
paths.push(h.agentsMd.path);
|
|
259
|
-
}
|
|
260
|
-
if (h.claudeMd !== void 0 && ["written", "updated", "would-write", "would-update"].includes(h.claudeMd.status)) {
|
|
261
|
-
paths.push(h.claudeMd.path);
|
|
262
|
-
}
|
|
263
|
-
return paths;
|
|
264
|
-
}
|
|
265
|
-
function modeBlurb(v) {
|
|
266
|
-
return v === "review" ? "asks before every publish" : v === "auto" ? "publishes clean scans automatically" : "only detected secrets stop a publish";
|
|
267
|
-
}
|
|
268
|
-
async function walletWalkthrough(ctx, deps, skipCreate, noWallet, io) {
|
|
269
|
-
const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);
|
|
270
|
-
if (exists) {
|
|
271
|
-
const address2 = await (deps.walletAddress ?? existingWalletAddress)(ctx);
|
|
272
|
-
return [`${paint(io, "bold", "Wallet:")} ${address2} (existing)`];
|
|
273
|
-
}
|
|
274
|
-
const later = `${paint(io, "bold", "Wallet:")} none. Create one later with: tenjin wallet create`;
|
|
275
|
-
if (skipCreate || noWallet) return [later];
|
|
276
|
-
const confirm = deps.confirmWallet ?? defaultConfirmYesNo;
|
|
277
|
-
if (!await confirm("Create a wallet now? [Y/n] ")) return [later];
|
|
278
|
-
const address = await (deps.createWallet ?? defaultCreateWallet)(ctx);
|
|
279
|
-
return [
|
|
280
|
-
paint(io, "bold", "Wallet created:"),
|
|
281
|
-
` ${address}`,
|
|
282
|
-
" Fund it: send a few dollars of USDC on Base to that address (this is a pocket-money wallet; keep it small).",
|
|
283
|
-
" Check with: tenjin wallet balance"
|
|
284
|
-
];
|
|
285
|
-
}
|
|
286
|
-
async function existingWalletAddress(ctx) {
|
|
287
|
-
return (await describeWallet(resolveWalletProvider(ctx))).address;
|
|
288
|
-
}
|
|
289
|
-
async function defaultCreateWallet(ctx) {
|
|
290
|
-
const result = await runWalletCreate(ctx);
|
|
291
|
-
return result.data.address;
|
|
292
|
-
}
|
|
293
|
-
function defaultConfirmYesNo(label) {
|
|
294
|
-
return promptYesNo(label, { defaultYes: true });
|
|
295
|
-
}
|
|
296
|
-
function doctorSummary(io, doctor) {
|
|
297
|
-
const problems = doctor.checks.filter((c) => c.status !== "ok");
|
|
298
|
-
if (problems.length === 0) return [`${paint(io, "green", "\u2713")} Everything checks out`];
|
|
299
|
-
const lines = [paint(io, "yellow", "Some checks need attention:")];
|
|
300
|
-
for (const c of problems) {
|
|
301
|
-
const icon = c.status === "fail" ? paint(io, "red", "\u2717") : paint(io, "yellow", "!");
|
|
302
|
-
lines.push(` ${icon} ${c.name}: ${sanitizeForTerminal(c.detail)}`);
|
|
303
|
-
if (c.fix !== void 0) {
|
|
304
|
-
lines.push(paint(io, "dim", ` fix: ${sanitizeForTerminal(c.fix)}`));
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return lines;
|
|
308
|
-
}
|
|
309
|
-
var DEFAULT_MODE = CONFIG_DEFAULTS.publish.mode;
|
|
310
|
-
var PUBLISH_MODE_PROMPT = [
|
|
311
|
-
"Publish consent mode?",
|
|
312
|
-
" review - asks a yes/no for every publish",
|
|
313
|
-
" auto - publishes automatically when the secret-scan is clean (including answers your agent derives)",
|
|
314
|
-
" full-auto - publishes even past warnings; only detected secrets stop it",
|
|
315
|
-
`[${DEFAULT_MODE}]: `
|
|
316
|
-
].join("\n");
|
|
317
|
-
async function selectPublishMode(flag, ctx, deps, dryRun, interactive) {
|
|
318
|
-
if (flag !== void 0) {
|
|
319
|
-
if (!dryRun) await persistPublishMode(ctx.dataDir, flag);
|
|
320
|
-
return { value: flag, source: "flag" };
|
|
321
|
-
}
|
|
322
|
-
const config = await loadRawConfig(ctx.dataDir);
|
|
323
|
-
if (config.publish?.mode !== void 0) {
|
|
324
|
-
return { value: config.publish.mode, source: "existing" };
|
|
325
|
-
}
|
|
326
|
-
if (dryRun || !interactive) return { value: DEFAULT_MODE, source: "default-skipped" };
|
|
327
|
-
const prompt = deps.promptMode ?? defaultPromptMode;
|
|
328
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
329
|
-
const answer = (await prompt(PUBLISH_MODE_PROMPT)).trim();
|
|
330
|
-
if (answer.length === 0) return { value: DEFAULT_MODE, source: "default-skipped" };
|
|
331
|
-
const parsed = PublishModeSchema.safeParse(answer);
|
|
332
|
-
if (parsed.success) {
|
|
333
|
-
await persistPublishMode(ctx.dataDir, parsed.data);
|
|
334
|
-
return { value: parsed.data, source: "prompt" };
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
ctx.io.stderr.write(
|
|
338
|
-
`Unrecognized mode; keeping the default (${DEFAULT_MODE}). Change it with \`tenjin config set publish.mode\`.
|
|
339
|
-
`
|
|
340
|
-
);
|
|
341
|
-
return { value: DEFAULT_MODE, source: "default-skipped" };
|
|
342
|
-
}
|
|
343
|
-
function parseModeFlag(value) {
|
|
344
|
-
return parsePublishModeFlag(value, "--publish-mode");
|
|
345
|
-
}
|
|
346
|
-
function defaultPromptMode(label) {
|
|
347
|
-
return new Promise((resolve) => {
|
|
348
|
-
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
349
|
-
let settled = false;
|
|
350
|
-
const settle = (value) => {
|
|
351
|
-
if (settled) return;
|
|
352
|
-
settled = true;
|
|
353
|
-
rl.close();
|
|
354
|
-
resolve(value);
|
|
355
|
-
};
|
|
356
|
-
rl.once("close", () => settle(""));
|
|
357
|
-
rl.question(label, (answer) => settle(answer));
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
function resolvePlans(override, home, which) {
|
|
361
|
-
if (override !== void 0 && override.length > 0) {
|
|
362
|
-
const plans2 = override.map((v) => planFor(validateHarness(v), ["override"], true, home));
|
|
363
|
-
return dedupeBySkillsDir(plans2);
|
|
364
|
-
}
|
|
365
|
-
const plans = [];
|
|
366
|
-
const claudeBy = harnessDetectedBy(home, "claude", which);
|
|
367
|
-
const codexBy = harnessDetectedBy(home, "codex", which);
|
|
368
|
-
if (claudeBy.length > 0) plans.push(planFor("claude", claudeBy, true, home));
|
|
369
|
-
if (codexBy.length > 0) plans.push(planFor("codex", codexBy, true, home));
|
|
370
|
-
if (plans.length === 0) {
|
|
371
|
-
plans.push(planFor("shared", ["fallback"], false, home));
|
|
372
|
-
}
|
|
373
|
-
return dedupeBySkillsDir(plans);
|
|
374
|
-
}
|
|
375
|
-
function planFor(harness, detectedBy, detected, home) {
|
|
376
|
-
const skillsDir = harnessTargetDir(home, harness);
|
|
377
|
-
return { harness, detected, detectedBy, skillsDir, wiresAgentsMd: harness !== "claude", home };
|
|
378
|
-
}
|
|
379
|
-
function dedupeBySkillsDir(plans) {
|
|
380
|
-
const seen = /* @__PURE__ */ new Set();
|
|
381
|
-
const out = [];
|
|
382
|
-
for (const p of plans) {
|
|
383
|
-
if (seen.has(p.skillsDir)) continue;
|
|
384
|
-
seen.add(p.skillsDir);
|
|
385
|
-
out.push(p);
|
|
386
|
-
}
|
|
387
|
-
return out;
|
|
388
|
-
}
|
|
389
|
-
function validateHarness(value) {
|
|
390
|
-
if (HARNESSES.includes(value)) return value;
|
|
391
|
-
throw new CliError("USAGE", `Unknown harness "${value}"`, {
|
|
392
|
-
fix: `--harness must be one of: ${HARNESSES.join(", ")}.`
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
async function applyPlan(plan, skillsSource, dryRun, claudeMdWrite) {
|
|
396
|
-
const skills = [];
|
|
397
|
-
const warnings = [];
|
|
398
|
-
for (const name of SKILL_NAMES) {
|
|
399
|
-
const { status, warning, preexisting } = await installSkill(
|
|
400
|
-
join(skillsSource, name),
|
|
401
|
-
join(plan.skillsDir, name),
|
|
402
|
-
dryRun,
|
|
403
|
-
name
|
|
404
|
-
);
|
|
405
|
-
skills.push({
|
|
406
|
-
name,
|
|
407
|
-
status,
|
|
408
|
-
preexisting,
|
|
409
|
-
cli: CLI_SKILL_NAMES.includes(name),
|
|
410
|
-
modelInvocable: await landedInvocable(plan.skillsDir, skillsSource, name, dryRun)
|
|
411
|
-
});
|
|
412
|
-
if (warning !== void 0) warnings.push(warning);
|
|
413
|
-
}
|
|
414
|
-
const hostedPreexisting = skills.some((s) => s.name === HOSTED_SKILL_NAME && s.preexisting);
|
|
415
|
-
const result = {
|
|
416
|
-
harness: plan.harness,
|
|
417
|
-
detected: plan.detected,
|
|
418
|
-
detectedBy: plan.detectedBy,
|
|
419
|
-
skillsDir: plan.skillsDir,
|
|
420
|
-
skills,
|
|
421
|
-
hostedPreexisting,
|
|
422
|
-
notes: notesFor(plan, hostedPreexisting),
|
|
423
|
-
warnings
|
|
424
|
-
};
|
|
425
|
-
if (plan.wiresAgentsMd) {
|
|
426
|
-
result.agentsMd = await wireAgentsMd(plan, dryRun);
|
|
427
|
-
result.codexNetworkRule = CODEX_NETWORK_RULE;
|
|
428
|
-
} else if (plan.harness === "claude") {
|
|
429
|
-
result.claudeMd = await wireClaudeMd(plan, dryRun, claudeMdWrite);
|
|
430
|
-
}
|
|
431
|
-
return result;
|
|
432
|
-
}
|
|
433
|
-
async function decideClaudeMd(flag, canPrompt, dryRun, deps) {
|
|
434
|
-
if (flag !== void 0) return flag;
|
|
435
|
-
if (dryRun || !canPrompt) return false;
|
|
436
|
-
const confirm = deps.confirmClaudeMd ?? defaultConfirmYesNo;
|
|
437
|
-
return confirm(
|
|
438
|
-
"Add a one-line nudge to ~/.claude/CLAUDE.md telling agents to try a free Tenjin search before regenerating research? It sends only generalized question text to tenjin.blog. [Y/n] "
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
async function wireClaudeMd(plan, dryRun, write) {
|
|
442
|
-
const path = join(plan.home, ".claude", "CLAUDE.md");
|
|
443
|
-
if (!write) return { path, status: "skipped" };
|
|
444
|
-
const existing = existsSync(path) ? await readFile(path, "utf8") : null;
|
|
445
|
-
const { content, change } = upsertMarkerLine(existing, nudgeLine(plan.skillsDir));
|
|
446
|
-
if (change === "none") return { path, status: "up-to-date" };
|
|
447
|
-
if (!dryRun && content !== null) await writeFileAtomic(path, content);
|
|
448
|
-
if (change === "append") return { path, status: dryRun ? "would-write" : "written" };
|
|
449
|
-
return { path, status: dryRun ? "would-update" : "updated" };
|
|
450
|
-
}
|
|
451
|
-
function notesFor(plan, hostedPreexisting) {
|
|
452
|
-
const notes = plan.harness === "claude" ? [
|
|
453
|
-
"Installed at the user level (~/.claude/skills). A Claude Code plugin will later make this automatic."
|
|
454
|
-
] : [
|
|
455
|
-
"Copied into the shared Agent Skills location (~/.agents/skills). Codex and any Agent-Skills-compatible harness read it there."
|
|
456
|
-
];
|
|
457
|
-
if (hostedPreexisting) {
|
|
458
|
-
notes.push(
|
|
459
|
-
`The hosted ${HOSTED_SKILL_NAME} skill was already here; it stays as the zero-install fallback and the CLI skills (${CLI_SKILL_NAMES.join(", ")}) take precedence while the CLI is installed.`
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
return notes;
|
|
463
|
-
}
|
|
464
|
-
async function landedInvocable(skillsDir, skillsSource, name, dryRun) {
|
|
465
|
-
const path = join(dryRun ? skillsSource : skillsDir, name, "SKILL.md");
|
|
466
|
-
if (!existsSync(path)) return false;
|
|
467
|
-
try {
|
|
468
|
-
return !isModelInvocationDisabled(await readFile(path, "utf8"));
|
|
469
|
-
} catch {
|
|
470
|
-
return false;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
async function assertSkillsLanded(plans, dryRun) {
|
|
474
|
-
if (dryRun) return;
|
|
475
|
-
const missing = [];
|
|
476
|
-
for (const plan of plans) {
|
|
477
|
-
for (const name of SKILL_NAMES) {
|
|
478
|
-
if (!existsSync(join(plan.skillsDir, name, "SKILL.md"))) {
|
|
479
|
-
missing.push(join(plan.skillsDir, name));
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
if (missing.length === 0) return;
|
|
484
|
-
throw new CliError("INTERNAL", `Skills were not written: ${missing.join(", ")}`, {
|
|
485
|
-
fix: "Check permissions on the skills directory and re-run `tenjin install`."
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
async function installSkill(srcDir, destDir, dryRun, name) {
|
|
489
|
-
const src = await readTree(srcDir);
|
|
490
|
-
const dest = await readTree(destDir);
|
|
491
|
-
if (src === null) {
|
|
492
|
-
throw new CliError("INTERNAL", `Packaged skill source ${srcDir} is empty`);
|
|
493
|
-
}
|
|
494
|
-
const preexisting = dest?.has("SKILL.md") === true;
|
|
495
|
-
const change = dest === null || dest.size === 0 ? "create" : treesEqual(src, dest) ? "none" : "update";
|
|
496
|
-
if (!dryRun && change !== "none") {
|
|
497
|
-
await rm(destDir, { recursive: true, force: true });
|
|
498
|
-
for (const [rel, content] of src) {
|
|
499
|
-
await writeFileAtomic(join(destDir, rel), content);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
if (change === "create") return { status: dryRun ? "would-install" : "installed", preexisting };
|
|
503
|
-
if (change === "none") return { status: "up-to-date", preexisting };
|
|
504
|
-
return {
|
|
505
|
-
status: dryRun ? "would-update" : "updated",
|
|
506
|
-
preexisting,
|
|
507
|
-
// The hosted skill is a MIRROR of tenjin.blog/skills.md (roadmap G4), so a
|
|
508
|
-
// differing local copy is a replacement, not the drift warning the CLI skills
|
|
509
|
-
// get. Neither side carries a version or date, so the wording claims no
|
|
510
|
-
// direction: the local file may well be a newer fetch than this package's copy.
|
|
511
|
-
warning: name === HOSTED_SKILL_NAME ? `${destDir}: the hosted Tenjin skill differed and ${dryRun ? "would be" : "was"} replaced by this package's mirror of tenjin.blog/skills.md, which may be older; it stays as the zero-install fallback. Re-fetch it from tenjin.blog/skills.md if you need the current one.` : `${destDir}: local skill copy differed and ${dryRun ? "would be" : "was"} overwritten (the packaged copy is canonical).`
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
async function readTree(dir) {
|
|
515
|
-
if (!existsSync(dir)) return null;
|
|
516
|
-
const entries = await readdir(dir, { recursive: true, withFileTypes: true });
|
|
517
|
-
const files = /* @__PURE__ */ new Map();
|
|
518
|
-
for (const entry of entries) {
|
|
519
|
-
if (!entry.isFile()) continue;
|
|
520
|
-
const full = join(entry.parentPath, entry.name);
|
|
521
|
-
files.set(relative(dir, full), await readFile(full));
|
|
522
|
-
}
|
|
523
|
-
return files;
|
|
524
|
-
}
|
|
525
|
-
function treesEqual(a, b) {
|
|
526
|
-
if (b === null) return false;
|
|
527
|
-
if (a.size !== b.size) return false;
|
|
528
|
-
for (const [k, v] of a) {
|
|
529
|
-
const other = b.get(k);
|
|
530
|
-
if (other === void 0 || !v.equals(other)) return false;
|
|
531
|
-
}
|
|
532
|
-
return true;
|
|
533
|
-
}
|
|
534
|
-
async function wireAgentsMd(plan, dryRun) {
|
|
535
|
-
const shared = join(plan.home, ".agents", "AGENTS.md");
|
|
536
|
-
const codex = join(plan.home, ".codex", "AGENTS.md");
|
|
537
|
-
const line = nudgeLine(plan.skillsDir);
|
|
538
|
-
for (const path of [shared, codex]) {
|
|
539
|
-
if (existsSync(path) && (await readFile(path, "utf8")).includes(SKILLS_MARKER)) {
|
|
540
|
-
return upsertAgentsMd(path, line, dryRun);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
return upsertAgentsMd(chooseAgentsMdPath(plan.home), line, dryRun);
|
|
544
|
-
}
|
|
545
|
-
async function upsertAgentsMd(path, line, dryRun) {
|
|
546
|
-
const existing = existsSync(path) ? await readFile(path, "utf8") : null;
|
|
547
|
-
const { content, change } = upsertMarkerLine(existing, line);
|
|
548
|
-
if (change === "none") return { path, status: "already-present" };
|
|
549
|
-
if (!dryRun && content !== null) await writeFileAtomic(path, content);
|
|
550
|
-
if (change === "append") return { path, status: dryRun ? "would-append" : "appended" };
|
|
551
|
-
return { path, status: dryRun ? "would-update" : "updated" };
|
|
552
|
-
}
|
|
553
|
-
function chooseAgentsMdPath(home) {
|
|
554
|
-
const shared = join(home, ".agents", "AGENTS.md");
|
|
555
|
-
const codex = join(home, ".codex", "AGENTS.md");
|
|
556
|
-
if (existsSync(shared)) return shared;
|
|
557
|
-
if (existsSync(codex)) return codex;
|
|
558
|
-
if (existsSync(join(home, ".codex"))) return codex;
|
|
559
|
-
return shared;
|
|
560
|
-
}
|
|
561
|
-
function paint(io, format, text) {
|
|
562
|
-
if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });
|
|
563
|
-
return styleText(format, text);
|
|
564
|
-
}
|
|
565
|
-
async function assertSkillsSource(dir) {
|
|
566
|
-
for (const name of SKILL_NAMES) {
|
|
567
|
-
if (!existsSync(join(dir, name, "SKILL.md"))) {
|
|
568
|
-
throw new CliError("INTERNAL", `Packaged skill "${name}" is missing under ${dir}`, {
|
|
569
|
-
fix: "Reinstall tenjin-cli; the published package must ship every skill under skills/."
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
for (const name of CLI_SKILL_NAMES) {
|
|
574
|
-
const text = await readFile(join(dir, name, "SKILL.md"), "utf8");
|
|
575
|
-
if (isModelInvocationDisabled(text)) {
|
|
576
|
-
throw new CliError(
|
|
577
|
-
"INTERNAL",
|
|
578
|
-
`Packaged skill "${name}" carries disable-model-invocation: true, so no harness would surface it`,
|
|
579
|
-
{
|
|
580
|
-
fix: "Reinstall tenjin-cli; the published CLI skills must be model-invocable."
|
|
581
|
-
}
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
export {
|
|
587
|
-
runInstall
|
|
588
|
-
};
|
|
589
|
-
//# sourceMappingURL=install-7ZIYISQ7.js.map
|