@v11g/agents-rock 1.0.2 → 1.0.4

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.
Files changed (65) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
  3. package/plugins/business-analyst/.claude-plugin/plugin.json +9 -0
  4. package/plugins/business-analyst/skills/business-analyst/README.md +23 -0
  5. package/plugins/business-analyst/skills/business-analyst/SKILL.md +73 -0
  6. package/plugins/business-analyst/skills/business-analyst/references/ai-extension.md +37 -0
  7. package/plugins/business-analyst/skills/business-analyst/references/frameworks.md +53 -0
  8. package/plugins/business-analyst/skills/business-analyst/references/interview.md +89 -0
  9. package/plugins/business-analyst/skills/business-analyst/references/review.md +25 -0
  10. package/plugins/business-analyst/skills/business-analyst/references/writing.md +102 -0
  11. package/plugins/business-analyst/skills/business-analyst/scripts/lib/checks.mjs +166 -0
  12. package/plugins/business-analyst/skills/business-analyst/scripts/lib/schema.mjs +78 -0
  13. package/plugins/business-analyst/skills/business-analyst/scripts/test/checks.test.mjs +188 -0
  14. package/plugins/business-analyst/skills/business-analyst/scripts/test/e2e.test.mjs +17 -0
  15. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-fail.json +205 -0
  16. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-pass.json +59 -0
  17. package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-pass.md +63 -0
  18. package/plugins/business-analyst/skills/business-analyst/scripts/test/python-parity.test.mjs +50 -0
  19. package/plugins/business-analyst/skills/business-analyst/scripts/test/schema.test.mjs +41 -0
  20. package/plugins/business-analyst/skills/business-analyst/scripts/validate.mjs +20 -0
  21. package/plugins/business-analyst/skills/business-analyst/scripts/validate.py +288 -0
  22. package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
  23. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +4 -2
  24. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +4 -1
  25. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +3 -2
  26. package/plugins/solution-architect/skills/estimate/SKILL.md +13 -5
  27. package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +917 -0
  28. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +430 -13
  29. package/plugins/solution-architect/skills/estimate/references/agentic-estimation.md +148 -0
  30. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +10 -0
  31. package/plugins/solution-architect/skills/estimate/references/interview.md +20 -1
  32. package/plugins/solution-architect/skills/estimate/references/task-shapes.md +173 -0
  33. package/plugins/solution-architect/skills/estimate/references/writing.md +31 -0
  34. package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +5 -1
  35. package/plugins/solution-architect/skills/estimate/scripts/lib/agentic-checks.mjs +65 -0
  36. package/plugins/solution-architect/skills/estimate/scripts/lib/baselines.mjs +107 -0
  37. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +16 -7
  38. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +14 -0
  39. package/plugins/solution-architect/skills/estimate/scripts/lib/measurements.mjs +59 -0
  40. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +28 -5
  41. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +53 -22
  42. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +52 -7
  43. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +14 -3
  44. package/plugins/solution-architect/skills/estimate/scripts/test/baselines.test.mjs +120 -0
  45. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +69 -0
  46. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +44 -0
  47. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +28 -1
  48. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-fail.md +55 -0
  49. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-pass.md +54 -0
  50. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +45 -0
  51. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/measurements.jsonl +20 -0
  52. package/plugins/solution-architect/skills/estimate/scripts/test/measurements.test.mjs +54 -0
  53. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +25 -1
  54. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +48 -1
  55. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +59 -0
  56. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +37 -0
  57. package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +168 -0
  58. package/plugins/solution-architect/skills/estimate/scripts/test/zip.mjs +41 -0
  59. package/plugins/solution-architect/skills/new-lead/SKILL.md +15 -10
  60. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +25 -50
  61. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +20 -40
  62. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +12 -4
  63. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +8 -3
  64. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +4 -0
  65. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +25 -21
