forgedev 1.2.0 → 1.3.0
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 +57 -10
- package/bin/chainproof.js +126 -0
- package/package.json +25 -7
- package/src/chainproof-bridge.js +330 -0
- package/src/ci-mode.js +85 -0
- package/src/claude-configurator.js +86 -49
- package/src/cli.js +30 -7
- package/src/composer.js +159 -34
- package/src/doctor-checks-chainproof.js +106 -0
- package/src/doctor-checks.js +39 -20
- package/src/doctor-prompts.js +9 -9
- package/src/doctor.js +37 -4
- package/src/guided.js +3 -3
- package/src/index.js +31 -10
- package/src/init-mode.js +64 -11
- package/src/menu.js +178 -0
- package/src/prompts.js +5 -12
- package/src/recommender.js +134 -10
- package/src/scanner.js +57 -2
- package/src/uat-generator.js +204 -189
- package/src/update-check.js +9 -4
- package/src/update.js +1 -1
- package/src/utils.js +64 -5
- package/templates/ai/guardrails-py/backend/app/ai/__init__.py +29 -0
- package/templates/ai/guardrails-py/backend/app/ai/audit_log.py +133 -0
- package/templates/ai/guardrails-py/backend/app/ai/client.py.template +323 -0
- package/templates/ai/guardrails-py/backend/app/ai/health.py.template +157 -0
- package/templates/ai/guardrails-py/backend/app/ai/input_guard.py +98 -0
- package/templates/ai/guardrails-ts/src/lib/ai/audit-log.ts.template +164 -0
- package/templates/ai/guardrails-ts/src/lib/ai/client.ts.template +403 -0
- package/templates/ai/guardrails-ts/src/lib/ai/health.ts.template +165 -0
- package/templates/ai/guardrails-ts/src/lib/ai/index.ts.template +17 -0
- package/templates/ai/guardrails-ts/src/lib/ai/input-guard.ts.template +124 -0
- package/templates/auth/nextauth/src/lib/auth.ts.template +12 -7
- package/templates/backend/express/Dockerfile.template +18 -0
- package/templates/backend/express/package.json.template +33 -0
- package/templates/backend/express/src/index.ts.template +34 -0
- package/templates/backend/express/src/routes/health.ts.template +27 -0
- package/templates/backend/express/tsconfig.json +17 -0
- package/templates/backend/fastapi/backend/Dockerfile.template +5 -0
- package/templates/backend/fastapi/backend/app/api/health.py.template +1 -1
- package/templates/backend/fastapi/backend/app/core/config.py.template +1 -1
- package/templates/backend/fastapi/backend/app/core/errors.py +1 -1
- package/templates/backend/fastapi/backend/app/main.py.template +3 -1
- package/templates/backend/fastapi/backend/requirements.txt.template +2 -0
- package/templates/backend/hono/Dockerfile.template +18 -0
- package/templates/backend/hono/package.json.template +31 -0
- package/templates/backend/hono/src/index.ts.template +32 -0
- package/templates/backend/hono/src/routes/health.ts.template +27 -0
- package/templates/backend/hono/tsconfig.json +18 -0
- package/templates/base/docs/uat/UAT_TEMPLATE.md.template +1 -1
- package/templates/chainproof/base/.chainproof/config.json.template +11 -0
- package/templates/chainproof/base/.chainproof/mcp-server.mjs +310 -0
- package/templates/chainproof/base/.mcp.json +9 -0
- package/templates/chainproof/fastapi/.chainproof/middleware.json.template +14 -0
- package/templates/chainproof/nextjs/.chainproof/hooks.json.template +19 -0
- package/templates/chainproof/polyglot/.chainproof/config.json.template +21 -0
- package/templates/claude-code/agents/architect.md +25 -11
- package/templates/claude-code/agents/build-error-resolver.md +19 -5
- package/templates/claude-code/agents/chief-of-staff.md +42 -8
- package/templates/claude-code/agents/code-quality-reviewer.md +14 -0
- package/templates/claude-code/agents/database-reviewer.md +15 -1
- package/templates/claude-code/agents/deep-reviewer.md +191 -0
- package/templates/claude-code/agents/doc-updater.md +19 -5
- package/templates/claude-code/agents/docs-lookup.md +19 -5
- package/templates/claude-code/agents/e2e-runner.md +26 -12
- package/templates/claude-code/agents/enforcement-gate.md +102 -0
- package/templates/claude-code/agents/frontend-builder.md +188 -0
- package/templates/claude-code/agents/harness-optimizer.md +36 -1
- package/templates/claude-code/agents/loop-operator.md +27 -13
- package/templates/claude-code/agents/planner.md +21 -7
- package/templates/claude-code/agents/product-strategist.md +24 -10
- package/templates/claude-code/agents/production-readiness.md +14 -0
- package/templates/claude-code/agents/prompt-auditor.md +115 -0
- package/templates/claude-code/agents/refactor-cleaner.md +22 -8
- package/templates/claude-code/agents/security-reviewer.md +14 -0
- package/templates/claude-code/agents/spec-validator.md +15 -1
- package/templates/claude-code/agents/tdd-guide.md +21 -7
- package/templates/claude-code/agents/uat-validator.md +14 -0
- package/templates/claude-code/claude-md/base.md +14 -7
- package/templates/claude-code/claude-md/fastapi.md +8 -8
- package/templates/claude-code/claude-md/fullstack.md +6 -6
- package/templates/claude-code/claude-md/hono.md +18 -0
- package/templates/claude-code/claude-md/nextjs.md +5 -5
- package/templates/claude-code/claude-md/remix.md +18 -0
- package/templates/claude-code/commands/audit-security.md +14 -0
- package/templates/claude-code/commands/audit-spec.md +14 -0
- package/templates/claude-code/commands/audit-wiring.md +14 -0
- package/templates/claude-code/commands/build-fix.md +28 -0
- package/templates/claude-code/commands/build-ui.md +59 -0
- package/templates/claude-code/commands/code-review.md +53 -31
- package/templates/claude-code/commands/fix-loop.md +211 -0
- package/templates/claude-code/commands/full-audit.md +36 -8
- package/templates/claude-code/commands/generate-prd.md +1 -1
- package/templates/claude-code/commands/generate-sdd.md +74 -0
- package/templates/claude-code/commands/generate-uat.md +107 -35
- package/templates/claude-code/commands/help.md +68 -0
- package/templates/claude-code/commands/live-uat.md +268 -0
- package/templates/claude-code/commands/optimize-claude-md.md +15 -1
- package/templates/claude-code/commands/plan.md +3 -3
- package/templates/claude-code/commands/pre-pr.md +57 -19
- package/templates/claude-code/commands/product-strategist.md +21 -0
- package/templates/claude-code/commands/resume-session.md +10 -10
- package/templates/claude-code/commands/run-uat.md +59 -2
- package/templates/claude-code/commands/save-session.md +10 -10
- package/templates/claude-code/commands/simplify.md +36 -0
- package/templates/claude-code/commands/tdd.md +17 -18
- package/templates/claude-code/commands/verify-all.md +24 -0
- package/templates/claude-code/commands/verify-intent.md +55 -0
- package/templates/claude-code/commands/workflows.md +52 -40
- package/templates/claude-code/hooks/polyglot.json +10 -1
- package/templates/claude-code/hooks/python.json +10 -1
- package/templates/claude-code/hooks/scripts/autofix-polyglot.mjs +2 -2
- package/templates/claude-code/hooks/scripts/autofix-python.mjs +1 -1
- package/templates/claude-code/hooks/scripts/autofix-typescript.mjs +1 -1
- package/templates/claude-code/hooks/scripts/code-hygiene.mjs +293 -0
- package/templates/claude-code/hooks/scripts/pre-commit-gate.mjs +207 -0
- package/templates/claude-code/hooks/typescript.json +10 -1
- package/templates/claude-code/skills/ai-prompts/SKILL.md +119 -41
- package/templates/claude-code/skills/git-workflow/SKILL.md +5 -5
- package/templates/claude-code/skills/nextjs/SKILL.md +1 -1
- package/templates/claude-code/skills/playwright/SKILL.md +5 -5
- package/templates/claude-code/skills/security-api/SKILL.md +1 -1
- package/templates/claude-code/skills/security-web/SKILL.md +1 -1
- package/templates/claude-code/skills/testing-patterns/SKILL.md +9 -9
- package/templates/database/prisma-postgres/{.env.example → .env.example.template} +1 -0
- package/templates/database/sqlalchemy-postgres/{.env.example → .env.example.template} +1 -0
- package/templates/docs-portal/fastapi/backend/app/portal/__pycache__/docs_reader.cpython-314.pyc +0 -0
- package/templates/docs-portal/fastapi/backend/app/portal/docs_reader.py +201 -0
- package/templates/docs-portal/fastapi/backend/app/portal/html_renderer.py +229 -0
- package/templates/docs-portal/fastapi/backend/app/portal/router.py.template +35 -0
- package/templates/docs-portal/nextjs/src/app/portal/[category]/[slug]/page.tsx +81 -0
- package/templates/docs-portal/nextjs/src/app/portal/[category]/page.tsx +65 -0
- package/templates/docs-portal/nextjs/src/app/portal/layout.tsx.template +54 -0
- package/templates/docs-portal/nextjs/src/app/portal/page.tsx +85 -0
- package/templates/docs-portal/nextjs/src/components/portal/markdown-renderer.tsx +101 -0
- package/templates/docs-portal/nextjs/src/components/portal/mobile-portal-nav.tsx +81 -0
- package/templates/docs-portal/nextjs/src/components/portal/portal-nav.tsx +86 -0
- package/templates/docs-portal/nextjs/src/lib/docs.ts +139 -0
- package/templates/frontend/nextjs/package.json.template +3 -1
- package/templates/frontend/react/index.html.template +12 -0
- package/templates/frontend/react/package.json.template +34 -0
- package/templates/frontend/react/src/App.tsx.template +10 -0
- package/templates/frontend/react/src/index.css +1 -0
- package/templates/frontend/react/src/main.tsx +10 -0
- package/templates/frontend/react/tsconfig.json +17 -0
- package/templates/frontend/react/vite.config.ts.template +15 -0
- package/templates/frontend/react/vitest.config.ts +9 -0
- package/templates/frontend/remix/app/root.tsx.template +31 -0
- package/templates/frontend/remix/app/routes/_index.tsx.template +19 -0
- package/templates/frontend/remix/app/routes/api.health.ts.template +10 -0
- package/templates/frontend/remix/app/tailwind.css +1 -0
- package/templates/frontend/remix/package.json.template +39 -0
- package/templates/frontend/remix/tsconfig.json +18 -0
- package/templates/frontend/remix/vite.config.ts.template +7 -0
- package/templates/infra/github-actions/.github/workflows/ci.yml.template +3 -0
- package/docs/00-README.md +0 -310
- package/docs/01-universal-prompt-library.md +0 -1049
- package/docs/02-claude-code-mastery-playbook.md +0 -283
- package/docs/03-multi-agent-verification.md +0 -565
- package/docs/04-errata-and-verification-checklist.md +0 -284
- package/docs/05-universal-scaffolder-vision.md +0 -452
- package/docs/06-confidence-assessment-and-repo-prompt.md +0 -407
- package/docs/errata.md +0 -58
- package/docs/multi-agent-verification.md +0 -66
- package/docs/playbook.md +0 -95
- package/docs/prompt-library.md +0 -160
- package/docs/uat/UAT_CHECKLIST.csv +0 -9
- package/docs/uat/UAT_TEMPLATE.md +0 -163
- package/templates/claude-code/commands/done.md +0 -19
- /package/{docs/plans/.gitkeep → templates/docs-portal/fastapi/backend/app/portal/__init__.py} +0 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ChainProof MCP Server — local file-based trust chain operations.
|
|
5
|
+
*
|
|
6
|
+
* Provides tools for recording AI decisions, tracking code provenance,
|
|
7
|
+
* and verifying trust chain integrity. Runs over stdio, no dependencies
|
|
8
|
+
* beyond Node.js built-ins.
|
|
9
|
+
*
|
|
10
|
+
* Auto-configured by DevForge. No setup required.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { createHash, generateKeyPairSync, sign, verify, randomUUID } from 'node:crypto';
|
|
16
|
+
import { createInterface } from 'node:readline';
|
|
17
|
+
|
|
18
|
+
// --- Project directory resolution ---
|
|
19
|
+
|
|
20
|
+
const PROJECT_DIR = process.env.CHAINPROOF_PROJECT_DIR || process.cwd();
|
|
21
|
+
const CP_DIR = path.join(PROJECT_DIR, '.chainproof');
|
|
22
|
+
const GENESIS_HASH = '0'.repeat(64);
|
|
23
|
+
|
|
24
|
+
// --- Crypto primitives ---
|
|
25
|
+
|
|
26
|
+
function hashContent(content) {
|
|
27
|
+
return createHash('sha256').update(content, 'utf-8').digest('hex');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function signEntry(content, privateKeyPem) {
|
|
31
|
+
const signature = sign(null, Buffer.from(content, 'utf-8'), privateKeyPem);
|
|
32
|
+
return signature.toString('base64');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function verifySignature(content, signatureB64, publicKeyPem) {
|
|
36
|
+
try {
|
|
37
|
+
return verify(null, Buffer.from(content, 'utf-8'), publicKeyPem, Buffer.from(signatureB64, 'base64'));
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function computeChainHash(prevHash, contentHash) {
|
|
44
|
+
return createHash('sha256').update(prevHash + contentHash, 'utf-8').digest('hex');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// --- File operations ---
|
|
48
|
+
|
|
49
|
+
function readJson(filePath) {
|
|
50
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function writeJson(filePath, data) {
|
|
54
|
+
const tmp = filePath + '.tmp';
|
|
55
|
+
fs.writeFileSync(tmp, JSON.stringify(data, null, 2) + '\n', 'utf-8');
|
|
56
|
+
fs.renameSync(tmp, filePath);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function ensureInitialized() {
|
|
60
|
+
if (!fs.existsSync(CP_DIR)) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
'No .chainproof/ directory found. Run "devforge init" or "chainproof init" first.'
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// --- Tool implementations ---
|
|
68
|
+
|
|
69
|
+
function recordDecision(content, entryType = 'decision') {
|
|
70
|
+
ensureInitialized();
|
|
71
|
+
const chainPath = path.join(CP_DIR, 'chain.json');
|
|
72
|
+
const chain = readJson(chainPath);
|
|
73
|
+
|
|
74
|
+
const contentHash = hashContent(content);
|
|
75
|
+
const prevHash = chain.currentHash;
|
|
76
|
+
const chainHash = computeChainHash(prevHash, contentHash);
|
|
77
|
+
|
|
78
|
+
let signature = null;
|
|
79
|
+
const keyPath = path.join(CP_DIR, 'keys', 'private.pem');
|
|
80
|
+
if (fs.existsSync(keyPath)) {
|
|
81
|
+
signature = signEntry(content, fs.readFileSync(keyPath, 'utf-8'));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const entry = {
|
|
85
|
+
id: randomUUID(),
|
|
86
|
+
timestamp: new Date().toISOString(),
|
|
87
|
+
entryType,
|
|
88
|
+
content,
|
|
89
|
+
contentHash,
|
|
90
|
+
prevHash,
|
|
91
|
+
chainHash,
|
|
92
|
+
signature,
|
|
93
|
+
sessionId: 'mcp-server',
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
chain.entries.push(entry);
|
|
97
|
+
chain.currentHash = chainHash;
|
|
98
|
+
writeJson(chainPath, chain);
|
|
99
|
+
|
|
100
|
+
return { id: entry.id, chainHash, signed: signature !== null };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function recordCode(filePath, contentHash, generator = 'unknown', language = null) {
|
|
104
|
+
ensureInitialized();
|
|
105
|
+
const artifactsPath = path.join(CP_DIR, 'artifacts.json');
|
|
106
|
+
const data = readJson(artifactsPath);
|
|
107
|
+
|
|
108
|
+
const record = {
|
|
109
|
+
id: randomUUID(),
|
|
110
|
+
timestamp: new Date().toISOString(),
|
|
111
|
+
filePath,
|
|
112
|
+
contentHash,
|
|
113
|
+
language,
|
|
114
|
+
generator,
|
|
115
|
+
promptHash: null,
|
|
116
|
+
nllEntryId: null,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
data.artifacts.push(record);
|
|
120
|
+
writeJson(artifactsPath, data);
|
|
121
|
+
|
|
122
|
+
return { id: record.id, filePath: record.filePath };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function verifyChainIntegrity() {
|
|
126
|
+
ensureInitialized();
|
|
127
|
+
const chain = readJson(path.join(CP_DIR, 'chain.json'));
|
|
128
|
+
const errors = [];
|
|
129
|
+
let expectedHash = GENESIS_HASH;
|
|
130
|
+
|
|
131
|
+
for (let i = 0; i < chain.entries.length; i++) {
|
|
132
|
+
const entry = chain.entries[i];
|
|
133
|
+
|
|
134
|
+
if (entry.prevHash !== expectedHash) {
|
|
135
|
+
errors.push(`Entry ${i}: prevHash mismatch`);
|
|
136
|
+
}
|
|
137
|
+
if (entry.contentHash !== hashContent(entry.content)) {
|
|
138
|
+
errors.push(`Entry ${i}: content was tampered`);
|
|
139
|
+
}
|
|
140
|
+
if (entry.chainHash !== computeChainHash(entry.prevHash, entry.contentHash)) {
|
|
141
|
+
errors.push(`Entry ${i}: chainHash mismatch`);
|
|
142
|
+
}
|
|
143
|
+
if (entry.signature) {
|
|
144
|
+
const pubPath = path.join(CP_DIR, 'keys', 'public.pem');
|
|
145
|
+
if (fs.existsSync(pubPath)) {
|
|
146
|
+
if (!verifySignature(entry.content, entry.signature, fs.readFileSync(pubPath, 'utf-8'))) {
|
|
147
|
+
errors.push(`Entry ${i}: invalid signature`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
expectedHash = entry.chainHash;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (chain.entries.length > 0 && chain.currentHash !== expectedHash) {
|
|
155
|
+
errors.push('currentHash does not match last entry');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return { valid: errors.length === 0, errors, entryCount: chain.entries.length };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getStatus() {
|
|
162
|
+
ensureInitialized();
|
|
163
|
+
const chain = readJson(path.join(CP_DIR, 'chain.json'));
|
|
164
|
+
|
|
165
|
+
let config = {};
|
|
166
|
+
const configPath = path.join(CP_DIR, 'config.json');
|
|
167
|
+
if (fs.existsSync(configPath)) config = readJson(configPath);
|
|
168
|
+
|
|
169
|
+
let artifacts = { artifacts: [] };
|
|
170
|
+
const artPath = path.join(CP_DIR, 'artifacts.json');
|
|
171
|
+
if (fs.existsSync(artPath)) artifacts = readJson(artPath);
|
|
172
|
+
|
|
173
|
+
const unsigned = chain.entries.filter(e => !e.signature).length;
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
initialized: true,
|
|
177
|
+
projectName: config.projectName || path.basename(PROJECT_DIR),
|
|
178
|
+
entryCount: chain.entries.length,
|
|
179
|
+
artifactCount: artifacts.artifacts.length,
|
|
180
|
+
currentHash: chain.currentHash,
|
|
181
|
+
unsignedEntries: unsigned,
|
|
182
|
+
createdAt: config.createdAt || null,
|
|
183
|
+
lastEntry: chain.entries.length > 0 ? chain.entries[chain.entries.length - 1].timestamp : null,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// --- MCP Protocol (JSON-RPC over stdio) ---
|
|
188
|
+
|
|
189
|
+
const TOOLS = [
|
|
190
|
+
{
|
|
191
|
+
name: 'chainproof_record_decision',
|
|
192
|
+
description: 'Record an AI decision in the trust chain. Use this when making architectural decisions, choosing implementations, or any significant choice during development.',
|
|
193
|
+
inputSchema: {
|
|
194
|
+
type: 'object',
|
|
195
|
+
properties: {
|
|
196
|
+
content: { type: 'string', description: 'The decision content to record' },
|
|
197
|
+
entry_type: { type: 'string', description: 'Type of entry: decision, implementation, review, refactor', default: 'decision' },
|
|
198
|
+
},
|
|
199
|
+
required: ['content'],
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'chainproof_record_code',
|
|
204
|
+
description: 'Record code provenance. Track who or what generated a file and its content hash.',
|
|
205
|
+
inputSchema: {
|
|
206
|
+
type: 'object',
|
|
207
|
+
properties: {
|
|
208
|
+
file_path: { type: 'string', description: 'Relative path to the file' },
|
|
209
|
+
content_hash: { type: 'string', description: 'SHA-256 hash of the file content' },
|
|
210
|
+
generator: { type: 'string', description: 'What generated this code (e.g., "claude-opus-4-6", "human")', default: 'unknown' },
|
|
211
|
+
language: { type: 'string', description: 'Programming language' },
|
|
212
|
+
},
|
|
213
|
+
required: ['file_path', 'content_hash'],
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'chainproof_verify',
|
|
218
|
+
description: 'Verify the integrity of the trust chain. Checks hash linking, content hashes, and signatures.',
|
|
219
|
+
inputSchema: { type: 'object', properties: {} },
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: 'chainproof_status',
|
|
223
|
+
description: 'Get the current status of the trust chain: entry count, artifact count, signature status.',
|
|
224
|
+
inputSchema: { type: 'object', properties: {} },
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
function handleToolCall(name, args) {
|
|
229
|
+
try {
|
|
230
|
+
switch (name) {
|
|
231
|
+
case 'chainproof_record_decision':
|
|
232
|
+
return recordDecision(args.content, args.entry_type || 'decision');
|
|
233
|
+
case 'chainproof_record_code':
|
|
234
|
+
return recordCode(args.file_path, args.content_hash, args.generator, args.language);
|
|
235
|
+
case 'chainproof_verify':
|
|
236
|
+
return verifyChainIntegrity();
|
|
237
|
+
case 'chainproof_status':
|
|
238
|
+
return getStatus();
|
|
239
|
+
default:
|
|
240
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
241
|
+
}
|
|
242
|
+
} catch (err) {
|
|
243
|
+
return { error: err.message };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function handleRequest(request) {
|
|
248
|
+
const { method, params, id } = request;
|
|
249
|
+
|
|
250
|
+
switch (method) {
|
|
251
|
+
case 'initialize':
|
|
252
|
+
return {
|
|
253
|
+
jsonrpc: '2.0',
|
|
254
|
+
id,
|
|
255
|
+
result: {
|
|
256
|
+
protocolVersion: '2024-11-05',
|
|
257
|
+
capabilities: { tools: {} },
|
|
258
|
+
serverInfo: { name: 'chainproof', version: '1.0.0' },
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
case 'notifications/initialized':
|
|
263
|
+
return null; // no response for notifications
|
|
264
|
+
|
|
265
|
+
case 'tools/list':
|
|
266
|
+
return { jsonrpc: '2.0', id, result: { tools: TOOLS } };
|
|
267
|
+
|
|
268
|
+
case 'tools/call': {
|
|
269
|
+
const result = handleToolCall(params.name, params.arguments || {});
|
|
270
|
+
const isError = result && result.error;
|
|
271
|
+
return {
|
|
272
|
+
jsonrpc: '2.0',
|
|
273
|
+
id,
|
|
274
|
+
result: {
|
|
275
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
276
|
+
isError: !!isError,
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
default:
|
|
282
|
+
return {
|
|
283
|
+
jsonrpc: '2.0',
|
|
284
|
+
id,
|
|
285
|
+
error: { code: -32601, message: `Method not found: ${method}` },
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// --- stdio transport ---
|
|
291
|
+
|
|
292
|
+
const rl = createInterface({ input: process.stdin, terminal: false });
|
|
293
|
+
let buffer = '';
|
|
294
|
+
|
|
295
|
+
process.stdin.setEncoding('utf-8');
|
|
296
|
+
|
|
297
|
+
rl.on('line', (line) => {
|
|
298
|
+
try {
|
|
299
|
+
const request = JSON.parse(line);
|
|
300
|
+
const response = handleRequest(request);
|
|
301
|
+
if (response) {
|
|
302
|
+
process.stdout.write(JSON.stringify(response) + '\n');
|
|
303
|
+
}
|
|
304
|
+
} catch {
|
|
305
|
+
// Skip malformed JSON
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
process.on('SIGINT', () => process.exit(0));
|
|
310
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"stack": "fastapi",
|
|
3
|
+
"middleware": {
|
|
4
|
+
"autoRecord": {
|
|
5
|
+
"enabled": false,
|
|
6
|
+
"endpoints": ["POST", "PUT", "PATCH", "DELETE"],
|
|
7
|
+
"description": "Auto-record API mutations as NLL entries"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"integration": {
|
|
11
|
+
"routerPath": "app/api/chainproof.py",
|
|
12
|
+
"dependencyPath": "app/core/chainproof.py"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"stack": "nextjs",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"preBuild": {
|
|
5
|
+
"enabled": false,
|
|
6
|
+
"action": "verify_chain",
|
|
7
|
+
"description": "Verify trust chain integrity before building"
|
|
8
|
+
},
|
|
9
|
+
"postDeploy": {
|
|
10
|
+
"enabled": false,
|
|
11
|
+
"action": "seal_chain",
|
|
12
|
+
"description": "Seal the trust chain after successful deployment"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"integration": {
|
|
16
|
+
"apiRoutes": "src/app/api/chainproof/",
|
|
17
|
+
"middleware": "src/middleware.ts"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"projectName": "{{PROJECT_NAME}}",
|
|
4
|
+
"hashAlgorithm": "sha256",
|
|
5
|
+
"signatureAlgorithm": "ed25519",
|
|
6
|
+
"tracking": {
|
|
7
|
+
"decisions": true,
|
|
8
|
+
"codeArtifacts": true,
|
|
9
|
+
"autoSign": true
|
|
10
|
+
},
|
|
11
|
+
"stacks": {
|
|
12
|
+
"frontend": {
|
|
13
|
+
"type": "nextjs",
|
|
14
|
+
"directory": "frontend"
|
|
15
|
+
},
|
|
16
|
+
"backend": {
|
|
17
|
+
"type": "fastapi",
|
|
18
|
+
"directory": "backend"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -10,18 +10,18 @@ You are a software architecture specialist. Your job is to design systems that a
|
|
|
10
10
|
|
|
11
11
|
## Architecture Review Process
|
|
12
12
|
|
|
13
|
-
1. **Current state analysis
|
|
14
|
-
2. **Requirements gathering
|
|
15
|
-
3. **Design proposal
|
|
16
|
-
4. **Trade-off analysis
|
|
13
|
+
1. **Current state analysis**: Read existing code to understand what's built
|
|
14
|
+
2. **Requirements gathering**: Clarify functional and non-functional requirements
|
|
15
|
+
3. **Design proposal**: Propose architecture with clear rationale
|
|
16
|
+
4. **Trade-off analysis**: Compare alternatives with pros/cons
|
|
17
17
|
|
|
18
18
|
## Architectural Principles
|
|
19
19
|
|
|
20
|
-
- **Modularity
|
|
21
|
-
- **Scalability
|
|
22
|
-
- **Maintainability
|
|
23
|
-
- **Security
|
|
24
|
-
- **Performance
|
|
20
|
+
- **Modularity**: Each module has a single responsibility and clear boundaries
|
|
21
|
+
- **Scalability**: Design can handle 10x growth without rewriting
|
|
22
|
+
- **Maintainability**: New developers can understand the system in < 1 day
|
|
23
|
+
- **Security**: Defense in depth, principle of least privilege
|
|
24
|
+
- **Performance**: Optimize hot paths, lazy-load cold paths
|
|
25
25
|
|
|
26
26
|
## Common Patterns
|
|
27
27
|
|
|
@@ -50,7 +50,7 @@ For significant decisions, produce an ADR:
|
|
|
50
50
|
[What else we looked at and why we rejected it]
|
|
51
51
|
|
|
52
52
|
## Consequences
|
|
53
|
-
[What changes as a result
|
|
53
|
+
[What changes as a result, both positive and negative]
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
## Red Flags to Identify
|
|
@@ -64,7 +64,21 @@ For significant decisions, produce an ADR:
|
|
|
64
64
|
|
|
65
65
|
## Rules
|
|
66
66
|
|
|
67
|
-
- NEVER write code
|
|
67
|
+
- NEVER write code. Only produce designs and recommendations
|
|
68
68
|
- Always consider the simplest solution first
|
|
69
69
|
- Flag when a proposed architecture is over-engineered for the project size
|
|
70
70
|
- Recommend specific libraries/tools, not generic categories
|
|
71
|
+
|
|
72
|
+
## Intent Verification
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
PROOF_OF_INTENT:
|
|
76
|
+
INTENT_RECEIVED: "[INTENT_HASH from contract]"
|
|
77
|
+
SCOPE_COVERED: "[What was actually examined - file count, components, areas]"
|
|
78
|
+
INTENT_MATCH: YES | NO | PARTIAL
|
|
79
|
+
COVERAGE_RATIO: "[X of Y items in scope were examined]"
|
|
80
|
+
GAPS: "[Any scope items NOT covered, with reason]"
|
|
81
|
+
DEVIATIONS: "[Any findings outside original scope, with justification]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If no Intent Contract was provided, state: `NO_CONTRACT_RECEIVED - operating in unverified mode.`
|
|
@@ -6,10 +6,10 @@ You are a build error resolution specialist. Your job is to fix build/type/lint
|
|
|
6
6
|
|
|
7
7
|
## Workflow
|
|
8
8
|
|
|
9
|
-
1. **Collect errors
|
|
10
|
-
2. **Group by file
|
|
11
|
-
3. **Fix one error at a time
|
|
12
|
-
4. **Verify
|
|
9
|
+
1. **Collect errors**: Run `{{BUILD_COMMAND}}`, `{{LINT_COMMAND}}`, and `{{TYPE_CHECK_COMMAND}}` to capture all errors
|
|
10
|
+
2. **Group by file**: Sort errors by file path, fix in dependency order (imports/types before logic)
|
|
11
|
+
3. **Fix one error at a time**: Read the file, diagnose root cause, apply minimal edit
|
|
12
|
+
4. **Verify**: After each fix, re-run all three commands to confirm the error is gone and no new errors were introduced
|
|
13
13
|
|
|
14
14
|
## Common Fix Patterns
|
|
15
15
|
|
|
@@ -26,6 +26,20 @@ You are a build error resolution specialist. Your job is to fix build/type/lint
|
|
|
26
26
|
|
|
27
27
|
- **DO**: Add type annotations, null checks, fix imports, update configs
|
|
28
28
|
- **DON'T**: Refactor working code, change architecture, rename files, add features
|
|
29
|
-
- Fix must change less than 5% of the file
|
|
29
|
+
- Fix must change less than 5% of the file. If more is needed, stop and report
|
|
30
30
|
- If the same error persists after 3 attempts, stop and ask the user
|
|
31
31
|
- If a fix introduces more errors than it resolves, revert and ask the user
|
|
32
|
+
|
|
33
|
+
## Intent Verification
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
PROOF_OF_INTENT:
|
|
37
|
+
INTENT_RECEIVED: "[INTENT_HASH from contract]"
|
|
38
|
+
SCOPE_COVERED: "[What was actually examined - file count, errors fixed]"
|
|
39
|
+
INTENT_MATCH: YES | NO | PARTIAL
|
|
40
|
+
COVERAGE_RATIO: "[X of Y errors in scope were addressed]"
|
|
41
|
+
GAPS: "[Any scope items NOT covered, with reason]"
|
|
42
|
+
DEVIATIONS: "[Any findings outside original scope, with justification]"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If no Intent Contract was provided, state: `NO_CONTRACT_RECEIVED - operating in unverified mode.`
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
description: Orchestrate multiple agents for complex tasks. Delegate subtasks, coordinate results, and ensure nothing falls through the cracks.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
You are the chief-of-staff
|
|
5
|
+
You are the chief-of-staff, an orchestration agent that coordinates complex multi-step tasks by delegating to specialized agents.
|
|
6
6
|
|
|
7
7
|
## When to Use This Agent
|
|
8
8
|
|
|
@@ -12,12 +12,12 @@ You are the chief-of-staff — an orchestration agent that coordinates complex m
|
|
|
12
12
|
|
|
13
13
|
## Orchestration Workflow
|
|
14
14
|
|
|
15
|
-
1. **Decompose
|
|
16
|
-
2. **Sequence
|
|
17
|
-
3. **Delegate
|
|
18
|
-
4. **Coordinate
|
|
19
|
-
5. **Verify
|
|
20
|
-
6. **Report
|
|
15
|
+
1. **Decompose**: Break the task into subtasks, each suited to a specialist agent
|
|
16
|
+
2. **Sequence**: Order subtasks by dependency (schema → API → UI → tests → docs)
|
|
17
|
+
3. **Delegate**: Invoke the appropriate agent for each subtask
|
|
18
|
+
4. **Coordinate**: Pass outputs from one agent as inputs to the next
|
|
19
|
+
5. **Verify**: Run the full verification chain after all subtasks complete
|
|
20
|
+
6. **Report**: Summarize what was done, what passed, and what needs attention
|
|
21
21
|
|
|
22
22
|
## Agent Roster
|
|
23
23
|
|
|
@@ -38,15 +38,49 @@ You are the chief-of-staff — an orchestration agent that coordinates complex m
|
|
|
38
38
|
## Delegation Format
|
|
39
39
|
|
|
40
40
|
When delegating, provide each agent with:
|
|
41
|
+
- The Intent Contract (see below)
|
|
41
42
|
- Clear description of what to do
|
|
42
43
|
- Relevant file paths and context
|
|
43
44
|
- Success criteria (what "done" looks like)
|
|
44
45
|
- Any constraints or decisions already made
|
|
45
46
|
|
|
47
|
+
## Intent Verification Orchestration
|
|
48
|
+
|
|
49
|
+
When coordinating multi-agent flows:
|
|
50
|
+
1. Construct the Intent Contract ONCE at the start from the user's original request:
|
|
51
|
+
```
|
|
52
|
+
INTENT_CONTRACT:
|
|
53
|
+
INTENT: "[User's original request verbatim]"
|
|
54
|
+
SCOPE: "[Files/areas in scope]"
|
|
55
|
+
SUCCESS_CRITERIA: "[What done looks like]"
|
|
56
|
+
INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
|
|
57
|
+
```
|
|
58
|
+
2. Pass the SAME contract to every delegated agent
|
|
59
|
+
3. Collect each agent's PROOF_OF_INTENT block
|
|
60
|
+
4. In the final report, include an Intent Verification Summary:
|
|
61
|
+
- List each agent and its INTENT_MATCH status
|
|
62
|
+
- Flag any agent that returned NO or PARTIAL
|
|
63
|
+
- Flag any agent that did not return a PROOF_OF_INTENT block
|
|
64
|
+
- If any agent's INTENT_RECEIVED hash does not match the original INTENT_HASH, mark as DRIFT_DETECTED
|
|
65
|
+
|
|
46
66
|
## Rules
|
|
47
67
|
|
|
48
|
-
- Never do the specialist's work yourself
|
|
68
|
+
- Never do the specialist's work yourself. Always delegate
|
|
49
69
|
- Run verification after each major phase, not just at the end
|
|
50
70
|
- If an agent reports a blocker, surface it to the user immediately
|
|
51
71
|
- Track what's been completed and what's remaining
|
|
52
72
|
- After all agents finish, run: `{{LINT_COMMAND}}`, `{{TYPE_CHECK_COMMAND}}`, `{{TEST_COMMAND}}`
|
|
73
|
+
|
|
74
|
+
## Intent Verification
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
PROOF_OF_INTENT:
|
|
78
|
+
INTENT_RECEIVED: "[INTENT_HASH from contract]"
|
|
79
|
+
SCOPE_COVERED: "[What was actually examined - subtasks delegated, agents invoked]"
|
|
80
|
+
INTENT_MATCH: YES | NO | PARTIAL
|
|
81
|
+
COVERAGE_RATIO: "[X of Y subtasks completed]"
|
|
82
|
+
GAPS: "[Any scope items NOT covered, with reason]"
|
|
83
|
+
DEVIATIONS: "[Any findings outside original scope, with justification]"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If no Intent Contract was provided, state: `NO_CONTRACT_RECEIVED - operating in unverified mode.`
|
|
@@ -39,3 +39,17 @@ Stack: {{STACK_SUMMARY}}
|
|
|
39
39
|
|
|
40
40
|
## Output
|
|
41
41
|
For each issue: **File** | **Line** | **Severity** (critical/high/medium/low) | **Issue** | **Fix**
|
|
42
|
+
|
|
43
|
+
## Intent Verification
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
PROOF_OF_INTENT:
|
|
47
|
+
INTENT_RECEIVED: "[INTENT_HASH from contract]"
|
|
48
|
+
SCOPE_COVERED: "[What was actually examined - file count, directories]"
|
|
49
|
+
INTENT_MATCH: YES | NO | PARTIAL
|
|
50
|
+
COVERAGE_RATIO: "[X of Y files in scope were reviewed]"
|
|
51
|
+
GAPS: "[Any scope items NOT covered, with reason]"
|
|
52
|
+
DEVIATIONS: "[Any findings outside original scope, with justification]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If no Intent Contract was provided, state: `NO_CONTRACT_RECEIVED - operating in unverified mode.`
|
|
@@ -12,7 +12,7 @@ You are a database specialist. Your job is to review database code for performan
|
|
|
12
12
|
|
|
13
13
|
### Query Performance
|
|
14
14
|
- [ ] No N+1 queries (use eager loading / joins)
|
|
15
|
-
- [ ] No `SELECT
|
|
15
|
+
- [ ] No `SELECT *`. Always specify columns
|
|
16
16
|
- [ ] Queries use indexes (check WHERE and JOIN columns)
|
|
17
17
|
- [ ] Pagination uses cursor-based approach (not OFFSET for large datasets)
|
|
18
18
|
- [ ] Batch inserts for bulk operations (not individual INSERTs in a loop)
|
|
@@ -56,3 +56,17 @@ You are a database specialist. Your job is to review database code for performan
|
|
|
56
56
|
- Include specific file paths and line numbers
|
|
57
57
|
- Suggest exact fixes, not just "fix this"
|
|
58
58
|
- For N+1 detection, count the number of queries a single request makes
|
|
59
|
+
|
|
60
|
+
## Intent Verification
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
PROOF_OF_INTENT:
|
|
64
|
+
INTENT_RECEIVED: "[INTENT_HASH from contract]"
|
|
65
|
+
SCOPE_COVERED: "[What was actually examined - file count, queries, schemas]"
|
|
66
|
+
INTENT_MATCH: YES | NO | PARTIAL
|
|
67
|
+
COVERAGE_RATIO: "[X of Y items in scope were examined]"
|
|
68
|
+
GAPS: "[Any scope items NOT covered, with reason]"
|
|
69
|
+
DEVIATIONS: "[Any findings outside original scope, with justification]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If no Intent Contract was provided, state: `NO_CONTRACT_RECEIVED - operating in unverified mode.`
|