tenjin-cli 0.1.0-alpha.10 → 0.1.0-alpha.11

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 (114) hide show
  1. package/README.md +54 -30
  2. package/dist/{buy-FMDBZ4NY.js → buy-THMVOPUH.js} +17 -17
  3. package/dist/{chunk-AWQ6A4CI.js → chunk-2SDUV6MQ.js} +83 -72
  4. package/dist/chunk-2SDUV6MQ.js.map +1 -0
  5. package/dist/{chunk-DKQMJTG7.js → chunk-3GSZUADW.js} +14 -3
  6. package/dist/{chunk-DKQMJTG7.js.map → chunk-3GSZUADW.js.map} +1 -1
  7. package/dist/{chunk-5SE6BJRP.js → chunk-4NTZETIL.js} +25 -2
  8. package/dist/chunk-4NTZETIL.js.map +1 -0
  9. package/dist/{chunk-TWRYSGAW.js → chunk-4TCU3YRD.js} +8 -12
  10. package/dist/chunk-4TCU3YRD.js.map +1 -0
  11. package/dist/{chunk-7WDY4AXV.js → chunk-6BGYHARE.js} +18 -18
  12. package/dist/{chunk-UOJRKQTZ.js → chunk-6UY2UQMY.js} +3 -3
  13. package/dist/{chunk-36X2CA3N.js → chunk-ALUNME53.js} +1 -6
  14. package/dist/{chunk-36X2CA3N.js.map → chunk-ALUNME53.js.map} +1 -1
  15. package/dist/{chunk-GECSWJ7O.js → chunk-CNUXRXI2.js} +2 -2
  16. package/dist/chunk-E6YOODH7.js +913 -0
  17. package/dist/chunk-E6YOODH7.js.map +1 -0
  18. package/dist/{chunk-O6CAUZGY.js → chunk-EDVI7RRD.js} +3 -3
  19. package/dist/{chunk-MD7WGYYI.js → chunk-GKV6VZSZ.js} +9 -9
  20. package/dist/{chunk-JSSIMGQT.js → chunk-GUUAYR3K.js} +27 -26
  21. package/dist/chunk-GUUAYR3K.js.map +1 -0
  22. package/dist/{chunk-ZUAQRIVP.js → chunk-IAFYUFIC.js} +64 -25
  23. package/dist/chunk-IAFYUFIC.js.map +1 -0
  24. package/dist/{chunk-R2VLGNFD.js → chunk-IB63U6BM.js} +5 -1
  25. package/dist/chunk-IB63U6BM.js.map +1 -0
  26. package/dist/chunk-IXTENA2H.js +235 -0
  27. package/dist/chunk-IXTENA2H.js.map +1 -0
  28. package/dist/{chunk-BJJ5BQO6.js → chunk-JTYIX6OD.js} +3 -4
  29. package/dist/{chunk-5JXAZP7H.js → chunk-NUF2PKJO.js} +2 -1
  30. package/dist/{chunk-KYH4KPE5.js → chunk-O25VWJCG.js} +26 -26
  31. package/dist/{chunk-BUDHTDKL.js → chunk-OCN27NJV.js} +6 -6
  32. package/dist/{chunk-GSDZRCGF.js → chunk-OZHJ3FLR.js} +4 -4
  33. package/dist/{chunk-X3OOVSPX.js → chunk-RSBN67PA.js} +2 -4
  34. package/dist/{chunk-5JMKIDMM.js → chunk-SFGXAZ3M.js} +3 -3
  35. package/dist/{chunk-POF7HPRV.js → chunk-TDDN5GXR.js} +3 -3
  36. package/dist/{chunk-STND72DS.js → chunk-UFPJBS4C.js} +4 -4
  37. package/dist/chunk-UFPJBS4C.js.map +1 -0
  38. package/dist/{chunk-A6KCZPNQ.js → chunk-UY6CGULW.js} +2 -2
  39. package/dist/{chunk-A6KCZPNQ.js.map → chunk-UY6CGULW.js.map} +1 -1
  40. package/dist/{chunk-VRRLTZ2Q.js → chunk-VWY3U732.js} +40 -17
  41. package/dist/chunk-VWY3U732.js.map +1 -0
  42. package/dist/{chunk-6BZLSRNU.js → chunk-XWHXX2BI.js} +6 -6
  43. package/dist/{chunk-V4WWTZHZ.js → chunk-ZE7KOO7A.js} +7 -7
  44. package/dist/{cli-HK2XAWNW.js → cli-Y2HBOSGK.js} +57 -60
  45. package/dist/{cli-HK2XAWNW.js.map → cli-Y2HBOSGK.js.map} +1 -1
  46. package/dist/{config-LYCHHNAJ.js → config-WDGMZKHU.js} +4 -4
  47. package/dist/{doctor-2KPUQURC.js → doctor-CSIWKWM2.js} +9 -9
  48. package/dist/{edit-TST3OCKQ.js → edit-E7N6F3OY.js} +15 -15
  49. package/dist/fund-OKK627GL.js +38 -0
  50. package/dist/index.js +1 -1
  51. package/dist/{inspect-TPTHVPBB.js → inspect-573WHEV4.js} +13 -13
  52. package/dist/{install-PT3XEDJ6.js → install-SQAYMNQC.js} +88 -823
  53. package/dist/install-SQAYMNQC.js.map +1 -0
  54. package/dist/{outcome-NPNSF2Q7.js → outcome-W3KYGF23.js} +9 -9
  55. package/dist/{publish-XP5SEWST.js → publish-N5U4XYVA.js} +16 -17
  56. package/dist/{read-D4VXRWOG.js → read-PJ7Z6UGF.js} +18 -18
  57. package/dist/{run-3IPGEXW7.js → run-FSO3MMXN.js} +71 -90
  58. package/dist/{run-3IPGEXW7.js.map → run-FSO3MMXN.js.map} +1 -1
  59. package/dist/{search-YOBD6VDI.js → search-ZWOP4EGK.js} +10 -11
  60. package/dist/{send-BWNP6WN4.js → send-F34ZDXDZ.js} +5 -5
  61. package/dist/{session-GZEZBOMI.js → session-4N4ZT3AH.js} +13 -13
  62. package/dist/{skill-heal-OK6YALW6.js → skill-heal-XBEK272G.js} +3 -3
  63. package/dist/uninstall-BTKPHPDL.js +68 -0
  64. package/dist/uninstall-BTKPHPDL.js.map +1 -0
  65. package/dist/{wallet-YEGQBWWL.js → wallet-UL4P2JRO.js} +3 -3
  66. package/dist/{wallet-5RHDFPN2.js → wallet-WJ6UP5OU.js} +5 -5
  67. package/docs/agent-permissions.md +42 -29
  68. package/package.json +1 -1
  69. package/skills/tenjin-publish/SKILL.md +49 -36
  70. package/skills/tenjin-search/SKILL.md +34 -28
  71. package/dist/candidate-7LAELUQD.js +0 -23
  72. package/dist/chunk-2GSRYTZS.js +0 -127
  73. package/dist/chunk-2GSRYTZS.js.map +0 -1
  74. package/dist/chunk-5SE6BJRP.js.map +0 -1
  75. package/dist/chunk-AWQ6A4CI.js.map +0 -1
  76. package/dist/chunk-JSSIMGQT.js.map +0 -1
  77. package/dist/chunk-R2VLGNFD.js.map +0 -1
  78. package/dist/chunk-STND72DS.js.map +0 -1
  79. package/dist/chunk-TEL27PR5.js +0 -124
  80. package/dist/chunk-TEL27PR5.js.map +0 -1
  81. package/dist/chunk-TWRYSGAW.js.map +0 -1
  82. package/dist/chunk-VRRLTZ2Q.js.map +0 -1
  83. package/dist/chunk-ZUAQRIVP.js.map +0 -1
  84. package/dist/install-PT3XEDJ6.js.map +0 -1
  85. /package/dist/{buy-FMDBZ4NY.js.map → buy-THMVOPUH.js.map} +0 -0
  86. /package/dist/{chunk-7WDY4AXV.js.map → chunk-6BGYHARE.js.map} +0 -0
  87. /package/dist/{chunk-UOJRKQTZ.js.map → chunk-6UY2UQMY.js.map} +0 -0
  88. /package/dist/{chunk-GECSWJ7O.js.map → chunk-CNUXRXI2.js.map} +0 -0
  89. /package/dist/{chunk-O6CAUZGY.js.map → chunk-EDVI7RRD.js.map} +0 -0
  90. /package/dist/{chunk-MD7WGYYI.js.map → chunk-GKV6VZSZ.js.map} +0 -0
  91. /package/dist/{chunk-BJJ5BQO6.js.map → chunk-JTYIX6OD.js.map} +0 -0
  92. /package/dist/{chunk-5JXAZP7H.js.map → chunk-NUF2PKJO.js.map} +0 -0
  93. /package/dist/{chunk-KYH4KPE5.js.map → chunk-O25VWJCG.js.map} +0 -0
  94. /package/dist/{chunk-BUDHTDKL.js.map → chunk-OCN27NJV.js.map} +0 -0
  95. /package/dist/{chunk-GSDZRCGF.js.map → chunk-OZHJ3FLR.js.map} +0 -0
  96. /package/dist/{chunk-X3OOVSPX.js.map → chunk-RSBN67PA.js.map} +0 -0
  97. /package/dist/{chunk-5JMKIDMM.js.map → chunk-SFGXAZ3M.js.map} +0 -0
  98. /package/dist/{chunk-POF7HPRV.js.map → chunk-TDDN5GXR.js.map} +0 -0
  99. /package/dist/{chunk-6BZLSRNU.js.map → chunk-XWHXX2BI.js.map} +0 -0
  100. /package/dist/{chunk-V4WWTZHZ.js.map → chunk-ZE7KOO7A.js.map} +0 -0
  101. /package/dist/{candidate-7LAELUQD.js.map → config-WDGMZKHU.js.map} +0 -0
  102. /package/dist/{config-LYCHHNAJ.js.map → doctor-CSIWKWM2.js.map} +0 -0
  103. /package/dist/{doctor-2KPUQURC.js.map → edit-E7N6F3OY.js.map} +0 -0
  104. /package/dist/{edit-TST3OCKQ.js.map → fund-OKK627GL.js.map} +0 -0
  105. /package/dist/{inspect-TPTHVPBB.js.map → inspect-573WHEV4.js.map} +0 -0
  106. /package/dist/{outcome-NPNSF2Q7.js.map → outcome-W3KYGF23.js.map} +0 -0
  107. /package/dist/{publish-XP5SEWST.js.map → publish-N5U4XYVA.js.map} +0 -0
  108. /package/dist/{read-D4VXRWOG.js.map → read-PJ7Z6UGF.js.map} +0 -0
  109. /package/dist/{search-YOBD6VDI.js.map → search-ZWOP4EGK.js.map} +0 -0
  110. /package/dist/{send-BWNP6WN4.js.map → send-F34ZDXDZ.js.map} +0 -0
  111. /package/dist/{session-GZEZBOMI.js.map → session-4N4ZT3AH.js.map} +0 -0
  112. /package/dist/{skill-heal-OK6YALW6.js.map → skill-heal-XBEK272G.js.map} +0 -0
  113. /package/dist/{wallet-5RHDFPN2.js.map → wallet-UL4P2JRO.js.map} +0 -0
  114. /package/dist/{wallet-YEGQBWWL.js.map → wallet-WJ6UP5OU.js.map} +0 -0