@@ -0,0 +1,168 @@
1
+ // The Feature breakdown's spreadsheet export: an internal-only button that
2
+ // clones the sample estimator workbook in the browser, fills tab 1 with the
3
+ // currently visible rows, and keeps every tier/price formula live in-cell.
4
+ import { test } from 'node:test';
5
+ import assert from 'node:assert/strict';
6
+ import { mkdtempSync } from 'node:fs';
7
+ import { execFileSync } from 'node:child_process';
8
+ import { tmpdir } from 'node:os';
9
+ import { join } from 'node:path';
10
+ import { pathToFileURL } from 'node:url';
11
+ import { findChrome } from '../../../analyze-requirements/scripts/lib/chrome.mjs';
12
+ import { openPage } from '../../../analyze-requirements/scripts/lib/cdp.mjs';
13
+ import { readZip } from './zip.mjs';
14
+
15
+ const skip = { skip: !findChrome() && 'no chrome on PATH' };
16
+ const fixture = new URL('./fixtures/booking-inputs.json', import.meta.url).pathname;
17
+
18
+ function buildPage() {
19
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-xlsx-'));
20
+ const scripts = new URL('..', import.meta.url).pathname;
21
+ const passMd = join(scripts, 'test/fixtures/estimation-pass.md');
22
+ execFileSync('node', [join(scripts, 'compute.mjs'), '--inputs', fixture, '--out', join(dir, 'estimation.json')]);
23
+ execFileSync('node', [join(scripts, 'render.mjs'), '--json', join(dir, 'estimation.json'), '--md', passMd, '--out', dir]);
24
+ return pathToFileURL(join(dir, 'estimate.html')).href;
25
+ }
26
+
27
+ async function exportedFiles(page) {
28
+ const b64 = await page.eval('window.__buildWorkbook()');
29
+ return readZip(Buffer.from(b64, 'base64'));
30
+ }
31
+
32
+ const sheet1 = (files) => files.get('xl/worksheets/sheet1.xml').toString('utf8');
33
+ const cell = (xml, ref) => new RegExp(`<c r="${ref}"[^>]*>(.*?)</c>`, 's').exec(xml)?.[1] ?? '';
34
+ const inlineText = (frag) => /<t[^>]*>([^<]*)<\/t>/.exec(frag)?.[1];
35
+ const cellNumber = (frag) => Number(/<v>([^<]*)<\/v>/.exec(frag)?.[1]);
36
+ const cellFormula = (frag) => /<f>([^<]*)<\/f>/.exec(frag)?.[1];
37
+
38
+ test('the breakdown filter bar carries an internal-only download button', skip, async () => {
39
+ const page = await openPage(buildPage());
40
+ try {
41
+ assert.ok(await page.eval(
42
+ `!!document.querySelector('#feature-table .bd-filters button[data-download][data-internal]')`),
43
+ 'expected a data-download button marked data-internal in the filter bar');
44
+ } finally { page.close(); }
45
+ });
46
+
47
+ test('the export clones the sample workbook with its guide tabs intact', skip, async () => {
48
+ const page = await openPage(buildPage());
49
+ try {
50
+ const files = await exportedFiles(page);
51
+ for (const name of ['xl/worksheets/sheet1.xml', 'xl/worksheets/sheet2.xml',
52
+ 'xl/worksheets/sheet3.xml', 'xl/styles.xml', '[Content_Types].xml']) {
53
+ assert.ok(files.has(name), `${name} missing from the exported archive`);
54
+ }
55
+ const workbook = files.get('xl/workbook.xml').toString('utf8');
56
+ assert.match(workbook, /Scoring Guide/);
57
+ assert.match(workbook, /Tier Reference/);
58
+ } finally { page.close(); }
59
+ });
60
+
61
+ test('rows land as inline strings ordered by milestone with derived 1-5 scores', skip, async () => {
62
+ const page = await openPage(buildPage());
63
+ try {
64
+ const xml = sheet1(await exportedFiles(page));
65
+ // M1 feature before M2 feature regardless of the table's hour sort
66
+ assert.equal(inlineText(cell(xml, 'A7')), 'User can book appointment');
67
+ assert.equal(inlineText(cell(xml, 'A8')), 'Email reminders');
68
+ for (const row of [7, 8]) {
69
+ for (const col of ['B', 'C', 'D', 'E', 'F']) {
70
+ const v = cellNumber(cell(xml, `${col}${row}`));
71
+ assert.ok(Number.isInteger(v) && v >= 1 && v <= 5, `${col}${row} must be 1-5, got ${v}`);
72
+ }
73
+ }
74
+ } finally { page.close(); }
75
+ });
76
+
77
+ test('tech and size scores follow the Scoring Guide definitions', skip, async () => {
78
+ const page = await openPage(buildPage());
79
+ try {
80
+ const xml = sheet1(await exportedFiles(page));
81
+ // TECH: hours-weighted category score (boilerplate 1.5, logic 3, novel 5).
82
+ // Booking mixes boilerplate(25.3h) + logic(44h) → 2.45 → 2; reminders is
83
+ // logic-only → 3.
84
+ assert.equal(cellNumber(cell(xml, 'B7')), 2);
85
+ assert.equal(cellNumber(cell(xml, 'B8')), 3);
86
+ // SIZE: absolute expected-hour bands [8, 24, 64, 128] per the guide's
87
+ // "<1 day → epic" scale. Booking ≈69h → 4; reminders ≈21h → 2.
88
+ assert.equal(cellNumber(cell(xml, 'C7')), 4);
89
+ assert.equal(cellNumber(cell(xml, 'C8')), 2);
90
+ } finally { page.close(); }
91
+ });
92
+
93
+ test('score math stays in the sheet: G-K are formulas, total row uses SUMIF', skip, async () => {
94
+ const page = await openPage(buildPage());
95
+ try {
96
+ const xml = sheet1(await exportedFiles(page));
97
+ assert.match(cellFormula(cell(xml, 'G7')) ?? '', /SUM\(B7:F7\)/);
98
+ assert.match(cellFormula(cell(xml, 'H7')) ?? '', /IF\(/);
99
+ for (const ref of ['I7', 'J7', 'K7']) {
100
+ assert.ok(cellFormula(cell(xml, ref)), `${ref} must hold a formula, not a baked value`);
101
+ }
102
+ assert.equal(inlineText(cell(xml, 'A27')), 'PROJECT TOTAL');
103
+ assert.match(cellFormula(cell(xml, 'G27')) ?? '', /SUMIF\(G7:G26/);
104
+ } finally { page.close(); }
105
+ });
106
+
107
+ test('milestone and container fill L/M under an autofiltered header', skip, async () => {
108
+ const page = await openPage(buildPage());
109
+ try {
110
+ const xml = sheet1(await exportedFiles(page));
111
+ assert.equal(inlineText(cell(xml, 'L6')), 'MILESTONE');
112
+ assert.equal(inlineText(cell(xml, 'M6')), 'CONTAINER');
113
+ assert.equal(inlineText(cell(xml, 'L7')), 'M1 - Booking core');
114
+ assert.equal(inlineText(cell(xml, 'M7')), 'Booking API');
115
+ assert.equal(inlineText(cell(xml, 'M8')), 'Notification Service');
116
+ assert.match(xml, /<autoFilter ref="A6:M26"\/>/);
117
+ } finally { page.close(); }
118
+ });
119
+
120
+ test('the export honours the active source filter', skip, async () => {
121
+ const page = await openPage(buildPage());
122
+ try {
123
+ await page.eval(`document.querySelector('#feature-table [data-prov="stated"]').click()`);
124
+ const xml = sheet1(await exportedFiles(page));
125
+ assert.match(xml, /User can book appointment/);
126
+ assert.doesNotMatch(xml, /Email reminders/);
127
+ assert.equal(inlineText(cell(xml, 'A27')), 'PROJECT TOTAL', 'total row must survive filtering');
128
+ } finally { page.close(); }
129
+ });
130
+
131
+ const sheetTasks = (files) => files.get('xl/worksheets/sheet4.xml')?.toString('utf8') ?? '';
132
+
133
+ test('the export adds a registered Task Breakdown tab', skip, async () => {
134
+ const page = await openPage(buildPage());
135
+ try {
136
+ const files = await exportedFiles(page);
137
+ assert.ok(files.has('xl/worksheets/sheet4.xml'), 'sheet4.xml missing');
138
+ assert.match(files.get('xl/workbook.xml').toString('utf8'), /name="Task Breakdown"/);
139
+ assert.match(files.get('xl/_rels/workbook.xml.rels').toString('utf8'), /Target="worksheets\/sheet4\.xml"/);
140
+ assert.match(files.get('[Content_Types].xml').toString('utf8'), /PartName="\/xl\/worksheets\/sheet4\.xml"/);
141
+ } finally { page.close(); }
142
+ });
143
+
144
+ test('task rows carry the PERT formula in-cell and ride the feature filter', skip, async () => {
145
+ const page = await openPage(buildPage());
146
+ try {
147
+ await page.eval(`document.querySelector('#feature-table [data-prov="stated"]').click()`);
148
+ const xml = sheetTasks(await exportedFiles(page));
149
+ assert.equal(inlineText(cell(xml, 'A2')), 'User can book appointment');
150
+ assert.equal(inlineText(cell(xml, 'B2')), 'Booking CRUD API');
151
+ assert.deepEqual(['D2', 'E2', 'F2'].map((r) => cellNumber(cell(xml, r))), [16, 24, 40]);
152
+ assert.match(cellFormula(cell(xml, 'G2')) ?? '', /\(D2\+4\*E2\+F2\)\/6/);
153
+ assert.equal(inlineText(cell(xml, 'H2')), 'HIGH');
154
+ assert.equal(inlineText(cell(xml, 'K2')), 'Booking API');
155
+ assert.doesNotMatch(xml, /Scheduled reminder jobs/, 'filtered-out feature tasks must not export');
156
+ } finally { page.close(); }
157
+ });
158
+
159
+ test('the task tab is filterable and sortable: autofilter over a frozen header', skip, async () => {
160
+ const page = await openPage(buildPage());
161
+ try {
162
+ const xml = sheetTasks(await exportedFiles(page));
163
+ assert.equal(inlineText(cell(xml, 'A1')), 'FEATURE');
164
+ // 3 fixture tasks under rows 2-4
165
+ assert.match(xml, /<autoFilter ref="A1:K4"\/>/);
166
+ assert.match(xml, /<pane ySplit="1"[^>]*state="frozen"/);
167
+ } finally { page.close(); }
168
+ });
@@ -0,0 +1,41 @@
1
+ // Minimal zip reader for asserting on workbooks the page exports.
2
+ // Central-directory driven: find EOCD, walk entries, inflate each.
3
+ import { inflateRawSync } from 'node:zlib';
4
+
5
+ function eocdOffset(buf) {
6
+ for (let i = buf.length - 22; i >= 0; i--) {
7
+ if (buf.readUInt32LE(i) === 0x06054b50) return i;
8
+ }
9
+ throw new Error('no end-of-central-directory record');
10
+ }
11
+
12
+ function entryData(buf, cd) {
13
+ const method = buf.readUInt16LE(cd + 10);
14
+ const csize = buf.readUInt32LE(cd + 20);
15
+ const local = buf.readUInt32LE(cd + 42);
16
+ const nameLen = buf.readUInt16LE(local + 26);
17
+ const extraLen = buf.readUInt16LE(local + 28);
18
+ const start = local + 30 + nameLen + extraLen;
19
+ const raw = buf.subarray(start, start + csize);
20
+ if (method === 0) return Buffer.from(raw);
21
+ if (method === 8) return inflateRawSync(raw);
22
+ throw new Error(`unsupported compression method ${method}`);
23
+ }
24
+
25
+ // Returns Map<path, Buffer> of every file in the archive.
26
+ export function readZip(buf) {
27
+ const eocd = eocdOffset(buf);
28
+ const count = buf.readUInt16LE(eocd + 10);
29
+ let cd = buf.readUInt32LE(eocd + 16);
30
+ const files = new Map();
31
+ for (let i = 0; i < count; i++) {
32
+ if (buf.readUInt32LE(cd) !== 0x02014b50) throw new Error('bad central directory');
33
+ const nameLen = buf.readUInt16LE(cd + 28);
34
+ const extraLen = buf.readUInt16LE(cd + 30);
35
+ const commentLen = buf.readUInt16LE(cd + 32);
36
+ const name = buf.toString('utf8', cd + 46, cd + 46 + nameLen);
37
+ files.set(name, entryData(buf, cd));
38
+ cd += 46 + nameLen + extraLen + commentLen;
39
+ }
40
+ return files;
41
+ }
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: new-lead
3
- description: Set up a pre-sales lead workspace and walk the human through the three solution-architect skills in order — analyze-requirements, estimate, proposal — plus a local leads dashboard. Use when the user says "new lead", points at a folder under leads/, or asks to see their leads pipeline.
3
+ description: Set up a pre-sales lead workspace and walk the human through the solution-architect skills in order — business-analyst first when installed, then analyze-requirements, estimate, proposal — plus a local leads dashboard. Use when the user says "new lead", points at a folder under leads/, or asks to see their leads pipeline.
4
4
  ---
5
5
 
6
6
  # new-lead
7
7
 
8
- Prepare a lead's workspace, then run `/analyze-requirements`, `/estimate` and
9
- `/proposal` in that order, stopping between each so the human sees what was
10
- produced. Also maintains the leads dashboard: a `leads.json` registry and a
8
+ Prepare a lead's workspace, then run `/business-analyst` (when installed),
9
+ `/analyze-requirements`, `/estimate` and `/proposal` in that order, stopping
10
+ between each so the human sees what was produced. Also maintains the leads dashboard: a `leads.json` registry and a
11
11
  self-contained local server.
12
12
 
13
13
  ## Hard rules
@@ -45,10 +45,15 @@ self-contained local server.
45
45
  - `/new-lead` with no argument → diff `readdir(<root>/leads)` against
46
46
  `leads.json` and print the state table below; the human picks one.
47
47
  4. **Adopt** (only when the folder has no registry entry) — see Adoption.
48
- 5. **Chain**: for each of `/analyze-requirements`, `/estimate`, `/proposal` —
49
- `cd` to the lead directory, invoke the skill, and when it returns, report
50
- what it wrote and wait. Skip any step whose artifact already exists unless
51
- the human asks for a re-run.
48
+ 5. **Chain**: when the `business-analyst` skill is available, the chain is
49
+ `/business-analyst`, `/analyze-requirements`, `/estimate`, `/proposal`;
50
+ otherwise recommend installing the business-analyst plugin in one line
51
+ (requirements discovery before architecture) and run the three-step
52
+ chain. For each step — `cd` to the lead directory, invoke the skill,
53
+ and when it returns, report what it wrote and wait. Skip any step whose
54
+ artifact already exists unless the human asks for a re-run.
55
+ `requirements.json` is soft evidence for the later skills, never a
56
+ prerequisite.
52
57
  6. **Sync the registry** after `/proposal` — see Registry sync.
53
58
  7. **Wrap**: start the dashboard (`sh <root>/start.sh`) if it is not already
54
59
  running, and report the URL.
@@ -58,8 +63,8 @@ self-contained local server.
58
63
  | State | Condition | Offer |
59
64
  | --- | --- | --- |
60
65
  | new | folder present, no registry entry | adopt, then run the chain |
61
- | WIP | entry present, one of `ARCHITECTURE.md` / `estimation.json` / `proposal.md` missing | resume at the first gap |
62
- | done | entry present, all three present | nothing; re-run a named step on request |
66
+ | WIP | entry present, one of `requirements.json` (checked only when the business-analyst skill is installed) / `ARCHITECTURE.md` / `estimation.json` / `proposal.md` missing | resume at the first gap |
67
+ | done | entry present, no artifact from the WIP row missing | nothing; re-run a named step on request |
63
68
  | orphan | entry present, folder gone | report only — never delete |
64
69
 
65
70
  ## Adoption
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
- <!-- new-lead-dashboard v3 -->
2
+ <!-- new-lead-dashboard v4 -->
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="utf-8">
@@ -8,48 +8,9 @@
8
8
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' rx='3' fill='%230f766e'/%3E%3C/svg%3E">
9
9
  <title>Lead detail</title>
10
10
  <style>
11
- /* Tokens: same vocabulary as index.html. Full light palette on bare :root,
12
- dark redefines via media query; [data-theme] lets this page's own toggle
13
- force an override in either direction. */
11
+ /* Tokens: same vocabulary as index.html. Dark by default on bare :root;
12
+ [data-theme="light"] is the explicit override this page's toggle sets. */
14
13
  :root {
15
- color-scheme:light;
16
- --bg:#f6f4ef; --bg-sunk:#edeae1; --card:#fffdf9; --card-raised:#fff;
17
- --ink:#1c1b18; --ink-soft:#45423a; --ink-dim:#6c6759;
18
- --border:#e4dfd3; --border-strong:#cec7b6;
19
- --accent:#0f766e; --accent-ink:#0a544f; --accent-soft:rgba(15,118,110,.09); --accent-line:rgba(15,118,110,.38);
20
- --ok:#15803d; --ok-soft:rgba(21,128,61,.1);
21
- --warn:#a55708; --warn-soft:rgba(165,87,8,.1);
22
- --pending-bg:#eae7dd; --pending-border:#c8c1b0; --pending-ink:#857f70;
23
- --focus:#0f766e; --focus-halo:rgba(15,118,110,.22);
24
- --scroll-thumb:#cec7b6; --scroll-thumb-hover:#b3aa95; --scroll-track:transparent;
25
- --tier-flat:0 0 0 1px rgba(0,0,0,.06);
26
- --tier-raised:0 0 0 1px rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.06), 0 2px 4px 0 rgba(0,0,0,.04);
27
- --tier-raised-hover:0 0 0 1px rgba(0,0,0,.08), 0 1px 2px -1px rgba(0,0,0,.08), 0 2px 4px 0 rgba(0,0,0,.06);
28
- --tier-hero:0 0 0 1px rgba(15,118,110,.16), 0 2px 6px -2px rgba(0,0,0,.07), 0 10px 26px -8px rgba(0,0,0,.09);
29
- --tier-sunk:inset 0 1px 3px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.04);
30
- --r-lg:.875rem; --r-md:.625rem; --r-sm:.5rem; --r-xs:.375rem; --r-pill:999px;
31
- --topbar-h:4.25rem; --ease:cubic-bezier(.16, 1, .3, 1);
32
- }
33
- @media (prefers-color-scheme:dark) {
34
- :root:not([data-theme="light"]) {
35
- color-scheme:dark;
36
- --bg:#0f1413; --bg-sunk:#0a0e0d; --card:#171d1c; --card-raised:#1c2322;
37
- --ink:#e9e7e2; --ink-soft:#bdc4c0; --ink-dim:#8d9a95;
38
- --border:#26312f; --border-strong:#3a4946;
39
- --accent:#3fb3a8; --accent-ink:#74d6cc; --accent-soft:rgba(63,179,168,.13); --accent-line:rgba(63,179,168,.42);
40
- --ok:#62c082; --ok-soft:rgba(98,192,130,.13);
41
- --warn:#dd9247; --warn-soft:rgba(221,146,71,.13);
42
- --pending-bg:#171d1c; --pending-border:#35423f; --pending-ink:#737e79;
43
- --focus:#74d6cc; --focus-halo:rgba(116,214,204,.25);
44
- --scroll-thumb:#3a4946; --scroll-thumb-hover:#4f6360;
45
- --tier-flat:0 0 0 1px rgba(255,255,255,.08);
46
- --tier-raised:0 0 0 1px rgba(255,255,255,.08);
47
- --tier-raised-hover:0 0 0 1px rgba(255,255,255,.13);
48
- --tier-hero:0 0 0 1px rgba(116,214,204,.22), 0 10px 30px -12px rgba(0,0,0,.7);
49
- --tier-sunk:inset 0 1px 3px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.05);
50
- }
51
- }
52
- :root[data-theme="dark"] {
53
14
  color-scheme:dark;
54
15
  --bg:#0f1413; --bg-sunk:#0a0e0d; --card:#171d1c; --card-raised:#1c2322;
55
16
  --ink:#e9e7e2; --ink-soft:#bdc4c0; --ink-dim:#8d9a95;
@@ -59,12 +20,31 @@
59
20
  --warn:#dd9247; --warn-soft:rgba(221,146,71,.13);
60
21
  --pending-bg:#171d1c; --pending-border:#35423f; --pending-ink:#737e79;
61
22
  --focus:#74d6cc; --focus-halo:rgba(116,214,204,.25);
62
- --scroll-thumb:#3a4946; --scroll-thumb-hover:#4f6360;
23
+ --scroll-thumb:#3a4946; --scroll-thumb-hover:#4f6360; --scroll-track:transparent;
63
24
  --tier-flat:0 0 0 1px rgba(255,255,255,.08);
64
25
  --tier-raised:0 0 0 1px rgba(255,255,255,.08);
65
26
  --tier-raised-hover:0 0 0 1px rgba(255,255,255,.13);
66
27
  --tier-hero:0 0 0 1px rgba(116,214,204,.22), 0 10px 30px -12px rgba(0,0,0,.7);
67
28
  --tier-sunk:inset 0 1px 3px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.05);
