@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
package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { inline, stripInline } from '../lib/md-inline.mjs';
|
|
4
|
+
|
|
5
|
+
// Every fact in an analyze-requirements set carries where it came from, and the four words
|
|
6
|
+
// are a closed vocabulary (validate-provenance.mjs). Written as `observed`, they
|
|
7
|
+
// rendered as <code> in accent teal — the same chip as `org_id` and
|
|
8
|
+
// `docker-compose.yml`, so the accent meant two unrelated things and the most
|
|
9
|
+
// repeated element in the document read as a snippet of code.
|
|
10
|
+
test('a provenance marker is its own element, not a code span', () => {
|
|
11
|
+
for (const word of ['observed', 'stated', 'researched', 'proposed']) {
|
|
12
|
+
const html = inline(`The value is bound. \`${word}\``);
|
|
13
|
+
assert.match(html, new RegExp(`<span class="prov" data-prov="${word}">${word}</span>`));
|
|
14
|
+
assert.doesNotMatch(html, /<code>/);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('a code span that is not a marker stays code', () => {
|
|
19
|
+
assert.match(inline('reads `org_id`'), /<code>org_id<\/code>/);
|
|
20
|
+
assert.match(inline('see `docker-compose.yml`'), /<code>docker-compose\.yml<\/code>/);
|
|
21
|
+
// Not a marker just because it contains one.
|
|
22
|
+
assert.match(inline('`observed_at`'), /<code>observed_at<\/code>/);
|
|
23
|
+
assert.match(inline('`the observed value`'), /<code>the observed value<\/code>/);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// The vocabulary is exact, so casing is not a licence to invent members.
|
|
27
|
+
test('the match is exact, not case-folded', () => {
|
|
28
|
+
assert.match(inline('`Observed`'), /<code>Observed<\/code>/);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('markers survive alongside other inline markup', () => {
|
|
32
|
+
const html = inline('**Bound**, never interpolated `observed` — see [ADR](x.md)');
|
|
33
|
+
assert.match(html, /<strong>Bound<\/strong>/);
|
|
34
|
+
assert.match(html, /data-prov="observed"/);
|
|
35
|
+
assert.match(html, /<a href="x\.md">ADR<\/a>/);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// The rail and the breadcrumb show heading text as plain text, and a marker is
|
|
39
|
+
// syntax there exactly like a code span is.
|
|
40
|
+
test('stripInline still drops the backticks', () => {
|
|
41
|
+
assert.equal(stripInline('a `observed` b'), 'a observed b');
|
|
42
|
+
});
|
package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { renderMarkdown } from '../lib/md-render.mjs';
|
|
4
|
+
|
|
5
|
+
test('renders headings with slug ids and collects them', () => {
|
|
6
|
+
const { html, headings } = renderMarkdown('## Core Components\ntext');
|
|
7
|
+
assert.match(html, /<h2 id="core-components">Core Components<\/h2>/);
|
|
8
|
+
assert.deepEqual(headings, [{ level: 2, text: 'Core Components', slug: 'core-components' }]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('renders tables, links, mermaid fences, likec4 markers', () => {
|
|
12
|
+
const md = '| A | src |\n|---|---|\n| x | observed |\n\n[adr](docs/adr/0001-sample.md)\n\n```mermaid\nerDiagram\n```\n\n<!-- likec4:view index -->';
|
|
13
|
+
const { html } = renderMarkdown(md);
|
|
14
|
+
assert.match(html, /<table>[\s\S]*<td>observed<\/td>/);
|
|
15
|
+
assert.match(html, /<a href="docs\/adr\/0001-sample.md">adr<\/a>/);
|
|
16
|
+
assert.match(html, /diagram-shell[\s\S]*mermaid-canvas/);
|
|
17
|
+
assert.match(html, /<c4-view view-id="index">/);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('strips frontmatter', () => {
|
|
21
|
+
const { html } = renderMarkdown('---\nname: x\n---\n## T');
|
|
22
|
+
assert.doesNotMatch(html, /name: x/);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('makes repeated heading ids unique within a document', () => {
|
|
26
|
+
const { html, headings } = renderMarkdown('## Consequences\n\n## Consequences');
|
|
27
|
+
assert.match(html, /<h2 id="consequences">/);
|
|
28
|
+
assert.match(html, /<h2 id="consequences-2">/);
|
|
29
|
+
assert.deepEqual(headings.map((h) => h.slug), ['consequences', 'consequences-2']);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('keeps heading ids unique across docs sharing a slug registry', () => {
|
|
33
|
+
const seen = new Map();
|
|
34
|
+
renderMarkdown('## Considered Options', seen);
|
|
35
|
+
const { headings } = renderMarkdown('## Considered Options', seen);
|
|
36
|
+
assert.equal(headings[0].slug, 'considered-options-2');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('renders a plain fenced block as preformatted code', () => {
|
|
40
|
+
const md = 'Tree:\n\n```\nroot/\n├── src/\n└── docs/\n```\n\nAfter.';
|
|
41
|
+
const { html } = renderMarkdown(md);
|
|
42
|
+
assert.match(html, /<pre><code>root\/\n├── src\/\n└── docs\/<\/code><\/pre>/);
|
|
43
|
+
assert.doesNotMatch(html, /``/);
|
|
44
|
+
assert.match(html, /<p>After\.<\/p>/);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('escapes html inside a plain fenced block', () => {
|
|
48
|
+
const { html } = renderMarkdown('```json\n{"a": "<b>"}\n```');
|
|
49
|
+
assert.match(html, /<pre><code>\{"a": "<b>"\}<\/code><\/pre>/);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('renders absolute-URL links with the href intact', () => {
|
|
53
|
+
const { html } = renderMarkdown('[Stripe](https://stripe.com/docs/api)');
|
|
54
|
+
assert.match(html, /<a href="https:\/\/stripe\.com\/docs\/api">Stripe<\/a>/);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('renders h4-h6 as real heading tags with no id', () => {
|
|
58
|
+
const { html, headings } = renderMarkdown('#### Deep\n\n##### Deeper\n\n###### Deepest');
|
|
59
|
+
assert.match(html, /<h4>Deep<\/h4>/);
|
|
60
|
+
assert.match(html, /<h5>Deeper<\/h5>/);
|
|
61
|
+
assert.match(html, /<h6>Deepest<\/h6>/);
|
|
62
|
+
assert.doesNotMatch(html, /<h4 id=/);
|
|
63
|
+
assert.deepEqual(headings, []);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('escapes a quote in a link target so it cannot break out of the href attribute', () => {
|
|
67
|
+
const { html } = renderMarkdown('[x](y"onclick="alert(1))');
|
|
68
|
+
assert.doesNotMatch(html, /"\s*onclick=/);
|
|
69
|
+
assert.match(html, /"/);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('h1 gets a doc-prefixed id and is reported as the page title', () => {
|
|
73
|
+
const { html, title, docId } = renderMarkdown('# Threat Model\n\n## Threats');
|
|
74
|
+
assert.match(html, /<h1 id="doc-threat-model"/);
|
|
75
|
+
assert.equal(title, 'Threat Model');
|
|
76
|
+
assert.equal(docId, 'doc-threat-model');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('doc ids use their own namespace so section slugs keep their numbering', () => {
|
|
80
|
+
const slugs = new Map();
|
|
81
|
+
const docSlugs = new Map();
|
|
82
|
+
renderMarkdown('# Related\n\n## Related', slugs, docSlugs);
|
|
83
|
+
const second = renderMarkdown('# Related\n\n## Related', slugs, docSlugs);
|
|
84
|
+
assert.equal(second.docId, 'doc-related-2');
|
|
85
|
+
assert.equal(second.headings[0].slug, 'related-2');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('a page with no h1 falls back to its first section for a title', () => {
|
|
89
|
+
const { title, docId } = renderMarkdown('## Only A Section');
|
|
90
|
+
assert.equal(title, 'Only A Section');
|
|
91
|
+
assert.equal(docId, null);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Lists had no shape of their own, so every "- item" fell through to the
|
|
95
|
+
// paragraph collector and a bulleted block came out as one run-on sentence with
|
|
96
|
+
// literal dashes in it. The real doc set has 268 bullets, 22 nested and 45
|
|
97
|
+
// numbered items — this was the largest reading defect in the body.
|
|
98
|
+
test('bullet lines become a list, not a run-on paragraph', () => {
|
|
99
|
+
const { html } = renderMarkdown('- one\n- two\n- three');
|
|
100
|
+
assert.match(html, /<ul><li>one<\/li><li>two<\/li><li>three<\/li><\/ul>/);
|
|
101
|
+
assert.doesNotMatch(html, /<p>- /);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('numbered lines become an ordered list', () => {
|
|
105
|
+
const { html } = renderMarkdown('1. first\n2. second');
|
|
106
|
+
assert.match(html, /<ol><li>first<\/li><li>second<\/li><\/ol>/);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('an indented bullet nests inside the item above it', () => {
|
|
110
|
+
const { html } = renderMarkdown('- parent\n - child\n- sibling');
|
|
111
|
+
assert.match(html, /<li>parent<ul><li>child<\/li><\/ul><\/li><li>sibling<\/li>/);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('inline markup still renders inside a list item', () => {
|
|
115
|
+
const { html } = renderMarkdown('- see `code` and **bold** and [a](b.md)');
|
|
116
|
+
assert.match(html, /<li>see <code>code<\/code> and <strong>bold<\/strong> and <a href="b\.md">a<\/a><\/li>/);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('a list ends where the prose resumes', () => {
|
|
120
|
+
const { html } = renderMarkdown('- item\n\nAfter the list.');
|
|
121
|
+
assert.match(html, /<\/ul>\n<p>After the list\.<\/p>/);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('a paragraph is not swallowed into a list that follows it', () => {
|
|
125
|
+
const { html } = renderMarkdown('Lead in:\n- item');
|
|
126
|
+
assert.match(html, /<p>Lead in:<\/p>\n<ul><li>item<\/li><\/ul>/);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// §4 Solution Strategy is specified as "≤5 bullets, each links an ADR"
|
|
130
|
+
// (references/writing.md), so its bullets are long enough to wrap in the source.
|
|
131
|
+
// A wrapped bullet used to end the list at the unmatched second line: the item
|
|
132
|
+
// closed, the continuation became an indented <p> carrying the ADR link on its
|
|
133
|
+
// own, and the next bullet opened a fresh <ul>. Five bullets rendered as five
|
|
134
|
+
// one-item lists interleaved with five stray paragraphs.
|
|
135
|
+
test('a wrapped bullet stays one list item', () => {
|
|
136
|
+
const { html } = renderMarkdown('- first line\n second line\n- next item');
|
|
137
|
+
assert.match(html, /<ul><li>first line second line<\/li><li>next item<\/li><\/ul>/);
|
|
138
|
+
assert.doesNotMatch(html, /<p>\s*second line/, 'the continuation broke out into a paragraph');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('a wrapped bullet keeps the link that lives on its second line', () => {
|
|
142
|
+
const { html } = renderMarkdown('- adopt event sourcing\n ([ADR 2](docs/adr/2.md))');
|
|
143
|
+
assert.match(html, /<li>adopt event sourcing \(<a href="docs\/adr\/2\.md">ADR 2<\/a>\)<\/li>/);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// The continuation rule only absorbs an indented second line: CommonMark's
|
|
147
|
+
// lazy continuation also allows an unindented one, which this renderer does
|
|
148
|
+
// not implement, because it needs no blank line before a paragraph and
|
|
149
|
+
// absorbing an unindented line would break the case above. Pinned here so
|
|
150
|
+
// the limit is a documented boundary rather than an accident.
|
|
151
|
+
test('an unindented line after a bullet stays its own paragraph', () => {
|
|
152
|
+
const { html } = renderMarkdown('- item\nnot indented\n- next');
|
|
153
|
+
assert.match(html, /<ul><li>item<\/li><\/ul>\n<p>not indented<\/p>\n<ul><li>next<\/li><\/ul>/);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// The continuation rule keys on indentation, so a block that follows a list
|
|
157
|
+
// without a blank line is still its own block. Absorbing it would flatten a
|
|
158
|
+
// table into the text of the bullet above it.
|
|
159
|
+
test('a table after a list is not absorbed into the last item', () => {
|
|
160
|
+
const { html } = renderMarkdown('- item\n| a | b |\n| --- | --- |\n| 1 | 2 |');
|
|
161
|
+
assert.match(html, /<\/ul>/);
|
|
162
|
+
assert.match(html, /<table>/);
|
|
163
|
+
assert.doesNotMatch(html, /<li>item \|/, 'the table was swallowed into the item');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// An indented marker under a bullet is a natural shape for §7's "2-4 dynamic
|
|
167
|
+
// views, named flows only": one flow named per bullet, its view embedded
|
|
168
|
+
// beneath. The continuation rule keyed on indentation alone would swallow it
|
|
169
|
+
// into the bullet's text, escape the comment, and silently drop the diagram.
|
|
170
|
+
test('an indented likec4 marker under a bullet still renders its diagram', () => {
|
|
171
|
+
const { html } = renderMarkdown('- checkout flow\n <!-- likec4:view checkout -->\n- refund flow');
|
|
172
|
+
assert.match(html, /<c4-view view-id="checkout">/);
|
|
173
|
+
assert.doesNotMatch(html, /likec4:view/, 'the marker was swallowed and escaped into the item');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// A two-column table whose right column runs to prose is a definition list
|
|
177
|
+
// wearing a table costume: 19 rows of hairline dividers where a card grid reads
|
|
178
|
+
// in one pass. Two columns of short values is real data and stays a table.
|
|
179
|
+
const defTable = (n, len) => ['| Term | Definition |', '|---|---|']
|
|
180
|
+
.concat(Array.from({ length: n }, (_, i) => `| T${i} | ${'x'.repeat(len)} |`))
|
|
181
|
+
.join('\n');
|
|
182
|
+
|
|
183
|
+
test('a two-column table of prose becomes a definition grid', () => {
|
|
184
|
+
const { html } = renderMarkdown(defTable(3, 90));
|
|
185
|
+
assert.match(html, /<dl class="def-grid">/);
|
|
186
|
+
assert.equal([...html.matchAll(/<dt>/g)].length, 3);
|
|
187
|
+
assert.match(html, /<dt>T0<\/dt><dd>x{90}<\/dd>/);
|
|
188
|
+
assert.doesNotMatch(html, /<table>/);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('a two-column table of short values stays a table', () => {
|
|
192
|
+
const { html } = renderMarkdown(defTable(3, 12));
|
|
193
|
+
assert.match(html, /<table>/);
|
|
194
|
+
assert.doesNotMatch(html, /def-grid/);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('a three-column table is always a table, however long its cells', () => {
|
|
198
|
+
const md = '| A | B | C |\n|---|---|---|\n| a | ' + 'x'.repeat(200) + ' | c |';
|
|
199
|
+
const { html } = renderMarkdown(md);
|
|
200
|
+
assert.match(html, /<table>/);
|
|
201
|
+
assert.doesNotMatch(html, /def-grid/);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('definition cells keep their inline markup', () => {
|
|
205
|
+
const md = '| Term | Definition |\n|---|---|\n| **T** | `code` ' + 'y'.repeat(80) + ' |';
|
|
206
|
+
const { html } = renderMarkdown(md);
|
|
207
|
+
assert.match(html, /<dt><strong>T<\/strong><\/dt>/);
|
|
208
|
+
assert.match(html, /<dd><code>code<\/code>/);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Four consecutive view markers are four zoom levels on one system — 1900px of
|
|
212
|
+
// stacked scroll where the reader cannot compare them. Markers with prose in
|
|
213
|
+
// between are separate scenarios and must stay separate.
|
|
214
|
+
test('consecutive view markers collapse into one tab group', () => {
|
|
215
|
+
const md = '<!-- likec4:view index -->\n\n<!-- likec4:view containers -->';
|
|
216
|
+
const { html } = renderMarkdown(md);
|
|
217
|
+
assert.match(html, /class="view-tabs"/);
|
|
218
|
+
assert.equal([...html.matchAll(/<c4-view /g)].length, 2);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('view markers separated by prose stay separate diagram shells', () => {
|
|
222
|
+
const md = '<!-- likec4:view a -->\n\nSome prose.\n\n<!-- likec4:view b -->';
|
|
223
|
+
const { html } = renderMarkdown(md);
|
|
224
|
+
assert.doesNotMatch(html, /view-tabs/);
|
|
225
|
+
assert.equal([...html.matchAll(/diagram-shell/g)].length, 2);
|
|
226
|
+
});
|
package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { parseTables } from '../lib/md-tables.mjs';
|
|
4
|
+
|
|
5
|
+
const MD = `## Core Components
|
|
6
|
+
|
|
7
|
+
| Component | Responsibility | src |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| api | serves REST | observed |
|
|
10
|
+
| worker | queue jobs | stated |
|
|
11
|
+
|
|
12
|
+
## External Integrations
|
|
13
|
+
|
|
14
|
+
| System | Method | src |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| stripe | REST | researched [1] |
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
test('parses tables with section, headers, rows', () => {
|
|
20
|
+
const tables = parseTables(MD);
|
|
21
|
+
assert.equal(tables.length, 2);
|
|
22
|
+
assert.equal(tables[0].section, 'Core Components');
|
|
23
|
+
assert.deepEqual(tables[0].headers, ['Component', 'Responsibility', 'src']);
|
|
24
|
+
assert.deepEqual(tables[0].rows[1], ['worker', 'queue jobs', 'stated']);
|
|
25
|
+
assert.equal(tables[1].section, 'External Integrations');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('returns empty array when no tables', () => {
|
|
29
|
+
assert.deepEqual(parseTables('# Title\nprose only'), []);
|
|
30
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { renderViewGroup, renderFlowTabs } from '../lib/md-views.mjs';
|
|
4
|
+
|
|
5
|
+
test('a single view renders as a bare diagram shell, with no tab chrome', () => {
|
|
6
|
+
const html = renderViewGroup(['deployment']);
|
|
7
|
+
assert.match(html, /<div class="diagram-shell"><c4-view view-id="deployment"><\/c4-view><\/div>/);
|
|
8
|
+
assert.doesNotMatch(html, /view-tabs/);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('several views render as one tab group', () => {
|
|
12
|
+
const html = renderViewGroup(['index', 'containers', 'components-api']);
|
|
13
|
+
assert.match(html, /class="view-tabs"/);
|
|
14
|
+
assert.equal([...html.matchAll(/role="tab"/g)].length, 3);
|
|
15
|
+
assert.equal([...html.matchAll(/role="tabpanel"/g)].length, 3);
|
|
16
|
+
assert.equal([...html.matchAll(/<c4-view /g)].length, 3);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('the first tab is selected and the rest are hidden', () => {
|
|
20
|
+
const html = renderViewGroup(['index', 'containers']);
|
|
21
|
+
assert.equal([...html.matchAll(/aria-selected="true"/g)].length, 1);
|
|
22
|
+
assert.equal([...html.matchAll(/<div class="view-panel" hidden/g)].length, 1);
|
|
23
|
+
assert.match(html, /aria-selected="true"[^>]*>index</);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('each panel is wired to its tab for screen readers', () => {
|
|
27
|
+
const html = renderViewGroup(['index', 'containers']);
|
|
28
|
+
assert.match(html, /id="tab-index"[^>]*aria-controls="panel-index"/);
|
|
29
|
+
assert.match(html, /id="panel-index"[^>]*aria-labelledby="tab-index"/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('view ids are escaped so a crafted id cannot break out of the attribute', () => {
|
|
33
|
+
const html = renderViewGroup(['a"><script>x</script>', 'b']);
|
|
34
|
+
assert.doesNotMatch(html, /<script>/);
|
|
35
|
+
assert.match(html, /"/);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/* ---------- flow tabs ---------- */
|
|
39
|
+
|
|
40
|
+
// Same tab chrome, but each panel carries the prose that explained its diagram.
|
|
41
|
+
// The tab is labelled with the flow's name, because `flow-oauth-login` is a view
|
|
42
|
+
// id and nobody reading chose it.
|
|
43
|
+
const FLOWS = [
|
|
44
|
+
{ id: 'flow-oauth-login', label: 'Google OAuth login', prose: '**Google OAuth login.** No secret in the browser.' },
|
|
45
|
+
{ id: 'flow-tenant-scoped-read', label: 'Tenant-scoped read', prose: '**Tenant-scoped read.** Re-derived per request.' },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
test('a flow group tabs on its labels, not its view ids', () => {
|
|
49
|
+
const html = renderFlowTabs(FLOWS);
|
|
50
|
+
assert.match(html, /class="view-tabs"/);
|
|
51
|
+
assert.match(html, /aria-selected="true"[^>]*>Google OAuth login</);
|
|
52
|
+
assert.doesNotMatch(html, />flow-oauth-login</);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('each panel holds its own prose above its own diagram', () => {
|
|
56
|
+
const html = renderFlowTabs(FLOWS);
|
|
57
|
+
const first = html.slice(html.indexOf('id="panel-flow-oauth-login"'), html.indexOf('id="panel-flow-tenant-scoped-read"'));
|
|
58
|
+
assert.match(first, /No secret in the browser/);
|
|
59
|
+
assert.match(first, /view-id="flow-oauth-login"/);
|
|
60
|
+
assert.doesNotMatch(first, /Re-derived per request/);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// The lead-in is already the tab label, so repeating it as bold text at the top of
|
|
64
|
+
// the panel says the same thing twice in two type sizes.
|
|
65
|
+
test('the lead-in is not repeated inside the panel it labels', () => {
|
|
66
|
+
const html = renderFlowTabs(FLOWS);
|
|
67
|
+
assert.doesNotMatch(html, /<strong>Google OAuth login/);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('a crafted label cannot break out of the panel', () => {
|
|
71
|
+
const html = renderFlowTabs([
|
|
72
|
+
{ id: 'a', label: '<script>x</script>', prose: '**a.** p' },
|
|
73
|
+
{ id: 'b', label: 'b', prose: '**b.** p' },
|
|
74
|
+
]);
|
|
75
|
+
assert.doesNotMatch(html, /<script>/);
|
|
76
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { isWideTable, isCrampedTable, renderWideCards } from '../lib/md-wide.mjs';
|
|
4
|
+
|
|
5
|
+
// §9 External Integrations is eight columns describing one integration. As a
|
|
6
|
+
// table that is a single row whose every cell wraps to four lines under a header
|
|
7
|
+
// nobody can scan across — the shape says "compare these" when there is nothing
|
|
8
|
+
// to compare. Turned sideways it is what it always was: a record with fields.
|
|
9
|
+
const H9 = ['Integration', 'Method', 'Auth and credential home', 'Failure mode',
|
|
10
|
+
'Rate limit / cost', 'Data leaving the boundary', 'Lock-in', 'src'];
|
|
11
|
+
const R9 = [['Google OAuth', 'HTTPS authorization-code flow', 'Client id from env',
|
|
12
|
+
'Login unavailable', 'No published quota', 'client id and scopes', 'Low', 'researched']];
|
|
13
|
+
|
|
14
|
+
test('a wide table with few rows is a record, not a comparison', () => {
|
|
15
|
+
assert.equal(isWideTable(H9, R9), true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// The threshold is both conditions, not either. A wide table with many rows is a
|
|
19
|
+
// real comparison and has to stay a table; a narrow one was never the problem.
|
|
20
|
+
test('a wide table with enough rows stays a table', () => {
|
|
21
|
+
const many = Array.from({ length: 6 }, () => R9[0]);
|
|
22
|
+
assert.equal(isWideTable(H9, many), false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('a narrow table stays a table however few rows it has', () => {
|
|
26
|
+
assert.equal(isWideTable(['ADR', 'Title', 'Status'], [['0001', 'x', 'Accepted']]), false);
|
|
27
|
+
assert.equal(isWideTable(['Term', 'Definition'], [['a', 'b']]), false);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('an empty table is not a record', () => {
|
|
31
|
+
assert.equal(isWideTable(H9, []), false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// The first column is the record's name, so it heads the card rather than
|
|
35
|
+
// becoming a field of it — a card titled "Integration: Google OAuth" reads as one
|
|
36
|
+
// field too many.
|
|
37
|
+
test('the first column titles the card and the rest are its fields', () => {
|
|
38
|
+
const html = renderWideCards(H9, R9);
|
|
39
|
+
assert.match(html, /class="rec-card"/);
|
|
40
|
+
assert.match(html, /class="rec-card__name">Google OAuth</);
|
|
41
|
+
assert.doesNotMatch(html, /<dt>Integration<\/dt>/);
|
|
42
|
+
assert.match(html, /<dt>Method<\/dt>/);
|
|
43
|
+
assert.match(html, /<dd>HTTPS authorization-code flow<\/dd>/);
|
|
44
|
+
assert.match(html, /<dt>Lock-in<\/dt>/);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('one card per row', () => {
|
|
48
|
+
const two = [R9[0], ['GitHub OAuth', 'b', 'c', 'd', 'e', 'f', 'g', 'h']];
|
|
49
|
+
const html = renderWideCards(H9, two);
|
|
50
|
+
assert.equal(html.match(/class="rec-card"/g).length, 2);
|
|
51
|
+
assert.match(html, /GitHub OAuth/);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Inline markup has to survive: §9's src column is a bracketed reference and the
|
|
55
|
+
// method column carries code spans.
|
|
56
|
+
test('cell markup is rendered, not escaped into the card', () => {
|
|
57
|
+
const html = renderWideCards(['Name', 'Detail'], [['x', 'reads `OAUTH_ID` from env']]);
|
|
58
|
+
assert.match(html, /<code>OAUTH_ID<\/code>/);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// A short row leaves the field missing rather than emitting an empty <dd> that
|
|
62
|
+
// looks like a documented blank.
|
|
63
|
+
test('a row shorter than its header skips the missing fields', () => {
|
|
64
|
+
const html = renderWideCards(['Name', 'A', 'B'], [['x', 'only-a']]);
|
|
65
|
+
assert.match(html, /<dt>A<\/dt>/);
|
|
66
|
+
assert.doesNotMatch(html, /<dt>B<\/dt>/);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// A wide table that keeps enough rows to stay a table still has to fit: §6 is
|
|
70
|
+
// eight columns of eight components, ~110px per column at the standard scale.
|
|
71
|
+
// The class is what earns it a tighter one.
|
|
72
|
+
test('a table wide enough to cramp its columns is marked for a tighter scale', () => {
|
|
73
|
+
assert.equal(isCrampedTable(['a', 'b', 'c', 'd', 'e', 'f', 'g']), true);
|
|
74
|
+
assert.equal(isCrampedTable(['a', 'b', 'c', 'd', 'e', 'f']), false);
|
|
75
|
+
assert.equal(isCrampedTable(['ADR', 'Title', 'Status']), false);
|
|
76
|
+
});
|