tenjin-cli 0.1.0-alpha.14 → 0.1.0-alpha.15
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 +18 -3
- package/dist/{buy-2JBYPHAI.js → buy-VIRNSYGN.js} +24 -23
- package/dist/{chunk-QWBUKIP2.js → chunk-2MYQN7HM.js} +66 -27
- package/dist/chunk-2MYQN7HM.js.map +1 -0
- package/dist/{chunk-DAZAXFSF.js → chunk-2RF2GIJQ.js} +57 -226
- package/dist/chunk-2RF2GIJQ.js.map +1 -0
- package/dist/{chunk-VEAERJVJ.js → chunk-3GL2Z5QK.js} +23 -9
- package/dist/chunk-3GL2Z5QK.js.map +1 -0
- package/dist/{chunk-IUQZ4Z7M.js → chunk-4CQIDQOT.js} +6 -1
- package/dist/chunk-4CQIDQOT.js.map +1 -0
- package/dist/{chunk-IXZJ3JOO.js → chunk-4KG27W2S.js} +10 -10
- package/dist/chunk-4KG27W2S.js.map +1 -0
- package/dist/{chunk-54AJIO3E.js → chunk-5QQTYWEU.js} +4 -3
- package/dist/chunk-5QQTYWEU.js.map +1 -0
- package/dist/chunk-65DTCCJ7.js +21 -0
- package/dist/chunk-65DTCCJ7.js.map +1 -0
- package/dist/{chunk-7NADDA2V.js → chunk-A5DKHMUN.js} +20 -8
- package/dist/chunk-A5DKHMUN.js.map +1 -0
- package/dist/{chunk-WYLMJQVH.js → chunk-B63XPWQ4.js} +24 -18
- package/dist/chunk-B63XPWQ4.js.map +1 -0
- package/dist/{chunk-L6G35FU5.js → chunk-CAR6FHK6.js} +5 -5
- package/dist/{chunk-7GJQ5RGA.js → chunk-CPCX67TI.js} +20 -22
- package/dist/{chunk-7GJQ5RGA.js.map → chunk-CPCX67TI.js.map} +1 -1
- package/dist/{chunk-XVPQGCH4.js → chunk-CQBVCYI2.js} +36 -50
- package/dist/chunk-CQBVCYI2.js.map +1 -0
- package/dist/chunk-DBU5CXBV.js +4731 -0
- package/dist/chunk-DBU5CXBV.js.map +1 -0
- package/dist/chunk-DHJD77OW.js +81 -0
- package/dist/chunk-DHJD77OW.js.map +1 -0
- package/dist/{chunk-XGZ5EVMB.js → chunk-EDZSNPE5.js} +2 -2
- package/dist/{chunk-736DW4V3.js → chunk-EFWZPUTC.js} +2 -2
- package/dist/chunk-EPFL6CTE.js +448 -0
- package/dist/chunk-EPFL6CTE.js.map +1 -0
- package/dist/{chunk-3P3ES4XU.js → chunk-GHLVXVZD.js} +3 -5
- package/dist/{chunk-3P3ES4XU.js.map → chunk-GHLVXVZD.js.map} +1 -1
- package/dist/{chunk-4UHNXY6B.js → chunk-H3SOOJ2I.js} +88 -294
- package/dist/chunk-H3SOOJ2I.js.map +1 -0
- package/dist/{chunk-MJSXP4LW.js → chunk-HPJGOLTN.js} +6 -8
- package/dist/{chunk-MJSXP4LW.js.map → chunk-HPJGOLTN.js.map} +1 -1
- package/dist/{chunk-J6FUAIRR.js → chunk-HRGBS2PA.js} +4 -6
- package/dist/{chunk-J6FUAIRR.js.map → chunk-HRGBS2PA.js.map} +1 -1
- package/dist/{chunk-FDUD3W5V.js → chunk-ITUXPJIS.js} +55 -58
- package/dist/chunk-ITUXPJIS.js.map +1 -0
- package/dist/{chunk-ETKZWJ4B.js → chunk-JBIKAAT3.js} +2 -2
- package/dist/{chunk-ETKZWJ4B.js.map → chunk-JBIKAAT3.js.map} +1 -1
- package/dist/{chunk-3ZW7HPY5.js → chunk-KAJZHIQ4.js} +13 -10
- package/dist/chunk-KAJZHIQ4.js.map +1 -0
- package/dist/{chunk-OWVVI4VQ.js → chunk-KINZ23CV.js} +107 -4535
- package/dist/chunk-KINZ23CV.js.map +1 -0
- package/dist/{chunk-PCX2JQ2J.js → chunk-LRYV3SK7.js} +9 -7
- package/dist/{chunk-PCX2JQ2J.js.map → chunk-LRYV3SK7.js.map} +1 -1
- package/dist/{chunk-ACBEHJAH.js → chunk-NIKXHWOL.js} +11 -13
- package/dist/{chunk-ACBEHJAH.js.map → chunk-NIKXHWOL.js.map} +1 -1
- package/dist/chunk-OKDRDT74.js +209 -0
- package/dist/chunk-OKDRDT74.js.map +1 -0
- package/dist/chunk-OKYSNAS3.js +2144 -0
- package/dist/chunk-OKYSNAS3.js.map +1 -0
- package/dist/{chunk-B676GPS2.js → chunk-OLWTRUTS.js} +7 -3
- package/dist/{chunk-B676GPS2.js.map → chunk-OLWTRUTS.js.map} +1 -1
- package/dist/{chunk-WU5CZPLD.js → chunk-QQ6ELLSA.js} +6 -8
- package/dist/{chunk-WU5CZPLD.js.map → chunk-QQ6ELLSA.js.map} +1 -1
- package/dist/{chunk-NAAMHWSI.js → chunk-QZ6ROAJU.js} +5 -4
- package/dist/chunk-QZ6ROAJU.js.map +1 -0
- package/dist/{chunk-GEHL43VE.js → chunk-R7RSCBI7.js} +130 -47
- package/dist/chunk-R7RSCBI7.js.map +1 -0
- package/dist/{chunk-LSWP7MU2.js → chunk-U6VPKMGC.js} +127 -27
- package/dist/chunk-U6VPKMGC.js.map +1 -0
- package/dist/{chunk-W4VW5XYB.js → chunk-US456VUI.js} +6 -6
- package/dist/{chunk-O75FOHXS.js → chunk-V44J2MXV.js} +64 -36
- package/dist/chunk-V44J2MXV.js.map +1 -0
- package/dist/{chunk-4Y53PDH6.js → chunk-VJQKL3YH.js} +10 -7
- package/dist/{chunk-4Y53PDH6.js.map → chunk-VJQKL3YH.js.map} +1 -1
- package/dist/{chunk-VRPLZERE.js → chunk-VJSQSLBM.js} +47 -26
- package/dist/chunk-VJSQSLBM.js.map +1 -0
- package/dist/{chunk-PKW3H26Z.js → chunk-VYOJOX4Z.js} +9 -7
- package/dist/chunk-VYOJOX4Z.js.map +1 -0
- package/dist/chunk-WY2K35OL.js +269 -0
- package/dist/chunk-WY2K35OL.js.map +1 -0
- package/dist/{chunk-PAOVPSP6.js → chunk-ZFJJ3EXC.js} +53 -5
- package/dist/chunk-ZFJJ3EXC.js.map +1 -0
- package/dist/{cli-U2BEUA55.js → cli-KKRKBU5T.js} +71 -40
- package/dist/{cli-U2BEUA55.js.map → cli-KKRKBU5T.js.map} +1 -1
- package/dist/config-JMRUNYE6.js +37 -0
- package/dist/discover-B5HF6SHM.js +102 -0
- package/dist/discover-B5HF6SHM.js.map +1 -0
- package/dist/doctor-ZBG7X66D.js +32 -0
- package/dist/edit-PZJIILQE.js +40 -0
- package/dist/{fund-Y5IAHZ5D.js → fund-EUDH5KPA.js} +19 -19
- package/dist/index.js +1 -1
- package/dist/{inspect-NFQ6SQQQ.js → inspect-QC6WEQPN.js} +20 -20
- package/dist/{install-DXX7PVUP.js → install-GNK2W3PI.js} +196 -78
- package/dist/install-GNK2W3PI.js.map +1 -0
- package/dist/outcome-KSGWZHUS.js +24 -0
- package/dist/pay-BC4UICPA.js +361 -0
- package/dist/pay-BC4UICPA.js.map +1 -0
- package/dist/publish-LXWFDIKF.js +42 -0
- package/dist/{read-W7QVRBVD.js → read-JMNUQ56P.js} +21 -21
- package/dist/{run-CJWPGMIQ.js → run-XYTQ5TWQ.js} +52 -45
- package/dist/{run-CJWPGMIQ.js.map → run-XYTQ5TWQ.js.map} +1 -1
- package/dist/search-TSQAB45E.js +25 -0
- package/dist/{send-C5EOKXOU.js → send-G746D7PQ.js} +14 -15
- package/dist/{send-C5EOKXOU.js.map → send-G746D7PQ.js.map} +1 -1
- package/dist/{session-OBCUUIFX.js → session-JBKWMJ24.js} +17 -17
- package/dist/{skill-heal-D6EPLPS6.js → skill-heal-WKD67SLJ.js} +17 -9
- package/dist/skill-heal-WKD67SLJ.js.map +1 -0
- package/dist/skill-placement-RIU4AMC2.js +20 -0
- package/dist/{uninstall-OWJNJ5LI.js → uninstall-5E263VTS.js} +12 -12
- package/dist/uninstall-5E263VTS.js.map +1 -0
- package/dist/{update-24Y2CQTT.js → update-R76LHOZW.js} +7 -8
- package/dist/{update-24Y2CQTT.js.map → update-R76LHOZW.js.map} +1 -1
- package/dist/{wallet-SLRIYJ2U.js → wallet-TQ7D5EQ7.js} +7 -8
- package/dist/{wallet-OFXDIIGP.js → wallet-ZAVXWLWP.js} +11 -12
- package/dist/wallet-ZAVXWLWP.js.map +1 -0
- package/docs/agent-permissions.md +17 -2
- package/docs/command-reference.md +84 -42
- package/docs/safety-model.md +9 -0
- package/package.json +1 -1
- package/skills/tenjin/SKILL.md +38 -29
- package/skills/tenjin-pay/SKILL.md +76 -0
- package/skills/tenjin-publish/SKILL.md +10 -7
- package/skills/tenjin-search/SKILL.md +18 -13
- package/skills/tenjin-search/references/permissions.md +9 -3
- package/dist/chunk-3ZW7HPY5.js.map +0 -1
- package/dist/chunk-4UHNXY6B.js.map +0 -1
- package/dist/chunk-54AJIO3E.js.map +0 -1
- package/dist/chunk-7NADDA2V.js.map +0 -1
- package/dist/chunk-DAZAXFSF.js.map +0 -1
- package/dist/chunk-DTCXO7HS.js +0 -791
- package/dist/chunk-DTCXO7HS.js.map +0 -1
- package/dist/chunk-FDUD3W5V.js.map +0 -1
- package/dist/chunk-GEHL43VE.js.map +0 -1
- package/dist/chunk-IU2HVT3Y.js +0 -313
- package/dist/chunk-IU2HVT3Y.js.map +0 -1
- package/dist/chunk-IUQZ4Z7M.js.map +0 -1
- package/dist/chunk-IXZJ3JOO.js.map +0 -1
- package/dist/chunk-LSWP7MU2.js.map +0 -1
- package/dist/chunk-NAAMHWSI.js.map +0 -1
- package/dist/chunk-O75FOHXS.js.map +0 -1
- package/dist/chunk-OWVVI4VQ.js.map +0 -1
- package/dist/chunk-PAOVPSP6.js.map +0 -1
- package/dist/chunk-PKW3H26Z.js.map +0 -1
- package/dist/chunk-PQZVDCCA.js +0 -125
- package/dist/chunk-PQZVDCCA.js.map +0 -1
- package/dist/chunk-QWBUKIP2.js.map +0 -1
- package/dist/chunk-VEAERJVJ.js.map +0 -1
- package/dist/chunk-VRPLZERE.js.map +0 -1
- package/dist/chunk-WYLMJQVH.js.map +0 -1
- package/dist/chunk-XVPQGCH4.js.map +0 -1
- package/dist/chunk-ZQIQ55KK.js +0 -51
- package/dist/chunk-ZQIQ55KK.js.map +0 -1
- package/dist/config-CNUIX23Q.js +0 -32
- package/dist/doctor-QJJXRWTO.js +0 -31
- package/dist/edit-HJ44P44P.js +0 -40
- package/dist/install-DXX7PVUP.js.map +0 -1
- package/dist/outcome-ANV4QIED.js +0 -24
- package/dist/publish-PCBTCXCZ.js +0 -42
- package/dist/search-JGAVKTYJ.js +0 -25
- package/dist/skill-heal-D6EPLPS6.js.map +0 -1
- package/dist/uninstall-OWJNJ5LI.js.map +0 -1
- /package/dist/{buy-2JBYPHAI.js.map → buy-VIRNSYGN.js.map} +0 -0
- /package/dist/{chunk-L6G35FU5.js.map → chunk-CAR6FHK6.js.map} +0 -0
- /package/dist/{chunk-XGZ5EVMB.js.map → chunk-EDZSNPE5.js.map} +0 -0
- /package/dist/{chunk-736DW4V3.js.map → chunk-EFWZPUTC.js.map} +0 -0
- /package/dist/{chunk-W4VW5XYB.js.map → chunk-US456VUI.js.map} +0 -0
- /package/dist/{config-CNUIX23Q.js.map → config-JMRUNYE6.js.map} +0 -0
- /package/dist/{doctor-QJJXRWTO.js.map → doctor-ZBG7X66D.js.map} +0 -0
- /package/dist/{edit-HJ44P44P.js.map → edit-PZJIILQE.js.map} +0 -0
- /package/dist/{fund-Y5IAHZ5D.js.map → fund-EUDH5KPA.js.map} +0 -0
- /package/dist/{inspect-NFQ6SQQQ.js.map → inspect-QC6WEQPN.js.map} +0 -0
- /package/dist/{outcome-ANV4QIED.js.map → outcome-KSGWZHUS.js.map} +0 -0
- /package/dist/{publish-PCBTCXCZ.js.map → publish-LXWFDIKF.js.map} +0 -0
- /package/dist/{read-W7QVRBVD.js.map → read-JMNUQ56P.js.map} +0 -0
- /package/dist/{search-JGAVKTYJ.js.map → search-TSQAB45E.js.map} +0 -0
- /package/dist/{session-OBCUUIFX.js.map → session-JBKWMJ24.js.map} +0 -0
- /package/dist/{wallet-OFXDIIGP.js.map → skill-placement-RIU4AMC2.js.map} +0 -0
- /package/dist/{wallet-SLRIYJ2U.js.map → wallet-TQ7D5EQ7.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/uninstall.ts"],"sourcesContent":["import { lstat, readFile, readdir, rm, rmdir, realpath } from 'node:fs/promises';\nimport { lstatSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { writeFileAtomic } from './atomic-json';\nimport {\n claudeSettingsPath,\n FREE_VERB_RULES,\n LEGACY_ALLOWLIST_RULES,\n MODE_GATED_RULES,\n} from './harness-permissions';\nimport { STOP_HOOK_FILE, WEBSEARCH_HOOK_FILE } from './hook-scripts';\nimport { hooksDir } from './paths';\nimport { SHIPPED_SKILL_FILES } from './skills-source';\nimport { resolveThroughLink } from './skill-writer';\nimport {\n CLI_SKILL_NAMES,\n HOSTED_SKILL_NAME,\n readSkillFile,\n skillFrontmatterName,\n skillsDirsFor,\n} from './skill-wiring';\n\n/**\n * The reverse of `install`, and ONLY of `install`.\n *\n * Every removal here is gated on OWNERSHIP rather than position or path alone,\n * reusing the rules the writers already use: a hook entry is ours when its\n * command names one of our two script filenames (lib/harness-hooks.ts), a skill\n * directory is ours when its SKILL.md frontmatter claims our skill's name\n * (lib/skill-heal.ts), a permission rule is ours when it is one of the free-verb\n * rules we wrote. Anything that merely sits at one of our paths belongs to\n * somebody else and is left alone.\n *\n * WHAT IS NEVER TOUCHED: anything under the data dir. The wallet, the config,\n * the library receipts, the search ledger, and whatever an older version left\n * in `candidates/` are all the operator's property, and their loss is\n * unrecoverable (a wallet holds funds). `install` did not create them, so\n * uninstall does not remove them, and the command says so in its own output\n * rather than leaving it to the docs.\n *\n * SETTINGS.JSON IS EDITED IN ONE PASS. Hooks and permission rules live in the\n * same file, so removing them separately would mean two whole-file\n * read-modify-writes and two chances to lose a concurrent edit by Claude Code.\n * One pass, one optimistic-concurrency check, one refusal.\n */\n\n/** Everything the command found and acted on, for both the receipt and the JSON. */\nexport interface UninstallReport {\n settings: SettingsOutcome;\n skills: string[];\n scripts: string[];\n hooksDir?: string;\n markers: string[];\n kept: string[];\n}\n\nexport interface SettingsOutcome {\n path: string;\n /** Hook events whose entry was ours and was removed. */\n hooks: string[];\n /** Free-verb rules removed from `permissions.allow`. */\n rules: string[];\n /** Absent when the file was edited (or had nothing of ours in it). */\n skipped?: SettingsSkipReason;\n warning?: string;\n}\n\nexport type SettingsSkipReason =\n | 'absent'\n | 'unresolvable'\n | 'unreadable'\n | 'unparsable'\n | 'unexpected-shape'\n | 'changed-since-read';\n\n/**\n * What uninstall deliberately leaves behind, named in the output every run.\n *\n * Stated as one rule and its ONE exception, rather than an inventory: everything\n * under the data dir is the operator's, so a list edited every time a file is\n * added or retired is a list that will eventually be wrong. The exception has to\n * be named, though. `~/.tenjin/hooks/*.mjs` is generated by `install`, is deleted\n * here, and is under the same directory the rule calls untouched, so the\n * unqualified version contradicted what the run in front of the operator had just\n * reported removing. `candidates/` is named explicitly because it is the one\n * directory nothing writes any more: an older version's parked drafts are still\n * sitting there, and someone who wants them needs the path.\n *\n * `publish.mode` is called out inside the config item because it is the one kept\n * value that GRANTS something on the next `install`: the rules come back under the\n * remembered mode. That is the intended model (installing is the consent, each\n * time), and docs/agent-permissions.md carries the full paragraph, but an operator\n * uninstalling to revoke should not have to find it there.\n */\nexport const KEPT_ITEMS: readonly string[] = [\n 'your wallet, config (publish.mode included, so a later install resumes it), library, and search history under ~/.tenjin',\n 'anything an older version left in ~/.tenjin/candidates (nothing reads it now)',\n];\n\n/**\n * The one thing under the data dir this command DOES remove, named beside\n * {@link KEPT_ITEMS} so the boundary reads as a boundary.\n */\nexport const REMOVED_FROM_DATA_DIR =\n 'the generated hook scripts in ~/.tenjin/hooks (install writes them back)';\n\n/** The legacy pointer line `install` used to write into CLAUDE.md / AGENTS.md. */\nexport const SKILLS_MARKER = '<!-- tenjin-cli:skills -->';\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Ours by the same rule that wrote it: the command names one of our scripts. */\nfunction ownsHookEntry(entry: unknown): boolean {\n if (!isPlainObject(entry)) return false;\n const handlers = entry.hooks;\n if (!Array.isArray(handlers)) return false;\n return handlers.some(\n (h) =>\n isPlainObject(h) &&\n typeof h.command === 'string' &&\n (h.command.includes(WEBSEARCH_HOOK_FILE) || h.command.includes(STOP_HOOK_FILE)),\n );\n}\n\n/**\n * Strip our hook entries and our free-verb rules from ~/.claude/settings.json,\n * leaving every other entry, rule, and key exactly where it was.\n *\n * Removal is BY OWNERSHIP, never by index: an entry we did not write keeps its\n * position even when one of ours is removed from in front of it. An emptied\n * `hooks.<event>` array is dropped rather than left as `[]`, and an emptied\n * `hooks` or `permissions.allow` likewise, so a full uninstall leaves the file\n * as it would have been had install never run — but only when WE emptied them.\n */\nexport async function removeFromSettings(homeDir: string): Promise<SettingsOutcome> {\n const declaredPath = claudeSettingsPath(homeDir);\n const skip = (path: string, skipped: SettingsSkipReason, warning?: string): SettingsOutcome => ({\n path,\n hooks: [],\n rules: [],\n skipped,\n ...(warning !== undefined ? { warning } : {}),\n });\n\n const entry = await lstat(declaredPath).catch(() => null);\n if (entry === null) return skip(declaredPath, 'absent');\n\n let path: string;\n try {\n path = await realpath(declaredPath);\n } catch (err) {\n return skip(\n declaredPath,\n 'unresolvable',\n `${declaredPath} could not be resolved (${(err as Error).message}); it was left exactly as it is.`,\n );\n }\n\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n return skip(\n path,\n 'unreadable',\n `${path} could not be read (${(err as Error).message}); it was left exactly as it is.`,\n );\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (err) {\n return skip(\n path,\n 'unparsable',\n `${path} is not valid JSON (${(err as Error).message}); it was left exactly as it is.`,\n );\n }\n if (!isPlainObject(parsed)) {\n return skip(path, 'unexpected-shape', `${path} is not a JSON object; it was left as it is.`);\n }\n\n const settings = parsed;\n const removedHooks: string[] = [];\n const removedRules: string[] = [];\n let next: Record<string, unknown> = settings;\n\n const hooksValue = settings.hooks;\n if (hooksValue !== undefined && !isPlainObject(hooksValue)) {\n return skip(\n path,\n 'unexpected-shape',\n `${path} has a \"hooks\" key that is not an object; it was left exactly as it is.`,\n );\n }\n if (isPlainObject(hooksValue)) {\n const nextHooks: Record<string, unknown> = {};\n for (const [event, value] of Object.entries(hooksValue)) {\n if (!Array.isArray(value)) {\n nextHooks[event] = value;\n continue;\n }\n const kept = value.filter((e) => !ownsHookEntry(e));\n if (kept.length !== value.length) removedHooks.push(event);\n // An event WE emptied loses its key entirely; one that still holds someone\n // else's entry keeps it, and an array that was already empty before we\n // looked is left as we found it.\n const emptiedByUs = kept.length === 0 && value.length > 0;\n if (!emptiedByUs) nextHooks[event] = kept;\n }\n next = { ...next, hooks: nextHooks };\n if (Object.keys(nextHooks).length === 0) delete next.hooks;\n }\n\n const permissions = settings.permissions;\n if (isPlainObject(permissions) && Array.isArray(permissions.allow)) {\n // What THIS version writes, plus what any prior version wrote. A rule we\n // retired is still a rule we put there, and leaving it behind would strand a\n // dead allow-line for a command that no longer exists. The mode-gated pair is\n // reclaimed WHATEVER the mode says: uninstall removes what this CLI wrote,\n // and the mode that justified those rules is about to have no CLI behind it.\n const ours = new Set<string>([\n ...FREE_VERB_RULES,\n ...LEGACY_ALLOWLIST_RULES,\n ...MODE_GATED_RULES,\n ]);\n const kept = permissions.allow.filter((r) => !(typeof r === 'string' && ours.has(r)));\n if (kept.length !== permissions.allow.length) {\n for (const rule of permissions.allow) {\n if (typeof rule === 'string' && ours.has(rule)) removedRules.push(rule);\n }\n const nextPermissions: Record<string, unknown> = { ...permissions, allow: kept };\n if (kept.length === 0) delete nextPermissions.allow;\n next = { ...next, permissions: nextPermissions };\n if (Object.keys(nextPermissions).length === 0) delete next.permissions;\n }\n }\n\n if (removedHooks.length === 0 && removedRules.length === 0) {\n return { path, hooks: [], rules: [] };\n }\n\n // The same optimistic-concurrency contract the writers hold: this is a\n // whole-file replacement built from a snapshot, and Claude Code writes this\n // file too, so a change that landed underneath us is refused rather than\n // erased.\n const current = await readFile(path, 'utf8').catch(() => null);\n if (current !== raw) {\n return skip(\n path,\n 'changed-since-read',\n `${path} changed while it was being updated, so nothing was removed from it. Re-run \\`tenjin uninstall\\`.`,\n );\n }\n await writeFileAtomic(path, `${JSON.stringify(next, null, 2)}\\n`);\n return { path, hooks: removedHooks, rules: removedRules };\n}\n\n/**\n * Delete the generated hook scripts and, when it is left empty, the directory\n * that held them. Only our two filenames: a file someone else parked in there is\n * both left alone and reason to keep the directory.\n */\nexport async function removeHookScripts(dataDir: string): Promise<{\n scripts: string[];\n removedDir?: string;\n}> {\n const dir = hooksDir(dataDir);\n const removed: string[] = [];\n for (const file of [WEBSEARCH_HOOK_FILE, STOP_HOOK_FILE]) {\n const path = join(dir, file);\n // isFile, not mere existence: a directory parked at a script path would make\n // the non-recursive `rm` throw EISDIR and abort the uninstall halfway.\n if (lstatSync(path, { throwIfNoEntry: false })?.isFile() !== true) continue;\n await rm(path, { force: true });\n removed.push(path);\n }\n const rest = await readdir(dir).catch(() => null);\n if (rest !== null && rest.length === 0) {\n // `rmdir`, not a recursive `rm`: it removes an EMPTY directory and nothing\n // else, so a file that appeared between the listing and this call keeps the\n // directory instead of being swept away with it.\n const gone = await rmdir(dir).then(\n () => true,\n () => false,\n );\n if (gone) return { scripts: removed, removedDir: dir };\n }\n return { scripts: removed };\n}\n\n/**\n * Remove the skills we installed, in every harness location.\n *\n * REMOVES THE FILES WE SHIPPED, NOT THE DIRECTORY THEY SIT IN. Everything else in\n * that directory belongs to the operator — notes, a local override, anything\n * they put beside our files — and a recursive delete of a directory we only\n * partly own is the data-loss shape this repo already unlearned once on the\n * write side (see lib/skill-writer.ts: \"Only the files this package SHIPS are\n * read and written\"). So: unlink each path in {@link SHIPPED_SKILL_FILES}, then\n * remove a directory only if nothing is left in it, exactly as\n * `removeHookScripts` does one function up. A skill that ships a `references/`\n * subdirectory has that pruned the same way, deepest first — an operator file\n * beside ours keeps both itself and the directory it is in.\n *\n * Ours means the SKILL.md frontmatter still claims the name we wrote, the rule\n * `skill-heal` uses to decide it may rewrite a file. A skill someone replaced\n * with their own is not ours to delete just for sitting at our path, and neither\n * is a directory reached through a symlink.\n */\nexport async function removeSkills(homeDir: string): Promise<string[]> {\n const removed: string[] = [];\n const names = [...CLI_SKILL_NAMES, HOSTED_SKILL_NAME];\n for (const dir of skillsDirsFor(homeDir)) {\n if (lstatSync(dir, { throwIfNoEntry: false })?.isDirectory() !== true) continue;\n for (const name of names) {\n const skillDir = join(dir, name);\n if (lstatSync(skillDir, { throwIfNoEntry: false })?.isDirectory() !== true) continue;\n const path = join(skillDir, 'SKILL.md');\n if (lstatSync(path, { throwIfNoEntry: false })?.isFile() !== true) continue;\n const read = await readSkillFile(path);\n if (read.kind !== 'ok') continue;\n if (skillFrontmatterName(read.bytes.toString('utf8')) !== name) continue;\n // SKILL.md is the ownership proof, so it is checked first and removed\n // last: a run that dies partway leaves the frontmatter that lets the next\n // one recognize the directory as ours.\n const shipped = SHIPPED_SKILL_FILES[name];\n const subdirs = new Set<string>();\n for (const rel of shipped) {\n if (rel === 'SKILL.md') continue;\n const file = join(skillDir, rel);\n // The directory is a prune CANDIDATE whether or not our file is still in\n // it: an operator who deleted the file by hand would otherwise be left\n // with an empty `references/` that nothing ever clears.\n subdirs.add(dirname(file));\n if (lstatSync(file, { throwIfNoEntry: false })?.isFile() !== true) continue;\n await rm(file, { force: true });\n }\n await rm(path, { force: true });\n // Only when OUR files were the only things in there. An operator file keeps\n // both itself and the directory; `rmdir` refuses a non-empty one anyway,\n // so the check and the call agree even if something lands in between.\n // Deepest first, so an emptied `references/` cannot keep its parent alive.\n for (const dir of [...subdirs].sort((a, b) => b.length - a.length)) {\n const left = await readdir(dir).catch(() => null);\n if (left !== null && left.length === 0) await rmdir(dir).catch(() => undefined);\n }\n const rest = await readdir(skillDir).catch(() => null);\n if (rest !== null && rest.length === 0) {\n await rmdir(skillDir).catch(() => undefined);\n }\n removed.push(skillDir);\n }\n }\n return removed;\n}\n\n/**\n * Drop the legacy pointer line from the files an older `install` wrote it into.\n * The line is found by its marker, never by exact text, so a drifted copy from\n * any earlier version is recognized; everything around it is preserved byte for\n * byte, because these files are the operator's own notes.\n *\n * Written through the link for the same reason the writers were: `writeFileAtomic`\n * commits with a rename, so committing at a declared path would replace a\n * dotfiles-managed symlink with a regular file and strand its target. A file we\n * cannot read, or one that is not a regular file, is skipped rather than fixed.\n */\nexport async function removeMarkerLines(homeDir: string): Promise<string[]> {\n const cleaned: string[] = [];\n for (const path of markerFiles(homeDir)) {\n const read = await readSkillFile(path);\n if (read.kind !== 'ok') continue;\n const text = read.bytes.toString('utf8');\n if (!text.split('\\n').some((l) => l.startsWith(SKILLS_MARKER))) continue;\n // ANCHORED to the start of the line, which is the only way install ever\n // wrote it. `includes` would take a whole line of the operator's own prose\n // for quoting the marker inside a sentence or a code fence.\n const kept = text.split('\\n').filter((l) => !l.startsWith(SKILLS_MARKER));\n const writeTo = await resolveThroughLink(path, 'the Tenjin pointer');\n // A file that held nothing but our line is emptied rather than deleted:\n // install created it in that case, but the operator may have pointed a\n // dotfiles link at it since, and an empty file is inert either way.\n await writeFileAtomic(writeTo, kept.join('\\n'));\n cleaned.push(path);\n }\n return cleaned;\n}\n\n/** Every file `install` has ever written the pointer line into. */\nexport function markerFiles(homeDir: string): string[] {\n return [\n join(homeDir, '.claude', 'CLAUDE.md'),\n join(homeDir, '.agents', 'AGENTS.md'),\n join(homeDir, '.codex', 'AGENTS.md'),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,UAAU,SAAS,IAAI,OAAO,gBAAgB;AAC9D,SAAS,iBAAiB;AAC1B,SAAS,SAAS,YAAY;AA4FvB,IAAM,aAAgC;AAAA,EAC3C;AAAA,EACA;AACF;AAMO,IAAM,wBACX;AAGK,IAAM,gBAAgB;AAE7B,SAAS,cAAc,OAAkD;AACvE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAA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,MAAM,MAAM,IAAI;AAChD,YAAI,SAAS,QAAQ,KAAK,WAAW,EAAG,OAAM,MAAMA,IAAG,EAAE,MAAM,MAAM,MAAS;AAAA,MAChF;AACA,YAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,MAAM,MAAM,IAAI;AACrD,UAAI,SAAS,QAAQ,KAAK,WAAW,GAAG;AACtC,cAAM,MAAM,QAAQ,EAAE,MAAM,MAAM,MAAS;AAAA,MAC7C;AACA,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;AACA,SAAO;AACT;AAaA,eAAsB,kBAAkB,SAAoC;AAC1E,QAAM,UAAoB,CAAC;AAC3B,aAAW,QAAQ,YAAY,OAAO,GAAG;AACvC,UAAM,OAAO,MAAM,cAAc,IAAI;AACrC,QAAI,KAAK,SAAS,KAAM;AACxB,UAAM,OAAO,KAAK,MAAM,SAAS,MAAM;AACvC,QAAI,CAAC,KAAK,MAAM,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,aAAa,CAAC,EAAG;AAIhE,UAAM,OAAO,KAAK,MAAM,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,aAAa,CAAC;AACxE,UAAM,UAAU,MAAM,mBAAmB,MAAM,oBAAoB;AAInE,UAAM,gBAAgB,SAAS,KAAK,KAAK,IAAI,CAAC;AAC9C,YAAQ,KAAK,IAAI;AAAA,EACnB;AACA,SAAO;AACT;AAGO,SAAS,YAAY,SAA2B;AACrD,SAAO;AAAA,IACL,KAAK,SAAS,WAAW,WAAW;AAAA,IACpC,KAAK,SAAS,WAAW,WAAW;AAAA,IACpC,KAAK,SAAS,UAAU,WAAW;AAAA,EACrC;AACF;","names":["path","dir"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/search.ts"],"sourcesContent":["import { CliError } from '../lib/errors';\nimport { formatUsdDisplay, isPaidPrice, parseUsdToAtomic } from '../lib/money';\nimport { resolveContextSettings } from '../lib/settings';\nimport { buildSearchRequest, postSearch, MAX_LIMIT, type SearchInput } from '../lib/agent-api';\nimport { recordSearch } from '../lib/search-store';\nimport { assertOnBaseOrigin } from '../lib/resource-ref';\nimport { sanitizeForTerminal } from '../lib/output';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin search \"<question>\"`, one POST to /api/agent/search. Prints the compact\n * CANDIDATES/MISS response (spec 10) and records the searchId + candidates\n * locally so `outcome --last` and `buy <resourceId>` can use them. No wallet, no\n * signing: search is anonymous.\n *\n * The machine envelope is the server's response verbatim plus exactly one\n * CLI-owned key, `publishBack`, and only on a MISS. It carries no server data: it\n * is the local searchId and the two commands that close the loop, which is\n * information the CLI owns and the contract does not describe.\n *\n * Search is the breadth step: a candidate is a lean hit (identity, price,\n * freshness, why it matched), and the full answer card comes from `tenjin inspect`,\n * which is free. So a candidate line stays short on purpose.\n *\n * The response's `searchId` is the outcome-reporting capability for\n * POST /api/searches/<searchId>/outcomes. tenjin#463 renamed the field (from\n * `lookupId`) and tenjin#616 dropped the `/agent` prefix from the path; this\n * client follows both end to end, so nothing on the wire or in the local store\n * still speaks `lookupId` or the prefixed spelling.\n */\n\nexport interface SearchArgs {\n question: string;\n /** Decimal USD at the edge (O1); converted to atomic for the wire. */\n maxPrice?: string;\n freshWithin?: string;\n limit?: string;\n /** Raw `k=v` / `k=v1,v2` pairs from repeated --applies-to. */\n appliesTo?: string[];\n}\n\nexport interface SearchDeps {\n fetchImpl?: typeof fetch;\n /** Environment seam (TENJIN_SESSION_ID); defaults to process.env. */\n env?: NodeJS.ProcessEnv;\n}\n\nexport async function runSearch(\n args: SearchArgs,\n ctx: CommandContext,\n deps: SearchDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const input: SearchInput = { question: args.question };\n if (args.maxPrice !== undefined) input.maxPrice = parseUsdToAtomic(args.maxPrice);\n if (args.freshWithin !== undefined) input.freshWithin = args.freshWithin;\n if (args.limit !== undefined) input.limit = parseLimit(args.limit);\n if (args.appliesTo !== undefined && args.appliesTo.length > 0) {\n input.appliesTo = parseAppliesTo(args.appliesTo);\n }\n\n const sessionId = readSessionId(deps.env ?? process.env);\n const request = buildSearchRequest(input);\n const response = await postSearch(request, {\n baseUrl: settings.baseUrl,\n timeoutMs: ctx.flags.timeout,\n evalCohort: settings.evalCohort,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n\n const candidates = response.candidates ?? [];\n // Ingest trust boundary: a candidate url that points off the configured origin\n // would later route a wallet-signed SIWX header and payment to that host via\n // `buy <resourceId>`. Refuse the whole response as a contract violation.\n for (const c of candidates) {\n try {\n assertOnBaseOrigin(c.url, settings.baseUrl, 'search candidate URL');\n } catch (err) {\n throw new CliError(\n 'CONTRACT_MISMATCH',\n `Search candidate ${c.resourceId} points off the configured base URL.`,\n { cause: err },\n );\n }\n }\n // Browse pointers are never buyable through `buy <resourceId>` (they are not\n // recorded), but their urls are still emitted into the agent's transcript, so\n // they get the same origin check rather than a weaker one.\n for (const b of response.browse ?? []) {\n try {\n assertOnBaseOrigin(b.url, settings.baseUrl, 'browse pointer URL');\n } catch (err) {\n throw new CliError(\n 'CONTRACT_MISMATCH',\n `Browse pointer ${b.resourceId} points off the configured base URL.`,\n { cause: err },\n );\n }\n }\n await recordSearch(ctx.dataDir, {\n searchId: response.searchId,\n at: new Date().toISOString(),\n question: request.question,\n decision: response.decision,\n // A deliberate search, as opposed to one the WebSearch hook rode along with.\n // The Stop hook nags on the two differently, so the tag has to be written\n // here rather than inferred later from anything.\n source: 'cli',\n // Usually absent; see readSessionId. An unstamped entry is raised in every\n // session, which is the safe direction for a reminder.\n ...(sessionId !== undefined ? { sessionId } : {}),\n candidates: candidates.map((c) => ({\n resourceId: c.resourceId,\n url: c.url,\n title: c.title,\n price: c.price,\n })),\n // The pointers stay unrecorded on purpose (see below); only how many of them\n // cost money, so `outcome` can tell a MISS that offered a payable browse tail\n // from one that offered nothing to buy. A zero-priced pointer does not count:\n // `read` delivers it for nothing, so there was no purchase to decline. Zero on\n // a CANDIDATES decision, where the contract carries no browse array and the\n // parser drops any that appears.\n paidBrowseCount: (response.browse ?? []).filter((b) => isPaidPrice(b.price) === true).length,\n });\n\n // A MISS may carry up to 3 browse pointers from the broad corpus. They are\n // pointers, NOT candidates: rendered as ONE hint line with no scores and no\n // per-item detail, so a MISS still reads as a MISS and an agent is never\n // nudged to treat a browse pointer as an answer. The machine JSON keeps the\n // full `browse` array; this line is only the human tail.\n //\n // The price rides this line because a browse url IS payable: it is the read\n // endpoint that answers a 402, and `buy <url>` resolves the URL arm by origin\n // without consulting the search store, so a browse pointer can be bought even\n // though `buy <resourceId>` can never reach one. All spend gates (price cap,\n // session budget, allowlist, confirm) still run; showing the price keeps the\n // only human-visible surface from being a blind spend.\n //\n // It renders in DOLLARS, not atomic units, because the whole point of the line\n // is that a human can size the spend against the gates they set, and every gate\n // is entered in decimal USD (`--max-price 0.10`, the `maxAutoSpend` config).\n // `formatUsdDisplay` is the canonical human-copy form (always two decimals, so\n // a dime reads \"0.10\" and not \"0.1\"); the machine `browse` array in --json still\n // carries the exact atomic string, per the money-units contract in the README.\n const browse = response.browse ?? [];\n const browseHint =\n browse.length > 0\n ? [\n `no match, ${browse.length} piece(s) you could browse: ${browse\n .map((b) => `${sanitizeForTerminal(b.title)} (${formatUsdDisplay(b.price)} USD)`)\n .join('; ')}`,\n ]\n : [];\n\n // `truncated` means the server's size backstop dropped candidates, either a\n // trailing few the limit had room for or a single oversized one. The response\n // ceiling GROWS with the number of candidates returned (tenjin#501), so the\n // remedy is counter-intuitive and worth stating outright: a larger --limit\n // recovers the tail, a smaller one returns strictly fewer. Only at the maximum\n // is the tail unrecoverable and narrowing the question the answer.\n //\n // The CLI knows the limit it sent, so it names the next step instead of\n // restating the rule and leaving the reader to work out which half applies.\n // The flag stays in the machine envelope (--json) untouched, where it is\n // omitted rather than false when it did not fire.\n //\n // Rendering it on a MISS too is DEFENSIVE, not wire behavior: the server only\n // ever sets the flag alongside candidates it dropped. Handling both keeps the\n // flag from going unrendered if that ever changes.\n const truncatedHint =\n response.truncated === true\n ? [\n request.limit < MAX_LIMIT\n ? `some candidates were dropped for size; retry with --limit ${MAX_LIMIT} (the size ceiling grows with the number of candidates returned)`\n : `some candidates were dropped for size; at --limit ${MAX_LIMIT} the dropped tail cannot be recovered, so narrow the question`,\n ]\n : [];\n\n // The publish-back line rides humanLines like every other rendering, so `--json`\n // suppresses it the way that flag's own help promises. It used to go straight to\n // stderr, which no output mode gates: an agent asking for a machine envelope got\n // ~260 bytes of human prose alongside it.\n const humanLines =\n response.decision === 'MISS'\n ? [\n `MISS, no candidates (searchId ${response.searchId})`,\n ...browseHint,\n ...truncatedHint,\n publishBackLine(response.searchId),\n ]\n : [\n `${candidates.length} candidate(s) (searchId ${response.searchId}):`,\n // Dollars for the same reason the browse hint uses them: this is the\n // human's cue to size the spend against gates they entered in decimal\n // USD. The machine `candidates` array in --json keeps atomic.\n ...candidates.map(\n (c, i) =>\n ` ${i + 1}. ${sanitizeForTerminal(c.title)}, ${formatUsdDisplay(c.price)} USD, ${sanitizeForTerminal(c.url)}`,\n ),\n ...truncatedHint,\n ];\n\n // The one CLI-owned field in this envelope. Everything else is the server's\n // response verbatim (spec 10), so the addition is namespaced under a key the\n // contract does not define and is present ONLY on a MISS: a MISS is the moment\n // the demand this searcher just expressed can still be met, and the searchId is\n // what ties the answer they are about to derive back to it. A CANDIDATES\n // response is byte-identical to what it was.\n const data =\n response.decision === 'MISS'\n ? { ...response, publishBack: publishBackHint(response.searchId) }\n : response;\n\n return { data, humanLines };\n}\n\n/**\n * The session to stamp this search with, so the Stop hook can tell one session's\n * open loops from a sibling's, or undefined when nothing can say.\n *\n * Two sources, in precedence order. TENJIN_SESSION_ID is the explicit operator\n * override and wins. CLAUDE_CODE_SESSION_ID is what Claude Code exports to Bash\n * tool subprocesses, which is what a `tenjin search` runs as; its value is the\n * same `session_id` the hook scripts are handed on stdin, so a CLI search and a\n * WebSearch-hook search in one session stamp identically. It is verified against\n * a live session rather than documented, hence the fallback rather than a\n * requirement: on a harness that does not export it this stays undefined, and\n * undefined is the safe answer — the hook raises an unstamped entry in every\n * session rather than in none.\n */\nfunction readSessionId(env: NodeJS.ProcessEnv): string | undefined {\n return firstNonEmpty(env.TENJIN_SESSION_ID) ?? firstNonEmpty(env.CLAUDE_CODE_SESSION_ID);\n}\n\nfunction firstNonEmpty(raw: string | undefined): string | undefined {\n if (typeof raw !== 'string') return undefined;\n const trimmed = raw.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/** The publish-back hint, as machine fields rather than prose to re-parse. */\nfunction publishBackHint(searchId: string): {\n searchId: string;\n reason: string;\n publish: string;\n decline: string;\n} {\n return {\n searchId,\n reason: 'Nothing on the marketplace answered this. If you solve it, publish it back.',\n // Both arms carry the searchId, because both are commands to run verbatim and\n // a publish without it leaves this very loop open (see publish's --search-id).\n // The second arm is DECLINE, not park: nothing is saved to come back to, and\n // reporting the outcome is what closes the loop so it never raises again.\n publish: `tenjin publish <file.md> --json --search-id ${searchId}`,\n decline: `tenjin outcome --search-id ${searchId} --status regenerated --json`,\n };\n}\n\n/** The same hint as one rendered line for a human. */\nfunction publishBackLine(searchId: string): string {\n return `Nobody has published this yet - if you solve it, publish it back (tenjin publish <file.md> --search-id ${searchId}); if you will not, close the loop: tenjin outcome --search-id ${searchId} --status regenerated`;\n}\n\nfunction parseLimit(raw: string): number {\n const n = Number(raw);\n if (!Number.isInteger(n)) {\n throw new CliError('USAGE', `Invalid --limit: ${JSON.stringify(raw)}`, {\n fix: 'Pass an integer between 1 and 10.',\n });\n }\n return n;\n}\n\n/** `products=Vercel` or `products=Vercel,Next` → { products: [\"Vercel\",\"Next\"] }. Repeated\n * keys merge their values. */\nfunction parseAppliesTo(pairs: string[]): Record<string, string[]> {\n const out: Record<string, string[]> = {};\n for (const pair of pairs) {\n const eq = pair.indexOf('=');\n if (eq <= 0) {\n throw new CliError('USAGE', `Invalid --applies-to: ${JSON.stringify(pair)}`, {\n fix: 'Use key=value, e.g. --applies-to products=Vercel.',\n });\n }\n const key = pair.slice(0, eq).trim();\n const values = pair\n .slice(eq + 1)\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v.length > 0);\n if (values.length === 0) {\n throw new CliError('USAGE', `--applies-to ${JSON.stringify(key)} has no values`, {\n fix: 'Give each key at least one value, e.g. products=Vercel.',\n });\n }\n out[key] = [...(out[key] ?? []), ...values];\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,eAAsB,UACpB,MACA,KACA,OAAmB,CAAC,GACI;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,QAAqB,EAAE,UAAU,KAAK,SAAS;AACrD,MAAI,KAAK,aAAa,OAAW,OAAM,WAAW,iBAAiB,KAAK,QAAQ;AAChF,MAAI,KAAK,gBAAgB,OAAW,OAAM,cAAc,KAAK;AAC7D,MAAI,KAAK,UAAU,OAAW,OAAM,QAAQ,WAAW,KAAK,KAAK;AACjE,MAAI,KAAK,cAAc,UAAa,KAAK,UAAU,SAAS,GAAG;AAC7D,UAAM,YAAY,eAAe,KAAK,SAAS;AAAA,EACjD;AAEA,QAAM,YAAY,cAAc,KAAK,OAAO,QAAQ,GAAG;AACvD,QAAM,UAAU,mBAAmB,KAAK;AACxC,QAAM,WAAW,MAAM,WAAW,SAAS;AAAA,IACzC,SAAS,SAAS;AAAA,IAClB,WAAW,IAAI,MAAM;AAAA,IACrB,YAAY,SAAS;AAAA,IACrB,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,EACtE,CAAC;AAED,QAAM,aAAa,SAAS,cAAc,CAAC;AAI3C,aAAW,KAAK,YAAY;AAC1B,QAAI;AACF,yBAAmB,EAAE,KAAK,SAAS,SAAS,sBAAsB;AAAA,IACpE,SAAS,KAAK;AACZ,YAAM,IAAI;AAAA,QACR;AAAA,QACA,oBAAoB,EAAE,UA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AA,MACrE,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAIA,SAAS,eAAe,OAA2C;AACjE,QAAM,MAAgC,CAAC;AACvC,aAAW,QAAQ,OAAO;AACxB,UAAM,KAAK,KAAK,QAAQ,GAAG;AAC3B,QAAI,MAAM,GAAG;AACX,YAAM,IAAI,SAAS,SAAS,yBAAyB,KAAK,UAAU,IAAI,CAAC,IAAI;AAAA,QAC3E,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,UAAM,MAAM,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK;AACnC,UAAM,SAAS,KACZ,MAAM,KAAK,CAAC,EACZ,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC;AAC7B,QAAI,OAAO,WAAW,GAAG;AACvB,YAAM,IAAI,SAAS,SAAS,gBAAgB,KAAK,UAAU,GAAG,CAAC,kBAAkB;AAAA,QAC/E,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,GAAG,IAAI,CAAC,GAAI,IAAI,GAAG,KAAK,CAAC,GAAI,GAAG,MAAM;AAAA,EAC5C;AACA,SAAO;AACT;","names":[]}
|
package/dist/chunk-ZQIQ55KK.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/lib/paths.ts
|
|
4
|
-
import { homedir } from "os";
|
|
5
|
-
import { join } from "path";
|
|
6
|
-
function dataDir(env = process.env) {
|
|
7
|
-
const override = env.TENJIN_DATA_DIR;
|
|
8
|
-
if (override !== void 0 && override.length > 0) return override;
|
|
9
|
-
return join(homedir(), ".tenjin");
|
|
10
|
-
}
|
|
11
|
-
function configPath(dir = dataDir()) {
|
|
12
|
-
return join(dir, "config.json");
|
|
13
|
-
}
|
|
14
|
-
function walletPath(dir = dataDir()) {
|
|
15
|
-
return join(dir, "wallet.json");
|
|
16
|
-
}
|
|
17
|
-
function sessionPath(dir = dataDir()) {
|
|
18
|
-
return join(dir, "session.json");
|
|
19
|
-
}
|
|
20
|
-
function spendLedgerPath(dir = dataDir()) {
|
|
21
|
-
return join(dir, "spend.json");
|
|
22
|
-
}
|
|
23
|
-
function updateCheckPath(dir = dataDir()) {
|
|
24
|
-
return join(dir, "update-check.json");
|
|
25
|
-
}
|
|
26
|
-
function hooksDir(dir = dataDir()) {
|
|
27
|
-
return join(dir, "hooks");
|
|
28
|
-
}
|
|
29
|
-
function passphraseBlobPath(dir = dataDir()) {
|
|
30
|
-
return join(dir, "passphrase.dpapi");
|
|
31
|
-
}
|
|
32
|
-
function passphraseBlobPathFor(account, dir = dataDir()) {
|
|
33
|
-
return join(dir, `passphrase.${account}.dpapi`);
|
|
34
|
-
}
|
|
35
|
-
function archivedWalletPath(account, dir = dataDir()) {
|
|
36
|
-
return join(dir, `wallet.${account}.json.bak`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
dataDir,
|
|
41
|
-
configPath,
|
|
42
|
-
walletPath,
|
|
43
|
-
sessionPath,
|
|
44
|
-
spendLedgerPath,
|
|
45
|
-
updateCheckPath,
|
|
46
|
-
hooksDir,
|
|
47
|
-
passphraseBlobPath,
|
|
48
|
-
passphraseBlobPathFor,
|
|
49
|
-
archivedWalletPath
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=chunk-ZQIQ55KK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/paths.ts"],"sourcesContent":["import { homedir } from 'node:os';\nimport { join } from 'node:path';\n\n/**\n * Where the CLI keeps its config and wallet. Defaults to ~/.tenjin, overridable\n * via TENJIN_DATA_DIR (CI, ephemeral agents, and every test — which point it at\n * a temp dir so the real home is never touched).\n */\nexport function dataDir(env: NodeJS.ProcessEnv = process.env): string {\n const override = env.TENJIN_DATA_DIR;\n if (override !== undefined && override.length > 0) return override;\n return join(homedir(), '.tenjin');\n}\n\nexport function configPath(dir: string = dataDir()): string {\n return join(dir, 'config.json');\n}\n\nexport function walletPath(dir: string = dataDir()): string {\n return join(dir, 'wallet.json');\n}\n\n/**\n * Where the delegated P-256 session key + its wallet-signed SIWX delegation are\n * cached (B3, D35). A short-lived (≤24h) hot key: lower stakes than wallet.json,\n * but still written 0600 and address-bound so a wallet change invalidates it.\n */\nexport function sessionPath(dir: string = dataDir()): string {\n return join(dir, 'session.json');\n}\n\n/**\n * Where the client-side rolling spend ledger lives (lib/wallet/spend.ts).\n *\n * Its own file, NOT session.json: the two schemas are incompatible and both\n * readers treat a parse failure as \"absent\", so a shared path meant each writer\n * silently destroyed the other's file — a session key wiped the spend window, and\n * the next spend wiped the session key.\n */\nexport function spendLedgerPath(dir: string = dataDir()): string {\n return join(dir, 'spend.json');\n}\n\n/**\n * Where the once-a-day \"a newer tenjin-cli exists\" check caches the registry\n * answer. A pure cache: nothing here is authoritative, so an unreadable file is\n * simply re-fetched.\n */\nexport function updateCheckPath(dir: string = dataDir()): string {\n return join(dir, 'update-check.json');\n}\n\n/**\n * Where `install` writes the standalone harness hook scripts. Under the data dir\n * rather than the harness's own config directory: the scripts are ours, a harness\n * only ever holds the path to them, and one location serves every harness.\n */\nexport function hooksDir(dir: string = dataDir()): string {\n return join(dir, 'hooks');\n}\n\n/**\n * Which searchIds the Stop hook has already nagged about, so each open loop is\n * raised once per turn-end rather than every turn.\n *\n * Not atomic, deliberately: two sessions ending at the same instant can both read\n * this file before either writes, and one loop is then named twice. The cost is a\n * duplicate line, and taking the search store's lock here would put a\n * cross-process wait at the end of every turn to buy nothing but tidiness.\n *\n * Its own file, NOT a field in searches.json, and that separation is the whole\n * point: the hook runs outside the CLI with no access to the lock `recordSearch`\n * takes, so a hook writing searches.json could erase a search landing at the same\n * moment. Nothing but the hook writes this file, and losing it costs one repeated\n * nag rather than a lost search.\n */\nexport function nagStatePath(dir: string = dataDir()): string {\n return join(dir, 'hook-nags.json');\n}\n\n/**\n * Where the LEGACY (pre-per-wallet) Windows DPAPI passphrase blob lives. The\n * file holds a DPAPI CurrentUser ciphertext, not the passphrase in plaintext.\n * New writes go to the per-wallet path below; this one is only read as a\n * migration fallback and removed after a verified per-wallet copy exists.\n */\nexport function passphraseBlobPath(dir: string = dataDir()): string {\n return join(dir, 'passphrase.dpapi');\n}\n\n/**\n * The per-wallet Windows DPAPI passphrase blob: one file per wallet address\n * (lowercase), so creating a new wallet never clobbers an old wallet's blob.\n * Only ever written on win32; other platforms use their own OS store.\n */\nexport function passphraseBlobPathFor(account: string, dir: string = dataDir()): string {\n return join(dir, `passphrase.${account}.dpapi`);\n}\n\n/**\n * Where `wallet create --replace` parks the outgoing wallet's keystore, keyed by\n * its lowercase address so successive replaces can never collide. Together with\n * the wallet's per-address passphrase entry in the OS store, this file keeps the\n * replaced wallet's funds recoverable; it is never read by the active-wallet\n * path.\n */\nexport function archivedWalletPath(account: string, dir: string = dataDir()): string {\n return join(dir, `wallet.${account}.json.bak`);\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,SAAS,YAAY;AAOd,SAAS,QAAQ,MAAyB,QAAQ,KAAa;AACpE,QAAM,WAAW,IAAI;AACrB,MAAI,aAAa,UAAa,SAAS,SAAS,EAAG,QAAO;AAC1D,SAAO,KAAK,QAAQ,GAAG,SAAS;AAClC;AAEO,SAAS,WAAW,MAAc,QAAQ,GAAW;AAC1D,SAAO,KAAK,KAAK,aAAa;AAChC;AAEO,SAAS,WAAW,MAAc,QAAQ,GAAW;AAC1D,SAAO,KAAK,KAAK,aAAa;AAChC;AAOO,SAAS,YAAY,MAAc,QAAQ,GAAW;AAC3D,SAAO,KAAK,KAAK,cAAc;AACjC;AAUO,SAAS,gBAAgB,MAAc,QAAQ,GAAW;AAC/D,SAAO,KAAK,KAAK,YAAY;AAC/B;AAOO,SAAS,gBAAgB,MAAc,QAAQ,GAAW;AAC/D,SAAO,KAAK,KAAK,mBAAmB;AACtC;AAOO,SAAS,SAAS,MAAc,QAAQ,GAAW;AACxD,SAAO,KAAK,KAAK,OAAO;AAC1B;AA2BO,SAAS,mBAAmB,MAAc,QAAQ,GAAW;AAClE,SAAO,KAAK,KAAK,kBAAkB;AACrC;AAOO,SAAS,sBAAsB,SAAiB,MAAc,QAAQ,GAAW;AACtF,SAAO,KAAK,KAAK,cAAc,OAAO,QAAQ;AAChD;AASO,SAAS,mBAAmB,SAAiB,MAAc,QAAQ,GAAW;AACnF,SAAO,KAAK,KAAK,UAAU,OAAO,WAAW;AAC/C;","names":[]}
|
package/dist/config-CNUIX23Q.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
persistInstallHarness,
|
|
4
|
-
persistPublishMode,
|
|
5
|
-
persistSearchHookMode,
|
|
6
|
-
runConfigGet,
|
|
7
|
-
runConfigList,
|
|
8
|
-
runConfigSet
|
|
9
|
-
} from "./chunk-4UHNXY6B.js";
|
|
10
|
-
import "./chunk-ZOBNS7CX.js";
|
|
11
|
-
import "./chunk-IUQZ4Z7M.js";
|
|
12
|
-
import "./chunk-PKW3H26Z.js";
|
|
13
|
-
import "./chunk-736DW4V3.js";
|
|
14
|
-
import "./chunk-UO22YNY4.js";
|
|
15
|
-
import "./chunk-DTCXO7HS.js";
|
|
16
|
-
import "./chunk-IU2HVT3Y.js";
|
|
17
|
-
import "./chunk-VEAERJVJ.js";
|
|
18
|
-
import "./chunk-LSWP7MU2.js";
|
|
19
|
-
import "./chunk-ETKZWJ4B.js";
|
|
20
|
-
import "./chunk-ZQIQ55KK.js";
|
|
21
|
-
import "./chunk-QWBUKIP2.js";
|
|
22
|
-
import "./chunk-PAOVPSP6.js";
|
|
23
|
-
import "./chunk-ZXTAQYNA.js";
|
|
24
|
-
export {
|
|
25
|
-
persistInstallHarness,
|
|
26
|
-
persistPublishMode,
|
|
27
|
-
persistSearchHookMode,
|
|
28
|
-
runConfigGet,
|
|
29
|
-
runConfigList,
|
|
30
|
-
runConfigSet
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=config-CNUIX23Q.js.map
|
package/dist/doctor-QJJXRWTO.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
collectDoctorChecks,
|
|
4
|
-
isNoWalletCheck,
|
|
5
|
-
renderDoctorHuman,
|
|
6
|
-
runDoctor
|
|
7
|
-
} from "./chunk-GEHL43VE.js";
|
|
8
|
-
import "./chunk-J6FUAIRR.js";
|
|
9
|
-
import "./chunk-54AJIO3E.js";
|
|
10
|
-
import "./chunk-XGZ5EVMB.js";
|
|
11
|
-
import "./chunk-3P3ES4XU.js";
|
|
12
|
-
import "./chunk-B676GPS2.js";
|
|
13
|
-
import "./chunk-IUQZ4Z7M.js";
|
|
14
|
-
import "./chunk-PKW3H26Z.js";
|
|
15
|
-
import "./chunk-736DW4V3.js";
|
|
16
|
-
import "./chunk-UO22YNY4.js";
|
|
17
|
-
import "./chunk-IU2HVT3Y.js";
|
|
18
|
-
import "./chunk-VEAERJVJ.js";
|
|
19
|
-
import "./chunk-LSWP7MU2.js";
|
|
20
|
-
import "./chunk-ETKZWJ4B.js";
|
|
21
|
-
import "./chunk-ZQIQ55KK.js";
|
|
22
|
-
import "./chunk-QWBUKIP2.js";
|
|
23
|
-
import "./chunk-PAOVPSP6.js";
|
|
24
|
-
import "./chunk-ZXTAQYNA.js";
|
|
25
|
-
export {
|
|
26
|
-
collectDoctorChecks,
|
|
27
|
-
isNoWalletCheck,
|
|
28
|
-
renderDoctorHuman,
|
|
29
|
-
runDoctor
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=doctor-QJJXRWTO.js.map
|
package/dist/edit-HJ44P44P.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
runEdit
|
|
4
|
-
} from "./chunk-IXZJ3JOO.js";
|
|
5
|
-
import "./chunk-VRPLZERE.js";
|
|
6
|
-
import "./chunk-WU5CZPLD.js";
|
|
7
|
-
import "./chunk-OWVVI4VQ.js";
|
|
8
|
-
import "./chunk-KZAAWQNP.js";
|
|
9
|
-
import "./chunk-S5RYMCV6.js";
|
|
10
|
-
import "./chunk-POJRB2AE.js";
|
|
11
|
-
import "./chunk-YLYINX2H.js";
|
|
12
|
-
import "./chunk-FDUD3W5V.js";
|
|
13
|
-
import "./chunk-7GJQ5RGA.js";
|
|
14
|
-
import "./chunk-J6FUAIRR.js";
|
|
15
|
-
import "./chunk-54AJIO3E.js";
|
|
16
|
-
import "./chunk-XGZ5EVMB.js";
|
|
17
|
-
import "./chunk-3P3ES4XU.js";
|
|
18
|
-
import "./chunk-B676GPS2.js";
|
|
19
|
-
import "./chunk-ZOBNS7CX.js";
|
|
20
|
-
import "./chunk-PKW3H26Z.js";
|
|
21
|
-
import "./chunk-736DW4V3.js";
|
|
22
|
-
import "./chunk-UO22YNY4.js";
|
|
23
|
-
import "./chunk-VEAERJVJ.js";
|
|
24
|
-
import "./chunk-LSWP7MU2.js";
|
|
25
|
-
import "./chunk-ETKZWJ4B.js";
|
|
26
|
-
import "./chunk-ZQIQ55KK.js";
|
|
27
|
-
import "./chunk-QWBUKIP2.js";
|
|
28
|
-
import "./chunk-PAOVPSP6.js";
|
|
29
|
-
import "./chunk-M2O56UK7.js";
|
|
30
|
-
import "./chunk-UHTVXQ2O.js";
|
|
31
|
-
import "./chunk-W6R3HAAG.js";
|
|
32
|
-
import "./chunk-47PP7TAG.js";
|
|
33
|
-
import "./chunk-XJN5WUKL.js";
|
|
34
|
-
import "./chunk-RBJPAZFI.js";
|
|
35
|
-
import "./chunk-KYQVEKP5.js";
|
|
36
|
-
import "./chunk-ZXTAQYNA.js";
|
|
37
|
-
export {
|
|
38
|
-
runEdit
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=edit-HJ44P44P.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/install.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport { homedir } from 'node:os';\nimport { z } from 'zod';\nimport { styleText } from 'node:util';\nimport { Stream } from 'node:stream';\nimport { CliError } from '../lib/errors';\nimport { hasCode } from '../lib/errno';\nimport { ownsAnyLock, releaseOwnedLocks } from '../lib/lock';\nimport { installSkill } from '../lib/skill-writer';\nimport type { SkillInstallStatus } from '../lib/skill-writer';\nimport { resolveSkillsSource, SKILL_NAMES } from '../lib/skills-source';\nimport {\n CLI_SKILL_NAMES,\n HARNESS_TARGETS,\n HOSTED_SKILL_NAME,\n harnessDetectedBy,\n harnessTargetDir,\n isModelInvocationDisabled,\n onPath,\n readSkillFile,\n} from '../lib/skill-wiring';\nimport type { HarnessTarget } from '../lib/skill-wiring';\nimport {\n CONFIG_DEFAULTS,\n loadRawConfig,\n PublishModeSchema,\n SearchHookModeSchema,\n parsePublishModeFlag,\n parseSearchHookModeFlag,\n} from '../lib/config';\nimport type { PublishMode, SearchHookMode } from '../lib/config';\nimport { persistInstallHarness, persistPublishMode, persistSearchHookMode } from './config';\nimport { runWalletCreate } from './wallet';\nimport { collectDoctorChecks, isNoWalletCheck } from './doctor';\nimport type { DoctorDeps, DoctorChecks } from './doctor';\nimport { describeWallet, resolveWalletProvider } from '../lib/wallet';\nimport type { PassphraseOverrides } from '../lib/wallet/local';\nimport { walletFileExists } from '../lib/wallet/store';\nimport { walletPath } from '../lib/paths';\nimport { PERMISSIONS_DOC_URL, recommendedPermissions } from '../lib/permissions';\nimport {\n FREE_VERB_RULES,\n inspectFreeVerbRules,\n MODE_GATED_RULES,\n permissionsSkipped,\n planFreeVerbAllowlist,\n retractModeGatedRules,\n rulesForPublishMode,\n wireFreeVerbAllowlist,\n} from '../lib/harness-permissions';\nimport type { PermissionsResult } from '../lib/harness-permissions';\nimport { hooksSkipped, hooksUndo, wireSearchHooks } from '../lib/harness-hooks';\nimport { removeMarkerLines } from '../lib/uninstall';\nimport type { HooksResult } from '../lib/harness-hooks';\nimport { confirmChoice, intro as clackIntro, outro as clackOutro, selectOne } from '../lib/clack';\nimport { sanitizeForTerminal } from '../lib/output';\nimport type { Io } from '../lib/output';\nimport type { CommandContext, CommandResult } from '../context';\n\n// The `--harness` vocabulary and its directory mapping are single-sourced in\n// skill-wiring beside the detection probes, because `doctor` maps a persisted choice\n// back to a directory with the same rules.\nconst HARNESSES = HARNESS_TARGETS;\ntype Harness = HarnessTarget;\n\nconst InstallInputSchema = z.object({\n harness: z.array(z.string()).optional(),\n dryRun: z.boolean().optional(),\n publishMode: z.string().optional(),\n noWallet: z.boolean().optional(),\n /**\n * ACCEPTED AND IGNORED. `install` writes no CLAUDE.md/AGENTS.md line any more —\n * a skill's own frontmatter description is the trigger surface the harness reads\n * at session start, so the line only duplicated it. Both spellings still parse so\n * a script or a released doc that passes one does not fail; neither does anything.\n */\n claudeMd: z.boolean().optional(),\n /**\n * Tri-state. `true` (`--allow-free-verbs`) wires the free-verb\n * allowlist without asking, which is now also what an unanswered non-interactive\n * run does, so the flag is kept for compatibility and as an explicit statement of\n * intent. `false` (`--no-allow-free-verbs`) is the opt-out and is the only way to\n * get a run that writes no permission rule. `undefined` asks when it can, and\n * writes when it cannot ask.\n */\n allowFreeVerbs: z.boolean().optional(),\n /** The harness search-hook behavior to install (`--search-hooks auto|remind|off`). */\n searchHooks: z.string().optional(),\n /**\n * `--no-hooks`: register no hooks THIS RUN, changing nothing persistent. It is\n * deliberately not the same as `--search-hooks off`, which is a durable\n * statement about behavior and writes `hooks.searchMode: off` to config.\n */\n noHooks: z.boolean().optional(),\n});\nexport type InstallInput = z.infer<typeof InstallInputSchema>;\n\n/**\n * The publish-mode question's seam: returns the chosen mode, or `null` when the\n * operator cancelled (which changes nothing and writes nothing). The choices\n * themselves are {@link PUBLISH_MODE_CHOICES}; the seam exists so tests answer\n * in-process and never render a prompt.\n */\nexport type PromptPublishModeFn = () => Promise<PublishMode | null>;\n\n/** A yes/no seam, same shape as buy's `confirm`. */\nexport type ConfirmFn = (label: string) => Promise<boolean>;\n\ntype PublishModeSource = 'flag' | 'existing' | 'prompt' | 'headless-default' | 'default-skipped';\ninterface PublishModeSelection {\n value: PublishMode;\n source: PublishModeSource;\n}\n\n/**\n * Why no wallet was created, when none was.\n *\n * `no-passphrase-store` is the one that matters: this machine has no OS\n * credential store that would hold a generated passphrase, and no\n * `TENJIN_WALLET_PASSPHRASE`. There is no fallback here BY DESIGN. A passphrase\n * written to a plain file beside the keystore it unlocks is not a passphrase, so\n * the run creates nothing and says so loudly with both remedies.\n */\ntype WalletSkipReason = 'no-passphrase-store' | 'create-failed' | 'dry-run' | 'flag';\n\n/**\n * How the wallet step resolved, so rendering stays separate from prompting.\n *\n * `declined` (an answer) and `skipped` (no answer, with a reason) are kept apart\n * deliberately: an install that could not create a key is a different state from\n * one the operator told not to, and only the first needs a remedy.\n */\ninterface WalletOutcome {\n status: 'existing' | 'created' | 'declined' | 'skipped';\n address?: string;\n /** Only ever set on `skipped`. */\n reason?: WalletSkipReason;\n /** The exact command that changes this outcome, mirroring the CliError contract. */\n fix?: string;\n /** The underlying failure, for a `create-failed` skip. */\n warning?: string;\n}\n\n/** The remedy for each skip, so no skipped state is ever a dead end. */\nfunction walletFix(reason: WalletSkipReason): string {\n switch (reason) {\n case 'no-passphrase-store':\n return 'No OS credential store is available to hold the wallet passphrase. Set TENJIN_WALLET_PASSPHRASE and re-run `tenjin install`, or run `tenjin wallet create` in a terminal to enter one.';\n case 'create-failed':\n return 'Fix the reported problem, then run `tenjin wallet create`.';\n case 'dry-run':\n case 'flag':\n return 'Create one with `tenjin wallet create`.';\n }\n}\n\n/**\n * The Codex config.toml rule the user must add by hand. We PRINT it, never edit\n * config.toml: Codex's default workspace-write sandbox blocks network, which would\n * make every paid x402 call fail (or prompt) until this is set.\n */\nconst CODEX_NETWORK_RULE = '[sandbox_workspace_write]\\nnetwork_access = true';\n\n/** Per-skill install outcome for one harness target. */\ninterface SkillResult {\n name: string;\n status: SkillInstallStatus;\n /** Was a real copy (a SKILL.md, not just the directory) already on disk before this run? */\n preexisting: boolean;\n /** Is this one of the two CLI adapter skills (as opposed to the hosted mirror)? */\n cli: boolean;\n /** Will a harness surface it to the model after this run? On a --dry-run nothing is\n * written, so it answers for the packaged copy that would land. */\n modelInvocable: boolean;\n}\n\ninterface HarnessResult {\n harness: Harness;\n detected: boolean;\n detectedBy: string[];\n skillsDir: string;\n skills: SkillResult[];\n /**\n * Was the hosted zero-install `tenjin` skill already in this target before the\n * run? Reported so an upgrade over a hosted-skill machine is visible in `--json`,\n * which is exactly the state #35 was invisible in.\n */\n hostedPreexisting: boolean;\n /**\n * Narrower than {@link HarnessResult.hostedPreexisting}: the hosted skill was here\n * AND the CLI adapters were not, which is the hosted-zero-install-first funnel\n * rather than a second run finding our own mirror. This is what gates the notice.\n */\n hostedArrivedFirst: boolean;\n codexNetworkRule?: string;\n notes: string[];\n warnings: string[];\n}\n\nexport interface InstallDeps {\n /** Home directory root for harness detection + skill destinations. Tests inject a temp dir. */\n homeDir?: string;\n /** The packaged skills source directory. Defaults to resolving it from this module's location. */\n skillsSourceDir?: string;\n /** PATH probe for `claude`/`codex` binaries. Injectable so tests never depend on the real PATH. */\n which?: (bin: string) => boolean;\n /** Environment (PATH for the default `which`). Defaults to process.env. */\n env?: NodeJS.ProcessEnv;\n /** Doctor check collector; defaults to the real one. Injected in tests to avoid the network. */\n collectChecks?: (ctx: CommandContext) => Promise<DoctorChecks>;\n /** Deps forwarded to the default doctor collector (e.g. a canned fetch). */\n doctorDeps?: DoctorDeps;\n /** Decision 1: the publish-mode select; defaults to the clack list. */\n promptPublishMode?: PromptPublishModeFn;\n /** Decision 2: the permissions confirm (default yes); defaults to the clack confirm. */\n confirmPermissions?: ConfirmFn;\n /** What a real run WOULD write, for `--dry-run`; defaults to the read-only plan pass. */\n planPermissions?: (home: string, mode: PublishMode) => Promise<PermissionsResult>;\n /** Whether decision 2 has anything left to grant; defaults to reading settings.json. */\n inspectPermissions?: (\n home: string,\n mode: PublishMode,\n ) => Promise<{ pending: string[] | null; satisfied?: PermissionsResult }>;\n /** The retraction-only pass `review` runs; defaults to the real writer. */\n retractModeGated?: (home: string) => Promise<PermissionsResult>;\n /** Decision 3: the search-hook mode select; defaults to the clack list. */\n promptSearchHooks?: () => Promise<SearchHookMode | null>;\n /** Decision 4: \"Create a wallet now?\"; defaults to the clack confirm (default yes). */\n confirmWallet?: ConfirmFn;\n /** Prompt-sequence chrome. Seams so tests never load the renderer. */\n intro?: (message: string) => Promise<void>;\n outro?: (message: string) => Promise<void>;\n /** Whether the human walkthrough runs (TTY, no --json, stdin is a TTY). Injected in tests. */\n isInteractive?: boolean;\n /** Does a wallet already exist? Defaults to walletFileExists(dataDir). */\n walletExists?: (dataDir: string) => Promise<boolean>;\n /** An existing wallet's address, for the \"(existing)\" line. Defaults to the local provider. */\n walletAddress?: (ctx: CommandContext) => Promise<string>;\n /** Create a wallet and return its address. Defaults to runWalletCreate. */\n createWallet?: (ctx: CommandContext) => Promise<string>;\n /**\n * Passphrase-resolution seam forwarded to `wallet create` (OS-store exec, TTY\n * prompt, platform). Tests MUST set it: without it a headless install now\n * creates a real wallet, and on macOS that writes to the developer's own login\n * keychain under the `tenjin-cli` service.\n */\n walletPassphrase?: PassphraseOverrides;\n}\n\n/**\n * `tenjin install`: detect the installed harness(es), copy the packaged skills\n * into each one's skills directory, wire the AGENTS.md pointer, ask AT MOST FOUR\n * questions (publishing, harness permissions, search hooks, wallet), then run the\n * doctor checks over the machine those answers just produced and print a short\n * summary. Everything that is not one of those four decisions is display: the\n * security reference material lives in docs/agent-permissions.md, not in the\n * middle of a setup flow.\n *\n * A NON-INTERACTIVE RUN IS A USABLE INSTALL, not a stripped one. The permission\n * allowlist, the search hooks, the CLAUDE.md nudge and the wallet are all settled\n * by default when there is no one to ask, because the machine that most needs\n * them is exactly the one running headless. Each is disclosed in the output with\n * its undo and each has an opt-out flag.\n *\n * Like every command it is human-first (the global output contract): at a TTY\n * without `--json` it prompts and returns the walkthrough as humanLines, which\n * the dispatcher prints to stdout with no envelope. With `--json` or piped\n * stdout it returns the envelope and asks nothing. Idempotent: a re-run reports\n * up-to-date, never duplicates the AGENTS.md line, adds no permission rule twice,\n * and registers no hook twice. `--dry-run` writes nothing.\n */\nexport async function runInstall(\n input: InstallInput,\n ctx: CommandContext,\n deps: InstallDeps = {},\n): Promise<CommandResult> {\n return withInterruptGuard((markPhase) => installBody(input, ctx, deps, markPhase));\n}\n\n/** How far the command got, for the interrupt diagnostic. */\ntype InstallPhase = 'writing-skills' | 'wired';\n\n/**\n * Run `fn` with SIGINT/SIGTERM answered for the WHOLE command, not just the\n * blocks that hold a lock. The default signal action terminates without running\n * `finally`, stranding whichever lock the command holds so every later run times\n * out on it; install takes two (the config lock behind decision 1, and the\n * wallet-create lock behind decision 3, whose scrypt work is the longest\n * interruptible window this command has). Ownership is tracked by the lock\n * itself, so the handler releases exactly what this process holds and a run still\n * QUEUED behind another cannot touch that other run's lock.\n *\n * `markPhase` carries the diagnostic past the states no lock covers: the skills\n * write holds nothing (each file lands by its own atomic rename), so without it an\n * interrupt mid-copy would report that nothing changed.\n */\nasync function withInterruptGuard(\n fn: (markPhase: (phase: InstallPhase) => void) => Promise<CommandResult>,\n): Promise<CommandResult> {\n let phase: InstallPhase | undefined;\n const onSignal = (signal: NodeJS.Signals): void => {\n const wasWriting = ownsAnyLock() || phase === 'writing-skills';\n releaseOwnedLocks();\n // An external SIGINT/SIGTERM can land while a clack prompt has the terminal\n // in raw mode with the cursor hidden; process.exit skips clack's teardown.\n // (Ctrl-C at a prompt is unaffected: raw mode delivers it as a keypress.)\n if (process.stdin.isTTY) process.stdin.setRawMode?.(false);\n if (process.stdout.isTTY) process.stdout.write('\\x1b[?25h');\n process.stderr.write(\n wasWriting\n ? `\\nInterrupted mid-write. Some files may be half-written; re-run \\`tenjin install\\` to finish.\\n`\n : phase === 'wired'\n ? `\\nInterrupted after the skills were written; later setup steps may not have finished. Re-run \\`tenjin install\\` to finish.\\n`\n : '\\nInterrupted before anything was written; nothing changed.\\n',\n );\n process.exit(signal === 'SIGINT' ? 130 : 143);\n };\n process.on('SIGINT', onSignal);\n process.on('SIGTERM', onSignal);\n try {\n return await fn((p) => {\n phase = p;\n });\n } finally {\n process.off('SIGINT', onSignal);\n process.off('SIGTERM', onSignal);\n }\n}\n\nasync function installBody(\n input: InstallInput,\n ctx: CommandContext,\n deps: InstallDeps,\n markPhase: (phase: InstallPhase) => void,\n): Promise<CommandResult> {\n const parsed = InstallInputSchema.safeParse(input);\n if (!parsed.success) {\n throw new CliError('USAGE', 'Invalid install options', {\n fix: 'Run `tenjin install --help`.',\n details: parsed.error.issues,\n });\n }\n const dryRun = parsed.data.dryRun === true;\n const noWallet = parsed.data.noWallet === true;\n const noHooks = parsed.data.noHooks === true;\n const allowFreeVerbs = parsed.data.allowFreeVerbs;\n // Validate the enum flags UP FRONT so a bad value fails before any wiring.\n const publishModeFlag =\n parsed.data.publishMode !== undefined ? parseModeFlag(parsed.data.publishMode) : undefined;\n const searchHooksFlag =\n parsed.data.searchHooks !== undefined\n ? parseSearchHookModeFlag(parsed.data.searchHooks, '--search-hooks')\n : undefined;\n const env = deps.env ?? process.env;\n const home = deps.homeDir ?? homedir();\n // An empty or relative HOME (sudo/docker env_reset, systemd units) would make\n // every target below relative, silently installing into the current working\n // directory and reporting success while no harness reads a thing.\n if (!isAbsolute(home)) {\n throw new CliError(\n 'INTERNAL',\n 'The home directory did not resolve to an absolute path, so nothing was installed.',\n {\n fix: 'Set HOME to your home directory (`export HOME=...`), then re-run `tenjin install`.',\n },\n );\n }\n const which = deps.which ?? ((bin: string) => onPath(bin, env));\n\n // Human-first is the global output rule (emitSuccess renders humanLines at a TTY\n // without --json and no envelope). `humanOutput` matches that gate so install\n // returns its walkthrough as humanLines; `canPrompt` additionally needs stdin, so\n // a piped-stdin run still renders a walkthrough (with defaults, no wallet prompt).\n const humanOutput = ctx.flags.json === true ? false : (deps.isInteractive ?? ctx.io.isTTY);\n const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));\n\n const skillsSource =\n deps.skillsSourceDir ?? resolveSkillsSource(fileURLToPath(new URL('.', import.meta.url)));\n await assertSkillsSource(skillsSource);\n\n const plans = resolvePlans(parsed.data.harness, home, which);\n // Same condition resolvePlans treats as an override, so what gets recorded below is\n // exactly what overrode detection.\n const explicitHarness = parsed.data.harness !== undefined && parsed.data.harness.length > 0;\n // The CLAUDE.md nudge is written BY DEFAULT, on both paths, only\n // `--no-claude-md` suppresses it. Codex already got the same line in its\n const harnesses: HarnessResult[] = [];\n // Unlocked. What makes concurrent writers safe here is the per-file atomic\n // rename, not serialization: the rm-then-write this used to be had two runs\n // reading each other's half-built trees (7 of 15 concurrent runs failed on raw\n // ENOENT/ENOTEMPTY renames), and 24 concurrent runs pass without a lock. The\n // self-heal is the other writer, and it writes these same bytes to these same\n // paths through the same writer.\n if (!dryRun) markPhase('writing-skills');\n for (const plan of plans) {\n harnesses.push(await applyPlan(plan, skillsSource, dryRun));\n }\n await assertSkillsLanded(plans, dryRun);\n if (!dryRun) markPhase('wired');\n // An explicit --harness is REMEMBERED, before the embedded doctor run so this run's\n // own check already honours it. Detection cannot see a harness we do not probe for,\n // so without the record a directory the user named by hand is a target for one run\n // and then invisible to every later doctor — including for the #35 shadowing defect\n // it was chosen to hold. `--dry-run` records nothing, like the publish-mode write.\n if (explicitHarness && !dryRun) {\n await underDataDir(ctx.dataDir, () =>\n persistInstallHarness(\n ctx.dataDir,\n plans.map((p) => p.harness),\n ),\n );\n }\n // One-time cleanup of the pointer line older versions wrote into the operator's\n // CLAUDE.md / AGENTS.md. `install` writes no such line now: a skill's own\n // frontmatter description is the trigger surface the harness loads at session\n // start, so the line only duplicated it. Removing it here is what gets the\n // footprint off machines that already have one, since most people re-run\n // `install` far more often than they would run a cleanup command.\n const pointerCleanup = dryRun ? [] : await removeMarkerLines(home);\n\n // The four decisions, in order. Each one is skipped (with its own recorded\n // reason) when a flag already settled it or when there is no one to ask.\n if (canPrompt) await (deps.intro ?? clackIntro)('tenjin install');\n const publishMode = await underDataDir(ctx.dataDir, () =>\n resolvePublishMode(publishModeFlag, ctx, deps, dryRun, canPrompt),\n );\n const permissions = await resolvePermissions({\n plans,\n home,\n deps,\n flag: allowFreeVerbs,\n dryRun,\n canPrompt,\n publishMode: publishMode.value,\n });\n const hooks = await underDataDir(ctx.dataDir, () =>\n resolveHooks({ plans, home, ctx, deps, flag: searchHooksFlag, noHooks, dryRun, canPrompt }),\n );\n // On BOTH paths now: the loop this command sets up needs a key, so a headless\n // run creates one rather than leaving the operator a setup that stops at the\n // first buy or publish.\n const wallet = await underDataDir(ctx.dataDir, () =>\n resolveWallet(ctx, deps, walletSkip(dryRun, noWallet), canPrompt),\n );\n\n // AFTER all four decisions, never before (#101). The snapshot used to be taken\n // straight after the skills were written, so a run that created a wallet\n // reported \"No wallet\" in both the walkthrough and `data.doctor` — the checks\n // described a machine that had stopped existing three steps earlier. Collecting\n // here costs nothing extra (it is still one run) and is what makes the embedded\n // report describe the install it is reporting on: the wallet just created, and\n // the config `publish.mode` just written.\n //\n // It still inspects the same `home` install wrote into, so its skill-wiring\n // check reports THIS run's result rather than os.homedir()'s. `which` goes with\n // it: the check gates its verdicts on harness detection, and a different probe\n // there would judge directories this run never targeted.\n const doctorDeps: DoctorDeps = { ...(deps.doctorDeps ?? {}) };\n doctorDeps.homeDir ??= home;\n doctorDeps.which ??= which;\n const collect = deps.collectChecks ?? ((c) => collectDoctorChecks(c, doctorDeps));\n const doctor = await collect(ctx);\n\n if (canPrompt) await (deps.outro ?? clackOutro)('Setup complete.');\n\n const data = {\n dryRun,\n skillsSource,\n harnesses,\n // One-time cleanup, reported because it edits a file the operator owns. Older\n // versions wrote a pointer line into CLAUDE.md/AGENTS.md; nothing writes one\n // now, so an install that finds one removes it and says which file it touched.\n pointerCleanup,\n doctor: { status: doctor.failure !== undefined ? 'fail' : 'pass', checks: doctor.checks },\n publishMode,\n // Shipped with the install rather than left for the operator to discover after\n // their first auto-mode denial (#33). Static constants, no config key: see\n // lib/permissions.ts for why this is deliberately not operator-editable state.\n // `wired` is the outcome of THIS run's settings.json write; the three\n // recommendation tiers beside it are unchanged, so a machine consumer that\n // read `alwaysSafe` / `optIn` / `neverAllowlisted` before still does.\n permissions: { ...recommendedPermissions(publishMode.value), wired: permissions },\n hooks,\n wallet,\n };\n\n // Machine path (--json or piped stdout): the envelope, no prompts.\n if (!humanOutput) return { data };\n\n // Human path: the walkthrough as humanLines (the global emitSuccess prints them\n // to stdout at a TTY and never an envelope).\n const humanLines = buildWalkthrough(ctx.io, {\n pointerCleanup,\n dryRun,\n dataDir: ctx.dataDir,\n harnesses,\n publishMode,\n permissions,\n hooks,\n wallet,\n doctor,\n });\n return { data, humanLines };\n}\n\n/**\n * Why no wallet is being created at all, or undefined when one is. Being unable\n * to prompt is NOT on this list any more: a headless run creates by default.\n */\nfunction walletSkip(dryRun: boolean, noWallet: boolean): 'dry-run' | 'flag' | undefined {\n if (dryRun) return 'dry-run';\n if (noWallet) return 'flag';\n return undefined;\n}\n\n/**\n * The two steps that write to the Tenjin data dir, with a denial there reported as\n * the directory it is rather than as a raw errno under INTERNAL. The skills are\n * already on disk by now, so the message says what failed, not that nothing\n * happened.\n */\nasync function underDataDir<T>(dataDir: string, fn: () => Promise<T>): Promise<T> {\n try {\n return await fn();\n } catch (err) {\n if (!hasCode(err, 'EACCES') && !hasCode(err, 'EPERM')) throw err;\n throw new CliError('INTERNAL', `Could not use the Tenjin data directory ${dataDir}.`, {\n fix: `Permission denied. Check that you can write to it (\\`ls -ld ${dataDir}\\`), then re-run \\`tenjin install\\`.`,\n cause: err,\n });\n }\n}\n\nconst EXAMPLE_QUESTION = \"what actually changed in <library> v3's public API\";\n\ninterface WalkthroughState {\n dryRun: boolean;\n /** Legacy pointer files this run cleaned; disclosed because they are the\n * operator's own notes and we edited them. */\n pointerCleanup: string[];\n /** Where the wallet keystore lives, for the create disclosure. */\n dataDir: string;\n harnesses: HarnessResult[];\n publishMode: PublishModeSelection;\n permissions: PermissionsResult;\n hooks: HooksResult;\n wallet: WalletOutcome;\n doctor: DoctorChecks;\n}\n\n/**\n * The human surface: what happened, then what still needs you (#80). The summary\n * of at most five lines comes FIRST — it used to sit under the warnings, so a\n * first-time reader met \"Some checks need attention\" before learning anything had\n * succeeded and the whole run read as failure-then-success. On a clean install\n * the summary IS the output.\n *\n * The dry-run banner stays on top: it qualifies every line below it, so it is not\n * an attention item but a statement about what the rest of the output means.\n */\nfunction buildWalkthrough(io: Io, s: WalkthroughState): string[] {\n const lines: string[] = [];\n if (s.dryRun) {\n lines.push(paint(io, 'yellow', 'Dry run: nothing was written.'));\n lines.push('');\n }\n lines.push(...summaryLines(io, s));\n const notices = noticeLines(io, s);\n if (notices.length > 0) lines.push('', ...notices);\n return lines;\n}\n\n/**\n * Everything below the summary: per-harness warnings, the Codex network rule,\n * the nudge disclosure and its undo, and any doctor check that is not ok. A\n * green doctor says nothing at all, so a clean run stays five lines.\n */\nfunction noticeLines(io: Io, s: WalkthroughState): string[] {\n const lines: string[] = [];\n for (const h of s.harnesses) {\n if (h.hostedArrivedFirst) {\n // Named by DIRECTORY: one line per harness, and the funnel puts the mirror\n // in both, so an unqualified line appears twice and reads as a stutter.\n lines.push(\n paint(\n io,\n 'dim',\n `The hosted ${HOSTED_SKILL_NAME} skill was already in ${h.skillsDir}: kept as the zero-install fallback, and the CLI skills now take precedence.`,\n ),\n );\n }\n if (h.codexNetworkRule !== undefined) {\n lines.push(paint(io, 'dim', 'Codex blocks network by default; add to ~/.codex/config.toml:'));\n for (const rl of h.codexNetworkRule.split('\\n')) lines.push(paint(io, 'dim', ` ${rl}`));\n }\n for (const w of h.warnings) lines.push(paint(io, 'yellow', `! ${w}`));\n }\n // Not dim: we edited a file the operator writes their own notes in, and a line\n // saying so is the only way they learn it happened.\n if (s.pointerCleanup.length > 0) {\n lines.push(\n `Removed the old Tenjin pointer line from ${s.pointerCleanup.join(' and ')}; the skills carry their own triggers now.`,\n );\n }\n // Same reason as the pointer line above: we edited the operator's settings.json\n // to REMOVE something, and the only way they learn it happened is a line here.\n // Two different removals, and calling them one thing made the honest half a lie:\n // `publish` and `edit` are current commands whose RULES the mode no longer\n // carries, and reporting them as \"commands that no longer exist\" told the\n // operator their publish verb had been retired.\n const stale = s.permissions.removed.filter((r) => !MODE_GATED_RULES.includes(r));\n if (stale.length > 0) {\n lines.push(\n `Removed ${stale.length} permission rule(s) an older tenjin left in ${s.permissions.path ?? 'your settings'} for commands that no longer exist.`,\n );\n }\n // A run that wired permissions without being asked has to say so, and say how to\n // take it back. This is the disclosure that makes the non-interactive default\n // defensible: nothing lands silently, whether it was answered or defaulted.\n if (s.permissions.planned !== true && s.permissions.added.length > 0) {\n // The undo only. The count, the file and the link are already on the\n // Permissions line above, and saying them twice in one screen is the noise\n // this walkthrough keeps getting trimmed of. The exact rules stay out of the\n // terminal entirely; the envelope carries them in `permissions.wired.added`.\n lines.push(paint(io, 'dim', `Undo anytime: remove those lines from ${s.permissions.path}.`));\n }\n if (s.hooks.added.length > 0 || s.hooks.updated.length > 0) {\n lines.push(paint(io, 'dim', hooksDisclosure(s.hooks)));\n lines.push(\n paint(io, 'dim', hooksUndo(s.hooks.path ?? '~/.claude/settings.json', s.hooks.scriptsDir)),\n );\n // NOT dim, unlike the disclosure above it: settings.json hooks are read once\n // at session start, so an operator who does not restart gets no hook activity\n // at all and nothing telling them why. That silence is the whole reason this\n // line exists, so it must not read as fine print.\n lines.push(\n `${paint(io, 'bold', 'Restart Claude Code')} to load them; hooks are read once at session start.`,\n );\n }\n if (s.hooks.warning !== undefined) {\n lines.push(paint(io, 'yellow', `! ${sanitizeForTerminal(s.hooks.warning)}`));\n }\n for (const line of walletDisclosure(s.wallet, s.dataDir)) lines.push(paint(io, 'dim', line));\n if (s.wallet.warning !== undefined) {\n lines.push(paint(io, 'yellow', `! ${sanitizeForTerminal(s.wallet.warning)}`));\n }\n if (s.permissions.warning !== undefined) {\n // Sanitized for the same reason doctorNotices sanitizes `detail`/`fix`: this\n // string embeds a V8 JSON parse error, and V8 quotes the offending input, so\n // ~20 bytes of whatever is in settings.json (escapes included) reach the\n // terminal at the moment we tell the operator we left their file alone.\n lines.push(paint(io, 'yellow', `! ${sanitizeForTerminal(s.permissions.warning)}`));\n }\n lines.push(...doctorNotices(io, s.doctor, s.wallet));\n return lines;\n}\n\n/**\n * The closing summary, capped at one line per subject: skills, publishing,\n * permissions, wallet, and the command to run next.\n */\nfunction summaryLines(io: Io, s: WalkthroughState): string[] {\n return [\n ...s.harnesses.map((h) => skillsLine(io, h, s.dryRun)),\n publishingLine(io, s.publishMode.value, s.permissions),\n permissionsLine(io, s.permissions),\n hooksLine(io, s.hooks),\n walletLine(io, s.wallet),\n `${paint(io, 'bold', 'Next:')} tenjin search \"${EXAMPLE_QUESTION}\"`,\n ];\n}\n\n/** What the hooks do, in one line, at the moment they are written. */\nfunction hooksDisclosure(h: HooksResult): string {\n const shared =\n 'A Stop hook reminds you locally when a MISS you searched for is still unpublished; it makes no network call.';\n if (h.mode === 'remind') {\n return `The WebSearch hook prints a one-line reminder that Tenjin may have an answer; it sends nothing off-machine. ${shared}`;\n }\n return `Before a web search, the WebSearch hook asks tenjin.blog the same question (free and anonymous, ~2s budget, 5s harness kill) and mentions a tested answer if one exists; the query text leaves the machine. It can never block or change the search. ${shared}`;\n}\n\n/**\n * One line for the harness hooks. A skip is never silent, for the same reason the\n * permissions line is never silent: the operator would otherwise find out by\n * noticing that nothing ever happens.\n */\nfunction hooksLine(io: Io, h: HooksResult): string {\n const label = paint(io, 'bold', 'Search hooks:');\n const wrote = h.added.length + h.updated.length;\n if (wrote > 0) {\n return `${paint(io, 'green', '✓')} ${label} ${h.mode} mode, ${wrote} hook(s) registered in ${h.path}. Change: tenjin config set hooks.searchMode <auto|remind|off>`;\n }\n if (h.skipped === undefined) {\n return `${paint(io, 'green', '✓')} ${label} ${h.mode} mode, already registered in ${h.path}`;\n }\n if (h.skipped === 'harness-not-claude') {\n return `${paint(io, 'dim', '-')} ${label} not wired (Claude Code only).`;\n }\n if (h.skipped === 'dry-run') {\n return `${paint(io, 'dim', '-')} ${label} unchanged (dry run).`;\n }\n if (h.skipped === 'mode-off') {\n return `${paint(io, 'dim', '-')} ${label} off (hooks.searchMode). Turn them on: tenjin config set hooks.searchMode auto, then tenjin install`;\n }\n if (h.skipped === 'declined') {\n return `${paint(io, 'dim', '-')} ${label} not registered this run; nothing was configured. Register them: tenjin install`;\n }\n if (h.skipped === 'changed-since-read') {\n return `${paint(io, 'yellow', '!')} ${label} ${h.path} changed while it was being updated, so nothing was written. Re-run: tenjin install`;\n }\n return `${paint(io, 'yellow', '!')} ${label} ${h.path} was left untouched. Fix it, then: tenjin install`;\n}\n\nfunction harnessLabel(h: Harness): string {\n return h === 'claude' ? 'Claude Code' : h === 'codex' ? 'Codex' : 'Agent Skills';\n}\n\n/**\n * One line per harness. It names the skills rather than counting them: #35\n * shipped as \"search worked, publish was simply absent\" on a machine that\n * already had the hosted skill, and a bare \"3 skills installed\" cannot tell you\n * publish is wired.\n */\nfunction skillsLine(io: Io, h: HarnessResult, dryRun: boolean): string {\n const changed = h.skills.some((s) => s.status !== 'up-to-date');\n const verb = dryRun ? 'would install' : changed ? 'installed' : 'up to date';\n const head = `${harnessLabel(h.harness)}: ${h.skills.length} skills ${verb}`;\n return `${paint(io, 'green', '✓')} ${paint(io, 'bold', head)} in ${h.skillsDir}. ${skillRoster(h)}.`;\n}\n\n/**\n * One line for the settled consent mode, with the same consequence the question\n * showed, and the way back out when this run actually granted something.\n *\n * The grant used to get two more lines of its own, reciting both rule strings and\n * all three undos. An operator meeting `Bash(tenjin publish:*)` for the first time\n * mid-install cannot act on it, and three undos for one decision is a menu, not a\n * disclosure. The full story (exact rules, keystore, session mint, flag caveats,\n * all three undos) is unchanged in docs/agent-permissions.md, `doctor --json`, and\n * this command's own `--json` envelope; the terminal gets the one command that\n * turns it off.\n */\nfunction publishingLine(io: Io, mode: PublishMode, wired: PermissionsResult): string {\n const undo =\n wired.modeGrant === undefined\n ? ''\n : ` ${paint(io, 'dim', wired.planned === true ? 'Would turn off:' : 'Turn off:')} tenjin config set publish.mode review`;\n return `${paint(io, 'green', '✓')} ${paint(io, 'bold', `Publishing: ${mode}`)}. ${modeBlurb(mode)}${undo}`;\n}\n\n/**\n * One line for the harness allowlist: what landed, or what to run to get it. A\n * skip is never silent, because the operator's next auto-mode session is where\n * they would otherwise find out (#33).\n *\n * The count is every rule of ours now in the file, and the word \"free\" is gone\n * with it: it was there to keep `publish` and `edit` out of a total that called\n * them free verbs, and a line that just says how many tenjin commands are allowed\n * needs no such qualifier. What the rules ARE, and what they clear, is one link\n * away rather than recited here.\n */\nfunction permissionsLine(io: Io, p: PermissionsResult): string {\n const label = paint(io, 'bold', 'Permissions:');\n const allowed = p.added.length + p.alreadyPresent.length;\n /**\n * What a `review` install took back, said on EVERY branch rather than on the\n * two that happened to be written first.\n *\n * The retraction runs above the guards that decline a write, so a run can\n * retract and then skip: `--no-allow-free-verbs` said \"unchanged\" and\n * `--harness shared` said \"not wired (Claude Code only)\", both over a\n * settings.json the same run had just deleted two rules from. The second was\n * the worse of the two, since it tells the operator their Claude settings were\n * left alone. Hoisted, so a branch that forgets it reads wrong at review time\n * rather than shipping.\n */\n const retracted = p.removed.filter((r) => MODE_GATED_RULES.includes(r));\n /**\n * PAST TENSE FOR A RUN, FUTURE FOR A PLAN. `planFreeVerbAllowlist` fills\n * `removed` with what a real run WOULD take back, so a dry run reaching the\n * past-tense sentence reports a deletion that never happened.\n */\n const gaveBack =\n retracted.length === 0\n ? ''\n : p.planned === true\n ? ` A real run would remove ${retracted.length} rule(s) for publish and edit from ${p.path ?? 'your settings'}.`\n : ` Publishing is back to asking first, so ${retracted.length} rule(s) for publish and edit were removed from ${p.path ?? 'your settings'}.`;\n /**\n * Nothing was written AND nothing was taken back: only then is \"unchanged\" the\n * honest word. Gated on `planned` too, because a dry run changes nothing by\n * definition, and \"otherwise unchanged\" there qualified against a retraction the\n * line never named.\n */\n const unchanged =\n retracted.length === 0 || p.planned === true ? 'unchanged' : 'otherwise unchanged';\n\n // A dry run reports the PLAN in the same fields, so it takes this branch and\n // says \"would allow\". An operator dry-running to find out whether publish and\n // edit get granted was previously told only \"unchanged (dry run)\".\n if (p.planned === true && p.added.length > 0) {\n return `${paint(io, 'dim', '-')} ${label} would allow ${allowed} tenjin commands in ${p.path}. Details: ${PERMISSIONS_DOC_URL}`;\n }\n if (p.added.length > 0) {\n return `${paint(io, 'green', '✓')} ${label} ${allowed} tenjin commands allowed in ${p.path}.${gaveBack} Details: ${PERMISSIONS_DOC_URL}`;\n }\n if (p.skipped === undefined) {\n return `${paint(io, 'green', '✓')} ${label} the ${FREE_VERB_RULES.length} free tenjin commands were already allowed in ${p.path}.${gaveBack}`;\n }\n if (p.skipped === 'harness-not-claude') {\n return `${paint(io, 'dim', '-')} ${label} not wired for this harness (Claude Code only).${gaveBack} The lines your harness needs: ${PERMISSIONS_DOC_URL}`;\n }\n if (p.skipped === 'dry-run') {\n return `${paint(io, 'dim', '-')} ${label} ${unchanged} (dry run); the ${FREE_VERB_RULES.length} rules a real run needs are already there.${gaveBack}`;\n }\n if (p.skipped === 'declined' || p.skipped === 'not-requested') {\n return `${paint(io, 'dim', '-')} ${label} ${unchanged}.${gaveBack} Allow the ${FREE_VERB_RULES.length} free tenjin commands with: tenjin install --allow-free-verbs`;\n }\n if (p.skipped === 'changed-since-read') {\n // Nothing is wrong with the file and the flag is not the remedy: another\n // writer touched it mid-run, so the merge has to be recomputed against what\n // is there now. The catch-all below says \"fix it\", which is wrong here.\n return `${paint(io, 'yellow', '!')} ${label} ${p.path} changed while it was being updated, so nothing was written.${gaveBack} Re-run: tenjin install`;\n }\n return `${paint(io, 'yellow', '!')} ${label} ${p.path} was left untouched.${gaveBack} Fix it, then: tenjin install --allow-free-verbs`;\n}\n\nfunction walletLine(io: Io, w: WalletOutcome): string {\n const label = paint(io, 'bold', 'Wallet:');\n if (w.status === 'existing') {\n return `${paint(io, 'green', '✓')} ${label} ${w.address} (existing). Check funds with: tenjin wallet balance`;\n }\n if (w.status === 'created') {\n return `${paint(io, 'green', '✓')} ${label} ${w.address}, holding $0. Fund it with a few dollars of USDC on Base, then: tenjin wallet balance`;\n }\n if (w.status === 'skipped') {\n const icon = w.reason === 'no-passphrase-store' || w.reason === 'create-failed' ? '!' : '-';\n const color = icon === '!' ? 'yellow' : 'dim';\n return `${paint(io, color, icon)} ${label} none (${w.reason}). ${w.fix}`;\n }\n return `${paint(io, 'dim', '-')} ${label} none. Create one later with: tenjin wallet create`;\n}\n\n/**\n * What a freshly created wallet means, at the moment it is created. Three things\n * an operator has to know and would otherwise learn the hard way: it is empty,\n * only a human can fund it, and where the key lives.\n */\nfunction walletDisclosure(w: WalletOutcome, dataDir: string): string[] {\n if (w.status !== 'created') return [];\n return [\n `A wallet was created at ${walletPath(dataDir)}: the key is encrypted at rest (keystore v3, scrypt, mode 0600) and never leaves this machine.`,\n 'It holds $0. Funding it is a human step: run `tenjin fund` (card checkout via Coinbase, opened in your browser), or send USDC on Base to that address.',\n ];\n}\n\n/** `tenjin-search, tenjin-publish (CLI); tenjin (hosted, zero-install fallback)`. */\nfunction skillRoster(h: HarnessResult): string {\n const cli = h.skills.filter((s) => s.cli).map((s) => s.name);\n const hosted = h.skills.filter((s) => !s.cli).map((s) => s.name);\n const parts: string[] = [];\n if (cli.length > 0) parts.push(`${cli.join(', ')} (CLI)`);\n if (hosted.length > 0) parts.push(`${hosted.join(', ')} (hosted, zero-install fallback)`);\n return parts.join('; ');\n}\n\n/**\n * The single line of consequence attached to a mode, wherever it is shown.\n *\n * `auto` used to end \"your harness still shows each command for approval\", which\n * stopped being true the moment the mode started writing its own harness rules.\n * The clause is gone rather than reworded: the thing an operator needs at this\n * moment is that publishing happens without them, under their name.\n */\nfunction modeBlurb(v: PublishMode): string {\n return v === 'auto'\n ? 'Your agent publishes and updates pieces on its own, under your identity.'\n : v === 'review'\n ? 'Your agent asks you in chat before every publish.'\n : 'Your agent publishes on its own, under your identity, and only a hard block stops it.';\n}\n\n/**\n * The wallet decision. A wallet is now created BY DEFAULT on both paths, because\n * the loop this command exists to set up does not close without one: `buy` needs\n * a funded key and publish-on-MISS needs a key to sign the write, so a walletless\n * install is a setup that stops at the first useful thing the agent tries.\n *\n * The headless path is the change. It creates without asking, using the\n * passphrase policy `resolvePassphraseForCreate` already enforces: an explicit\n * `TENJIN_WALLET_PASSPHRASE`, else a strong generated passphrase written to the\n * platform's OS credential store and verified by reading it back. When neither is\n * available it creates NOTHING and reports `skipped: no-passphrase-store` with\n * both remedies. There is deliberately no plain-file fallback: a passphrase\n * sitting next to the keystore it unlocks protects nothing, and an install is\n * never the right place to invent one.\n *\n * A creation failure never fails the install. The skills, hooks and permissions\n * this run just wired are all useful without a wallet, so the failure is reported\n * loudly and the command still succeeds.\n */\nasync function resolveWallet(\n ctx: CommandContext,\n deps: InstallDeps,\n skipReason: 'dry-run' | 'flag' | undefined,\n canPrompt: boolean,\n): Promise<WalletOutcome> {\n const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);\n if (exists) {\n return {\n status: 'existing',\n address: await (deps.walletAddress ?? existingWalletAddress)(ctx),\n };\n }\n if (skipReason !== undefined) {\n return { status: 'skipped', reason: skipReason, fix: walletFix(skipReason) };\n }\n\n // Interactive keeps the question (default yes); headless has nobody to ask and\n // takes the default rather than treating silence as a no.\n if (canPrompt) {\n const confirm = deps.confirmWallet ?? defaultConfirm;\n if (!(await confirm(WALLET_QUESTION))) return { status: 'declined' };\n }\n\n try {\n const create =\n deps.createWallet ??\n ((c: CommandContext) => defaultCreateWallet(c, deps.walletPassphrase, deps.env));\n return { status: 'created', address: await create(ctx) };\n } catch (err) {\n // The one failure with a real remedy: no env passphrase and no OS store, so\n // resolvePassphraseForCreate refused rather than encrypt with a passphrase\n // that has no durable copy. Anything else is reported as itself.\n const reason: WalletSkipReason = isNoPassphraseError(err)\n ? 'no-passphrase-store'\n : 'create-failed';\n return {\n status: 'skipped',\n reason,\n fix: walletFix(reason),\n ...(reason === 'create-failed'\n ? { warning: `The wallet could not be created: ${errorText(err)}` }\n : {}),\n };\n }\n}\n\n/** Is this the passphrase layer refusing because no durable store could serve? */\nfunction isNoPassphraseError(err: unknown): boolean {\n return (\n err instanceof CliError &&\n err.code === 'USAGE' &&\n err.message.includes('No wallet passphrase is available')\n );\n}\n\nfunction errorText(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\nasync function existingWalletAddress(ctx: CommandContext): Promise<string> {\n return (await describeWallet(resolveWalletProvider(ctx))).address;\n}\n\nasync function defaultCreateWallet(\n ctx: CommandContext,\n passphrase?: PassphraseOverrides,\n env?: NodeJS.ProcessEnv,\n): Promise<string> {\n const result = await runWalletCreate(ctx, {\n ...(passphrase !== undefined ? { passphrase } : {}),\n ...(env !== undefined ? { env } : {}),\n });\n return (result.data as { address: string }).address;\n}\n\n/** The shared confirm, defaulting to YES (setup ergonomics); cancel reads as no. */\nfunction defaultConfirm(label: string): Promise<boolean> {\n return confirmChoice(label, true);\n}\n\n/**\n * Doctor problems only. A fully green run prints nothing here: the summary is\n * the whole output, and \"everything checks out\" is what an absent warning means.\n *\n * The \"no wallet\" warn is dropped when the summary already carries it (#80): the\n * summary's own wallet line says `none` and names the same `tenjin wallet create`,\n * and someone who only wants `tenjin search` does not need it twice, in yellow,\n * for a wallet they were just told is optional. Every other wallet warn — a\n * keystore that will not open, an invalid TENJIN_WALLET_KEY, loose file\n * permissions — still prints, because nothing else in the output says it.\n *\n * Hence `isNoWalletCheck` rather than the check's NAME. `resolveWallet` probes for\n * a wallet FILE, so it reports no wallet for a machine whose credential is a\n * broken env key; matching on the name suppressed doctor's warning about it and\n * left the run silent about the only wallet state install cannot describe itself.\n *\n * `summaryAlreadySaysNoWallet` covers BOTH ways this run can end without one, and\n * both print the same `tenjin wallet create` pointer: `declined` (the operator\n * said no) and `skipped` (never asked, or the passphrase had nowhere to live).\n * `created` and `existing` never suppress, since there IS a wallet and any warn\n * about it is news.\n */\nfunction summaryAlreadySaysNoWallet(wallet: WalletOutcome): boolean {\n return wallet.status === 'declined' || wallet.status === 'skipped';\n}\n\nfunction doctorNotices(io: Io, doctor: DoctorChecks, wallet: WalletOutcome): string[] {\n const problems = doctor.checks.filter(\n (c) => c.status !== 'ok' && !(summaryAlreadySaysNoWallet(wallet) && isNoWalletCheck(c)),\n );\n if (problems.length === 0) return [];\n const lines = [paint(io, 'yellow', 'Some checks need attention:')];\n for (const c of problems) {\n const icon = c.status === 'fail' ? paint(io, 'red', '✗') : paint(io, 'yellow', '!');\n // Same seam as renderDoctorHuman: `detail`/`fix` carry server-sourced substrings.\n lines.push(` ${icon} ${c.name}: ${sanitizeForTerminal(c.detail)}`);\n if (c.fix !== undefined) {\n lines.push(paint(io, 'dim', ` fix: ${sanitizeForTerminal(c.fix)}`));\n }\n }\n return lines;\n}\n\n// --- Publish-mode selection (D38 setup) ------------------------------------------\n\n/**\n * The STORED default: what a `--dry-run` or a cancelled question leaves\n * `publish.mode` at, which is to say unset. A NON-INTERACTIVE run no longer lands\n * here; it settles RECOMMENDED_MODE below, because leaving the key unset made a\n * headless install the one path where the agent's publishing consent silently\n * differed from what the operator would have been shown. This value is now the\n * \"nobody chose anything and nothing was written\" answer only.\n */\nconst DEFAULT_MODE: PublishMode = CONFIG_DEFAULTS.publish.mode;\n\n/**\n * What a headless run settles on, and it is the SAME answer the interactive\n * select recommends (PUBLISH_MODE_CHOICES' initialValue), not the stored default.\n * That equality is the point: \"non-interactive is an interactive all-yes\" has to\n * be true of publishing too, or the sentence is wrong about the one decision\n * that governs what the agent puts on a public marketplace.\n */\nconst RECOMMENDED_MODE: PublishMode = 'auto';\n\n/** Decision 1's literal copy: one line of consequence per option, `auto` first. */\nexport const PUBLISH_MODE_CHOICES = [\n {\n value: 'auto',\n label: 'Auto (recommended)',\n hint: 'your agent publishes and updates pieces on its own, under your identity',\n },\n { value: 'review', label: 'Ask me in chat first' },\n { value: 'full-auto', label: 'Fully unattended', hint: 'only a hard block stops it' },\n] as const satisfies readonly { value: PublishMode; label: string; hint?: string }[];\n\nexport const PUBLISH_MODE_QUESTION = 'When your agent has something worth publishing:';\n\n/**\n * Resolve (and, for an explicit choice, persist) the publish consent mode at\n * install time. Precedence: `--publish-mode` flag > an already-configured global\n * mode > the interactive select > the headless settle > the untouched default.\n * A cancelled select and `--dry-run` write nothing and leave `publish.mode` unset\n * so its provenance stays `default`; a non-interactive run SETTLES the\n * recommended mode, which is the one case that writes without being asked.\n */\nasync function resolvePublishMode(\n flag: PublishMode | undefined,\n ctx: CommandContext,\n deps: InstallDeps,\n dryRun: boolean,\n interactive: boolean,\n): Promise<PublishModeSelection> {\n if (flag !== undefined) {\n if (!dryRun) await persistPublishMode(ctx.dataDir, flag); // --dry-run: would-set only\n return { value: flag, source: 'flag' };\n }\n\n // Only the GLOBAL config file counts as \"already configured\" for setup: env/flag\n // are per-run and a project `.tenjin.json` is not this machine's global choice.\n const config = await loadRawConfig(ctx.dataDir);\n if (config.publish?.mode !== undefined) {\n return { value: config.publish.mode, source: 'existing' };\n }\n\n // A dry run asks nothing and writes nothing, so it reports the untouched\n // default rather than the mode a real run would settle.\n if (dryRun) return { value: DEFAULT_MODE, source: 'default-skipped' };\n\n // `interactive` is the walkthrough gate (already false under --json or off a\n // TTY), so a machine consumer never sits behind a prompt. It SETTLES the\n // recommended mode rather than leaving the key unset: every other decision this\n // command makes headlessly lands on what an interactive yes would have chosen,\n // and leaving this one alone made a headless install the only path where the\n // agent's publishing consent silently differed from the one the operator was\n // shown. An already-configured mode was returned above, so this only ever\n // writes where nothing was set.\n if (!interactive) {\n await persistPublishMode(ctx.dataDir, RECOMMENDED_MODE);\n return { value: RECOMMENDED_MODE, source: 'headless-default' };\n }\n\n const answer = await (deps.promptPublishMode ?? defaultPromptPublishMode)();\n if (answer === null) return { value: DEFAULT_MODE, source: 'default-skipped' }; // cancelled: no write\n // The seam is injectable, so an answer is validated rather than trusted; an\n // unparseable one is a cancel, not a write of something unknown.\n const parsed = PublishModeSchema.safeParse(answer);\n if (!parsed.success) return { value: DEFAULT_MODE, source: 'default-skipped' };\n await persistPublishMode(ctx.dataDir, parsed.data);\n return { value: parsed.data, source: 'prompt' };\n}\n\nfunction defaultPromptPublishMode(): Promise<PublishMode | null> {\n return selectOne<PublishMode>({\n message: PUBLISH_MODE_QUESTION,\n choices: PUBLISH_MODE_CHOICES.map((c) => ({ ...c })),\n initialValue: 'auto',\n });\n}\n\nfunction parseModeFlag(value: string): PublishMode {\n return parsePublishModeFlag(value, '--publish-mode');\n}\n\n// --- Harness permissions (decision 2) ---------------------------------------------\n\n/**\n * Decision 2's literal copy: one question, and a consequence that lib/permissions.ts\n * would agree with. NOT \"read-only\" and NOT \"never touches your wallet\" — that\n * module refuses both claims in as many words (`search` and `outcome` POST\n * off-machine, `read` saves to the library and can present a cached\n * wallet-derived delegation, and two of the nine rules are `wallet show` /\n * `wallet balance`). What is actually true of the whole tier is that it cannot\n * spend and cannot move your keys, so that is what the question says.\n *\n * The pointer is how FLAG_CAVEAT reaches the consent moment: the walkthrough\n * prints neither the rules nor the flag caveat, so the yes/no that replaced them\n * names where both live in full. It used to point at `tenjin doctor`, which\n * printed them; doctor now points at the same page (#81).\n */\n/**\n * The consent moment, in two sentences and a link.\n *\n * This question used to recite the tier: a count of \"free\" commands, which of\n * them send data, what `doctor` does to the wallet, and (once the pair started\n * landing here) both rule strings verbatim. An operator meeting `Bash(tenjin\n * publish:*)` for the first time at a yes/no prompt cannot act on any of it, and\n * a prompt nobody finishes reading is not consent.\n *\n * Two facts survive, because they are the two a human can actually decide on:\n * this cannot spend their money, and on an auto mode their agent will publish\n * under their name without being asked. Everything else (the exact rules, the\n * keystore, the read+write session mint, the `--base-url` and `--yes` caveats,\n * all three undos) is unchanged one link away in docs/agent-permissions.md, and\n * in `doctor --json` and this command's `--json` envelope for an agent reading it.\n *\n * Counts come from the rule sets, so a verb added to either tier cannot make the\n * question lie.\n */\nfunction permissionsQuestionHead(mode: PublishMode): string {\n const count = rulesForPublishMode(mode).length;\n return `Let your agent use tenjin without permission popups? Adds ${count} command rules to ~/.claude/settings.json.`;\n}\n\nexport const PERMISSIONS_QUESTION = `${permissionsQuestionHead('review')} None of them can spend your money. Details: ${PERMISSIONS_DOC_URL}`;\n\n/** The same question, plus the one thing an auto mode changes about the answer. */\nexport function permissionsQuestion(mode: PublishMode): string {\n if (mode === 'review') return PERMISSIONS_QUESTION;\n return `${permissionsQuestionHead(mode)} None of them can spend your money, and on publish.mode ${mode} your agent will publish under your identity on its own. Details: ${PERMISSIONS_DOC_URL}`;\n}\n\n/** The wallet decision's literal copy. */\nexport const WALLET_QUESTION = 'Create a wallet now?';\n\n/**\n * Settle the harness allowlist. The write itself is free-verb only and cannot\n * widen (see lib/harness-permissions.ts); this decides ONLY whether to call it.\n *\n * Precedence: `--no-allow-free-verbs` refuses outright, `--allow-free-verbs`\n * wires it, an interactive run asks, and a NON-INTERACTIVE run wires it. That\n * last arm is the change #33 was really asking for: the machine most likely to be\n * denied mid-task is the headless one, and leaving it unwired because nobody was\n * there to say yes made a bare `tenjin install` produce an install that does not\n * work. The disclosure and the undo ride the output on both paths.\n *\n * INSTALLING TENJIN IS THE CONSENT for the mode-gated rules (owner call, PR #164\n * review round). The allowlist is written for the mode this run settles, on every\n * path including the headless one, and the FIRST install writes it — there is no\n * \"chosen vs defaulted\" distinction. What makes that defensible is that it is\n * DOCUMENTED, on the surface each reader is actually using. A human gets\n * `publishingLine`: what the agent will now do, in plain words, plus the one\n * command that turns it off. An agent, and any headless run, gets `modeGrant` on\n * the `--json` envelope, carrying both rule strings, the keystore sentence and\n * all three undos. docs/agent-permissions.md carries the rest. The terminal is\n * deliberately the leanest of the three (owner call): a rule string an operator\n * is meeting for the first time mid-install is not disclosure they can act on.\n * The bare CLI, with no install ever run, still defaults to `review` — install is\n * the consent anchor, so nothing is granted to someone who never ran it.\n *\n * The probe runs on EVERY path that might write, including the headless ones.\n * Nothing left to grant is not a question and not a write: it is the ordinary\n * state of a re-run, and returning the SNAPSHOT's own result is what makes a\n * re-run report `alreadyPresent` accurately instead of an empty pair. It also\n * keeps the consent gate honest, because calling the writer after a zero-pending\n * probe would re-read the file and silently re-add a rule revoked in between. An\n * unreadable file is \"unknown\", never \"already allowed\", so it falls through.\n */\nasync function resolvePermissions(args: {\n plans: HarnessPlan[];\n home: string;\n deps: InstallDeps;\n flag: boolean | undefined;\n dryRun: boolean;\n canPrompt: boolean;\n /**\n * The mode decision 1 just settled, never a raw flag or a project file: the\n * rule set follows what this install is putting the machine on, so the two\n * decisions cannot disagree.\n */\n publishMode: PublishMode;\n}): Promise<PermissionsResult> {\n const { plans, home, deps, flag, dryRun, canPrompt, publishMode } = args;\n\n // A dry run writes nothing, so it settles before the retraction rather than\n // after it: what it owes the operator is the plan, not a revocation.\n if (dryRun) return (deps.planPermissions ?? planFreeVerbAllowlist)(home, publishMode);\n\n /**\n * TIGHTENING FIRST, above every guard below, because none of them is about a\n * retraction. `--no-allow-free-verbs` declines a WRITE OF OURS; it is not a\n * request to keep a grant the operator just revoked by moving to `review`, and\n * ordering it first let `install --publish-mode review --no-allow-free-verbs`\n * write `mode: review` to config.json, leave both mode-gated rules allowed, and\n * report `skipped: declined` with a fix telling the operator to ADD rules on the\n * run where they asked to revoke. The `--harness` guard is the same shape: it\n * scopes a write to the harnesses this run targets, and a Claude rule this CLI\n * wrote is ours to reclaim whichever harness is being installed today.\n *\n * The one thing that CANNOT fall through is a file we could not read: the\n * additive writer refuses it for the same reason, so there is nothing to fall\n * through to, and the retraction's own `fix` names the pair where the writer's\n * does not.\n */\n let retractedRules: string[] = [];\n let retractedFrom: string | undefined;\n if (publishMode === 'review') {\n const retracted = await (deps.retractModeGated ?? retractModeGatedRules)(home);\n if (retracted.skipped !== undefined) return retracted;\n retractedRules = retracted.removed;\n retractedFrom = retracted.path;\n }\n\n /**\n * Carry what the retraction took back onto whatever the rest of this function\n * returns. It used to RETURN the retraction, which jumped the additive pass and\n * the legacy sweep both: a review-install on a machine holding only the pair\n * retracted them, reported \"the 9 free tenjin commands were already allowed\"\n * over a file holding none of them, left a stranded legacy rule in place, and\n * made the operator run install twice to get the tier.\n */\n const withRetraction = (result: PermissionsResult): PermissionsResult =>\n retractedRules.length === 0\n ? result\n : {\n ...result,\n removed: [...retractedRules, ...result.removed],\n // A non-Claude skip carries no `path`, deliberately: naming a Claude\n // file to a Codex-only operator points them at a file that is nothing\n // to do with their harness. Once we have RETRACTED from that file, the\n // reverse is true, and the operator needs to know which file changed.\n ...(result.path === undefined ? { path: retractedFrom } : {}),\n };\n\n // Only Claude Code has a settings file with this shape. Codex and the shared\n // Agent Skills location gate permissions elsewhere, so there is nothing here to\n // write for them, and guessing at another harness's config would be the kind of\n // uninvited write this whole module is careful about.\n if (!plans.some((p) => p.harness === 'claude')) {\n return withRetraction(\n permissionsSkipped(plans[0]?.harness ?? 'shared', home, 'harness-not-claude'),\n );\n }\n if (flag === false) return withRetraction(permissionsSkipped('claude', home, 'declined'));\n\n const probe = await (deps.inspectPermissions ?? inspectFreeVerbRules)(home, publishMode);\n if (probe.satisfied !== undefined) return withRetraction(probe.satisfied);\n // Nothing to GRANT, but something of ours to retract: an older version's rule\n // for a command that no longer exists, or the publish rule under a mode that\n // no longer carries it. That needs no consent — it only ever removes a rule\n // this CLI wrote — so it runs without the prompt.\n if (probe.pending !== null && probe.pending.length === 0) {\n return withRetraction(await wireFreeVerbAllowlist(home, publishMode));\n }\n\n if (flag === true || !canPrompt) {\n return withRetraction(await wireFreeVerbAllowlist(home, publishMode));\n }\n\n const confirm = deps.confirmPermissions ?? defaultConfirm;\n if (!(await confirm(permissionsQuestion(publishMode)))) {\n return withRetraction(permissionsSkipped('claude', home, 'declined'));\n }\n return withRetraction(await wireFreeVerbAllowlist(home, publishMode));\n}\n\n// --- Search hooks (decision 3) ----------------------------------------------------\n\n/**\n * The search-hook question's literal copy. It names both hooks, because they are\n * installed together and the second one is the surprising half: an operator who\n * agreed to \"check Tenjin before a web search\" has not thereby agreed to a\n * reminder at the end of every turn, so the question says both out loud.\n */\nexport const SEARCH_HOOKS_QUESTION = 'Let Tenjin ride along with your web searches?';\n\nexport const SEARCH_HOOKS_CHOICES = [\n {\n value: 'auto',\n label: 'Yes, check Tenjin first (recommended)',\n hint: 'before a WebSearch, ask tenjin.blog the same question (free, anonymous, 2s budget) and mention a tested answer; the query text leaves the machine',\n },\n {\n value: 'remind',\n label: 'Just remind me',\n hint: 'a one-line reminder, nothing sent off-machine',\n },\n { value: 'off', label: 'No hooks', hint: 'nothing is registered' },\n] as const satisfies readonly { value: SearchHookMode; label: string; hint?: string }[];\n\n/**\n * Settle the harness hooks. Same shape as the allowlist decision and the same\n * default posture: a flag settles it, an interactive run asks, and a\n * non-interactive run wires `auto` with the disclosure and undo in its output.\n *\n * The chosen mode is PERSISTED to config, so it is the script's behavior from\n * then on and `tenjin config set hooks.searchMode` is enough to change it later\n * without re-installing. A `--dry-run` persists nothing, like the publish mode.\n */\nasync function resolveHooks(args: {\n plans: HarnessPlan[];\n home: string;\n ctx: CommandContext;\n deps: InstallDeps;\n flag: SearchHookMode | undefined;\n noHooks: boolean;\n dryRun: boolean;\n canPrompt: boolean;\n}): Promise<HooksResult> {\n const { plans, home, ctx, deps, flag, noHooks, dryRun, canPrompt } = args;\n const dataDir = ctx.dataDir;\n const stored = (await loadRawConfig(dataDir)).hooks?.searchMode;\n\n if (!plans.some((p) => p.harness === 'claude')) {\n const harness = plans[0]?.harness ?? 'shared';\n return hooksSkipped(\n harness,\n home,\n dataDir,\n flag ?? stored ?? DEFAULT_HOOK_MODE,\n 'harness-not-claude',\n );\n }\n // `--no-hooks` is a decision about THIS RUN and writes no config, so the stored\n // mode is reported unchanged and a later bare re-run wires them. That is the\n // difference from `--search-hooks off`, which is a durable statement.\n if (noHooks) {\n return hooksSkipped('claude', home, dataDir, stored ?? DEFAULT_HOOK_MODE, 'declined');\n }\n\n const mode = await chooseHookMode(flag, stored, deps, dryRun, canPrompt);\n // Cancelling the select is a decision NOT to decide, so it behaves exactly like\n // `--no-hooks`: nothing registered, nothing written. Every other decision in\n // this walkthrough already treats Escape that way, and this one used to be the\n // single prompt where backing out still wired and persisted a mode.\n if (mode === null) {\n return hooksSkipped('claude', home, dataDir, stored ?? DEFAULT_HOOK_MODE, 'declined');\n }\n if (dryRun) return hooksSkipped('claude', home, dataDir, mode, 'dry-run');\n if (mode !== (stored ?? DEFAULT_HOOK_MODE) || stored === undefined) {\n await persistSearchHookMode(dataDir, mode);\n }\n // `off` is a decision not to register anything, so settings.json is not touched\n // at all. It is NOT the same as an inert script: an operator who later sets the\n // mode back to `auto` re-runs install, which is what the fix string says.\n if (mode === 'off') return hooksSkipped('claude', home, dataDir, mode, 'mode-off');\n return wireSearchHooks({ homeDir: home, dataDir, mode });\n}\n\n/** The stored default for a run that was never asked. */\nconst DEFAULT_HOOK_MODE: SearchHookMode = CONFIG_DEFAULTS.hooks.searchMode;\n\n/**\n * Precedence for the hook mode: `--search-hooks` > the interactive select > an\n * already-configured mode > the default.\n *\n * NULL means the operator cancelled (Escape, ctrl-C, or an answer the schema does\n * not recognize). That is not a mode and must not be resolved into one: the\n * caller treats it as `--no-hooks` for this run, registering nothing and writing\n * no config, which is what every other cancel in this walkthrough does.\n */\nasync function chooseHookMode(\n flag: SearchHookMode | undefined,\n stored: SearchHookMode | undefined,\n deps: InstallDeps,\n dryRun: boolean,\n canPrompt: boolean,\n): Promise<SearchHookMode | null> {\n if (flag !== undefined) return flag;\n if (dryRun || !canPrompt) return stored ?? DEFAULT_HOOK_MODE;\n const answer = await (deps.promptSearchHooks ?? defaultPromptSearchHooks)();\n if (answer === null) return null;\n // The seam is injectable, so an answer is validated rather than trusted; an\n // unrecognized one is a cancel, not a write of something unknown.\n const parsed = SearchHookModeSchema.safeParse(answer);\n return parsed.success ? parsed.data : null;\n}\n\nfunction defaultPromptSearchHooks(): Promise<SearchHookMode | null> {\n return selectOne<SearchHookMode>({\n message: SEARCH_HOOKS_QUESTION,\n choices: SEARCH_HOOKS_CHOICES.map((c) => ({ ...c })),\n initialValue: 'auto',\n });\n}\n\n// --- Detection + planning --------------------------------------------------------\n\ninterface HarnessPlan {\n harness: Harness;\n detected: boolean;\n detectedBy: string[];\n skillsDir: string;\n wiresAgentsMd: boolean;\n home: string;\n}\n\n/**\n * Turn detection (or an explicit --harness override) into the ordered, de-duped\n * list of targets to write. Codex and the shared fallback both land in\n * ~/.agents/skills (the harness-shared Agent Skills location), so a request for\n * both collapses to one target keyed by that directory.\n */\nfunction resolvePlans(\n override: string[] | undefined,\n home: string,\n which: (bin: string) => boolean,\n): HarnessPlan[] {\n if (override !== undefined && override.length > 0) {\n const plans = override.map((v) => planFor(validateHarness(v), ['override'], true, home));\n return dedupeBySkillsDir(plans);\n }\n\n const plans: HarnessPlan[] = [];\n // Same two probes doctor's skills check gates its per-directory verdicts on.\n const claudeBy = harnessDetectedBy(home, 'claude', which);\n const codexBy = harnessDetectedBy(home, 'codex', which);\n if (claudeBy.length > 0) plans.push(planFor('claude', claudeBy, true, home));\n if (codexBy.length > 0) plans.push(planFor('codex', codexBy, true, home));\n if (plans.length === 0) {\n // Nothing detected: the shared Agent Skills location is the fallback target, so\n // a harness installed later still finds the skills.\n plans.push(planFor('shared', ['fallback'], false, home));\n }\n return dedupeBySkillsDir(plans);\n}\n\nfunction planFor(\n harness: Harness,\n detectedBy: string[],\n detected: boolean,\n home: string,\n): HarnessPlan {\n const skillsDir = harnessTargetDir(home, harness);\n return { harness, detected, detectedBy, skillsDir, wiresAgentsMd: harness !== 'claude', home };\n}\n\nfunction dedupeBySkillsDir(plans: HarnessPlan[]): HarnessPlan[] {\n const seen = new Set<string>();\n const out: HarnessPlan[] = [];\n for (const p of plans) {\n if (seen.has(p.skillsDir)) continue;\n seen.add(p.skillsDir);\n out.push(p);\n }\n return out;\n}\n\nfunction validateHarness(value: string): Harness {\n if ((HARNESSES as readonly string[]).includes(value)) return value as Harness;\n throw new CliError('USAGE', `Unknown harness \"${value}\"`, {\n fix: `--harness must be one of: ${HARNESSES.join(', ')}.`,\n });\n}\n\n// --- Applying a plan -------------------------------------------------------------\n\n/**\n * Wire one harness target. EVERY packaged skill is written on every run,\n * unconditionally: an existing Tenjin skill in the target (typically the hosted\n * zero-install one from tenjin.blog/skills.md) is never a reason to skip, because\n * install on such a machine is the UPGRADE path (#35). The hosted mirror is kept\n * and refreshed rather than removed (roadmap G4: it is the permanent zero-install\n * curriculum); the two CLI adapter skills land beside it and supersede it while\n * the CLI is present.\n */\nasync function applyPlan(\n plan: HarnessPlan,\n skillsSource: string,\n dryRun: boolean,\n): Promise<HarnessResult> {\n const skills: SkillResult[] = [];\n const warnings: string[] = [];\n for (const name of SKILL_NAMES) {\n const { status, warning, preexisting } = await installSkill(\n join(skillsSource, name),\n join(plan.skillsDir, name),\n dryRun,\n name,\n );\n skills.push({\n name,\n status,\n preexisting,\n cli: (CLI_SKILL_NAMES as readonly string[]).includes(name),\n modelInvocable: await landedInvocable(plan.skillsDir, skillsSource, name, dryRun),\n });\n if (warning !== undefined) warnings.push(warning);\n }\n\n const hostedPreexisting = skills.some((s) => s.name === HOSTED_SKILL_NAME && s.preexisting);\n // The notice is about arriving through the hosted skill, which is only news when\n // the CLI adapters were NOT already wired: after an earlier install the mirror on\n // disk is one we wrote, and announcing it is the CLI reporting its own footprint.\n const hostedArrivedFirst = hostedPreexisting && !skills.some((s) => s.cli && s.preexisting);\n const result: HarnessResult = {\n harness: plan.harness,\n detected: plan.detected,\n detectedBy: plan.detectedBy,\n skillsDir: plan.skillsDir,\n skills,\n hostedPreexisting,\n hostedArrivedFirst,\n notes: notesFor(plan, hostedArrivedFirst),\n warnings,\n };\n\n if (plan.wiresAgentsMd) result.codexNetworkRule = CODEX_NETWORK_RULE;\n return result;\n}\n\nfunction notesFor(plan: HarnessPlan, hostedArrivedFirst: boolean): string[] {\n const notes =\n plan.harness === 'claude'\n ? [\n 'Installed at the user level (~/.claude/skills). A Claude Code plugin will later make this automatic.',\n ]\n : [\n 'Copied into the shared Agent Skills location (~/.agents/skills). Codex and any Agent-Skills-compatible harness read it there.',\n ];\n if (hostedArrivedFirst) {\n // \"The skill stays\", never \"your copy is untouched\": the FILE is replaced by\n // this package's mirror, and a note reading as preservation beside a warning\n // saying replacement is worse than either alone.\n notes.push(\n `The hosted ${HOSTED_SKILL_NAME} skill was already here; the skill stays as the zero-install fallback (its file is replaced by this package's mirror) and the CLI skills (${CLI_SKILL_NAMES.join(', ')}) take precedence while the CLI is installed.`,\n );\n }\n return notes;\n}\n\n/**\n * Did the skill actually land model-invocable? Read back from the target so the\n * reported value is the file a harness will read, not what we intended to write.\n * A dry run wrote nothing, so it READS THE PACKAGED SOURCE — the file that would\n * land. Hardcoding `true` there was wrong for the one skill whose value can\n * legitimately be false: `assertSkillsSource` exempts the hosted mirror from the\n * invocability assertion, so a shadowed mirror ships and must report as shadowed on\n * both paths.\n */\nasync function landedInvocable(\n skillsDir: string,\n skillsSource: string,\n name: string,\n dryRun: boolean,\n): Promise<boolean> {\n // Guarded like every other read of this path. It is read back AFTER the write, so\n // an external writer can have swapped it for a pipe or a device in between, and a\n // raw read there would hang the command that just finished its work.\n const read = await readSkillFile(join(dryRun ? skillsSource : skillsDir, name, 'SKILL.md'));\n if (read.kind !== 'ok') return false;\n return !isModelInvocationDisabled(read.bytes.toString('utf8'));\n}\n\n/**\n * Every packaged skill landed in every target. Runs after ALL targets are written,\n * never mid-loop: a throw between two targets would leave target 1 rewritten and\n * target 2 untouched. (It still sits ahead of the doctor run, the publish-mode\n * question and the wallet step, so a throw here skips those either way.)\n *\n * Presence only. Whether a skill is model-invocable is a property of the PACKAGED\n * source, checked up front by `assertSkillsSource` before anything is written.\n */\nasync function assertSkillsLanded(plans: HarnessPlan[], dryRun: boolean): Promise<void> {\n if (dryRun) return;\n const missing: string[] = [];\n for (const plan of plans) {\n for (const name of SKILL_NAMES) {\n if (!existsSync(join(plan.skillsDir, name, 'SKILL.md'))) {\n missing.push(join(plan.skillsDir, name));\n }\n }\n }\n if (missing.length === 0) return;\n throw new CliError('INTERNAL', `Skills were not written: ${missing.join(', ')}`, {\n // Safe to point at permissions because nothing removes a landed file any more:\n // each shipped file arrives by its own atomic rename. When this was a\n // rm-then-write it also fired on a lost race, and sent people to chmod a\n // directory that was fine.\n fix: `Check that you can write to the skills directory (\\`ls -ld ${dirname(missing[0] ?? '')}\\`), then re-run \\`tenjin install\\`.`,\n });\n}\n\n// --- Human rendering -------------------------------------------------------------\n\nfunction paint(io: Io, format: Parameters<typeof styleText>[0], text: string): string {\n if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });\n return styleText(format, text);\n}\n\n// --- Skills source guard ---------------------------------------------------------\n\n/**\n * Guard the packaged source BEFORE any target is touched, so a bad package aborts\n * with nothing written rather than mid-copy.\n *\n * The model-invocable assertion covers only CLI_SKILL_NAMES. The hosted `tenjin`\n * mirror is written verbatim from tenjin.blog/skills.md by scripts/sync-skill.mjs\n * and its frontmatter is not authored here: if upstream ever adds\n * `disable-model-invocation: true` (a plausible way to say \"prefer the CLI\n * skills\"), asserting on it would hard-fail every install with a fix that cannot\n * work, and skill-drift.yml would stay green because the mirror still matches\n * upstream. Doctor warns about the mirror instead.\n */\nasync function assertSkillsSource(dir: string): Promise<void> {\n for (const name of SKILL_NAMES) {\n if (!existsSync(join(dir, name, 'SKILL.md'))) {\n throw new CliError('INTERNAL', `Packaged skill \"${name}\" is missing under ${dir}`, {\n fix: 'Reinstall tenjin-cli; the published package must ship every skill under skills/.',\n });\n }\n }\n for (const name of CLI_SKILL_NAMES) {\n const text = await readFile(join(dir, name, 'SKILL.md'), 'utf8');\n if (isModelInvocationDisabled(text)) {\n throw new CliError(\n 'INTERNAL',\n `Packaged skill \"${name}\" carries disable-model-invocation: true, so no harness would surface it`,\n {\n fix: 'Reinstall tenjin-cli; the published CLI skills must be model-invocable.',\n },\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY,YAAY;AAC1C,SAAS,eAAe;AAExB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AA0DvB,IAAM,YAAY;AAGlB,IAAM,qBAAqB,iBAAE,OAAO;AAAA,EAClC,SAAS,iBAAE,MAAM,iBAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACtC,QAAQ,iBAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,aAAa,iBAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,iBAAE,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/B,UAAU,iBAAE,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS/B,gBAAgB,iBAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAErC,aAAa,iBAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,SAAS,iBAAE,QAAQ,EAAE,SAAS;AAChC,CAAC;AAkDD,SAAS,UAAU,QAAkC;AACnD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAOA,IAAM,qBAAqB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AAM,UAAU,GAAG,MAAM;AAC/D,QAAI,0BAA0B,IAAI,GAAG;AACnC,YAAM,IAAI;AAAA,QACR;AAAA,QACA,mBAAmB,IAAI;AAAA,QACvB;AAAA,UACE,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["plans"]}
|
package/dist/outcome-ANV4QIED.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
runOutcome
|
|
4
|
-
} from "./chunk-PQZVDCCA.js";
|
|
5
|
-
import "./chunk-7NADDA2V.js";
|
|
6
|
-
import "./chunk-FDUD3W5V.js";
|
|
7
|
-
import "./chunk-54AJIO3E.js";
|
|
8
|
-
import "./chunk-XGZ5EVMB.js";
|
|
9
|
-
import "./chunk-B676GPS2.js";
|
|
10
|
-
import "./chunk-ZOBNS7CX.js";
|
|
11
|
-
import "./chunk-PKW3H26Z.js";
|
|
12
|
-
import "./chunk-736DW4V3.js";
|
|
13
|
-
import "./chunk-UO22YNY4.js";
|
|
14
|
-
import "./chunk-VEAERJVJ.js";
|
|
15
|
-
import "./chunk-LSWP7MU2.js";
|
|
16
|
-
import "./chunk-ETKZWJ4B.js";
|
|
17
|
-
import "./chunk-ZQIQ55KK.js";
|
|
18
|
-
import "./chunk-QWBUKIP2.js";
|
|
19
|
-
import "./chunk-PAOVPSP6.js";
|
|
20
|
-
import "./chunk-ZXTAQYNA.js";
|
|
21
|
-
export {
|
|
22
|
-
runOutcome
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=outcome-ANV4QIED.js.map
|
package/dist/publish-PCBTCXCZ.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
runPublish
|
|
4
|
-
} from "./chunk-O75FOHXS.js";
|
|
5
|
-
import "./chunk-VRPLZERE.js";
|
|
6
|
-
import "./chunk-WU5CZPLD.js";
|
|
7
|
-
import "./chunk-SGK2B724.js";
|
|
8
|
-
import "./chunk-OWVVI4VQ.js";
|
|
9
|
-
import "./chunk-KZAAWQNP.js";
|
|
10
|
-
import "./chunk-S5RYMCV6.js";
|
|
11
|
-
import "./chunk-POJRB2AE.js";
|
|
12
|
-
import "./chunk-YLYINX2H.js";
|
|
13
|
-
import "./chunk-7NADDA2V.js";
|
|
14
|
-
import "./chunk-FDUD3W5V.js";
|
|
15
|
-
import "./chunk-7GJQ5RGA.js";
|
|
16
|
-
import "./chunk-J6FUAIRR.js";
|
|
17
|
-
import "./chunk-54AJIO3E.js";
|
|
18
|
-
import "./chunk-XGZ5EVMB.js";
|
|
19
|
-
import "./chunk-3P3ES4XU.js";
|
|
20
|
-
import "./chunk-B676GPS2.js";
|
|
21
|
-
import "./chunk-ZOBNS7CX.js";
|
|
22
|
-
import "./chunk-PKW3H26Z.js";
|
|
23
|
-
import "./chunk-736DW4V3.js";
|
|
24
|
-
import "./chunk-UO22YNY4.js";
|
|
25
|
-
import "./chunk-VEAERJVJ.js";
|
|
26
|
-
import "./chunk-LSWP7MU2.js";
|
|
27
|
-
import "./chunk-ETKZWJ4B.js";
|
|
28
|
-
import "./chunk-ZQIQ55KK.js";
|
|
29
|
-
import "./chunk-QWBUKIP2.js";
|
|
30
|
-
import "./chunk-PAOVPSP6.js";
|
|
31
|
-
import "./chunk-M2O56UK7.js";
|
|
32
|
-
import "./chunk-UHTVXQ2O.js";
|
|
33
|
-
import "./chunk-W6R3HAAG.js";
|
|
34
|
-
import "./chunk-47PP7TAG.js";
|
|
35
|
-
import "./chunk-XJN5WUKL.js";
|
|
36
|
-
import "./chunk-RBJPAZFI.js";
|
|
37
|
-
import "./chunk-KYQVEKP5.js";
|
|
38
|
-
import "./chunk-ZXTAQYNA.js";
|
|
39
|
-
export {
|
|
40
|
-
runPublish
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=publish-PCBTCXCZ.js.map
|
package/dist/search-JGAVKTYJ.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
runSearch
|
|
4
|
-
} from "./chunk-XVPQGCH4.js";
|
|
5
|
-
import "./chunk-4Y53PDH6.js";
|
|
6
|
-
import "./chunk-7NADDA2V.js";
|
|
7
|
-
import "./chunk-FDUD3W5V.js";
|
|
8
|
-
import "./chunk-54AJIO3E.js";
|
|
9
|
-
import "./chunk-XGZ5EVMB.js";
|
|
10
|
-
import "./chunk-B676GPS2.js";
|
|
11
|
-
import "./chunk-ZOBNS7CX.js";
|
|
12
|
-
import "./chunk-PKW3H26Z.js";
|
|
13
|
-
import "./chunk-736DW4V3.js";
|
|
14
|
-
import "./chunk-UO22YNY4.js";
|
|
15
|
-
import "./chunk-VEAERJVJ.js";
|
|
16
|
-
import "./chunk-LSWP7MU2.js";
|
|
17
|
-
import "./chunk-ETKZWJ4B.js";
|
|
18
|
-
import "./chunk-ZQIQ55KK.js";
|
|
19
|
-
import "./chunk-QWBUKIP2.js";
|
|
20
|
-
import "./chunk-PAOVPSP6.js";
|
|
21
|
-
import "./chunk-ZXTAQYNA.js";
|
|
22
|
-
export {
|
|
23
|
-
runSearch
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=search-JGAVKTYJ.js.map
|