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.
Files changed (176) hide show
  1. package/README.md +18 -3
  2. package/dist/{buy-2JBYPHAI.js → buy-VIRNSYGN.js} +24 -23
  3. package/dist/{chunk-QWBUKIP2.js → chunk-2MYQN7HM.js} +66 -27
  4. package/dist/chunk-2MYQN7HM.js.map +1 -0
  5. package/dist/{chunk-DAZAXFSF.js → chunk-2RF2GIJQ.js} +57 -226
  6. package/dist/chunk-2RF2GIJQ.js.map +1 -0
  7. package/dist/{chunk-VEAERJVJ.js → chunk-3GL2Z5QK.js} +23 -9
  8. package/dist/chunk-3GL2Z5QK.js.map +1 -0
  9. package/dist/{chunk-IUQZ4Z7M.js → chunk-4CQIDQOT.js} +6 -1
  10. package/dist/chunk-4CQIDQOT.js.map +1 -0
  11. package/dist/{chunk-IXZJ3JOO.js → chunk-4KG27W2S.js} +10 -10
  12. package/dist/chunk-4KG27W2S.js.map +1 -0
  13. package/dist/{chunk-54AJIO3E.js → chunk-5QQTYWEU.js} +4 -3
  14. package/dist/chunk-5QQTYWEU.js.map +1 -0
  15. package/dist/chunk-65DTCCJ7.js +21 -0
  16. package/dist/chunk-65DTCCJ7.js.map +1 -0
  17. package/dist/{chunk-7NADDA2V.js → chunk-A5DKHMUN.js} +20 -8
  18. package/dist/chunk-A5DKHMUN.js.map +1 -0
  19. package/dist/{chunk-WYLMJQVH.js → chunk-B63XPWQ4.js} +24 -18
  20. package/dist/chunk-B63XPWQ4.js.map +1 -0
  21. package/dist/{chunk-L6G35FU5.js → chunk-CAR6FHK6.js} +5 -5
  22. package/dist/{chunk-7GJQ5RGA.js → chunk-CPCX67TI.js} +20 -22
  23. package/dist/{chunk-7GJQ5RGA.js.map → chunk-CPCX67TI.js.map} +1 -1
  24. package/dist/{chunk-XVPQGCH4.js → chunk-CQBVCYI2.js} +36 -50
  25. package/dist/chunk-CQBVCYI2.js.map +1 -0
  26. package/dist/chunk-DBU5CXBV.js +4731 -0
  27. package/dist/chunk-DBU5CXBV.js.map +1 -0
  28. package/dist/chunk-DHJD77OW.js +81 -0
  29. package/dist/chunk-DHJD77OW.js.map +1 -0
  30. package/dist/{chunk-XGZ5EVMB.js → chunk-EDZSNPE5.js} +2 -2
  31. package/dist/{chunk-736DW4V3.js → chunk-EFWZPUTC.js} +2 -2
  32. package/dist/chunk-EPFL6CTE.js +448 -0
  33. package/dist/chunk-EPFL6CTE.js.map +1 -0
  34. package/dist/{chunk-3P3ES4XU.js → chunk-GHLVXVZD.js} +3 -5
  35. package/dist/{chunk-3P3ES4XU.js.map → chunk-GHLVXVZD.js.map} +1 -1
  36. package/dist/{chunk-4UHNXY6B.js → chunk-H3SOOJ2I.js} +88 -294
  37. package/dist/chunk-H3SOOJ2I.js.map +1 -0
  38. package/dist/{chunk-MJSXP4LW.js → chunk-HPJGOLTN.js} +6 -8
  39. package/dist/{chunk-MJSXP4LW.js.map → chunk-HPJGOLTN.js.map} +1 -1
  40. package/dist/{chunk-J6FUAIRR.js → chunk-HRGBS2PA.js} +4 -6
  41. package/dist/{chunk-J6FUAIRR.js.map → chunk-HRGBS2PA.js.map} +1 -1
  42. package/dist/{chunk-FDUD3W5V.js → chunk-ITUXPJIS.js} +55 -58
  43. package/dist/chunk-ITUXPJIS.js.map +1 -0
  44. package/dist/{chunk-ETKZWJ4B.js → chunk-JBIKAAT3.js} +2 -2
  45. package/dist/{chunk-ETKZWJ4B.js.map → chunk-JBIKAAT3.js.map} +1 -1
  46. package/dist/{chunk-3ZW7HPY5.js → chunk-KAJZHIQ4.js} +13 -10
  47. package/dist/chunk-KAJZHIQ4.js.map +1 -0
  48. package/dist/{chunk-OWVVI4VQ.js → chunk-KINZ23CV.js} +107 -4535
  49. package/dist/chunk-KINZ23CV.js.map +1 -0
  50. package/dist/{chunk-PCX2JQ2J.js → chunk-LRYV3SK7.js} +9 -7
  51. package/dist/{chunk-PCX2JQ2J.js.map → chunk-LRYV3SK7.js.map} +1 -1
  52. package/dist/{chunk-ACBEHJAH.js → chunk-NIKXHWOL.js} +11 -13
  53. package/dist/{chunk-ACBEHJAH.js.map → chunk-NIKXHWOL.js.map} +1 -1
  54. package/dist/chunk-OKDRDT74.js +209 -0
  55. package/dist/chunk-OKDRDT74.js.map +1 -0
  56. package/dist/chunk-OKYSNAS3.js +2144 -0
  57. package/dist/chunk-OKYSNAS3.js.map +1 -0
  58. package/dist/{chunk-B676GPS2.js → chunk-OLWTRUTS.js} +7 -3
  59. package/dist/{chunk-B676GPS2.js.map → chunk-OLWTRUTS.js.map} +1 -1
  60. package/dist/{chunk-WU5CZPLD.js → chunk-QQ6ELLSA.js} +6 -8
  61. package/dist/{chunk-WU5CZPLD.js.map → chunk-QQ6ELLSA.js.map} +1 -1
  62. package/dist/{chunk-NAAMHWSI.js → chunk-QZ6ROAJU.js} +5 -4
  63. package/dist/chunk-QZ6ROAJU.js.map +1 -0
  64. package/dist/{chunk-GEHL43VE.js → chunk-R7RSCBI7.js} +130 -47
  65. package/dist/chunk-R7RSCBI7.js.map +1 -0
  66. package/dist/{chunk-LSWP7MU2.js → chunk-U6VPKMGC.js} +127 -27
  67. package/dist/chunk-U6VPKMGC.js.map +1 -0
  68. package/dist/{chunk-W4VW5XYB.js → chunk-US456VUI.js} +6 -6
  69. package/dist/{chunk-O75FOHXS.js → chunk-V44J2MXV.js} +64 -36
  70. package/dist/chunk-V44J2MXV.js.map +1 -0
  71. package/dist/{chunk-4Y53PDH6.js → chunk-VJQKL3YH.js} +10 -7
  72. package/dist/{chunk-4Y53PDH6.js.map → chunk-VJQKL3YH.js.map} +1 -1
  73. package/dist/{chunk-VRPLZERE.js → chunk-VJSQSLBM.js} +47 -26
  74. package/dist/chunk-VJSQSLBM.js.map +1 -0
  75. package/dist/{chunk-PKW3H26Z.js → chunk-VYOJOX4Z.js} +9 -7
  76. package/dist/chunk-VYOJOX4Z.js.map +1 -0
  77. package/dist/chunk-WY2K35OL.js +269 -0
  78. package/dist/chunk-WY2K35OL.js.map +1 -0
  79. package/dist/{chunk-PAOVPSP6.js → chunk-ZFJJ3EXC.js} +53 -5
  80. package/dist/chunk-ZFJJ3EXC.js.map +1 -0
  81. package/dist/{cli-U2BEUA55.js → cli-KKRKBU5T.js} +71 -40
  82. package/dist/{cli-U2BEUA55.js.map → cli-KKRKBU5T.js.map} +1 -1
  83. package/dist/config-JMRUNYE6.js +37 -0
  84. package/dist/discover-B5HF6SHM.js +102 -0
  85. package/dist/discover-B5HF6SHM.js.map +1 -0
  86. package/dist/doctor-ZBG7X66D.js +32 -0
  87. package/dist/edit-PZJIILQE.js +40 -0
  88. package/dist/{fund-Y5IAHZ5D.js → fund-EUDH5KPA.js} +19 -19
  89. package/dist/index.js +1 -1
  90. package/dist/{inspect-NFQ6SQQQ.js → inspect-QC6WEQPN.js} +20 -20
  91. package/dist/{install-DXX7PVUP.js → install-GNK2W3PI.js} +196 -78
  92. package/dist/install-GNK2W3PI.js.map +1 -0
  93. package/dist/outcome-KSGWZHUS.js +24 -0
  94. package/dist/pay-BC4UICPA.js +361 -0
  95. package/dist/pay-BC4UICPA.js.map +1 -0
  96. package/dist/publish-LXWFDIKF.js +42 -0
  97. package/dist/{read-W7QVRBVD.js → read-JMNUQ56P.js} +21 -21
  98. package/dist/{run-CJWPGMIQ.js → run-XYTQ5TWQ.js} +52 -45
  99. package/dist/{run-CJWPGMIQ.js.map → run-XYTQ5TWQ.js.map} +1 -1
  100. package/dist/search-TSQAB45E.js +25 -0
  101. package/dist/{send-C5EOKXOU.js → send-G746D7PQ.js} +14 -15
  102. package/dist/{send-C5EOKXOU.js.map → send-G746D7PQ.js.map} +1 -1
  103. package/dist/{session-OBCUUIFX.js → session-JBKWMJ24.js} +17 -17
  104. package/dist/{skill-heal-D6EPLPS6.js → skill-heal-WKD67SLJ.js} +17 -9
  105. package/dist/skill-heal-WKD67SLJ.js.map +1 -0
  106. package/dist/skill-placement-RIU4AMC2.js +20 -0
  107. package/dist/{uninstall-OWJNJ5LI.js → uninstall-5E263VTS.js} +12 -12
  108. package/dist/uninstall-5E263VTS.js.map +1 -0
  109. package/dist/{update-24Y2CQTT.js → update-R76LHOZW.js} +7 -8
  110. package/dist/{update-24Y2CQTT.js.map → update-R76LHOZW.js.map} +1 -1
  111. package/dist/{wallet-SLRIYJ2U.js → wallet-TQ7D5EQ7.js} +7 -8
  112. package/dist/{wallet-OFXDIIGP.js → wallet-ZAVXWLWP.js} +11 -12
  113. package/dist/wallet-ZAVXWLWP.js.map +1 -0
  114. package/docs/agent-permissions.md +17 -2
  115. package/docs/command-reference.md +84 -42
  116. package/docs/safety-model.md +9 -0
  117. package/package.json +1 -1
  118. package/skills/tenjin/SKILL.md +38 -29
  119. package/skills/tenjin-pay/SKILL.md +76 -0
  120. package/skills/tenjin-publish/SKILL.md +10 -7
  121. package/skills/tenjin-search/SKILL.md +18 -13
  122. package/skills/tenjin-search/references/permissions.md +9 -3
  123. package/dist/chunk-3ZW7HPY5.js.map +0 -1
  124. package/dist/chunk-4UHNXY6B.js.map +0 -1
  125. package/dist/chunk-54AJIO3E.js.map +0 -1
  126. package/dist/chunk-7NADDA2V.js.map +0 -1
  127. package/dist/chunk-DAZAXFSF.js.map +0 -1
  128. package/dist/chunk-DTCXO7HS.js +0 -791
  129. package/dist/chunk-DTCXO7HS.js.map +0 -1
  130. package/dist/chunk-FDUD3W5V.js.map +0 -1
  131. package/dist/chunk-GEHL43VE.js.map +0 -1
  132. package/dist/chunk-IU2HVT3Y.js +0 -313
  133. package/dist/chunk-IU2HVT3Y.js.map +0 -1
  134. package/dist/chunk-IUQZ4Z7M.js.map +0 -1
  135. package/dist/chunk-IXZJ3JOO.js.map +0 -1
  136. package/dist/chunk-LSWP7MU2.js.map +0 -1
  137. package/dist/chunk-NAAMHWSI.js.map +0 -1
  138. package/dist/chunk-O75FOHXS.js.map +0 -1
  139. package/dist/chunk-OWVVI4VQ.js.map +0 -1
  140. package/dist/chunk-PAOVPSP6.js.map +0 -1
  141. package/dist/chunk-PKW3H26Z.js.map +0 -1
  142. package/dist/chunk-PQZVDCCA.js +0 -125
  143. package/dist/chunk-PQZVDCCA.js.map +0 -1
  144. package/dist/chunk-QWBUKIP2.js.map +0 -1
  145. package/dist/chunk-VEAERJVJ.js.map +0 -1
  146. package/dist/chunk-VRPLZERE.js.map +0 -1
  147. package/dist/chunk-WYLMJQVH.js.map +0 -1
  148. package/dist/chunk-XVPQGCH4.js.map +0 -1
  149. package/dist/chunk-ZQIQ55KK.js +0 -51
  150. package/dist/chunk-ZQIQ55KK.js.map +0 -1
  151. package/dist/config-CNUIX23Q.js +0 -32
  152. package/dist/doctor-QJJXRWTO.js +0 -31
  153. package/dist/edit-HJ44P44P.js +0 -40
  154. package/dist/install-DXX7PVUP.js.map +0 -1
  155. package/dist/outcome-ANV4QIED.js +0 -24
  156. package/dist/publish-PCBTCXCZ.js +0 -42
  157. package/dist/search-JGAVKTYJ.js +0 -25
  158. package/dist/skill-heal-D6EPLPS6.js.map +0 -1
  159. package/dist/uninstall-OWJNJ5LI.js.map +0 -1
  160. /package/dist/{buy-2JBYPHAI.js.map → buy-VIRNSYGN.js.map} +0 -0
  161. /package/dist/{chunk-L6G35FU5.js.map → chunk-CAR6FHK6.js.map} +0 -0
  162. /package/dist/{chunk-XGZ5EVMB.js.map → chunk-EDZSNPE5.js.map} +0 -0
  163. /package/dist/{chunk-736DW4V3.js.map → chunk-EFWZPUTC.js.map} +0 -0
  164. /package/dist/{chunk-W4VW5XYB.js.map → chunk-US456VUI.js.map} +0 -0
  165. /package/dist/{config-CNUIX23Q.js.map → config-JMRUNYE6.js.map} +0 -0
  166. /package/dist/{doctor-QJJXRWTO.js.map → doctor-ZBG7X66D.js.map} +0 -0
  167. /package/dist/{edit-HJ44P44P.js.map → edit-PZJIILQE.js.map} +0 -0
  168. /package/dist/{fund-Y5IAHZ5D.js.map → fund-EUDH5KPA.js.map} +0 -0
  169. /package/dist/{inspect-NFQ6SQQQ.js.map → inspect-QC6WEQPN.js.map} +0 -0
  170. /package/dist/{outcome-ANV4QIED.js.map → outcome-KSGWZHUS.js.map} +0 -0
  171. /package/dist/{publish-PCBTCXCZ.js.map → publish-LXWFDIKF.js.map} +0 -0
  172. /package/dist/{read-W7QVRBVD.js.map → read-JMNUQ56P.js.map} +0 -0
  173. /package/dist/{search-JGAVKTYJ.js.map → search-TSQAB45E.js.map} +0 -0
  174. /package/dist/{session-OBCUUIFX.js.map → session-JBKWMJ24.js.map} +0 -0
  175. /package/dist/{wallet-OFXDIIGP.js.map → skill-placement-RIU4AMC2.js.map} +0 -0
  176. /package/dist/{wallet-SLRIYJ2U.js.map → wallet-TQ7D5EQ7.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/skill-heal.ts"],"sourcesContent":["import { existsSync, lstatSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { emitWriteNotice } from './output';\nimport type { Io } from './output';\nimport { installSkill } from './skill-writer';\nimport {\n CLI_SKILL_NAMES,\n readSkillFile,\n skillFrontmatterName,\n skillsDirsFor,\n} from './skill-wiring';\nimport { resolveSkillsSource } from './skills-source';\n\nexport interface HealDeps {\n io: Io;\n /** Environment for the CI and opt-out checks. Defaults to process.env. */\n env?: NodeJS.ProcessEnv;\n /** Home whose skills directories are healed. Tests inject a temp dir. */\n homeDir?: string;\n /**\n * The packaged skills source. Defaults to this build's own, and only that\n * default is checked for being a working tree: passing one is a deliberate act.\n */\n skillsSourceDir?: string;\n}\n\n/** The opt-out, in the shape the CLI's other `TENJIN_NO_*` switches take. */\nconst OPT_OUT = 'TENJIN_NO_SKILL_HEAL';\n\n/**\n * Refresh the CLI adapter skills ALREADY in a harness skills directory, so\n * updating the CLI updates the copies `install` wrote instead of leaving an agent\n * on an older version's instructions. Subordinate to the command that ran, like\n * the update nudge: after the envelope, never on stdout, never a failure.\n *\n * It is an UNATTENDED writer into the operator's home, so it is strictly more\n * conservative than `install`, which a human ran on purpose. What it declines to\n * touch is listed on {@link healable}, and it heals only the two CLI adapters:\n * the hosted `tenjin` skill mirrors tenjin.blog/skills.md, so the copy on disk\n * may be a NEWER fetch than this package ships, and rewriting it would undo that\n * and make install's \"re-fetch it from tenjin.blog/skills.md\" false. Same domain\n * `doctor`'s staleness check compares.\n *\n * Unlocked, on purpose. Concurrent healers write byte-identical content to the\n * same paths through per-file atomic renames, so there is nothing to serialize;\n * a lock here could only make things worse, because one left behind by a killed\n * process would silently disable healing on this machine forever.\n */\nexport async function healWiredSkills(deps: HealDeps): Promise<void> {\n try {\n const env = deps.env ?? process.env;\n // The same two doors the update nudge uses: a build log cannot act on this,\n // and an operator who wants their skills left alone says so once.\n if (env.CI !== undefined && env.CI.length > 0) return;\n if (env[OPT_OUT] === '1') return;\n\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, healing paths under the working directory.\n if (!isAbsolute(home)) return;\n\n const source = deps.skillsSourceDir ?? packagedSource();\n if (source === null) return;\n const targets = healable(home);\n if (targets.length === 0) return;\n await heal(targets, source, deps.io);\n } catch {\n // Whatever it was, it is the next command's to retry; this one is finished.\n }\n}\n\n/**\n * This build's packaged skills, or null when they are a working tree's. The\n * published package ships `dist/` and `skills/` with no `src/` beside them, so a\n * `src/` sibling means a checkout, whose skills may be half-edited and are not\n * what anyone agreed to install.\n */\nfunction packagedSource(): string | null {\n const dir = resolveSkillsSource(fileURLToPath(new URL('.', import.meta.url)));\n return existsSync(join(dirname(dir), 'src')) ? null : dir;\n}\n\ninterface Target {\n dir: string;\n name: string;\n /** The SKILL.md itself: what the gates judged, and what the notice names. */\n path: string;\n}\n\n/**\n * The (directory, skill) pairs this may rewrite, which is a deliberately narrow\n * set. A skill that is not there is never created, because presence is the\n * operator's consent to a directory.\n *\n * Nothing here is reached THROUGH a symlink. `install` follows one on purpose,\n * since the operator pointed it somewhere; unattended, following one means a\n * write landing wherever it points and a notice naming a path that is not where\n * it landed. That argument does not get weaker one directory up, so every\n * component this CLI creates is checked with `lstat`, not `stat`: the skills\n * directory, the skill directory, and SKILL.md. Above them is the harness's own\n * home, which every tool including the harness reaches through, so a link there\n * is the operator's name for the place rather than a redirect around us.\n *\n * Gating SKILL.md gates the whole write. It is not the only file a skill ships\n * any more (tenjin-search carries `references/`), but it is the only one whose\n * frontmatter can prove the directory is OURS, and `installSkill` writes the\n * whole packaged tree once that gate passes — so a reference file deleted or\n * edited under a healthy SKILL.md is restored on the same pass. The other gate,\n * that the file is ours at all, needs its content and so lives at the write.\n */\nfunction healable(home: string): Target[] {\n const found: Target[] = [];\n for (const dir of skillsDirsFor(home)) {\n if (!isRealDirectory(dir)) continue;\n for (const name of CLI_SKILL_NAMES) {\n if (!isRealDirectory(join(dir, name))) continue;\n const path = join(dir, name, 'SKILL.md');\n if (lstatSync(path, { throwIfNoEntry: false })?.isFile() !== true) continue;\n found.push({ dir, name, path });\n }\n }\n return found;\n}\n\n/** A directory, and not a symlink to one. */\nfunction isRealDirectory(path: string): boolean {\n return lstatSync(path, { throwIfNoEntry: false })?.isDirectory() === true;\n}\n\nasync function heal(targets: readonly Target[], source: string, io: Io): Promise<void> {\n const updated: string[] = [];\n for (const { dir, name, path } of targets) {\n try {\n if (!(await isOurs(path, name))) continue;\n const { status } = await installSkill(join(source, name), join(dir, name), false, name, {\n followSymlinks: false,\n });\n if (status === 'up-to-date') continue;\n updated.push(path);\n } catch {\n // A denied write, a case collision, a file swapped under us: that skill keeps\n // what it has and the others are still healed, and NOTHING is said about it.\n // A cause the next command cannot clear either (a directory at 0500) would\n // otherwise print the same line forever, on every command, with no state to\n // suppress it and no way to dismiss it. `tenjin doctor` is where a skill that\n // is wired but not from this build gets reported, which is exactly this.\n }\n }\n if (updated.length > 0) emitWriteNotice(io, noticeFor(updated));\n}\n\n/** Does this file claim to BE the skill we would write over it? Somebody else's\n * skill is not ours to replace just for sitting at one of our paths. */\nasync function isOurs(path: string, name: string): Promise<boolean> {\n const read = await readSkillFile(path);\n return read.kind === 'ok' && skillFrontmatterName(read.bytes.toString('utf8')) === name;\n}\n\n/**\n * Files, not directories: this line is the only notice that content in the\n * operator's home changed unasked, so it has to say which content. It claims\n * nothing about edits being lost, because it cannot know. Every routine upgrade\n * rewrites these same files, and telling someone their edits are gone when they\n * made none is worse than saying nothing.\n */\nfunction noticeFor(updated: readonly string[]): string {\n return `Updated ${updated.join(' and ')} to match this CLI.`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,iBAAiB;AACtC,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY,YAAY;AAC1C,SAAS,qBAAqB;AA0B9B,IAAM,UAAU;AAqBhB,eAAsB,gBAAgB,MAA+B;AACnE,MAAI;AACF,UAAM,MAAM,KAAK,OAAO,QAAQ;AAGhC,QAAI,IAAI,OAAO,UAAa,IAAI,GAAG,SAAS,EAAG;AAC/C,QAAI,IAAI,OAAO,MAAM,IAAK;AAE1B,UAAM,OAAO,KAAK,WAAW,QAAQ;AAGrC,QAAI,CAAC,WAAW,IAAI,EAAG;AAEvB,UAAM,SAAS,KAAK,mBAAmB,eAAe;AACtD,QAAI,WAAW,KAAM;AACrB,UAAM,UAAU,SAAS,IAAI;AAC7B,QAAI,QAAQ,WAAW,EAAG;AAC1B,UAAM,KAAK,SAAS,QAAQ,KAAK,EAAE;AAAA,EACrC,QAAQ;AAAA,EAER;AACF;AAQA,SAAS,iBAAgC;AACvC,QAAM,MAAM,oBAAoB,cAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC,CAAC;AAC5E,SAAO,WAAW,KAAK,QAAQ,GAAG,GAAG,KAAK,CAAC,IAAI,OAAO;AACxD;AA8BA,SAAS,SAAS,MAAwB;AACxC,QAAM,QAAkB,CAAC;AACzB,aAAW,OAAO,cAAc,IAAI,GAAG;AACrC,QAAI,CAAC,gBAAgB,GAAG,EAAG;AAC3B,eAAW,QAAQ,iBAAiB;AAClC,UAAI,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,EAAG;AACvC,YAAM,OAAO,KAAK,KAAK,MAAM,UAAU;AACvC,UAAI,UAAU,MAAM,EAAE,gBAAgB,MAAM,CAAC,GAAG,OAAO,MAAM,KAAM;AACnE,YAAM,KAAK,EAAE,KAAK,MAAM,KAAK,CAAC;AAAA,IAChC;AAAA,EACF;AACA,SAAO;AACT;AAGA,SAAS,gBAAgB,MAAuB;AAC9C,SAAO,UAAU,MAAM,EAAE,gBAAgB,MAAM,CAAC,GAAG,YAAY,MAAM;AACvE;AAEA,eAAe,KAAK,SAA4B,QAAgB,IAAuB;AACrF,QAAM,UAAoB,CAAC;AAC3B,aAAW,EAAE,KAAK,MAAM,KAAK,KAAK,SAAS;AACzC,QAAI;AACF,UAAI,CAAE,MAAM,OAAO,MAAM,IAAI,EAAI;AACjC,YAAM,EAAE,OAAO,IAAI,MAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,OAAO,MAAM;AAAA,QACtF,gBAAgB;AAAA,MAClB,CAAC;AACD,UAAI,WAAW,aAAc;AAC7B,cAAQ,KAAK,IAAI;AAAA,IACnB,QAAQ;AAAA,IAOR;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,EAAG,iBAAgB,IAAI,UAAU,OAAO,CAAC;AAChE;AAIA,eAAe,OAAO,MAAc,MAAgC;AAClE,QAAM,OAAO,MAAM,cAAc,IAAI;AACrC,SAAO,KAAK,SAAS,QAAQ,qBAAqB,KAAK,MAAM,SAAS,MAAM,CAAC,MAAM;AACrF;AASA,SAAS,UAAU,SAAoC;AACrD,SAAO,WAAW,QAAQ,KAAK,OAAO,CAAC;AACzC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/uninstall.ts"],"sourcesContent":["import { homedir } from 'node:os';\nimport {\n KEPT_ITEMS,\n REMOVED_FROM_DATA_DIR,\n removeFromSettings,\n removeHookScripts,\n removeMarkerLines,\n removeSkills,\n type UninstallReport,\n} from '../lib/uninstall';\nimport { sanitizeForTerminal } from '../lib/output';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin uninstall`: undo exactly what `tenjin install` wrote, and nothing else.\n *\n * The shape of this command is the promise it makes. It removes the skills, the\n * hook scripts, our hook entries and permission rules in the harness's\n * settings.json, and the legacy pointer line older versions wrote into\n * CLAUDE.md/AGENTS.md. It does NOT remove the wallet, the config, the library,\n * the search ledger, or parked candidates: `install` did not create those, and a\n * wallet holds funds while a candidate is unpublished work. The hook scripts are\n * the one thing under `~/.tenjin` it does remove, because `install` generated\n * them. The receipt names both halves on every run, so the operator learns the\n * boundary from the command rather than from the docs.\n *\n * IDEMPOTENT BY CONSTRUCTION. Every step is \"remove it if it is ours and there\",\n * so a half-installed machine, an already-uninstalled one, and a machine that\n * never ran install all succeed and report what was (not) found. There is no\n * confirmation prompt and no --force: nothing here is unrecoverable, since a\n * `tenjin install` puts all of it back.\n */\n\nexport interface UninstallDeps {\n /** Home whose harness directories are cleaned; tests inject a temp dir. */\n home?: string;\n}\n\nexport async function runUninstall(\n ctx: CommandContext,\n deps: UninstallDeps = {},\n): Promise<CommandResult> {\n const home = deps.home ?? homedir();\n\n // Settings first: it is the only step with a concurrency guard, and the only\n // one that can refuse. Doing it before the scripts are deleted means a refusal\n // leaves a registered hook still pointing at a script that exists, rather than\n // at one that does not.\n const settings = await removeFromSettings(home);\n const scripts = await removeHookScripts(ctx.dataDir);\n const skills = await removeSkills(home);\n const markers = await removeMarkerLines(home);\n\n const report: UninstallReport = {\n settings,\n skills,\n scripts: scripts.scripts,\n ...(scripts.removedDir !== undefined ? { hooksDir: scripts.removedDir } : {}),\n markers,\n kept: [...KEPT_ITEMS],\n };\n\n return { data: report, humanLines: humanLines(report) };\n}\n\nfunction humanLines(report: UninstallReport): string[] {\n const { settings } = report;\n const removed: string[] = [];\n for (const dir of report.skills) removed.push(`skill ${sanitizeForTerminal(dir)}`);\n for (const script of report.scripts) removed.push(`hook script ${sanitizeForTerminal(script)}`);\n if (report.hooksDir !== undefined) {\n removed.push(`empty hooks directory ${sanitizeForTerminal(report.hooksDir)}`);\n }\n for (const event of settings.hooks) {\n removed.push(`${event} hook entry in ${sanitizeForTerminal(settings.path)}`);\n }\n if (settings.rules.length > 0) {\n removed.push(\n `${settings.rules.length} tenjin permission rule(s) in ${sanitizeForTerminal(settings.path)}`,\n );\n }\n for (const path of report.markers) {\n removed.push(`legacy pointer line in ${sanitizeForTerminal(path)}`);\n }\n\n const lines =\n removed.length === 0\n ? ['Nothing to remove; tenjin was not installed here.']\n : ['Removed:', ...removed.map((r) => ` - ${r}`)];\n\n // Named on EVERY run, including the nothing-to-remove one: the boundary is the\n // point of the command, and an operator reaching for it is usually worried\n // about exactly these things. The exception is named right under them, because\n // an unqualified \"nothing under ~/.tenjin is touched\" is contradicted by the\n // hook scripts this same receipt just listed as removed.\n lines.push('Kept:');\n for (const item of report.kept) lines.push(` - ${item}`);\n lines.push(`Removed from ~/.tenjin: ${REMOVED_FROM_DATA_DIR}`);\n\n if (settings.warning !== undefined) {\n lines.push(`! ${sanitizeForTerminal(settings.warning)}`);\n }\n lines.push('Reinstall anytime: tenjin install');\n return lines;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AAsCxB,eAAsB,aACpB,KACA,OAAsB,CAAC,GACC;AACxB,QAAM,OAAO,KAAK,QAAQ,QAAQ;AAMlC,QAAM,WAAW,MAAM,mBAAmB,IAAI;AAC9C,QAAM,UAAU,MAAM,kBAAkB,IAAI,OAAO;AACnD,QAAM,SAAS,MAAM,aAAa,IAAI;AACtC,QAAM,UAAU,MAAM,kBAAkB,IAAI;AAE5C,QAAM,SAA0B;AAAA,IAC9B;AAAA,IACA;AAAA,IACA,SAAS,QAAQ;AAAA,IACjB,GAAI,QAAQ,eAAe,SAAY,EAAE,UAAU,QAAQ,WAAW,IAAI,CAAC;AAAA,IAC3E;AAAA,IACA,MAAM,CAAC,GAAG,UAAU;AAAA,EACtB;AAEA,SAAO,EAAE,MAAM,QAAQ,YAAY,WAAW,MAAM,EAAE;AACxD;AAEA,SAAS,WAAW,QAAmC;AACrD,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,UAAoB,CAAC;AAC3B,aAAW,OAAO,OAAO,OAAQ,SAAQ,KAAK,SAAS,oBAAoB,GAAG,CAAC,EAAE;AACjF,aAAW,UAAU,OAAO,QAAS,SAAQ,KAAK,eAAe,oBAAoB,MAAM,CAAC,EAAE;AAC9F,MAAI,OAAO,aAAa,QAAW;AACjC,YAAQ,KAAK,yBAAyB,oBAAoB,OAAO,QAAQ,CAAC,EAAE;AAAA,EAC9E;AACA,aAAW,SAAS,SAAS,OAAO;AAClC,YAAQ,KAAK,GAAG,KAAK,kBAAkB,oBAAoB,SAAS,IAAI,CAAC,EAAE;AAAA,EAC7E;AACA,MAAI,SAAS,MAAM,SAAS,GAAG;AAC7B,YAAQ;AAAA,MACN,GAAG,SAAS,MAAM,MAAM,iCAAiC,oBAAoB,SAAS,IAAI,CAAC;AAAA,IAC7F;AAAA,EACF;AACA,aAAW,QAAQ,OAAO,SAAS;AACjC,YAAQ,KAAK,0BAA0B,oBAAoB,IAAI,CAAC,EAAE;AAAA,EACpE;AAEA,QAAM,QACJ,QAAQ,WAAW,IACf,CAAC,mDAAmD,IACpD,CAAC,YAAY,GAAG,QAAQ,IAAI,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC;AAOpD,QAAM,KAAK,OAAO;AAClB,aAAW,QAAQ,OAAO,KAAM,OAAM,KAAK,OAAO,IAAI,EAAE;AACxD,QAAM,KAAK,2BAA2B,qBAAqB,EAAE;AAE7D,MAAI,SAAS,YAAY,QAAW;AAClC,UAAM,KAAK,KAAK,oBAAoB,SAAS,OAAO,CAAC,EAAE;AAAA,EACzD;AACA,QAAM,KAAK,mCAAmC;AAC9C,SAAO;AACT;","names":[]}