@v11g/agents-rock 1.0.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 +65 -0
- package/bin/agents-rock.mjs +4 -0
- package/package.json +13 -0
- package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
- package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
- package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
- package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
- package/plugins/solution-architect/skills/estimate/README.md +67 -0
- package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
- package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
- package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
- package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
- package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
- package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
- package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
- package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
- package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
- package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
- package/plugins/solution-architect/skills/new-lead/README.md +48 -0
- package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
- package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
- package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
- package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
- package/plugins/solution-architect/skills/proposal/README.md +36 -0
- package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
- package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
- package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
- package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
- package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
- package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
- package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
- package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
- package/src/cli/agents.mjs +12 -0
- package/src/cli/args.mjs +46 -0
- package/src/cli/install.mjs +68 -0
- package/src/cli/main.mjs +124 -0
- package/src/cli/picker.mjs +78 -0
- package/src/cli/registry.mjs +26 -0
- package/src/cli/uninstall.mjs +38 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { test, before, after } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { cp, mkdtemp, readFile, writeFile, mkdir, symlink, rm } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { relative } from 'node:path';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { startServer } from '../serve.mjs';
|
|
8
|
+
|
|
9
|
+
let server, base, root;
|
|
10
|
+
before(async () => {
|
|
11
|
+
root = await mkdtemp(join(tmpdir(), 'srv-')); // copy fixture so POSTs don't dirty it
|
|
12
|
+
await cp(new URL('./fixtures/root', import.meta.url).pathname, root, { recursive: true });
|
|
13
|
+
// stats.mjs and vendor/* aren't part of the shared fixture — write minimal stand-ins
|
|
14
|
+
// under scripts/ so the allowlist has something to serve.
|
|
15
|
+
await mkdir(join(root, 'scripts', 'vendor'), { recursive: true });
|
|
16
|
+
await writeFile(join(root, 'scripts', 'stats.mjs'), 'export const x = 1;\n');
|
|
17
|
+
await writeFile(join(root, 'scripts', 'vendor', 'reactflow-bundle.js'), '// stub\n');
|
|
18
|
+
server = await startServer(root, 0);
|
|
19
|
+
base = `http://127.0.0.1:${server.address().port}`;
|
|
20
|
+
});
|
|
21
|
+
after(async () => {
|
|
22
|
+
await new Promise((resolve) => server.close(resolve));
|
|
23
|
+
await rm(root, { recursive: true, force: true });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('GET /api/leads returns enriched registry', async () => {
|
|
27
|
+
const body = await (await fetch(`${base}/api/leads`)).json();
|
|
28
|
+
const acme = body.leads.find(l => l.id === 'acme-crm');
|
|
29
|
+
assert.equal(acme.artifacts.docs, true);
|
|
30
|
+
assert.equal(acme.artifacts.proposal, false);
|
|
31
|
+
});
|
|
32
|
+
test('GET /api/leads/:id/map returns nodes', async () => {
|
|
33
|
+
const map = await (await fetch(`${base}/api/leads/acme-crm/map`)).json();
|
|
34
|
+
assert.ok(map.nodes.some(n => n.id === 'arch'));
|
|
35
|
+
});
|
|
36
|
+
test('POST /api/leads/:id marks won and stamps closed', async () => {
|
|
37
|
+
const res = await fetch(`${base}/api/leads/acme-crm`, {
|
|
38
|
+
method: 'POST', body: JSON.stringify({ status: 'won' }),
|
|
39
|
+
headers: { 'content-type': 'application/json' },
|
|
40
|
+
});
|
|
41
|
+
const lead = await res.json();
|
|
42
|
+
assert.equal(lead.status, 'won');
|
|
43
|
+
assert.match(lead.closed, /^\d{4}-\d{2}-\d{2}$/);
|
|
44
|
+
});
|
|
45
|
+
test('POST bad status -> 400; unknown id -> 404', async () => {
|
|
46
|
+
const bad = await fetch(`${base}/api/leads/acme-crm`, { method: 'POST', body: '{"status":"maybe"}' });
|
|
47
|
+
assert.equal(bad.status, 400);
|
|
48
|
+
const missing = await fetch(`${base}/api/leads/nope`, { method: 'POST', body: '{"status":"won"}' });
|
|
49
|
+
assert.equal(missing.status, 404);
|
|
50
|
+
});
|
|
51
|
+
test('POST notes writes notes.md and responds {ok: true}', async () => {
|
|
52
|
+
const res = await fetch(`${base}/api/leads/acme-crm/notes`, { method: 'POST', body: '{"content":"call went well"}' });
|
|
53
|
+
assert.deepEqual(await res.json(), { ok: true });
|
|
54
|
+
assert.match(await readFile(join(root, 'leads', 'acme-crm', 'notes.md'), 'utf8'), /call went well/);
|
|
55
|
+
});
|
|
56
|
+
test('static serving with traversal guard', async () => {
|
|
57
|
+
assert.equal((await fetch(`${base}/leads/acme-crm/dist/index.html`)).status, 200);
|
|
58
|
+
// Plain "../../etc/passwd" and "%2e%2e" between literal slashes get collapsed by the
|
|
59
|
+
// WHATWG URL parser *before* the request ever leaves fetch() -- the server never sees a
|
|
60
|
+
// ".." segment for those, so they can't exercise the guard (verified empirically: req.url
|
|
61
|
+
// arrives as "/etc/passwd" / "/leads.json.lock", both harmless in-bounds, non-allowlisted
|
|
62
|
+
// paths that the allowlist rule alone already 404s). An encoded *slash* (%2F) is not
|
|
63
|
+
// collapsed by the URL parser -- it survives to the server, where decodeURIComponent turns
|
|
64
|
+
// it into a real ".." segment, which is the guard this test needs to exercise.
|
|
65
|
+
assert.equal((await fetch(`${base}/leads/acme-crm/..%2F..%2Fetc%2Fpasswd`)).status, 403);
|
|
66
|
+
assert.equal((await fetch(`${base}/leads/acme-crm/..%2Fleads.json.lock`)).status, 403);
|
|
67
|
+
});
|
|
68
|
+
test('static allowlist: leads.json, notes.md, rfp.md, brief.md -> 404; stats.mjs, vendor -> 200', async () => {
|
|
69
|
+
assert.equal((await fetch(`${base}/leads.json`)).status, 404);
|
|
70
|
+
assert.equal((await fetch(`${base}/leads/acme-crm/notes.md`)).status, 404);
|
|
71
|
+
assert.equal((await fetch(`${base}/leads/acme-crm/rfp.md`)).status, 404);
|
|
72
|
+
assert.equal((await fetch(`${base}/leads/acme-crm/brief.md`)).status, 404);
|
|
73
|
+
assert.equal((await fetch(`${base}/scripts/stats.mjs`)).status, 200);
|
|
74
|
+
assert.equal((await fetch(`${base}/scripts/vendor/reactflow-bundle.js`)).status, 200);
|
|
75
|
+
});
|
|
76
|
+
test('static content-type and body are correct for allowlisted files', async () => {
|
|
77
|
+
const stats = await fetch(`${base}/scripts/stats.mjs`);
|
|
78
|
+
assert.equal(stats.headers.get('content-type'), 'text/javascript');
|
|
79
|
+
assert.equal(await stats.text(), 'export const x = 1;\n');
|
|
80
|
+
const doc = await fetch(`${base}/leads/acme-crm/dist/index.html`);
|
|
81
|
+
assert.equal(doc.headers.get('content-type'), 'text/html');
|
|
82
|
+
});
|
|
83
|
+
test('the scripts tree is not browsable beyond the two allowlisted entries', async () => {
|
|
84
|
+
assert.equal((await fetch(`${base}/scripts/serve.mjs`)).status, 404);
|
|
85
|
+
assert.equal((await fetch(`${base}/scripts/lib/registry.mjs`)).status, 404);
|
|
86
|
+
assert.equal((await fetch(`${base}/scripts/index.html`)).status, 404);
|
|
87
|
+
assert.equal((await fetch(`${base}/leads.json`)).status, 404);
|
|
88
|
+
});
|
|
89
|
+
test('id validation guards every :id route before touching the lead dir or map builder', async () => {
|
|
90
|
+
assert.equal((await fetch(`${base}/api/leads/-bad/map`)).status, 404);
|
|
91
|
+
assert.equal((await fetch(`${base}/api/leads/-bad`, { method: 'POST', body: '{"status":"won"}' })).status, 404);
|
|
92
|
+
assert.equal((await fetch(`${base}/api/leads/-bad/notes`, { method: 'POST', body: '{"content":"x"}' })).status, 404);
|
|
93
|
+
});
|
|
94
|
+
test('directory GET on an allowlisted prefix 4xxs cleanly and the server stays up', async () => {
|
|
95
|
+
const distDir = await fetch(`${base}/leads/acme-crm/dist/`);
|
|
96
|
+
assert.ok(distDir.status >= 400 && distDir.status < 500);
|
|
97
|
+
const vendorDir = await fetch(`${base}/scripts/vendor/`);
|
|
98
|
+
assert.ok(vendorDir.status >= 400 && vendorDir.status < 500);
|
|
99
|
+
// server must still be listening -- this is the crash the reviewer reproduced
|
|
100
|
+
const stillUp = await fetch(`${base}/api/leads`);
|
|
101
|
+
assert.equal(stillUp.status, 200);
|
|
102
|
+
});
|
|
103
|
+
test('symlink inside dist/ pointing outside root is rejected, not followed', async () => {
|
|
104
|
+
const outside = join(root, '..', 'outside-secret.txt');
|
|
105
|
+
await writeFile(outside, 'top secret');
|
|
106
|
+
await symlink(outside, join(root, 'leads', 'acme-crm', 'dist', 'link.html'));
|
|
107
|
+
const res = await fetch(`${base}/leads/acme-crm/dist/link.html`);
|
|
108
|
+
assert.equal(res.status, 403);
|
|
109
|
+
await rm(outside, { force: true });
|
|
110
|
+
});
|
|
111
|
+
test('symlink inside dist/ escaping to leads.json is rejected, not the registry', async () => {
|
|
112
|
+
await symlink(join(root, 'leads.json'), join(root, 'leads', 'acme-crm', 'dist', 'rel-escape.json'));
|
|
113
|
+
const res = await fetch(`${base}/leads/acme-crm/dist/rel-escape.json`);
|
|
114
|
+
assert.ok(res.status >= 400 && res.status < 500, `expected 4xx, got ${res.status}`);
|
|
115
|
+
assert.doesNotMatch(await res.text(), /Beta Shop/);
|
|
116
|
+
});
|
|
117
|
+
test('symlink inside dist/ escaping to notes.md is rejected, not the notes', async () => {
|
|
118
|
+
await symlink(join(root, 'leads', 'acme-crm', 'notes.md'), join(root, 'leads', 'acme-crm', 'dist', 'notes-leak.md'));
|
|
119
|
+
const res = await fetch(`${base}/leads/acme-crm/dist/notes-leak.md`);
|
|
120
|
+
assert.ok(res.status >= 400 && res.status < 500, `expected 4xx, got ${res.status}`);
|
|
121
|
+
assert.doesNotMatch(await res.text(), /omnichannel/);
|
|
122
|
+
});
|
|
123
|
+
test('symlinks inside dist/ escaping to brief.md and rfp.md are also rejected', async () => {
|
|
124
|
+
const targets = [
|
|
125
|
+
['brief.md', /aging spreadsheet-based/],
|
|
126
|
+
['rfp.md', /Request for Proposal/],
|
|
127
|
+
];
|
|
128
|
+
for (const [name, marker] of targets) {
|
|
129
|
+
await symlink(join(root, 'leads', 'acme-crm', name), join(root, 'leads', 'acme-crm', 'dist', `escape-${name}`));
|
|
130
|
+
const res = await fetch(`${base}/leads/acme-crm/dist/escape-${name}`);
|
|
131
|
+
assert.ok(res.status >= 400 && res.status < 500, `${name}: expected 4xx, got ${res.status}`);
|
|
132
|
+
assert.doesNotMatch(await res.text(), marker);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
test('symlinked directory inside dist/ cannot reach leads.json through it', async () => {
|
|
136
|
+
await symlink(root, join(root, 'leads', 'acme-crm', 'dist', 'sub'));
|
|
137
|
+
const res = await fetch(`${base}/leads/acme-crm/dist/sub/leads.json`);
|
|
138
|
+
assert.ok(res.status >= 400 && res.status < 500, `expected 4xx, got ${res.status}`);
|
|
139
|
+
assert.doesNotMatch(await res.text(), /Beta Shop/);
|
|
140
|
+
});
|
|
141
|
+
test('a two-hop symlink chain inside dist/ cannot reach leads.json either', async () => {
|
|
142
|
+
await symlink(join(root, 'leads.json'), join(root, 'hop.json'));
|
|
143
|
+
await symlink(join(root, 'hop.json'), join(root, 'leads', 'acme-crm', 'dist', 'chain.json'));
|
|
144
|
+
const res = await fetch(`${base}/leads/acme-crm/dist/chain.json`);
|
|
145
|
+
assert.ok(res.status >= 400 && res.status < 500, `expected 4xx, got ${res.status}`);
|
|
146
|
+
assert.doesNotMatch(await res.text(), /Beta Shop/);
|
|
147
|
+
});
|
|
148
|
+
test('symlink inside dist/ pointing at another allowlisted dist file still serves 200', async () => {
|
|
149
|
+
await symlink(join(root, 'leads', 'acme-crm', 'dist', 'index.html'), join(root, 'leads', 'acme-crm', 'dist', 'alias.html'));
|
|
150
|
+
const res = await fetch(`${base}/leads/acme-crm/dist/alias.html`);
|
|
151
|
+
assert.equal(res.status, 200);
|
|
152
|
+
});
|
|
153
|
+
test('GET / 404s cleanly when index.html has not been built yet', async () => {
|
|
154
|
+
assert.equal((await fetch(`${base}/`)).status, 404);
|
|
155
|
+
});
|
|
156
|
+
test('serveFile does not leak the registry when index.html or detail.html is symlinked to it', async () => {
|
|
157
|
+
const cases = [['index.html', `${base}/`], ['detail.html', `${base}/detail/acme-crm`]];
|
|
158
|
+
for (const [name, url] of cases) {
|
|
159
|
+
const target = join(root, 'scripts', name);
|
|
160
|
+
await symlink(join(root, 'leads.json'), target);
|
|
161
|
+
const res = await fetch(url);
|
|
162
|
+
assert.notEqual(res.status, 200, `${name}: unexpectedly served`);
|
|
163
|
+
assert.doesNotMatch(await res.text(), /Beta Shop/);
|
|
164
|
+
await rm(target, { force: true });
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
test('POST to a static-only path is rejected, not served', async () => {
|
|
168
|
+
const res = await fetch(`${base}/scripts/stats.mjs`, { method: 'POST', body: '' });
|
|
169
|
+
assert.notEqual(res.status, 200);
|
|
170
|
+
});
|
|
171
|
+
test('POST notes does not follow a symlinked notes.md out of the root', async () => {
|
|
172
|
+
const outside = join(root, '..', 'notes-write-target.txt');
|
|
173
|
+
await writeFile(outside, 'ORIGINAL SECRET');
|
|
174
|
+
const link = join(root, 'leads', 'acme-crm', 'notes.md');
|
|
175
|
+
await rm(link, { force: true });
|
|
176
|
+
await symlink(outside, link);
|
|
177
|
+
const res = await fetch(`${base}/api/leads/acme-crm/notes`, {
|
|
178
|
+
method: 'POST', body: '{"content":"OVERWRITTEN VIA DASHBOARD"}',
|
|
179
|
+
});
|
|
180
|
+
assert.notEqual(res.status, 200, 'symlinked notes.md was accepted for writing');
|
|
181
|
+
assert.equal(await readFile(outside, 'utf8'), 'ORIGINAL SECRET', 'file outside the root was modified');
|
|
182
|
+
await rm(link, { force: true });
|
|
183
|
+
await rm(outside, { force: true });
|
|
184
|
+
});
|
|
185
|
+
test('POST notes does not follow a lead directory symlinked out of the root', async () => {
|
|
186
|
+
const outsideDir = join(root, '..', 'outside-lead-dir');
|
|
187
|
+
await mkdir(outsideDir, { recursive: true });
|
|
188
|
+
await writeFile(join(outsideDir, 'notes.md'), 'ORIGINAL SECRET');
|
|
189
|
+
await symlink(outsideDir, join(root, 'leads', 'ghost-lead'));
|
|
190
|
+
const res = await fetch(`${base}/api/leads/ghost-lead/notes`, {
|
|
191
|
+
method: 'POST', body: '{"content":"OVERWRITTEN VIA DASHBOARD"}',
|
|
192
|
+
});
|
|
193
|
+
assert.notEqual(res.status, 200, 'symlinked lead dir was accepted for writing');
|
|
194
|
+
assert.equal(await readFile(join(outsideDir, 'notes.md'), 'utf8'), 'ORIGINAL SECRET',
|
|
195
|
+
'file outside the root was modified');
|
|
196
|
+
await rm(join(root, 'leads', 'ghost-lead'), { force: true });
|
|
197
|
+
await rm(outsideDir, { recursive: true, force: true });
|
|
198
|
+
});
|
|
199
|
+
test('relative --root still resolves to real, absolute paths for static serving', async () => {
|
|
200
|
+
const rel = relative(process.cwd(), root);
|
|
201
|
+
const s2 = await startServer(rel, 0);
|
|
202
|
+
const b2 = `http://127.0.0.1:${s2.address().port}`;
|
|
203
|
+
assert.equal((await fetch(`${b2}/leads/acme-crm/dist/index.html`)).status, 200);
|
|
204
|
+
await new Promise((resolve) => s2.close(resolve));
|
|
205
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { computeStats, filterLeads, sortLeads } from '../../assets/dashboard/stats.mjs';
|
|
4
|
+
|
|
5
|
+
const L = (o) => ({ id: 'x', client: 'C', title: 'T', status: 'active',
|
|
6
|
+
created: '2026-08-01', closed: null, value: null, scenario: null, ...o });
|
|
7
|
+
const leads = [
|
|
8
|
+
L({ id: 'a', status: 'won', closed: '2026-08-05', value: { low: 10, high: 20, currency: 'USD' } }),
|
|
9
|
+
L({ id: 'b', status: 'won', closed: '2026-07-30' }),
|
|
10
|
+
L({ id: 'c', status: 'lost', closed: '2026-08-02', created: '2026-07-29' }),
|
|
11
|
+
L({ id: 'd', client: 'Acme', value: { low: 5, high: 9, currency: 'USD' } }),
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
test('computeStats', () => {
|
|
15
|
+
const s = computeStats(leads, '2026-08-10');
|
|
16
|
+
assert.equal(s.wonThisMonth, 1);
|
|
17
|
+
assert.equal(s.winRate, 0.67);
|
|
18
|
+
assert.deepEqual(s.pipelineValue, [{ currency: 'USD', low: 5, high: 9, count: 1 }]);
|
|
19
|
+
assert.equal(s.avgCycleDays, 4); // a: 08-01→08-05 = 4d; b: closed < created, skipped; c: 07-29→08-02 = 4d; mean = 4
|
|
20
|
+
});
|
|
21
|
+
test('computeStats empty', () => {
|
|
22
|
+
const s = computeStats([], '2026-08-10');
|
|
23
|
+
assert.deepEqual(s, { wonThisMonth: 0, winRate: null, pipelineValue: null, avgCycleDays: null });
|
|
24
|
+
});
|
|
25
|
+
test('filterLeads by status and text', () => {
|
|
26
|
+
assert.deepEqual(filterLeads(leads, { status: 'won', text: '' }).map(l => l.id), ['a', 'b']);
|
|
27
|
+
assert.deepEqual(filterLeads(leads, { status: 'all', text: 'acme' }).map(l => l.id), ['d']);
|
|
28
|
+
});
|
|
29
|
+
test('sortLeads by value desc, non-mutating', () => {
|
|
30
|
+
const input = [...leads];
|
|
31
|
+
assert.deepEqual(sortLeads(leads, 'value', 'desc').map(l => l.id), ['a', 'd', 'b', 'c']);
|
|
32
|
+
assert.deepEqual(leads, input);
|
|
33
|
+
});
|
|
34
|
+
// Pins the current rule (owner decision, 2026-08-11, supersedes the old
|
|
35
|
+
// "currency from the first counted lead" behavior): active leads are grouped by
|
|
36
|
+
// currency, each group summed separately, and groups are ordered by descending
|
|
37
|
+
// `high` total (biggest pipeline number first, matching the owner's approved
|
|
38
|
+
// mock) with an ascending-currency-code tie-break so the order never reshuffles
|
|
39
|
+
// between renders when two currencies total the same.
|
|
40
|
+
test('computeStats pipelineValue: grouped subtotals, biggest total first', () => {
|
|
41
|
+
const mixed = [
|
|
42
|
+
L({ id: 'e', value: { low: 100, high: 200, currency: 'USD' } }),
|
|
43
|
+
L({ id: 'f', value: { low: 10, high: 20, currency: 'EUR' } }),
|
|
44
|
+
L({ id: 'g', value: { low: 50, high: 60, currency: 'USD' } }),
|
|
45
|
+
];
|
|
46
|
+
const s = computeStats(mixed, '2026-08-10');
|
|
47
|
+
assert.deepEqual(s.pipelineValue, [
|
|
48
|
+
{ currency: 'USD', low: 150, high: 260, count: 2 },
|
|
49
|
+
{ currency: 'EUR', low: 10, high: 20, count: 1 },
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
test('computeStats pipelineValue: three currencies ordered by total, null-value lead excluded', () => {
|
|
53
|
+
const mixed = [
|
|
54
|
+
L({ id: 'h', value: { low: 1, high: 2, currency: 'GBP' } }),
|
|
55
|
+
L({ id: 'i', value: null }),
|
|
56
|
+
L({ id: 'j', value: { low: 3, high: 4, currency: 'AUD' } }),
|
|
57
|
+
L({ id: 'k', value: { low: 5, high: 6, currency: 'JPY' } }),
|
|
58
|
+
];
|
|
59
|
+
const s = computeStats(mixed, '2026-08-10');
|
|
60
|
+
assert.deepEqual(s.pipelineValue, [
|
|
61
|
+
{ currency: 'JPY', low: 5, high: 6, count: 1 },
|
|
62
|
+
{ currency: 'AUD', low: 3, high: 4, count: 1 },
|
|
63
|
+
{ currency: 'GBP', low: 1, high: 2, count: 1 },
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
test('computeStats pipelineValue: equal totals tie-break ascending by currency code', () => {
|
|
67
|
+
const tied = [
|
|
68
|
+
L({ id: 'm', value: { low: 40, high: 100, currency: 'USD' } }),
|
|
69
|
+
L({ id: 'n', value: { low: 40, high: 100, currency: 'EUR' } }),
|
|
70
|
+
];
|
|
71
|
+
const s = computeStats(tied, '2026-08-10');
|
|
72
|
+
assert.deepEqual(s.pipelineValue, [
|
|
73
|
+
{ currency: 'EUR', low: 40, high: 100, count: 1 },
|
|
74
|
+
{ currency: 'USD', low: 40, high: 100, count: 1 },
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
test('search does not throw on a null client, and still matches id and title', () => {
|
|
78
|
+
const leads = [
|
|
79
|
+
{ id: 'acme-crm', client: null, title: 'CRM rebuild', status: 'active' },
|
|
80
|
+
{ id: 'beta-shop', client: 'Beta', title: 'Shop', status: 'active' },
|
|
81
|
+
];
|
|
82
|
+
assert.deepEqual(filterLeads(leads, { status: 'all', text: 'crm' }).map(l => l.id), ['acme-crm']);
|
|
83
|
+
assert.deepEqual(filterLeads(leads, { status: 'all', text: 'beta' }).map(l => l.id), ['beta-shop']);
|
|
84
|
+
assert.equal(filterLeads(leads, { status: 'all', text: 'zzz' }).length, 0);
|
|
85
|
+
});
|
|
86
|
+
test('sorting by client puts nulls last when ascending', () => {
|
|
87
|
+
const leads = [
|
|
88
|
+
{ id: 'a', client: null, title: 'T', status: 'active' },
|
|
89
|
+
{ id: 'b', client: 'Acme', title: 'T', status: 'active' },
|
|
90
|
+
];
|
|
91
|
+
assert.deepEqual(sortLeads(leads, 'client', 'asc').map(l => l.id), ['b', 'a']);
|
|
92
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFile } from 'node:child_process';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { mkdtemp, writeFile } from 'node:fs/promises';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
const run = promisify(execFile);
|
|
9
|
+
const CLI = new URL('../validate.mjs', import.meta.url).pathname;
|
|
10
|
+
|
|
11
|
+
test('exit 0 on valid file', async () => {
|
|
12
|
+
const dir = await mkdtemp(join(tmpdir(), 'v-'));
|
|
13
|
+
const file = join(dir, 'leads.json');
|
|
14
|
+
await writeFile(file, JSON.stringify({ version: 1, leads: [] }));
|
|
15
|
+
const { stdout } = await run('node', [CLI, '--file', file]);
|
|
16
|
+
assert.equal(stdout, '');
|
|
17
|
+
});
|
|
18
|
+
test('exit 1 with findings on invalid file', async () => {
|
|
19
|
+
const dir = await mkdtemp(join(tmpdir(), 'v-'));
|
|
20
|
+
const file = join(dir, 'leads.json');
|
|
21
|
+
await writeFile(file, JSON.stringify({ version: 3, leads: [] }));
|
|
22
|
+
await assert.rejects(() => run('node', [CLI, '--file', file]),
|
|
23
|
+
(err) => err.code === 1 && /version/.test(err.stdout));
|
|
24
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
|
|
5
|
+
test('bundle exists, stamped, exposes LeadFlow', async () => {
|
|
6
|
+
const src = await readFile(new URL('../../assets/dashboard/vendor/reactflow-bundle.js', import.meta.url), 'utf8');
|
|
7
|
+
assert.match(src.slice(0, 200), /new-lead-dashboard v\d+/);
|
|
8
|
+
assert.match(src, /LeadFlow/);
|
|
9
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// new-lead-dashboard v1
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { validateRegistry } from './lib/registry.mjs';
|
|
5
|
+
|
|
6
|
+
const { values } = parseArgs({ options: { file: { type: 'string' } } });
|
|
7
|
+
if (!values.file) { console.error('usage: validate.mjs --file <leads.json>'); process.exit(2); }
|
|
8
|
+
const findings = validateRegistry(JSON.parse(await readFile(values.file, 'utf8')));
|
|
9
|
+
if (findings.length) { findings.forEach(f => console.log(f)); process.exit(1); }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# proposal
|
|
2
|
+
|
|
3
|
+
Pre-sales client proposal assembled from the analyze-requirements and estimate skills'
|
|
4
|
+
outputs: `proposal.md` as the editable source of truth and `proposal.html`
|
|
5
|
+
as a self-contained, print-ready page you can send to a client or print to
|
|
6
|
+
PDF.
|
|
7
|
+
|
|
8
|
+
## What it needs
|
|
9
|
+
|
|
10
|
+
Both are hard prerequisites — the skill stops without them:
|
|
11
|
+
|
|
12
|
+
- `ARCHITECTURE.md` (analyze-requirements skill)
|
|
13
|
+
- `estimation.json` (estimate skill)
|
|
14
|
+
|
|
15
|
+
## What it asks
|
|
16
|
+
|
|
17
|
+
A short interview: who the client is, how technical they are (a non-tech
|
|
18
|
+
client gets a jargon-free document, enforced by the validator), which
|
|
19
|
+
staffing scenario to offer, and how long the proposal stays valid. Your
|
|
20
|
+
firm profile is asked once and cached (`.claude/proposal-profile.json`,
|
|
21
|
+
project or global scope — your choice).
|
|
22
|
+
|
|
23
|
+
## What it guarantees
|
|
24
|
+
|
|
25
|
+
- Every number traces to `estimation.json` — the validator recomputes the
|
|
26
|
+
client-facing ranges and refuses anything hand-invented.
|
|
27
|
+
- Exactly one scenario reaches the client, as a range.
|
|
28
|
+
- No internal leakage: other scenarios, rates, provenance tags, and the
|
|
29
|
+
internal risk register never appear.
|
|
30
|
+
- Validation gates rendering; a fresh-eyes subagent review and your own
|
|
31
|
+
sign-off gate delivery.
|
|
32
|
+
|
|
33
|
+
## Pipeline
|
|
34
|
+
|
|
35
|
+
interview → derive.mjs → proposal.md → validate.mjs → fresh-eyes review →
|
|
36
|
+
human review → render.mjs → serve.mjs
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: proposal
|
|
3
|
+
description: Assemble a pre-sales client proposal from analyze-requirements and estimate outputs — interviewed client context, one offered scenario as a price range, and a print-ready client page. Use when the user asks for a proposal, a client pitch document, a quote document, or "something I can send the client".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# proposal
|
|
7
|
+
|
|
8
|
+
Assemble a pre-sales client proposal: proposal.md as the source of truth and
|
|
9
|
+
a self-contained, print-ready proposal.html the user can send or print to
|
|
10
|
+
PDF.
|
|
11
|
+
|
|
12
|
+
## Hard rules
|
|
13
|
+
|
|
14
|
+
1. Assembly only — never re-analyze. Architecture facts come from
|
|
15
|
+
ARCHITECTURE.md; every number comes from estimation.json via
|
|
16
|
+
`scripts/derive.mjs`. A number the derivation didn't produce does not
|
|
17
|
+
go in the document.
|
|
18
|
+
2. Both prerequisites are hard: no ARCHITECTURE.md or no estimation.json →
|
|
19
|
+
stop and name the skill to run (`analyze-requirements` / `estimate`).
|
|
20
|
+
3. One scenario reaches the client — the one picked in the interview,
|
|
21
|
+
presented as a range. The others never leak.
|
|
22
|
+
4. `node scripts/validate.mjs` must exit 0 before the page renders;
|
|
23
|
+
`render.mjs` re-runs the same checks and refuses on findings.
|
|
24
|
+
5. Human review of proposal.md before anything is rendered for or sent to
|
|
25
|
+
a client.
|
|
26
|
+
|
|
27
|
+
## Flow
|
|
28
|
+
|
|
29
|
+
1. **Prereq gate**: ARCHITECTURE.md and estimation.json both exist, or stop.
|
|
30
|
+
2. **Interview**: follow `references/interview.md` — client context, tech
|
|
31
|
+
level, scenario pick, validity, firm profile (with storage-scope choice).
|
|
32
|
+
3. **Figures**: `node scripts/derive.mjs --estimation <dir>/estimation.json
|
|
33
|
+
--scenario <id> --out <dir>/proposal-figures.json` — the only numbers
|
|
34
|
+
allowed in the document.
|
|
35
|
+
4. **Write**: proposal.md per `references/writing.md` (ten sections,
|
|
36
|
+
frontmatter contract, tech-level language).
|
|
37
|
+
5. **Validate**: `node scripts/validate.mjs --md <dir>/proposal.md
|
|
38
|
+
--estimation <dir>/estimation.json` — fix findings, re-run until clean.
|
|
39
|
+
6. **Fresh-eyes review**: dispatch a subagent per `references/review.md`;
|
|
40
|
+
fix findings, re-run validate; one re-review cycle max.
|
|
41
|
+
7. **Human review**: show the user proposal.md and wait for approval.
|
|
42
|
+
8. **Render**: `node scripts/render.mjs --md <dir>/proposal.md
|
|
43
|
+
--estimation <dir>/estimation.json --mermaid-bundle <path> --out <dir>/dist`
|
|
44
|
+
— reuse the mermaid bundle built for the analyze-requirements viewer
|
|
45
|
+
(analyze-requirements `references/viewer.md` §1). `<dir>/dist/` is the one
|
|
46
|
+
rendered-pages folder: proposal.html ships beside index.html and
|
|
47
|
+
estimate.html; proposal.html itself carries no link back.
|
|
48
|
+
9. **Serve**: `node ../analyze-requirements/scripts/serve.mjs <dir>`; report the URL.
|
|
49
|
+
|
|
50
|
+
## Placement
|
|
51
|
+
|
|
52
|
+
proposal.md lives beside ARCHITECTURE.md and estimation.md. proposal.html
|
|
53
|
+
follows the estimate.html rule: into the rendered viewer's directory when
|
|
54
|
+
one exists, else beside proposal.md.
|
|
55
|
+
|
|
56
|
+
## Dependency
|
|
57
|
+
|
|
58
|
+
Node ≥ 20. Scripts are dependency-free.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title><!-- slot:TITLE --></title>
|
|
7
|
+
<style>
|
|
8
|
+
<!-- slot:FONTS -->
|
|
9
|
+
:root {
|
|
10
|
+
--ink: #1a1d21; --muted: #5c6470; --line: #d9dde3;
|
|
11
|
+
--accent: #0f5c5a; --bg: #ffffff; --wash: #f6f7f9;
|
|
12
|
+
}
|
|
13
|
+
* { box-sizing: border-box; }
|
|
14
|
+
body {
|
|
15
|
+
margin: 0; background: var(--bg); color: var(--ink);
|
|
16
|
+
font: 16px/1.65 "IBM Plex Sans", system-ui, sans-serif;
|
|
17
|
+
}
|
|
18
|
+
nav {
|
|
19
|
+
position: fixed; top: 0; left: 0; bottom: 0; width: 230px;
|
|
20
|
+
padding: 2.5rem 1.5rem; border-right: 1px solid var(--line);
|
|
21
|
+
background: var(--wash); overflow-y: auto;
|
|
22
|
+
}
|
|
23
|
+
nav a {
|
|
24
|
+
display: block; color: var(--muted); text-decoration: none;
|
|
25
|
+
font-size: .85rem; padding: .3rem 0;
|
|
26
|
+
}
|
|
27
|
+
nav a:hover { color: var(--accent); }
|
|
28
|
+
main { max-width: 72ch; margin: 0 auto; padding: 3rem 2rem 5rem; }
|
|
29
|
+
@media (min-width: 980px) { main { margin-left: 270px; } }
|
|
30
|
+
@media (max-width: 979px) { nav { display: none; } }
|
|
31
|
+
h1 { font-size: 1.9rem; line-height: 1.25; letter-spacing: -.01em; }
|
|
32
|
+
h2 {
|
|
33
|
+
font-size: 1.25rem; margin-top: 2.6rem; padding-top: 1.2rem;
|
|
34
|
+
border-top: 1px solid var(--line); color: var(--accent);
|
|
35
|
+
}
|
|
36
|
+
h3 {
|
|
37
|
+
font-size: .85rem; text-transform: uppercase; letter-spacing: .07em;
|
|
38
|
+
color: var(--muted); font-weight: 600; margin: 1.6rem 0 .3rem;
|
|
39
|
+
}
|
|
40
|
+
dl.def-grid { margin: 0 0 .4rem; border-top: 1px solid var(--line); padding-top: .2rem; }
|
|
41
|
+
.def-grid .def {
|
|
42
|
+
display: grid; grid-template-columns: 220px 1fr; gap: 0 1.5rem;
|
|
43
|
+
padding: .5rem 0;
|
|
44
|
+
}
|
|
45
|
+
.def-grid dt { font-weight: 600; font-size: .95rem; }
|
|
46
|
+
.def-grid dd { margin: 0; color: var(--muted); }
|
|
47
|
+
@media (max-width: 640px) {
|
|
48
|
+
.def-grid .def { grid-template-columns: 1fr; gap: .15rem; }
|
|
49
|
+
}
|
|
50
|
+
table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
|
|
51
|
+
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
|
|
52
|
+
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
|
|
53
|
+
strong { font-weight: 600; }
|
|
54
|
+
code, pre { font-family: "IBM Plex Mono", monospace; font-size: .9em; }
|
|
55
|
+
.diagram-shell { margin: 1.5rem 0; padding: 1rem; background: var(--wash); border-radius: 8px; }
|
|
56
|
+
.mermaid-canvas svg { max-width: 100%; height: auto; }
|
|
57
|
+
@media print {
|
|
58
|
+
nav { display: none; }
|
|
59
|
+
main { margin: 0 auto; padding: 0; max-width: none; }
|
|
60
|
+
h2, h3 { break-after: avoid; }
|
|
61
|
+
table, .diagram-shell { break-inside: avoid; }
|
|
62
|
+
.def-grid .def { break-inside: avoid; }
|
|
63
|
+
@page { size: A4; margin: 22mm 18mm; }
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
66
|
+
</head>
|
|
67
|
+
<body>
|
|
68
|
+
<nav aria-label="Sections">
|
|
69
|
+
<!-- slot:NAV -->
|
|
70
|
+
</nav>
|
|
71
|
+
<main>
|
|
72
|
+
<!-- slot:CONTENT -->
|
|
73
|
+
</main>
|
|
74
|
+
<script>
|
|
75
|
+
<!-- slot:MERMAID_BUNDLE -->
|
|
76
|
+
</script>
|
|
77
|
+
<script>
|
|
78
|
+
mermaid.initialize({ startOnLoad: false, theme: 'neutral', fontFamily: '"IBM Plex Sans", sans-serif' });
|
|
79
|
+
mermaid.run({ querySelector: '.mermaid-canvas' });
|
|
80
|
+
</script>
|
|
81
|
+
</body>
|
|
82
|
+
</html>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Interview — prereq gate, client context, profile
|
|
2
|
+
|
|
3
|
+
Read before asking anything. Pre-fill from evidence, ask only holes, one
|
|
4
|
+
question at a time.
|
|
5
|
+
|
|
6
|
+
## 0. Prereq gate + evidence load
|
|
7
|
+
|
|
8
|
+
Both files must exist or the skill stops:
|
|
9
|
+
|
|
10
|
+
- No ARCHITECTURE.md → stop: "run the analyze-requirements skill first."
|
|
11
|
+
- No estimation.json → stop: "run the estimate skill first."
|
|
12
|
+
|
|
13
|
+
Read ARCHITECTURE.md, estimation.json, and estimation.md. Load the firm
|
|
14
|
+
profile (see §3). Then state what is already known: scope, milestones,
|
|
15
|
+
scenarios with cost/duration, risks, tech stack. The user corrects anything
|
|
16
|
+
stale before questions begin.
|
|
17
|
+
|
|
18
|
+
## 1. Client context — the only-human-knows questions
|
|
19
|
+
|
|
20
|
+
1. Client name, and who decides (owner? IT manager? founder?).
|
|
21
|
+
2. **Tech level: non-tech / low-tech / technical.** This sets the document's
|
|
22
|
+
language everywhere — non-tech bans jargon outright (the validator
|
|
23
|
+
enforces a deny-list; `jargon_allow` in frontmatter overrides per term
|
|
24
|
+
when the client themselves uses it).
|
|
25
|
+
3. The client's business problem, in their words — seeds Background &
|
|
26
|
+
Objectives.
|
|
27
|
+
4. What the client cares about most: price, speed, or reliability — shapes
|
|
28
|
+
the Executive Summary's emphasis.
|
|
29
|
+
5. Which scenario to offer. List every scenario from estimation.json with
|
|
30
|
+
its cost and duration; the user picks exactly one. Only that one appears
|
|
31
|
+
in the proposal.
|
|
32
|
+
6. Validity period — default 30 days from today; compute the date for
|
|
33
|
+
`valid_until`.
|
|
34
|
+
|
|
35
|
+
## 2. Gaps + confirmation
|
|
36
|
+
|
|
37
|
+
- Out-of-scope items beyond what estimation.md already excludes?
|
|
38
|
+
- Anything the client already rejected or demanded (constraints)?
|
|
39
|
+
- Anything in ARCHITECTURE.md or estimation.md that conflicts or is unclear
|
|
40
|
+
→ ask, never guess.
|
|
41
|
+
|
|
42
|
+
## 3. Firm profile
|
|
43
|
+
|
|
44
|
+
Lookup order: `<project>/.claude/proposal-profile.json` →
|
|
45
|
+
`~/.claude/proposal-profile.json` → none. Project scope wins when both exist.
|
|
46
|
+
|
|
47
|
+
Shape:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"firm": "Code Engine Studio",
|
|
52
|
+
"contact": "hello@codeenginestudio.com",
|
|
53
|
+
"website": "https://codeenginestudio.com",
|
|
54
|
+
"blurb": "One-paragraph plain-language introduction.",
|
|
55
|
+
"relevant_work": [{ "name": "Clinic scheduler", "oneliner": "what it was, outcome" }]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- Found → show it, confirm or edit; save edits back to the same scope.
|
|
60
|
+
- Not found → interview the fields, then ask: "store globally
|
|
61
|
+
(~/.claude/proposal-profile.json) or project-level
|
|
62
|
+
(.claude/proposal-profile.json)?" and write the chosen file.
|
|
63
|
+
- Corrupt/unreadable → warn, re-interview, rewrite.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Fresh-eyes review — subagent charter
|
|
2
|
+
|
|
3
|
+
Run after `validate.mjs` first exits 0, before human review. Dispatch one
|
|
4
|
+
general-purpose subagent with **only**: proposal.md, estimation.json, and
|
|
5
|
+
the client tech level. No interview context — it must read the document the
|
|
6
|
+
way the client will.
|
|
7
|
+
|
|
8
|
+
## Charter (the subagent checks exactly these)
|
|
9
|
+
|
|
10
|
+
1. **Comprehension** — would a reader at the stated tech level understand
|
|
11
|
+
every sentence? Flag anything too technical; this catches jargon beyond
|
|
12
|
+
the deny-list.
|
|
13
|
+
2. **Executive summary** — does page one answer what we build, what it
|
|
14
|
+
costs, and how long it takes?
|
|
15
|
+
3. **Honesty** — persuasive is fine, hype is not. Flag any claim the
|
|
16
|
+
document itself cannot back.
|
|
17
|
+
4. **Leaks** — anything internal: other scenarios, rates, provenance
|
|
18
|
+
words, confidence internals.
|
|
19
|
+
5. **Contradictions** — scope vs out-of-scope, price table vs summary,
|
|
20
|
+
milestones vs delivery prose.
|
|
21
|
+
|
|
22
|
+
Return findings as a list; no rewrites.
|
|
23
|
+
|
|
24
|
+
## Loop bound
|
|
25
|
+
|
|
26
|
+
Fix findings → re-run `validate.mjs` → one findings-only re-review, then
|
|
27
|
+
stop. Human review of proposal.md is the final gate regardless of what the
|
|
28
|
+
review found.
|