@abdulr7man/pensieve 0.0.0-stage → 1.2.2

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 (179) hide show
  1. package/LICENSE +684 -0
  2. package/README.md +180 -2
  3. package/VERSION +1 -0
  4. package/agents/README.md +16 -0
  5. package/agents/pensieve-code-auditor.md +58 -0
  6. package/agents/pensieve-mapper.md +46 -0
  7. package/agents/pensieve-planner.md +67 -0
  8. package/agents/pensieve-reconner.md +76 -0
  9. package/agents/pensieve-reporter.md +61 -0
  10. package/agents/pensieve-roe-checker.md +46 -0
  11. package/agents/pensieve-scoper.md +77 -0
  12. package/agents/pensieve-tester.md +83 -0
  13. package/agents/pensieve-validator.md +62 -0
  14. package/bin/pensieve +452 -0
  15. package/bin/pensieve-installer.cjs +5 -0
  16. package/commands/pensieve-close.md +6 -0
  17. package/commands/pensieve-map.md +6 -0
  18. package/commands/pensieve-new-engagement.md +6 -0
  19. package/commands/pensieve-pause.md +15 -0
  20. package/commands/pensieve-plan.md +6 -0
  21. package/commands/pensieve-progress.md +34 -0
  22. package/commands/pensieve-quick.md +8 -0
  23. package/commands/pensieve-recon.md +6 -0
  24. package/commands/pensieve-report.md +6 -0
  25. package/commands/pensieve-resume.md +6 -0
  26. package/commands/pensieve-retest.md +10 -0
  27. package/commands/pensieve-scope.md +49 -0
  28. package/commands/pensieve-surface.md +8 -0
  29. package/commands/pensieve-test.md +6 -0
  30. package/commands/pensieve-validate.md +6 -0
  31. package/docker/Dockerfile.pensieve-toolbox +75 -0
  32. package/docker/compose.pensieve-net.yml +37 -0
  33. package/docker/squid.conf.template +21 -0
  34. package/package.json +39 -4
  35. package/packs/ad/ad-killchain/checklist.md +64 -0
  36. package/packs/ad/ad-killchain/pack.yaml +19 -0
  37. package/packs/cloud/cloud-cis/checklist.md +66 -0
  38. package/packs/cloud/cloud-cis/pack.yaml +20 -0
  39. package/packs/fintech/practice-core/checklist.md +33 -0
  40. package/packs/fintech/practice-core/learnings.md +5 -0
  41. package/packs/fintech/practice-core/pack.yaml +18 -0
  42. package/packs/infra/ptes-infra/checklist.md +22 -0
  43. package/packs/infra/ptes-infra/pack.yaml +19 -0
  44. package/packs/mobile/owasp-masvs/checklist.md +80 -0
  45. package/packs/mobile/owasp-masvs/pack.yaml +20 -0
  46. package/packs/owasp-api-v4/checklist.md +85 -0
  47. package/packs/owasp-api-v4/learnings.md +6 -0
  48. package/packs/owasp-api-v4/pack.yaml +23 -0
  49. package/packs/owasp-api-v4/runbooks/API1/SKILL.md +66 -0
  50. package/packs/owasp-api-v4/runbooks/API10/SKILL.md +67 -0
  51. package/packs/owasp-api-v4/runbooks/API2/SKILL.md +129 -0
  52. package/packs/owasp-api-v4/runbooks/API3/SKILL.md +55 -0
  53. package/packs/owasp-api-v4/runbooks/API4/SKILL.md +59 -0
  54. package/packs/owasp-api-v4/runbooks/API5/SKILL.md +60 -0
  55. package/packs/owasp-api-v4/runbooks/API6/SKILL.md +63 -0
  56. package/packs/owasp-api-v4/runbooks/API7/SKILL.md +70 -0
  57. package/packs/owasp-api-v4/runbooks/API8/SKILL.md +72 -0
  58. package/packs/owasp-api-v4/runbooks/API9/SKILL.md +66 -0
  59. package/packs/thickclient/thickclient-core/checklist.md +60 -0
  60. package/packs/thickclient/thickclient-core/pack.yaml +24 -0
  61. package/packs/web/asvs-l2/checklist.md +50 -0
  62. package/packs/web/asvs-l2/learnings.md +6 -0
  63. package/packs/web/asvs-l2/pack.yaml +19 -0
  64. package/packs/web/asvs-l2/runbooks/V2-AUTH-ENUM/SKILL.md +75 -0
  65. package/packs/web/asvs-l2/runbooks/V2-AUTH-LIVE/SKILL.md +78 -0
  66. package/packs/web/asvs-l2/runbooks/V2-AUTH-MFA/SKILL.md +76 -0
  67. package/packs/web/asvs-l2/runbooks/V2-AUTH-RATE/SKILL.md +72 -0
  68. package/packs/web/owasp-testing-checklist/checklist.md +52 -0
  69. package/packs/web/owasp-testing-checklist/learnings.md +47 -0
  70. package/packs/web/owasp-testing-checklist/pack.yaml +21 -0
  71. package/packs/web/unauth-perimeter/checklist.md +72 -0
  72. package/packs/web/unauth-perimeter/pack.yaml +18 -0
  73. package/packs/web/unauth-perimeter/runbooks/PERIM-01/SKILL.md +60 -0
  74. package/packs/web/unauth-perimeter/runbooks/PERIM-02/SKILL.md +63 -0
  75. package/packs/web/unauth-perimeter/runbooks/PERIM-03/SKILL.md +62 -0
  76. package/packs/web/unauth-perimeter/runbooks/PERIM-04/SKILL.md +75 -0
  77. package/packs/web/unauth-perimeter/runbooks/PERIM-05/SKILL.md +66 -0
  78. package/packs/web/unauth-perimeter/runbooks/PERIM-06/SKILL.md +59 -0
  79. package/packs/web/unauth-perimeter/runbooks/PERIM-07/SKILL.md +56 -0
  80. package/packs/web/unauth-perimeter/runbooks/PERIM-08/SKILL.md +57 -0
  81. package/packs/web/unauth-perimeter/runbooks/PERIM-09/SKILL.md +62 -0
  82. package/packs/web/unauth-perimeter/runbooks/PERIM-10/SKILL.md +60 -0
  83. package/packs/whitebox/code-audit-core/checklist.md +36 -0
  84. package/packs/whitebox/code-audit-core/learnings.md +6 -0
  85. package/packs/whitebox/code-audit-core/pack.yaml +14 -0
  86. package/prompts/orchestrator-core.md +52 -0
  87. package/reference/attack-playbooks.md +57 -0
  88. package/reference/otp-relay.md +98 -0
  89. package/reference/param-profiles.md +48 -0
  90. package/reference/templates/FINDING.md +97 -0
  91. package/reference/tool-selection.md +64 -0
  92. package/reference/vulnerability-finding-standard.md +80 -0
  93. package/runtimes/hermes/hooks/injection-scan.py +290 -0
  94. package/runtimes/hermes/hooks/scope-guard.py +136 -0
  95. package/skills/pensieve/SKILL.md +134 -0
  96. package/skills/pensieve-close/SKILL.md +31 -0
  97. package/skills/pensieve-map/SKILL.md +25 -0
  98. package/skills/pensieve-new-engagement/SKILL.md +28 -0
  99. package/skills/pensieve-pause/SKILL.md +22 -0
  100. package/skills/pensieve-plan/SKILL.md +39 -0
  101. package/skills/pensieve-progress/SKILL.md +35 -0
  102. package/skills/pensieve-quick/SKILL.md +47 -0
  103. package/skills/pensieve-recon/SKILL.md +30 -0
  104. package/skills/pensieve-report/SKILL.md +46 -0
  105. package/skills/pensieve-resume/SKILL.md +33 -0
  106. package/skills/pensieve-retest/SKILL.md +35 -0
  107. package/skills/pensieve-scope/SKILL.md +35 -0
  108. package/skills/pensieve-surface/SKILL.md +36 -0
  109. package/skills/pensieve-test/SKILL.md +35 -0
  110. package/skills/pensieve-validate/SKILL.md +28 -0
  111. package/skills/pensieve-wiki/SKILL.md +39 -0
  112. package/src/installer/cli.cjs +209 -0
  113. package/src/installer/home.cjs +155 -0
  114. package/src/installer/runtimes.cjs +276 -0
  115. package/src/installer/uninstall.cjs +342 -0
  116. package/src/pensieve-sdk/bin/pensieve-sdk.cjs +1045 -0
  117. package/src/pensieve-sdk/lib/agent-translate.cjs +50 -0
  118. package/src/pensieve-sdk/lib/approvals.cjs +408 -0
  119. package/src/pensieve-sdk/lib/audit.cjs +290 -0
  120. package/src/pensieve-sdk/lib/checklist.cjs +337 -0
  121. package/src/pensieve-sdk/lib/clientlist.cjs +814 -0
  122. package/src/pensieve-sdk/lib/close.cjs +133 -0
  123. package/src/pensieve-sdk/lib/config.cjs +156 -0
  124. package/src/pensieve-sdk/lib/cvss.cjs +91 -0
  125. package/src/pensieve-sdk/lib/env.cjs +272 -0
  126. package/src/pensieve-sdk/lib/evidence.cjs +217 -0
  127. package/src/pensieve-sdk/lib/findings.cjs +1096 -0
  128. package/src/pensieve-sdk/lib/frontmatter.cjs +178 -0
  129. package/src/pensieve-sdk/lib/graph.cjs +607 -0
  130. package/src/pensieve-sdk/lib/ids.cjs +63 -0
  131. package/src/pensieve-sdk/lib/init.cjs +79 -0
  132. package/src/pensieve-sdk/lib/liveness.cjs +176 -0
  133. package/src/pensieve-sdk/lib/loop.cjs +619 -0
  134. package/src/pensieve-sdk/lib/migrate.cjs +57 -0
  135. package/src/pensieve-sdk/lib/monitor.cjs +69 -0
  136. package/src/pensieve-sdk/lib/pack.cjs +607 -0
  137. package/src/pensieve-sdk/lib/paths.cjs +73 -0
  138. package/src/pensieve-sdk/lib/pdf.cjs +291 -0
  139. package/src/pensieve-sdk/lib/recon.cjs +296 -0
  140. package/src/pensieve-sdk/lib/renderers/__pycache__/formal_report.cpython-314.pyc +0 -0
  141. package/src/pensieve-sdk/lib/renderers/formal_report.py +608 -0
  142. package/src/pensieve-sdk/lib/report.cjs +1135 -0
  143. package/src/pensieve-sdk/lib/runbook.cjs +124 -0
  144. package/src/pensieve-sdk/lib/sarif.cjs +154 -0
  145. package/src/pensieve-sdk/lib/scope.cjs +621 -0
  146. package/src/pensieve-sdk/lib/security.cjs +61 -0
  147. package/src/pensieve-sdk/lib/skills.cjs +193 -0
  148. package/src/pensieve-sdk/lib/state.cjs +610 -0
  149. package/src/pensieve-sdk/lib/subagent.cjs +658 -0
  150. package/src/pensieve-sdk/lib/target.cjs +149 -0
  151. package/src/pensieve-sdk/lib/tools.cjs +66 -0
  152. package/src/pensieve-sdk/lib/vault.cjs +122 -0
  153. package/src/pensieve-sdk/lib/vendor/cvss40.LICENSE +22 -0
  154. package/src/pensieve-sdk/lib/vendor/cvss40.js +1208 -0
  155. package/src/pensieve-sdk/package.json +11 -0
  156. package/templates/ACCOUNTS.md +35 -0
  157. package/templates/ATTACK-SURFACE.md +30 -0
  158. package/templates/FINDING.md +43 -0
  159. package/templates/PLAN.md +33 -0
  160. package/templates/PROJECT.md +29 -0
  161. package/templates/ROE.md +50 -0
  162. package/templates/RUN-LOG.md +19 -0
  163. package/templates/SCOPE.md +32 -0
  164. package/templates/VALIDATION.md +62 -0
  165. package/templates/report/REPORT.md +49 -0
  166. package/workflows/close.md +34 -0
  167. package/workflows/map.md +39 -0
  168. package/workflows/new-engagement.md +37 -0
  169. package/workflows/plan.md +45 -0
  170. package/workflows/progress.md +28 -0
  171. package/workflows/quick.md +67 -0
  172. package/workflows/recon.md +87 -0
  173. package/workflows/report.md +51 -0
  174. package/workflows/resume.md +26 -0
  175. package/workflows/retest.md +53 -0
  176. package/workflows/scope.md +47 -0
  177. package/workflows/surface.md +29 -0
  178. package/workflows/test.md +95 -0
  179. package/workflows/validate.md +34 -0
