@nforma.ai/nforma 0.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 +22 -0
- package/README.md +1024 -0
- package/agents/qgsd-codebase-mapper.md +764 -0
- package/agents/qgsd-debugger.md +1201 -0
- package/agents/qgsd-executor.md +472 -0
- package/agents/qgsd-integration-checker.md +443 -0
- package/agents/qgsd-phase-researcher.md +502 -0
- package/agents/qgsd-plan-checker.md +643 -0
- package/agents/qgsd-planner.md +1182 -0
- package/agents/qgsd-project-researcher.md +621 -0
- package/agents/qgsd-quorum-orchestrator.md +628 -0
- package/agents/qgsd-quorum-slot-worker.md +41 -0
- package/agents/qgsd-quorum-synthesizer.md +133 -0
- package/agents/qgsd-quorum-test-worker.md +37 -0
- package/agents/qgsd-quorum-worker.md +161 -0
- package/agents/qgsd-research-synthesizer.md +239 -0
- package/agents/qgsd-roadmapper.md +660 -0
- package/agents/qgsd-verifier.md +628 -0
- package/bin/accept-debug-invariant.cjs +165 -0
- package/bin/account-manager.cjs +719 -0
- package/bin/aggregate-requirements.cjs +466 -0
- package/bin/analyze-assumptions.cjs +757 -0
- package/bin/analyze-state-space.cjs +921 -0
- package/bin/attribute-trace-divergence.cjs +150 -0
- package/bin/auth-drivers/gh-cli.cjs +93 -0
- package/bin/auth-drivers/index.cjs +46 -0
- package/bin/auth-drivers/pool.cjs +67 -0
- package/bin/auth-drivers/simple.cjs +95 -0
- package/bin/autoClosePtoF.cjs +110 -0
- package/bin/blessed-terminal.cjs +350 -0
- package/bin/build-phase-index.cjs +472 -0
- package/bin/call-quorum-slot.cjs +541 -0
- package/bin/ccr-secure-config.cjs +99 -0
- package/bin/ccr-secure-start.cjs +83 -0
- package/bin/check-bundled-sdks.cjs +177 -0
- package/bin/check-coverage-guard.cjs +112 -0
- package/bin/check-liveness-fairness.cjs +95 -0
- package/bin/check-mcp-health.cjs +123 -0
- package/bin/check-provider-health.cjs +395 -0
- package/bin/check-results-exit.cjs +24 -0
- package/bin/check-spec-sync.cjs +360 -0
- package/bin/check-trace-redaction.cjs +271 -0
- package/bin/check-trace-schema-drift.cjs +99 -0
- package/bin/compareDrift.cjs +21 -0
- package/bin/conformance-schema.cjs +12 -0
- package/bin/count-scenarios.cjs +420 -0
- package/bin/debt-dedup.cjs +144 -0
- package/bin/debt-ledger.cjs +61 -0
- package/bin/debt-retention.cjs +76 -0
- package/bin/debt-state-machine.cjs +80 -0
- package/bin/detect-coverage-gaps.cjs +204 -0
- package/bin/detect-project-intent.cjs +362 -0
- package/bin/export-prism-constants.cjs +164 -0
- package/bin/extract-annotations.cjs +633 -0
- package/bin/extractFormalExpected.cjs +104 -0
- package/bin/fingerprint-drift.cjs +24 -0
- package/bin/fingerprint-issue.cjs +46 -0
- package/bin/formal-core.cjs +519 -0
- package/bin/formal-ref-linker.cjs +141 -0
- package/bin/formal-test-sync.cjs +788 -0
- package/bin/generate-formal-specs.cjs +588 -0
- package/bin/generate-petri-net.cjs +397 -0
- package/bin/generate-phase-spec.cjs +249 -0
- package/bin/generate-proposed-changes.cjs +194 -0
- package/bin/generate-tla-cfg.cjs +122 -0
- package/bin/generate-traceability-matrix.cjs +701 -0
- package/bin/generate-triage-bundle.cjs +300 -0
- package/bin/gh-account-rotate.cjs +34 -0
- package/bin/initialize-model-registry.cjs +105 -0
- package/bin/install-formal-tools.cjs +382 -0
- package/bin/install.js +2424 -0
- package/bin/isNumericThreshold.cjs +34 -0
- package/bin/issue-classifier.cjs +151 -0
- package/bin/levenshtein.cjs +74 -0
- package/bin/lint-formal-models.cjs +580 -0
- package/bin/load-baseline-requirements.cjs +275 -0
- package/bin/manage-agents-core.cjs +815 -0
- package/bin/migrate-formal-dir.cjs +172 -0
- package/bin/migrate-planning.cjs +206 -0
- package/bin/migrate-to-slots.cjs +255 -0
- package/bin/nForma.cjs +2726 -0
- package/bin/observe-config.cjs +353 -0
- package/bin/observe-debt-writer.cjs +140 -0
- package/bin/observe-handler-grafana.cjs +128 -0
- package/bin/observe-handler-internal.cjs +301 -0
- package/bin/observe-handler-logstash.cjs +153 -0
- package/bin/observe-handler-prometheus.cjs +185 -0
- package/bin/observe-handlers.cjs +436 -0
- package/bin/observe-registry.cjs +131 -0
- package/bin/observe-render.cjs +168 -0
- package/bin/planning-paths.cjs +167 -0
- package/bin/polyrepo.cjs +560 -0
- package/bin/prism-priority.cjs +153 -0
- package/bin/probe-quorum-slots.cjs +167 -0
- package/bin/promote-model.cjs +225 -0
- package/bin/propose-debug-invariants.cjs +165 -0
- package/bin/providers.json +392 -0
- package/bin/pty-proxy.py +129 -0
- package/bin/qgsd-solve.cjs +2477 -0
- package/bin/quorum-consensus-gate.cjs +238 -0
- package/bin/quorum-formal-context.cjs +183 -0
- package/bin/quorum-slot-dispatch.cjs +934 -0
- package/bin/read-policy.cjs +60 -0
- package/bin/requirement-map.cjs +63 -0
- package/bin/requirements-core.cjs +247 -0
- package/bin/resolve-cli.cjs +101 -0
- package/bin/review-mcp-logs.cjs +294 -0
- package/bin/run-account-manager-tlc.cjs +188 -0
- package/bin/run-account-pool-alloy.cjs +158 -0
- package/bin/run-alloy.cjs +153 -0
- package/bin/run-audit-alloy.cjs +187 -0
- package/bin/run-breaker-tlc.cjs +181 -0
- package/bin/run-formal-check.cjs +395 -0
- package/bin/run-formal-verify.cjs +701 -0
- package/bin/run-installer-alloy.cjs +188 -0
- package/bin/run-oauth-rotation-prism.cjs +132 -0
- package/bin/run-oscillation-tlc.cjs +202 -0
- package/bin/run-phase-tlc.cjs +228 -0
- package/bin/run-prism.cjs +446 -0
- package/bin/run-protocol-tlc.cjs +201 -0
- package/bin/run-quorum-composition-alloy.cjs +155 -0
- package/bin/run-sensitivity-sweep.cjs +231 -0
- package/bin/run-stop-hook-tlc.cjs +188 -0
- package/bin/run-tlc.cjs +467 -0
- package/bin/run-transcript-alloy.cjs +173 -0
- package/bin/run-uppaal.cjs +264 -0
- package/bin/secrets.cjs +134 -0
- package/bin/sensitivity-report.cjs +219 -0
- package/bin/sensitivity-sweep-feedback.cjs +194 -0
- package/bin/set-secret.cjs +29 -0
- package/bin/setup-telemetry-cron.sh +36 -0
- package/bin/sweepPtoF.cjs +63 -0
- package/bin/sync-baseline-requirements.cjs +290 -0
- package/bin/task-envelope.cjs +360 -0
- package/bin/telemetry-collector.cjs +229 -0
- package/bin/unified-mcp-server.mjs +735 -0
- package/bin/update-agents.cjs +369 -0
- package/bin/update-scoreboard.cjs +1134 -0
- package/bin/validate-debt-entry.cjs +207 -0
- package/bin/validate-invariant.cjs +419 -0
- package/bin/validate-memory.cjs +389 -0
- package/bin/validate-requirements-haiku.cjs +435 -0
- package/bin/validate-traces.cjs +438 -0
- package/bin/verify-formal-results.cjs +124 -0
- package/bin/verify-quorum-health.cjs +273 -0
- package/bin/write-check-result.cjs +106 -0
- package/bin/xstate-to-tla.cjs +483 -0
- package/bin/xstate-trace-walker.cjs +205 -0
- package/commands/qgsd/add-phase.md +43 -0
- package/commands/qgsd/add-requirement.md +24 -0
- package/commands/qgsd/add-todo.md +47 -0
- package/commands/qgsd/audit-milestone.md +37 -0
- package/commands/qgsd/check-todos.md +45 -0
- package/commands/qgsd/cleanup.md +18 -0
- package/commands/qgsd/close-formal-gaps.md +33 -0
- package/commands/qgsd/complete-milestone.md +136 -0
- package/commands/qgsd/debug.md +166 -0
- package/commands/qgsd/discuss-phase.md +83 -0
- package/commands/qgsd/execute-phase.md +117 -0
- package/commands/qgsd/fix-tests.md +27 -0
- package/commands/qgsd/formal-test-sync.md +32 -0
- package/commands/qgsd/health.md +22 -0
- package/commands/qgsd/help.md +22 -0
- package/commands/qgsd/insert-phase.md +32 -0
- package/commands/qgsd/join-discord.md +18 -0
- package/commands/qgsd/list-phase-assumptions.md +46 -0
- package/commands/qgsd/map-codebase.md +71 -0
- package/commands/qgsd/map-requirements.md +20 -0
- package/commands/qgsd/mcp-restart.md +176 -0
- package/commands/qgsd/mcp-set-model.md +134 -0
- package/commands/qgsd/mcp-setup.md +1371 -0
- package/commands/qgsd/mcp-status.md +274 -0
- package/commands/qgsd/mcp-update.md +238 -0
- package/commands/qgsd/new-milestone.md +44 -0
- package/commands/qgsd/new-project.md +42 -0
- package/commands/qgsd/observe.md +260 -0
- package/commands/qgsd/pause-work.md +38 -0
- package/commands/qgsd/plan-milestone-gaps.md +34 -0
- package/commands/qgsd/plan-phase.md +44 -0
- package/commands/qgsd/polyrepo.md +50 -0
- package/commands/qgsd/progress.md +24 -0
- package/commands/qgsd/queue.md +54 -0
- package/commands/qgsd/quick.md +133 -0
- package/commands/qgsd/quorum-test.md +275 -0
- package/commands/qgsd/quorum.md +707 -0
- package/commands/qgsd/reapply-patches.md +110 -0
- package/commands/qgsd/remove-phase.md +31 -0
- package/commands/qgsd/research-phase.md +189 -0
- package/commands/qgsd/resume-work.md +40 -0
- package/commands/qgsd/set-profile.md +34 -0
- package/commands/qgsd/settings.md +39 -0
- package/commands/qgsd/solve.md +565 -0
- package/commands/qgsd/sync-baselines.md +119 -0
- package/commands/qgsd/triage.md +233 -0
- package/commands/qgsd/update.md +37 -0
- package/commands/qgsd/verify-work.md +38 -0
- package/hooks/dist/config-loader.js +297 -0
- package/hooks/dist/conformance-schema.cjs +12 -0
- package/hooks/dist/gsd-context-monitor.js +64 -0
- package/hooks/dist/qgsd-check-update.js +62 -0
- package/hooks/dist/qgsd-circuit-breaker.js +682 -0
- package/hooks/dist/qgsd-precompact.js +156 -0
- package/hooks/dist/qgsd-prompt.js +653 -0
- package/hooks/dist/qgsd-session-start.js +122 -0
- package/hooks/dist/qgsd-slot-correlator.js +58 -0
- package/hooks/dist/qgsd-spec-regen.js +86 -0
- package/hooks/dist/qgsd-statusline.js +91 -0
- package/hooks/dist/qgsd-stop.js +553 -0
- package/hooks/dist/qgsd-token-collector.js +133 -0
- package/hooks/dist/unified-mcp-server.mjs +669 -0
- package/package.json +95 -0
- package/scripts/build-hooks.js +46 -0
- package/scripts/postinstall.js +48 -0
- package/scripts/secret-audit.sh +45 -0
- package/templates/qgsd.json +49 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// hooks/qgsd-precompact.js
|
|
3
|
+
// PreCompact hook — injects QGSD session state as additionalContext before context compaction.
|
|
4
|
+
// Reads .planning/STATE.md "Current Position" section and any pending task files.
|
|
5
|
+
// Output survives compaction and appears in the first message of the compacted context.
|
|
6
|
+
// Fails open on all errors — never blocks compaction.
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
// Extract the "## Current Position" section from STATE.md content.
|
|
14
|
+
// Returns the trimmed text between "## Current Position" and the next "## " header.
|
|
15
|
+
// Returns null if the section is not found.
|
|
16
|
+
function extractCurrentPosition(stateContent) {
|
|
17
|
+
const startMarker = '## Current Position';
|
|
18
|
+
const startIdx = stateContent.indexOf(startMarker);
|
|
19
|
+
if (startIdx === -1) return null;
|
|
20
|
+
|
|
21
|
+
const afterStart = startIdx + startMarker.length;
|
|
22
|
+
// Find the next section header (## followed by a space at start of line)
|
|
23
|
+
const nextHeaderMatch = stateContent.slice(afterStart).search(/\n## /);
|
|
24
|
+
let section;
|
|
25
|
+
if (nextHeaderMatch === -1) {
|
|
26
|
+
section = stateContent.slice(afterStart);
|
|
27
|
+
} else {
|
|
28
|
+
section = stateContent.slice(afterStart, afterStart + nextHeaderMatch);
|
|
29
|
+
}
|
|
30
|
+
return section.trim() || null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Read pending task files without consuming them (unlike qgsd-prompt.js's consumePendingTask).
|
|
34
|
+
// Checks .claude/pending-task.txt and .claude/pending-task-*.txt files.
|
|
35
|
+
// Returns an array of { filename, content } objects for each file found.
|
|
36
|
+
function readPendingTasks(cwd) {
|
|
37
|
+
const claudeDir = path.join(cwd, '.claude');
|
|
38
|
+
const results = [];
|
|
39
|
+
|
|
40
|
+
if (!fs.existsSync(claudeDir)) return results;
|
|
41
|
+
|
|
42
|
+
// Check generic pending-task.txt first
|
|
43
|
+
const genericFile = path.join(claudeDir, 'pending-task.txt');
|
|
44
|
+
if (fs.existsSync(genericFile)) {
|
|
45
|
+
try {
|
|
46
|
+
const content = fs.readFileSync(genericFile, 'utf8').trim();
|
|
47
|
+
if (content) results.push({ filename: 'pending-task.txt', content });
|
|
48
|
+
} catch (e) {
|
|
49
|
+
process.stderr.write('[qgsd-precompact] Could not read ' + genericFile + ': ' + e.message + '\n');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check session-scoped pending-task-*.txt files
|
|
54
|
+
try {
|
|
55
|
+
const entries = fs.readdirSync(claudeDir);
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (entry.startsWith('pending-task-') && entry.endsWith('.txt') && !entry.endsWith('.claimed')) {
|
|
58
|
+
const filePath = path.join(claudeDir, entry);
|
|
59
|
+
try {
|
|
60
|
+
const content = fs.readFileSync(filePath, 'utf8').trim();
|
|
61
|
+
if (content) results.push({ filename: entry, content });
|
|
62
|
+
} catch (e) {
|
|
63
|
+
process.stderr.write('[qgsd-precompact] Could not read ' + filePath + ': ' + e.message + '\n');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
process.stderr.write('[qgsd-precompact] Could not read .claude dir: ' + e.message + '\n');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return results;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let raw = '';
|
|
75
|
+
process.stdin.setEncoding('utf8');
|
|
76
|
+
process.stdin.on('data', chunk => { raw += chunk; });
|
|
77
|
+
process.stdin.on('end', () => {
|
|
78
|
+
try {
|
|
79
|
+
const input = JSON.parse(raw);
|
|
80
|
+
const cwd = input.cwd || process.cwd();
|
|
81
|
+
|
|
82
|
+
const statePath = path.join(cwd, '.planning', 'STATE.md');
|
|
83
|
+
|
|
84
|
+
let additionalContext;
|
|
85
|
+
|
|
86
|
+
if (!fs.existsSync(statePath)) {
|
|
87
|
+
// No STATE.md — minimal context
|
|
88
|
+
additionalContext = 'QGSD session resumed after compaction. Run `cat .planning/STATE.md` for project state.';
|
|
89
|
+
} else {
|
|
90
|
+
let stateContent;
|
|
91
|
+
try {
|
|
92
|
+
stateContent = fs.readFileSync(statePath, 'utf8');
|
|
93
|
+
} catch (e) {
|
|
94
|
+
process.stderr.write('[qgsd-precompact] Could not read STATE.md: ' + e.message + '\n');
|
|
95
|
+
additionalContext = 'QGSD session resumed after compaction. Run `cat .planning/STATE.md` for project state.';
|
|
96
|
+
emitOutput(additionalContext);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const currentPosition = extractCurrentPosition(stateContent);
|
|
101
|
+
const pendingTasks = readPendingTasks(cwd);
|
|
102
|
+
|
|
103
|
+
const lines = [
|
|
104
|
+
'QGSD CONTINUATION CONTEXT (auto-injected at compaction)',
|
|
105
|
+
'',
|
|
106
|
+
'## Current Position',
|
|
107
|
+
currentPosition || '(Could not extract Current Position section — run `cat .planning/STATE.md` for full state.)',
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
if (pendingTasks.length > 0) {
|
|
111
|
+
lines.push('');
|
|
112
|
+
lines.push('## Pending Task');
|
|
113
|
+
// Include the first pending task found (generic file takes priority)
|
|
114
|
+
lines.push(pendingTasks[0].content);
|
|
115
|
+
if (pendingTasks.length > 1) {
|
|
116
|
+
process.stderr.write('[qgsd-precompact] Multiple pending task files found; injecting first: ' + pendingTasks[0].filename + '\n');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
lines.push('');
|
|
121
|
+
lines.push('## Resume Instructions');
|
|
122
|
+
lines.push('You are mid-session on a QGSD project. The context above shows where you were.');
|
|
123
|
+
lines.push('- If a PLAN.md is in progress, continue executing from the current plan.');
|
|
124
|
+
lines.push('- If a pending task is shown above, execute it next.');
|
|
125
|
+
lines.push('- Run `cat .planning/STATE.md` to get full project state if needed.');
|
|
126
|
+
lines.push('- All project rules in CLAUDE.md still apply (quorum required for planning commands).');
|
|
127
|
+
|
|
128
|
+
additionalContext = lines.join('\n');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
emitOutput(additionalContext);
|
|
132
|
+
|
|
133
|
+
} catch (e) {
|
|
134
|
+
process.stderr.write('[qgsd-precompact] Fatal error: ' + e.message + '\n');
|
|
135
|
+
process.exit(0); // Fail open — never block compaction
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
function emitOutput(additionalContext) {
|
|
140
|
+
process.stdout.write(JSON.stringify({
|
|
141
|
+
hookSpecificOutput: {
|
|
142
|
+
hookEventName: 'PreCompact',
|
|
143
|
+
additionalContext,
|
|
144
|
+
},
|
|
145
|
+
}));
|
|
146
|
+
process.exit(0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Export helpers for unit testing (tree-shaken at runtime — no cost)
|
|
150
|
+
// The file is a script and exits via process.exit() before reaching this line in normal operation.
|
|
151
|
+
// When require()d by tests, the stdin handler is registered but never fires, so module.exports is set.
|
|
152
|
+
if (typeof module !== 'undefined') {
|
|
153
|
+
module.exports = module.exports || {};
|
|
154
|
+
module.exports.extractCurrentPosition = extractCurrentPosition;
|
|
155
|
+
module.exports.readPendingTasks = readPendingTasks;
|
|
156
|
+
}
|