@modootoday/pmcp 0.17.4 → 0.18.0

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 (246) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/CHANGELOG.md +60 -0
  5. package/README.md +29 -24
  6. package/dist/apply-4IGTXOCQ.js +242 -0
  7. package/dist/{attachment-tU5FZrgZ.d.ts → attachment-D84OGI6n.d.ts} +1 -1
  8. package/dist/available-DBSIVVJ6.js +73 -0
  9. package/dist/broadcast-3RY3OZGY.js +18 -0
  10. package/dist/chunk-25GHX674.js +1246 -0
  11. package/dist/chunk-2P4Z2NUX.js +28 -0
  12. package/dist/chunk-34DECPVC.js +22 -0
  13. package/dist/chunk-3NYG4SGU.js +45 -0
  14. package/dist/chunk-3PW4FI7U.js +32 -0
  15. package/dist/chunk-3Y3HDMHA.js +108 -0
  16. package/dist/chunk-47O3X4VS.js +113 -0
  17. package/dist/chunk-4NDEP7HU.js +26 -0
  18. package/dist/chunk-4VCC2NXE.js +104 -0
  19. package/dist/chunk-5OMOPUE6.js +39 -0
  20. package/dist/chunk-5QQWS4US.js +53 -0
  21. package/dist/chunk-5ZABTVSW.js +48 -0
  22. package/dist/chunk-65ZHM5RH.js +4985 -0
  23. package/dist/chunk-665TA55Z.js +419 -0
  24. package/dist/chunk-6STKGOCW.js +27 -0
  25. package/dist/chunk-6WXMJOMI.js +9 -0
  26. package/dist/chunk-73AKO4UL.js +24 -0
  27. package/dist/chunk-7BLPN3W6.js +31 -0
  28. package/dist/chunk-7DLZC73N.js +29 -0
  29. package/dist/chunk-7GBYECSK.js +72 -0
  30. package/dist/chunk-7TD53M7L.js +13 -0
  31. package/dist/chunk-A4PKLESO.js +112 -0
  32. package/dist/chunk-ABTJQ4QV.js +74 -0
  33. package/dist/chunk-BBTBJCFA.js +380 -0
  34. package/dist/chunk-BU65MNVU.js +13 -0
  35. package/dist/chunk-BVCTKPT3.js +83 -0
  36. package/dist/chunk-C4NHQGHL.js +142 -0
  37. package/dist/chunk-CJTKR6K6.js +1213 -0
  38. package/dist/chunk-DCU2EXQV.js +78 -0
  39. package/dist/chunk-DZ2MRTYT.js +135 -0
  40. package/dist/chunk-E2YOZ2FF.js +207 -0
  41. package/dist/chunk-E3DQB5LS.js +48 -0
  42. package/dist/chunk-E7OOHLQR.js +7 -0
  43. package/dist/chunk-EATCUWGG.js +66 -0
  44. package/dist/chunk-EIDIVIAD.js +33 -0
  45. package/dist/chunk-EJBZGIDK.js +1934 -0
  46. package/dist/chunk-ELAGZ635.js +252 -0
  47. package/dist/chunk-GZHHEHKY.js +44 -0
  48. package/dist/chunk-HDMBVLCZ.js +53 -0
  49. package/dist/chunk-HQOB7OQS.js +81 -0
  50. package/dist/chunk-IGYRMM62.js +28 -0
  51. package/dist/chunk-IJBSOWHK.js +86 -0
  52. package/dist/chunk-INT7QLEU.js +114 -0
  53. package/dist/chunk-J6QLLQVL.js +1025 -0
  54. package/dist/chunk-J7UYNJCR.js +9 -0
  55. package/dist/chunk-JEL35P7S.js +53 -0
  56. package/dist/chunk-JGJ4INEN.js +32 -0
  57. package/dist/chunk-JS5RTH4I.js +84 -0
  58. package/dist/chunk-JUXNIXN4.js +42 -0
  59. package/dist/chunk-JWRZDYB5.js +59 -0
  60. package/dist/chunk-KMXRRSKT.js +660 -0
  61. package/dist/chunk-LAZQBMAU.js +67 -0
  62. package/dist/chunk-LLBPVZXM.js +67 -0
  63. package/dist/chunk-LLT5FQBE.js +57 -0
  64. package/dist/chunk-LMT3PPXJ.js +17 -0
  65. package/dist/chunk-MM2Y43LC.js +87 -0
  66. package/dist/chunk-MPSQXSC6.js +346 -0
  67. package/dist/chunk-MVFH26QT.js +97 -0
  68. package/dist/chunk-MWFOUBFC.js +39 -0
  69. package/dist/chunk-N5AQ3PP7.js +211 -0
  70. package/dist/chunk-NQPURJT5.js +44 -0
  71. package/dist/chunk-NRBQK6UX.js +105 -0
  72. package/dist/chunk-NZS5CD72.js +333 -0
  73. package/dist/chunk-OEH47H6A.js +48 -0
  74. package/dist/chunk-OG7QR2DP.js +75 -0
  75. package/dist/chunk-OPYFEHKG.js +52 -0
  76. package/dist/chunk-P4N7DBD5.js +83 -0
  77. package/dist/chunk-PAX3QXX2.js +140 -0
  78. package/dist/chunk-PLX3BOOS.js +396 -0
  79. package/dist/chunk-PMJG2CXF.js +122 -0
  80. package/dist/chunk-PWSJJXLQ.js +643 -0
  81. package/dist/chunk-Q5H3L6Y4.js +23 -0
  82. package/dist/chunk-Q65R3XKX.js +155 -0
  83. package/dist/chunk-QEW4J3IZ.js +74 -0
  84. package/dist/chunk-QPL7E2HW.js +464 -0
  85. package/dist/chunk-R2GPCZUX.js +22 -0
  86. package/dist/chunk-R4L6LJJ2.js +778 -0
  87. package/dist/chunk-R5MT42JS.js +284 -0
  88. package/dist/chunk-RK4PYD7L.js +73 -0
  89. package/dist/chunk-RMATE45Z.js +197 -0
  90. package/dist/chunk-S3PIAMXV.js +230 -0
  91. package/dist/chunk-SG5TPMKH.js +93 -0
  92. package/dist/chunk-T3LKX23M.js +168 -0
  93. package/dist/chunk-T6GOWHK6.js +30 -0
  94. package/dist/chunk-TIA4SPU2.js +10 -0
  95. package/dist/chunk-TNCZ6444.js +57 -0
  96. package/dist/chunk-TVL5RTE6.js +269 -0
  97. package/dist/chunk-UOCLRM7P.js +151 -0
  98. package/dist/chunk-UPQTAHUK.js +189 -0
  99. package/dist/chunk-V4NPDK6X.js +14 -0
  100. package/dist/chunk-VJFEN6DJ.js +38 -0
  101. package/dist/chunk-WIW772I3.js +25 -0
  102. package/dist/chunk-XELAZAIM.js +136 -0
  103. package/dist/chunk-XNML2KIC.js +23 -0
  104. package/dist/chunk-XP2U3LO3.js +30 -0
  105. package/dist/chunk-YGOWIJPE.js +51 -0
  106. package/dist/chunk-YIXDHQYE.js +11 -0
  107. package/dist/chunk-YMHUM7AV.js +22 -0
  108. package/dist/chunk-YSAWTGNA.js +117 -0
  109. package/dist/chunk-Z4HRRXRF.js +478 -0
  110. package/dist/chunk-ZH6R642Z.js +102 -0
  111. package/dist/claude-U2JC2DNQ.js +77 -0
  112. package/dist/cli-VYCQJZ5X.js +41 -0
  113. package/dist/cli-ZTCBSDW4.js +46 -0
  114. package/dist/cli.js +144 -16197
  115. package/dist/completion-E7RRG3ZT.js +142 -0
  116. package/dist/config-DnpLL2kT.d.ts +46 -0
  117. package/dist/{service-qpCsOXkQ.d.ts → core-C1LPjxK6.d.ts} +2 -6
  118. package/dist/diagnostics-XXH4FLUG.js +93 -0
  119. package/dist/doctor-ZIOESU3N.js +538 -0
  120. package/dist/entry-ZNFCTDVE.js +305 -0
  121. package/dist/exec-mcp-X6372BLE.js +365 -0
  122. package/dist/harness-F2XFDYXF.js +177 -0
  123. package/dist/harness-egress-bridge.js +4 -4
  124. package/dist/harness-launch-gate.js +47 -940
  125. package/dist/harness-pane-runner.js +13 -80
  126. package/dist/harness-worker.js +21 -2703
  127. package/dist/hook-body.js +5221 -0
  128. package/dist/hook-spec-C5fWTSCH.d.ts +100 -0
  129. package/dist/hook.js +26 -0
  130. package/dist/hooks-FYE2L5RW.js +21 -0
  131. package/dist/host-GRY3VAHH.js +22 -0
  132. package/dist/host-X6BR6X4O.js +200 -0
  133. package/dist/host-run-GCA6H6SR.js +307 -0
  134. package/dist/http.d.ts +5 -42
  135. package/dist/http.js +21 -2234
  136. package/dist/import-mcp-2TTBPVLY.js +400 -0
  137. package/dist/index.d.ts +146 -168
  138. package/dist/index.js +133 -4948
  139. package/dist/init-627KFXTG.js +14 -0
  140. package/dist/install-GG7HHZK2.js +796 -0
  141. package/dist/invoke-LW22Z6ET.js +23 -0
  142. package/dist/list-MCP2FXUF.js +68 -0
  143. package/dist/list-NGMSQ5SH.js +65 -0
  144. package/dist/load-BEUBABtB.d.ts +21 -0
  145. package/dist/logout-6CSHUWWE.js +44 -0
  146. package/dist/logs-SPB6AANY.js +107 -0
  147. package/dist/mailbox/index.d.ts +10 -5
  148. package/dist/mailbox/index.js +53 -1572
  149. package/dist/mailbox-7BV54Q4R.js +285 -0
  150. package/dist/mailbox-GDJ7BWQN.js +189 -0
  151. package/dist/mainline-JQTTYJMI.js +639 -0
  152. package/dist/marketplace-G4VQET5W.js +191 -0
  153. package/dist/mcp-2DKVU3SW.js +15 -0
  154. package/dist/mcp-V23HC3LB.js +193 -0
  155. package/dist/models-ISU4DCMA.js +32 -0
  156. package/dist/opencode-CN7JLQYO.js +60 -0
  157. package/dist/pause-FFAYRBWI.js +18 -0
  158. package/dist/preview-DT7DWG5F.js +91 -0
  159. package/dist/project/hook-adapter.d.ts +5 -2
  160. package/dist/project/hook-adapter.js +41 -27
  161. package/dist/project-FY62G55N.js +70 -0
  162. package/dist/pty-XTJ4MIWK.js +94 -0
  163. package/dist/recovery-U6QB3PMT.js +100 -0
  164. package/dist/reindex-Y27QJFDB.js +22 -0
  165. package/dist/resume-UU4HZIUP.js +18 -0
  166. package/dist/run-HALGEJNJ.js +19 -0
  167. package/dist/run-OGA3P7FC.js +126 -0
  168. package/dist/serve-NBKT5BKY.js +104 -0
  169. package/dist/session-XM2CR425.js +159 -0
  170. package/dist/setup-DTKZLZUT.js +18 -0
  171. package/dist/start-login-UIQYQBMC.js +416 -0
  172. package/dist/status-A2OUTNGK.js +9 -0
  173. package/dist/status-H2VAHIDV.js +10 -0
  174. package/dist/status-NOOHW5WA.js +43 -0
  175. package/dist/status-VHODZPXB.js +55 -0
  176. package/dist/status-XQANBVXW.js +286 -0
  177. package/dist/stdio.d.ts +3 -13
  178. package/dist/stdio.js +16 -3186
  179. package/dist/sweep-64JDCGK6.js +18 -0
  180. package/dist/test-MKAXFJOL.js +561 -0
  181. package/dist/tools-gpHNq9Dh.d.ts +328 -0
  182. package/dist/tui-MWKAXE4K.js +153 -0
  183. package/dist/unbroadcast-KPUEFLZD.js +18 -0
  184. package/dist/validate-5GZ5YWNA.js +46 -0
  185. package/dist/worker-RQ575EJL.js +80 -0
  186. package/dist/worktree-create-PZSRB7PH.js +89 -0
  187. package/dist/worktree-list-JYB6VXLW.js +51 -0
  188. package/dist/worktree-sync-UF5CXPWV.js +30 -0
  189. package/docs/hooks/capabilities/antigravity.json +199 -0
  190. package/docs/hooks/capabilities/claude.json +179 -0
  191. package/docs/hooks/capabilities/codex.json +179 -0
  192. package/docs/hooks/capabilities/gemini.json +196 -0
  193. package/docs/hooks/capabilities/grok.json +192 -0
  194. package/docs/hooks/capabilities/opencode.json +184 -0
  195. package/docs/project-configuration.md +821 -4
  196. package/docs/terminal-harness.md +71 -28
  197. package/docs/terminal-workspace.md +91 -170
  198. package/gemini-extension.json +1 -1
  199. package/package.json +13 -1
  200. package/plugin.json +1 -1
  201. package/plugins/pmcp/.claude-plugin/plugin.json +4 -2
  202. package/plugins/pmcp/gemini-extension.json +1 -1
  203. package/plugins/pmcp/mod/commands.ts +72 -0
  204. package/plugins/pmcp/mod/contract.d.ts +39 -0
  205. package/plugins/pmcp/mod/draw.tsx +216 -0
  206. package/plugins/pmcp/mod/guard.ts +42 -0
  207. package/plugins/pmcp/mod/hooks.json +4 -0
  208. package/plugins/pmcp/mod/host.ts +46 -0
  209. package/plugins/pmcp/mod/model.ts +144 -0
  210. package/plugins/pmcp/mod/reader/index.ts +18 -0
  211. package/plugins/pmcp/mod/reader/read.ts +76 -0
  212. package/plugins/pmcp/mod/reader/settings.ts +54 -0
  213. package/plugins/pmcp/mod/reader/types.ts +38 -0
  214. package/plugins/pmcp/mod/register.tsx +73 -0
  215. package/plugins/pmcp/mod/sessions/format.ts +91 -0
  216. package/plugins/pmcp/mod/sessions/types.ts +162 -0
  217. package/plugins/pmcp/mod/snapshot.ts +75 -0
  218. package/plugins/pmcp/mod/spinner.tsx +30 -0
  219. package/plugins/pmcp/mod/state.ts +28 -0
  220. package/plugins/pmcp/plugin.json +1 -1
  221. package/plugins/pmcp/skills/agent-assets-migrate/SKILL.md +96 -0
  222. package/plugins/pmcp/skills/headless-agents-ci-scaffold/SKILL.md +100 -0
  223. package/plugins/pmcp/skills/marketplace-plugin-scaffold/SKILL.md +87 -0
  224. package/plugins/pmcp/skills/package-skill-catalog/SKILL.md +51 -11
  225. package/plugins/pmcp/skills/pmcp-project-init/SKILL.md +145 -0
  226. package/plugins/pmcp/skills/pmcp-sessions-and-git/SKILL.md +104 -0
  227. package/plugins/pmcp/skills/skill-package-scaffold/SKILL.md +88 -0
  228. package/schema/catalog-v1.json +158 -0
  229. package/schema/library.json +164 -0
  230. package/schema/marketplace-manifest.json +130 -0
  231. package/schema/plugin-manifest.json +55 -0
  232. package/schema/skill-frontmatter.json +144 -0
  233. package/schema/skill-metadata-core.json +110 -0
  234. package/skills/agent-assets-migrate/SKILL.md +96 -0
  235. package/skills/headless-agents-ci-scaffold/SKILL.md +100 -0
  236. package/skills/marketplace-plugin-scaffold/SKILL.md +87 -0
  237. package/skills/package-skill-catalog/SKILL.md +51 -11
  238. package/skills/pmcp-project-init/SKILL.md +145 -0
  239. package/skills/pmcp-sessions-and-git/SKILL.md +104 -0
  240. package/skills/skill-package-scaffold/SKILL.md +88 -0
  241. package/dist/config-BkSpjUG6.d.ts +0 -50
  242. package/dist/embed-DRROSD3F.d.ts +0 -53
  243. package/dist/hook-spec-CSJJySsH.d.ts +0 -11
  244. package/dist/server-VWSY3Shw.d.ts +0 -543
  245. package/dist/tui-worker.js +0 -6549
  246. /package/dist/{tui-worker.d.ts → hook.d.ts} +0 -0