29
+ --r-lg:.875rem; --r-md:.625rem; --r-sm:.5rem; --r-xs:.375rem; --r-pill:999px;
30
+ --topbar-h:4.25rem; --ease:cubic-bezier(.16, 1, .3, 1);
31
+ }
32
+ :root[data-theme="light"] {
33
+ color-scheme:light;
34
+ --bg:#f6f4ef; --bg-sunk:#edeae1; --card:#fffdf9; --card-raised:#fff;
35
+ --ink:#1c1b18; --ink-soft:#45423a; --ink-dim:#6c6759;
36
+ --border:#e4dfd3; --border-strong:#cec7b6;
37
+ --accent:#0f766e; --accent-ink:#0a544f; --accent-soft:rgba(15,118,110,.09); --accent-line:rgba(15,118,110,.38);
38
+ --ok:#15803d; --ok-soft:rgba(21,128,61,.1);
39
+ --warn:#a55708; --warn-soft:rgba(165,87,8,.1);
40
+ --pending-bg:#eae7dd; --pending-border:#c8c1b0; --pending-ink:#857f70;
41
+ --focus:#0f766e; --focus-halo:rgba(15,118,110,.22);
42
+ --scroll-thumb:#cec7b6; --scroll-thumb-hover:#b3aa95;
43
+ --tier-flat:0 0 0 1px rgba(0,0,0,.06);
44
+ --tier-raised:0 0 0 1px rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.06), 0 2px 4px 0 rgba(0,0,0,.04);
45
+ --tier-raised-hover:0 0 0 1px rgba(0,0,0,.08), 0 1px 2px -1px rgba(0,0,0,.08), 0 2px 4px 0 rgba(0,0,0,.06);
46
+ --tier-hero:0 0 0 1px rgba(15,118,110,.16), 0 2px 6px -2px rgba(0,0,0,.07), 0 10px 26px -8px rgba(0,0,0,.09);
47
+ --tier-sunk:inset 0 1px 3px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.04);
68
48
  }
