create-claude-cabinet 0.11.2 → 0.12.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/README.md +1 -1
- package/lib/cli.js +7 -6
- package/lib/db-setup.js +4 -10
- package/lib/settings-merge.js +29 -3
- package/package.json +1 -1
- package/templates/README.md +3 -4
- package/templates/hooks/omega-memory-guard.sh +83 -0
- package/templates/scripts/merge-findings.js +1 -1
- package/templates/scripts/pib-db-schema.sql +2 -2
- package/templates/scripts/{pib-db.js → pib-db.mjs} +22 -15
- package/templates/scripts/work-tracker-server.mjs +1 -1
- package/templates/skills/audit/SKILL.md +1 -1
- package/templates/skills/cabinet-cc-health/SKILL.md +1 -1
- package/templates/skills/debrief/SKILL.md +3 -3
- package/templates/skills/debrief/phases/close-work.md +4 -4
- package/templates/skills/debrief/phases/record-lessons.md +6 -7
- package/templates/skills/execute-plans/SKILL.md +2 -2
- package/templates/skills/onboard/phases/post-onboard-audit.md +1 -1
- package/templates/skills/onboard/phases/work-tracking.md +2 -2
- package/templates/skills/orient/SKILL.md +20 -8
- package/templates/skills/orient/phases/work-scan.md +4 -4
- package/templates/skills/plan/SKILL.md +2 -2
- package/templates/skills/plan/phases/overlap-check.md +1 -1
- package/templates/skills/plan/phases/work-tracker.md +3 -3
- package/templates/skills/triage-audit/SKILL.md +1 -1
- package/templates/skills/triage-audit/phases/apply-verdicts.md +1 -1
- package/templates/skills/triage-audit/phases/load-findings.md +1 -1
- package/templates/skills/work-tracker/SKILL.md +3 -3
- package/templates/hooks/stop-hook.md +0 -56
package/README.md
CHANGED
|
@@ -185,7 +185,7 @@ source code.
|
|
|
185
185
|
└── settings.json # hook configuration
|
|
186
186
|
|
|
187
187
|
scripts/
|
|
188
|
-
├── pib-db.
|
|
188
|
+
├── pib-db.mjs # work tracking CLI (if installed)
|
|
189
189
|
└── ... # triage tools (if audit installed)
|
|
190
190
|
|
|
191
191
|
.ccrc.json # installation metadata
|
package/lib/cli.js
CHANGED
|
@@ -304,7 +304,7 @@ const MODULES = {
|
|
|
304
304
|
name: 'Session Loop (orient + debrief)',
|
|
305
305
|
description: 'The briefing cycle. Claude starts each session informed, ends by preparing the next briefing.',
|
|
306
306
|
mandatory: true,
|
|
307
|
-
templates: ['skills/orient', 'skills/orient-quick', 'skills/debrief', 'skills/debrief-quick', 'skills/debrief/phases/upstream-feedback.md', 'skills/menu'
|
|
307
|
+
templates: ['skills/orient', 'skills/orient-quick', 'skills/debrief', 'skills/debrief-quick', 'skills/debrief/phases/upstream-feedback.md', 'skills/menu'],
|
|
308
308
|
},
|
|
309
309
|
'hooks': {
|
|
310
310
|
name: 'Git Guardrails + Telemetry',
|
|
@@ -320,7 +320,7 @@ const MODULES = {
|
|
|
320
320
|
mandatory: false,
|
|
321
321
|
default: true,
|
|
322
322
|
lean: false,
|
|
323
|
-
templates: ['scripts/pib-db.
|
|
323
|
+
templates: ['scripts/pib-db.mjs', 'scripts/pib-db-schema.sql', 'scripts/work-tracker-server.mjs', 'scripts/work-tracker-ui.html', 'skills/work-tracker'],
|
|
324
324
|
needsDb: true,
|
|
325
325
|
},
|
|
326
326
|
'planning': {
|
|
@@ -390,7 +390,7 @@ const MODULES = {
|
|
|
390
390
|
default: true,
|
|
391
391
|
lean: false,
|
|
392
392
|
needsOmega: true,
|
|
393
|
-
templates: ['skills/memory', 'scripts/cabinet-memory-adapter.py', 'rules/memory-capture.md'],
|
|
393
|
+
templates: ['skills/memory', 'scripts/cabinet-memory-adapter.py', 'rules/memory-capture.md', 'hooks/omega-memory-guard.sh'],
|
|
394
394
|
},
|
|
395
395
|
};
|
|
396
396
|
|
|
@@ -621,7 +621,7 @@ async function run() {
|
|
|
621
621
|
selectedModules = Object.keys(MODULES);
|
|
622
622
|
if (flags.noDb) {
|
|
623
623
|
includeDb = false;
|
|
624
|
-
// work-tracking templates are still copied (pib-db.
|
|
624
|
+
// work-tracking templates are still copied (pib-db.mjs, schema) but
|
|
625
625
|
// the DB isn't initialized. Mark it as skipped so /onboard knows
|
|
626
626
|
// to ask about the alternative work tracking system.
|
|
627
627
|
selectedModules = selectedModules.filter(m => m !== 'work-tracking');
|
|
@@ -845,7 +845,8 @@ async function run() {
|
|
|
845
845
|
|
|
846
846
|
// --- Merge hooks into settings.json ---
|
|
847
847
|
if (selectedModules.includes('hooks') && !flags.dryRun) {
|
|
848
|
-
const
|
|
848
|
+
const includeMemory = selectedModules.includes('memory');
|
|
849
|
+
const settingsPath = mergeSettings(projectDir, { includeDb, includeMemory });
|
|
849
850
|
console.log(` ⚙️ Merged hooks into ${path.relative(projectDir, settingsPath)}`);
|
|
850
851
|
}
|
|
851
852
|
|
|
@@ -856,7 +857,7 @@ async function run() {
|
|
|
856
857
|
for (const r of dbResults) console.log(` 🗄️ ${r}`);
|
|
857
858
|
} catch (err) {
|
|
858
859
|
console.log(` ⚠ Database setup failed: ${err.message}`);
|
|
859
|
-
console.log(' You can set it up later: node scripts/pib-db.
|
|
860
|
+
console.log(' You can set it up later: node scripts/pib-db.mjs init');
|
|
860
861
|
}
|
|
861
862
|
}
|
|
862
863
|
|
package/lib/db-setup.js
CHANGED
|
@@ -4,7 +4,7 @@ const path = require('path');
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Set up the PIB database in the target project.
|
|
7
|
-
* - Copies pib-db.
|
|
7
|
+
* - Copies pib-db.mjs and schema to scripts/
|
|
8
8
|
* - Runs npm init if no package.json
|
|
9
9
|
* - Installs better-sqlite3
|
|
10
10
|
* - Runs pib-db init
|
|
@@ -21,14 +21,8 @@ function setupDb(projectDir) {
|
|
|
21
21
|
results.push('Created package.json');
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// pib-db.
|
|
25
|
-
//
|
|
26
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
27
|
-
if (pkg.type !== 'module' && pkg.name !== 'create-claude-cabinet') {
|
|
28
|
-
pkg.type = 'module';
|
|
29
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
30
|
-
results.push('Set package.json type to "module"');
|
|
31
|
-
}
|
|
24
|
+
// pib-db.mjs uses ESM imports — .mjs extension lets Node treat it as ESM
|
|
25
|
+
// regardless of the project's package.json type field
|
|
32
26
|
|
|
33
27
|
// Install better-sqlite3 if not already installed
|
|
34
28
|
const nodeModules = path.join(projectDir, 'node_modules', 'better-sqlite3');
|
|
@@ -39,7 +33,7 @@ function setupDb(projectDir) {
|
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
// Initialize the database
|
|
42
|
-
const dbScript = path.join(scriptsDir, 'pib-db.
|
|
36
|
+
const dbScript = path.join(scriptsDir, 'pib-db.mjs');
|
|
43
37
|
if (fs.existsSync(dbScript)) {
|
|
44
38
|
console.log(' Initializing database...');
|
|
45
39
|
execSync(`node ${dbScript} init`, { cwd: projectDir, stdio: 'pipe' });
|
package/lib/settings-merge.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
+
const MEMORY_HOOKS = {
|
|
5
|
+
PreToolUse: [
|
|
6
|
+
{
|
|
7
|
+
matcher: 'Edit|Write',
|
|
8
|
+
hooks: [
|
|
9
|
+
{
|
|
10
|
+
type: 'command',
|
|
11
|
+
command: '.claude/hooks/omega-memory-guard.sh',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
|
|
4
18
|
const DEFAULT_HOOKS = {
|
|
5
19
|
PreToolUse: [
|
|
6
20
|
{
|
|
@@ -50,7 +64,7 @@ const DEFAULT_HOOKS = {
|
|
|
50
64
|
* Merge PIB hooks into the project's .claude/settings.json.
|
|
51
65
|
* Creates the file if it doesn't exist. Preserves existing hooks.
|
|
52
66
|
*/
|
|
53
|
-
function mergeSettings(projectDir, { includeDb = true } = {}) {
|
|
67
|
+
function mergeSettings(projectDir, { includeDb = true, includeMemory = false } = {}) {
|
|
54
68
|
const settingsDir = path.join(projectDir, '.claude');
|
|
55
69
|
const settingsPath = path.join(settingsDir, 'settings.json');
|
|
56
70
|
|
|
@@ -81,8 +95,20 @@ function mergeSettings(projectDir, { includeDb = true } = {}) {
|
|
|
81
95
|
});
|
|
82
96
|
}
|
|
83
97
|
|
|
98
|
+
// Build the full hook set — include memory hooks if memory module is selected
|
|
99
|
+
const allHooks = { ...DEFAULT_HOOKS };
|
|
100
|
+
if (includeMemory) {
|
|
101
|
+
for (const [event, hooks] of Object.entries(MEMORY_HOOKS)) {
|
|
102
|
+
if (!allHooks[event]) {
|
|
103
|
+
allHooks[event] = hooks;
|
|
104
|
+
} else {
|
|
105
|
+
allHooks[event] = [...allHooks[event], ...hooks];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
84
110
|
// Merge each hook event type
|
|
85
|
-
for (const [event, newHooks] of Object.entries(
|
|
111
|
+
for (const [event, newHooks] of Object.entries(allHooks)) {
|
|
86
112
|
if (!settings.hooks[event]) {
|
|
87
113
|
settings.hooks[event] = newHooks;
|
|
88
114
|
} else {
|
|
@@ -106,4 +132,4 @@ function mergeSettings(projectDir, { includeDb = true } = {}) {
|
|
|
106
132
|
return settingsPath;
|
|
107
133
|
}
|
|
108
134
|
|
|
109
|
-
module.exports = { mergeSettings, DEFAULT_HOOKS };
|
|
135
|
+
module.exports = { mergeSettings, DEFAULT_HOOKS, MEMORY_HOOKS };
|
package/package.json
CHANGED
package/templates/README.md
CHANGED
|
@@ -11,12 +11,11 @@ templates, see [EXTENSIONS.md](EXTENSIONS.md).
|
|
|
11
11
|
|
|
12
12
|
## What's Here
|
|
13
13
|
|
|
14
|
-
### Hooks (
|
|
14
|
+
### Hooks (4)
|
|
15
15
|
|
|
16
16
|
| Artifact | What It Does |
|
|
17
17
|
|----------|-------------|
|
|
18
18
|
| `hooks/git-guardrails.sh` | PreToolUse hook that blocks destructive git operations (force push to main, hard reset, git clean). Zero configuration. |
|
|
19
|
-
| `hooks/stop-hook.md` | Stop event hook that checks whether the session-closing skill ran. Prompt-type (advisory, not blocking). |
|
|
20
19
|
| `hooks/skill-telemetry.sh` | UserPromptSubmit hook that detects /skill-name invocations and logs to JSONL. Configurable via env vars. |
|
|
21
20
|
| `hooks/skill-tool-telemetry.sh` | PostToolUse hook that captures programmatic Skill tool invocations. Configurable via env vars. |
|
|
22
21
|
| `hooks/cc-upstream-guard.sh` | PreToolUse hook that blocks edits to manifest-tracked upstream files. Prevents downstream drift. |
|
|
@@ -115,7 +114,7 @@ mandates and scoped directives.
|
|
|
115
114
|
| `scripts/finding-schema.json` | JSON Schema for audit finding validation. |
|
|
116
115
|
| `scripts/load-triage-history.js` | Build suppression lists from triage history. Tries pib-db first, falls back to filesystem. |
|
|
117
116
|
| `scripts/merge-findings.js` | Merge per-cabinet-member JSON outputs into unified run-summary. Optional `--db` flag for pib-db ingestion. |
|
|
118
|
-
| `scripts/pib-db.
|
|
117
|
+
| `scripts/pib-db.mjs` | Reference data layer CLI. SQLite for work tracking (actions, projects) and audit findings. |
|
|
119
118
|
| `scripts/pib-db-schema.sql` | Database schema: projects, actions, audit_runs, audit_findings. |
|
|
120
119
|
| `scripts/resolve-committees.cjs` | Merge upstream `committees.yaml` with project `committees-project.yaml`. Deterministic output. |
|
|
121
120
|
| `scripts/triage-server.mjs` | Self-contained Node.js HTTP server for triage UI. Zero external dependencies. |
|
|
@@ -171,7 +170,7 @@ into your project's `.claude/` directory. The minimum viable adoption:
|
|
|
171
170
|
|
|
172
171
|
You now have git safety and skill discovery. Add more modules as needed:
|
|
173
172
|
|
|
174
|
-
- **Session loop:** `skills/orient/`, `skills/debrief
|
|
173
|
+
- **Session loop:** `skills/orient/`, `skills/debrief/`
|
|
175
174
|
- **Planning:** `skills/plan/`, `skills/execute/`
|
|
176
175
|
- **Audit:** `skills/audit/`, `skills/pulse/`, `skills/triage-audit/`, plus `cabinet/` infrastructure and `scripts/`
|
|
177
176
|
- **Cabinet members:** Copy individual `skills/cabinet-*/` directories for the experts you want
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Omega Memory Guard — PreToolUse hook for Edit and Write tool calls
|
|
3
|
+
#
|
|
4
|
+
# When omega is available, blocks writes to flat markdown memory files.
|
|
5
|
+
# Semantic memories belong in omega (searchable, deduplicated, graph-linked).
|
|
6
|
+
# Flat markdown is the fallback ONLY when omega is unavailable.
|
|
7
|
+
#
|
|
8
|
+
# Scope:
|
|
9
|
+
# BLOCKS: .claude/memory/*.md, .claude/projects/*/memory/*.md
|
|
10
|
+
# ALLOWS: MEMORY.md index files (structural, not memory content)
|
|
11
|
+
# ALLOWS: memory/patterns/*.md (enforcement pipeline artifacts)
|
|
12
|
+
# ALLOWS: Everything if omega is unavailable (flat markdown IS correct fallback)
|
|
13
|
+
#
|
|
14
|
+
# ROLLBACK: Comment out the PreToolUse entry for this hook in
|
|
15
|
+
# .claude/settings.json to disable it immediately.
|
|
16
|
+
#
|
|
17
|
+
# Hook contract:
|
|
18
|
+
# Input: $CLAUDE_TOOL_INPUT has the tool use JSON with "file_path" field
|
|
19
|
+
# Output: JSON on stdout with { "decision": "block"|"allow", "reason": "..." }
|
|
20
|
+
|
|
21
|
+
# Extract file_path from tool input
|
|
22
|
+
FILE_PATH=$(echo "$CLAUDE_TOOL_INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('file_path',''))" 2>/dev/null)
|
|
23
|
+
|
|
24
|
+
if [ -z "$FILE_PATH" ]; then
|
|
25
|
+
echo '{"decision":"allow"}'
|
|
26
|
+
exit 0
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# Only care about memory directory paths
|
|
30
|
+
case "$FILE_PATH" in
|
|
31
|
+
*/.claude/memory/*|*/.claude/projects/*/memory/*)
|
|
32
|
+
;;
|
|
33
|
+
*)
|
|
34
|
+
echo '{"decision":"allow"}'
|
|
35
|
+
exit 0
|
|
36
|
+
;;
|
|
37
|
+
esac
|
|
38
|
+
|
|
39
|
+
# Allow MEMORY.md index files (structural, not memory content)
|
|
40
|
+
BASENAME=$(basename "$FILE_PATH")
|
|
41
|
+
if [ "$BASENAME" = "MEMORY.md" ]; then
|
|
42
|
+
echo '{"decision":"allow"}'
|
|
43
|
+
exit 0
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# Allow pattern files (enforcement pipeline artifacts, not semantic memories)
|
|
47
|
+
case "$FILE_PATH" in
|
|
48
|
+
*/memory/patterns/*)
|
|
49
|
+
echo '{"decision":"allow"}'
|
|
50
|
+
exit 0
|
|
51
|
+
;;
|
|
52
|
+
esac
|
|
53
|
+
|
|
54
|
+
# Check if omega is available
|
|
55
|
+
OMEGA_PYTHON="$HOME/.claude-cabinet/omega-venv/bin/python3"
|
|
56
|
+
if [ ! -x "$OMEGA_PYTHON" ]; then
|
|
57
|
+
# Omega not available — flat markdown IS the correct fallback
|
|
58
|
+
echo '{"decision":"allow"}'
|
|
59
|
+
exit 0
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# Find the adapter script
|
|
63
|
+
find_adapter() {
|
|
64
|
+
local dir="$PWD"
|
|
65
|
+
while [ "$dir" != "/" ]; do
|
|
66
|
+
if [ -f "$dir/scripts/cabinet-memory-adapter.py" ]; then
|
|
67
|
+
echo "$dir/scripts/cabinet-memory-adapter.py"
|
|
68
|
+
return 0
|
|
69
|
+
fi
|
|
70
|
+
dir=$(dirname "$dir")
|
|
71
|
+
done
|
|
72
|
+
return 1
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
ADAPTER=$(find_adapter)
|
|
76
|
+
if [ -z "$ADAPTER" ]; then
|
|
77
|
+
# No adapter found — flat markdown fallback is correct
|
|
78
|
+
echo '{"decision":"allow"}'
|
|
79
|
+
exit 0
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# Omega is available — block the flat markdown write
|
|
83
|
+
echo "{\"decision\":\"block\",\"reason\":\"Omega is active — use omega_store() or the adapter instead of writing to flat markdown memory files. Run: echo '{\\\"text\\\": \\\"your memory\\\", \\\"type\\\": \\\"lesson\\\"}' | $OMEGA_PYTHON $ADAPTER store\"}"
|
|
@@ -117,7 +117,7 @@ console.log(` critical: ${severityCounts.critical}, warn: ${severityCounts.warn
|
|
|
117
117
|
// ---------------------------------------------------------------------------
|
|
118
118
|
if (useDb) {
|
|
119
119
|
try {
|
|
120
|
-
const pibDb = join(__dirname, 'pib-db.
|
|
120
|
+
const pibDb = join(__dirname, 'pib-db.mjs');
|
|
121
121
|
execSync(`node "${pibDb}" ingest-findings "${runDir}"`, { stdio: 'inherit' });
|
|
122
122
|
} catch (err) {
|
|
123
123
|
console.error(`DB ingest failed: ${err.message}`);
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
-- This is the default persistence layer. Projects that outgrow it
|
|
4
4
|
-- override via phase files (pointing to their own API, DB, or service).
|
|
5
5
|
--
|
|
6
|
-
-- Initialize: node scripts/pib-db.
|
|
7
|
-
-- Query: node scripts/pib-db.
|
|
6
|
+
-- Initialize: node scripts/pib-db.mjs init
|
|
7
|
+
-- Query: node scripts/pib-db.mjs query "SELECT ..."
|
|
8
8
|
|
|
9
9
|
CREATE TABLE IF NOT EXISTS projects (
|
|
10
10
|
fid TEXT PRIMARY KEY CHECK(fid GLOB 'prj:*'),
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
// override via phase files (pointing to their own API, DB, or service).
|
|
7
7
|
//
|
|
8
8
|
// Usage:
|
|
9
|
-
// node scripts/pib-db.
|
|
10
|
-
// node scripts/pib-db.
|
|
11
|
-
// node scripts/pib-db.
|
|
12
|
-
// node scripts/pib-db.
|
|
13
|
-
// node scripts/pib-db.
|
|
14
|
-
// node scripts/pib-db.
|
|
15
|
-
// node scripts/pib-db.
|
|
16
|
-
// node scripts/pib-db.
|
|
17
|
-
// node scripts/pib-db.
|
|
18
|
-
// node scripts/pib-db.
|
|
19
|
-
// node scripts/pib-db.
|
|
9
|
+
// node scripts/pib-db.mjs init # Create/migrate DB
|
|
10
|
+
// node scripts/pib-db.mjs query "SELECT * FROM ..." # Run a query
|
|
11
|
+
// node scripts/pib-db.mjs create-action "Do the thing" --area dev
|
|
12
|
+
// node scripts/pib-db.mjs list-actions [--status X] # Open actions (or filtered)
|
|
13
|
+
// node scripts/pib-db.mjs update-action act:abc --status in-progress
|
|
14
|
+
// node scripts/pib-db.mjs complete-action act:abc123
|
|
15
|
+
// node scripts/pib-db.mjs create-project "My Project" --area dev
|
|
16
|
+
// node scripts/pib-db.mjs list-projects # Active projects
|
|
17
|
+
// node scripts/pib-db.mjs ingest-findings <run-dir> # Ingest audit findings
|
|
18
|
+
// node scripts/pib-db.mjs triage <finding-id> <status> [notes]
|
|
19
|
+
// node scripts/pib-db.mjs triage-history # Suppression list JSON
|
|
20
20
|
//
|
|
21
21
|
// Environment:
|
|
22
22
|
// PIB_DB_PATH — path to SQLite file (default: ./pib.db)
|
|
@@ -44,9 +44,16 @@ function getDb() {
|
|
|
44
44
|
db.pragma('journal_mode = WAL');
|
|
45
45
|
db.pragma('foreign_keys = ON');
|
|
46
46
|
return db;
|
|
47
|
-
} catch {
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (err.code === 'ERR_DLOPEN_FAILED') {
|
|
49
|
+
console.error('Error: better-sqlite3 native module version mismatch.');
|
|
50
|
+
console.error(' Rebuild it for your current Node version:');
|
|
51
|
+
console.error(' npm rebuild better-sqlite3');
|
|
52
|
+
} else {
|
|
53
|
+
console.error('Error: better-sqlite3 not found. Install it:');
|
|
54
|
+
console.error(' npm install better-sqlite3');
|
|
55
|
+
}
|
|
56
|
+
if (err.message) console.error(` (${err.message.split('\n')[0]})`);
|
|
50
57
|
process.exit(1);
|
|
51
58
|
}
|
|
52
59
|
}
|
|
@@ -344,7 +351,7 @@ switch (command) {
|
|
|
344
351
|
triageHistory();
|
|
345
352
|
break;
|
|
346
353
|
default:
|
|
347
|
-
console.log(`Usage: pib-db.
|
|
354
|
+
console.log(`Usage: pib-db.mjs <command>
|
|
348
355
|
|
|
349
356
|
Commands:
|
|
350
357
|
init Create/migrate the database
|
|
@@ -18,7 +18,7 @@ const DB_PATH = resolve(process.argv.find((_, i, a) => a[i - 1] === '--db') || '
|
|
|
18
18
|
|
|
19
19
|
if (!existsSync(DB_PATH)) {
|
|
20
20
|
console.error(`Database not found: ${DB_PATH}`);
|
|
21
|
-
console.error('Run: node scripts/pib-db.
|
|
21
|
+
console.error('Run: node scripts/pib-db.mjs init');
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -222,7 +222,7 @@ drift between the two:
|
|
|
222
222
|
- Work tracking specifically: the pib-db scripts ship with both the
|
|
223
223
|
work-tracking and audit modules, so `.ccrc.json` alone doesn't tell
|
|
224
224
|
you if work tracking is active. Check whether `pib.db` exists AND
|
|
225
|
-
has projects/actions with real data (`node scripts/pib-db.
|
|
225
|
+
has projects/actions with real data (`node scripts/pib-db.mjs
|
|
226
226
|
list-projects`). If it does but the briefing says "no work tracking,"
|
|
227
227
|
that's a direct contradiction.
|
|
228
228
|
- `.ccrc.json` version vs `package.json` version — they should match.
|
|
@@ -268,9 +268,9 @@ anything that future sessions need to know? A new pattern, a gotcha,
|
|
|
268
268
|
a process gap, a user preference? Lessons are perishable — capture
|
|
269
269
|
them now while context is fresh.
|
|
270
270
|
|
|
271
|
-
**Omega-
|
|
271
|
+
**Omega-only:** If `~/.claude-cabinet/omega-venv/bin/python3` and
|
|
272
272
|
`scripts/cabinet-memory-adapter.py` both exist, write lessons to omega
|
|
273
|
-
|
|
273
|
+
— never to flat markdown. A guard hook enforces this. Use the adapter:
|
|
274
274
|
|
|
275
275
|
```bash
|
|
276
276
|
echo '{"text": "the lesson", "type": "lesson"}' | \
|
|
@@ -278,7 +278,7 @@ echo '{"text": "the lesson", "type": "lesson"}' | \
|
|
|
278
278
|
```
|
|
279
279
|
|
|
280
280
|
Types: `decision`, `lesson`, `preference`, `constraint`, `pattern`.
|
|
281
|
-
|
|
281
|
+
Flat markdown memory is the fallback only when omega is unavailable.
|
|
282
282
|
|
|
283
283
|
**Omega broken:** If the memory module is installed (check `.ccrc.json`
|
|
284
284
|
for `"memory": true`) but the venv or adapter is missing, surface this
|
|
@@ -16,13 +16,13 @@ When no custom close-work is configured:
|
|
|
16
16
|
|
|
17
17
|
1. **Get session work:** Review `git log --oneline` for this session's
|
|
18
18
|
commits (since session start or last 2 hours)
|
|
19
|
-
2. **Get open actions:** `node scripts/pib-db.
|
|
19
|
+
2. **Get open actions:** `node scripts/pib-db.mjs list-actions`
|
|
20
20
|
3. **Match:** For each open action, check if this session's work
|
|
21
21
|
addresses it (compare action text/notes against commit messages
|
|
22
22
|
and changed files)
|
|
23
23
|
4. **Propose:** Present matched actions and ask the user to confirm
|
|
24
24
|
which to close
|
|
25
|
-
5. **Close confirmed:** `node scripts/pib-db.
|
|
25
|
+
5. **Close confirmed:** `node scripts/pib-db.mjs complete-action <fid>`
|
|
26
26
|
|
|
27
27
|
If pib-db doesn't exist, skip with a note.
|
|
28
28
|
|
|
@@ -96,7 +96,7 @@ leaving it active is stale state that erodes trust in the work tracker.
|
|
|
96
96
|
When using pib-db (default):
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
|
-
node scripts/pib-db.
|
|
99
|
+
node scripts/pib-db.mjs query "
|
|
100
100
|
SELECT p.fid, p.name,
|
|
101
101
|
(SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid) as total,
|
|
102
102
|
(SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid AND a.completed = 1) as done
|
|
@@ -111,7 +111,7 @@ node scripts/pib-db.js query "
|
|
|
111
111
|
For each result: all actions are complete. Propose completing the project:
|
|
112
112
|
- Show the project name and action count (e.g., "prj:abc — My Project (5/5 actions done)")
|
|
113
113
|
- Ask the user to confirm before closing
|
|
114
|
-
- On confirmation: `node scripts/pib-db.
|
|
114
|
+
- On confirmation: `node scripts/pib-db.mjs query "UPDATE projects SET status = 'done', completed_at = date('now') WHERE fid = '<fid>'"`
|
|
115
115
|
|
|
116
116
|
**Design notes:**
|
|
117
117
|
- Projects with zero total actions are excluded — they may be containers
|
|
@@ -18,9 +18,9 @@ Check whether omega memory is available:
|
|
|
18
18
|
- `~/.claude-cabinet/omega-venv/bin/python3` exists AND
|
|
19
19
|
- `scripts/cabinet-memory-adapter.py` exists
|
|
20
20
|
|
|
21
|
-
**When omega is available
|
|
22
|
-
the adapter.
|
|
23
|
-
|
|
21
|
+
**When omega is available — use it. No exceptions.** Write lessons to
|
|
22
|
+
omega via the adapter. Never write to flat markdown memory files when
|
|
23
|
+
omega is available — a guard hook will block the attempt.
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
echo '{"text": "the lesson", "type": "lesson", "tags": ["tag1"]}' | \
|
|
@@ -34,10 +34,9 @@ Memory types to use:
|
|
|
34
34
|
- `constraint` — limitations discovered, prerequisites found
|
|
35
35
|
- `pattern` — conventions established, recurring solutions
|
|
36
36
|
|
|
37
|
-
**When omega is NOT available
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
retrieval.
|
|
37
|
+
**When omega is NOT available:** Only then use flat markdown memory
|
|
38
|
+
(auto-memory in `~/.claude/projects/` memory directory). Check omega
|
|
39
|
+
availability first — don't assume it's unavailable without checking.
|
|
41
40
|
|
|
42
41
|
## What to Look For
|
|
43
42
|
|
|
@@ -57,7 +57,7 @@ Read `phases/fetch-plans.md` for where plans come from.
|
|
|
57
57
|
surface area declarations:
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
|
-
node scripts/pib-db.
|
|
60
|
+
node scripts/pib-db.mjs query "
|
|
61
61
|
SELECT a.fid, a.text, a.notes
|
|
62
62
|
FROM actions a
|
|
63
63
|
WHERE a.completed = 0 AND a.deleted_at IS NULL
|
|
@@ -200,7 +200,7 @@ Read `phases/completion.md` for how to mark plans as done after execution.
|
|
|
200
200
|
|
|
201
201
|
**Default (absent/empty):** Mark completed plans via pib-db:
|
|
202
202
|
```bash
|
|
203
|
-
node scripts/pib-db.
|
|
203
|
+
node scripts/pib-db.mjs complete-action <fid>
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
Projects using external APIs or different work trackers define this phase.
|
|
@@ -44,7 +44,7 @@ generated phase files:
|
|
|
44
44
|
|
|
45
45
|
- **Skipped modules:** No phase file should reference a skipped module's
|
|
46
46
|
infrastructure. If work-tracking was skipped, no phase should reference
|
|
47
|
-
`pib.db` or `pib-db.
|
|
47
|
+
`pib.db` or `pib-db.mjs`. If audit was skipped, no phase should reference
|
|
48
48
|
`committees.yaml`, `committees-project.yaml`, or cabinet member activation.
|
|
49
49
|
- **Installed modules:** Each installed module should have at least a
|
|
50
50
|
minimal presence in the generated configuration. A module that's installed
|
|
@@ -56,8 +56,8 @@ that CC skills (orient, debrief, plan) use by default.
|
|
|
56
56
|
- Projects that also use the audit loop (findings can link to actions)
|
|
57
57
|
|
|
58
58
|
**What gets set up:**
|
|
59
|
-
- `pib.db` — SQLite database (created by `node scripts/pib-db.
|
|
60
|
-
- `scripts/pib-db.
|
|
59
|
+
- `pib.db` — SQLite database (created by `node scripts/pib-db.mjs init`)
|
|
60
|
+
- `scripts/pib-db.mjs` — CLI for create/query/close operations
|
|
61
61
|
- `scripts/pib-db-schema.sql` — Schema definition
|
|
62
62
|
- Orient `work-scan.md` phase — queries pib-db for open items
|
|
63
63
|
- Plan `work-tracker.md` phase — creates actions from plans
|
|
@@ -126,12 +126,12 @@ Read `phases/work-scan.md` for what work items to check. This includes
|
|
|
126
126
|
whatever the project uses to track work: a backlog, task list, inbox,
|
|
127
127
|
queue, or issue tracker.
|
|
128
128
|
|
|
129
|
-
**Default (absent/empty):** If `scripts/pib-db.
|
|
129
|
+
**Default (absent/empty):** If `scripts/pib-db.mjs` exists, run the
|
|
130
130
|
standard work scan:
|
|
131
131
|
|
|
132
132
|
1. **Active projects and open actions:**
|
|
133
133
|
```bash
|
|
134
|
-
node scripts/pib-db.
|
|
134
|
+
node scripts/pib-db.mjs query "
|
|
135
135
|
SELECT p.fid, p.name,
|
|
136
136
|
(SELECT COUNT(*) FROM actions a WHERE a.project_fid = p.fid AND a.completed = 0 AND a.deleted_at IS NULL) as open_actions
|
|
137
137
|
FROM projects p
|
|
@@ -142,7 +142,7 @@ standard work scan:
|
|
|
142
142
|
|
|
143
143
|
2. **Flagged actions** (prioritized items needing attention):
|
|
144
144
|
```bash
|
|
145
|
-
node scripts/pib-db.
|
|
145
|
+
node scripts/pib-db.mjs query "
|
|
146
146
|
SELECT a.fid, a.text, p.name as project
|
|
147
147
|
FROM actions a
|
|
148
148
|
LEFT JOIN projects p ON a.project_fid = p.fid
|
|
@@ -154,7 +154,7 @@ standard work scan:
|
|
|
154
154
|
|
|
155
155
|
**Completion candidates** — active projects where all actions are done:
|
|
156
156
|
```bash
|
|
157
|
-
node scripts/pib-db.
|
|
157
|
+
node scripts/pib-db.mjs query "
|
|
158
158
|
SELECT p.fid, p.name
|
|
159
159
|
FROM projects p
|
|
160
160
|
WHERE p.status = 'active' AND p.deleted_at IS NULL
|
|
@@ -165,7 +165,7 @@ standard work scan:
|
|
|
165
165
|
|
|
166
166
|
**Stale projects** — active projects with no action completed in 14+ days:
|
|
167
167
|
```bash
|
|
168
|
-
node scripts/pib-db.
|
|
168
|
+
node scripts/pib-db.mjs query "
|
|
169
169
|
SELECT p.fid, p.name,
|
|
170
170
|
MAX(a.completed_at) as last_completion
|
|
171
171
|
FROM projects p
|
|
@@ -259,9 +259,21 @@ Read `phases/briefing.md` for how to present the orientation results.
|
|
|
259
259
|
This phase controls format, sections, tone, and any time-aware or
|
|
260
260
|
context-aware presentation modes.
|
|
261
261
|
|
|
262
|
-
**Default (absent/empty):** Present a
|
|
263
|
-
in
|
|
264
|
-
|
|
262
|
+
**Default (absent/empty):** Present a structured briefing with these
|
|
263
|
+
required sections in this order:
|
|
264
|
+
|
|
265
|
+
1. **Project State** — version, what's active, high-level status
|
|
266
|
+
2. **Work Items** — active projects, open action counts, flagged/overdue
|
|
267
|
+
items listed explicitly
|
|
268
|
+
3. **Attention Items** — anything surfaced by health checks, feedback
|
|
269
|
+
reports, extraction proposals, stale/completable projects
|
|
270
|
+
4. **Maintenance** — omega consolidation results, any weekly tasks run
|
|
271
|
+
5. **Cabinet Notes** — output from cabinet consultations (only if they
|
|
272
|
+
had something to say)
|
|
273
|
+
|
|
274
|
+
Keep sections consistent across sessions. Omit a section only if it
|
|
275
|
+
has literally nothing to report (not "nothing interesting" — nothing
|
|
276
|
+
at all). Use the same section names and order every time.
|
|
265
277
|
|
|
266
278
|
### 9. Show Available Skills (core)
|
|
267
279
|
|
|
@@ -7,7 +7,7 @@ only report on project state, not on what needs doing.
|
|
|
7
7
|
When this file is absent or empty, the default behavior is: query the
|
|
8
8
|
reference data layer (pib-db) for open actions and projects. If pib-db
|
|
9
9
|
is not initialized, skip gracefully with a note that work tracking is
|
|
10
|
-
available via `node scripts/pib-db.
|
|
10
|
+
available via `node scripts/pib-db.mjs init`.
|
|
11
11
|
|
|
12
12
|
## Default Behavior (pib-db)
|
|
13
13
|
|
|
@@ -15,10 +15,10 @@ When no custom work-scan is configured, query pib-db:
|
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
# Open actions (overdue first, then due today, then flagged, then recent)
|
|
18
|
-
node scripts/pib-db.
|
|
18
|
+
node scripts/pib-db.mjs list-actions
|
|
19
19
|
|
|
20
20
|
# Active projects with open action counts
|
|
21
|
-
node scripts/pib-db.
|
|
21
|
+
node scripts/pib-db.mjs list-projects
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Present grouped by urgency:
|
|
@@ -28,7 +28,7 @@ Present grouped by urgency:
|
|
|
28
28
|
- **Recent** — actions created in the last 7 days
|
|
29
29
|
|
|
30
30
|
If pib-db doesn't exist (file not found), skip with: "Work tracking
|
|
31
|
-
available — run `node scripts/pib-db.
|
|
31
|
+
available — run `node scripts/pib-db.mjs init` to set up."
|
|
32
32
|
|
|
33
33
|
## What to Include
|
|
34
34
|
|
|
@@ -249,13 +249,13 @@ of phase file content.
|
|
|
249
249
|
Read `phases/work-tracker.md` for how to file the approved plan as a
|
|
250
250
|
work item in your project's tracking system.
|
|
251
251
|
|
|
252
|
-
**Default (absent/empty):** If `scripts/pib-db.
|
|
252
|
+
**Default (absent/empty):** If `scripts/pib-db.mjs` exists, file the
|
|
253
253
|
approved plan as a pib-db action. Use the plan title as the action text
|
|
254
254
|
and the full plan (with surface area, acceptance criteria, etc.) as the
|
|
255
255
|
notes. If the plan belongs to an existing project, associate it:
|
|
256
256
|
|
|
257
257
|
```bash
|
|
258
|
-
node scripts/pib-db.
|
|
258
|
+
node scripts/pib-db.mjs create-action --text "<plan title>" --project "<project fid>" --notes "<full plan>"
|
|
259
259
|
```
|
|
260
260
|
|
|
261
261
|
If pib-db doesn't exist, present the plan in conversation for the user
|
|
@@ -14,7 +14,7 @@ When no custom overlap check is configured:
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
# Search open actions for keywords related to the proposed work
|
|
17
|
-
node scripts/pib-db.
|
|
17
|
+
node scripts/pib-db.mjs query "SELECT fid, text, substr(notes, 1, 200) as notes_preview FROM actions WHERE completed = 0 AND deleted_at IS NULL AND (text LIKE '%keyword%' OR notes LIKE '%keyword%')"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Search with multiple keywords derived from the proposed plan's problem
|
|
@@ -6,7 +6,7 @@ tracking system. The /plan skill reads this file after user approval.
|
|
|
6
6
|
When this file is absent or empty, the default behavior is: create an
|
|
7
7
|
action in the reference data layer (pib-db) with the plan summary in
|
|
8
8
|
notes. If pib-db is not initialized, note that work tracking is available
|
|
9
|
-
via `node scripts/pib-db.
|
|
9
|
+
via `node scripts/pib-db.mjs init`.
|
|
10
10
|
|
|
11
11
|
## Default Behavior (pib-db)
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ When no custom work tracker is configured:
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
# Create an action for the approved plan
|
|
17
|
-
node scripts/pib-db.
|
|
17
|
+
node scripts/pib-db.mjs create-action "Short imperative plan title" \
|
|
18
18
|
--area "<area>" \
|
|
19
19
|
--notes "## Problem\n...\n\n## Implementation\n..."
|
|
20
20
|
```
|
|
@@ -26,7 +26,7 @@ If the plan relates to an existing project in pib-db, include
|
|
|
26
26
|
`--project <project-fid>` to link them.
|
|
27
27
|
|
|
28
28
|
If pib-db doesn't exist, note: "Work tracking available — run
|
|
29
|
-
`node scripts/pib-db.
|
|
29
|
+
`node scripts/pib-db.mjs init` to set up. Plan saved in conversation
|
|
30
30
|
only."
|
|
31
31
|
|
|
32
32
|
## What to Include
|
|
@@ -27,7 +27,7 @@ Define your verdict application strategy:
|
|
|
27
27
|
- If successful, update `triage_status = 'fixed'`
|
|
28
28
|
- If failed, create an action instead
|
|
29
29
|
3. If not auto-fixable:
|
|
30
|
-
- Create an action via `node scripts/pib-db.
|
|
30
|
+
- Create an action via `node scripts/pib-db.mjs create-action`
|
|
31
31
|
- Include finding details in action notes
|
|
32
32
|
|
|
33
33
|
### Defer Verdicts
|
|
@@ -29,7 +29,7 @@ Returns JSON array of findings in the same format as run-summary.json.
|
|
|
29
29
|
### Specific Run
|
|
30
30
|
Load findings from a specific audit run instead of all open findings:
|
|
31
31
|
```bash
|
|
32
|
-
node scripts/pib-db.
|
|
32
|
+
node scripts/pib-db.mjs query "SELECT * FROM audit_findings WHERE run_id = 'run-2026-04-01'"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Multiple Sources
|
|
@@ -13,7 +13,7 @@ related:
|
|
|
13
13
|
path: scripts/work-tracker-ui.html
|
|
14
14
|
role: "Browser-based work tracking interface"
|
|
15
15
|
- type: file
|
|
16
|
-
path: scripts/pib-db.
|
|
16
|
+
path: scripts/pib-db.mjs
|
|
17
17
|
role: "Data layer — projects and actions in pib.db"
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -32,7 +32,7 @@ and progress in a browser rather than through conversation.
|
|
|
32
32
|
```
|
|
33
33
|
If missing, initialize it:
|
|
34
34
|
```bash
|
|
35
|
-
node scripts/pib-db.
|
|
35
|
+
node scripts/pib-db.mjs init
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
2. **Start the server:**
|
|
@@ -45,7 +45,7 @@ and progress in a browser rather than through conversation.
|
|
|
45
45
|
|
|
46
46
|
4. **Stay available.** The user may come back with questions about what
|
|
47
47
|
they see, or ask you to create/update projects and actions based on
|
|
48
|
-
their review. Use `scripts/pib-db.
|
|
48
|
+
their review. Use `scripts/pib-db.mjs` for any mutations they request.
|
|
49
49
|
|
|
50
50
|
## Notes
|
|
51
51
|
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# Stop Hook Template
|
|
2
|
-
|
|
3
|
-
The Stop hook fires when a session is ending. It checks whether
|
|
4
|
-
substantive work was done without running the session-closing skill
|
|
5
|
-
(e.g., `/debrief`). If yes, it prompts to run it.
|
|
6
|
-
|
|
7
|
-
## How to Install
|
|
8
|
-
|
|
9
|
-
Add this to your `.claude/settings.json` under the `hooks` key:
|
|
10
|
-
|
|
11
|
-
```json
|
|
12
|
-
{
|
|
13
|
-
"hooks": {
|
|
14
|
-
"Stop": [
|
|
15
|
-
{
|
|
16
|
-
"matcher": "",
|
|
17
|
-
"hooks": [
|
|
18
|
-
{
|
|
19
|
-
"type": "prompt",
|
|
20
|
-
"prompt": "Check if substantive work was done without running the session-closing skill. If yes, prompt to run it.",
|
|
21
|
-
"statusMessage": "Checking session close compliance..."
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## How It Works
|
|
31
|
-
|
|
32
|
-
- **Event:** `Stop` — fires when the user ends the session
|
|
33
|
-
- **Type:** `prompt` — an LLM-evaluated check, not a deterministic script
|
|
34
|
-
- **Compliance:** ~80% — prompt-type hooks are advisory, not blocking
|
|
35
|
-
|
|
36
|
-
## Customization
|
|
37
|
-
|
|
38
|
-
Replace the prompt text with your project's specific closing skill name:
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
"Check if substantive work was done without /debrief. If yes, prompt to run it."
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This is the single most important anti-entropy hook in the methodology.
|
|
45
|
-
Without it, sessions end without capturing what happened, and the next
|
|
46
|
-
session starts blind. The session loop (orient → work → debrief) is the
|
|
47
|
-
system's learning mechanism. This hook guards the debrief step.
|
|
48
|
-
|
|
49
|
-
## Limitations
|
|
50
|
-
|
|
51
|
-
This is a prompt-type hook, not a command hook. It asks the LLM to check
|
|
52
|
-
and prompt — it doesn't deterministically block the session from ending.
|
|
53
|
-
Compliance is imperfect. This is an honest example of the anti-entropy
|
|
54
|
-
principle in action: debrief compliance has been a recurring friction
|
|
55
|
-
point in the reference implementation, promoted to a hook. It's better
|
|
56
|
-
than without. It's not 100%.
|