@@ -0,0 +1,538 @@
1
+ import {
2
+ specFrom
3
+ } from "./chunk-7BLPN3W6.js";
4
+ import "./chunk-7DLZC73N.js";
5
+ import {
6
+ doctor,
7
+ spawnRunner
8
+ } from "./chunk-PWSJJXLQ.js";
9
+ import "./chunk-ZH6R642Z.js";
10
+ import "./chunk-N5AQ3PP7.js";
11
+ import "./chunk-P4N7DBD5.js";
12
+ import "./chunk-WIW772I3.js";
13
+ import "./chunk-VJFEN6DJ.js";
14
+ import "./chunk-XP2U3LO3.js";
15
+ import "./chunk-TIA4SPU2.js";
16
+ import {
17
+ HOOK_FILE,
18
+ LOCK_FILE,
19
+ POLICY_FILE,
20
+ sha256
21
+ } from "./chunk-J6QLLQVL.js";
22
+ import "./chunk-PLX3BOOS.js";
23
+ import {
24
+ FEATURES,
25
+ GUARDS,
26
+ RUNTIMES,
27
+ RUNTIME_IDS
28
+ } from "./chunk-65ZHM5RH.js";
29
+ import "./chunk-HQOB7OQS.js";
30
+ import "./chunk-S3PIAMXV.js";
31
+ import "./chunk-JS5RTH4I.js";
32
+ import "./chunk-DCU2EXQV.js";
33
+ import "./chunk-XELAZAIM.js";
34
+ import "./chunk-QEW4J3IZ.js";
35
+ import "./chunk-OPYFEHKG.js";
36
+ import "./chunk-EATCUWGG.js";
37
+ import "./chunk-NRBQK6UX.js";
38
+ import "./chunk-3PW4FI7U.js";
39
+ import "./chunk-SG5TPMKH.js";
40
+ import "./chunk-Z4HRRXRF.js";
41
+ import "./chunk-C4NHQGHL.js";
42
+ import "./chunk-Q5H3L6Y4.js";
43
+ import "./chunk-73AKO4UL.js";
44
+ import {
45
+ doctorSpec
46
+ } from "./chunk-LLBPVZXM.js";
47
+ import "./chunk-XNML2KIC.js";
48
+ import "./chunk-JEL35P7S.js";
49
+ import {
50
+ ArgumentError,
51
+ many
52
+ } from "./chunk-A4PKLESO.js";
53
+ import {
54
+ TOOLS
55
+ } from "./chunk-V4NPDK6X.js";
56
+ import "./chunk-4VCC2NXE.js";
57
+ import "./chunk-665TA55Z.js";
58
+ import "./chunk-OEH47H6A.js";
59
+ import "./chunk-IJBSOWHK.js";
60
+ import "./chunk-E7OOHLQR.js";
61
+ import "./chunk-QPL7E2HW.js";
62
+ import "./chunk-PMJG2CXF.js";
63
+
64
+ // src/commands/doctor.ts
65
+ import { homedir } from "os";
66
+
67
+ // src/project/features.ts
68
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
69
+ import { join as join2 } from "path";
70
+
71
+ // src/project/features/catalog.ts
72
+ var NOTICE_EVENTS = {
73
+ "sessions.registry": ["session_start", "before_tool", "session_end"],
74
+ "sessions.pause": ["session_start", "prompt", "before_tool"],
75
+ "sessions.broadcast": ["session_start", "prompt", "before_tool"],
76
+ "sessions.mailbox": ["session_start", "prompt", "before_tool"],
77
+ "git.shared_checkout": ["session_start", "prompt", "before_tool"],
78
+ "git.worktrees.sync": ["session_start", "prompt"]
79
+ };
80
+ var OUTPUTS = {
81
+ "sessions.registry": [],
82
+ "sessions.pause": ["deny", "context"],
83
+ "sessions.leases": ["deny"],
84
+ "sessions.roles": ["deny"],
85
+ "sessions.broadcast": ["context"],
86
+ "sessions.mailbox": ["context"],
87
+ "git.shared_checkout": ["context"],
88
+ "git.worktrees.sync": ["context"],
89
+ "git.mainline.deliver": ["deny"]
90
+ };
91
+ function guardOutputs(id, policy) {
92
+ const mode = policy?.guards.find((guard) => guard.id === id)?.mode ?? GUARDS[id]?.defaultMode;
93
+ if (mode === "ask") return ["ask"];
94
+ if (mode === "graded") return ["deny", "ask"];
95
+ if (mode === "warn") return ["context"];
96
+ return ["deny"];
97
+ }
98
+ function featureCatalog(policy) {
99
+ const features = Object.keys(FEATURES).map((id) => ({
100
+ id,
101
+ events: NOTICE_EVENTS[id] ?? ["before_tool"],
102
+ outputs: OUTPUTS[id] ?? [],
103
+ fields: id === "sessions.roles" ? ["agent_type"] : []
104
+ }));
105
+ const guards = Object.keys(GUARDS).map((id) => ({
106
+ id,
107
+ events: ["before_tool"],
108
+ outputs: guardOutputs(id, policy),
109
+ fields: []
110
+ }));
111
+ const checks = [
112
+ {
113
+ id: "checks.after_edit",
114
+ events: ["after_tool"],
115
+ outputs: ["context"],
116
+ fields: []
117
+ },
118
+ {
119
+ id: "checks.on_stop",
120
+ events: ["after_tool", "stop"],
121
+ outputs: ["context"],
122
+ fields: []
123
+ }
124
+ ];
125
+ const custom = (policy?.custom ?? []).map((entry) => ({
126
+ id: `custom.${entry.name}`,
127
+ events: [
128
+ entry.event === "after_edit" ? "after_tool" : "before_tool"
129
+ ],
130
+ outputs: [entry.event === "after_edit" ? "feedback" : "deny"],
131
+ fields: []
132
+ }));
133
+ return [...features, ...guards, ...checks, ...custom];
134
+ }
135
+
136
+ // src/project/features/support.ts
137
+ import { existsSync, readFileSync } from "fs";
138
+ import { fileURLToPath } from "url";
139
+ var RANK = {
140
+ unsupported: 0,
141
+ unqualified: 1,
142
+ measured: 2
143
+ };
144
+ function measurementFile(runtime) {
145
+ const candidates = [
146
+ "../docs/hooks/capabilities/",
147
+ "../../../docs/hooks/capabilities/"
148
+ ].map(
149
+ (base) => fileURLToPath(new URL(`${base}${runtime}.json`, import.meta.url))
150
+ );
151
+ return candidates.find((file) => existsSync(file)) ?? null;
152
+ }
153
+ function readMeasurement(runtime) {
154
+ const file = measurementFile(runtime);
155
+ if (!file) return null;
156
+ try {
157
+ return JSON.parse(readFileSync(file, "utf8"));
158
+ } catch {
159
+ return null;
160
+ }
161
+ }
162
+ function eventSupport(measurement, event) {
163
+ const fires = measurement.events?.[event]?.fires;
164
+ if (fires === true) return "measured";
165
+ if (typeof fires === "string") return "unqualified";
166
+ return "unsupported";
167
+ }
168
+ function outputSupport(measurement, output, event) {
169
+ const entry = measurement.outputs?.[output];
170
+ const value = entry?.support;
171
+ if (value === "unsupported") return "unsupported";
172
+ if (value !== "measured") return "unqualified";
173
+ const delivered = entry?.delivered;
174
+ const deferred = entry?.deferred ?? {};
175
+ if (Array.isArray(delivered) && !delivered.includes(event) && !Object.hasOwn(deferred, event))
176
+ return "unqualified";
177
+ return "measured";
178
+ }
179
+ function featureSupport(needs, measurement) {
180
+ if (!measurement) return "unqualified";
181
+ const absent = measurement.fields_absent ?? [];
182
+ const parts = [
183
+ ...needs.events.map((event) => eventSupport(measurement, event)),
184
+ ...needs.outputs.flatMap(
185
+ (output) => needs.events.map((event) => outputSupport(measurement, output, event))
186
+ ),
187
+ ...needs.fields.map(
188
+ (field) => absent.some((entry) => entry.startsWith(field)) ? "unsupported" : "unqualified"
189
+ )
190
+ ];
191
+ return parts.reduce(
192
+ (worst, part) => RANK[part] < RANK[worst] ? part : worst,
193
+ "measured"
194
+ );
195
+ }
196
+
197
+ // src/project/features/trust.ts
198
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
199
+ import { join } from "path";
200
+ import { parse } from "smol-toml";
201
+ var snake = (native) => native.replace(/([a-z])([A-Z])/gu, "$1_$2").toLowerCase();
202
+ function codexTrustKeys(home, env) {
203
+ const file = join(env["CODEX_HOME"] ?? join(home, ".codex"), "config.toml");
204
+ if (!existsSync2(file)) return null;
205
+ try {
206
+ const config = parse(readFileSync2(file, "utf8"));
207
+ return new Set(Object.keys(config.hooks?.state ?? {}));
208
+ } catch {
209
+ return null;
210
+ }
211
+ }
212
+ function codexTrust(root, natives, keys) {
213
+ if (!keys) return "unknown";
214
+ const file = join(root, ".codex/hooks.json");
215
+ if (!existsSync2(file)) return "untrusted";
216
+ const hooks = JSON.parse(readFileSync2(file, "utf8")).hooks ?? {};
217
+ for (const native of natives) {
218
+ const groups = hooks[native] ?? [];
219
+ const group = groups.findIndex(
220
+ (entry) => (entry.hooks ?? []).some((hook) => hook.command?.includes(HOOK_FILE))
221
+ );
222
+ if (group < 0 || !keys.has(`${file}:${snake(native)}:${group}:0`))
223
+ return "untrusted";
224
+ }
225
+ return "trusted";
226
+ }
227
+
228
+ // src/project/features.ts
229
+ function onDisk(root) {
230
+ const file = join2(root, POLICY_FILE);
231
+ if (!existsSync3(file)) return null;
232
+ const text = readFileSync3(file, "utf8");
233
+ const lock = existsSync3(join2(root, LOCK_FILE)) ? JSON.parse(readFileSync3(join2(root, LOCK_FILE), "utf8")) : {};
234
+ const entry = lock.outputs?.find((output) => output.path === POLICY_FILE);
235
+ return { text, locked: entry?.sha256 === sha256(text) };
236
+ }
237
+ function nativeEvents(needs) {
238
+ return needs.events.flatMap(
239
+ (event) => RUNTIMES.codex.nativeEvent(event) ?? []
240
+ );
241
+ }
242
+ function enabledSource(on, source) {
243
+ if (!on) return "default-off";
244
+ return source === "auto" ? "auto" : "toml";
245
+ }
246
+ function projectionState(on, disk, expected) {
247
+ if (!on) return "-";
248
+ if (!disk) return "no";
249
+ return disk.text === expected && disk.locked ? "yes" : "drift";
250
+ }
251
+ function featureRows(spec, options) {
252
+ const policy = spec.hookBundle?.policy ?? null;
253
+ const expected = policy ? `${JSON.stringify(policy, null, 2)}
254
+ ` : "";
255
+ const disk = onDisk(spec.root);
256
+ const keys = codexTrustKeys(options.home, options.env);
257
+ const measurements = Object.fromEntries(
258
+ RUNTIME_IDS.map((id) => [id, readMeasurement(id)])
259
+ );
260
+ const active = /* @__PURE__ */ new Set([
261
+ ...(policy?.guards ?? []).map((guard) => guard.id),
262
+ ...(policy?.custom ?? []).map((entry) => `custom.${entry.name}`)
263
+ ]);
264
+ return featureCatalog(policy).map((needs) => {
265
+ const on = active.has(needs.id);
266
+ const source = spec.featureSources?.[needs.id];
267
+ const enabled = enabledSource(on, source);
268
+ const projected = projectionState(on, disk, expected);
269
+ const cell = (runtime) => {
270
+ if (!on || !policy?.targets.includes(runtime)) return "-";
271
+ const support = featureSupport(needs, measurements[runtime]);
272
+ const lowered = policy.lowering[runtime] && needs.outputs.includes("ask") ? ` (ask->${policy.lowering[runtime].ask})` : "";
273
+ return `${support}${lowered}`;
274
+ };
275
+ const trust = on && policy?.targets.includes("codex") ? codexTrust(spec.root, nativeEvents(needs), keys) : "-";
276
+ const cells = Object.fromEntries(
277
+ RUNTIME_IDS.map((id) => [id, cell(id)])
278
+ );
279
+ return {
280
+ feature: needs.id,
281
+ enabled,
282
+ projected,
283
+ claude: cells.claude,
284
+ codex: cells.codex,
285
+ codexTrust: trust,
286
+ cells
287
+ };
288
+ });
289
+ }
290
+
291
+ // src/project/memory.ts
292
+ import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
293
+ import { isAbsolute, join as join3, resolve } from "path";
294
+ import { parse as parse2 } from "smol-toml";
295
+ function object(value) {
296
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
297
+ throw new Error("Configuration is not an object");
298
+ }
299
+ return value;
300
+ }
301
+ function settings(file, toml = false) {
302
+ if (!existsSync4(file)) {
303
+ return {};
304
+ }
305
+ const text = readFileSync4(file, "utf8");
306
+ return object(toml ? parse2(text) : JSON.parse(text));
307
+ }
308
+ function configuredState(value) {
309
+ if (value === true) {
310
+ return "enabled";
311
+ }
312
+ if (value === false) {
313
+ return "disabled";
314
+ }
315
+ return "unknown";
316
+ }
317
+ function located(metadata2, path, pathScope) {
318
+ return { ...metadata2, path, pathScope, exists: existsSync4(path) };
319
+ }
320
+ function metadata(tool, spec, options) {
321
+ const env = options.env ?? {};
322
+ const directory = (name, fallback) => resolve(spec.root, env[name] ?? join3(options.home, fallback));
323
+ if (tool === "opencode") {
324
+ return {
325
+ state: "unsupported",
326
+ source: "OpenCode native memory metadata is not qualified"
327
+ };
328
+ }
329
+ if (tool === "antigravity") {
330
+ return {
331
+ state: "unsupported",
332
+ source: "No qualified native memory API; brain trajectories are not memory"
333
+ };
334
+ }
335
+ if (tool === "codex") {
336
+ const home2 = directory("CODEX_HOME", ".codex");
337
+ const result = options.run(
338
+ "codex",
339
+ ["features", "list"],
340
+ spec.root,
341
+ options.env
342
+ );
343
+ const match = result.stdout.match(
344
+ /^memories\s+\S+(?:\s+\S+)*\s+(true|false)\s*$/mu
345
+ );
346
+ const state = result.status === 0 && match ? configuredState(match[1] === "true") : "unknown";
347
+ return located(
348
+ {
349
+ state,
350
+ source: result.missing ? "Native CLI not installed" : "codex features list; active session overrides are not inspected"
351
+ },
352
+ join3(home2, "memories"),
353
+ "store"
354
+ );
355
+ }
356
+ const version = options.run(tool, ["--version"], spec.root, options.env);
357
+ if (version.missing || version.status !== 0) {
358
+ return {
359
+ state: "unknown",
360
+ source: "Native CLI unavailable; memory configuration not inspected"
361
+ };
362
+ }
363
+ if (tool === "claude") {
364
+ const home2 = directory("CLAUDE_CONFIG_DIR", ".claude");
365
+ const user2 = settings(join3(home2, "settings.json"));
366
+ const state = env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"] === "1" ? "disabled" : configuredState(user2["autoMemoryEnabled"]);
367
+ const source = "User configuration and disable environment flag; project trust and active session overrides are not inspected";
368
+ const override = user2["autoMemoryDirectory"];
369
+ if (typeof override === "string") {
370
+ const path = override.startsWith("~/") ? join3(options.home, override.slice(2)) : override;
371
+ if (!isAbsolute(path)) {
372
+ return {
373
+ state: "unknown",
374
+ source: "Invalid autoMemoryDirectory metadata; value redacted"
375
+ };
376
+ }
377
+ return located({ state, source }, path, "store");
378
+ }
379
+ const projectName = env["CLAUDE_CODE_PROJECT_DIR_NAME"];
380
+ if (env["CLAUDE_CONFIG_DIR"] && projectName && !projectName.includes("/") && !projectName.includes("\\") && projectName !== "." && projectName !== "..") {
381
+ return located(
382
+ { state, source },
383
+ join3(home2, "projects", projectName, "memory"),
384
+ "store"
385
+ );
386
+ }
387
+ return located(
388
+ {
389
+ state,
390
+ source: `${source}; native project directory encoding is not guessed`
391
+ },
392
+ join3(home2, "projects"),
393
+ "base"
394
+ );
395
+ }
396
+ if (tool === "grok") {
397
+ const home2 = join3(options.home, ".grok");
398
+ const user2 = settings(join3(home2, "config.toml"), true);
399
+ const project = settings(join3(spec.root, ".grok/config.toml"), true);
400
+ const userMemory = user2["memory"] === void 0 ? {} : object(user2["memory"]);
401
+ const projectMemory = project["memory"] === void 0 ? {} : object(project["memory"]);
402
+ const overridden = projectMemory["enabled"] !== void 0;
403
+ const state = overridden ? "unknown" : configuredState(userMemory["enabled"]);
404
+ return located(
405
+ {
406
+ state,
407
+ source: "User memory configuration; project trust and workspace encoding are not exposed by a read-only native memory command"
408
+ },
409
+ join3(home2, "memory-v2/workspaces"),
410
+ "base"
411
+ );
412
+ }
413
+ const home = directory("GEMINI_CLI_HOME", ".gemini");
414
+ const user = settings(join3(home, "settings.json"));
415
+ const context = user["context"] === void 0 ? {} : object(user["context"]);
416
+ const names = context["fileName"] ?? "GEMINI.md";
417
+ const contextFileNames = typeof names === "string" ? [names] : names;
418
+ if (!Array.isArray(contextFileNames) || !contextFileNames.every((name) => typeof name === "string")) {
419
+ return {
420
+ state: "unknown",
421
+ source: "Invalid context filename metadata; values redacted"
422
+ };
423
+ }
424
+ return located(
425
+ {
426
+ state: "unknown",
427
+ source: "Global memory file existence and user context filenames; active memory tool enablement is not exposed",
428
+ contextFileNames
429
+ },
430
+ join3(home, "GEMINI.md"),
431
+ "store"
432
+ );
433
+ }
434
+ function memoryFindings(spec, options) {
435
+ const findings = [];
436
+ for (const tool of spec.tools) {
437
+ if (options.only && !options.only.has(tool)) {
438
+ continue;
439
+ }
440
+ let memory;
441
+ try {
442
+ memory = metadata(tool, spec, options);
443
+ } catch {
444
+ memory = {
445
+ state: "unknown",
446
+ source: "Cannot read configuration metadata; contents are redacted"
447
+ };
448
+ }
449
+ findings.push({
450
+ tool,
451
+ check: "native memory metadata",
452
+ status: memory.state === "enabled" ? "ok" : "skip",
453
+ detail: `${memory.state}${memory.path ? `; ${memory.pathScope}: ${memory.path}; exists=${memory.exists}` : ""}`,
454
+ memory
455
+ });
456
+ }
457
+ return findings;
458
+ }
459
+
460
+ // src/commands/doctor/features.ts
461
+ var ALWAYS = ["claude", "codex"];
462
+ function printFeatures(ui, rows) {
463
+ if (rows.length === 0) return;
464
+ const extra = RUNTIME_IDS.filter(
465
+ (id) => !ALWAYS.includes(id) && rows.some((row) => (row.cells?.[id] ?? "-") !== "-")
466
+ );
467
+ const columns = [
468
+ "feature",
469
+ "enabled",
470
+ "projected",
471
+ "claude",
472
+ "codex",
473
+ "codex trust",
474
+ ...extra
475
+ ];
476
+ const cells = rows.map((row) => [
477
+ row.feature,
478
+ row.enabled,
479
+ row.projected,
480
+ row.claude,
481
+ row.codex,
482
+ row.codexTrust,
483
+ ...extra.map((id) => row.cells?.[id] ?? "-")
484
+ ]);
485
+ const widths = columns.map(
486
+ (name, at) => Math.max(name.length, ...cells.map((cell) => cell[at].length))
487
+ );
488
+ const render = (values) => ` ${values.map((value, at) => value.padEnd(widths[at])).join(" ")}`.trimEnd();
489
+ ui.line();
490
+ ui.heading("features");
491
+ ui.line(render(columns));
492
+ cells.forEach((cell) => ui.line(render(cell)));
493
+ }
494
+
495
+ // src/commands/doctor.ts
496
+ var MARKS = {
497
+ ok: "ok",
498
+ fail: "FAIL",
499
+ warn: "warn",
500
+ skip: "skip"
501
+ };
502
+ var doctorCommand = {
503
+ ...doctorSpec,
504
+ run(context) {
505
+ const only = many(context.args, "tool");
506
+ for (const tool of only) {
507
+ if (!TOOLS.includes(tool))
508
+ throw new ArgumentError(`unknown tool ${tool}`);
509
+ }
510
+ const options = {
511
+ run: spawnRunner,
512
+ home: context.env["HOME"] ?? homedir(),
513
+ env: context.env,
514
+ ...only.length > 0 ? { only: new Set(only) } : {}
515
+ };
516
+ const spec = specFrom(context);
517
+ const findings = context.args.flags.has("memory") ? memoryFindings(spec, options) : doctor(spec, options);
518
+ const features = spec.hookBundle ? featureRows(spec, options) : [];
519
+ if (context.args.flags.has("json")) {
520
+ const extra = features.length > 0 ? { features } : {};
521
+ context.ui.data(`${JSON.stringify({ findings, ...extra }, null, 2)}
522
+ `);
523
+ } else {
524
+ context.ui.table(
525
+ findings.map((f) => [
526
+ `${MARKS[f.status]} ${f.tool}`,
527
+ f.detail ? `${f.check} (${f.detail})` : f.check
528
+ ])
529
+ );
530
+ printFeatures(context.ui, features);
531
+ }
532
+ return findings.some((f) => f.status === "fail") ? 1 : 0;
533
+ }
534
+ };
535
+ export {
536
+ doctorCommand
537
+ };
538
+ //# sourceMappingURL=doctor-ZIOESU3N.js.map