@abdulr7man/pensieve 0.0.0-stage → 1.2.1
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 +176 -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,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-tester
|
|
3
|
+
description: Executes one approved plan inside the toolbox → run log + draft findings. Runs at /pensieve-test.
|
|
4
|
+
model_tier: DEFAULT
|
|
5
|
+
tools: [read_file, write_file, patch, terminal]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# pensieve-tester
|
|
9
|
+
|
|
10
|
+
You execute ONE plan against the in-scope assets, log everything, and register
|
|
11
|
+
draft findings with evidence. You prove; you don't assert.
|
|
12
|
+
|
|
13
|
+
## Contract
|
|
14
|
+
|
|
15
|
+
- files_to_read: `ROE.md`, `SCOPE.md`, the assigned
|
|
16
|
+
`plans/PLAN-*.md`, `ACCOUNTS.md` (engagement root), the plan's pack
|
|
17
|
+
checklist.md, `reference/param-profiles.md` (intensity → tool presets),
|
|
18
|
+
`reference/attack-playbooks.md` (lane sequences)
|
|
19
|
+
- roe_check: `pensieve-sdk scope.check-command --engagement <dir> <command>` on
|
|
20
|
+
any command whose target is not literally an AST host; quote verdicts in the
|
|
21
|
+
run log when asked.
|
|
22
|
+
- All testing executes in the toolbox (`docker exec`, proxy env from
|
|
23
|
+
`pensieve-sdk env.proxy-env --engagement <dir>`). `env.status --engagement
|
|
24
|
+
<dir>` up before starting.
|
|
25
|
+
|
|
26
|
+
## Protocol
|
|
27
|
+
|
|
28
|
+
1. Create runs/RUN-<ts>-<plan>.md from references/templates/RUN-LOG.md.
|
|
29
|
+
2. Work the plan's checklist IN ORDER; mark the pack status table as you go
|
|
30
|
+
(done / n/a+why / blocked).
|
|
31
|
+
3. Every request/response that matters → save raw → `pensieve-sdk evidence.put
|
|
32
|
+
--engagement <dir> <file>` → cite E-id in the run log row. REDACT BEFORE
|
|
33
|
+
YOU PUT (see Evidence hygiene below); link with `--finding_id` once the
|
|
34
|
+
finding exists (unlinked puts are warned on).
|
|
35
|
+
4. On a suspected finding: prove it to the plan's "expected evidence" bar,
|
|
36
|
+
then `pensieve-sdk findings.add --engagement <dir> --title ... --cwe ...
|
|
37
|
+
--cvss <vector> --evidence <E-ids>` (title CWE-named, vector PROPOSED by
|
|
38
|
+
you — the sdk computes score; never state a number you computed yourself).
|
|
39
|
+
The register assigns the finding id by severity letter (C-1, H-2, M-1,
|
|
40
|
+
L-1, I-1 — legacy engagements keep F-nnn) and writes the finding file as
|
|
41
|
+
findings/<id>-<title-slug>.md; cite that id verbatim everywhere after.
|
|
42
|
+
5. New-scope tripwire: anything outside SCOPE.md → stop that thread, note in
|
|
43
|
+
the run log under "tripwires", continue with in-scope items only.
|
|
44
|
+
6. Update plans/PLAN-*.md checkboxes; append gaps to the run log.
|
|
45
|
+
|
|
46
|
+
## Output contract
|
|
47
|
+
|
|
48
|
+
- Files: runs/RUN-*.md (complete log), findings/<id>-*.md (draft, evidence-linked;
|
|
49
|
+
<id> is the register id — severity-letter or legacy F-nnn),
|
|
50
|
+
updated pack checklist + plan checkboxes
|
|
51
|
+
- Terminal marker: `## TEST RUN COMPLETE plan=<id> findings=<n> tripwires=<n>`
|
|
52
|
+
|
|
53
|
+
## Rules
|
|
54
|
+
|
|
55
|
+
- A finding without replayable evidence does not get registered — it goes in
|
|
56
|
+
the run log as a lead.
|
|
57
|
+
- If the brief carries an `agent_skills` block (the "Agent skills" section),
|
|
58
|
+
READ each referenced SKILL.md runbook (paths-not-payloads — open the file) and
|
|
59
|
+
treat its Steps / Expected Evidence / Pass-Fail as authoritative for the
|
|
60
|
+
matching checklist items.
|
|
61
|
+
- Intensity limits from PROJECT.md are hard limits: map the engagement
|
|
62
|
+
intensity to a param-profiles.md profile (low→STEALTH, normal→NORMAL,
|
|
63
|
+
high→AGGRESSIVE) and never exceed its presets; when in doubt, slow down
|
|
64
|
+
and note it.
|
|
65
|
+
- DoS-class confirmation (crash proofs) requires the human — `## HUMAN NEEDED`.
|
|
66
|
+
|
|
67
|
+
## Evidence hygiene — redact BEFORE evidence.put
|
|
68
|
+
|
|
69
|
+
The ledger is append-only and hash-chained: anything you `evidence.put` is
|
|
70
|
+
preserved byte-for-byte forever and ships in the report appendix manifest.
|
|
71
|
+
Redact from every capture before storing:
|
|
72
|
+
|
|
73
|
+
- **Secrets and credentials**: session cookies, Authorization/bearer headers,
|
|
74
|
+
API keys, passwords, private keys — keep only the proof that the secret
|
|
75
|
+
WORKED (e.g. the authenticated response), never the secret itself.
|
|
76
|
+
- **Tokens**: CSRF tokens, JWTs, reset links — truncate to the first bytes
|
|
77
|
+
needed to prove structure/validity (`eyJhbGciOi…[redacted]`).
|
|
78
|
+
- **Out-of-scope PII**: personal data belonging to users/tenants outside
|
|
79
|
+
SCOPE.md — replace with `<redacted-pii>`; prove the exposure class (count,
|
|
80
|
+
field names, one masked row), don't archive strangers' data.
|
|
81
|
+
|
|
82
|
+
If a secret MUST be evidenced (e.g. a leaked key IS the finding), record the
|
|
83
|
+
minimum viable fragment and note the redaction in the run log.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-validator
|
|
3
|
+
description: Independent PoC-replay of draft findings (any tool) + Nuclei report artifact; verdicts flip finding status. Runs at /pensieve-validate.
|
|
4
|
+
model_tier: DEFAULT
|
|
5
|
+
tools: [read_file, write_file, terminal]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# pensieve-validator
|
|
9
|
+
|
|
10
|
+
You are the second pair of hands. A finding is only `validated` when YOU
|
|
11
|
+
reproduce it independently — staged discipline (adapted from Raptor's
|
|
12
|
+
exploitability validator): inventory → reproduce → sanity-check → rule.
|
|
13
|
+
"Proven" and "probable" stay distinct: dynamic replay = validated;
|
|
14
|
+
code-path-only = validated-static.
|
|
15
|
+
|
|
16
|
+
## Contract
|
|
17
|
+
|
|
18
|
+
- The finding standard is BINDING: `reference/vulnerability-finding-standard.md`.
|
|
19
|
+
Your verdict gate-keeps it — `findings.status <id> validated` is refused by the
|
|
20
|
+
findings-standard gate until the record carries the five mandatory sections
|
|
21
|
+
(affected assets, description, PoC with at least one step citing
|
|
22
|
+
ledger-verified `[E-id]` evidence, demonstrated impact, remediation). A
|
|
23
|
+
complete finding looks like `reference/templates/FINDING.md` (the authoring
|
|
24
|
+
template); severity-letter ids (C-1/H-1/M-1/L-1/I-1) are SDK-assigned and
|
|
25
|
+
never rewritten.
|
|
26
|
+
- files_to_read: the finding file, its plan, its run log, the evidence it
|
|
27
|
+
cites (verify hashes: `pensieve-sdk evidence.verify --engagement <dir>`
|
|
28
|
+
<E-id>), SCOPE.md, ROE.md
|
|
29
|
+
- You were NOT the testing agent. Use your OWN method/tooling where possible
|
|
30
|
+
(different tool, different path to the same proof). Runs in the toolbox.
|
|
31
|
+
|
|
32
|
+
## Protocol
|
|
33
|
+
|
|
34
|
+
1. Inventory: list the finding's claims (bug, reachability, impact). Each gets
|
|
35
|
+
its own verdict — a true bug with an overstated impact is not validated.
|
|
36
|
+
2. Reproduce: replay the PoC from scratch (accounts per ACCOUNTS.md).
|
|
37
|
+
Record every step in findings/VALIDATION-<id>.md (references/templates/VALIDATION.md).
|
|
38
|
+
3. Sanity check: is the effect explained by something benign (caching, the
|
|
39
|
+
OTHER account's own data, a public endpoint)? Say so = reject.
|
|
40
|
+
4. Severity: propose the CVSS vector fresh (don't inherit the tester's);
|
|
41
|
+
`pensieve-sdk cvss.score` computes. Diff vs the finding's vector → note it.
|
|
42
|
+
5. Report artifact: if template-able (web/API), write a Nuclei template that
|
|
43
|
+
re-fires on the vulnerable behavior and passes on the fixed one; store via
|
|
44
|
+
evidence.put. This template ships IN THE REPORT (ADR-005) — it is not the
|
|
45
|
+
validation itself.
|
|
46
|
+
6. Rule: `pensieve-sdk findings.status --engagement <dir> <id>
|
|
47
|
+
validated|rejected` + verdict paragraph. Static-only (white-box) →
|
|
48
|
+
independent code-path re-review, verdict validated-static with file:line
|
|
49
|
+
chain.
|
|
50
|
+
|
|
51
|
+
## Output contract
|
|
52
|
+
|
|
53
|
+
- File: findings/VALIDATION-<id>.md
|
|
54
|
+
- Status flip via sdk; updated finding file (vector if yours differs)
|
|
55
|
+
- Terminal marker: `## FINDING VALIDATED <id>` / `## FINDING REJECTED <id>` /
|
|
56
|
+
`## HUMAN NEEDED <id> <why>`
|
|
57
|
+
|
|
58
|
+
## Rules
|
|
59
|
+
|
|
60
|
+
- Never "validate" by rereading the tester's log. Replay or reject.
|
|
61
|
+
- If reproduction needs out-of-scope anything → `## HUMAN NEEDED`, full stop.
|
|
62
|
+
- One finding, one validation file, one verdict. No batch verdicts.
|
package/bin/pensieve
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* PENSIEVE CLI — GSD-style self-managed lifecycle.
|
|
4
|
+
*
|
|
5
|
+
* install [--runtime hermes|claude-code] [--profile DIR] [--source DIR] [--dry-run]
|
|
6
|
+
* update [--runtime R] [--dry-run] [--assume-updated]
|
|
7
|
+
* uninstall [--runtime R] [--restore]
|
|
8
|
+
* status [--runtime R]
|
|
9
|
+
* check
|
|
10
|
+
* version
|
|
11
|
+
* build-wiki [--categories a,b] [--files PATH] [--all] [--out PATH]
|
|
12
|
+
*
|
|
13
|
+
* Model (GSD update.md): source repo is the single source of truth. A marker
|
|
14
|
+
* file records what is installed where. update = detect source version ->
|
|
15
|
+
* diff installed manifest -> show changelog -> confirm -> clean-reinstall.
|
|
16
|
+
* install is idempotent (re-copy, refresh marker). uninstall removes our
|
|
17
|
+
* files and optionally restores pre-install backups.
|
|
18
|
+
*
|
|
19
|
+
* No external dependencies. Node 20+.
|
|
20
|
+
*/
|
|
21
|
+
'use strict';
|
|
22
|
+
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const fsp = require('fs/promises');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const os = require('os');
|
|
27
|
+
const cp = require('child_process');
|
|
28
|
+
const { translateAgent } = require('../src/pensieve-sdk/lib/agent-translate.cjs');
|
|
29
|
+
|
|
30
|
+
// The 7 autonomous agents translated+installed for claude-code (explicit allowlist,
|
|
31
|
+
// never a glob — pensieve-scoper stays inline, pensieve-code-auditor is not one of the 7).
|
|
32
|
+
const AGENT_ALLOWLIST = [
|
|
33
|
+
'pensieve-reconner', 'pensieve-mapper', 'pensieve-planner', 'pensieve-tester',
|
|
34
|
+
'pensieve-validator', 'pensieve-reporter', 'pensieve-roe-checker',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const ROOT = path.resolve(__dirname, '..'); // repo root
|
|
38
|
+
const HOME = process.env.HOME || os.homedir();
|
|
39
|
+
|
|
40
|
+
function parseArgs(rest) {
|
|
41
|
+
const a = {};
|
|
42
|
+
for (let i = 0; i < rest.length; i++) {
|
|
43
|
+
const x = rest[i];
|
|
44
|
+
if (x.startsWith('--')) {
|
|
45
|
+
const restArg = x.slice(2);
|
|
46
|
+
const eq = restArg.indexOf('=');
|
|
47
|
+
if (eq >= 0) {
|
|
48
|
+
const k = restArg.slice(0, eq).replace(/-/g, '_');
|
|
49
|
+
a[k] = restArg.slice(eq + 1);
|
|
50
|
+
} else {
|
|
51
|
+
const k = restArg.replace(/-/g, '_');
|
|
52
|
+
if (i + 1 < rest.length && !rest[i + 1].startsWith('--')) a[k] = rest[++i];
|
|
53
|
+
else a[k] = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return a;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function readJson(p, d = {}) {
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
63
|
+
} catch { return d; }
|
|
64
|
+
}
|
|
65
|
+
function wjson(p, o) { fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, JSON.stringify(o, null, 2) + '\n'); }
|
|
66
|
+
|
|
67
|
+
function hash(p) {
|
|
68
|
+
const buf = fs.readFileSync(p);
|
|
69
|
+
const h = require('crypto').createHash('sha256').update(buf).digest('hex');
|
|
70
|
+
return h.slice(0, 16);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* ---------- version ---------- */
|
|
74
|
+
function sourceVersion() {
|
|
75
|
+
const v = fs.existsSync(path.join(ROOT, 'VERSION')) ? fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf8').trim() : 'unknown';
|
|
76
|
+
return v;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* ---------- manifest: what a runtime owns ---------- */
|
|
80
|
+
function manifest(runtime, sourceRoot) {
|
|
81
|
+
const profile = (runtime === 'claude-code') ? path.join(HOME, '.claude') : path.join(HOME, '.hermes');
|
|
82
|
+
const out = { runtime, profile, source: sourceRoot, files: [] };
|
|
83
|
+
const src = (r) => path.join(sourceRoot, r);
|
|
84
|
+
const add = (from, to) => {
|
|
85
|
+
const f = path.join(from, to);
|
|
86
|
+
if (!fs.existsSync(f)) return;
|
|
87
|
+
out.files.push({ from: to, to: path.join(profile, to) });
|
|
88
|
+
};
|
|
89
|
+
if (runtime === 'hermes') {
|
|
90
|
+
add(src('runtimes/hermes'), 'skills/software-development/pensieve-framework/SKILL.md');
|
|
91
|
+
add(src('skills/pensieve'), 'skills/software-development/pensieve-framework/SKILL.md');
|
|
92
|
+
add(src('runtimes/hermes'), 'skills/software-development/pensieve-framework/references/orchestrator-core.md');
|
|
93
|
+
add(src('runtimes/hermes'), 'skills/software-development/pensieve-framework/references/live-engagement-ops.md');
|
|
94
|
+
// command skills (the 15 /pensieve-*)
|
|
95
|
+
const cmdDir = src('skills');
|
|
96
|
+
if (fs.existsSync(cmdDir)) {
|
|
97
|
+
for (const d of fs.readdirSync(cmdDir)) {
|
|
98
|
+
const dp = path.join(cmdDir, d, 'SKILL.md');
|
|
99
|
+
if (fs.existsSync(dp)) add(cmdDir, `skills/software-development/${d}/SKILL.md`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// hooks
|
|
103
|
+
add(src('runtimes/hermes/hooks'), 'hooks/scope-guard.js');
|
|
104
|
+
add(src('runtimes/hermes/hooks'), 'hooks/pensieve-scope-guard.js');
|
|
105
|
+
// standalone scope-guard
|
|
106
|
+
add(src('runtimes/hermes'), 'scope-guard'); // dir? handled specially below
|
|
107
|
+
} else {
|
|
108
|
+
// claude-code: skills + commands
|
|
109
|
+
add(src('skills'), 'skills/pensieve-framework/SKILL.md');
|
|
110
|
+
add(src('skills/pensieve-framework'), 'skills/pensieve-framework/SKILL.md');
|
|
111
|
+
add(src('commands'), 'commands/pensieve-framework.md');
|
|
112
|
+
for (const d of fs.existsSync(src('commands')) ? fs.readdirSync(src('commands')) : []) {
|
|
113
|
+
const p = path.join(src('commands'), d);
|
|
114
|
+
if (fs.statSync(p).isFile()) add(src('commands'), `commands/${path.basename(p)}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* ---------- dry run ---------- */
|
|
121
|
+
function log(label, body) { process.stdout.write(label + '\n' + (body || '') + '\n\n'); }
|
|
122
|
+
|
|
123
|
+
/* ---------- install ---------- */
|
|
124
|
+
function install(opts = {}) {
|
|
125
|
+
const runtime = opts.runtime || process.env.PENSIEVE_RUNTIME || 'hermes';
|
|
126
|
+
const source = opts.source || ROOT;
|
|
127
|
+
const profileDir = (runtime === 'claude-code') ? path.join(HOME, '.claude') : path.join(HOME, '.hermes');
|
|
128
|
+
const marker = path.join(profileDir, '.pensieve-installed.json');
|
|
129
|
+
const backupRoot = path.join(profileDir, '.pensieve-backup');
|
|
130
|
+
|
|
131
|
+
if (!fs.existsSync(source) || !fs.existsSync(path.join(source, 'src', 'pensieve-sdk'))) {
|
|
132
|
+
fail(`source dir not found: ${source} (must be the PENSIEVE repo)`);
|
|
133
|
+
}
|
|
134
|
+
const files = buildFileList(runtime, source, profileDir); // [{from, to, size}]
|
|
135
|
+
const backup = opts.dryRun ? false : backupExisting(files, backupRoot);
|
|
136
|
+
|
|
137
|
+
if (opts.dryRun) {
|
|
138
|
+
log('[dry-run] would install', files.map(f => `${f.to} (${hash(f.from)})`).join('\n '));
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
fs.mkdirSync(profileDir, { recursive: true });
|
|
143
|
+
let installed = 0, failed = 0;
|
|
144
|
+
for (const f of files) {
|
|
145
|
+
fs.mkdirSync(path.dirname(f.to), { recursive: true });
|
|
146
|
+
try {
|
|
147
|
+
if (f.transform === 'agent') fs.writeFileSync(f.to, translateAgent(fs.readFileSync(f.from, 'utf8'), runtime));
|
|
148
|
+
else fs.copyFileSync(f.from, f.to);
|
|
149
|
+
installed++;
|
|
150
|
+
} catch (e) {
|
|
151
|
+
failed++;
|
|
152
|
+
warn(`skip ${f.to}: ${e.message}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const markerData = {
|
|
156
|
+
runtime, profile: profileDir, source, source_version: sourceVersion(),
|
|
157
|
+
installed_at: new Date().toISOString(), installed: installed, failed,
|
|
158
|
+
backup_dir: backup, files: files.map(f => ({ from: f.from, to: f.to, sha: hash(f.from), size: f.from ? fs.statSync(f.from).size : 0 }))
|
|
159
|
+
};
|
|
160
|
+
// back up marker
|
|
161
|
+
if (fs.existsSync(marker)) fs.copyFileSync(marker, marker + '.bak');
|
|
162
|
+
wjson(marker, markerData);
|
|
163
|
+
reportInstalled(markerData, runtime);
|
|
164
|
+
return failed === 0 ? 0 : 1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function backupExisting(files, backupRoot) {
|
|
168
|
+
const touched = new Set(files.map(f => f.to));
|
|
169
|
+
const existing = files.filter(f => fs.existsSync(f.to));
|
|
170
|
+
if (!existing.length) return null;
|
|
171
|
+
const out = path.join(backupRoot, new Date().toISOString().replace(/[:T-]/g, '_'));
|
|
172
|
+
fs.mkdirSync(out, { recursive: true });
|
|
173
|
+
for (const f of existing) {
|
|
174
|
+
const rel = path.relative(HOME, f.to);
|
|
175
|
+
const dst = path.join(out, rel);
|
|
176
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
177
|
+
try { fs.copyFileSync(f.to, dst); } catch {}
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function buildFileList(runtime, source, profileDir) {
|
|
183
|
+
const files = [];
|
|
184
|
+
const push = (from, to) => {
|
|
185
|
+
if (!fs.existsSync(from) || path.dirname(to) === to) return;
|
|
186
|
+
files.push({ from, to: path.join(profileDir, to), src: from });
|
|
187
|
+
};
|
|
188
|
+
if (runtime === 'hermes') {
|
|
189
|
+
const skillDir = path.join(source, 'skills');
|
|
190
|
+
push(path.join(skillDir, 'pensieve-framework', 'SKILL.md'), 'skills/software-development/pensieve-framework/SKILL.md');
|
|
191
|
+
if (fs.existsSync(path.join(source, 'prompts', 'orchestrator-core.md')))
|
|
192
|
+
push(path.join(source, 'prompts', 'orchestrator-core.md'), 'skills/software-development/pensieve-framework/references/orchestrator-core.md');
|
|
193
|
+
if (fs.existsSync(path.join(source, 'reference', 'live-engagement-ops.md')))
|
|
194
|
+
push(path.join(source, 'reference', 'live-engagement-ops.md'), 'skills/software-development/pensieve-framework/references/live-engagement-ops.md');
|
|
195
|
+
for (const d of (fs.existsSync(skillDir) ? fs.readdirSync(skillDir) : [])) {
|
|
196
|
+
const sk = path.join(skillDir, d, 'SKILL.md');
|
|
197
|
+
if (fs.existsSync(sk)) push(sk, `skills/software-development/${d}/SKILL.md`);
|
|
198
|
+
}
|
|
199
|
+
for (const h of ['scope-guard.js', 'pensieve-scope-guard.js']) {
|
|
200
|
+
const h2 = path.join(source, 'runtimes', 'hermes', 'hooks', h);
|
|
201
|
+
if (fs.existsSync(h2)) push(h2, `hooks/${h}`);
|
|
202
|
+
}
|
|
203
|
+
const sg = path.join(source, 'runtimes/hermes', 'scope-guard');
|
|
204
|
+
if (fs.existsSync(sg)) push(sg, 'scope-guard');
|
|
205
|
+
} else {
|
|
206
|
+
const skillDir = path.join(source, 'skills');
|
|
207
|
+
if (fs.existsSync(path.join(skillDir, 'pensieve-framework', 'SKILL.md')))
|
|
208
|
+
push(path.join(skillDir, 'pensieve-framework', 'SKILL.md'), 'skills/pensieve-framework/SKILL.md');
|
|
209
|
+
const cmdDir = path.join(source, 'commands');
|
|
210
|
+
if (fs.existsSync(cmdDir)) {
|
|
211
|
+
for (const f of fs.readdirSync(cmdDir)) {
|
|
212
|
+
const p = path.join(cmdDir, f);
|
|
213
|
+
if (fs.statSync(p).isFile() && f.endsWith('.md')) push(p, `commands/${f}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// 7 autonomous agents — translated on install (transform flag), not plain-copied.
|
|
217
|
+
for (const name of AGENT_ALLOWLIST) {
|
|
218
|
+
const from = path.join(source, 'agents', `${name}.md`);
|
|
219
|
+
if (fs.existsSync(from)) {
|
|
220
|
+
files.push({ from, to: path.join(profileDir, `agents/${name}.md`), src: from, transform: 'agent' });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return files;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function reportInstalled(m, runtime) {
|
|
228
|
+
const rel = (p) => path.relative(HOME, p);
|
|
229
|
+
log(`PENSIEVE installed (${runtime})`,
|
|
230
|
+
` version : ${m.source_version}\n` +
|
|
231
|
+
` source : ${m.source}\n` +
|
|
232
|
+
` marker : ${rel(path.join(m.profile, '.pensieve-installed.json'))}\n` +
|
|
233
|
+
` files : ${m.installed} ok${m.failed ? ` / ${m.failed} skipped` : ''}\n` +
|
|
234
|
+
` backup : ${m.backup_dir || '(none needed — nothing pre-existing)'}\n\n` +
|
|
235
|
+
` To use: /pensieve-help (or /pensieve-new-engagement etc.)\n` +
|
|
236
|
+
` Verify: pensieve check / pensieve status`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* ---------- update ---------- */
|
|
240
|
+
function update(opts = {}) {
|
|
241
|
+
const runtime = opts.runtime || 'hermes';
|
|
242
|
+
const markerPath = path.join((runtime === 'claude-code') ? path.join(HOME, '.claude') : path.join(HOME, '.hermes'), '.pensieve-installed.json');
|
|
243
|
+
const marker = readJson(markerPath);
|
|
244
|
+
if (!marker || !marker.profile) return warn('nothing to update — nothing installed. Run `pensieve install` first.') || 1;
|
|
245
|
+
const current = sourceVersion();
|
|
246
|
+
const prev = marker.source_version;
|
|
247
|
+
const changelog = buildChangelog(prev, current, marker.source);
|
|
248
|
+
log('PENSIEVE update',
|
|
249
|
+
` installed: ${prev || '?'} -> source: ${current}\n` +
|
|
250
|
+
` profile : ${marker.profile}\n` +
|
|
251
|
+
(prev === current ? ' unchanged: source version matches installed version.\n' : '\n') +
|
|
252
|
+
(changelog ? '\n changelog:\n' + changelog.split('\n').map(l => ' ' + l).join('\n') + '\n' : '') +
|
|
253
|
+
(prev === current ? '' : '\n' + (opts.assumeUpdated ? ' [assume-updated] auto-confirmed\n' : ' confirm? [y/N] ')) +
|
|
254
|
+
(prev === current ? '\n nothing to do (idempotent re-install available).\n' : ''));
|
|
255
|
+
if (prev === current) {
|
|
256
|
+
warn('no version drift; reinstalling copies for hygiene (idempotent).');
|
|
257
|
+
return install(opts);
|
|
258
|
+
}
|
|
259
|
+
if (!opts.assumeUpdated && !process.env.PENSIEVE_ASSUME_UPDATED) {
|
|
260
|
+
if (!process.stdin.isTTY) {
|
|
261
|
+
console.warn('non-interactive: no update confirmed (stdin not TTY).');
|
|
262
|
+
return 1;
|
|
263
|
+
}
|
|
264
|
+
const r = fs.readFileSync(0, 'utf8');
|
|
265
|
+
const ans = (r || '').trim().toLowerCase();
|
|
266
|
+
if (ans[0] !== 'y') { console.warn('aborted (no drift-confirmation). Use --assume-updated to confirm.'); return 1; }
|
|
267
|
+
}
|
|
268
|
+
return install(opts);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function buildChangelog(prev, cur, src) {
|
|
272
|
+
try {
|
|
273
|
+
const f = path.join(src, 'docs', 'CHANGELOG.md');
|
|
274
|
+
if (!fs.existsSync(f)) return '';
|
|
275
|
+
const c = fs.readFileSync(f, 'utf8');
|
|
276
|
+
const lines = c.split('\n');
|
|
277
|
+
const from = prev.replace(/[v]/g, '');
|
|
278
|
+
const to = cur.replace(/[v]/g, '');
|
|
279
|
+
let out = [], inRange = false;
|
|
280
|
+
for (const l of lines) {
|
|
281
|
+
const m = l.match(/^v?([0-9]+)\.([0-9]+)(?:\.[0-9]+)?/);
|
|
282
|
+
if (m) { const v = m[0].replace(/^v/,''); if (from && to) { /* range */ } inRange = true; }
|
|
283
|
+
if (inRange) out.push(l);
|
|
284
|
+
}
|
|
285
|
+
return out.join('\n') || '';
|
|
286
|
+
} catch { return ''; }
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* ---------- status ---------- */
|
|
290
|
+
function status(opts = {}) {
|
|
291
|
+
const runtime = opts.runtime || 'hermes';
|
|
292
|
+
const profileDir = (runtime === 'claude-code') ? path.join(HOME, '.claude') : path.join(HOME, '.hermes');
|
|
293
|
+
const marker = readJson(path.join(profileDir, '.pensieve-installed.json'));
|
|
294
|
+
const m = marker.source || 'n/a';
|
|
295
|
+
const v = marker.source_version || '?';
|
|
296
|
+
const sv = sourceVersion();
|
|
297
|
+
const drift = v !== sv ? 'DRIFT' : 'in-sync';
|
|
298
|
+
const cmdSkills = fs.existsSync(path.join(ROOT, 'skills')) ? fs.readdirSync(path.join(ROOT, 'skills')).length : 0;
|
|
299
|
+
const log = (l, r) => process.stdout.write(`${l.padEnd(12)}${r}\n`);
|
|
300
|
+
log('runtime ', marker ? marker.runtime : '(none installed)');
|
|
301
|
+
log('profile ', marker ? marker.profile : '(none)');
|
|
302
|
+
log('installed ', marker ? v : '-');
|
|
303
|
+
log('source ', sv);
|
|
304
|
+
log('drift ', drift);
|
|
305
|
+
log('files ', marker ? `${marker.installed} ok${marker.failed ? ` / ${marker.failed} skipped` : ''}` : '-');
|
|
306
|
+
log('command sk', `${cmdSkills} in repo (${marker ? marker.profile : 'N/A'})`);
|
|
307
|
+
return 0;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* ---------- uninstall ---------- */
|
|
311
|
+
function uninstall(opts = {}) {
|
|
312
|
+
const runtime = opts.runtime || 'hermes';
|
|
313
|
+
const profileDir = (runtime === 'claude-code') ? path.join(HOME, '.claude') : path.join(HOME, '.hermes');
|
|
314
|
+
const marker = readJson(path.join(profileDir, '.pensieve-installed.json'));
|
|
315
|
+
if (!marker) return fail('nothing installed for ' + runtime);
|
|
316
|
+
|
|
317
|
+
const files = (marker.files || []);
|
|
318
|
+
let removed = 0;
|
|
319
|
+
// 1) back up recorded files if --restore (snapshot pre-removal)
|
|
320
|
+
let backupOut = null;
|
|
321
|
+
if (opts.restore) {
|
|
322
|
+
backupOut = path.join(profileDir, '.pensieve-backup', 'uninstall-' + new Date().toISOString().replace(/[:T-]/g, '_'));
|
|
323
|
+
fs.mkdirSync(backupOut, { recursive: true });
|
|
324
|
+
for (const f of files) if (fs.existsSync(f.to)) {
|
|
325
|
+
const rel = path.relative(HOME, f.to);
|
|
326
|
+
const dst = path.join(backupOut, rel);
|
|
327
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
328
|
+
try { fs.copyFileSync(f.to, dst); } catch {}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// 2) unlink each recorded file
|
|
332
|
+
for (const f of files) {
|
|
333
|
+
if (fs.existsSync(f.to)) { try { fs.unlinkSync(f.to); removed++; } catch { /* ignore */ } }
|
|
334
|
+
}
|
|
335
|
+
// 3) remove now-empty parent dirs, deepest first
|
|
336
|
+
const dirs = [...new Set(files.map(f => path.dirname(f.to)))]
|
|
337
|
+
.sort((a, b) => b.split('/').length - a.split('/').length);
|
|
338
|
+
for (const d of dirs) { try { if (fs.existsSync(d)) fs.rmdirSync(d); } catch { /* leave non-empty dirs */ } }
|
|
339
|
+
// 4) move marker out
|
|
340
|
+
const m = path.join(profileDir, '.pensieve-installed.json');
|
|
341
|
+
if (fs.existsSync(m)) fs.renameSync(m, m + '.uninstalled-' + new Date().toISOString().replace(/[:T-]/g, '_'));
|
|
342
|
+
console.log('PENSIEVE uninstalled (' + runtime + ')');
|
|
343
|
+
console.log(` removed ${removed}/${files.length} recorded files; marker -> .pensieve-installed.json.uninstalled-*`);
|
|
344
|
+
if (opts.restore && backupOut) console.log(' pre-uninstall snapshot: ' + backupOut);
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/* ---------- check ---------- */
|
|
349
|
+
function check(opts = {}) {
|
|
350
|
+
let ok = 0, warnc = 0;
|
|
351
|
+
const logOk = (m) => { ok++; console.log(` ok ${m}`); };
|
|
352
|
+
const logMiss = (m, lbl) => { warnc++; console.log(` MISS ${m} (${lbl})`); };
|
|
353
|
+
function verify(runtime, profileDir) {
|
|
354
|
+
const marker = readJson(path.join(profileDir, '.pensieve-installed.json'));
|
|
355
|
+
if (!marker || !marker.profile) { console.log(` -- no marker in ${profileDir}\n`); return 0; }
|
|
356
|
+
for (const f of marker.files) {
|
|
357
|
+
fs.existsSync(f.to) ? logOk(f.to) : logMiss(f.to, 'marked file missing');
|
|
358
|
+
}
|
|
359
|
+
const sdk = path.join(ROOT, 'src', 'pensieve-sdk');
|
|
360
|
+
if (fs.existsSync(sdk)) {
|
|
361
|
+
try {
|
|
362
|
+
cp.execSync(`node ${path.join(sdk, 'bin', 'pensieve-sdk.cjs')} state.list`, { timeout: 15000 });
|
|
363
|
+
logOk('sdk state.list reachable');
|
|
364
|
+
} catch (e) {
|
|
365
|
+
warnc++;
|
|
366
|
+
console.log(' WARN sdk state.list failed: ' + (e.message || (e.stdout || '').toString().slice(0, 120)));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
const skillDir = path.join(profileDir, 'skills', 'software-development');
|
|
370
|
+
let cmdCount = 0;
|
|
371
|
+
if (fs.existsSync(skillDir)) {
|
|
372
|
+
cmdCount = fs.readdirSync(skillDir).filter(d => {
|
|
373
|
+
const p = path.join(skillDir, d, 'SKILL.md');
|
|
374
|
+
return d.startsWith('pensieve-') && fs.existsSync(p);
|
|
375
|
+
}).length;
|
|
376
|
+
}
|
|
377
|
+
cmdCount ? logOk(`${cmdCount} /pensieve-* command skills in profile`) : logMiss(skillDir, 'command skills dir');
|
|
378
|
+
const agentDir = path.join(profileDir, 'agents');
|
|
379
|
+
const agents = fs.existsSync(agentDir)
|
|
380
|
+
? fs.readdirSync(agentDir).filter(f => f.startsWith('pensieve-') && f.endsWith('.md')).sort()
|
|
381
|
+
: [];
|
|
382
|
+
if (agents.length) logOk(`${agents.length} pensieve agents in profile: ${agents.join(', ')}`);
|
|
383
|
+
console.log(` [${runtime}]`);
|
|
384
|
+
}
|
|
385
|
+
console.log('PENSIEVE check');
|
|
386
|
+
verify('hermes', path.join(HOME, '.hermes'));
|
|
387
|
+
verify('claude-code', path.join(HOME, '.claude'));
|
|
388
|
+
console.log('result', `${ok} ok, ${warnc} warning(s)`);
|
|
389
|
+
return warnc === 0 ? 0 : 2;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function fail(m) { console.error('ERR: ' + m); return 1; }
|
|
393
|
+
function warn(m) { console.warn('WARN: ' + m); return 0; }
|
|
394
|
+
|
|
395
|
+
/* ---------- wiki (LLM-wiki over hacktricks) ---------- */
|
|
396
|
+
function wiki(rest) {
|
|
397
|
+
const script = path.join(__dirname, 'build-wiki.py');
|
|
398
|
+
// forward any extra args after 'wiki' (e.g. --out, --categories)
|
|
399
|
+
const args = rest.slice(0).filter(a => !a.startsWith('-llm') || true);
|
|
400
|
+
return cp.spawnSync('python3', [script, ...rest], { stdio: 'inherit', cwd: ROOT });
|
|
401
|
+
}
|
|
402
|
+
function wikiShow() {
|
|
403
|
+
const wiki = process.env.WIKI_DIR || HOME;
|
|
404
|
+
const d = path.join(wiki, 'concepts');
|
|
405
|
+
if (!fs.existsSync(d)) { console.log(`wiki not built in ${wiki} (run: pensieve wiki --all --out ${wiki})`); return 0; }
|
|
406
|
+
const pages = fs.readdirSync(d).filter(f => f.endsWith('.md'));
|
|
407
|
+
const catPages = pages.filter(p => !p.includes('-'));
|
|
408
|
+
console.log(`Wiki at ${wiki} (${pages.length} pages, ${catPages.length} category pages)`);
|
|
409
|
+
let raw = 'n/a';
|
|
410
|
+
try {
|
|
411
|
+
if (fs.lstatSync(wiki + '/raw').isSymbolicLink()) raw = fs.readlinkSync(wiki + '/raw');
|
|
412
|
+
} catch (e) {}
|
|
413
|
+
console.log('raw ->', raw);
|
|
414
|
+
console.log('Rebuild: pensieve wiki --all');
|
|
415
|
+
console.log('Synthesis: pensieve wiki --categories <cat> --llm on');
|
|
416
|
+
return 0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function main() {
|
|
420
|
+
const c = process.argv[2] || 'help';
|
|
421
|
+
const rest = process.argv.slice(3);
|
|
422
|
+
const o = parseArgs(rest);
|
|
423
|
+
const runtime = o.runtime || 'hermes';
|
|
424
|
+
const source = o.source || ROOT;
|
|
425
|
+
let rc;
|
|
426
|
+
try {
|
|
427
|
+
switch (c) {
|
|
428
|
+
case 'version': console.log(sourceVersion()); return 0;
|
|
429
|
+
case 'install': return install({ runtime, source, profileDir: o.profileDir, dry_run: o['dry_run'], dryRun: o['dry_run'] });
|
|
430
|
+
case 'update': return update({ runtime, source, assumeUpdated: o['assume_updated'] });
|
|
431
|
+
case 'uninstall': return uninstall({ runtime, restore: o.restore });
|
|
432
|
+
case 'status': return status({ runtime });
|
|
433
|
+
case 'check': return check();
|
|
434
|
+
case 'build-wiki': case 'wiki': return wiki(rest);
|
|
435
|
+
case 'wiki-list': return wikiShow();
|
|
436
|
+
case 'help': case 'helps': case '':
|
|
437
|
+
console.log('PENSIEVE CLI — GSD self-managed lifecycle\n' +
|
|
438
|
+
' install [--runtime hermes|claude-code] [--source DIR] [--profile DIR] [--dry-run]\n' +
|
|
439
|
+
' update [--runtime R] [--source DIR] [--assume-updated]\n' +
|
|
440
|
+
' uninstall [--runtime R] [--restore]\n' +
|
|
441
|
+
' status [--runtime R]\n' +
|
|
442
|
+
' check\n' +
|
|
443
|
+
' version\n' +
|
|
444
|
+
' build-wiki [--categories a,b] [--all] [--out PATH]\n\n' +
|
|
445
|
+
`source version: ${sourceVersion()}\nrepo: ${ROOT}`);
|
|
446
|
+
return 0;
|
|
447
|
+
default: console.error('unknown command: ' + c + '\n'); process.exit(2);
|
|
448
|
+
}
|
|
449
|
+
} catch (e) { console.error(e.message); return 1; }
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
main();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pensieve-pause
|
|
3
|
+
description: Leave a continue-here note; the status machine does not move.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /pensieve-pause
|
|
7
|
+
|
|
8
|
+
1. `pensieve-sdk state.pause --engagement <dir> "<note>"` — writes
|
|
9
|
+
continue-here.md (engagement root) with the current status, the digest's
|
|
10
|
+
next
|
|
11
|
+
action, and the note.
|
|
12
|
+
2. Confirm to the human: pausing changed NOTHING in the status machine —
|
|
13
|
+
/pensieve-resume will surface the note on top of file-truth state.
|
|
14
|
+
3. If the engagement env is up and the pause is long, suggest
|
|
15
|
+
`pensieve-sdk env.down --engagement <dir>` (egress containment stops too).
|