@@ -1,124 +0,0 @@
1
- import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- UUID_RE,
4
- newId
5
- } from "./chunk-36X2CA3N.js";
6
- import {
7
- hasCode
8
- } from "./chunk-2I4QTOLB.js";
9
- import {
10
- external_exports,
11
- writeFileAtomicExclusive
12
- } from "./chunk-PZRAAAY2.js";
13
-
14
- // src/lib/candidate-store.ts
15
- import { mkdir, readFile, readdir, rm, stat } from "fs/promises";
16
- import { join } from "path";
17
- var DRAFT_FILE = "draft.md";
18
- var META_FILE = "meta.json";
19
- var CandidateMetaSchema = external_exports.object({
20
- schemaVersion: external_exports.literal(1),
21
- searchId: external_exports.string(),
22
- question: external_exports.string().optional(),
23
- // Fixed-width UTC ISO-8601 (a trailing Z, never an offset): listCandidates
24
- // sorts newest-first lexicographically on this string, which is only a valid
25
- // proxy for chronological order when every value is same-zone UTC. z.iso
26
- // .datetime() rejects offsets and non-datetime strings, pinning that invariant.
27
- created: external_exports.iso.datetime(),
28
- /** The repo root the add ran in, or the cwd when not in a repo. */
29
- sourceProject: external_exports.string()
30
- });
31
- function candidatesDir(dataDir) {
32
- return join(dataDir, "candidates");
33
- }
34
- function candidateDir(dataDir, id) {
35
- return join(candidatesDir(dataDir), id);
36
- }
37
- async function createCandidate(dataDir, input) {
38
- const id = newId();
39
- const dir = candidateDir(dataDir, id);
40
- await mkdir(dir, { recursive: true, mode: 448 });
41
- const draftPath = join(dir, DRAFT_FILE);
42
- const meta = {
43
- schemaVersion: 1,
44
- searchId: input.searchId,
45
- ...input.question !== void 0 ? { question: input.question } : {},
46
- created: input.created,
47
- sourceProject: input.sourceProject
48
- };
49
- try {
50
- await writeFileAtomicExclusive(draftPath, input.draft, { mode: 384, dirMode: 448 });
51
- await writeFileAtomicExclusive(join(dir, META_FILE), `${JSON.stringify(meta, null, 2)}
52
- `, {
53
- mode: 384,
54
- dirMode: 448
55
- });
56
- } catch (err) {
57
- if (!hasCode(err, "EEXIST")) {
58
- await rm(dir, { recursive: true, force: true }).catch(() => void 0);
59
- }
60
- throw err;
61
- }
62
- return { id, meta, dir, draftPath };
63
- }
64
- async function readCandidate(dataDir, id) {
65
- if (!UUID_RE.test(id)) return null;
66
- const dir = candidateDir(dataDir, id);
67
- const meta = await readMeta(dir);
68
- if (meta === null) return null;
69
- return { id, meta, dir, draftPath: join(dir, DRAFT_FILE) };
70
- }
71
- async function listCandidates(dataDir) {
72
- let entries;
73
- try {
74
- entries = await readdir(candidatesDir(dataDir), { withFileTypes: true });
75
- } catch {
76
- return [];
77
- }
78
- const records = [];
79
- for (const entry of entries) {
80
- if (!entry.isDirectory() || !UUID_RE.test(entry.name)) continue;
81
- const record = await readCandidate(dataDir, entry.name);
82
- if (record !== null) records.push(record);
83
- }
84
- records.sort((a, b) => {
85
- if (a.meta.created !== b.meta.created) return a.meta.created < b.meta.created ? 1 : -1;
86
- return a.id < b.id ? 1 : -1;
87
- });
88
- return records;
89
- }
90
- async function dropCandidate(dataDir, id) {
91
- if (!UUID_RE.test(id)) return false;
92
- const dir = candidateDir(dataDir, id);
93
- try {
94
- if (!(await stat(dir)).isDirectory()) return false;
95
- } catch {
96
- return false;
97
- }
98
- await rm(dir, { recursive: true, force: true });
99
- return true;
100
- }
101
- async function readMeta(dir) {
102
- let raw;
103
- try {
104
- raw = await readFile(join(dir, META_FILE), "utf8");
105
- } catch {
106
- return null;
107
- }
108
- let json;
109
- try {
110
- json = JSON.parse(raw);
111
- } catch {
112
- return null;
113
- }
114
- const parsed = CandidateMetaSchema.safeParse(json);
115
- return parsed.success ? parsed.data : null;
116
- }
117
-
118
- export {
119
- createCandidate,
120
- readCandidate,
121
- listCandidates,
122
- dropCandidate
123
- };
124
- //# sourceMappingURL=chunk-TEL27PR5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/candidate-store.ts"],"sourcesContent":["import { mkdir, readFile, readdir, rm, stat } from 'node:fs/promises';\nimport type { Dirent } from 'node:fs';\nimport { join } from 'node:path';\nimport { z } from 'zod';\nimport { writeFileAtomicExclusive } from './atomic-json';\nimport { hasCode } from './errno';\nimport { newId, UUID_RE } from './ids';\n\n/**\n * The D40 candidate store: publish drafts parked locally that never touch the\n * network and never upload — only a later `tenjin publish --candidate <id>`\n * sends one, under the D38 consent scan. Each candidate is its OWN directory\n * `~/.tenjin/candidates/<id>/` holding the draft markdown plus a meta.json.\n *\n * Custody mirrors the wallet key discipline: the candidates tree is 0700 and\n * every file 0600, written create-once through writeFileAtomicExclusive so a\n * reader sees a complete file or none and a uuid collision is loud, never a\n * silent overwrite. Unlike search-store's single shared ledger, there is no shared\n * mutable file here — a fresh uuid per add means two concurrent adds land in two\n * distinct dirs and cannot contend — so no cross-process lock is needed. The\n * meta.json is written LAST and atomically, making it the commit point: `list`\n * skips any dir whose meta is absent or unreadable, so a torn or half-written\n * add reads as not-yet-there rather than a broken candidate, the same\n * best-effort posture loadSearches takes on a corrupt store. A crash mid-add is\n * cleaned up eagerly (the dir is removed on any write failure), and `drop` can\n * still remove a metaless orphan by id so a leaked draft is never stranded.\n */\n\nconst DRAFT_FILE = 'draft.md';\nconst META_FILE = 'meta.json';\n\nconst CandidateMetaSchema = z.object({\n schemaVersion: z.literal(1),\n searchId: z.string(),\n question: z.string().optional(),\n // Fixed-width UTC ISO-8601 (a trailing Z, never an offset): listCandidates\n // sorts newest-first lexicographically on this string, which is only a valid\n // proxy for chronological order when every value is same-zone UTC. z.iso\n // .datetime() rejects offsets and non-datetime strings, pinning that invariant.\n created: z.iso.datetime(),\n /** The repo root the add ran in, or the cwd when not in a repo. */\n sourceProject: z.string(),\n});\nexport type CandidateMeta = z.infer<typeof CandidateMetaSchema>;\n\nexport interface CandidateRecord {\n id: string;\n meta: CandidateMeta;\n /** Absolute path of the candidate directory. */\n dir: string;\n /** Absolute path of the draft markdown inside the directory. */\n draftPath: string;\n}\n\nexport interface CreateCandidateInput {\n /** The draft markdown, copied verbatim into the candidate. */\n draft: string;\n searchId: string;\n question?: string;\n /** ISO-8601 creation time; the command supplies it via its clock seam. */\n created: string;\n sourceProject: string;\n}\n\nfunction candidatesDir(dataDir: string): string {\n return join(dataDir, 'candidates');\n}\n\nfunction candidateDir(dataDir: string, id: string): string {\n return join(candidatesDir(dataDir), id);\n}\n\n/** Park a draft as a new candidate and return the created record. Both files are\n * written create-once (no-clobber, fsynced) at a fresh uuid path, meta.json\n * last, so the candidate is either fully present to `list`/`read` or absent,\n * never half-there. */\nexport async function createCandidate(\n dataDir: string,\n input: CreateCandidateInput,\n): Promise<CandidateRecord> {\n const id = newId();\n const dir = candidateDir(dataDir, id);\n await mkdir(dir, { recursive: true, mode: 0o700 });\n\n const draftPath = join(dir, DRAFT_FILE);\n const meta: CandidateMeta = {\n schemaVersion: 1,\n searchId: input.searchId,\n ...(input.question !== undefined ? { question: input.question } : {}),\n created: input.created,\n sourceProject: input.sourceProject,\n };\n try {\n // Exclusive (create-or-EEXIST, fsynced) so a uuid collision is loud, not a\n // silent overwrite of an existing candidate, and the crash-durable commit of\n // meta.json is the last, atomic step.\n await writeFileAtomicExclusive(draftPath, input.draft, { mode: 0o600, dirMode: 0o700 });\n await writeFileAtomicExclusive(join(dir, META_FILE), `${JSON.stringify(meta, null, 2)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n } catch (err) {\n // An EEXIST means something already lived at this fresh-uuid path (a real\n // collision, astronomically unlikely): surface it loudly and NEVER delete\n // what was already there. Any other failure is a partial write of our own\n // fresh dir — remove it so a crash mid-add can't strand a hidden dir holding\n // the (secrets-adjacent) draft that `list` skips and no one can name to `drop`.\n if (!hasCode(err, 'EEXIST')) {\n await rm(dir, { recursive: true, force: true }).catch(() => undefined);\n }\n throw err;\n }\n\n return { id, meta, dir, draftPath };\n}\n\n/** One candidate by id, or null when it is unknown (or the id is malformed, so a\n * stray argument can never traverse out of the store). */\nexport async function readCandidate(dataDir: string, id: string): Promise<CandidateRecord | null> {\n if (!UUID_RE.test(id)) return null;\n const dir = candidateDir(dataDir, id);\n const meta = await readMeta(dir);\n if (meta === null) return null;\n return { id, meta, dir, draftPath: join(dir, DRAFT_FILE) };\n}\n\n/** Every pending candidate, newest first by `created` (no auto-expiry — stale\n * candidates stay visible, D40). Tie-broken on id so the order is total. */\nexport async function listCandidates(dataDir: string): Promise<CandidateRecord[]> {\n let entries: Dirent[];\n try {\n entries = await readdir(candidatesDir(dataDir), { withFileTypes: true });\n } catch {\n return [];\n }\n const records: CandidateRecord[] = [];\n for (const entry of entries) {\n if (!entry.isDirectory() || !UUID_RE.test(entry.name)) continue;\n const record = await readCandidate(dataDir, entry.name);\n if (record !== null) records.push(record);\n }\n records.sort((a, b) => {\n if (a.meta.created !== b.meta.created) return a.meta.created < b.meta.created ? 1 : -1;\n return a.id < b.id ? 1 : -1;\n });\n return records;\n}\n\n/** Discard one candidate by id. Returns false when the id is malformed or no\n * such dir exists, so the command can surface a clean not-found; nothing is\n * ever auto-deleted. Removes the dir even when its meta is absent or corrupt,\n * so a crash-orphaned candidate can still be cleaned up by id (the id is\n * UUID-gated first, so a stray argument can never target a path outside the\n * store). */\nexport async function dropCandidate(dataDir: string, id: string): Promise<boolean> {\n if (!UUID_RE.test(id)) return false;\n const dir = candidateDir(dataDir, id);\n try {\n if (!(await stat(dir)).isDirectory()) return false;\n } catch {\n return false; // no such candidate\n }\n await rm(dir, { recursive: true, force: true });\n return true;\n}\n\n/** Read and validate a candidate's meta.json; null on any absence/corruption. */\nasync function readMeta(dir: string): Promise<CandidateMeta | null> {\n let raw: string;\n try {\n raw = await readFile(join(dir, META_FILE), 'utf8');\n } catch {\n return null;\n }\n let json: unknown;\n try {\n json = JSON.parse(raw);\n } catch {\n return null;\n }\n const parsed = CandidateMetaSchema.safeParse(json);\n return parsed.success ? parsed.data : null;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,OAAO,UAAU,SAAS,IAAI,YAAY;AAEnD,SAAS,YAAY;AA0BrB,IAAM,aAAa;AACnB,IAAM,YAAY;AAElB,IAAM,sBAAsB,iBAAE,OAAO;AAAA,EACnC,eAAe,iBAAE,QAAQ,CAAC;AAAA,EAC1B,UAAU,iBAAE,OAAO;AAAA,EACnB,UAAU,iBAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9B,SAAS,iBAAE,IAAI,SAAS;AAAA;AAAA,EAExB,eAAe,iBAAE,OAAO;AAC1B,CAAC;AAsBD,SAAS,cAAc,SAAyB;AAC9C,SAAO,KAAK,SAAS,YAAY;AACnC;AAEA,SAAS,aAAa,SAAiB,IAAoB;AACzD,SAAO,KAAK,cAAc,OAAO,GAAG,EAAE;AACxC;AAMA,eAAsB,gBACpB,SACA,OAC0B;AAC1B,QAAM,KAAK,MAAM;AACjB,QAAM,MAAM,a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C,aAAW,SAAS,SAAS;AAC3B,QAAI,CAAC,MAAM,YAAY,KAAK,CAAC,QAAQ,KAAK,MAAM,IAAI,EAAG;AACvD,UAAM,SAAS,MAAM,cAAc,SAAS,MAAM,IAAI;AACtD,QAAI,WAAW,KAAM,SAAQ,KAAK,MAAM;AAAA,EAC1C;AACA,UAAQ,KAAK,CAAC,GAAG,MAAM;AACrB,QAAI,EAAE,KAAK,YAAY,EAAE,KAAK,QAAS,QAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,IAAI;AACpF,WAAO,EAAE,KAAK,EAAE,KAAK,IAAI;AAAA,EAC3B,CAAC;AACD,SAAO;AACT;AAQA,eAAsB,cAAc,SAAiB,IAA8B;AACjF,MAAI,CAAC,QAAQ,KAAK,EAAE,EAAG,QAAO;AAC9B,QAAM,MAAM,aAAa,SAAS,EAAE;AACpC,MAAI;AACF,QAAI,EAAE,MAAM,KAAK,GAAG,GAAG,YAAY,EAAG,QAAO;AAAA,EAC/C,QAAQ;AACN,WAAO;AAAA,EACT;AACA,QAAM,GAAG,KAAK,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAC9C,SAAO;AACT;AAGA,eAAe,SAAS,KAA4C;AAClE,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,SAAS,KAAK,KAAK,SAAS,GAAG,MAAM;AAAA,EACnD,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,QAAM,SAAS,oBAAoB,UAAU,IAAI;AACjD,SAAO,OAAO,UAAU,OAAO,OAAO;AACxC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/permissions.ts"],"sourcesContent":["/**\n * The recommended HARNESS permission allowlist: the exact rule lines an operator\n * pastes into Claude Code (or an equivalent harness) so auto mode stops denying\n * the free Tenjin verbs, and so the one paying verb is cleared deliberately\n * rather than by accident.\n *\n * This is a HARNESS-side allowlist (which shell commands the agent may run at\n * all). It is NOT the CLI's spend policy and shares nothing with it: the shipped\n * `allowlistCreators` config key gates WHO you may pay, this file gates WHICH\n * COMMANDS the harness will run without a prompt. The two are deliberately kept\n * apart in name and in code — clearing `Bash(tenjin buy:*)` here never raises a\n * spend cap. That is a claim about this file, NOT a claim that the spend policy\n * stops an allowlisted `buy`: `--yes` is an ordinary flag on an allowlisted verb\n * and `confirmSpend` returns true on it before any TTY check\n * (src/commands/buy.ts), so under CONFIG_DEFAULTS nothing denies. See\n * OPT_IN_ALLOWLIST's note for the walk-through.\n *\n * These are static, shipped constants on purpose: there is NO config key for\n * them. An operator-editable \"which commands may run\" list stored next to the\n * spend policy would be a second, weaker copy of a control the harness already\n * owns, and a CLI that could widen its own permission grant is exactly the shape\n * this file exists to avoid.\n *\n * Scope: `tenjin mcp` exposes the same command cores over MCP, where the harness\n * gates TOOLS, not Bash lines. These rules say nothing about that surface, which\n * is why `tenjin mcp` is itself never recommended here: clearing it would route\n * around every rule below. MCP_CAVEAT names the tools to leave gated for an\n * operator who runs the server anyway.\n *\n * LIMIT OF A PREFIX RULE, read this before adding an entry: the rule constrains\n * the VERB and nothing else. `addGlobalFlags` (src/cli.ts) puts `--json`,\n * `--timeout`, and `--base-url` on every leaf command, so every rule below also\n * clears `--base-url <url>` in trailing position. `--base-url` is validated as a\n * URL and nothing more, and it wins settings precedence, so it re-points the\n * trust boundary itself: the `search` question goes to that host, `doctor` probes\n * it, and `assertOnBaseOrigin` only checks that a resource URL shares an origin\n * with the CONFIGURED base, so an attacker-controlled pair satisfies the pin. No\n * prefix syntax expresses \"this verb but not that flag\", so the mitigation is\n * disclosure rather than a narrower rule: FLAG_CAVEAT rides the `--json` payload\n * and docs/agent-permissions.md, every human surface points at that page, and the\n * skills tell the agent never to pass `--base-url` on an allowlisted verb. Pinning\n * the paying path to a constant origin instead is the real fix and is an\n * x402/payments-semantics change, tracked separately.\n */\n\n/** One pasteable allowlist rule plus why it is safe (or what it costs). */\nexport interface AllowlistEntry {\n /** The exact line to add to the harness permission allowlist. */\n rule: string;\n /** The verb it clears. */\n command: string;\n /** Why it is safe to pre-clear, or what the operator is opting into. */\n note: string;\n}\n\n/** A verb deliberately kept OUT of the recommended allowlist, and why. */\nexport interface ExcludedVerb {\n command: string;\n reason: string;\n}\n\n/**\n * FREE verbs: they CANNOT SPEND AND CANNOT MOVE YOUR KEYS. That is the whole\n * definition of this tier, and it is deliberately narrower than the older \"no\n * wallet, no signing, no payment\" — which stopped being true the moment `read`\n * gained the ability to PRESENT a cached session key. `read` signs, with a P-256\n * delegation loaded from disk; it cannot mint one (that needs the wallet, and its\n * import graph is test-pinned clear of it) and cannot produce the\n * secp256k1/EIP-712 signature a payment authorization needs (wrong curve). Money\n * stays out of reach; a signature as such no longer does, so the tier says what\n * it means. `doctor` decrypts locally to check the wallet still opens.\n *\n * What the tier does NOT claim, because it is not true: that the read scope\n * limits what a leaked delegation is worth. Scope is enforced only on the request\n * shape that carries both a session signature and the delegation header; the same\n * delegation replayed as a plain `SIGN-IN-WITH-X` takes a different server path\n * where no scope logic runs. So a session file is a wallet-derived credential\n * with the authority of the wallet behind it, and the mitigations that actually\n * hold are the ones in this repo: it is 0600, short-lived (≤24h, server-clamped),\n * bound to the origin it was minted for, and never presented off that origin.\n * Treat \"read is allowlisted\" as \"read may transmit that credential to the\n * configured origin\", and see FLAG_CAVEAT for why the configured origin is not\n * automatically the one you configured.\n *\n * Not all of them are read-only, and the difference is disclosed rather than\n * papered over — `search` POSTs the (generalized, anonymous) question off-machine\n * and records it locally, `outcome` POSTs a report that moves the marketplace's\n * reuse signal (both unauthenticated remote writes), and `read` writes locally,\n * saving a delivered piece to the library, and `doctor` decrypts the keystore\n * locally to check it opens. Pre-clearing them is defensible because they cost\n * nothing and none of it leaves the machine; calling them read-only to justify it\n * would not be.\n *\n * Rules are PREFIX rules: `Bash(tenjin search:*)` clears commands that start with\n * `tenjin search` and nothing else. The narrow `wallet show` / `wallet balance` /\n * `config get` / `candidate list` forms are deliberate: a `Bash(tenjin wallet:*)`\n * or `Bash(tenjin config:*)` rule would silently swallow `wallet create` and\n * `config set`, and `config set` can raise the spend caps.\n *\n * Two known gaps, both fail-closed (denied, never wrongly allowed):\n * - Bare `tenjin config` (runConfigList) is as read-only as `config get`, but no\n * prefix rule reaches it without also covering `config set`, so it stays out.\n * Use `tenjin config get <key>`, which is a different supported command rather\n * than a reworded one.\n * - Group-level flag forms like `tenjin wallet --json show` are not covered.\n * Put global flags AFTER the leaf verb (`tenjin wallet show --json`); the\n * CLI parses either, and only the trailing form matches these rules.\n */\nexport const ALWAYS_SAFE_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin search:*)',\n command: 'tenjin search',\n note:\n 'Free anonymous marketplace search. No wallet, no signing, no payment. ' +\n 'Not read-only: it POSTs the generalized question off-machine and records ' +\n 'the search locally.',\n },\n {\n rule: 'Bash(tenjin inspect:*)',\n command: 'tenjin inspect',\n note: 'Free pre-purchase card and preview. Never signs, never pays, never saves.',\n },\n {\n rule: 'Bash(tenjin read:*)',\n command: 'tenjin read',\n note:\n 'Free-only delivery: free pieces, local-library re-reads, and pieces this ' +\n 'wallet already owns when a read-scoped session key is cached. Cannot spend ' +\n 'and cannot open the keystore — the wallet, payment, and session-MINTING ' +\n 'modules are all absent from its import graph, so the key it may present is ' +\n 'a P-256 delegation loaded from disk, which is the wrong curve to authorize ' +\n 'a payment. TRANSMITS A CREDENTIAL: when a session key exists, a cold 402 ' +\n 'sends that wallet-derived delegation to the server. It goes only to the ' +\n 'origin the delegation was minted for, which is what stops a stray ' +\n '`--base-url` from redirecting it, and no scope on it limits what a holder ' +\n 'could do with it. Not read-only: a freshly delivered piece is saved to the ' +\n 'library.',\n },\n {\n rule: 'Bash(tenjin outcome:*)',\n command: 'tenjin outcome',\n note:\n 'Free honest outcome report on a past search. No wallet, no payment. ' +\n 'Not read-only: it POSTs a report that moves the marketplace reuse signal.',\n },\n {\n rule: 'Bash(tenjin doctor:*)',\n command: 'tenjin doctor',\n note:\n 'Local environment and API reachability diagnostics. Decrypts the wallet ' +\n 'locally to check it still opens; signs nothing and sends nothing.',\n },\n {\n rule: 'Bash(tenjin wallet show:*)',\n command: 'tenjin wallet show',\n note: 'Prints the wallet address and key source. Never prints the key.',\n },\n {\n rule: 'Bash(tenjin wallet balance:*)',\n command: 'tenjin wallet balance',\n note: 'Read-only USDC balance query on Base.',\n },\n {\n rule: 'Bash(tenjin config get:*)',\n command: 'tenjin config get',\n note:\n 'Reads one effective config value. `config set` is excluded on purpose. ' +\n 'Note `config get rpcUrl` returns your RPC URL, which commonly embeds a ' +\n 'provider API key: no wallet secret, but a credential-adjacent read.',\n },\n {\n rule: 'Bash(tenjin candidate list:*)',\n command: 'tenjin candidate list',\n note: 'Lists local parked drafts. Candidates are local files; nothing uploads.',\n },\n];\n\n/**\n * The verbs offered as EXPLICIT opt-in lines rather than shipped in the safe set:\n * the one that spends, and the one that opens the keystore.\n *\n * Read the buy note carefully before pasting the line: on the DEFAULT config this\n * rule authorizes unattended spending up to the wallet balance. Walking\n * evaluateSpendPolicy (lib/policy.ts) against CONFIG_DEFAULTS with an agent that\n * passes `--yes` (which this repo's own skill snippet offers):\n * - `maxPriceAtomic` is unset unless the agent chooses to pass `--max-price`;\n * - `allowlistCreators` is empty, so the creator gate is off;\n * - `sessionBudget` is '0', which `if (policy.sessionBudgetAtomic > 0n)` reads\n * as DISABLED, not as a zero ceiling;\n * - `maxAutoSpend` '0' and `confirm` 'always' both land on `confirm`, and\n * `confirmSpend` returns true on `--yes` before any TTY check.\n * Nothing denies. Note the asymmetry that makes the pair read safer than it is:\n * `maxAutoSpend: '0'` means \"auto-approve nothing\" while `sessionBudget: '0'`\n * means \"no ceiling at all\".\n */\nexport const OPT_IN_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin buy:*)',\n command: 'tenjin buy',\n note:\n 'SPENDS USDC on Base, unrefundably. This authorizes UNATTENDED purchases: ' +\n '`--yes` is an ordinary flag on the same allowlisted verb and it clears the ' +\n 'confirm gate, so on the default config nothing stops a spend up to your ' +\n 'wallet balance. Set a real ceiling first with ' +\n '`tenjin config set maxAutoSpend <usd>` and ' +\n '`tenjin config set sessionBudget <usd>` (sessionBudget 0 means NO ceiling, ' +\n 'not a zero one). This line never raises a spend cap by itself, but do not ' +\n 'read that as a human being on every purchase. Fund small.',\n },\n {\n rule: 'Bash(tenjin session start:*)',\n command: 'tenjin session start',\n note:\n 'OPENS THE KEYSTORE (one wallet signature), but SPENDS NOTHING and cannot: ' +\n 'it mints a ≤24h P-256 session key so `tenjin read` can recover pieces you ' +\n 'already own without paying. The delegated key is the wrong curve for a ' +\n 'payment authorization, so no session file can ever move money. Do NOT read ' +\n 'the `read` scope as a bound on the rest: the file it leaves is a ' +\n 'wallet-derived credential, and what limits it is that it expires in 24h, ' +\n 'lives 0600, and is refused off the origin it was minted for — not its ' +\n 'scope. What you are opting into is unattended keystore access: on an ' +\n 'encrypted wallet the passphrase prompt is skipped or answered from the ' +\n 'environment, and the `--base-url` caveat below bites hardest here, because ' +\n 'a mint against an attacker-chosen host is a wallet signature you did not ' +\n 'intend to make.',\n },\n];\n\n/**\n * Verbs that must NEVER appear in the recommended allowlist, with the reason each\n * one is a human decision. `tenjin send` is the wallet escape hatch (tenjin-agent\n * #40) and heads this list: it moves USDC to an arbitrary address, outside the\n * spend policy that bounds `buy`. Naming it here is load-bearing even in versions\n * where the verb does not exist yet — the exclusion ships before the verb does.\n */\nexport const NEVER_ALLOWLISTED: readonly ExcludedVerb[] = [\n {\n command: 'tenjin send',\n reason:\n 'Moves USDC out of the wallet to an arbitrary address (the escape hatch, #40). ' +\n 'Irreversible and not bounded by the buy spend policy. Always a human decision.',\n },\n {\n command: 'tenjin publish',\n reason: 'Puts your content on a public marketplace under your identity.',\n },\n {\n command: 'tenjin edit',\n reason:\n 'Write-capable despite the no-flag form reading as a pure show: it edits live posts ' +\n 'and answer cards under your identity, and moves prices. A prefix rule pins the verb, ' +\n 'not the flags, so no rule can clear the read half without clearing the write half.',\n },\n {\n command: 'tenjin wallet create',\n reason: 'Creates the payment credential; a stray run is a wallet you did not mean to have.',\n },\n {\n command: 'tenjin config set',\n reason:\n 'Can raise maxAutoSpend / sessionBudget / confirm, i.e. widen the agent’s own spend policy.',\n },\n {\n command: 'tenjin candidate add / tenjin candidate drop',\n reason: 'Writes or discards local drafts; `candidate list` is the read-only half.',\n },\n {\n command: 'tenjin install',\n reason: 'Writes into harness config and skills directories.',\n },\n {\n command: 'tenjin mcp',\n reason:\n 'Long-running server that re-exposes every command core over stdio; ' +\n 'clearing it would indirectly clear everything above.',\n },\n];\n\n/**\n * The flag-surface caveat. A prefix rule pins the verb, never the flags, and the\n * flag that matters is `--base-url`: it is accepted on every leaf, validated only\n * as a URL, and it wins settings precedence, so it moves the destination of every\n * allowlisted verb. Printed with the rules everywhere they are printed, because\n * an operator who only reads the verb list would never learn it.\n */\nexport const FLAG_CAVEAT: readonly string[] = [\n 'Caveat: a prefix rule pins the VERB, not the flags. Every line above also clears',\n '`--base-url <url>` on that verb, which re-points where the question, the probe, the',\n 'session key `read` may present, and (for buy) the signature and payment go. Signed',\n 'and credential-bearing traffic is NOT confined to the paying verb: `read` is in the',\n 'safe tier and still transmits a wallet-derived delegation once one is cached, which is',\n 'why that delegation is bound to the origin it was minted for and refused elsewhere.',\n 'Allowlist these verbs only if you are content for the agent to choose the destination',\n 'host, and set the base URL in config instead of letting it be an argument. The skills',\n 'tell agents never to pass --base-url on an allowlisted verb, but that is a convention,',\n 'not an enforced boundary.',\n];\n\n/**\n * The MCP caveat. `tenjin mcp` is never recommended as a Bash rule, but an\n * operator who registers the server anyway is on a different permission surface\n * (tools, not command strings) where three excluded verbs come back.\n */\nexport const MCP_CAVEAT: readonly string[] = [\n 'Running the local MCP server (`tenjin mcp`) instead? That is a different permission',\n 'surface: the harness gates TOOLS there, and these Bash rules do not apply. Leave',\n '`mcp__tenjin__tenjin_publish`, `mcp__tenjin__tenjin_edit`, and',\n '`mcp__tenjin__tenjin_wallet` gated, and treat `mcp__tenjin__tenjin_candidate` as gated',\n 'for its add/drop actions. `tenjin_buy` is the same opt-in decision as the buy line above.',\n];\n\n/** The machine shape emitted by `tenjin doctor --json` and `tenjin install --json`. */\nexport interface RecommendedPermissions {\n alwaysSafe: AllowlistEntry[];\n optIn: AllowlistEntry[];\n neverAllowlisted: ExcludedVerb[];\n /** Caveats that qualify the rules above; never omit them when rendering. */\n caveats: { flags: string[]; mcp: string[] };\n}\n\nexport function recommendedPermissions(): RecommendedPermissions {\n return {\n alwaysSafe: ALWAYS_SAFE_ALLOWLIST.map((e) => ({ ...e })),\n optIn: OPT_IN_ALLOWLIST.map((e) => ({ ...e })),\n neverAllowlisted: NEVER_ALLOWLISTED.map((e) => ({ ...e })),\n caveats: { flags: [...FLAG_CAVEAT], mcp: [...MCP_CAVEAT] },\n };\n}\n\n/** Every rule this module recommends adding (safe + opt-in). */\nexport function recommendedRules(): string[] {\n return [...ALWAYS_SAFE_ALLOWLIST, ...OPT_IN_ALLOWLIST].map((e) => e.rule);\n}\n\n/**\n * The permission caveats' one home. `doctor` used to print the whole thing —\n * nine rules, both opt-in notes, every exclusion, the flag caveat and the MCP\n * caveat, ~60 lines ahead of the check list it was actually run for. No doctor\n * command in the wider ecosystem carries security prose, and an operator reading\n * a wall of it in a terminal cannot paste from it, search it, or link a colleague\n * to a section. The page can do all three, so it is where the caveats live and\n * where every human surface points; `--json` still carries them as data\n * (`recommendedPermissions`), which is what an agent reads.\n */\nexport const PERMISSIONS_DOC_URL =\n 'https://github.com/BackTrackCo/tenjin-agent/blob/main/docs/agent-permissions.md';\n\n/**\n * The single line that replaced the block: what is on the page, and its URL. It\n * names the counts rather than the rules so the operator knows whether the page\n * answers their question before they open it.\n *\n * Subagent delegation is named here rather than on a second line, because doctor\n * deliberately closes with ONE pointer (#81) and the operator deciding what to\n * hand a subagent is reading exactly this line. The free tier IS the\n * subagent-safe set, so the counts already answer the question; which verbs stay\n * human-gated lives on the page with every other caveat.\n */\nexport function permissionsPointer(): string {\n return (\n `Auto-mode permission allowlist and subagent delegation (${ALWAYS_SAFE_ALLOWLIST.length} free verbs, ` +\n `${OPT_IN_ALLOWLIST.length} opt-ins, the --base-url caveat): ${PERMISSIONS_DOC_URL}`\n );\n}\n"],"mappings":";;;AA4GO,IAAM,wBAAmD;AAAA,EAC9D;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAGJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAWJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAEJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAEJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAGJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AACF;AAoBO,IAAM,mBAA8C;AAAA,EACzD;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAQJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAYJ;AACF;AASO,IAAM,oBAA6C;AAAA,EACxD;AAAA,IACE,SAAS;AAAA,IACT,QACE;AAAA,EAEJ;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,QACE;AAAA,EAGJ;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,QACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,QACE;AAAA,EAEJ;AACF;AASO,IAAM,cAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,IAAM,aAAgC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAWO,SAAS,yBAAiD;AAC/D,SAAO;AAAA,IACL,YAAY,sBAAsB,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAAA,IACvD,OAAO,iBAAiB,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAAA,IAC7C,kBAAkB,kBAAkB,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAAA,IACzD,SAAS,EAAE,OAAO,CAAC,GAAG,WAAW,GAAG,KAAK,CAAC,GAAG,UAAU,EAAE;AAAA,EAC3D;AACF;AAiBO,IAAM,sBACX;AAaK,SAAS,qBAA6B;AAC3C,SACE,2DAA2D,sBAAsB,MAAM,gBACpF,iBAAiB,MAAM,qCAAqC,mBAAmB;AAEtF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/doctor.ts"],"sourcesContent":["import { styleText } from 'node:util';\nimport { Stream } from 'node:stream';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { resolveSkillsSource } from '../lib/skills-source';\nimport { CliError } from '../lib/errors';\nimport {\n CLI_SKILL_NAMES,\n HOSTED_SKILL_NAME,\n anyTenjinSkill,\n cliSkillsWired,\n detectHarnesses,\n harnessFlagFor,\n harnessInPlay,\n harnessReads,\n harnessRequested,\n missingCliSkills,\n onPath,\n readAllWiring,\n readSkillFile,\n shadowedCliSkills,\n} from '../lib/skill-wiring';\nimport type {\n DirState,\n HarnessTarget,\n HarnessWiring,\n NotInvocableReason,\n} from '../lib/skill-wiring';\nimport { fetchJson } from '../lib/http';\nimport { loadRawConfig, resolveSettings } from '../lib/config';\nimport { tryOriginOf, trimSlash } from '../lib/url';\nimport { configPath, sessionPath } from '../lib/paths';\nimport { toMoney } from '../lib/money';\nimport { walletFileExists } from '../lib/wallet/store';\nimport { isSessionPresentable, readSessionFile } from '../lib/session-present';\nimport { sanitizeForTerminal } from '../lib/output';\nimport { permissionsPointer, recommendedPermissions } from '../lib/permissions';\nimport type { PartialConfig } from '../lib/config';\nimport type { ErrorCode } from '../schemas';\nimport type { Io } from '../lib/output';\nimport type {\n PassphraseOverrides,\n WalletDescription,\n WalletProvider,\n WalletVerification,\n} from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * One environment/reachability check. The doctor agent builds the check list\n * against this shape without changing it: `required` drives the exit code (exit\n * 0 iff every required check is ok), `status` drives the TTY rendering, and a\n * `fix` is mandatory on every failure (spec 10). Warn-level checks never fail\n * the command.\n */\nexport interface CheckResult {\n name: string;\n status: 'ok' | 'warn' | 'fail';\n required: boolean;\n detail: string;\n fix?: string;\n /**\n * Optional structured payload for machine consumers, so `--json` carries the\n * check's findings as data instead of only as the prose in `detail`. Additive\n * and per-check; the human renderer ignores it.\n */\n data?: unknown;\n}\n\n/** ~$20 in atomic USDC (6 decimals). Above this, the pocket-money wallet warns. */\nconst POCKET_MONEY_CEILING_ATOMIC = 20_000_000n;\n\n/**\n * `doctor` is an allowlisted verb an unattended agent runs on its own, and its\n * `fix:` lines reach that agent both on the TTY and in `error.details.checks`.\n * So they name the CONFIGURED base URL and the operator command that changes it,\n * never `--base-url`: the flag rides every allowlisted verb (see FLAG_CAVEAT in\n * lib/permissions), and a fix line telling the agent to pass it would be the CLI\n * coaching the exact move the skills forbid. `config set` is not allowlisted, so\n * pointing there routes the change through the operator by construction.\n */\nconst FIX_POINT_AT_TENJIN_API =\n 'Point the configured base URL at a Tenjin API (expected an OpenAPI document): `tenjin config set baseUrl <url>`.';\nconst FIX_CHECK_NETWORK_AND_BASE_URL =\n 'Check your network connection and the configured base URL (`tenjin config get baseUrl`).';\n\n/**\n * A CheckResult plus the error code to raise if it is a *required* failure. Only\n * required checks carry a `failCode`; the outcome step raises the first one, so\n * the failure envelope's `error.code` names what actually broke (api-contract\n * unreachable vs malformed differ) while still carrying the whole check list.\n */\ninterface BuiltCheck {\n result: CheckResult;\n failCode?: ErrorCode;\n}\n\nexport interface DoctorDeps {\n /** Environment for wallet-key detection and settings precedence. */\n env?: NodeJS.ProcessEnv;\n /** Injected fetch for the reachability checks; tests pass a canned stub. */\n fetchImpl?: typeof fetch;\n /** Inject the active wallet provider. When set, NO local fs/env is consulted —\n * the provider owns its own describe() and diagnostics(), so a remote provider's\n * checks can't be contaminated by a stale local wallet file. */\n provider?: WalletProvider;\n /** Home directory root for the skill-wiring check. Defaults to os.homedir(); tests\n * (and `install`, which reuses these checks) inject their own. */\n homeDir?: string;\n /** PATH probe for the `claude`/`codex` binaries, half of harness detection. Defaults\n * to probing `env.PATH`, so a test passing `env: {}` detects neither. */\n which?: (bin: string) => boolean;\n /** Clock seam (ms since epoch) for the session-expiry check. */\n now?: () => number;\n /** Packaged skills to compare the wired copies against; defaults to this build's. */\n skillsSourceDir?: string;\n /**\n * Passphrase seams for the wallet verification (#70), which reads the OS\n * credential store. Tests inject a platform with no store, or a stubbed exec,\n * so no assertion here depends on what is in the developer's real keychain.\n */\n walletPassphrase?: Omit<PassphraseOverrides, 'isTTY'>;\n}\n\n/**\n * The full check list plus the first required failure, if any. `install` reuses\n * this to run the doctor checks as its last step and EMBED the summary without\n * throwing (D39: doctor is diagnostics, it never blocks the caller); `runDoctor`\n * wraps it and turns a required failure into the thrown failure envelope.\n */\nexport interface DoctorChecks {\n checks: CheckResult[];\n failure?: { code: ErrorCode; result: CheckResult };\n}\n\nexport async function collectDoctorChecks(\n ctx: CommandContext,\n deps: DoctorDeps = {},\n): Promise<DoctorChecks> {\n const env = deps.env ?? process.env;\n const { config, check: configCheck } = await loadConfigForDoctor(ctx.dataDir);\n const settings = resolveSettings({ config, flags: { baseUrl: ctx.flags.baseUrl }, env });\n const baseUrl = settings.baseUrl.value;\n\n const built: BuiltCheck[] = [\n checkNode(),\n configCheck,\n await checkApiContract(baseUrl, ctx.flags.timeout, deps.fetchImpl),\n await checkReadPath(baseUrl, ctx.flags.timeout, deps.fetchImpl),\n await checkSearchContract(baseUrl, ctx.flags.timeout, deps.fetchImpl),\n await checkSkills(\n deps.homeDir ?? homedir(),\n deps.which ?? ((bin) => onPath(bin, env)),\n config.install?.harness ?? [],\n deps.skillsSourceDir,\n ),\n await checkSession(ctx.dataDir, deps.now ?? Date.now, tryOriginOf(baseUrl)),\n ];\n\n // The wallet/custody/balance checks all come from the ACTIVE provider: it owns\n // describe() and diagnostics(), so doctor never runs its own fs/env probe.\n for (const result of await checkWallet(ctx, deps, env, settings.rpcUrl.value)) {\n built.push({ result });\n }\n\n const checks = built.map((b) => b.result);\n const firstFail = built.find((b) => b.result.required && b.result.status === 'fail');\n if (firstFail === undefined) return { checks };\n return { checks, failure: { code: firstFail.failCode ?? 'INTERNAL', result: firstFail.result } };\n}\n\nexport async function runDoctor(\n ctx: CommandContext,\n deps: DoctorDeps = {},\n): Promise<CommandResult> {\n const { checks, failure } = await collectDoctorChecks(ctx, deps);\n if (failure !== undefined) {\n const r = failure.result;\n // The allowlist rides on the FAILURE envelope too. An operator whose fresh\n // install is broken is the likeliest one to be reading doctor output at all,\n // and the earlier version dropped the block on exactly that path while the\n // comment below claimed otherwise. The human failure path still renders only\n // the error and its fix (that is emitFailure's contract, not doctor's), so\n // the machine payload is where this has to land.\n throw new CliError(failure.code, r.detail, {\n ...(r.fix !== undefined ? { fix: r.fix } : {}),\n details: { checks, permissions: recommendedPermissions() },\n });\n }\n\n // The discoverability surface for the auto-mode denial problem (#33), now one\n // line rather than the ~60 that used to bury the check list this command was\n // run for: an operator whose agent just got denied still learns the allowlist\n // exists and where to get it. It reports nothing about the local machine, so it\n // is deliberately NOT a check: it can never pass or fail. `--json` is unchanged\n // and still carries the whole recommendation as data.\n return {\n data: { status: 'pass', checks, permissions: recommendedPermissions() },\n humanLines: [...renderDoctorHuman(ctx.io, checks), '', permissionsPointer()],\n };\n}\n\nfunction checkNode(): BuiltCheck {\n const version = process.versions.node;\n const major = Number.parseInt(version.split('.')[0] ?? '0', 10);\n if (major >= 22) {\n return { result: { name: 'node', status: 'ok', required: true, detail: `Node ${version}` } };\n }\n return {\n result: {\n name: 'node',\n status: 'fail',\n required: true,\n detail: `Node ${version} is unsupported (need >= 22)`,\n fix: 'Install Node 22 or newer',\n },\n failCode: 'NODE_UNSUPPORTED',\n };\n}\n\n/**\n * loadRawConfig throws CONFIG_INVALID on a bad file (which we convert into a\n * failing check) but the config value is also needed for baseUrl/rpcUrl\n * resolution; an invalid file falls back to {} so the reachability checks still\n * run and appear in the list, and config is reported as the first required fail.\n */\nasync function loadConfigForDoctor(\n dataDir: string,\n): Promise<{ config: PartialConfig; check: BuiltCheck }> {\n try {\n const config = await loadRawConfig(dataDir);\n const detail =\n Object.keys(config).length === 0\n ? 'No config file; using defaults'\n : `Config at ${configPath(dataDir)} is valid`;\n return { config, check: { result: { name: 'config', status: 'ok', required: true, detail } } };\n } catch (err) {\n if (err instanceof CliError && err.code === 'CONFIG_INVALID') {\n return {\n config: {},\n check: {\n result: {\n name: 'config',\n status: 'fail',\n required: true,\n detail: err.message,\n ...(err.fix !== undefined ? { fix: err.fix } : {}),\n },\n failCode: 'CONFIG_INVALID',\n },\n };\n }\n throw err;\n }\n}\n\nasync function checkApiContract(\n baseUrl: string,\n timeoutMs: number,\n fetchImpl?: typeof fetch,\n): Promise<BuiltCheck> {\n const url = `${trimSlash(baseUrl)}/openapi.json`;\n const res = await fetchJson(url, { timeoutMs, fetchImpl });\n if (!res.ok) {\n const malformed = res.kind === 'invalid-json';\n return {\n result: {\n name: 'api-contract',\n status: 'fail',\n required: true,\n detail: malformed\n ? `OpenAPI document at ${url} was not valid JSON`\n : `Could not reach the Tenjin API at ${url}: ${res.message}`,\n fix: malformed ? FIX_POINT_AT_TENJIN_API : FIX_CHECK_NETWORK_AND_BASE_URL,\n },\n failCode: malformed ? 'CONTRACT_MISMATCH' : 'API_UNREACHABLE',\n };\n }\n const version = infoVersion(res.json);\n if (version === undefined) {\n return {\n result: {\n name: 'api-contract',\n status: 'fail',\n required: true,\n detail: `OpenAPI document at ${url} is missing a string info.version`,\n fix: FIX_POINT_AT_TENJIN_API,\n },\n failCode: 'CONTRACT_MISMATCH',\n };\n }\n return {\n result: {\n name: 'api-contract',\n status: 'ok',\n required: true,\n detail: `Tenjin API ${version} at ${baseUrl}`,\n },\n };\n}\n\n/**\n * WARN-level (never fails doctor): is the A2 search endpoint advertised in the\n * OpenAPI doc? Absent means the deployment predates A2 (the buy/search path will\n * not work against it yet). Warn-only because doctor's job is a working READ path,\n * and search is additive.\n */\nasync function checkSearchContract(\n baseUrl: string,\n timeoutMs: number,\n fetchImpl?: typeof fetch,\n): Promise<BuiltCheck> {\n const url = `${trimSlash(baseUrl)}/openapi.json`;\n const res = await fetchJson(url, { timeoutMs, fetchImpl });\n if (!res.ok) {\n return {\n result: {\n name: 'search-contract',\n status: 'warn',\n required: false,\n detail: `Could not confirm the search endpoint at ${url}`,\n fix: 'Check the configured base URL (`tenjin config get baseUrl`); search/buy need the A2 endpoints deployed.',\n },\n };\n }\n const present = hasSearchPath(res.json);\n return {\n result: present\n ? {\n name: 'search-contract',\n status: 'ok',\n required: false,\n detail: 'Search endpoint advertised',\n }\n : {\n name: 'search-contract',\n status: 'warn',\n required: false,\n detail: 'This deployment does not advertise POST /api/agent/search (A2 not deployed)',\n fix: 'search/buy need A2 deployed; point the configured base URL at a deploy that has it (`tenjin config set baseUrl <url>`).',\n },\n };\n}\n\nfunction hasSearchPath(json: unknown): boolean {\n if (!isRecord(json)) return false;\n const paths = json.paths;\n return isRecord(paths) && '/api/agent/search' in paths;\n}\n\n/**\n * WARN-level (never fails doctor): is the harness skill wiring usable? #35 was\n * invisible without a screen recording, because the publish skill was on disk yet\n * the model never saw it and only the hosted skill answered publish asks.\n *\n * Verdicts are per DIRECTORY, never unioned across them — in EITHER direction.\n * Unioning the problems contradicts itself on a real machine: a Claude-only install\n * leaves a stray hosted skill in ~/.agents/skills, and flat-mapping announced both\n * CLI skills \"missing\" in the same sentence that listed them wired. Unioning the\n * successes is the same bug inverted, and worse: Claude Code reads ~/.claude/skills\n * and Codex reads ~/.agents/skills, so a wired .agents cannot answer for .claude,\n * and asking whether SOME directory is wired reported `ok` on a machine where\n * `tenjin-publish` was unreachable from Claude Code — exactly the #35 shape.\n *\n * So each directory is judged alone, and only when a harness on this machine\n * actually reads it (`harnessReads`, the probes `install` picks targets with). That\n * gate is what keeps a leftover mirror quiet: a hosted-only ~/.agents/skills with no\n * Codex is nobody's problem, while a hosted-only ~/.claude/skills with Claude Code\n * installed is the bug.\n *\n * Warn and never required: a CI or server machine legitimately has no harness, so\n * this must not move the exit code.\n */\n/**\n * `requested` is the `--harness` set a past `install` recorded (config `install.harness`).\n * It joins detection in deciding which directories are in play, and rides in the data as\n * its own field so `harnessPresent` keeps meaning \"a harness detected here reads this\".\n */\nasync function checkSkills(\n home: string,\n which: (bin: string) => boolean,\n requested: readonly HarnessTarget[],\n skillsSourceDir?: string,\n): Promise<BuiltCheck> {\n const present = detectHarnesses(home, which);\n const wiring = await readAllWiring(home);\n const data = {\n directories: wiring.map((w) => ({\n ...w,\n harnessPresent: harnessReads(home, w.dir, present),\n requested: harnessRequested(home, w.dir, requested),\n })),\n };\n const inPlay = wiring.filter((w) => anyTenjinSkill(w));\n\n if (inPlay.length === 0) {\n // Same fixFor path every other branch uses, over the same harnessInPlay\n // predicate (detected OR requested) — filtering on `requested` alone named\n // only the recorded directory and left a DETECTED one unwired, which just\n // swapped which directory the first command missed. Gated on\n // `requested.length > 0` so a machine with no record at all keeps the plain\n // `tenjin install` rather than newly spelling out a detected harness that\n // nobody asked to see named.\n const targeted =\n requested.length > 0\n ? wiring.filter((w) => harnessInPlay(home, w.dir, present, requested))\n : [];\n return {\n result: {\n name: 'skills',\n status: 'warn',\n required: false,\n detail: `No Tenjin skills wired under ${home} (looked in .claude/skills and .agents/skills)`,\n fix: targeted.length > 0 ? fixFor(home, targeted) : 'tenjin install',\n data,\n },\n };\n }\n\n // Every directory in play must carry BOTH CLI skills, model-invocable. Anything less\n // is the defect, whether it is shadowed, half-installed, hosted-only or absent; a\n // directory neither detected nor asked for is described but never warned about.\n const broken = wiring.filter(\n (w) => harnessInPlay(home, w.dir, present, requested) && !cliSkillsWired(w),\n );\n if (broken.length > 0) {\n return {\n result: {\n name: 'skills',\n status: 'warn',\n required: false,\n detail: `${broken.map(describeProblem).join('; ')}. Full state: ${describeWiring(inPlay)}`,\n fix: fixFor(home, broken),\n data,\n },\n };\n }\n\n // Wired is not the same as CURRENT. `npm i -g tenjin-cli` updates the binary and\n // nothing else, so the copies install wrote stay at whatever version wrote them\n // until someone re-runs install, and every check above passes the whole time.\n //\n // EVERY directory, not just the ones in play. The checks above ask what a\n // harness on this machine reads; this one has to cover what the self-heal\n // writes, which is any directory holding one of our adapters. A ~/.agents/skills\n // that fell out of play (a fallback install, then Claude Code arrives) is where\n // the heal keeps working and, when it cannot, keeps quiet: reporting a narrower\n // set than it writes would leave a stale directory nothing ever names.\n const { stale, verifiable } = await compareWiredSkills(\n wiring.map((w) => w.dir),\n skillsSourceDir,\n );\n if (!verifiable) {\n return {\n result: {\n name: 'skills',\n status: 'warn',\n required: false,\n detail: `${CLI_SKILL_NAMES.join(' + ')} wired, but this build's packaged copies could not be read, so whether they are current is unknown`,\n fix: 'Reinstall the CLI: `npm i -g tenjin-cli`, then `tenjin install`.',\n data,\n },\n };\n }\n if (stale.length > 0) {\n return {\n result: {\n name: 'skills',\n status: 'warn',\n required: false,\n detail: `${CLI_SKILL_NAMES.join(' + ')} wired but not from this CLI build (${stale.join(', ')}); agents are reading an older version's instructions`,\n // fixFor, like every neighbouring branch: a plain `tenjin install` targets\n // DETECTED harnesses only, so for a directory that exists because someone\n // passed --harness it would be a fix that never clears the warning.\n fix: fixFor(\n home,\n wiring.filter((w) => stale.includes(w.dir)),\n ),\n data,\n },\n };\n }\n\n return {\n result: {\n name: 'skills',\n status: 'ok',\n required: false,\n detail: `${CLI_SKILL_NAMES.join(' + ')} wired: ${describeWiring(inPlay)}`,\n data,\n },\n };\n}\n\n/**\n * How the wired CLI adapter skills compare to the packaged ones.\n *\n * `verifiable` is false when this build cannot read its own packaged copies, which\n * is a broken package rather than evidence of no drift; reporting that as current\n * would make the check quietly green on exactly the install doctor should describe.\n *\n * Only the ADAPTERS are compared: the hosted mirror is a copy of\n * tenjin.blog/skills.md that an operator may legitimately have re-fetched newer\n * than this package ships.\n *\n * This is also where a skill the post-command self-heal could NOT rewrite\n * surfaces. That writer stays silent about its failures on purpose: a cause it\n * cannot clear (an unwritable skills directory) would otherwise print the same\n * line on every command forever. Stale here means exactly that, and the fix names\n * the harness. For the handoff to hold, the CALLER has to pass every directory\n * the heal can reach, not only the ones a detected harness reads.\n */\nasync function compareWiredSkills(\n dirs: readonly string[],\n sourceDir?: string,\n): Promise<{ stale: string[]; verifiable: boolean }> {\n let source: string;\n try {\n source = sourceDir ?? resolveSkillsSource(fileURLToPath(new URL('.', import.meta.url)));\n } catch {\n return { stale: [], verifiable: false };\n }\n // Read once, not once per directory.\n const packaged = new Map<string, Buffer>();\n for (const name of CLI_SKILL_NAMES) {\n const read = await readSkillFile(join(source, name, 'SKILL.md'));\n if (read.kind === 'ok') packaged.set(name, read.bytes);\n }\n if (packaged.size !== CLI_SKILL_NAMES.length) return { stale: [], verifiable: false };\n\n const stale: string[] = [];\n for (const dir of dirs) {\n for (const name of CLI_SKILL_NAMES) {\n // Guarded: a pipe or device at this path would otherwise block the whole\n // diagnostic. Anything but a readable regular file is the wiring check's\n // business, not this one's.\n const onDisk = await readSkillFile(join(dir, name, 'SKILL.md'));\n if (onDisk.kind !== 'ok') continue;\n if (!packaged.get(name)!.equals(onDisk.bytes)) {\n stale.push(dir);\n break;\n }\n }\n }\n return { stale, verifiable: true };\n}\n\n/** What is wrong in ONE directory, naming the directory and the skills. */\nfunction describeProblem(w: HarnessWiring): string {\n const shadowed = shadowedCliSkills(w);\n const missing = missingCliSkills(w);\n const parts: string[] = [];\n // Grouped BY REASON, not into one clause: the two claims differ in strength. A\n // readable file with the flag set is a fact; an unreadable one is a disjunction,\n // because the whole reason we cannot assert the flag is that we could not read it.\n // Merging them would spread that hedge onto a skill we know the answer for.\n const unreadable = shadowed.filter((n) => reasonFor(w, n) === 'unreadable');\n const disabled = shadowed.filter((n) => reasonFor(w, n) !== 'unreadable');\n if (disabled.length > 0) {\n parts.push(\n `${disabled.join(', ')} installed but not model-invocable (disable-model-invocation: true)`,\n );\n }\n if (unreadable.length > 0) {\n parts.push(\n `${unreadable.join(', ')} installed but not model-invocable (unreadable or disable-model-invocation: true)`,\n );\n }\n // Naming both by name reads as a half-install; when NEITHER is there the state is\n // \"this harness has no CLI skills at all\", which is a different sentence.\n if (missing.length === CLI_SKILL_NAMES.length) {\n parts.push(\n w.state === 'hosted-only'\n ? `the hosted ${HOSTED_SKILL_NAME} skill is here but neither CLI skill is wired`\n : 'neither CLI skill is wired',\n );\n } else if (missing.length > 0) parts.push(`${missing.join(', ')} missing`);\n return `${w.dir}: ${parts.join(' and ')}`;\n}\n\nfunction reasonFor(w: HarnessWiring, name: string): NotInvocableReason | undefined {\n return w.skills.find((s) => s.name === name)?.reason;\n}\n\n/** Is the hosted zero-install mirror in THIS directory? */\nfunction hostedHere(w: HarnessWiring): boolean {\n return w.skills.find((s) => s.name === HOSTED_SKILL_NAME)?.present === true;\n}\n\n/**\n * A fix that can actually clear the warning. A bare `tenjin install` only targets\n * the directories detection picks, so a problem in ~/.agents/skills on a\n * Claude-only machine needs `--harness shared` spelled out.\n */\nfunction fixFor(home: string, dirs: HarnessWiring[]): string {\n const flags = [...new Set(dirs.map((w) => harnessFlagFor(home, w.dir)))];\n return `tenjin install ${flags.map((f) => `--harness ${f}`).join(' ')}`;\n}\n\n/** One-line per-directory summary: `<dir> -> <skills> (<posture>)`. */\nfunction describeWiring(wiring: HarnessWiring[]): string {\n return wiring\n .map((w) => {\n const parts = w.skills\n .filter((s) => s.present)\n .map((s) =>\n s.modelInvocable === false ? `${s.name} [${s.reason ?? 'shadowed'}]` : s.name,\n );\n return `${w.dir} -> ${parts.join(', ')} (${posture(w)})`;\n })\n .join('; ');\n}\n\n/**\n * The precedence half of the `wired` posture is only true when there is a mirror\n * here to take precedence OVER. `classify` keys `wired` off the two CLI skills\n * alone, so a directory whose mirror was deleted is `wired` with no `tenjin` in it,\n * and the unconditional string claimed a file the same line had just not listed.\n */\nfunction posture(w: HarnessWiring): string {\n if (w.state !== 'wired') return POSTURE[w.state];\n return hostedHere(w)\n ? 'CLI skills wired, take precedence over the hosted mirror'\n : 'CLI skills wired';\n}\n\nconst POSTURE: Record<DirState, string> = {\n empty: 'no Tenjin skills',\n 'hosted-only': 'hosted skill only, no CLI skills here',\n partial: 'only one CLI skill',\n // \"at least one\": a directory with one CLI skill shadowed and the other absent\n // classifies as `shadowed` too, and \"CLI skills present\" would be false there.\n shadowed: 'at least one CLI skill present but not model-invocable',\n wired: 'CLI skills wired, take precedence over the hosted mirror',\n};\n\n/**\n * The delegated session key `tenjin read` presents to recover a piece this wallet\n * already owns (`tenjin session start --scope read` mints it). Never required and\n * never a fail — `read` works without one — so ABSENT is `ok`: the normal\n * posture, not a defect.\n *\n * Everything else warns, and the states are kept apart on purpose. A 0600 file\n * that is now group-readable, or one whose contents no longer parse, is a TAMPER\n * signal on a wallet-derived credential; `loadSessionFile` fails closed on both\n * and collapses them to \"no session\", which is the right instruction for a caller\n * that can re-mint and exactly the wrong report for the verb an operator runs\n * when something looks wrong. `readSessionFile` keeps them distinguishable and\n * this is the one caller that needs them.\n *\n * An unreadable file (EACCES after a `sudo` run, EIO) warns rather than throwing:\n * doctor is diagnostics, and a session cache nobody asked about must never take\n * down the run that was going to explain the rest of the machine.\n *\n * Reports address / origin / scope / expiry and nothing else. The delegation and\n * the private JWK never reach this output — doctor's payload is the single most\n * likely thing in this CLI to be pasted into an issue.\n */\nasync function checkSession(\n dataDir: string,\n now: () => number,\n origin: string | null,\n): Promise<BuiltCheck> {\n const warn = (detail: string, data?: unknown): BuiltCheck => ({\n result: {\n name: 'session',\n status: 'warn',\n required: false,\n detail,\n fix: 'tenjin session start --scope read',\n ...(data !== undefined ? { data } : {}),\n },\n });\n\n const state = await readSessionFile(dataDir);\n if (state.kind === 'absent') {\n return {\n result: {\n name: 'session',\n status: 'ok',\n required: false,\n detail:\n 'No session key; `tenjin read` delivers free and locally-cached pieces (`tenjin session start --scope read` adds owned-piece recovery)',\n },\n };\n }\n if (state.kind === 'loosened') {\n return warn(\n `Session key at ${sessionPath(dataDir)} is mode 0${state.mode.toString(8)}, not 0600, so it is refused; it holds a wallet-derived credential and was changed out of band. Delete it and re-mint`,\n );\n }\n // Same standing as `absent`: a cache this CLI cannot use, re-minted by one\n // command. A failing check here meant a permanent post-update warning.\n if (state.kind === 'outdated') {\n return {\n result: {\n name: 'session',\n status: 'ok',\n required: false,\n detail: `Cached session key at ${sessionPath(dataDir)} predates this CLI version (no \\`${state.field}\\`) and is not used; \\`tenjin session start --scope read\\` mints a current one`,\n },\n };\n }\n if (state.kind === 'corrupt') {\n return warn(`Session key at ${sessionPath(dataDir)} could not be parsed (${state.reason})`);\n }\n if (state.kind === 'unreadable') {\n return warn(`Session key at ${sessionPath(dataDir)} could not be read: ${state.message}`);\n }\n\n const file = state.file;\n // A base URL that is not an http(s) origin cannot be compared against, and this\n // is the diagnostic verb: it reports that and keeps going. The `config` check\n // above owns the fix for the value itself.\n if (origin === null) {\n return {\n result: {\n name: 'session',\n status: 'warn',\n required: false,\n detail: `Session key was minted for ${file.origin}, but the configured base URL is not an http(s) origin, so it cannot be matched`,\n fix: 'Set an absolute http(s) base URL: `tenjin config set baseUrl <url>`.',\n data: { address: file.address, origin: file.origin, scope: file.scope, exp: file.exp },\n },\n };\n }\n const data = { address: file.address, origin: file.origin, scope: file.scope, exp: file.exp };\n if (file.origin !== origin) {\n return warn(\n `Session key was minted for ${file.origin}, but the configured base URL is ${origin}; it is not presented off its own origin`,\n data,\n );\n }\n if (!isSessionPresentable(file, now(), 'read', origin)) {\n return warn(\n `Session key for ${file.address} is expired or out of scope (scope ${file.scope}, exp ${file.exp})`,\n data,\n );\n }\n return {\n result: {\n name: 'session',\n status: 'ok',\n required: false,\n detail: `Session key ${file.address}, scope ${file.scope}, for ${file.origin}, expires ${file.exp}`,\n data,\n },\n };\n}\n\nasync function checkReadPath(\n baseUrl: string,\n timeoutMs: number,\n fetchImpl?: typeof fetch,\n): Promise<BuiltCheck> {\n // The shipped public read path. The A2 search-contract check is a B2 follow-up.\n // Probe the UNFILTERED listing: the server logs every nonblank first-page `q`\n // as agent search demand, so a `q` here would fabricate that demand into the\n // experiment this CLI exists to measure. Never add a `q` to this probe.\n const url = `${trimSlash(baseUrl)}/api/articles?limit=1`;\n const res = await fetchJson(url, { timeoutMs, fetchImpl });\n if (!res.ok) {\n return {\n result: {\n name: 'read-path',\n status: 'fail',\n required: true,\n detail: `Read path ${url} failed: ${res.message}`,\n fix: FIX_CHECK_NETWORK_AND_BASE_URL,\n },\n failCode: 'API_UNREACHABLE',\n };\n }\n const items = isRecord(res.json) ? res.json.items : undefined;\n if (!Array.isArray(items)) {\n return {\n result: {\n name: 'read-path',\n status: 'fail',\n required: true,\n detail: `Read path ${url} did not return an items array`,\n fix: 'Point the configured base URL at a Tenjin API: `tenjin config set baseUrl <url>`.',\n },\n failCode: 'API_UNREACHABLE',\n };\n }\n return {\n result: { name: 'read-path', status: 'ok', required: true, detail: `Read path OK at ${url}` },\n };\n}\n\n/**\n * Diagnose the wallet the CLI would actually use, entirely through the ACTIVE\n * provider. An injected provider owns everything — no local file or env is touched.\n * With no injected provider we do ONE cheap fs/env probe purely to decide whether\n * any credential exists: none → emit the \"no wallet\" warn WITHOUT importing the\n * wallet lib (that import statically pulls viem, and a no-wallet run must not parse\n * it). Otherwise the provider describes itself (address + source), PROVES the\n * credential can sign when it can do so without prompting (#70), reports its own\n * custody warnings, and the balance probes describe()'s address. A custody problem\n * (bad key, provider refusal) is warn-level, never a hard fail.\n */\nasync function checkWallet(\n ctx: CommandContext,\n deps: DoctorDeps,\n env: NodeJS.ProcessEnv,\n rpcUrl: string,\n): Promise<CheckResult[]> {\n const provider = deps.provider ?? (await resolveLocalProviderOrNull(ctx, env, deps));\n if (provider === null) return [noWalletCheck()];\n\n const { describeWallet } = await import('../lib/wallet');\n let desc: WalletDescription;\n try {\n desc = await describeWallet(provider);\n } catch (err) {\n if (err instanceof CliError && err.code === 'WALLET_MISSING') return [noWalletCheck()];\n return [walletWarn(err)];\n }\n\n const checks: CheckResult[] = [walletCheck(desc, await verifyWallet(provider))];\n // Custody warnings are the provider's own (perms, env-shadow for the local\n // provider; none for a remote one). Render each as a warn check; the fix text,\n // when there is one, is carried inline in the warning string.\n for (const warning of (await provider.diagnostics()).warnings) {\n checks.push({ name: 'wallet-custody', status: 'warn', required: false, detail: warning });\n }\n checks.push(await checkBalance(desc.address, rpcUrl));\n return checks;\n}\n\n/**\n * The active local provider, or null when no credential exists at all. The null\n * path never imports the wallet lib, keeping a no-wallet doctor run off viem.\n */\nasync function resolveLocalProviderOrNull(\n ctx: CommandContext,\n env: NodeJS.ProcessEnv,\n deps: DoctorDeps,\n): Promise<WalletProvider | null> {\n const envKey = env.TENJIN_WALLET_KEY;\n const envKeySet = typeof envKey === 'string' && envKey.length > 0;\n if (!envKeySet && !(await walletFileExists(ctx.dataDir))) return null;\n const { resolveWalletProvider } = await import('../lib/wallet');\n return resolveWalletProvider(ctx, {\n ...(deps.walletPassphrase !== undefined ? { passphrase: deps.walletPassphrase } : {}),\n });\n}\n\n/**\n * Ask the provider to prove the credential can sign (#70). A provider without a\n * `verify` is not a failure and not a pass: it is the `unverified` state, same as\n * a keystore whose passphrase only a human could supply. A provider that throws\n * is treated the same way — doctor reports what it could not establish and keeps\n * going; it never turns a diagnostic's own failure into a verdict about the\n * wallet.\n */\nasync function verifyWallet(provider: WalletProvider): Promise<WalletVerification> {\n if (provider.verify === undefined) {\n return {\n status: 'unverified',\n detail: `provider \"${provider.id}\" cannot verify without a key`,\n };\n }\n try {\n return await provider.verify();\n } catch (err) {\n return {\n status: 'unverified',\n detail: `verification could not run (${err instanceof Error ? err.message : String(err)})`,\n };\n }\n}\n\n/**\n * The wallet check, with the verification folded INTO its status rather than\n * reported beside it. #70 was exactly a green `wallet` line above an unopenable\n * keystore, so an `ok` here has to mean the key is usable, not merely that a file\n * parsed. Still never `required` and never a `fail`: a wallet nobody can open is\n * a real problem, but `read` and `search` work without one, so it must not move\n * the exit code.\n */\nfunction walletCheck(desc: WalletDescription, v: WalletVerification): CheckResult {\n const head = `Wallet ${desc.address} (${desc.credentialSource})`;\n if (v.status === 'broken') {\n return {\n name: 'wallet',\n status: 'warn',\n required: false,\n detail: `${head}: ${v.detail}`,\n fix: v.fix,\n };\n }\n if (v.status === 'unverified') {\n return {\n name: 'wallet',\n status: 'warn',\n required: false,\n detail: `${head} present, not verified: ${v.detail}`,\n fix: 'Set TENJIN_WALLET_PASSPHRASE, or store the passphrase in your OS credential store, so doctor can prove the keystore still opens.',\n };\n }\n return { name: 'wallet', status: 'ok', required: false, detail: `${head}, ${v.detail}` };\n}\n\nfunction noWalletCheck(): CheckResult {\n return {\n name: 'wallet',\n status: 'warn',\n required: false,\n detail: 'No wallet; needed only for buy/publish',\n fix: 'tenjin wallet create',\n data: { credential: 'absent' },\n };\n}\n\n/**\n * Is this the check that says there is no credential at all? `install` prints its\n * own line for that state and drops the duplicate, so it has to recognise THIS\n * check and not merely one named `wallet`: a warn about a credential that exists\n * and does not work (an unopenable keystore, an invalid TENJIN_WALLET_KEY) shares\n * the name and is the one wallet state nothing else in install's output carries.\n */\nexport function isNoWalletCheck(c: CheckResult): boolean {\n return c.name === 'wallet' && isRecord(c.data) && c.data.credential === 'absent';\n}\n\nfunction walletWarn(err: unknown): CheckResult {\n return {\n name: 'wallet',\n status: 'warn',\n required: false,\n detail: err instanceof Error ? err.message : String(err),\n ...(err instanceof CliError && err.fix !== undefined ? { fix: err.fix } : {}),\n };\n}\n\n/**\n * Balance is best-effort: a zero balance is a fundable warning and an RPC flake\n * must never fail doctor. viem loads only here, via a lazy import, so a doctor\n * run without a wallet never parses the viem chunk.\n */\nasync function checkBalance(address: string, rpcUrl: string): Promise<CheckResult> {\n try {\n const { getUsdcBalance } = await import('../lib/usdc');\n const balance = await getUsdcBalance(address as `0x${string}`, rpcUrl);\n if (balance === 0n) {\n return {\n name: 'balance',\n status: 'warn',\n required: false,\n detail: 'Wallet USDC balance is 0',\n fix: 'Send USDC on Base. $5 covers ~50 typical resources.',\n };\n }\n const money = toMoney(balance.toString());\n // Pocket-money posture (roadmap B2): a plaintext-adjacent local key should\n // hold only small change, so a balance over ~$20 is a warn, not an error.\n if (balance > POCKET_MONEY_CEILING_ATOMIC) {\n return {\n name: 'balance',\n status: 'warn',\n required: false,\n detail: `Balance ${money.usd} USDC is above the ~$20 pocket-money ceiling`,\n fix: 'Keep only small change in the CLI wallet; sweep the excess to cold storage.',\n };\n }\n return {\n name: 'balance',\n status: 'ok',\n required: false,\n detail: `Balance ${money.usd} USDC (${money.atomic} atomic)`,\n };\n } catch (err) {\n return {\n name: 'balance',\n status: 'warn',\n required: false,\n detail: `Could not read balance: ${err instanceof Error ? err.message : String(err)}`,\n fix: 'Check rpcUrl or retry; a balance read failure never fails doctor.',\n };\n }\n}\n\nexport function renderDoctorHuman(io: Io, checks: CheckResult[]): string[] {\n const nameWidth = Math.max(...checks.map((c) => c.name.length));\n const lines: string[] = [];\n for (const c of checks) {\n const icon =\n c.status === 'ok'\n ? paint(io, 'green', '✓')\n : c.status === 'warn'\n ? paint(io, 'yellow', '!')\n : paint(io, 'red', '✗');\n // `detail` and `fix` interpolate SERVER-sourced strings (the OpenAPI\n // info.version, a provider's error text), so a newline or ANSI in a hostile\n // deployment's version string could forge extra lines here — including a\n // convincing closing pointer at a URL of its choosing. Sanitize at the render\n // seam: output.ts exempts doctor on the assumption it only paints its OWN\n // text, which has not been true since these lines began carrying server text.\n lines.push(\n `${icon} ${c.name.padEnd(nameWidth)} ${paint(io, 'dim', sanitizeForTerminal(c.detail))}`,\n );\n if (c.status !== 'ok' && c.fix !== undefined) {\n lines.push(` ${paint(io, 'dim', `fix: ${sanitizeForTerminal(c.fix)}`)}`);\n }\n }\n return lines;\n}\n\n/**\n * Color for stderr, honoring NO_COLOR and the target's color depth: styleText\n * takes the stderr stream when it is a genuine Stream (it throws on anything\n * else, so a test/redirected sink falls back to the default plain check).\n */\nfunction paint(io: Io, format: Parameters<typeof styleText>[0], text: string): string {\n if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });\n return styleText(format, text);\n}\n\nfunction infoVersion(json: unknown): string | undefined {\n if (!isRecord(json)) return undefined;\n const info = json.info;\n if (!isRecord(info)) return undefined;\n return typeof info.version === 'string' ? info.version : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAmE9B,IAAM,8BAA8B;AAWpC,IAAM,0BACJ;AACF,IAAM,iCACJ;AAmDF,eAAsB,oBACpB,KACA,OAA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