69
49
 
70
50
  /* base */
@@ -454,19 +434,14 @@ function esc(s) {
454
434
  }
455
435
 
456
436
  /* ================================================================== *
457
- * Theme toggle (three-state tokens; this only forces an override).
437
+ * Theme toggle (dark is the page default; light is an explicit override).
458
438
  * ================================================================== */
459
439
  (function () {
460
440
  const buttons = document.querySelectorAll('[data-set-theme]');
461
441
  function mark(theme) {
462
442
  buttons.forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.setTheme === theme)));
463
443
  }
464
- const media = window.matchMedia('(prefers-color-scheme: dark)');
465
- function current() {
466
- return document.documentElement.dataset.theme || (media.matches ? 'dark' : 'light');
467
- }
468
- mark(current());
469
- media.addEventListener('change', () => { if (!document.documentElement.dataset.theme) mark(current()); });
444
+ mark(document.documentElement.dataset.theme || 'dark');
470
445
  buttons.forEach((btn) => btn.addEventListener('click', () => {
471
446
  document.documentElement.dataset.theme = btn.dataset.setTheme;
472
447
  mark(btn.dataset.setTheme);
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
- <!-- new-lead-dashboard v2 -->
2
+ <!-- new-lead-dashboard v3 -->
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="utf-8">
@@ -8,51 +8,31 @@
8
8
  <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' rx='3' fill='%230f766e'/%3E%3C/svg%3E">
9
9
  <title>Leads</title>
10
10
  <style>
11
- /* Tokens: same vocabulary as the lead detail page. Full light palette on bare
12
- :root, dark redefines only. No [data-theme] override block because this page
13
- ships no theme control. */
11
+ /* Tokens: same vocabulary as the lead detail page. Dark by default on bare
12
+ :root. No light block and no [data-theme] override because this page ships
13
+ no theme control. */
14
14
  :root {
15
- color-scheme:light;
16
- --bg:#f6f4ef; --bg-sunk:#edeae1; --card:#fffdf9; --card-raised:#fff;
17
- --ink:#1c1b18; --ink-soft:#45423a; --ink-dim:#6c6759;
18
- --border:#e4dfd3; --border-strong:#cec7b6;
19
- --accent:#0f766e; --accent-ink:#0a544f; --accent-soft:rgba(15,118,110,.09); --accent-line:rgba(15,118,110,.38);
20
- --ok:#15803d; --ok-soft:rgba(21,128,61,.1);
21
- --warn:#a55708; --warn-soft:rgba(165,87,8,.1);
22
- --pending-bg:#eae7dd; --pending-ink:#857f70;
23
- --focus:#0f766e;
15
+ color-scheme:dark;
16
+ --bg:#0f1413; --bg-sunk:#0a0e0d; --card:#171d1c; --card-raised:#1c2322;
17
+ --ink:#e9e7e2; --ink-soft:#bdc4c0; --ink-dim:#8d9a95;
18
+ --border:#26312f; --border-strong:#3a4946;
19
+ --accent:#3fb3a8; --accent-ink:#74d6cc; --accent-soft:rgba(63,179,168,.13); --accent-line:rgba(63,179,168,.42);
20
+ --ok:#62c082; --ok-soft:rgba(98,192,130,.13);
21
+ --warn:#dd9247; --warn-soft:rgba(221,146,71,.13);
22
+ --pending-bg:#1f2726; --pending-ink:#8d9a95;
23
+ --focus:#74d6cc;
24
24
  /* Opaque: sticky cells paint over scrolling content, so these two cannot be tints. */
25
- --row-hover:#f2efe7; --th-active:#e6e9e4;
26
- --scroll-thumb:#cec7b6; --scroll-thumb-hover:#b3aa95; --scroll-track:transparent;
25
+ --row-hover:#1d2523; --th-active:#152321;
26
+ --scroll-thumb:#3a4946; --scroll-thumb-hover:#4f6360; --scroll-track:transparent;
27
27
  /* Depth tiers: layered transparent shadows instead of borders. */
28
- --tier-flat:0 0 0 1px rgba(0,0,0,.06);
29
- --tier-raised:0 0 0 1px rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.06), 0 2px 4px 0 rgba(0,0,0,.04);
30
- --tier-raised-hover:0 0 0 1px rgba(0,0,0,.08), 0 1px 2px -1px rgba(0,0,0,.08), 0 2px 4px 0 rgba(0,0,0,.06);
31
- --tier-hero:0 0 0 1px rgba(15,118,110,.16), 0 2px 6px -2px rgba(0,0,0,.07), 0 10px 26px -8px rgba(0,0,0,.09);
32
- --tier-sunk:inset 0 1px 3px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.04);
28
+ --tier-flat:0 0 0 1px rgba(255,255,255,.08);
29
+ --tier-raised:0 0 0 1px rgba(255,255,255,.08);
30
+ --tier-raised-hover:0 0 0 1px rgba(255,255,255,.13);
31
+ --tier-hero:0 0 0 1px rgba(116,214,204,.22), 0 10px 30px -12px rgba(0,0,0,.7);
32
+ --tier-sunk:inset 0 1px 3px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.05);
33
33
  --r-lg:.875rem; --r-md:.625rem; --r-sm:.5rem; --r-xs:.375rem; --r-pill:999px;
34
34
  --topbar-h:3.5rem; --ease:cubic-bezier(.16, 1, .3, 1);
35
35
  }