@@ -0,0 +1,276 @@
1
+ 'use strict';
2
+ /**
3
+ * runtimes.cjs — NPX-02/03 (v1.2): the runtime registry + wiring engines.
4
+ *
5
+ * hermes + claude-code are FULL parity ports of install.sh's engines
6
+ * (skills, commands/agents, hooks, config/settings surgery, smoke tests).
7
+ * codex / opencode / cursor / gemini are THIN markdown wiring: command
8
+ * files in each runtime's native convention (md where the runtime reads
9
+ * md, generated TOML where it reads TOML), all pointing at the
10
+ * self-contained ~/.pensieve — labeled honestly: no runtime-layer
11
+ * scope-guard hooks; engagement containment stays enforced by the SDK +
12
+ * the toolbox network for every runtime.
13
+ */
14
+ const fs = require('node:fs');
15
+ const path = require('node:path');
16
+ const os = require('node:os');
17
+ const { spawnSync } = require('node:child_process');
18
+ const { ROOT, copyDir, record } = require('./home.cjs');
19
+
20
+ function which(bin) {
21
+ const r = spawnSync(bin, ['--version'], { encoding: 'utf8' });
22
+ return !(r.error && r.error.code === 'ENOENT') && r.status !== null;
23
+ }
24
+
25
+ function rmLink(p) { if (fs.existsSync(p) || fs.lstatSync(p).isLink?.() || isLink(p)) fs.rmSync(p, { force: true }); }
26
+ function isLink(p) { try { return fs.lstatSync(p).isSymbolicLink(); } catch { return false; } }
27
+
28
+ // ---------------------------------------------------------------- hermes ---
29
+ function wireHermes(HOME, { base, profile, skillsDir, manifest, log }) {
30
+ const hermesBase = base || path.join(HOME, '.hermes');
31
+ const profileHome = profile ? path.join(hermesBase, 'profiles', profile) : hermesBase;
32
+ if (!fs.existsSync(path.join(profileHome, 'config.yaml'))) {
33
+ throw new Error(
34
+ `hermes home config not found: ${path.join(profileHome, 'config.yaml')} `
35
+ + `(create the profile first: hermes profile create ${profile || '<default>'}, or run hermes once to initialize the home)`
36
+ );
37
+ }
38
+
39
+ // skill + command skills: symlink into the shared home (Hermes follows links)
40
+ const linkPensieve = path.join(profileHome, 'skills', 'pensieve');
41
+ fs.rmSync(linkPensieve, { recursive: true, force: true });
42
+ fs.mkdirSync(path.dirname(linkPensieve), { recursive: true });
43
+ fs.symlinkSync(path.join(skillsDir, 'pensieve'), linkPensieve);
44
+ record(manifest, linkPensieve);
45
+
46
+ const sd = path.join(profileHome, 'skills', 'software-development');
47
+ fs.mkdirSync(sd, { recursive: true });
48
+ let n = 0;
49
+ for (const name of fs.readdirSync(skillsDir)) {
50
+ if (!name.startsWith('pensieve-')) continue;
51
+ const link = path.join(sd, name);
52
+ fs.rmSync(link, { recursive: true, force: true });
53
+ fs.symlinkSync(path.join(skillsDir, name), link);
54
+ record(manifest, link);
55
+ n += 1;
56
+ }
57
+ if (log) log(`skill -> ${linkPensieve} (symlink); ${n} command skills -> ${sd}`);
58
+
59
+ // hooks: the guard pair
60
+ const hooksDir = path.join(profileHome, 'hooks');
61
+ fs.mkdirSync(hooksDir, { recursive: true });
62
+ for (const h of ['scope-guard.py', 'injection-scan.py']) {
63
+ const dst = path.join(hooksDir, h);
64
+ fs.copyFileSync(path.join(ROOT, 'runtimes', 'hermes', 'hooks', h), dst);
65
+ fs.chmodSync(dst, 0o755);
66
+ record(manifest, dst);
67
+ }
68
+
69
+ // config.yaml surgery — the install.sh four cases, ported
70
+ const cfgPath = path.join(profileHome, 'config.yaml');
71
+ const cfg = fs.readFileSync(cfgPath, 'utf8');
72
+ const block = [
73
+ '',
74
+ 'hooks:',
75
+ ' pre_tool_call:',
76
+ ' - matcher: "terminal"',
77
+ ` command: "${hooksDir}/scope-guard.py"`,
78
+ ' timeout: 10',
79
+ ' fail_closed: true',
80
+ ' post_tool_call:',
81
+ ' - matcher: "terminal|web_extract|web_search|browser_exec"',
82
+ ` command: "${hooksDir}/injection-scan.py"`,
83
+ ' timeout: 10',
84
+ ' pre_llm_call:',
85
+ ` - command: "${hooksDir}/injection-scan.py"`,
86
+ ' timeout: 10',
87
+ 'hooks_auto_accept: true',
88
+ '',
89
+ ].join('\n');
90
+ if (/injection-scan\.py/.test(cfg)) {
91
+ if (log) log('hooks already registered (scope-guard + injection-scan) — no change');
92
+ } else if (/scope-guard\.py/.test(cfg)) {
93
+ const anchor = 'hooks_auto_accept:';
94
+ if (!cfg.includes(anchor)) throw new Error('hooks_auto_accept anchor missing — merge the injection-scan events manually (see docs)');
95
+ fs.mkdirSync(path.join(profileHome, 'backups', 'pensieve'), { recursive: true });
96
+ const bak = path.join(profileHome, 'backups', 'pensieve', `config.yaml.pre-injection-scan.${stamp()}`);
97
+ fs.copyFileSync(cfgPath, bak);
98
+ const splice = [
99
+ ' post_tool_call:',
100
+ ' - matcher: "terminal|web_extract|web_search|browser_exec"',
101
+ ` command: "${hooksDir}/injection-scan.py"`,
102
+ ' timeout: 10',
103
+ ' pre_llm_call:',
104
+ ` - command: "${hooksDir}/injection-scan.py"`,
105
+ ' timeout: 10',
106
+ ].join('\n');
107
+ fs.writeFileSync(cfgPath, cfg.replace(anchor, splice + '\n' + anchor, 1));
108
+ if (log) log(`injection-scan registered into the existing hooks block (backup: ${bak})`);
109
+ } else if (/^hooks:/m.test(cfg)) {
110
+ throw new Error(
111
+ 'config.yaml already has a hooks: block — merge manually '
112
+ + '(scope-guard pre_tool_call fail_closed + injection-scan post_tool_call/pre_llm_call)'
113
+ );
114
+ } else {
115
+ fs.mkdirSync(path.join(profileHome, 'backups', 'pensieve'), { recursive: true });
116
+ const bak = path.join(profileHome, 'backups', 'pensieve', `config.yaml.pre-pensieve.${stamp()}`);
117
+ fs.copyFileSync(cfgPath, bak);
118
+ fs.writeFileSync(cfgPath, cfg + block);
119
+ if (log) log(`hooks registered (backup: ${bak})`);
120
+ }
121
+
122
+ // smoke: the guard allows outside-engagement traffic and hermes sees it
123
+ const payload = '{"tool_name":"terminal","tool_input":{"command":"curl http://example.com"},"cwd":"/tmp"}';
124
+ const guard = spawnSync('python3', [path.join(hooksDir, 'scope-guard.py')], { input: payload, encoding: 'utf8' });
125
+ if (guard.status !== 0) throw new Error(`guard smoke test failed (outside engagement must allow): ${guard.stderr || guard.status}`);
126
+ const see = spawnSync('hermes', ['hooks', 'list'], { env: { ...process.env, HERMES_HOME: profileHome }, encoding: 'utf8' });
127
+ if (!String(see.stdout || '').includes('scope-guard')) {
128
+ throw new Error('hermes does not see the scope-guard hook — the config surgery did not land');
129
+ }
130
+ if (log) log('guard registered and behaves (smoke OK)');
131
+ return { runtime: 'hermes', home: profileHome };
132
+ }
133
+
134
+ // ---------------------------------------------------------------- claude ---
135
+ function wireClaude(HOME, { skillsDir, manifest, log }) {
136
+ const claudeHome = path.join(HOME, '.claude');
137
+ if (!which('claude')) throw new Error('claude CLI not found — install Claude Code first, or check PATH');
138
+
139
+ // agents: delegate to the translator (single source of truth) like install.sh
140
+ const tr = spawnSync(process.execPath,
141
+ [path.join(ROOT, 'bin', 'pensieve'), 'install', '--runtime', 'claude-code'],
142
+ { env: { ...process.env, HOME }, stdio: 'inherit' });
143
+ if (tr.status !== 0) throw new Error('agent translation failed (bin/pensieve install --runtime claude-code)');
144
+
145
+ // commands with the workflow path rewritten to the installed reference tree
146
+ const CT = path.join(HOME, '.pensieve', 'claude', 'pensieve');
147
+ fs.rmSync(CT, { recursive: true, force: true });
148
+ fs.mkdirSync(CT, { recursive: true });
149
+ for (const d of ['workflows', 'templates', 'packs', 'prompts', 'reference']) {
150
+ copyDir(path.join(ROOT, d), path.join(CT, d));
151
+ }
152
+ const cmdsDir = path.join(claudeHome, 'commands');
153
+ fs.mkdirSync(cmdsDir, { recursive: true });
154
+ let nCmd = 0;
155
+ for (const f of fs.readdirSync(path.join(ROOT, 'commands'))) {
156
+ if (!f.startsWith('pensieve-') || !f.endsWith('.md')) continue;
157
+ const text = fs.readFileSync(path.join(ROOT, 'commands', f), 'utf8')
158
+ .split('workflows/').join(`${CT}/workflows/`);
159
+ fs.writeFileSync(path.join(cmdsDir, f), text);
160
+ record(manifest, path.join(cmdsDir, f));
161
+ nCmd += 1;
162
+ }
163
+ const refLink = path.join(claudeHome, 'pensieve');
164
+ fs.rmSync(refLink, { recursive: true, force: true });
165
+ fs.symlinkSync(CT, refLink);
166
+ record(manifest, refLink);
167
+ if (log) log(`commands (${nCmd}) + reference -> ${CT} (symlink)`);
168
+
169
+ // hooks + settings.json surgery (native JSON; idempotent; backup)
170
+ const hooksDir = path.join(claudeHome, 'hooks');
171
+ fs.mkdirSync(hooksDir, { recursive: true });
172
+ for (const h of ['scope-guard.py', 'injection-scan.py']) {
173
+ const dst = path.join(hooksDir, h);
174
+ fs.copyFileSync(path.join(ROOT, 'runtimes', 'hermes', 'hooks', h), dst);
175
+ fs.chmodSync(dst, 0o755);
176
+ record(manifest, dst);
177
+ }
178
+ const settingsPath = path.join(claudeHome, 'settings.json');
179
+ if (!fs.existsSync(settingsPath)) fs.writeFileSync(settingsPath, '{}\n');
180
+ let settings;
181
+ try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); }
182
+ catch (e) { throw new Error(`settings.json is not valid JSON (${e.message}) — merge manually`); }
183
+ const guard = `"${path.join(hooksDir, 'scope-guard.py')}"`;
184
+ const inj = `"${path.join(hooksDir, 'injection-scan.py')}"`;
185
+ const registered = (entries, needle) =>
186
+ (entries || []).some((e) => (e.hooks || []).some((h) => String(h.command || '').includes(needle)));
187
+ const hooks = (settings.hooks = settings.hooks || {});
188
+ const pre = (hooks.PreToolUse = hooks.PreToolUse || []);
189
+ const post = (hooks.PostToolUse = hooks.PostToolUse || []);
190
+ const changed = [];
191
+ if (!registered(pre, 'scope-guard.py')) {
192
+ let m = pre.find((e) => e.matcher === 'Bash');
193
+ if (!m) { m = { matcher: 'Bash', hooks: [] }; pre.push(m); }
194
+ m.hooks.push({ type: 'command', command: guard, timeout: 10 });
195
+ changed.push('scope-guard(PreToolUse:Bash)');
196
+ }
197
+ if (!registered(post, 'injection-scan.py')) {
198
+ let m = post.find((e) => e.matcher === 'Bash|WebFetch|WebSearch');
199
+ if (!m) { m = { matcher: 'Bash|WebFetch|WebSearch', hooks: [] }; post.push(m); }
200
+ m.hooks.push({ type: 'command', command: inj, timeout: 10 });
201
+ changed.push('injection-scan(PostToolUse:Bash|WebFetch|WebSearch)');
202
+ }
203
+ if (changed.length) {
204
+ fs.mkdirSync(path.join(claudeHome, 'backups', 'pensieve'), { recursive: true });
205
+ const bak = path.join(claudeHome, 'backups', 'pensieve', `settings.json.pre-pensieve.${stamp()}`);
206
+ fs.copyFileSync(settingsPath, bak);
207
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
208
+ if (log) log(`settings merged (backup: ${bak}): ${changed.join(', ')}`);
209
+ } else if (log) log('hooks already registered — no change (no new backup)');
210
+
211
+ // smoke: the guard allows outside-engagement traffic
212
+ const payload = '{"tool_name":"Bash","tool_input":{"command":"curl http://example.com"},"cwd":"/tmp"}';
213
+ const g = spawnSync('python3', [path.join(hooksDir, 'scope-guard.py')], { input: payload, encoding: 'utf8' });
214
+ if (g.status !== 0) throw new Error(`guard smoke test failed: ${g.stderr || g.status}`);
215
+ JSON.parse(fs.readFileSync(settingsPath, 'utf8')); // still valid JSON
216
+ if (log) log('hooks behave; settings valid');
217
+ return { runtime: 'claude', home: claudeHome };
218
+ }
219
+
220
+ // ----------------------------------------------------------------- thin ---
221
+ const THIN = {
222
+ codex: {
223
+ label: 'OpenAI Codex', home: (H) => path.join(H, '.codex'),
224
+ commandsDir: (H) => path.join(H, '.codex', 'prompts'), format: 'md',
225
+ },
226
+ opencode: {
227
+ label: 'OpenCode', home: (H) => path.join(H, '.config', 'opencode'),
228
+ commandsDir: (H) => path.join(H, '.config', 'opencode', 'command'), format: 'md',
229
+ },
230
+ cursor: {
231
+ label: 'Cursor', home: (H) => path.join(H, '.cursor'),
232
+ commandsDir: (H) => path.join(H, '.cursor', 'commands'), format: 'md',
233
+ },
234
+ gemini: {
235
+ label: 'Gemini CLI', home: (H) => path.join(H, '.gemini'),
236
+ commandsDir: (H) => path.join(H, '.gemini', 'commands'), format: 'toml',
237
+ },
238
+ };
239
+
240
+ function wireThin(HOME, id, { skillsDir, manifest, log }) {
241
+ const spec = THIN[id];
242
+ if (!spec) throw new Error(`unknown thin runtime: ${id}`);
243
+ const dir = spec.commandsDir(HOME);
244
+ fs.mkdirSync(dir, { recursive: true });
245
+ const wfRoot = path.join(HOME, '.pensieve', 'skills', 'pensieve', 'references');
246
+ let n = 0;
247
+ for (const f of fs.readdirSync(path.join(ROOT, 'commands'))) {
248
+ if (!f.startsWith('pensieve-') || !f.endsWith('.md')) continue;
249
+ const name = f.replace(/\.md$/, '');
250
+ const text = fs.readFileSync(path.join(ROOT, 'commands', f), 'utf8')
251
+ .split('workflows/').join(`${wfRoot}/workflows/`);
252
+ const dst = path.join(dir, spec.format === 'toml' ? `${name}.toml` : f);
253
+ if (spec.format === 'toml') {
254
+ const first = text.split('\n').find((l) => l.trim()) || name;
255
+ fs.writeFileSync(dst, `description = "pensieve: ${first.slice(0, 80).replace(/"/g, "'")}"\n`
256
+ + `prompt = "Read and follow ${wfRoot}/workflows/${workflowFor(name)}.md exactly."\n`);
257
+ } else {
258
+ fs.writeFileSync(dst, `> PENSIEVE /${name} — thin wiring: no runtime-layer guard hooks; containment stays with the SDK + toolbox network.\n\n${text}`);
259
+ }
260
+ record(manifest, dst);
261
+ n += 1;
262
+ }
263
+ if (log) log(`${spec.label}: ${n} command files -> ${dir} (markdown wiring; SDK at ~/.pensieve)`);
264
+ return { runtime: id, home: spec.home(HOME) };
265
+ }
266
+
267
+ function workflowFor(commandName) {
268
+ // commands/pensieve-<x>.md -> workflows/<x>.md (same stem)
269
+ return commandName.replace(/^pensieve-/, '');
270
+ }
271
+
272
+ function stamp() {
273
+ return new Date().toISOString().replace(/[-:T]/g, '').slice(0, 15).replace(/(\d{8})(\d{6})/, '$1-$2');
274
+ }
275
+
276
+ module.exports = { which, wireHermes, wireClaude, wireThin, THIN };
@@ -0,0 +1,342 @@
1
+ 'use strict';
2
+ /**
3
+ * uninstall.cjs — NPX-04 (v1.2): uninstall in the same bin, node port of
4
+ * uninstall.sh v2's semantics.
5
+ *
6
+ * Two removal sources, unioned:
7
+ * 1. INSTALL-MANIFEST.json — every path the npm installer wrote (exact)
8
+ * 2. the v2 heuristic sweep — for .sh-era installs and strays: pensieve-*
9
+ * symlinks (symlink-only; real dirs warned, never touched), hook files,
10
+ * config.yaml + settings.json surgery with foreign entries preserved,
11
+ * STRIKE artifacts only with --legacy-strike, rc PATH strip, backups
12
+ * tarred before removal. Owner-gated early-close reasons (SDK-side)
13
+ * are untouched here — this removes installs, never engagements.
14
+ */
15
+ const fs = require('node:fs');
16
+ const path = require('node:path');
17
+ const os = require('node:os');
18
+ const { spawnSync } = require('node:child_process');
19
+ const { pensieveHome, loadManifest, manifestFile } = require('./home.cjs');
20
+
21
+ const DRY = { v: false };
22
+
23
+ function say(m) { console.log(' ' + m); }
24
+ function ok(m) { console.log(' ✔ ' + m); }
25
+ function warn(m) { console.log(' ! ' + m); }
26
+
27
+ function isLink(p) { try { return fs.lstatSync(p).isSymbolicLink(); } catch { return false; } }
28
+ function ex(p) { try { fs.accessSync(p); return true; } catch { return false; } }
29
+
30
+ function backupDir(HOME) {
31
+ return path.join(HOME, '.local', 'share', 'pensieve-backups',
32
+ new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14) + '-' + process.pid);
33
+ }
34
+
35
+ function backupFile(BK, src) {
36
+ if (!DRY.v && BK && ex(src)) {
37
+ fs.mkdirSync(BK, { recursive: true });
38
+ fs.copyFileSync(src, path.join(BK, relName(src)));
39
+ }
40
+ }
41
+ function backupTree(BK, dir) {
42
+ if (!DRY.v && BK && ex(dir)) {
43
+ fs.mkdirSync(path.dirname(BK), { recursive: true });
44
+ spawnSync('tar', ['czf', path.join(BK, relName(dir) + '.tar.gz'), '-C', path.dirname(dir), path.basename(dir)]);
45
+ }
46
+ }
47
+ function relName(p) { return p.replace(/^\/+/, '').replace(/\//g, '__'); }
48
+
49
+ function rm(p) { if (DRY.v) { say(`DRY: rm ${p}`); return; } fs.rmSync(p, { force: true }); }
50
+ function rmrf(p) { if (DRY.v) { say(`DRY: rm -rf ${p}`); return; } fs.rmSync(p, { recursive: true, force: true }); }
51
+
52
+ // ------------------------------------------------- config.yaml surgery ---
53
+ // Port of the hardened v2 python: entry/cont/subkey grammar, up-scan that
54
+ // stops at THIS entry's header (a foreign entry above survives), sub-keys
55
+ // dropped only when they HAD entries, block dropped only when fully empty.
56
+ function stripHermesConfig(cfgPath, hooksDir, BK) {
57
+ const text = fs.readFileSync(cfgPath, 'utf8');
58
+ const lines = text.split('\n').map((l, i) => ({ l: l + '\n', i }));
59
+ const isEntry = (s) => /^\s+- (matcher|command):/.test(s);
60
+ const isCont = (s) => /^\s+(matcher|command|timeout|fail_closed|type):/.test(s) && !isEntry(s);
61
+ const isHooksKey = (s) => /^hooks:\s*$/.test(s);
62
+ const isSubkey = (s) => /^\s{2}[A-Za-z_][A-Za-z0-9_]*:\s*$/.test(s);
63
+ const isTop = (s) => /^[A-Za-z_#]/.test(s) && !isHooksKey(s);
64
+
65
+ const bounds = (arr) => {
66
+ const hi = arr.findIndex((x) => isHooksKey(x.l));
67
+ if (hi < 0) return [null, null];
68
+ let be = hi + 1;
69
+ while (be < arr.length && !isTop(arr[be].l)) be += 1;
70
+ return [hi, be];
71
+ };
72
+ const counts = (arr, hi, be) => {
73
+ const c = {}; let cur = null;
74
+ for (let k = hi + 1; k < be; k++) {
75
+ const m = /^\s{2}([A-Za-z_][A-Za-z0-9_]*)/.exec(arr[k].l);
76
+ if (m) { cur = m[1]; c[cur] = 0; } else if (isEntry(arr[k].l) && cur) c[cur] += 1;
77
+ }
78
+ return c;
79
+ };
80
+
81
+ let [hi, be] = bounds(lines);
82
+ const orig = hi === null ? {} : counts(lines, hi, be);
83
+ const remove = new Set();
84
+ if (hi !== null) {
85
+ for (let i = hi + 1; i < be; i++) {
86
+ if (!lines[i].l.includes(hooksDir)) continue;
87
+ remove.add(i);
88
+ let j = i + 1;
89
+ while (j < be && isCont(lines[j].l)) { remove.add(j); j += 1; }
90
+ j = i - 1;
91
+ while (j > hi && isCont(lines[j].l)) { remove.add(j); j -= 1; }
92
+ if (j > hi && isEntry(lines[j].l)) remove.add(j);
93
+ }
94
+ }
95
+ lines.forEach((x, i) => { if (/^hooks_auto_accept:\s*true\s*$/.test(x.l)) remove.add(i); });
96
+ let out = lines.filter((x) => !remove.has(x.i)).map((x) => x.l);
97
+
98
+ let [hi2, be2] = bounds(out.map((l) => ({ l })));
99
+ if (hi2 !== null) {
100
+ const now = counts(out.map((l) => ({ l })), hi2, be2);
101
+ out = out.filter((l, k) => {
102
+ const m = /^\s{2}([A-Za-z_][A-Za-z0-9_]*)/.exec(l);
103
+ if (m && isSubkey(l) && (now[m[1]] || 0) === 0 && (orig[m[1]] || 0) > 0) return false;
104
+ return true;
105
+ });
106
+ [hi2, be2] = bounds(out.map((l) => ({ l })));
107
+ const hasEntry = out.slice(hi2 + 1, be2).some((l) => isEntry(l));
108
+ if (!hasEntry) out = out.slice(0, hi2).concat(out.slice(be2));
109
+ }
110
+
111
+ backupFile(BK, cfgPath);
112
+ if (DRY.v) { say(`DRY: would strip pensieve hook entries from ${cfgPath}`); return; }
113
+ fs.writeFileSync(cfgPath, out.join(''));
114
+ ok(`config.yaml: pensieve hook entries stripped (hooks_auto_accept too) — ${cfgPath}`);
115
+ }
116
+
117
+ // ------------------------------------------------ settings.json surgery ---
118
+ function stripClaudeSettings(settingsPath, BK) {
119
+ let s;
120
+ try { s = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); }
121
+ catch (e) { throw new Error(`${settingsPath} is not valid JSON (${e.message}) — settings left untouched`); }
122
+ if (!s || typeof s !== 'object' || !s.hooks || typeof s.hooks !== 'object') { ok('no hooks in settings.json — nothing to strip'); return; }
123
+ let removed = 0;
124
+ for (const event of Object.keys(s.hooks)) {
125
+ const entries = s.hooks[event];
126
+ if (!Array.isArray(entries)) continue;
127
+ const kept = [];
128
+ for (const e of entries) {
129
+ if (e && Array.isArray(e.hooks)) {
130
+ const kh = e.hooks.filter((h) => !h || typeof h !== 'object'
131
+ || (!String(h.command || '').includes('scope-guard.py') && !String(h.command || '').includes('injection-scan.py')));
132
+ removed += e.hooks.length - kh.length;
133
+ if (kh.length) { e.hooks = kh; kept.push(e); }
134
+ } else kept.push(e);
135
+ }
136
+ if (kept.length) s.hooks[event] = kept; else delete s.hooks[event];
137
+ }
138
+ if (!Object.keys(s.hooks).length) delete s.hooks;
139
+ backupFile(BK, settingsPath);
140
+ if (DRY.v) { say(`DRY: would strip ${removed} pensieve hook entries from ${settingsPath}`); return; }
141
+ fs.writeFileSync(settingsPath, JSON.stringify(s, null, 2) + '\n');
142
+ ok(`settings.json: ${removed} pensieve hook entries removed (foreign entries kept)`);
143
+ }
144
+
145
+ // ------------------------------------------------------------ rc strip ---
146
+ function stripRc(HOME, legacy) {
147
+ for (const rc of ['.profile', '.bashrc', '.zshrc', '.zprofile', '.zshenv']) {
148
+ const p = path.join(HOME, rc);
149
+ if (!ex(p)) continue;
150
+ const text = fs.readFileSync(p, 'utf8');
151
+ const pens = text.includes('.pensieve/bin');
152
+ const strike = legacy && text.includes('.strike/bin');
153
+ if (!pens && !strike) continue;
154
+ const mode = pens && strike ? 'both' : (pens ? 'pensieve' : 'strike');
155
+ const lines = text.split('\n');
156
+ const drop = new Set();
157
+ const nameOk = (n) => mode === 'both' || mode === n;
158
+ lines.forEach((l, i) => {
159
+ const pl = 'PATH=' in l && '.pensieve/bin' in l;
160
+ const sl = 'PATH=' in l && '.strike/bin' in l;
161
+ if ((mode === 'pensieve' && pl) || (mode === 'strike' && sl) || (mode === 'both' && (pl || sl))) drop.add(i);
162
+ let m = /^\s*if \[ -d "\$HOME\/\.?(pensieve|strike)\/bin"/.exec(l);
163
+ if (m && nameOk(m[1])) {
164
+ drop.add(i);
165
+ let j = i + 1;
166
+ while (j < lines.length && !/^\s*fi\s*$/.test(lines[j])) {
167
+ if ('PATH=' in lines[j] && ('.pensieve/bin' in lines[j] || '.strike/bin' in lines[j])) drop.add(j);
168
+ j += 1;
169
+ }
170
+ if (j < lines.length) drop.add(j);
171
+ }
172
+ m = /^# (STRIKE|PENSIEVE)[:, ]/.exec(l);
173
+ if (m && nameOk(m[1].toLowerCase())) drop.add(i);
174
+ });
175
+ const out = lines.filter((l, i) => !drop.has(i)).join('\n');
176
+ const BK = backupDir(HOME);
177
+ backupFile(BK, p);
178
+ if (DRY.v) { say(`DRY: would strip ${mode} PATH lines from ${p}`); continue; }
179
+ fs.writeFileSync(p, out);
180
+ ok(`${p}: ${drop.size} line(s) stripped`);
181
+ }
182
+ }
183
+
184
+ // --------------------------------------------------------- hermes sweep ---
185
+ function sweepHermesHome(PH, { legacy, BK }) {
186
+ if (!ex(PH)) { ok(`no hermes home at ${PH}`); return; }
187
+ if (ex(path.join(PH, 'skills'))) {
188
+ const pats = [path.join(PH, 'skills', 'pensieve'), path.join(PH, 'skills', 'software-development', 'pensieve-*')];
189
+ if (legacy) pats.push(path.join(PH, 'skills', 'strike'), path.join(PH, 'skills', 'software-development', 'strike-*'));
190
+ for (const pat of pats) {
191
+ for (const link of glob(pat)) {
192
+ if (!isLink(link)) continue;
193
+ const target = fs.readlinkSync(link);
194
+ if (/\/\.pensieve\/|\/\.strike\//.test(target)) { rm(link); ok(`removed symlink ${path.basename(link)}`); }
195
+ else warn(`kept ${path.basename(link)} — symlink, but not into a pensieve install`);
196
+ }
197
+ }
198
+ for (const dir of [path.join(PH, 'skills', 'software-development', 'pensieve-*'), path.join(PH, 'skills', 'pensieve'),
199
+ path.join(PH, 'skills', 'software-development', 'strike-*'), path.join(PH, 'skills', 'strike')]) {
200
+ for (const d of glob(dir)) {
201
+ if (ex(d) && !isLink(d)) warn(`kept ${path.basename(d)} — real directory, not created by the installer`);
202
+ }
203
+ }
204
+ }
205
+ for (const h of ['scope-guard.py', 'injection-scan.py']) {
206
+ const p = path.join(PH, 'hooks', h);
207
+ if (ex(p)) { rm(p); ok(`removed ${p}`); }
208
+ }
209
+ const cfg = path.join(PH, 'config.yaml');
210
+ if (ex(cfg) && /scope-guard\.py|injection-scan\.py/.test(fs.readFileSync(cfg, 'utf8'))) {
211
+ stripHermesConfig(cfg, path.join(PH, 'hooks'), BK);
212
+ } else if (ex(cfg)) {
213
+ ok(`no pensieve hook registrations in ${cfg}`);
214
+ }
215
+ const bdir = path.join(PH, 'backups', 'pensieve');
216
+ if (ex(bdir)) { backupTree(BK, bdir); rmrf(bdir); ok(`removed ${bdir}`); }
217
+ }
218
+
219
+ function glob(pattern) {
220
+ const idx = pattern.indexOf('*');
221
+ if (idx < 0) return ex(pattern) ? [pattern] : [];
222
+ const dir = pattern.slice(0, pattern.lastIndexOf('/', idx));
223
+ const rest = pattern.slice(dir.length + 1);
224
+ const [prefix, suffix] = rest.split('*');
225
+ let out = [];
226
+ try {
227
+ for (const name of fs.readdirSync(dir)) {
228
+ if (name.startsWith(prefix) && name.endsWith(suffix)) out.push(path.join(dir, name));
229
+ }
230
+ } catch { /* dir absent */ }
231
+ return out;
232
+ }
233
+
234
+ // --------------------------------------------------------- claude sweep ---
235
+ function sweepClaudeHome(CH, { legacy, BK }) {
236
+ if (!ex(CH)) { ok(`no claude-code home at ${CH}`); return; }
237
+ if (isLink(path.join(CH, 'pensieve'))) { rm(path.join(CH, 'pensieve')); ok(`removed ${CH}/pensieve reference symlink`); }
238
+ for (const d of [path.join(CH, 'commands'), path.join(CH, 'agents')]) {
239
+ let n = 0;
240
+ for (const f of glob(path.join(d, 'pensieve-*.md'))) { rm(f); n += 1; }
241
+ if (n) ok(`removed ${n} pensieve file(s) from ${d}`);
242
+ }
243
+ if (legacy) {
244
+ let n = 0;
245
+ for (const f of [...glob(path.join(CH, 'commands', 'strike-*.md')), ...glob(path.join(CH, 'agents', 'strike-*.md'))]) { rm(f); n += 1; }
246
+ if (n) ok(`removed ${n} legacy STRIKE file(s)`);
247
+ for (const m of ['.strike-installed.json', '.strike-installed.json.bak']) {
248
+ const p = path.join(CH, m); if (ex(p)) { rm(p); ok(`removed ${p}`); }
249
+ }
250
+ for (const d of ['strike', '.strike-backup', 'backups/strike']) {
251
+ const p = path.join(CH, d);
252
+ if (ex(p)) { backupTree(BK, p); rmrf(p); ok(`removed ${p}`); }
253
+ }
254
+ }
255
+ for (const h of ['scope-guard.py', 'injection-scan.py']) {
256
+ const p = path.join(CH, 'hooks', h);
257
+ if (ex(p)) { rm(p); ok(`removed ${p}`); }
258
+ }
259
+ const settings = path.join(CH, 'settings.json');
260
+ if (ex(settings) && /scope-guard\.py|injection-scan\.py/.test(fs.readFileSync(settings, 'utf8'))) {
261
+ stripClaudeSettings(settings, BK);
262
+ } else if (ex(settings)) {
263
+ ok(`no pensieve hook entries in ${settings}`);
264
+ }
265
+ const bdir = path.join(CH, 'backups', 'pensieve');
266
+ if (ex(bdir)) { backupTree(BK, bdir); rmrf(bdir); ok(`removed ${bdir}`); }
267
+ }
268
+
269
+ // ---------------------------------------------------------------- main ---
270
+ function uninstall(HOME, opts = {}) {
271
+ DRY.v = !!opts.dryRun;
272
+ const BK = backupDir(HOME);
273
+ const manifest = loadManifest(HOME);
274
+ say(`uninstall scope: hermes=${opts.hermes ? 'yes' : 'no'} claude=${opts.claude ? 'yes' : 'no'}`
275
+ + `${opts.legacy ? ' +legacy-strike' : ''}${opts.dryRun ? ' [dry run]' : ''}${manifest ? ' (manifest found)' : ' (heuristic sweep)'}`);
276
+
277
+ // 1. registry backup + ~/.pensieve (wide hermes sweep only)
278
+ if (opts.hermes && !opts.profile) {
279
+ const home = pensieveHome(HOME);
280
+ if (ex(home)) {
281
+ backupFile(BK, path.join(home, 'engagements.json'));
282
+ if (opts.noBackup) warn('backups disabled — ~/.pensieve/engagements.json will be lost');
283
+ rmrf(home);
284
+ ok('~/.pensieve removed (registry backed up first)');
285
+ } else ok('~/.pensieve not present');
286
+ } else if (opts.hermes && opts.profile && ex(pensieveHome(HOME))) {
287
+ warn('~/.pensieve kept — shared home; re-run without --profile to remove it');
288
+ }
289
+
290
+ // 2. manifest paths (exact removal of what the npm installer wrote)
291
+ if (manifest && manifest.paths) {
292
+ for (const p of manifest.paths) {
293
+ if (isLink(p) || (ex(p) && fs.statSync(p).isFile())) { rm(p); ok(`removed (manifest) ${p}`); }
294
+ else if (ex(p)) warn(`kept ${p} — real directory, not touched`);
295
+ }
296
+ rm(manifestFile(HOME));
297
+ }
298
+
299
+ // 3. heuristic sweep (v2 semantics) — unioned with the manifest
300
+ if (opts.hermes) {
301
+ if (opts.home) sweepHermesHome(opts.home, { legacy: opts.legacy, BK });
302
+ else if (opts.profile) sweepHermesHome(path.join(HOME, '.hermes', 'profiles', opts.profile), { legacy: opts.legacy, BK });
303
+ else {
304
+ sweepHermesHome(path.join(HOME, '.hermes'), { legacy: opts.legacy, BK });
305
+ const profilesDir = path.join(HOME, '.hermes', 'profiles');
306
+ if (ex(profilesDir)) {
307
+ for (const p of fs.readdirSync(profilesDir).map((n) => path.join(profilesDir, n))) {
308
+ if (ex(p)) sweepHermesHome(p, { legacy: opts.legacy, BK });
309
+ }
310
+ }
311
+ }
312
+ }
313
+ if (opts.claude) sweepClaudeHome(path.join(HOME, '.claude'), { legacy: opts.legacy, BK });
314
+
315
+ // 4. rc PATH strip
316
+ stripRc(HOME, opts.legacy);
317
+
318
+ // 5. legacy ~/.strike
319
+ if (opts.legacy && opts.hermes && !opts.profile) {
320
+ const s = path.join(HOME, '.strike');
321
+ if (ex(s)) { backupFile(BK, path.join(s, 'engagements.json')); rmrf(s); ok('~/.strike (legacy STRIKE install) removed'); }
322
+ else ok('~/.strike not present');
323
+ } else if (ex(path.join(HOME, '.strike'))) {
324
+ warn('~/.strike (legacy install) kept — pass --legacy-strike to remove it');
325
+ }
326
+
327
+ // 6. docker image
328
+ if (opts.purgeImage) {
329
+ const insp = spawnSync('docker', ['image', 'inspect', 'pensieve-toolbox:local'], { encoding: 'utf8' });
330
+ if (insp.status === 0) {
331
+ if (DRY.v) say('DRY: docker rmi pensieve-toolbox:local'); else spawnSync('docker', ['rmi', 'pensieve-toolbox:local'], { stdio: 'inherit' });
332
+ ok('pensieve-toolbox:local image removed');
333
+ } else ok('image not present (or docker unavailable)');
334
+ }
335
+
336
+ say('');
337
+ say('done. never touched: engagement directories, real skill directories, foreign hooks/settings entries,');
338
+ say(`and the docker image (unless --purge-image). backups${opts.dryRun ? ' (dry run / none)' : ` at ${BK}`}.`);
339
+ say('reinstall any time: npx @abdulr7man/pensieve');
340
+ }
341
+
342
+ module.exports = { uninstall };