@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.
- package/LICENSE +684 -0
- package/README.md +180 -2
- package/VERSION +1 -0
- package/agents/README.md +16 -0
- package/agents/pensieve-code-auditor.md +58 -0
- package/agents/pensieve-mapper.md +46 -0
- package/agents/pensieve-planner.md +67 -0
- package/agents/pensieve-reconner.md +76 -0
- package/agents/pensieve-reporter.md +61 -0
- package/agents/pensieve-roe-checker.md +46 -0
- package/agents/pensieve-scoper.md +77 -0
- package/agents/pensieve-tester.md +83 -0
- package/agents/pensieve-validator.md +62 -0
- package/bin/pensieve +452 -0
- package/bin/pensieve-installer.cjs +5 -0
- package/commands/pensieve-close.md +6 -0
- package/commands/pensieve-map.md +6 -0
- package/commands/pensieve-new-engagement.md +6 -0
- package/commands/pensieve-pause.md +15 -0
- package/commands/pensieve-plan.md +6 -0
- package/commands/pensieve-progress.md +34 -0
- package/commands/pensieve-quick.md +8 -0
- package/commands/pensieve-recon.md +6 -0
- package/commands/pensieve-report.md +6 -0
- package/commands/pensieve-resume.md +6 -0
- package/commands/pensieve-retest.md +10 -0
- package/commands/pensieve-scope.md +49 -0
- package/commands/pensieve-surface.md +8 -0
- package/commands/pensieve-test.md +6 -0
- package/commands/pensieve-validate.md +6 -0
- package/docker/Dockerfile.pensieve-toolbox +75 -0
- package/docker/compose.pensieve-net.yml +37 -0
- package/docker/squid.conf.template +21 -0
- package/package.json +39 -4
- package/packs/ad/ad-killchain/checklist.md +64 -0
- package/packs/ad/ad-killchain/pack.yaml +19 -0
- package/packs/cloud/cloud-cis/checklist.md +66 -0
- package/packs/cloud/cloud-cis/pack.yaml +20 -0
- package/packs/fintech/practice-core/checklist.md +33 -0
- package/packs/fintech/practice-core/learnings.md +5 -0
- package/packs/fintech/practice-core/pack.yaml +18 -0
- package/packs/infra/ptes-infra/checklist.md +22 -0
- package/packs/infra/ptes-infra/pack.yaml +19 -0
- package/packs/mobile/owasp-masvs/checklist.md +80 -0
- package/packs/mobile/owasp-masvs/pack.yaml +20 -0
- package/packs/owasp-api-v4/checklist.md +85 -0
- package/packs/owasp-api-v4/learnings.md +6 -0
- package/packs/owasp-api-v4/pack.yaml +23 -0
- package/packs/owasp-api-v4/runbooks/API1/SKILL.md +66 -0
- package/packs/owasp-api-v4/runbooks/API10/SKILL.md +67 -0
- package/packs/owasp-api-v4/runbooks/API2/SKILL.md +129 -0
- package/packs/owasp-api-v4/runbooks/API3/SKILL.md +55 -0
- package/packs/owasp-api-v4/runbooks/API4/SKILL.md +59 -0
- package/packs/owasp-api-v4/runbooks/API5/SKILL.md +60 -0
- package/packs/owasp-api-v4/runbooks/API6/SKILL.md +63 -0
- package/packs/owasp-api-v4/runbooks/API7/SKILL.md +70 -0
- package/packs/owasp-api-v4/runbooks/API8/SKILL.md +72 -0
- package/packs/owasp-api-v4/runbooks/API9/SKILL.md +66 -0
- package/packs/thickclient/thickclient-core/checklist.md +60 -0
- package/packs/thickclient/thickclient-core/pack.yaml +24 -0
- package/packs/web/asvs-l2/checklist.md +50 -0
- package/packs/web/asvs-l2/learnings.md +6 -0
- package/packs/web/asvs-l2/pack.yaml +19 -0
- package/packs/web/asvs-l2/runbooks/V2-AUTH-ENUM/SKILL.md +75 -0
- package/packs/web/asvs-l2/runbooks/V2-AUTH-LIVE/SKILL.md +78 -0
- package/packs/web/asvs-l2/runbooks/V2-AUTH-MFA/SKILL.md +76 -0
- package/packs/web/asvs-l2/runbooks/V2-AUTH-RATE/SKILL.md +72 -0
- package/packs/web/owasp-testing-checklist/checklist.md +52 -0
- package/packs/web/owasp-testing-checklist/learnings.md +47 -0
- package/packs/web/owasp-testing-checklist/pack.yaml +21 -0
- package/packs/web/unauth-perimeter/checklist.md +72 -0
- package/packs/web/unauth-perimeter/pack.yaml +18 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-01/SKILL.md +60 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-02/SKILL.md +63 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-03/SKILL.md +62 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-04/SKILL.md +75 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-05/SKILL.md +66 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-06/SKILL.md +59 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-07/SKILL.md +56 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-08/SKILL.md +57 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-09/SKILL.md +62 -0
- package/packs/web/unauth-perimeter/runbooks/PERIM-10/SKILL.md +60 -0
- package/packs/whitebox/code-audit-core/checklist.md +36 -0
- package/packs/whitebox/code-audit-core/learnings.md +6 -0
- package/packs/whitebox/code-audit-core/pack.yaml +14 -0
- package/prompts/orchestrator-core.md +52 -0
- package/reference/attack-playbooks.md +57 -0
- package/reference/otp-relay.md +98 -0
- package/reference/param-profiles.md +48 -0
- package/reference/templates/FINDING.md +97 -0
- package/reference/tool-selection.md +64 -0
- package/reference/vulnerability-finding-standard.md +80 -0
- package/runtimes/hermes/hooks/injection-scan.py +290 -0
- package/runtimes/hermes/hooks/scope-guard.py +136 -0
- package/skills/pensieve/SKILL.md +134 -0
- package/skills/pensieve-close/SKILL.md +31 -0
- package/skills/pensieve-map/SKILL.md +25 -0
- package/skills/pensieve-new-engagement/SKILL.md +28 -0
- package/skills/pensieve-pause/SKILL.md +22 -0
- package/skills/pensieve-plan/SKILL.md +39 -0
- package/skills/pensieve-progress/SKILL.md +35 -0
- package/skills/pensieve-quick/SKILL.md +47 -0
- package/skills/pensieve-recon/SKILL.md +30 -0
- package/skills/pensieve-report/SKILL.md +46 -0
- package/skills/pensieve-resume/SKILL.md +33 -0
- package/skills/pensieve-retest/SKILL.md +35 -0
- package/skills/pensieve-scope/SKILL.md +35 -0
- package/skills/pensieve-surface/SKILL.md +36 -0
- package/skills/pensieve-test/SKILL.md +35 -0
- package/skills/pensieve-validate/SKILL.md +28 -0
- package/skills/pensieve-wiki/SKILL.md +39 -0
- package/src/installer/cli.cjs +209 -0
- package/src/installer/home.cjs +155 -0
- package/src/installer/runtimes.cjs +276 -0
- package/src/installer/uninstall.cjs +342 -0
- package/src/pensieve-sdk/bin/pensieve-sdk.cjs +1045 -0
- package/src/pensieve-sdk/lib/agent-translate.cjs +50 -0
- package/src/pensieve-sdk/lib/approvals.cjs +408 -0
- package/src/pensieve-sdk/lib/audit.cjs +290 -0
- package/src/pensieve-sdk/lib/checklist.cjs +337 -0
- package/src/pensieve-sdk/lib/clientlist.cjs +814 -0
- package/src/pensieve-sdk/lib/close.cjs +133 -0
- package/src/pensieve-sdk/lib/config.cjs +156 -0
- package/src/pensieve-sdk/lib/cvss.cjs +91 -0
- package/src/pensieve-sdk/lib/env.cjs +272 -0
- package/src/pensieve-sdk/lib/evidence.cjs +217 -0
- package/src/pensieve-sdk/lib/findings.cjs +1096 -0
- package/src/pensieve-sdk/lib/frontmatter.cjs +178 -0
- package/src/pensieve-sdk/lib/graph.cjs +607 -0
- package/src/pensieve-sdk/lib/ids.cjs +63 -0
- package/src/pensieve-sdk/lib/init.cjs +79 -0
- package/src/pensieve-sdk/lib/liveness.cjs +176 -0
- package/src/pensieve-sdk/lib/loop.cjs +619 -0
- package/src/pensieve-sdk/lib/migrate.cjs +57 -0
- package/src/pensieve-sdk/lib/monitor.cjs +69 -0
- package/src/pensieve-sdk/lib/pack.cjs +607 -0
- package/src/pensieve-sdk/lib/paths.cjs +73 -0
- package/src/pensieve-sdk/lib/pdf.cjs +291 -0
- package/src/pensieve-sdk/lib/recon.cjs +296 -0
- package/src/pensieve-sdk/lib/renderers/__pycache__/formal_report.cpython-314.pyc +0 -0
- package/src/pensieve-sdk/lib/renderers/formal_report.py +608 -0
- package/src/pensieve-sdk/lib/report.cjs +1135 -0
- package/src/pensieve-sdk/lib/runbook.cjs +124 -0
- package/src/pensieve-sdk/lib/sarif.cjs +154 -0
- package/src/pensieve-sdk/lib/scope.cjs +621 -0
- package/src/pensieve-sdk/lib/security.cjs +61 -0
- package/src/pensieve-sdk/lib/skills.cjs +193 -0
- package/src/pensieve-sdk/lib/state.cjs +610 -0
- package/src/pensieve-sdk/lib/subagent.cjs +658 -0
- package/src/pensieve-sdk/lib/target.cjs +149 -0
- package/src/pensieve-sdk/lib/tools.cjs +66 -0
- package/src/pensieve-sdk/lib/vault.cjs +122 -0
- package/src/pensieve-sdk/lib/vendor/cvss40.LICENSE +22 -0
- package/src/pensieve-sdk/lib/vendor/cvss40.js +1208 -0
- package/src/pensieve-sdk/package.json +11 -0
- package/templates/ACCOUNTS.md +35 -0
- package/templates/ATTACK-SURFACE.md +30 -0
- package/templates/FINDING.md +43 -0
- package/templates/PLAN.md +33 -0
- package/templates/PROJECT.md +29 -0
- package/templates/ROE.md +50 -0
- package/templates/RUN-LOG.md +19 -0
- package/templates/SCOPE.md +32 -0
- package/templates/VALIDATION.md +62 -0
- package/templates/report/REPORT.md +49 -0
- package/workflows/close.md +34 -0
- package/workflows/map.md +39 -0
- package/workflows/new-engagement.md +37 -0
- package/workflows/plan.md +45 -0
- package/workflows/progress.md +28 -0
- package/workflows/quick.md +67 -0
- package/workflows/recon.md +87 -0
- package/workflows/report.md +51 -0
- package/workflows/resume.md +26 -0
- package/workflows/retest.md +53 -0
- package/workflows/scope.md +47 -0
- package/workflows/surface.md +29 -0
- package/workflows/test.md +95 -0
- package/workflows/validate.md +34 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-scope
|
|
3
|
+
description: "Scoping interview → scope package → HUMAN CHECKPOINT → enforcement artifacts."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: AGPL-3.0-only
|
|
6
|
+
platforms: [linux]
|
|
7
|
+
metadata:
|
|
8
|
+
hermes:
|
|
9
|
+
tags: [pensieve, pentest, command]
|
|
10
|
+
category: software-development
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /pensieve-scope
|
|
14
|
+
|
|
15
|
+
Agent: pensieve-scoper (agents/pensieve-scoper.md — follow it exactly).
|
|
16
|
+
|
|
17
|
+
1. scoper interview → SCOPE.md / ROE.md / PROJECT.md / ACCOUNTS.md complete.
|
|
18
|
+
2. `## SCOPE READY FOR APPROVAL` → **HUMAN CHECKPOINT**: the human reads and
|
|
19
|
+
explicitly approves. Changes → scoper revises, re-present.
|
|
20
|
+
3. On approval:
|
|
21
|
+
- record the checkpoint: `pensieve-sdk approve --engagement <dir>
|
|
22
|
+
--artifact scope --by <name>` (ADR-023 — set-status refuses
|
|
23
|
+
scoped → recon without it)
|
|
24
|
+
- `pensieve-sdk state.set-status --engagement <dir> scoped`
|
|
25
|
+
- `pensieve-sdk env.render --engagement <dir>` → writes env/ at the
|
|
26
|
+
engagement root (allowlist,
|
|
27
|
+
squid.conf, compose) — the enforcement artifacts DERIVED from SCOPE.md
|
|
28
|
+
- run the pensieve-roe-checker (agents/pensieve-roe-checker.md); a FAILED
|
|
29
|
+
check returns to the human with the blocker list
|
|
30
|
+
4. Report the derived containment: allowlisted hosts + safe ports.
|
|
31
|
+
|
|
32
|
+
success_criteria:
|
|
33
|
+
- scope approval recorded as SCOPE.md frontmatter (approve --artifact scope)
|
|
34
|
+
- env/allowlist.txt exists and matches SCOPE.md hosts
|
|
35
|
+
- roe check PASSED
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-surface
|
|
3
|
+
description: "List, enable, or disable methodology packs for this engagement."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: AGPL-3.0-only
|
|
6
|
+
platforms: [linux]
|
|
7
|
+
metadata:
|
|
8
|
+
hermes:
|
|
9
|
+
tags: [pensieve, pentest, command]
|
|
10
|
+
category: software-development
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Surface — methodology pack management (per engagement)
|
|
14
|
+
|
|
15
|
+
Packs are per-engagement (ADR-014): enabling one never reinstalls PENSIEVE and
|
|
16
|
+
never touches other engagements. All state lives in the engagement's
|
|
17
|
+
config.yaml (`enabled_packs`).
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
1. SHOW the current surface — run:
|
|
22
|
+
- `pensieve-sdk pack.enabled --engagement <dir>`
|
|
23
|
+
- `pensieve-sdk pack.list`
|
|
24
|
+
Present: enabled packs, available packs (one line each: slug — name).
|
|
25
|
+
|
|
26
|
+
2. APPLY the user's instruction:
|
|
27
|
+
- enable: `pensieve-sdk pack.enable --engagement <dir> <slug>`
|
|
28
|
+
(invalid slug → sdk errors; show pack.list again and stop)
|
|
29
|
+
- disable: `pensieve-sdk pack.disable --engagement <dir> <slug>`
|
|
30
|
+
- bare /pensieve-surface with no instruction → stop after step 1.
|
|
31
|
+
|
|
32
|
+
3. TOOL DELTA on enable — run `pensieve-sdk tools.check --engagement <dir>
|
|
33
|
+
--pack <slug>`. If it returns tools needing install, present the plan and
|
|
34
|
+
defer to the plan workflow's provisioning gate (never install here).
|
|
35
|
+
|
|
36
|
+
4. CONFIRM — re-run pack.enabled and print the new surface in one line.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-test
|
|
3
|
+
description: "Execute approved plans (one agent run per plan) → draft findings with evidence."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: AGPL-3.0-only
|
|
6
|
+
platforms: [linux]
|
|
7
|
+
metadata:
|
|
8
|
+
hermes:
|
|
9
|
+
tags: [pensieve, pentest, command]
|
|
10
|
+
category: software-development
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /pensieve-test
|
|
14
|
+
|
|
15
|
+
Agent: pensieve-tester (agents/pensieve-tester.md) — one run PER PLAN.
|
|
16
|
+
|
|
17
|
+
1. Preconditions: status=planned, env up (re-check containment self-check);
|
|
18
|
+
tester maps PROJECT.md intensity to a reference/param-profiles.md profile
|
|
19
|
+
before the first command.
|
|
20
|
+
2. For each approved plan, in plan order:
|
|
21
|
+
- spawn a fresh tester run with the plan as its contract (fresh context
|
|
22
|
+
per plan — tester reads only what its contract lists)
|
|
23
|
+
- collect `## TEST RUN COMPLETE` markers; tripwires → surface to human
|
|
24
|
+
2b. WAF watch (ADR-017): after EACH plan run, `pensieve-sdk monitor.scan
|
|
25
|
+
--engagement <dir>`. Any alert → throttle (lower concurrency, add delay),
|
|
26
|
+
note it in the run log; a `waf_blocking` alert → pause that lane and
|
|
27
|
+
surface to the human (continuing burns the source IP and poisons results).
|
|
28
|
+
3. After all plans: `pensieve-sdk state.set-status --engagement <dir> testing` →
|
|
29
|
+
print the draft findings list (`pensieve-sdk findings.list --engagement <dir>
|
|
30
|
+
--status draft`).
|
|
31
|
+
|
|
32
|
+
success_criteria:
|
|
33
|
+
- every plan has a runs/RUN-*.md with complete log + marked checklist
|
|
34
|
+
- every registered finding has ≥1 evidence id
|
|
35
|
+
- tripwires surfaced, none silently expanded
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-validate
|
|
3
|
+
description: "Independent replay of every draft finding → validated/rejected."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: AGPL-3.0-only
|
|
6
|
+
platforms: [linux]
|
|
7
|
+
metadata:
|
|
8
|
+
hermes:
|
|
9
|
+
tags: [pensieve, pentest, command]
|
|
10
|
+
category: software-development
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /pensieve-validate
|
|
14
|
+
|
|
15
|
+
Agent: pensieve-validator (agents/pensieve-validator.md) — one validation PER
|
|
16
|
+
FINDING, and never the same run that produced the finding.
|
|
17
|
+
|
|
18
|
+
1. `pensieve-sdk findings.list --engagement <dir> --status draft` → work queue.
|
|
19
|
+
2. Per finding: validator protocol → VALIDATION-<id>.md + status flip.
|
|
20
|
+
3. `## HUMAN NEEDED` items pause that finding only; continue the queue.
|
|
21
|
+
4. End: print the gate (`pensieve-sdk findings.gate --engagement <dir>`) —
|
|
22
|
+
validated / rejected / unresolved lists.
|
|
23
|
+
5. `pensieve-sdk state.set-status --engagement <dir> validating`.
|
|
24
|
+
|
|
25
|
+
success_criteria:
|
|
26
|
+
- zero findings remain `draft` OR unresolved ones are human-flagged
|
|
27
|
+
- every validated finding has a VALIDATION-<id>.md with replay steps
|
|
28
|
+
- template-able web/API findings carry a Nuclei artifact in evidence/
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-wiki
|
|
3
|
+
description: "Query the interlinked pentesting knowledge wiki built from the hacktricks corpus (~/wiki) and cite raw sources."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: AGPL-3.0-only
|
|
6
|
+
platforms: [linux]
|
|
7
|
+
metadata:
|
|
8
|
+
hermes:
|
|
9
|
+
tags: [pensieve, pentest, command, knowledge]
|
|
10
|
+
category: software-development
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /pensieve-wiki
|
|
14
|
+
|
|
15
|
+
Agent: orchestrator-core (prompts/orchestrator-core.md).
|
|
16
|
+
|
|
17
|
+
The knowledge base lives at `~/wiki` (env `WIKI_DIR` to override). It is an
|
|
18
|
+
interlinked markdown wiki: `index.md` → category pages → subtopic pages →
|
|
19
|
+
`raw/` (symlink to the hacktricks corpus, the immutable source of truth).
|
|
20
|
+
|
|
21
|
+
1. **Orient** — read `~/wiki/index.md` to see the category catalogue.
|
|
22
|
+
2. **Walk the graph** — `[[wikilinks]]` connect a subtopic to its parent
|
|
23
|
+
category and sibling subtopics. Start at the category page, drill to the
|
|
24
|
+
subtopic that names the technique, then open the linked files.
|
|
25
|
+
3. **Answer from the corpus** — every claim must cite a `raw/...` source. The
|
|
26
|
+
`sources:` field on each page lists the backing technique notes; open them
|
|
27
|
+
in `raw/` for full technique detail (the pages are summaries, not the
|
|
28
|
+
techniques themselves).
|
|
29
|
+
4. **Rebuild** — after corpus changes, run `pensieve wiki --all` (fast,
|
|
30
|
+
deterministic, lint-clean). For curated LLM synthesis of a small set:
|
|
31
|
+
`pensieve wiki --categories <cat> --llm on`.
|
|
32
|
+
5. **Fresh questions** — if no page covers the topic, search the corpus with
|
|
33
|
+
`grep -rn '<term>' ~/wiki/raw` and note the gap in `~/wiki/log.md`.
|
|
34
|
+
|
|
35
|
+
success_criteria:
|
|
36
|
+
- every answer cites at least one `raw/` source
|
|
37
|
+
- answer is grounded in the corpus, not invented
|
|
38
|
+
- `index.md` lists the current categories
|
|
39
|
+
- wiki is lint-clean (no broken `[[wikilinks]]`)
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* cli.cjs — NPX-02 (v1.2): the installer's UX — GSD-style interactive
|
|
4
|
+
* runtime picker (detection badges; one, several, or all), global/local,
|
|
5
|
+
* flags for CI and tests (--hermes --claude --codex --opencode --cursor
|
|
6
|
+
* --gemini --all), --uninstall in the same bin, --dry-run, --profile.
|
|
7
|
+
*/
|
|
8
|
+
const fs = require('node:fs');
|
|
9
|
+
const path = require('node:path');
|
|
10
|
+
const os = require('node:os');
|
|
11
|
+
const readline = require('node:readline');
|
|
12
|
+
const home = require('./home.cjs');
|
|
13
|
+
const { wireHermes, wireClaude, wireThin, THIN, which } = require('./runtimes.cjs');
|
|
14
|
+
const { uninstall } = require('./uninstall.cjs');
|
|
15
|
+
|
|
16
|
+
const VERSION = (() => {
|
|
17
|
+
try { return fs.readFileSync(path.join(home.ROOT, 'VERSION'), 'utf8').trim(); } catch { return 'dev'; }
|
|
18
|
+
})();
|
|
19
|
+
|
|
20
|
+
const FULL_RUNTIMES = {
|
|
21
|
+
hermes: { label: 'Hermes Agent', detect: () => which('hermes') },
|
|
22
|
+
claude: { label: 'Claude Code', detect: () => which('claude') },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// GSD-parity picker (checked against get-shit-done-cc's promptRuntime):
|
|
26
|
+
// numbered options with their target homes, a numbered All, multi-select
|
|
27
|
+
// hint, a default in the prompt, graceful Ctrl-D cancel, and PURE prompt
|
|
28
|
+
// builders/parsers exported for tests.
|
|
29
|
+
const RUNTIME_ORDER = ['hermes', 'claude', 'codex', 'opencode', 'cursor', 'gemini'];
|
|
30
|
+
const HOME_PREVIEW = {
|
|
31
|
+
hermes: '~/.hermes', claude: '~/.claude', codex: '~/.codex',
|
|
32
|
+
opencode: '~/.config/opencode', cursor: '~/.cursor', gemini: '~/.gemini',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function runtimeEntries() {
|
|
36
|
+
const meta = { ...FULL_RUNTIMES, ...THIN };
|
|
37
|
+
return RUNTIME_ORDER
|
|
38
|
+
.filter((id) => meta[id])
|
|
39
|
+
.map((id) => ({ id, label: meta[id].label, home: HOME_PREVIEW[id], detected: meta[id].detect ? meta[id].detect() : false }));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function buildRuntimePromptText(entries) {
|
|
43
|
+
const detected = entries.filter((e) => e.detected);
|
|
44
|
+
const lines = ['', ' Which runtime(s) would you like to install for?', ''];
|
|
45
|
+
entries.forEach((e, i) => {
|
|
46
|
+
lines.push(` ${i + 1}) ${e.label.padEnd(14)} ${e.detected ? '[detected] ' : ' '}${HOME_PREVIEW[e.id]}`);
|
|
47
|
+
});
|
|
48
|
+
lines.push(` ${entries.length + 1}) All${detected.length ? ` (detected: ${detected.map((d) => d.label).join(', ')})` : ''}`);
|
|
49
|
+
lines.push('');
|
|
50
|
+
lines.push(' Select multiple: 1,2 or 1 2');
|
|
51
|
+
lines.push('');
|
|
52
|
+
return lines.join('\n');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Pure input parser (GSD's parseRuntimeInput shape, our all-detected default). */
|
|
56
|
+
function parseRuntimeInput(answer, entries) {
|
|
57
|
+
const detected = entries.filter((e) => e.detected).map((e) => e.id);
|
|
58
|
+
const allOption = String(entries.length + 1);
|
|
59
|
+
const input = (answer == null ? '' : String(answer)).trim();
|
|
60
|
+
if (!input) return detected; // enter = all detected
|
|
61
|
+
const choices = input.split(/[\s,]+/).filter(Boolean);
|
|
62
|
+
if (choices.includes(allOption) || input.toLowerCase() === 'all') return detected;
|
|
63
|
+
const selected = [];
|
|
64
|
+
for (const c of choices) {
|
|
65
|
+
const n = parseInt(c, 10);
|
|
66
|
+
const e = Number.isInteger(n) && n >= 1 && n <= entries.length ? entries[n - 1] : null;
|
|
67
|
+
if (e && !selected.includes(e.id)) selected.push(e.id);
|
|
68
|
+
}
|
|
69
|
+
return selected; // [] = invalid → caller re-asks
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function parseArgs(argv) {
|
|
73
|
+
const o = { runtimes: [], profile: '', local: false, uninstall: false, dryRun: false, home: '', help: false };
|
|
74
|
+
for (let i = 0; i < argv.length; i++) {
|
|
75
|
+
const a = argv[i];
|
|
76
|
+
if (a === '--hermes' || a === '--claude' || a === '--codex' || a === '--opencode' || a === '--cursor' || a === '--gemini') {
|
|
77
|
+
o.runtimes.push(a.slice(2));
|
|
78
|
+
} else if (a === '--all') o.all = true;
|
|
79
|
+
else if (a === '-g' || a === '--global') o.local = false;
|
|
80
|
+
else if (a === '-l' || a === '--local') o.local = true;
|
|
81
|
+
else if (a === '-u' || a === '--uninstall') o.uninstall = true;
|
|
82
|
+
else if (a === '--dry-run') o.dryRun = true;
|
|
83
|
+
else if (a === '--legacy-strike') o.legacy = true;
|
|
84
|
+
else if (a === '--purge-image') o.purgeImage = true;
|
|
85
|
+
else if (a === '--no-backup') o.noBackup = true;
|
|
86
|
+
else if (a === '--home') o.home = argv[++i];
|
|
87
|
+
else if (a === '--profile') o.profile = argv[++i];
|
|
88
|
+
else if (a === '-h' || a === '--help') o.help = true;
|
|
89
|
+
else { console.error(`unknown flag: ${a}`); process.exit(2); }
|
|
90
|
+
}
|
|
91
|
+
return o;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function help() {
|
|
95
|
+
console.log(`PENSIEVE ${VERSION} — installer / uninstaller (npx @abdulr7man/pensieve)
|
|
96
|
+
|
|
97
|
+
Usage: npx @abdulr7man/pensieve [options]
|
|
98
|
+
|
|
99
|
+
Runtime (interactive picker when omitted; --all = all detected):
|
|
100
|
+
--hermes Hermes Agent (full wiring: skills, hooks, config surgery)
|
|
101
|
+
--claude Claude Code (full wiring: commands, agents, hooks, settings)
|
|
102
|
+
--codex OpenAI Codex (markdown wiring)
|
|
103
|
+
--opencode OpenCode (markdown wiring)
|
|
104
|
+
--cursor Cursor (markdown wiring)
|
|
105
|
+
--gemini Gemini CLI (markdown wiring, TOML commands)
|
|
106
|
+
--all every runtime detected on this machine
|
|
107
|
+
|
|
108
|
+
Scope: -g/--global (default) | -l/--local (this project's ./.hermes / ./.claude)
|
|
109
|
+
Hermes: --profile <name> install into that profile (never defaulted)
|
|
110
|
+
Other: -u/--uninstall | --legacy-strike | --purge-image | --no-backup
|
|
111
|
+
--dry-run | --home <dir> | -h/--help
|
|
112
|
+
|
|
113
|
+
Examples:
|
|
114
|
+
npx @abdulr7man/pensieve # interactive: pick runtime(s)
|
|
115
|
+
npx @abdulr7man/pensieve --hermes # Hermes, global
|
|
116
|
+
npx @abdulr7man/pensieve --claude -l # Claude Code, this project only
|
|
117
|
+
npx @abdulr7man/pensieve --all # everything detected
|
|
118
|
+
npx @abdulr7man/pensieve --uninstall # the inverse of all of it`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Interactive picker — GSD-parity: question, numbered options, multi-select,
|
|
122
|
+
* default in the prompt, graceful Ctrl-D cancel. Non-TTY: all detected. */
|
|
123
|
+
async function pickRuntimes() {
|
|
124
|
+
const entries = runtimeEntries();
|
|
125
|
+
const detected = entries.filter((e) => e.detected);
|
|
126
|
+
console.log(buildRuntimePromptText(entries));
|
|
127
|
+
if (!process.stdin.isTTY) {
|
|
128
|
+
console.log(' no TTY — installing for every DETECTED runtime (pass --hermes/--claude/... to pin)\n');
|
|
129
|
+
return detected.map((d) => d.id);
|
|
130
|
+
}
|
|
131
|
+
for (;;) {
|
|
132
|
+
const answer = await new Promise((resolve) => {
|
|
133
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
134
|
+
let answered = false;
|
|
135
|
+
rl.on('close', () => {
|
|
136
|
+
if (!answered) { answered = true; console.log('\n Installation cancelled\n'); process.exit(0); }
|
|
137
|
+
});
|
|
138
|
+
rl.question(` Choice [${detected.length ? 'all detected' : '1'}]: `, (a) => { answered = true; rl.close(); resolve(a); });
|
|
139
|
+
});
|
|
140
|
+
const picks = parseRuntimeInput(answer, entries);
|
|
141
|
+
if (picks.length) return picks;
|
|
142
|
+
console.log(' no valid selection — try 1, 1,2, or the All option');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function main() {
|
|
147
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
148
|
+
if (opts.help) { help(); return; }
|
|
149
|
+
|
|
150
|
+
const HOME = opts.home ? path.resolve(opts.home) : os.homedir();
|
|
151
|
+
|
|
152
|
+
if (opts.uninstall) {
|
|
153
|
+
const scope = opts.runtimes.length ? opts.runtimes : ['hermes', 'claude'];
|
|
154
|
+
uninstall(HOME, {
|
|
155
|
+
hermes: scope.includes('hermes'), claude: scope.includes('claude'),
|
|
156
|
+
profile: opts.profile, legacy: opts.legacy, purgeImage: opts.purgeImage,
|
|
157
|
+
noBackup: opts.noBackup, dryRun: opts.dryRun, home: opts.local ? path.join(process.cwd(), '.hermes') : '',
|
|
158
|
+
});
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
console.log(`\n PENSIEVE ${VERSION} — installer\n`);
|
|
163
|
+
|
|
164
|
+
let runtimes = opts.runtimes;
|
|
165
|
+
if (!runtimes.length) runtimes = await pickRuntimes();
|
|
166
|
+
if (opts.all) runtimes = Object.keys({ ...FULL_RUNTIMES, ...THIN }).filter((id) => (FULL_RUNTIMES[id] || THIN[id]).detect());
|
|
167
|
+
if (!runtimes.length) {
|
|
168
|
+
console.error('no runtime selected/detected — pass --hermes, --claude, --codex, --opencode, --cursor, --gemini, or --all');
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
console.log(` runtimes: ${runtimes.join(', ')} scope: ${opts.local ? 'local' : 'global'} home: ${HOME}\n`);
|
|
172
|
+
|
|
173
|
+
if (opts.dryRun) {
|
|
174
|
+
console.log(' DRY: would preflight + build toolbox + write ~/.pensieve + wire the runtimes above');
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
home.preflight();
|
|
178
|
+
|
|
179
|
+
home.toolbox(HOME, (m) => console.log(' ' + m));
|
|
180
|
+
const shared = home.buildSharedHome(HOME, { version: VERSION, log: (m) => console.log(' ✔ ' + m) });
|
|
181
|
+
const manifest = home.newManifest(VERSION);
|
|
182
|
+
|
|
183
|
+
const results = [];
|
|
184
|
+
for (const id of runtimes) {
|
|
185
|
+
try {
|
|
186
|
+
if (id === 'hermes') {
|
|
187
|
+
const base = opts.local ? path.join(process.cwd(), '.hermes') : path.join(HOME, '.hermes');
|
|
188
|
+
results.push(wireHermes(HOME, { base, profile: opts.profile, skillsDir: shared.skillsDir, manifest, log: (m) => console.log(' ✔ ' + m) }));
|
|
189
|
+
} else if (id === 'claude') {
|
|
190
|
+
results.push(wireClaude(HOME, { skillsDir: shared.skillsDir, manifest, log: (m) => console.log(' ✔ ' + m) }));
|
|
191
|
+
} else {
|
|
192
|
+
results.push(wireThin(HOME, id, { skillsDir: shared.skillsDir, manifest, log: (m) => console.log(' ✔ ' + m) }));
|
|
193
|
+
}
|
|
194
|
+
} catch (e) {
|
|
195
|
+
console.error(` ✘ ${id}: ${e.message}`);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
manifest.runtimes = results;
|
|
200
|
+
home.saveManifest(HOME, manifest);
|
|
201
|
+
|
|
202
|
+
console.log(`\n == PENSIEVE ${VERSION} installed (${runtimes.join(', ')}, ${opts.local ? 'local' : 'global'} scope)\n`);
|
|
203
|
+
if (runtimes.includes('hermes')) console.log(` ${opts.profile ? `hermes -p ${opts.profile}` : 'hermes'} → /pensieve-new-engagement`);
|
|
204
|
+
if (runtimes.includes('claude')) console.log(' claude (in an engagement dir) → /pensieve-new-engagement');
|
|
205
|
+
console.log(' to uninstall: npx @abdulr7man/pensieve --uninstall\n');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
module.exports = { main, parseArgs, pickRuntimes, buildRuntimePromptText, parseRuntimeInput, runtimeEntries, VERSION };
|
|
209
|
+
if (require.main === module) main();
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* home.cjs — NPX-01 (v1.2): the self-contained ~/.pensieve shared home.
|
|
4
|
+
*
|
|
5
|
+
* Ported from install.sh's ~/.pensieve section with ONE structural change:
|
|
6
|
+
* SELF-CONTAINED. The .sh installer symlinked pensieve-sdk into the source
|
|
7
|
+
* checkout — fine for a git clone, dangling the moment an npx cache is
|
|
8
|
+
* pruned. The npm installer COPIES the (zero-dependency) SDK into
|
|
9
|
+
* ~/.pensieve so the install never references the package that produced it.
|
|
10
|
+
*
|
|
11
|
+
* Every path written OUTSIDE ~/.pensieve is recorded in the manifest
|
|
12
|
+
* (INSTALL-MANIFEST.json) — the uninstall's authoritative removal list.
|
|
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
|
+
|
|
19
|
+
const ROOT = path.resolve(__dirname, '..', '..'); // npm package root = repo layout
|
|
20
|
+
|
|
21
|
+
function pensieveHome(HOME) {
|
|
22
|
+
return path.join(HOME || os.homedir(), '.pensieve');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function manifestFile(HOME) {
|
|
26
|
+
return path.join(pensieveHome(HOME), 'INSTALL-MANIFEST.json');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function loadManifest(HOME) {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(fs.readFileSync(manifestFile(HOME), 'utf8'));
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function saveManifest(HOME, manifest) {
|
|
38
|
+
fs.mkdirSync(pensieveHome(HOME), { recursive: true });
|
|
39
|
+
fs.writeFileSync(manifestFile(HOME), JSON.stringify(manifest, null, 2) + '\n');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function newManifest(version) {
|
|
43
|
+
return {
|
|
44
|
+
package: '@abdulr7man/pensieve',
|
|
45
|
+
version,
|
|
46
|
+
installed_at: new Date().toISOString(),
|
|
47
|
+
runtimes: {},
|
|
48
|
+
paths: [], // every path written OUTSIDE ~/.pensieve (uninstall removes these)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function record(manifest, p) {
|
|
53
|
+
if (!manifest.paths.includes(p)) manifest.paths.push(p);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function copyDir(src, dst) {
|
|
57
|
+
fs.mkdirSync(dst, { recursive: true });
|
|
58
|
+
fs.cpSync(src, dst, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Preflight: node is running; verify python3 + docker with clear deaths. */
|
|
62
|
+
function preflight() {
|
|
63
|
+
for (const tool of ['python3', 'docker']) {
|
|
64
|
+
const r = spawnSync(tool, ['--version'], { encoding: 'utf8' });
|
|
65
|
+
if (r.error || r.status !== 0) {
|
|
66
|
+
throw new Error(`${tool} not found — PENSIEVE needs it ${tool === 'docker' ? 'for the contained toolbox' : 'for hook/settings wiring'}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Toolbox image: reuse if present, build once if missing (INSTALL-03 port). */
|
|
72
|
+
function toolbox(HOME, log) {
|
|
73
|
+
const inspect = spawnSync('docker', ['image', 'inspect', 'pensieve-toolbox:local'], { encoding: 'utf8' });
|
|
74
|
+
if (inspect.status === 0) {
|
|
75
|
+
if (log) log('pensieve-toolbox:local present — reusing (not rebuilt)');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (log) log('pensieve-toolbox:local missing — building from docker/Dockerfile.pensieve-toolbox');
|
|
79
|
+
const build = spawnSync('docker',
|
|
80
|
+
['build', '-f', path.join(ROOT, 'docker', 'Dockerfile.pensieve-toolbox'), '-t', 'pensieve-toolbox:local', ROOT],
|
|
81
|
+
{ stdio: 'inherit' });
|
|
82
|
+
if (build.status !== 0) {
|
|
83
|
+
const base = spawnSync('docker', ['image', 'inspect', 'pentest-toolbox:full'], { encoding: 'utf8' });
|
|
84
|
+
if (base.status !== 0) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
'prerequisite missing: the base image pentest-toolbox:full is not present, so pensieve-toolbox:local cannot be built. '
|
|
87
|
+
+ 'Build or import the base toolbox image first (see the header of docker/Dockerfile.pensieve-toolbox), then re-run'
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
throw new Error('toolbox build failed — see the docker output above, fix the cause, then re-run');
|
|
91
|
+
}
|
|
92
|
+
if (log) log('pensieve-toolbox:local built');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The shared home: SDK COPY (self-contained), skills real copies, registry
|
|
97
|
+
* preserved. Returns { home, sdkBin } for the wiring engines.
|
|
98
|
+
*/
|
|
99
|
+
function buildSharedHome(HOME, { version, log }) {
|
|
100
|
+
const home = pensieveHome(HOME);
|
|
101
|
+
fs.mkdirSync(home, { recursive: true });
|
|
102
|
+
|
|
103
|
+
// SDK: COPY, never symlink (NPX-01: the npx cache is not a stable home)
|
|
104
|
+
const sdkDst = path.join(home, 'sdk');
|
|
105
|
+
fs.rmSync(sdkDst, { recursive: true, force: true });
|
|
106
|
+
copyDir(path.join(ROOT, 'src', 'pensieve-sdk'), sdkDst);
|
|
107
|
+
|
|
108
|
+
// CLI on the user's path: a launcher shim, NOT a copy — the SDK bin
|
|
109
|
+
// resolves its lib modules relative to its own path, so the full tree stays
|
|
110
|
+
// at ~/.pensieve/sdk and the shim just requires into it (self-contained:
|
|
111
|
+
// both live in ~/.pensieve; nothing references the npx cache).
|
|
112
|
+
const binDir = path.join(home, 'bin');
|
|
113
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
114
|
+
const sdkBin = path.join(binDir, 'pensieve-sdk');
|
|
115
|
+
fs.writeFileSync(sdkBin,
|
|
116
|
+
'#!/usr/bin/env node\n'
|
|
117
|
+
+ "// PENSIEVE launcher — delegates to the self-contained copy at ~/.pensieve/sdk\n"
|
|
118
|
+
+ "require('../sdk/bin/pensieve-sdk.cjs');\n");
|
|
119
|
+
fs.chmodSync(sdkBin, 0o755);
|
|
120
|
+
const smoke = spawnSync(process.execPath, [sdkBin, 'help'], { encoding: 'utf8' });
|
|
121
|
+
if (smoke.status !== 0) {
|
|
122
|
+
throw new Error('pensieve-sdk smoke test failed after copy — the copied SDK is not runnable');
|
|
123
|
+
}
|
|
124
|
+
if (log) log(`pensieve-sdk -> ${sdkBin} (self-contained copy, smoke OK)`);
|
|
125
|
+
|
|
126
|
+
// Skills: real copies under ~/.pensieve/skills (profile wiring symlinks here).
|
|
127
|
+
// The pensieve skill gets its references/ tree built at install time exactly
|
|
128
|
+
// like install.sh does (SKILL.md + references/{agents,workflows,commands,
|
|
129
|
+
// packs,templates,reference} + orchestrator-core.md from the package root).
|
|
130
|
+
const skillsDir = path.join(home, 'skills');
|
|
131
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
132
|
+
fs.rmSync(path.join(skillsDir, 'pensieve'), { recursive: true, force: true });
|
|
133
|
+
const skillDir = path.join(skillsDir, 'pensieve');
|
|
134
|
+
fs.mkdirSync(path.join(skillDir, 'references'), { recursive: true });
|
|
135
|
+
fs.copyFileSync(path.join(ROOT, 'skills', 'pensieve', 'SKILL.md'), path.join(skillDir, 'SKILL.md'));
|
|
136
|
+
for (const d of ['agents', 'workflows', 'commands', 'packs', 'templates', 'reference']) {
|
|
137
|
+
fs.rmSync(path.join(skillDir, 'references', d), { recursive: true, force: true });
|
|
138
|
+
copyDir(path.join(ROOT, d), path.join(skillDir, 'references', d));
|
|
139
|
+
}
|
|
140
|
+
fs.copyFileSync(
|
|
141
|
+
path.join(ROOT, 'prompts', 'orchestrator-core.md'),
|
|
142
|
+
path.join(skillDir, 'references', 'orchestrator-core.md')
|
|
143
|
+
);
|
|
144
|
+
for (const name of fs.readdirSync(path.join(ROOT, 'skills'))) {
|
|
145
|
+
if (!name.startsWith('pensieve-')) continue;
|
|
146
|
+
fs.rmSync(path.join(skillsDir, name), { recursive: true, force: true });
|
|
147
|
+
copyDir(path.join(ROOT, 'skills', name), path.join(skillsDir, name));
|
|
148
|
+
}
|
|
149
|
+
return { home, sdkBin, skillsDir };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
module.exports = {
|
|
153
|
+
ROOT, pensieveHome, manifestFile, loadManifest, saveManifest,
|
|
154
|
+
newManifest, record, copyDir, preflight, toolbox, buildSharedHome,
|
|
155
|
+
};
|