36
- @media (prefers-color-scheme:dark) {
37
- :root {
38
- color-scheme:dark;
39
- --bg:#0f1413; --bg-sunk:#0a0e0d; --card:#171d1c; --card-raised:#1c2322;
40
- --ink:#e9e7e2; --ink-soft:#bdc4c0; --ink-dim:#8d9a95;
41
- --border:#26312f; --border-strong:#3a4946;
42
- --accent:#3fb3a8; --accent-ink:#74d6cc; --accent-soft:rgba(63,179,168,.13); --accent-line:rgba(63,179,168,.42);
43
- --ok:#62c082; --ok-soft:rgba(98,192,130,.13);
44
- --warn:#dd9247; --warn-soft:rgba(221,146,71,.13);
45
- --pending-bg:#1f2726; --pending-ink:#8d9a95;
46
- --focus:#74d6cc;
47
- --row-hover:#1d2523; --th-active:#152321;
48
- --scroll-thumb:#3a4946; --scroll-thumb-hover:#4f6360;
49
- --tier-flat:0 0 0 1px rgba(255,255,255,.08);
50
- --tier-raised:0 0 0 1px rgba(255,255,255,.08);
51
- --tier-raised-hover:0 0 0 1px rgba(255,255,255,.13);
52
- --tier-hero:0 0 0 1px rgba(116,214,204,.22), 0 10px 30px -12px rgba(0,0,0,.7);
53
- --tier-sunk:inset 0 1px 3px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.05);
54
- }
55
- }
56
36
 
