tenjin-cli 0.1.0-alpha.12 → 0.1.0-alpha.14
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 +36 -2
- package/dist/{buy-3DTBFZ4B.js → buy-2JBYPHAI.js} +23 -21
- package/dist/{chunk-Y7ERTA7D.js → chunk-3P3ES4XU.js} +4 -6
- package/dist/chunk-3P3ES4XU.js.map +1 -0
- package/dist/{chunk-WWIKAJFO.js → chunk-3ZW7HPY5.js} +12 -10
- package/dist/{chunk-WWIKAJFO.js.map → chunk-3ZW7HPY5.js.map} +1 -1
- package/dist/chunk-4UHNXY6B.js +786 -0
- package/dist/chunk-4UHNXY6B.js.map +1 -0
- package/dist/{chunk-6UY2UQMY.js → chunk-4Y53PDH6.js} +4 -4
- package/dist/{chunk-TUXKOIOU.js → chunk-54AJIO3E.js} +12 -13
- package/dist/chunk-54AJIO3E.js.map +1 -0
- package/dist/chunk-736DW4V3.js +65 -0
- package/dist/chunk-736DW4V3.js.map +1 -0
- package/dist/{chunk-CNUXRXI2.js → chunk-7GJQ5RGA.js} +9 -9
- package/dist/{chunk-4NTZETIL.js → chunk-7NADDA2V.js} +10 -7
- package/dist/{chunk-4NTZETIL.js.map → chunk-7NADDA2V.js.map} +1 -1
- package/dist/{chunk-UFPJBS4C.js → chunk-ACBEHJAH.js} +10 -8
- package/dist/{chunk-UFPJBS4C.js.map → chunk-ACBEHJAH.js.map} +1 -1
- package/dist/{chunk-IB63U6BM.js → chunk-B676GPS2.js} +34 -11
- package/dist/chunk-B676GPS2.js.map +1 -0
- package/dist/{chunk-MBKFZBB2.js → chunk-DAZAXFSF.js} +24 -24
- package/dist/{chunk-E6YOODH7.js → chunk-DTCXO7HS.js} +284 -406
- package/dist/chunk-DTCXO7HS.js.map +1 -0
- package/dist/{chunk-HWHYPCCH.js → chunk-ETKZWJ4B.js} +2 -2
- package/dist/{chunk-HWHYPCCH.js.map → chunk-ETKZWJ4B.js.map} +1 -1
- package/dist/{chunk-X2WZPGCF.js → chunk-FDUD3W5V.js} +5 -5
- package/dist/{chunk-6RMEX74N.js → chunk-GEHL43VE.js} +63 -26
- package/dist/chunk-GEHL43VE.js.map +1 -0
- package/dist/chunk-IU2HVT3Y.js +313 -0
- package/dist/chunk-IU2HVT3Y.js.map +1 -0
- package/dist/{chunk-4TCU3YRD.js → chunk-IUQZ4Z7M.js} +40 -8
- package/dist/chunk-IUQZ4Z7M.js.map +1 -0
- package/dist/{chunk-CBNXUQGM.js → chunk-IXZJ3JOO.js} +10 -8
- package/dist/{chunk-CBNXUQGM.js.map → chunk-IXZJ3JOO.js.map} +1 -1
- package/dist/{chunk-NUF2PKJO.js → chunk-J6FUAIRR.js} +4 -6
- package/dist/{chunk-NUF2PKJO.js.map → chunk-J6FUAIRR.js.map} +1 -1
- package/dist/{chunk-OZHJ3FLR.js → chunk-L6G35FU5.js} +5 -5
- package/dist/{chunk-ALUNME53.js → chunk-LSWP7MU2.js} +52 -68
- package/dist/chunk-LSWP7MU2.js.map +1 -0
- package/dist/chunk-MJSXP4LW.js +191 -0
- package/dist/chunk-MJSXP4LW.js.map +1 -0
- package/dist/{chunk-RSBN67PA.js → chunk-NAAMHWSI.js} +7 -6
- package/dist/chunk-NAAMHWSI.js.map +1 -0
- package/dist/{chunk-7MJVNALU.js → chunk-O75FOHXS.js} +35 -15
- package/dist/chunk-O75FOHXS.js.map +1 -0
- package/dist/{chunk-6BGYHARE.js → chunk-OWVVI4VQ.js} +15 -15
- package/dist/{chunk-PZRAAAY2.js → chunk-PAOVPSP6.js} +10 -3
- package/dist/chunk-PAOVPSP6.js.map +1 -0
- package/dist/{chunk-ROAK2DOX.js → chunk-PCX2JQ2J.js} +8 -8
- package/dist/{chunk-JTYIX6OD.js → chunk-PKW3H26Z.js} +7 -5
- package/dist/{chunk-JTYIX6OD.js.map → chunk-PKW3H26Z.js.map} +1 -1
- package/dist/{chunk-V5UHKC46.js → chunk-PQZVDCCA.js} +7 -7
- package/dist/{chunk-P74I3WH4.js → chunk-QWBUKIP2.js} +9 -5
- package/dist/chunk-QWBUKIP2.js.map +1 -0
- package/dist/{chunk-FKSAUOJU.js → chunk-UO22YNY4.js} +1 -69
- package/dist/chunk-UO22YNY4.js.map +1 -0
- package/dist/chunk-VEAERJVJ.js +43 -0
- package/dist/chunk-VEAERJVJ.js.map +1 -0
- package/dist/{chunk-ILDVGY7K.js → chunk-VRPLZERE.js} +25 -12
- package/dist/chunk-VRPLZERE.js.map +1 -0
- package/dist/{chunk-L3I2MVKR.js → chunk-W4VW5XYB.js} +6 -6
- package/dist/{chunk-TDDN5GXR.js → chunk-WU5CZPLD.js} +5 -5
- package/dist/chunk-WYLMJQVH.js +240 -0
- package/dist/chunk-WYLMJQVH.js.map +1 -0
- package/dist/{chunk-PZSUWDF2.js → chunk-XGZ5EVMB.js} +2 -2
- package/dist/{chunk-CLOEU7RA.js → chunk-XVPQGCH4.js} +14 -13
- package/dist/chunk-XVPQGCH4.js.map +1 -0
- package/dist/chunk-ZOBNS7CX.js +73 -0
- package/dist/chunk-ZOBNS7CX.js.map +1 -0
- package/dist/{cli-3WZGLZDP.js → cli-U2BEUA55.js} +53 -150
- package/dist/cli-U2BEUA55.js.map +1 -0
- package/dist/{config-WDGMZKHU.js → config-CNUIX23Q.js} +14 -8
- package/dist/doctor-QJJXRWTO.js +31 -0
- package/dist/edit-HJ44P44P.js +40 -0
- package/dist/{fund-JAPOFTUG.js → fund-Y5IAHZ5D.js} +19 -17
- package/dist/index.js +1 -1
- package/dist/inspect-NFQ6SQQQ.js +37 -0
- package/dist/{install-WXTOHDWC.js → install-DXX7PVUP.js} +128 -408
- package/dist/install-DXX7PVUP.js.map +1 -0
- package/dist/outcome-ANV4QIED.js +24 -0
- package/dist/publish-PCBTCXCZ.js +42 -0
- package/dist/{read-UAZGZ4UL.js → read-W7QVRBVD.js} +24 -22
- package/dist/{read-UAZGZ4UL.js.map → read-W7QVRBVD.js.map} +1 -1
- package/dist/{run-AJNCOT5R.js → run-CJWPGMIQ.js} +35 -33
- package/dist/{run-AJNCOT5R.js.map → run-CJWPGMIQ.js.map} +1 -1
- package/dist/search-JGAVKTYJ.js +25 -0
- package/dist/{send-F34ZDXDZ.js → send-C5EOKXOU.js} +13 -11
- package/dist/{send-F34ZDXDZ.js.map → send-C5EOKXOU.js.map} +1 -1
- package/dist/{session-4N4ZT3AH.js → session-OBCUUIFX.js} +16 -15
- package/dist/{session-4N4ZT3AH.js.map → session-OBCUUIFX.js.map} +1 -1
- package/dist/{skill-heal-XBEK272G.js → skill-heal-D6EPLPS6.js} +5 -6
- package/dist/skill-heal-D6EPLPS6.js.map +1 -0
- package/dist/{uninstall-BTKPHPDL.js → uninstall-OWJNJ5LI.js} +13 -8
- package/dist/uninstall-OWJNJ5LI.js.map +1 -0
- package/dist/update-24Y2CQTT.js +318 -0
- package/dist/update-24Y2CQTT.js.map +1 -0
- package/dist/{wallet-WJ6UP5OU.js → wallet-OFXDIIGP.js} +11 -10
- package/dist/{wallet-UL4P2JRO.js → wallet-SLRIYJ2U.js} +7 -7
- package/docs/agent-permissions.md +111 -16
- package/docs/command-reference.md +68 -11
- package/package.json +1 -1
- package/skills/tenjin-publish/SKILL.md +181 -192
- package/skills/tenjin-publish/references/maintain.md +39 -0
- package/skills/tenjin-search/SKILL.md +86 -279
- package/skills/tenjin-search/references/permissions.md +106 -0
- package/dist/chunk-2I4QTOLB.js +0 -11
- package/dist/chunk-2I4QTOLB.js.map +0 -1
- package/dist/chunk-4TCU3YRD.js.map +0 -1
- package/dist/chunk-6RMEX74N.js.map +0 -1
- package/dist/chunk-7MJVNALU.js.map +0 -1
- package/dist/chunk-ALUNME53.js.map +0 -1
- package/dist/chunk-CLOEU7RA.js.map +0 -1
- package/dist/chunk-E6YOODH7.js.map +0 -1
- package/dist/chunk-FKSAUOJU.js.map +0 -1
- package/dist/chunk-IB63U6BM.js.map +0 -1
- package/dist/chunk-ILDVGY7K.js.map +0 -1
- package/dist/chunk-P74I3WH4.js.map +0 -1
- package/dist/chunk-PZRAAAY2.js.map +0 -1
- package/dist/chunk-RSBN67PA.js.map +0 -1
- package/dist/chunk-SFGXAZ3M.js +0 -316
- package/dist/chunk-SFGXAZ3M.js.map +0 -1
- package/dist/chunk-TUXKOIOU.js.map +0 -1
- package/dist/chunk-Y7ERTA7D.js.map +0 -1
- package/dist/cli-3WZGLZDP.js.map +0 -1
- package/dist/doctor-EKVCP7JP.js +0 -27
- package/dist/edit-4UZQVFCK.js +0 -38
- package/dist/inspect-IEV75A42.js +0 -35
- package/dist/install-WXTOHDWC.js.map +0 -1
- package/dist/outcome-FYOFDOUK.js +0 -22
- package/dist/publish-6QNARH7E.js +0 -40
- package/dist/search-EEKTW6VK.js +0 -23
- package/dist/skill-heal-XBEK272G.js.map +0 -1
- package/dist/uninstall-BTKPHPDL.js.map +0 -1
- /package/dist/{buy-3DTBFZ4B.js.map → buy-2JBYPHAI.js.map} +0 -0
- /package/dist/{chunk-6UY2UQMY.js.map → chunk-4Y53PDH6.js.map} +0 -0
- /package/dist/{chunk-CNUXRXI2.js.map → chunk-7GJQ5RGA.js.map} +0 -0
- /package/dist/{chunk-MBKFZBB2.js.map → chunk-DAZAXFSF.js.map} +0 -0
- /package/dist/{chunk-X2WZPGCF.js.map → chunk-FDUD3W5V.js.map} +0 -0
- /package/dist/{chunk-OZHJ3FLR.js.map → chunk-L6G35FU5.js.map} +0 -0
- /package/dist/{chunk-6BGYHARE.js.map → chunk-OWVVI4VQ.js.map} +0 -0
- /package/dist/{chunk-ROAK2DOX.js.map → chunk-PCX2JQ2J.js.map} +0 -0
- /package/dist/{chunk-V5UHKC46.js.map → chunk-PQZVDCCA.js.map} +0 -0
- /package/dist/{chunk-L3I2MVKR.js.map → chunk-W4VW5XYB.js.map} +0 -0
- /package/dist/{chunk-TDDN5GXR.js.map → chunk-WU5CZPLD.js.map} +0 -0
- /package/dist/{chunk-PZSUWDF2.js.map → chunk-XGZ5EVMB.js.map} +0 -0
- /package/dist/{config-WDGMZKHU.js.map → config-CNUIX23Q.js.map} +0 -0
- /package/dist/{doctor-EKVCP7JP.js.map → doctor-QJJXRWTO.js.map} +0 -0
- /package/dist/{edit-4UZQVFCK.js.map → edit-HJ44P44P.js.map} +0 -0
- /package/dist/{fund-JAPOFTUG.js.map → fund-Y5IAHZ5D.js.map} +0 -0
- /package/dist/{inspect-IEV75A42.js.map → inspect-NFQ6SQQQ.js.map} +0 -0
- /package/dist/{outcome-FYOFDOUK.js.map → outcome-ANV4QIED.js.map} +0 -0
- /package/dist/{publish-6QNARH7E.js.map → publish-PCBTCXCZ.js.map} +0 -0
- /package/dist/{search-EEKTW6VK.js.map → search-JGAVKTYJ.js.map} +0 -0
- /package/dist/{wallet-UL4P2JRO.js.map → wallet-OFXDIIGP.js.map} +0 -0
- /package/dist/{wallet-WJ6UP5OU.js.map → wallet-SLRIYJ2U.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
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,QAAQ,KAAK;AAC5E;AAGA,SAAS,cAAc,OAAyB;AAC9C,MAAI,CAAC,cAAc,KAAK,EAAG,QAAO;AAClC,QAAM,WAAW,MAAM;AACvB,MAAI,CAAC,MAAM,QAAQ,QAAQ,EAAG,QAAO;AACrC,SAAO,SAAS;AAAA,IACd,CAAC,MACC,cAAc,CAAC,KACf,OAAO,EAAE,YAAY,aACpB,EAAE,QAAQ,SAAS,mBAAmB,KAAK,EAAE,QAAQ,SAAS,cAAc;AAAA,EACjF;AACF;AAYA,eAAsB,mBAAmB,SAA2C;AAClF,QAAM,eAAe,mBAAmB,OAAO;AAC/C,QAAM,OAAO,CAACA,OAAc,SAA6B,aAAuC;AAAA,IAC9F,MAAAA;AAAA,IACA,OAAO,CAAC;AAAA,IACR,OAAO,CAAC;AAAA,IACR;AAAA,IACA,GAAI,YAAY,SAAY,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC7C;AAEA,QAAM,QAAQ,MAAM,MAAM,YAAY,EAAE,MAAM,MAAM,IAAI;AACxD,MAAI,UAAU,KAAM,QAAO,KAAK,cAAc,QAAQ;AAEtD,MAAI;AAC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C,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,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
CliError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PAOVPSP6.js";
|
|
5
5
|
|
|
6
6
|
// src/lib/url.ts
|
|
7
7
|
function trimSlash(url) {
|
|
@@ -32,4 +32,4 @@ export {
|
|
|
32
32
|
tryOriginOf,
|
|
33
33
|
originOf
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-XGZ5EVMB.js.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
assertOnBaseOrigin
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4Y53PDH6.js";
|
|
5
5
|
import {
|
|
6
6
|
recordSearch
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7NADDA2V.js";
|
|
8
8
|
import {
|
|
9
9
|
MAX_LIMIT,
|
|
10
10
|
buildSearchRequest,
|
|
11
11
|
postSearch
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FDUD3W5V.js";
|
|
13
13
|
import {
|
|
14
14
|
sanitizeForTerminal
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-B676GPS2.js";
|
|
16
16
|
import {
|
|
17
17
|
resolveContextSettings
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-PKW3H26Z.js";
|
|
19
19
|
import {
|
|
20
20
|
formatUsdDisplay,
|
|
21
21
|
isPaidPrice,
|
|
22
22
|
parseUsdToAtomic
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-736DW4V3.js";
|
|
24
24
|
import {
|
|
25
25
|
CliError
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-PAOVPSP6.js";
|
|
27
27
|
|
|
28
28
|
// src/commands/search.ts
|
|
29
29
|
async function runSearch(args, ctx, deps = {}) {
|
|
@@ -92,10 +92,6 @@ async function runSearch(args, ctx, deps = {}) {
|
|
|
92
92
|
// parser drops any that appears.
|
|
93
93
|
paidBrowseCount: (response.browse ?? []).filter((b) => isPaidPrice(b.price) === true).length
|
|
94
94
|
});
|
|
95
|
-
if (response.decision === "MISS") {
|
|
96
|
-
ctx.io.stderr.write(`${publishBackLine(response.searchId)}
|
|
97
|
-
`);
|
|
98
|
-
}
|
|
99
95
|
const browse = response.browse ?? [];
|
|
100
96
|
const browseHint = browse.length > 0 ? [
|
|
101
97
|
`no match, ${browse.length} piece(s) you could browse: ${browse.map((b) => `${sanitizeForTerminal(b.title)} (${formatUsdDisplay(b.price)} USD)`).join("; ")}`
|
|
@@ -103,7 +99,12 @@ async function runSearch(args, ctx, deps = {}) {
|
|
|
103
99
|
const truncatedHint = response.truncated === true ? [
|
|
104
100
|
request.limit < MAX_LIMIT ? `some candidates were dropped for size; retry with --limit ${MAX_LIMIT} (the size ceiling grows with the number of candidates returned)` : `some candidates were dropped for size; at --limit ${MAX_LIMIT} the dropped tail cannot be recovered, so narrow the question`
|
|
105
101
|
] : [];
|
|
106
|
-
const humanLines = response.decision === "MISS" ? [
|
|
102
|
+
const humanLines = response.decision === "MISS" ? [
|
|
103
|
+
`MISS, no candidates (searchId ${response.searchId})`,
|
|
104
|
+
...browseHint,
|
|
105
|
+
...truncatedHint,
|
|
106
|
+
publishBackLine(response.searchId)
|
|
107
|
+
] : [
|
|
107
108
|
`${candidates.length} candidate(s) (searchId ${response.searchId}):`,
|
|
108
109
|
// Dollars for the same reason the browse hint uses them: this is the
|
|
109
110
|
// human's cue to size the spend against gates they entered in decimal
|
|
@@ -172,4 +173,4 @@ function parseAppliesTo(pairs) {
|
|
|
172
173
|
export {
|
|
173
174
|
runSearch
|
|
174
175
|
};
|
|
175
|
-
//# sourceMappingURL=chunk-
|
|
176
|
+
//# sourceMappingURL=chunk-XVPQGCH4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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AC/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":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/lib/lock.ts
|
|
4
|
+
import { mkdirSync, rmSync } from "fs";
|
|
5
|
+
import { writeFile } from "fs/promises";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
var owned = /* @__PURE__ */ new Set();
|
|
8
|
+
function ownsAnyLock() {
|
|
9
|
+
return owned.size > 0;
|
|
10
|
+
}
|
|
11
|
+
function releaseOwnedLocks() {
|
|
12
|
+
for (const path of owned) {
|
|
13
|
+
try {
|
|
14
|
+
rmSync(path, { recursive: true, force: true });
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
owned.clear();
|
|
19
|
+
}
|
|
20
|
+
var DEFAULTS = { timeoutMs: 5e3, retryMs: 25 };
|
|
21
|
+
var LockTimeoutError = class extends Error {
|
|
22
|
+
lockPath;
|
|
23
|
+
constructor(lockPath, timeoutMs) {
|
|
24
|
+
super(
|
|
25
|
+
`Timed out waiting for lock at ${lockPath} after ${timeoutMs}ms; if no other tenjin process is running, remove that directory and retry.`
|
|
26
|
+
);
|
|
27
|
+
this.name = "LockTimeoutError";
|
|
28
|
+
this.lockPath = lockPath;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
async function withFileLock(lockPath, fn, opts = {}) {
|
|
32
|
+
const { timeoutMs, retryMs } = { ...DEFAULTS, ...opts };
|
|
33
|
+
const metaPath = join(lockPath, "meta");
|
|
34
|
+
const deadline = Date.now() + timeoutMs;
|
|
35
|
+
for (; ; ) {
|
|
36
|
+
try {
|
|
37
|
+
mkdirSync(lockPath);
|
|
38
|
+
owned.add(lockPath);
|
|
39
|
+
break;
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (!isEexist(err)) throw err;
|
|
42
|
+
if (Date.now() >= deadline) throw new LockTimeoutError(lockPath, timeoutMs);
|
|
43
|
+
await delay(retryMs);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
await writeFile(metaPath, JSON.stringify({ pid: process.pid, acquiredAt: Date.now() })).catch(
|
|
47
|
+
() => void 0
|
|
48
|
+
);
|
|
49
|
+
try {
|
|
50
|
+
return await fn();
|
|
51
|
+
} finally {
|
|
52
|
+
try {
|
|
53
|
+
rmSync(lockPath, { recursive: true, force: true });
|
|
54
|
+
owned.delete(lockPath);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
opts.onReleaseError?.(lockPath, err);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function isEexist(err) {
|
|
61
|
+
return typeof err === "object" && err !== null && err.code === "EEXIST";
|
|
62
|
+
}
|
|
63
|
+
function delay(ms) {
|
|
64
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
ownsAnyLock,
|
|
69
|
+
releaseOwnedLocks,
|
|
70
|
+
LockTimeoutError,
|
|
71
|
+
withFileLock
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-ZOBNS7CX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/lock.ts"],"sourcesContent":["import { mkdirSync, rmSync } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Locks this process currently holds. Ownership starts the instant `mkdir`\n * succeeds and ends when the release has removed the directory, so there is no\n * window where a lock is on disk and unaccounted for. A removal that FAILS keeps\n * the lock owned: the directory is still on disk, no successor can claim the path\n * while it exists, and a signal-time release gets another attempt. The one place\n * ownership is dropped without a successful removal is `releaseOwnedLocks`, which\n * runs only as the process exits, where a claim held by a dying process helps\n * nobody.\n *\n * It exists because the default signal action terminates WITHOUT running\n * `finally`: without this, one Ctrl-C leaves a lock nothing will ever clean and\n * every later run of the same command times out on it.\n */\nconst owned = new Set<string>();\n\n/** Does this process hold any lock right now? */\nexport function ownsAnyLock(): boolean {\n return owned.size > 0;\n}\n\n/**\n * Synchronously attempt to release every lock this process holds. BEST EFFORT: a\n * path that refuses to be removed is left on disk and the next run's timeout names\n * it. Safe to call from a signal handler, and a no-op when this process holds\n * none, so a run merely QUEUED behind another cannot remove that other run's lock.\n */\nexport function releaseOwnedLocks(): void {\n for (const path of owned) {\n // NEVER throws. This runs inside a signal handler, and a throw there is an\n // uncaught exception: the process dies with code 1 and a stack trace instead\n // of the diagnostic and exit 130 the handler promises. One lock we could not\n // remove must not cost the report, or the exit code, or the other locks.\n try {\n rmSync(path, { recursive: true, force: true });\n } catch {\n // Left behind; the next run's timeout names the path.\n }\n }\n owned.clear();\n}\n\nexport interface FileLockOptions {\n /** Give up acquiring after this long (ms). */\n timeoutMs?: number;\n /** Poll interval between acquisition attempts (ms). */\n retryMs?: number;\n /**\n * Called when the lock could not be removed on release. The protected work\n * succeeded, so this is not a failure of the command; it is a leftover that will\n * block later runs, and the caller is the only one able to say so.\n */\n onReleaseError?: (lockPath: string, err: unknown) => void;\n}\n\nconst DEFAULTS = { timeoutMs: 5000, retryMs: 25 };\n\n/** Thrown when the lock cannot be acquired within `timeoutMs`. Carries the lock\n * path so a caller can surface the manual-recovery step in its own error contract. */\nexport class LockTimeoutError extends Error {\n readonly lockPath: string;\n constructor(lockPath: string, timeoutMs: number) {\n super(\n `Timed out waiting for lock at ${lockPath} after ${timeoutMs}ms; if no other tenjin process is running, remove that directory and retry.`,\n );\n this.name = 'LockTimeoutError';\n this.lockPath = lockPath;\n }\n}\n\n/**\n * Minimal cross-process mutex: the lock IS a directory, and mkdir is atomic, so a\n * second holder gets EEXIST and retries with backoff until `timeoutMs`, then\n * throws LockTimeoutError. There is deliberately NO auto-steal of a \"stale\" lock:\n * concurrent waiters each judging a lock stale could remove a fresh holder's\n * directory and lose its update. A crashed holder's lock is recovered by hand (the\n * timeout error names the path); the pid+acquiredAt meta exists only to make that\n * manual call diagnosable. Always released in the finally.\n *\n * ⚠ MIRRORED, MUST UPDATE TOGETHER. The generated WebSearch hook script in\n * lib/hook-scripts.ts (`withStoreLock`) reimplements this protocol byte for byte,\n * because it runs as a standalone .mjs outside the CLI and cannot import this\n * module, yet writes the same searches.json. If you change what the lock IS\n * (directory vs file), where it lives, or the no-stale-steal rule, change it\n * there too. Two writers of one file that disagree about the mutex have no mutex.\n * lib/hook-scripts.test.ts pins the two together and fails loudly on drift.\n */\nexport async function withFileLock<T>(\n lockPath: string,\n fn: () => Promise<T>,\n opts: FileLockOptions = {},\n): Promise<T> {\n const { timeoutMs, retryMs } = { ...DEFAULTS, ...opts };\n const metaPath = join(lockPath, 'meta');\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n try {\n // SYNCHRONOUS, for the same reason the release is: `await mkdir` finishes the\n // syscall before the continuation records ownership, so between the two the\n // directory is on disk and unclaimed. A signal there exits without removing\n // it and, with no stale recovery, nothing ever will. mkdirSync and the add\n // are one uninterruptible step.\n mkdirSync(lockPath);\n owned.add(lockPath); // owned from here, released only in the finally below\n break; // acquired\n } catch (err) {\n if (!isEexist(err)) throw err;\n if (Date.now() >= deadline) throw new LockTimeoutError(lockPath, timeoutMs);\n await delay(retryMs);\n }\n }\n await writeFile(metaPath, JSON.stringify({ pid: process.pid, acquiredAt: Date.now() })).catch(\n () => undefined,\n );\n try {\n return await fn();\n } finally {\n // SYNCHRONOUS, and in this order, because both are load-bearing. A signal\n // handler cannot run between two synchronous statements, so there is no instant\n // where the lock is on disk but unclaimed (a signal would exit without removing\n // it, and with no stale recovery nothing ever would) nor one where it is\n // claimed after release (a signal would remove whatever SUCCESSOR had since\n // acquired the path). An `await` here reopens the first window: `rm` yields, the\n // handler runs, sees no ownership, and leaves the directory behind.\n //\n // With no stealing, nothing else ever removes or replaces this directory, so\n // the lock here is provably the one we created — the unconditional rm is sound.\n try {\n rmSync(lockPath, { recursive: true, force: true });\n owned.delete(lockPath);\n } catch (err) {\n // KEEP ownership when the removal fails: the successor-steal risk only\n // exists once the directory is gone and someone else can take the path, so a\n // removal that failed leaves it on disk and still ours, and a signal-time\n // release gets another attempt. That only helps while THIS process lives,\n // though; once it exits normally the leftover blocks every later run, so the\n // caller is told rather than left to discover it as a timeout.\n opts.onReleaseError?.(lockPath, err);\n }\n }\n}\n\nfunction isEexist(err: unknown): boolean {\n return typeof err === 'object' && err !== null && (err as { code?: unknown }).code === 'EEXIST';\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;;AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AAgBrB,IAAM,QAAQ,oBAAI,IAAY;AAGvB,SAAS,cAAuB;AACrC,SAAO,MAAM,OAAO;AACtB;AAQO,SAAS,oBAA0B;AACxC,aAAW,QAAQ,OAAO;AAKxB,QAAI;AACF,aAAO,MAAM,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IAC/C,QAAQ;AAAA,IAER;AAAA,EACF;AACA,QAAM,MAAM;AACd;AAeA,IAAM,WAAW,EAAE,WAAW,KAAM,SAAS,GAAG;AAIzC,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACT,YAAY,UAAkB,WAAmB;AAC/C;AAAA,MACE,iCAAiC,QAAQ,UAAU,SAAS;AAAA,IAC9D;AACA,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;AAmBA,eAAsB,aACpB,UACA,IACA,OAAwB,CAAC,GACb;AACZ,QAAM,EAAE,WAAW,QAAQ,IAAI,EAAE,GAAG,UAAU,GAAG,KAAK;AACtD,QAAM,WAAW,KAAK,UAAU,MAAM;AACtC,QAAM,WAAW,KAAK,IAAI,IAAI;AAC9B,aAAS;AACP,QAAI;AAMF,gBAAU,QAAQ;AAClB,YAAM,IAAI,QAAQ;AAClB;AAAA,IACF,SAAS,KAAK;AACZ,UAAI,CAAC,SAAS,GAAG,EAAG,OAAM;AAC1B,UAAI,KAAK,IAAI,KAAK,SAAU,OAAM,IAAI,iBAAiB,UAAU,SAAS;AAC1E,YAAM,MAAM,OAAO;AAAA,IACrB;AAAA,EACF;AACA,QAAM,UAAU,UAAU,KAAK,UAAU,EAAE,KAAK,QAAQ,KAAK,YAAY,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE;AAAA,IACtF,MAAM;AAAA,EACR;AACA,MAAI;AACF,WAAO,MAAM,GAAG;AAAA,EAClB,UAAE;AAWA,QAAI;AACF,aAAO,UAAU,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AACjD,YAAM,OAAO,QAAQ;AAAA,IACvB,SAAS,KAAK;AAOZ,WAAK,iBAAiB,UAAU,GAAG;AAAA,IACrC;AAAA,EACF;AACF;AAEA,SAAS,SAAS,KAAuB;AACvC,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAS,IAA2B,SAAS;AACzF;AAEA,SAAS,MAAM,IAA2B;AACxC,SAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AACzD;","names":[]}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
package_default
|
|
7
|
-
} from "./chunk-HWHYPCCH.js";
|
|
3
|
+
maybeUpdate,
|
|
4
|
+
readUpdateSignal
|
|
5
|
+
} from "./chunk-MJSXP4LW.js";
|
|
8
6
|
import {
|
|
9
7
|
defaultIo,
|
|
10
8
|
emitFailure,
|
|
11
|
-
emitNotice,
|
|
12
9
|
emitSuccess
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-B676GPS2.js";
|
|
11
|
+
import {
|
|
12
|
+
PERMISSIONS_DOC_URL
|
|
13
|
+
} from "./chunk-IUQZ4Z7M.js";
|
|
14
|
+
import "./chunk-LSWP7MU2.js";
|
|
15
|
+
import {
|
|
16
|
+
package_default
|
|
17
|
+
} from "./chunk-ETKZWJ4B.js";
|
|
14
18
|
import {
|
|
15
|
-
dataDir
|
|
16
|
-
updateCheckPath
|
|
19
|
+
dataDir
|
|
17
20
|
} from "./chunk-ZQIQ55KK.js";
|
|
21
|
+
import "./chunk-QWBUKIP2.js";
|
|
18
22
|
import {
|
|
19
23
|
CliError,
|
|
20
|
-
external_exports
|
|
21
|
-
|
|
22
|
-
} from "./chunk-PZRAAAY2.js";
|
|
24
|
+
external_exports
|
|
25
|
+
} from "./chunk-PAOVPSP6.js";
|
|
23
26
|
import {
|
|
24
27
|
__commonJS,
|
|
25
28
|
__require,
|
|
@@ -3476,118 +3479,6 @@ var {
|
|
|
3476
3479
|
Help
|
|
3477
3480
|
} = import_index.default;
|
|
3478
3481
|
|
|
3479
|
-
// src/lib/update-check.ts
|
|
3480
|
-
import { readFile } from "fs/promises";
|
|
3481
|
-
var CHECK_INTERVAL_MS = 864e5;
|
|
3482
|
-
var FETCH_TIMEOUT_MS = 1500;
|
|
3483
|
-
var DIST_TAGS_URL = "https://registry.npmjs.org/-/package/tenjin-cli/dist-tags";
|
|
3484
|
-
var TagEntrySchema = external_exports.object({
|
|
3485
|
-
checkedAtMs: external_exports.number(),
|
|
3486
|
-
latest: external_exports.string(),
|
|
3487
|
-
/** When the nudge was last PRINTED for this tag. Absent until one has been. */
|
|
3488
|
-
notifiedAtMs: external_exports.number().optional()
|
|
3489
|
-
});
|
|
3490
|
-
var CacheSchema = external_exports.object({
|
|
3491
|
-
schemaVersion: external_exports.literal(1),
|
|
3492
|
-
tags: external_exports.record(external_exports.string(), TagEntrySchema)
|
|
3493
|
-
});
|
|
3494
|
-
var DistTagsSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
3495
|
-
async function maybeNudgeUpdate(deps) {
|
|
3496
|
-
try {
|
|
3497
|
-
const env = deps.env ?? process.env;
|
|
3498
|
-
if (!deps.io.isTTY || deps.json) return;
|
|
3499
|
-
if (env.CI !== void 0 && env.CI.length > 0) return;
|
|
3500
|
-
const nowMs = (deps.now ?? Date.now)();
|
|
3501
|
-
const current = deps.currentVersion ?? package_default.version;
|
|
3502
|
-
const path = updateCheckPath(deps.dir);
|
|
3503
|
-
const tag = parseVersion(current)?.alpha !== null ? "alpha" : "latest";
|
|
3504
|
-
const cached = await readCache(path);
|
|
3505
|
-
const entry = cached?.tags[tag];
|
|
3506
|
-
const fresh = entry !== void 0 && nowMs - entry.checkedAtMs < CHECK_INTERVAL_MS;
|
|
3507
|
-
const latest = fresh ? entry.latest : await fetchLatest(deps, tag);
|
|
3508
|
-
if (latest === null) return;
|
|
3509
|
-
const notifiedAtMs = entry?.notifiedAtMs;
|
|
3510
|
-
const due = isNewer(latest, current) && (notifiedAtMs === void 0 || nowMs - notifiedAtMs >= CHECK_INTERVAL_MS);
|
|
3511
|
-
const nudgedAtMs = due ? nowMs : notifiedAtMs;
|
|
3512
|
-
if (!fresh || due) {
|
|
3513
|
-
await writeCache(path, {
|
|
3514
|
-
schemaVersion: 1,
|
|
3515
|
-
// Read-modify-write: the tag this run did not ask about keeps whatever it
|
|
3516
|
-
// knew, including its own nudge clock.
|
|
3517
|
-
tags: {
|
|
3518
|
-
...cached?.tags,
|
|
3519
|
-
[tag]: {
|
|
3520
|
-
checkedAtMs: fresh ? entry.checkedAtMs : nowMs,
|
|
3521
|
-
latest,
|
|
3522
|
-
...nudgedAtMs !== void 0 ? { notifiedAtMs: nudgedAtMs } : {}
|
|
3523
|
-
}
|
|
3524
|
-
}
|
|
3525
|
-
});
|
|
3526
|
-
}
|
|
3527
|
-
if (!due) return;
|
|
3528
|
-
const target = parseVersion(latest)?.alpha === null ? "tenjin-cli" : "tenjin-cli@alpha";
|
|
3529
|
-
emitNotice(
|
|
3530
|
-
deps.io,
|
|
3531
|
-
`tenjin-cli ${latest} is available (you have ${current}). Update: npm i -g ${target}`,
|
|
3532
|
-
{ json: deps.json }
|
|
3533
|
-
);
|
|
3534
|
-
} catch {
|
|
3535
|
-
}
|
|
3536
|
-
}
|
|
3537
|
-
async function fetchLatest(deps, tag) {
|
|
3538
|
-
const doFetch = deps.fetchImpl ?? fetch;
|
|
3539
|
-
let json;
|
|
3540
|
-
try {
|
|
3541
|
-
const res = await doFetch(DIST_TAGS_URL, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
3542
|
-
if (!res.ok) return null;
|
|
3543
|
-
json = await res.json();
|
|
3544
|
-
} catch {
|
|
3545
|
-
return null;
|
|
3546
|
-
}
|
|
3547
|
-
const parsed = DistTagsSchema.safeParse(json);
|
|
3548
|
-
if (!parsed.success) return null;
|
|
3549
|
-
return parsed.data[tag] ?? null;
|
|
3550
|
-
}
|
|
3551
|
-
async function writeCache(path, cache) {
|
|
3552
|
-
await writeFileAtomic(path, `${JSON.stringify(cache, null, 2)}
|
|
3553
|
-
`, {
|
|
3554
|
-
mode: 384,
|
|
3555
|
-
dirMode: 448
|
|
3556
|
-
});
|
|
3557
|
-
}
|
|
3558
|
-
async function readCache(path) {
|
|
3559
|
-
try {
|
|
3560
|
-
const parsed = CacheSchema.safeParse(JSON.parse(await readFile(path, "utf8")));
|
|
3561
|
-
return parsed.success ? parsed.data : null;
|
|
3562
|
-
} catch {
|
|
3563
|
-
return null;
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
var VERSION_RE = /^(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?$/;
|
|
3567
|
-
function parseVersion(raw) {
|
|
3568
|
-
const m = VERSION_RE.exec(raw);
|
|
3569
|
-
if (m === null) return null;
|
|
3570
|
-
const [, major, minor, patch, alpha] = m;
|
|
3571
|
-
if (major === void 0 || minor === void 0 || patch === void 0) return null;
|
|
3572
|
-
return {
|
|
3573
|
-
major: Number(major),
|
|
3574
|
-
minor: Number(minor),
|
|
3575
|
-
patch: Number(patch),
|
|
3576
|
-
alpha: alpha !== void 0 ? Number(alpha) : null
|
|
3577
|
-
};
|
|
3578
|
-
}
|
|
3579
|
-
function isNewer(candidate, current) {
|
|
3580
|
-
const a = parseVersion(candidate);
|
|
3581
|
-
const b = parseVersion(current);
|
|
3582
|
-
if (a === null || b === null) return false;
|
|
3583
|
-
if (a.major !== b.major) return a.major > b.major;
|
|
3584
|
-
if (a.minor !== b.minor) return a.minor > b.minor;
|
|
3585
|
-
if (a.patch !== b.patch) return a.patch > b.patch;
|
|
3586
|
-
if (a.alpha === null) return b.alpha !== null;
|
|
3587
|
-
if (b.alpha === null) return false;
|
|
3588
|
-
return a.alpha > b.alpha;
|
|
3589
|
-
}
|
|
3590
|
-
|
|
3591
3482
|
// src/cli.ts
|
|
3592
3483
|
var GlobalOptsSchema = external_exports.object({
|
|
3593
3484
|
json: external_exports.boolean().default(false),
|
|
@@ -3616,17 +3507,23 @@ function buildProgram(io, setExit) {
|
|
|
3616
3507
|
const program2 = new Command();
|
|
3617
3508
|
const runCommand = async (command, cmd, run) => {
|
|
3618
3509
|
const json = cmd.optsWithGlobals().json === true;
|
|
3510
|
+
const updateAvailable = command === "update" ? null : await readUpdateSignal(dataDir(process.env));
|
|
3619
3511
|
try {
|
|
3620
3512
|
const ctx = buildContext(cmd, io);
|
|
3621
3513
|
const result = await run(ctx);
|
|
3622
|
-
emitSuccess(ctx.io, command, result.data, result.humanLines, {
|
|
3514
|
+
emitSuccess(ctx.io, command, result.data, result.humanLines, {
|
|
3515
|
+
json: ctx.flags.json,
|
|
3516
|
+
updateAvailable
|
|
3517
|
+
});
|
|
3623
3518
|
} catch (err) {
|
|
3624
|
-
setExit(emitFailure(io, command, err, { json }).exitCode);
|
|
3519
|
+
setExit(emitFailure(io, command, err, { json, updateAvailable }).exitCode);
|
|
3520
|
+
}
|
|
3521
|
+
if (command !== "update") {
|
|
3522
|
+
await maybeUpdate({ dir: dataDir(process.env), io, json });
|
|
3625
3523
|
}
|
|
3626
|
-
await maybeNudgeUpdate({ dir: dataDir(process.env), io, json });
|
|
3627
3524
|
if (command !== "install") {
|
|
3628
3525
|
try {
|
|
3629
|
-
const { healWiredSkills } = await import("./skill-heal-
|
|
3526
|
+
const { healWiredSkills } = await import("./skill-heal-D6EPLPS6.js");
|
|
3630
3527
|
await healWiredSkills({ io });
|
|
3631
3528
|
} catch {
|
|
3632
3529
|
}
|
|
@@ -3673,7 +3570,7 @@ function buildProgram(io, setExit) {
|
|
|
3673
3570
|
const o = this.opts();
|
|
3674
3571
|
const claudeMdGiven = this.getOptionValueSource("claudeMd") !== "default";
|
|
3675
3572
|
const allowGiven = this.getOptionValueSource("allowFreeVerbs") !== "default";
|
|
3676
|
-
const { runInstall } = await import("./install-
|
|
3573
|
+
const { runInstall } = await import("./install-DXX7PVUP.js");
|
|
3677
3574
|
return runInstall(
|
|
3678
3575
|
{
|
|
3679
3576
|
...Array.isArray(o.harness) && o.harness.length > 0 ? { harness: o.harness } : {},
|
|
@@ -3690,37 +3587,43 @@ function buildProgram(io, setExit) {
|
|
|
3690
3587
|
});
|
|
3691
3588
|
});
|
|
3692
3589
|
addGlobalFlags(program2.command("uninstall")).description(
|
|
3693
|
-
"Remove everything `tenjin install` wrote: the skills, the harness hooks and their settings entries, and the tenjin permission rules.
|
|
3590
|
+
"Remove everything `tenjin install` wrote: the skills, the harness hooks and their settings entries, the generated hook scripts in ~/.tenjin/hooks, and the tenjin permission rules. Your wallet, config, library and search history are kept"
|
|
3694
3591
|
).action(async function() {
|
|
3695
3592
|
await runCommand("uninstall", this, async (ctx) => {
|
|
3696
|
-
const { runUninstall } = await import("./uninstall-
|
|
3593
|
+
const { runUninstall } = await import("./uninstall-OWJNJ5LI.js");
|
|
3697
3594
|
return runUninstall(ctx);
|
|
3698
3595
|
});
|
|
3699
3596
|
});
|
|
3700
3597
|
addGlobalFlags(program2.command("doctor")).description("Check the local environment and Tenjin API reachability").action(async function() {
|
|
3701
3598
|
await runCommand("doctor", this, async (ctx) => {
|
|
3702
|
-
const { runDoctor } = await import("./doctor-
|
|
3599
|
+
const { runDoctor } = await import("./doctor-QJJXRWTO.js");
|
|
3703
3600
|
return runDoctor(ctx);
|
|
3704
3601
|
});
|
|
3705
3602
|
});
|
|
3603
|
+
addGlobalFlags(program2.command("update")).description("Update tenjin-cli to the newest version npm publishes on the latest tag").option("--check", "report whether a newer version exists without installing it").action(async function() {
|
|
3604
|
+
await runCommand("update", this, async (ctx) => {
|
|
3605
|
+
const { runUpdate } = await import("./update-24Y2CQTT.js");
|
|
3606
|
+
return runUpdate({ check: this.opts().check === true }, ctx);
|
|
3607
|
+
});
|
|
3608
|
+
});
|
|
3706
3609
|
const config = addGlobalFlags(program2.command("config")).description(
|
|
3707
3610
|
"Show or change CLI configuration"
|
|
3708
3611
|
);
|
|
3709
3612
|
config.action(async function() {
|
|
3710
3613
|
await runCommand("config", this, async (ctx) => {
|
|
3711
|
-
const { runConfigList } = await import("./config-
|
|
3614
|
+
const { runConfigList } = await import("./config-CNUIX23Q.js");
|
|
3712
3615
|
return runConfigList(ctx);
|
|
3713
3616
|
});
|
|
3714
3617
|
});
|
|
3715
3618
|
addGlobalFlags(config.command("get <key>")).description("Print one effective config value").action(async function(key) {
|
|
3716
3619
|
await runCommand("config.get", this, async (ctx) => {
|
|
3717
|
-
const { runConfigGet } = await import("./config-
|
|
3620
|
+
const { runConfigGet } = await import("./config-CNUIX23Q.js");
|
|
3718
3621
|
return runConfigGet({ key }, ctx);
|
|
3719
3622
|
});
|
|
3720
3623
|
});
|
|
3721
3624
|
addGlobalFlags(config.command("set <key> <value>")).description("Set a config value (decimal USD accepted for spend keys)").action(async function(key, value) {
|
|
3722
3625
|
await runCommand("config.set", this, async (ctx) => {
|
|
3723
|
-
const { runConfigSet } = await import("./config-
|
|
3626
|
+
const { runConfigSet } = await import("./config-CNUIX23Q.js");
|
|
3724
3627
|
return runConfigSet({ key, value }, ctx);
|
|
3725
3628
|
});
|
|
3726
3629
|
});
|
|
@@ -3733,19 +3636,19 @@ function buildProgram(io, setExit) {
|
|
|
3733
3636
|
).action(async function() {
|
|
3734
3637
|
await runCommand("wallet.create", this, async (ctx) => {
|
|
3735
3638
|
const o = this.opts();
|
|
3736
|
-
const { runWalletCreate } = await import("./wallet-
|
|
3639
|
+
const { runWalletCreate } = await import("./wallet-OFXDIIGP.js");
|
|
3737
3640
|
return runWalletCreate(ctx, o.replace === true ? { replace: true } : {});
|
|
3738
3641
|
});
|
|
3739
3642
|
});
|
|
3740
3643
|
addGlobalFlags(wallet.command("show")).description("Show the wallet address and key source (never the key)").action(async function() {
|
|
3741
3644
|
await runCommand("wallet.show", this, async (ctx) => {
|
|
3742
|
-
const { runWalletShow } = await import("./wallet-
|
|
3645
|
+
const { runWalletShow } = await import("./wallet-OFXDIIGP.js");
|
|
3743
3646
|
return runWalletShow(ctx);
|
|
3744
3647
|
});
|
|
3745
3648
|
});
|
|
3746
3649
|
addGlobalFlags(wallet.command("balance")).description("Show the wallet USDC balance on Base").action(async function() {
|
|
3747
3650
|
await runCommand("wallet.balance", this, async (ctx) => {
|
|
3748
|
-
const { runWalletBalance } = await import("./wallet-
|
|
3651
|
+
const { runWalletBalance } = await import("./wallet-OFXDIIGP.js");
|
|
3749
3652
|
return runWalletBalance(ctx);
|
|
3750
3653
|
});
|
|
3751
3654
|
});
|
|
@@ -3757,7 +3660,7 @@ function buildProgram(io, setExit) {
|
|
|
3757
3660
|
).action(async function(amountUsd) {
|
|
3758
3661
|
await runCommand("fund", this, async (ctx) => {
|
|
3759
3662
|
const o = this.opts();
|
|
3760
|
-
const { runFund } = await import("./fund-
|
|
3663
|
+
const { runFund } = await import("./fund-Y5IAHZ5D.js");
|
|
3761
3664
|
return runFund(ctx, {
|
|
3762
3665
|
...amountUsd !== void 0 ? { amountUsd } : {},
|
|
3763
3666
|
...o.open === false ? { open: false } : {},
|
|
@@ -3770,7 +3673,7 @@ function buildProgram(io, setExit) {
|
|
|
3770
3673
|
).option("--yes", "skip the interactive confirm (required to send when not at a TTY)").action(async function(amount, token, to) {
|
|
3771
3674
|
await runCommand("send", this, async (ctx) => {
|
|
3772
3675
|
const o = this.opts();
|
|
3773
|
-
const { runSend } = await import("./send-
|
|
3676
|
+
const { runSend } = await import("./send-C5EOKXOU.js");
|
|
3774
3677
|
return runSend({ amount, token, to, ...o.yes === true ? { yes: true } : {} }, ctx);
|
|
3775
3678
|
});
|
|
3776
3679
|
});
|
|
@@ -3779,7 +3682,7 @@ function buildProgram(io, setExit) {
|
|
|
3779
3682
|
).option("--max-price <usd>", "only candidates at or below this decimal-USD price").option("--fresh-within <window>", "freshness window, e.g. P30D, P2W, P1Y").option("--limit <n>", "maximum candidates (1-10, default 5)").option("--applies-to <pair>", "applicability filter key=value (repeatable)", collect, []).action(async function(question) {
|
|
3780
3683
|
await runCommand("search", this, async (ctx) => {
|
|
3781
3684
|
const o = this.opts();
|
|
3782
|
-
const { runSearch } = await import("./search-
|
|
3685
|
+
const { runSearch } = await import("./search-JGAVKTYJ.js");
|
|
3783
3686
|
return runSearch(
|
|
3784
3687
|
{
|
|
3785
3688
|
question,
|
|
@@ -3796,7 +3699,7 @@ function buildProgram(io, setExit) {
|
|
|
3796
3699
|
"Show a candidate's pre-purchase card / preview. Use after search, before buy, to check price, scope, and freshness; it never pays"
|
|
3797
3700
|
).action(async function(resource) {
|
|
3798
3701
|
await runCommand("inspect", this, async (ctx) => {
|
|
3799
|
-
const { runInspect } = await import("./inspect-
|
|
3702
|
+
const { runInspect } = await import("./inspect-NFQ6SQQQ.js");
|
|
3800
3703
|
return runInspect({ ref: resource }, ctx);
|
|
3801
3704
|
});
|
|
3802
3705
|
});
|
|
@@ -3808,7 +3711,7 @@ function buildProgram(io, setExit) {
|
|
|
3808
3711
|
).action(async function(resource) {
|
|
3809
3712
|
await runCommand("read", this, async (ctx) => {
|
|
3810
3713
|
const o = this.opts();
|
|
3811
|
-
const { runRead } = await import("./read-
|
|
3714
|
+
const { runRead } = await import("./read-W7QVRBVD.js");
|
|
3812
3715
|
return runRead(
|
|
3813
3716
|
{
|
|
3814
3717
|
ref: resource,
|
|
@@ -3829,7 +3732,7 @@ function buildProgram(io, setExit) {
|
|
|
3829
3732
|
).option("--scope <scope>", "session scope; this version mints `read` only (default: read)").action(async function() {
|
|
3830
3733
|
await runCommand("session.start", this, async (ctx) => {
|
|
3831
3734
|
const o = this.opts();
|
|
3832
|
-
const { runSessionStart } = await import("./session-
|
|
3735
|
+
const { runSessionStart } = await import("./session-OBCUUIFX.js");
|
|
3833
3736
|
return runSessionStart(typeof o.scope === "string" ? { scope: o.scope } : {}, ctx);
|
|
3834
3737
|
});
|
|
3835
3738
|
});
|
|
@@ -3841,7 +3744,7 @@ function buildProgram(io, setExit) {
|
|
|
3841
3744
|
).action(async function(resource) {
|
|
3842
3745
|
await runCommand("buy", this, async (ctx) => {
|
|
3843
3746
|
const o = this.opts();
|
|
3844
|
-
const { runBuy } = await import("./buy-
|
|
3747
|
+
const { runBuy } = await import("./buy-2JBYPHAI.js");
|
|
3845
3748
|
return runBuy(
|
|
3846
3749
|
{
|
|
3847
3750
|
ref: resource,
|
|
@@ -3865,7 +3768,7 @@ function buildProgram(io, setExit) {
|
|
|
3865
3768
|
).option("--question <text>", "a question this piece answers (repeatable)", collect, []).option("--task <text>", "a task this piece supports (repeatable)", collect, []).option("--scope <text>", "what the piece covers (card scope)").option("--exclusions <text>", "what the piece does not cover (card exclusions)").option("--applies-to <pair>", "applicability key=value (repeatable)", collect, []).option("--as-of <iso>", "as-of timestamp, ISO-8601 with offset").option("--valid-until <iso>", "valid-until timestamp, ISO-8601 with offset").option("--artifact-type <type>", "document | skill | dataset").option("--temporal-mode <mode>", "snapshot | maintained | evergreen").option("--provenance <text>", "provenance summary (card)").option("--methodology <text>", "methodology summary (card)").action(async function(file) {
|
|
3866
3769
|
await runCommand("publish", this, async (ctx) => {
|
|
3867
3770
|
const o = this.opts();
|
|
3868
|
-
const { runPublish } = await import("./publish-
|
|
3771
|
+
const { runPublish } = await import("./publish-PCBTCXCZ.js");
|
|
3869
3772
|
return runPublish(
|
|
3870
3773
|
{
|
|
3871
3774
|
...typeof file === "string" ? { file } : {},
|
|
@@ -3921,7 +3824,7 @@ function buildProgram(io, setExit) {
|
|
|
3921
3824
|
).action(async function(postId) {
|
|
3922
3825
|
await runCommand("edit", this, async (ctx) => {
|
|
3923
3826
|
const o = this.opts();
|
|
3924
|
-
const { runEdit } = await import("./edit-
|
|
3827
|
+
const { runEdit } = await import("./edit-HJ44P44P.js");
|
|
3925
3828
|
return runEdit(
|
|
3926
3829
|
{
|
|
3927
3830
|
postId,
|
|
@@ -3961,7 +3864,7 @@ function buildProgram(io, setExit) {
|
|
|
3961
3864
|
).option("--resource <id>", "the resourceId the outcome concerns").option("--content-hash <hash>", "sha256:<64hex> of the exact body read").action(async function() {
|
|
3962
3865
|
await runCommand("outcome", this, async (ctx) => {
|
|
3963
3866
|
const o = this.opts();
|
|
3964
|
-
const { runOutcome } = await import("./outcome-
|
|
3867
|
+
const { runOutcome } = await import("./outcome-ANV4QIED.js");
|
|
3965
3868
|
return runOutcome(
|
|
3966
3869
|
{
|
|
3967
3870
|
status: String(o.status),
|
|
@@ -3976,7 +3879,7 @@ function buildProgram(io, setExit) {
|
|
|
3976
3879
|
});
|
|
3977
3880
|
addGlobalFlags(program2.command("mcp")).description("Run a local stdio MCP server exposing the Tenjin command cores to an MCP client").action(async function() {
|
|
3978
3881
|
const ctx = buildContext(this, io);
|
|
3979
|
-
const { runMcpServer } = await import("./run-
|
|
3882
|
+
const { runMcpServer } = await import("./run-CJWPGMIQ.js");
|
|
3980
3883
|
await runMcpServer({ dataDir: ctx.dataDir, flags: ctx.flags });
|
|
3981
3884
|
});
|
|
3982
3885
|
return program2;
|
|
@@ -4018,4 +3921,4 @@ export {
|
|
|
4018
3921
|
buildProgram,
|
|
4019
3922
|
main
|
|
4020
3923
|
};
|
|
4021
|
-
//# sourceMappingURL=cli-
|
|
3924
|
+
//# sourceMappingURL=cli-U2BEUA55.js.map
|