57
37
  /* base */
58
38
  * { box-sizing:border-box; }
@@ -1,5 +1,5 @@
1
1
  // scripts/lib/map-nodes.mjs
2
- // new-lead-dashboard v2
2
+ // new-lead-dashboard v3
3
3
  import { readdir } from 'node:fs/promises';
4
4
  import { join } from 'node:path';
5
5
 
@@ -37,7 +37,7 @@ export async function leadNodes(id, dir, src) {
37
37
  const proposalMds = [...ctx.names].filter((n) => isProposalMd(n) && n !== 'proposal.md');
38
38
  const claimed = new Set([...Object.values(NAMED_PAGES), ...proposalMds.map(htmlFor)]);
39
39
  return [
40
- ...evidenceNodes(entries),
40
+ ...evidenceNodes(ctx, entries),
41
41
  ...docNodes(ctx),
42
42
  ...proposalMds.map((n) => docNode(ctx, { key: n, label: n, page: htmlFor(n), exists: true })),
43
43
  ...pageNodes(ctx, claimed),
@@ -51,12 +51,20 @@ function isEvidence(entry) {
51
51
  && !isProposalMd(entry.name);
52
52
  }
53
53
 
54
- function evidenceNodes(entries) {
54
+ // Doc extensions the dashboard server serves from the lead root (serve.mjs DOC_RE).
55
+ const VIEWABLE_RE = /\.(?:md|txt|csv|json|pdf)$/;
56
+
57
+ function evidenceNodes(ctx, entries) {
55
58
  return entries.filter(isEvidence).map((entry) => ({
56
59
  id: `evidence-${entry.name}`,
57
60
  type: 'evidence',
58
61
  position: { x: 0, y: 0 },
59
- data: { label: entry.name, status: 'ready', href: null, detail: null },
62
+ data: {
63
+ label: entry.name,
64
+ status: 'ready',
65
+ href: entry.isFile() && VIEWABLE_RE.test(entry.name) ? `/leads/${ctx.id}/${entry.name}` : null,
66
+ detail: null,
67
+ },
60
68
  }));
61
69
  }
62
70
 
@@ -1,5 +1,5 @@
1
1
  // scripts/serve.mjs
2
- // new-lead-dashboard v3
2
+ // new-lead-dashboard v4
3
3
  import { createServer } from 'node:http';
4
4
  import { readFile, writeFile, realpath, stat, lstat } from 'node:fs/promises';
5
5
  import { join, resolve, sep, extname } from 'node:path';
@@ -12,10 +12,14 @@ import { findFreePort } from './lib/port.mjs';
12
12
 
13
13
  const MIME = {
14
14
  '.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', '.css': 'text/css',
15
- '.json': 'application/json', '.svg': 'image/svg+xml', '.md': 'text/plain',
15
+ '.json': 'application/json', '.svg': 'image/svg+xml', '.pdf': 'application/pdf',
16
+ '.md': 'text/plain; charset=utf-8', '.txt': 'text/plain; charset=utf-8', '.csv': 'text/plain; charset=utf-8',
16
17
  };
17
18
  const ID = ID_RE.source.slice(1, -1);
18
19
  const DIST_RE = new RegExp(`^/leads/(${ID})/dist/`);
20
+ // Documents at the lead root (requirements.md, rfp.md, a client PDF, ...) are
21
+ // viewable in the browser: one path segment deep, doc extensions only.
22
+ const DOC_RE = new RegExp(`^/leads/(${ID})/[^/]+\\.(?:md|txt|csv|json|pdf)$`);
19
23
  const SCRIPTS_DIR = 'scripts';
20
24
  const DEFAULT_PORT = 4600;
21
25
 
@@ -128,7 +132,8 @@ function send(res, status, body) {
128
132
  function isAllowlisted(decoded) {
129
133
  return decoded === '/scripts/stats.mjs'
130
134
  || decoded.startsWith('/scripts/vendor/')
131
- || DIST_RE.test(decoded);
135
+ || DIST_RE.test(decoded)
136
+ || DOC_RE.test(decoded);
132
137
  }
133
138
 
134
139
  async function serveStatic(root, pathname, res) {
@@ -26,6 +26,10 @@ test('evidence is the human-dropped files, never the generated artifacts', async
26
26
  assert.ok(!labels.includes(generated), `${generated} must not be listed as evidence`);
27
27
  }
28
28
  });
29
+ test('evidence doc files are clickable, served from the lead root', async () => {
30
+ const m = await buildLeadMap(ROOT, 'acme-crm');
31
+ assert.equal(byId(m, 'evidence-rfp.md').data.href, '/leads/acme-crm/rfp.md');
32
+ });
29
33
  test('components parsed from ARCHITECTURE.md §6 table', async () => {
30
34
  const m = await buildLeadMap(ROOT, 'acme-crm');
31
35
  assert.ok(byId(m, 'component-atlas.api'));
@@ -65,14 +65,31 @@ test('static serving with traversal guard', async () => {
65
65
  assert.equal((await fetch(`${base}/leads/acme-crm/..%2F..%2Fetc%2Fpasswd`)).status, 403);
66
66
  assert.equal((await fetch(`${base}/leads/acme-crm/..%2Fleads.json.lock`)).status, 403);
67
67
  });
68
- test('static allowlist: leads.json, notes.md, rfp.md, brief.md -> 404; stats.mjs, vendor -> 200', async () => {
68
+ test('static allowlist: leads.json -> 404; lead-root docs, stats.mjs, vendor -> 200', async () => {
69
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);
70
+ assert.equal((await fetch(`${base}/leads/acme-crm/notes.md`)).status, 200);
71
+ assert.equal((await fetch(`${base}/leads/acme-crm/rfp.md`)).status, 200);
72
+ assert.equal((await fetch(`${base}/leads/acme-crm/brief.md`)).status, 200);
73
73
  assert.equal((await fetch(`${base}/scripts/stats.mjs`)).status, 200);
74
74
  assert.equal((await fetch(`${base}/scripts/vendor/reactflow-bundle.js`)).status, 200);
75
75
  });
76
+ test('lead-root docs: only doc extensions, only one path segment deep', async () => {
77
+ await writeFile(join(root, 'leads', 'acme-crm', 'script.mjs'), 'export {};\n');
78
+ assert.equal((await fetch(`${base}/leads/acme-crm/script.mjs`)).status, 404);
79
+ await mkdir(join(root, 'leads', 'acme-crm', 'docs'), { recursive: true });
80
+ await writeFile(join(root, 'leads', 'acme-crm', 'docs', 'nested.md'), 'nested\n');
81
+ assert.equal((await fetch(`${base}/leads/acme-crm/docs/nested.md`)).status, 404);
82
+ const md = await fetch(`${base}/leads/acme-crm/rfp.md`);
83
+ assert.equal(md.headers.get('content-type'), 'text/plain; charset=utf-8');
84
+ });
85
+ test('lead-root doc symlinked out of the root is rejected, not followed', async () => {
86
+ const outside = join(root, '..', 'outside-doc.md');
87
+ await writeFile(outside, 'top secret');
88
+ await symlink(outside, join(root, 'leads', 'acme-crm', 'leak.md'));
89
+ const res = await fetch(`${base}/leads/acme-crm/leak.md`);
90
+ assert.ok(res.status >= 400 && res.status < 500, `expected 4xx, got ${res.status}`);
91
+ await rm(outside, { force: true });
92
+ });
76
93
  test('static content-type and body are correct for allowlisted files', async () => {
77
94
  const stats = await fetch(`${base}/scripts/stats.mjs`);
78
95
  assert.equal(stats.headers.get('content-type'), 'text/javascript');
@@ -114,23 +131,10 @@ test('symlink inside dist/ escaping to leads.json is rejected, not the registry'
114
131
  assert.ok(res.status >= 400 && res.status < 500, `expected 4xx, got ${res.status}`);
115
132
  assert.doesNotMatch(await res.text(), /Beta Shop/);
116
133
  });
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
+ test('symlink inside dist/ to a lead-root doc serves 200 — those docs are allowlisted directly now', async () => {
135
+ await symlink(join(root, 'leads', 'acme-crm', 'rfp.md'), join(root, 'leads', 'acme-crm', 'dist', 'alias-rfp.md'));
136
+ const res = await fetch(`${base}/leads/acme-crm/dist/alias-rfp.md`);
137
+ assert.equal(res.status, 200);
134
138
  });
135
139
  test('symlinked directory inside dist/ cannot reach leads.json through it', async () => {
136
140
  await symlink(root, join(root, 'leads', 'acme-crm', 'dist', 'sub'));