spatial-views 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +245 -2
- package/dist/app/assets/abnfDiagram-S7VZAUFO-CFbb_Sz2.js +1 -0
- package/dist/app/assets/architecture-WOLXFQ4H-CsBD__5a.js +1 -0
- package/dist/app/assets/architectureDiagram-YGSQEFNW-C0ic4ib1.js +36 -0
- package/dist/app/assets/blockDiagram-APKKGZFW-BZDPbzAG.js +140 -0
- package/dist/app/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
- package/dist/app/assets/c4Diagram-KJ2TOQU5-BilBWuq5.js +38 -0
- package/dist/app/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dist/app/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/dist/app/assets/chunk-6MUBBAK2-BBl-4tQr.js +2 -0
- package/dist/app/assets/chunk-AXFCVDMN-BhsttQ-k.js +62 -0
- package/dist/app/assets/chunk-BG4553SI-mWcPcFZr.js +127 -0
- package/dist/app/assets/chunk-DQASFODM-7FKe2gLt.js +10 -0
- package/dist/app/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
- package/dist/app/assets/chunk-HFQBQIA3-nXrQ08BL.js +1 -0
- package/dist/app/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
- package/dist/app/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dist/app/assets/chunk-KQLB2F66-swukhFmZ.js +2 -0
- package/dist/app/assets/chunk-KS47KZWR-DkDkwO82.js +1 -0
- package/dist/app/assets/chunk-LEVMRMFU-DXH6iXv3.js +1 -0
- package/dist/app/assets/chunk-M57EVK23-B-kEyOJF.js +1 -0
- package/dist/app/assets/chunk-NGNAAXSQ-DI_UYJZ4.js +136 -0
- package/dist/app/assets/chunk-OY52VR5R-DweG7qYw.js +88 -0
- package/dist/app/assets/chunk-QB3YPZ4I-DyozK3lV.js +213 -0
- package/dist/app/assets/chunk-R3KSYZAL-BEXCUN6J.js +1 -0
- package/dist/app/assets/chunk-STOXU5M4-BaTlty4O.js +72 -0
- package/dist/app/assets/chunk-TU62E6Q5-_rcUP1Fh.js +1 -0
- package/dist/app/assets/chunk-X3CZISLH-NOpCnvgE.js +1 -0
- package/dist/app/assets/chunk-X4PVCEUW-DGxTL3kB.js +1 -0
- package/dist/app/assets/chunk-XXDRQBXY-C02Gpej2.js +1 -0
- package/dist/app/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dist/app/assets/classDiagram-v2-L25IHNXF-DLEBwpvk.js +217 -0
- package/dist/app/assets/cose-bilkent-JH36ORCC-kNCXOm8k.js +1 -0
- package/dist/app/assets/cynefin-EF2NZ3EQ-6MWNLbuF.js +1 -0
- package/dist/app/assets/cynefinDiagram-L36ESFBY-CLFstukD.js +62 -0
- package/dist/app/assets/cytoscape.esm-nTrd5EVq.js +321 -0
- package/dist/app/assets/d3-scale-CaJQQYkF.js +1 -0
- package/dist/app/assets/dagre-SPEB5RXH-BaSAny1T.js +4 -0
- package/dist/app/assets/diagram-3B7GL73J-DJNlt5Sg.js +200 -0
- package/dist/app/assets/diagram-DNEMPZML-DEHeuILB.js +24 -0
- package/dist/app/assets/diagram-L3MUGCDN-ob5Ka2Xc.js +41 -0
- package/dist/app/assets/diagram-LA4NIPWU-DNESzFAc.js +24 -0
- package/dist/app/assets/diagram-MHCOC4E2-CVi9zKjG.js +3 -0
- package/dist/app/assets/diagram-XPFHEONP-DInT4C7e.js +30 -0
- package/dist/app/assets/dist-CjvHN74u.js +1 -0
- package/dist/app/assets/ebnfDiagram-UZSYDL2S-CRCZNsji.js +1 -0
- package/dist/app/assets/elk-XV6XMXQE-D4fsWI2l.js +2 -0
- package/dist/app/assets/erDiagram-EYBAPDEH-YQNM5StV.js +99 -0
- package/dist/app/assets/eventmodeling-K75KTNOO-Bev08J2F.js +1 -0
- package/dist/app/assets/flowDiagram-MALGAFMO-BhJ554DH.js +1 -0
- package/dist/app/assets/ganttDiagram-23REXITY-CkaBMYM4.js +292 -0
- package/dist/app/assets/gitGraph-VSP46ZUC-CtbZ0sIS.js +1 -0
- package/dist/app/assets/gitGraphDiagram-STJD7YCW-D15ZdQ-Z.js +106 -0
- package/dist/app/assets/graphlib-DS17s2tU.js +1 -0
- package/dist/app/assets/index-Bn6_wHEp.js +98 -0
- package/dist/app/assets/index-H-Z7MFhZ.css +1 -0
- package/dist/app/assets/info-OHQRW6UA-CfUW1XFR.js +1 -0
- package/dist/app/assets/infoDiagram-KBXO4MBG-DT7LbBRQ.js +2 -0
- package/dist/app/assets/ishikawaDiagram-M35NCXHK-CF51lhjB.js +70 -0
- package/dist/app/assets/journeyDiagram-OPLOXDXO-_36FonKk.js +139 -0
- package/dist/app/assets/kanban-definition-BZKZHSQY-tLk_OlQ-.js +89 -0
- package/dist/app/assets/katex-MEuSR36T.js +257 -0
- package/dist/app/assets/mermaid-parser.core-_3Vo8x6b.js +7 -0
- package/dist/app/assets/mermaid.core-y-x1CYxC.js +44 -0
- package/dist/app/assets/mindmap-definition-I2QAS2VK-BCI4HRX3.js +98 -0
- package/dist/app/assets/packet-JDAUHWVQ-Cco3UoaI.js +1 -0
- package/dist/app/assets/pegDiagram-FD4XPPHP-BOzSoNji.js +1 -0
- package/dist/app/assets/pie-XZMESJXO-reOB2GXn.js +1 -0
- package/dist/app/assets/pieDiagram-J4AKIIQI-PlHpwT_c.js +39 -0
- package/dist/app/assets/quadrantDiagram-XTYBLID2-CdxZ0ael.js +7 -0
- package/dist/app/assets/radar-ABXABTNO-DfCl8uV2.js +1 -0
- package/dist/app/assets/railroad-I3PHUGI6-4s14UyW1.js +1 -0
- package/dist/app/assets/railroad-abnf-LNEFI6M7-C49jJE4Y.js +1 -0
- package/dist/app/assets/railroad-ebnf-DWYD2UWJ-Bx-pcPc7.js +1 -0
- package/dist/app/assets/railroad-peg-JR7BVNR7-DjBPSCKV.js +1 -0
- package/dist/app/assets/railroadDiagram-MRQ6NCDL-wGcmIMqq.js +1 -0
- package/dist/app/assets/requirementDiagram-Y7LWUY3S-DprFI03z.js +84 -0
- package/dist/app/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/app/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/app/assets/sankeyDiagram-WGJFYUXA-DygYWLTR.js +40 -0
- package/dist/app/assets/sequenceDiagram-5NDRBG5M-BzIr2DBO.js +169 -0
- package/dist/app/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
- package/dist/app/assets/stateDiagram-v2-FJ4FJNEA-MGCqKnm_.js +291 -0
- package/dist/app/assets/swimlanes-UMQ2AFYF-CIEH82Zt.js +1 -0
- package/dist/app/assets/swimlanesDiagram-OMPLPG4O-YWNJjl0g.js +8 -0
- package/dist/app/assets/timeline-definition-SEUHKTQE-BGYSqup2.js +120 -0
- package/dist/app/assets/treeView-D4JQ5SDB-B39o1sJo.js +1 -0
- package/dist/app/assets/treemap-SAJKECNS-BoGxrUH4.js +1 -0
- package/dist/app/assets/usecaseDiagram-AFA6YXN4-dy6oVOke.js +328 -0
- package/dist/app/assets/vennDiagram-NNMJR3RB-CUyuhcAk.js +34 -0
- package/dist/app/assets/wardley-7MLQ67FV-sYPAvQ06.js +1 -0
- package/dist/app/assets/wardleyDiagram-S7YFUSEH-DYtxYUHe.js +78 -0
- package/dist/app/assets/xychartDiagram-GGNKY7IX-ClR06AlB.js +7 -0
- package/dist/app/index.html +14 -0
- package/dist/cli/index.js +338 -0
- package/dist/core/api.js +420 -0
- package/dist/core/approvals.js +426 -0
- package/dist/core/context.js +259 -0
- package/dist/core/diff.js +156 -0
- package/dist/core/docs.js +140 -0
- package/dist/core/doctor.js +152 -0
- package/dist/core/doctypes.js +79 -0
- package/dist/core/edit.js +130 -0
- package/dist/core/errors.js +3 -0
- package/dist/core/flags.js +13 -0
- package/dist/core/gaps.js +119 -0
- package/dist/core/heading.js +4 -0
- package/dist/core/history.js +50 -0
- package/dist/core/home.js +345 -0
- package/dist/core/lanes.js +134 -0
- package/dist/core/launch.js +34 -0
- package/dist/core/layout.js +362 -0
- package/dist/core/links.js +68 -0
- package/dist/core/mermaid.js +175 -0
- package/dist/core/newdoc.js +66 -0
- package/dist/core/open-folder.js +30 -0
- package/dist/core/openspec.js +120 -0
- package/dist/core/paths.js +90 -0
- package/dist/core/project.js +392 -0
- package/dist/core/resolve.js +35 -0
- package/dist/core/route.js +420 -0
- package/dist/core/scan.js +514 -0
- package/dist/core/schema.js +270 -0
- package/dist/core/scope.js +126 -0
- package/dist/core/setup.js +134 -0
- package/dist/core/skills.js +181 -0
- package/dist/core/storage/config.js +74 -0
- package/dist/core/storage/events.js +54 -0
- package/dist/core/storage/folder-watch.js +147 -0
- package/dist/core/storage/folder.js +469 -0
- package/dist/core/storage/index.js +8 -0
- package/dist/core/storage/local.js +22 -0
- package/dist/core/storage/migrate.js +48 -0
- package/dist/core/storage/postgres.js +290 -0
- package/dist/core/storage/types.js +101 -0
- package/dist/core/storage.js +589 -0
- package/dist/core/suggest.js +283 -0
- package/dist/core/tree.js +254 -0
- package/dist/core/types.js +583 -0
- package/dist/core/version.js +1 -0
- package/dist/core/versions.js +245 -0
- package/dist/core/watch.js +2 -0
- package/dist/core/xml.js +68 -0
- package/dist/demo/args.js +58 -0
- package/dist/demo/browser.js +301 -0
- package/dist/demo/platform.js +147 -0
- package/dist/demo/run.js +198 -0
- package/dist/demo/steps.js +328 -0
- package/dist/mcp/project-tools.js +193 -0
- package/dist/mcp/server.js +785 -0
- package/examples/platform/README.md +33 -0
- package/examples/platform/api/package.json +8 -0
- package/examples/platform/api/src/auth-middleware.js +16 -0
- package/examples/platform/api/src/proxy.js +7 -0
- package/examples/platform/api/src/rate-limit.js +13 -0
- package/examples/platform/api/src/server.js +40 -0
- package/examples/platform/auth/package.json +9 -0
- package/examples/platform/auth/src/server.js +24 -0
- package/examples/platform/auth/src/tokens.js +19 -0
- package/examples/platform/auth/src/users.js +16 -0
- package/examples/platform/docs/api/PRD.md +10 -0
- package/examples/platform/docs/api/SDD.md +15 -0
- package/examples/platform/docs/auth/PRD.md +10 -0
- package/examples/platform/docs/auth/SDD.md +8 -0
- package/examples/platform/docs/frontend/PRD.md +18 -0
- package/examples/platform/docs/frontend/SDD.md +13 -0
- package/examples/platform/docs/pricing/PRD.md +9 -0
- package/examples/platform/docs/pricing/SDD.md +8 -0
- package/examples/platform/docs/products/PRD.md +9 -0
- package/examples/platform/docs/products/SDD.md +8 -0
- package/examples/platform/frontend/package.json +8 -0
- package/examples/platform/frontend/src/api-client.js +21 -0
- package/examples/platform/frontend/src/main.js +21 -0
- package/examples/platform/frontend/src/pages/products.js +12 -0
- package/examples/platform/frontend/src/pages/sign-in.js +14 -0
- package/examples/platform/frontend/src/session.js +11 -0
- package/examples/platform/pricing/package.json +9 -0
- package/examples/platform/pricing/src/cache.js +19 -0
- package/examples/platform/pricing/src/product-events.js +17 -0
- package/examples/platform/pricing/src/rules.js +19 -0
- package/examples/platform/pricing/src/server.js +32 -0
- package/examples/platform/products/package.json +9 -0
- package/examples/platform/products/src/catalog.js +20 -0
- package/examples/platform/products/src/events.js +11 -0
- package/examples/platform/products/src/search.js +9 -0
- package/examples/platform/products/src/server.js +31 -0
- package/migrations/postgres/001_init.sql +55 -0
- package/migrations/postgres/002_view_versions.sql +18 -0
- package/package.json +69 -4
- package/schema/approval.schema.json +173 -0
- package/schema/gap.schema.json +56 -0
- package/schema/pins.schema.json +122 -0
- package/schema/project.schema.json +93 -0
- package/schema/settings.schema.json +86 -0
- package/schema/toolbox.schema.json +206 -0
- package/schema/type.schema.json +121 -0
- package/schema/view.schema.json +240 -0
- package/skills/claude/build-gap/SKILL.md +28 -0
- package/skills/claude/check-ui/SKILL.md +40 -0
- package/skills/claude/draw-system/SKILL.md +38 -0
- package/skills/claude/gap-from-view/SKILL.md +29 -0
- package/skills/claude/post-audit/SKILL.md +58 -0
- package/skills/claude/pre-audit/SKILL.md +82 -0
- package/skills/claude/update-state/SKILL.md +56 -0
- package/skills/cursor/check-ui.mdc +40 -0
- package/skills/cursor/draw-system.mdc +38 -0
- package/skills/cursor/post-audit.mdc +44 -0
- package/skills/cursor/pre-audit.mdc +49 -0
- package/skills/cursor/update-state.mdc +45 -0
- package/skills/windsurf/spatial-views.md +212 -0
- package/toolboxes/aws.yaml +43 -0
- package/toolboxes/azure.yaml +41 -0
- package/toolboxes/cloud.yaml +95 -0
- package/toolboxes/docs.yaml +111 -0
- package/toolboxes/software.yaml +114 -0
- package/toolboxes/types/docs/gap.yaml +15 -0
- package/toolboxes/types/docs/mdd.yaml +19 -0
- package/toolboxes/types/docs/plain.yaml +7 -0
- package/toolboxes/types/docs/prd.yaml +17 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What pre-audit draws for examples/platform (Direction, 22 Nov 2026): the
|
|
3
|
+
* System Overview (Frontend, API, Auth, Products, Pricing), one Sub View per
|
|
4
|
+
* area (3 to 6 typed modules, with file pointers), and each area's PRD and
|
|
5
|
+
* SDD pinned to its module. Nothing else: no lanes, no Gaps, no reports.
|
|
6
|
+
*
|
|
7
|
+
* The end-to-end test (test/demo-platform.test.ts), the screenshot test
|
|
8
|
+
* (test/ui/platform.spec.ts) and `spatial-views demo` all draw it through the
|
|
9
|
+
* MCP tools, as the Skill does.
|
|
10
|
+
*/
|
|
11
|
+
export const AREAS = [
|
|
12
|
+
{
|
|
13
|
+
id: "frontend",
|
|
14
|
+
name: "Frontend",
|
|
15
|
+
type: "frontend",
|
|
16
|
+
description: "The storefront: browse, search, a product's price, sign in.",
|
|
17
|
+
modules: [
|
|
18
|
+
{ name: "Shell and routing", type: "frontend", files: ["frontend:src/main.js"] },
|
|
19
|
+
{ name: "Product pages", type: "frontend", files: ["frontend:src/pages/products.js"] },
|
|
20
|
+
{ name: "Sign-in", type: "frontend", files: ["frontend:src/pages/sign-in.js"] },
|
|
21
|
+
{ name: "API client", type: "api", files: ["frontend:src/api-client.js"] },
|
|
22
|
+
{ name: "Session", type: "database", files: ["frontend:src/session.js"], properties: { engine: "Other", managed: false } },
|
|
23
|
+
],
|
|
24
|
+
connections: [
|
|
25
|
+
["Shell and routing", "Product pages", "/"],
|
|
26
|
+
["Shell and routing", "Sign-in", "/sign-in"],
|
|
27
|
+
["Product pages", "API client", "products, prices"],
|
|
28
|
+
["Sign-in", "API client", "login"],
|
|
29
|
+
["Sign-in", "Session", "token"],
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "api",
|
|
34
|
+
name: "API",
|
|
35
|
+
type: "api",
|
|
36
|
+
description: "The gateway: one front door; checks tokens, limits rates, forwards.",
|
|
37
|
+
modules: [
|
|
38
|
+
{ name: "Rate limiter", type: "service", files: ["api:src/rate-limit.js"] },
|
|
39
|
+
{ name: "Router", type: "api", files: ["api:src/server.js"] },
|
|
40
|
+
{ name: "Auth middleware", type: "auth", files: ["api:src/auth-middleware.js"] },
|
|
41
|
+
{ name: "Proxy", type: "service", files: ["api:src/proxy.js"] },
|
|
42
|
+
],
|
|
43
|
+
connections: [
|
|
44
|
+
["Rate limiter", "Router", "allowed"],
|
|
45
|
+
["Router", "Auth middleware", "POST /quotes"],
|
|
46
|
+
["Router", "Proxy", "forward"],
|
|
47
|
+
["Auth middleware", "Proxy", "token ok"],
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "auth",
|
|
52
|
+
name: "Auth",
|
|
53
|
+
type: "auth",
|
|
54
|
+
description: "Signs users in and issues short-lived tokens.",
|
|
55
|
+
modules: [
|
|
56
|
+
{ name: "Login handler", type: "api", files: ["auth:src/server.js"] },
|
|
57
|
+
{ name: "JWKS endpoint", type: "api", files: ["auth:src/server.js"] },
|
|
58
|
+
{ name: "Token service", type: "service", files: ["auth:src/tokens.js"] },
|
|
59
|
+
{ name: "Users DB", type: "database", files: ["auth:src/users.js"], properties: { engine: "PostgreSQL" } },
|
|
60
|
+
],
|
|
61
|
+
connections: [
|
|
62
|
+
["Login handler", "Users DB", "find user"],
|
|
63
|
+
["Login handler", "Token service", "issue"],
|
|
64
|
+
["JWKS endpoint", "Token service", "public keys"],
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "products",
|
|
69
|
+
name: "Products",
|
|
70
|
+
type: "service",
|
|
71
|
+
description: "The catalogue: list, search, and announce changes.",
|
|
72
|
+
modules: [
|
|
73
|
+
{ name: "Catalogue API", type: "api", files: ["products:src/server.js"] },
|
|
74
|
+
{ name: "Search", type: "service", files: ["products:src/search.js"] },
|
|
75
|
+
{ name: "Products DB", type: "database", files: ["products:src/catalog.js"], properties: { engine: "PostgreSQL" } },
|
|
76
|
+
{ name: "Change events", type: "queue", files: ["products:src/events.js"], properties: { kind: "Topic", broker: "RabbitMQ" } },
|
|
77
|
+
],
|
|
78
|
+
connections: [
|
|
79
|
+
["Catalogue API", "Search", "?q="],
|
|
80
|
+
["Catalogue API", "Products DB", "SQL"],
|
|
81
|
+
["Search", "Products DB", "full text"],
|
|
82
|
+
["Catalogue API", "Change events", "products.changed"],
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "pricing",
|
|
87
|
+
name: "Pricing",
|
|
88
|
+
type: "service",
|
|
89
|
+
description: "Prices and quotes, with discounts; never stale.",
|
|
90
|
+
modules: [
|
|
91
|
+
{ name: "Price API", type: "api", files: ["pricing:src/server.js"] },
|
|
92
|
+
{ name: "Rules engine", type: "service", files: ["pricing:src/rules.js"] },
|
|
93
|
+
{ name: "Price cache", type: "database", files: ["pricing:src/cache.js"], properties: { engine: "Redis" } },
|
|
94
|
+
{ name: "Product events", type: "queue", files: ["pricing:src/product-events.js"], properties: { broker: "RabbitMQ" } },
|
|
95
|
+
],
|
|
96
|
+
connections: [
|
|
97
|
+
["Price API", "Price cache", "price:id"],
|
|
98
|
+
["Price API", "Rules engine", "on a miss"],
|
|
99
|
+
["Product events", "Price cache", "forget"],
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
/** The System Overview's connections, between areas (by repo id). */
|
|
104
|
+
export const OVERVIEW = [
|
|
105
|
+
["frontend", "api", "https"],
|
|
106
|
+
["api", "auth", "login, JWKS"],
|
|
107
|
+
["api", "products", "/products"],
|
|
108
|
+
["api", "pricing", "/prices, /quotes"],
|
|
109
|
+
["products", "pricing", "products.changed"],
|
|
110
|
+
];
|
|
111
|
+
export const SOURCES = ["frontend", "api", "auth", "products", "pricing", "docs"];
|
|
112
|
+
/** Run one tool and fail loudly on a tool error. */
|
|
113
|
+
export async function must(call, tool, args = {}) {
|
|
114
|
+
const r = (await call(tool, args));
|
|
115
|
+
if (r && typeof r === "object" && r.isError)
|
|
116
|
+
throw new Error(`${tool} ${JSON.stringify(args)}: ${r.text}`);
|
|
117
|
+
return r;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* pre-audit's drawing, after the sources are added: type and name the System
|
|
121
|
+
* Overview's modules and connect them, one Sub View per area, and pin each
|
|
122
|
+
* area's PRD and SDD to its module.
|
|
123
|
+
*/
|
|
124
|
+
export async function drawPlatform(call, beat = async () => { }) {
|
|
125
|
+
for (const a of AREAS) {
|
|
126
|
+
await must(call, "update_module", { module: a.id, in_view: "system-overview", name: a.name, type: a.type, description: a.description });
|
|
127
|
+
await beat("module");
|
|
128
|
+
}
|
|
129
|
+
for (const [from, to, label] of OVERVIEW) {
|
|
130
|
+
await must(call, "connect", { view: "system-overview", from, to, ...(label ? { label } : {}) });
|
|
131
|
+
await beat("connection");
|
|
132
|
+
}
|
|
133
|
+
await beat("details");
|
|
134
|
+
for (const a of AREAS) {
|
|
135
|
+
const view = `${a.id}-view`;
|
|
136
|
+
await must(call, "create_view", { name: a.name, id: view, type: "sub-view", from_module: a.id, in_view: "system-overview" });
|
|
137
|
+
for (const m of a.modules)
|
|
138
|
+
await must(call, "add_module", { view, name: m.name, type: m.type, ...(m.properties ? { properties: m.properties } : {}) });
|
|
139
|
+
for (const [from, to, label] of a.connections)
|
|
140
|
+
await must(call, "connect", { view, from, to, ...(label ? { label } : {}) });
|
|
141
|
+
for (const m of a.modules)
|
|
142
|
+
for (const f of m.files)
|
|
143
|
+
await must(call, "add_file_pointer", { module: m.name, in_view: view, path: f });
|
|
144
|
+
for (const doc of ["PRD", "SDD"])
|
|
145
|
+
await must(call, "pin", { path: `docs:${a.id}/${doc}.md`, module: a.id, view: "system-overview" });
|
|
146
|
+
}
|
|
147
|
+
}
|
package/dist/demo/run.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { cp, mkdir, mkdtemp, readFile, rm, stat } from "node:fs/promises";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
9
|
+
import { UserError } from "../core/errors.js";
|
|
10
|
+
import { DEMO_USAGE, parseDemoArgs } from "./args.js";
|
|
11
|
+
import { Human, loadChromium, openWindow, Screen } from "./browser.js";
|
|
12
|
+
import { SOURCES } from "./platform.js";
|
|
13
|
+
import { OVERVIEW_ID, STEP_COUNT, steps } from "./steps.js";
|
|
14
|
+
/**
|
|
15
|
+
* `spatial-views demo`: the scripted demo, for recording. A throwaway home
|
|
16
|
+
* folder, the canvas on it, the repo's own MCP server over stdio as the AI,
|
|
17
|
+
* and a Chromium window driven by Playwright as the person. Everything runs on
|
|
18
|
+
* 127.0.0.1; nothing is fetched from the network.
|
|
19
|
+
*/
|
|
20
|
+
const EXAMPLES = fileURLToPath(new URL("../../examples/platform/", import.meta.url));
|
|
21
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
22
|
+
function freePort() {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const srv = createServer();
|
|
25
|
+
srv.unref();
|
|
26
|
+
srv.on("error", reject);
|
|
27
|
+
srv.listen(0, "127.0.0.1", () => {
|
|
28
|
+
const a = srv.address();
|
|
29
|
+
srv.close(() => (a && typeof a === "object" ? resolve(a.port) : reject(new Error("no free port"))));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** The environment both servers run with: the throwaway home, folder storage, no experimental features. */
|
|
34
|
+
export function demoEnv(home, env = process.env) {
|
|
35
|
+
const out = { ...env, SPATIAL_VIEWS_HOME: home };
|
|
36
|
+
for (const k of ["SPATIAL_VIEWS_STORAGE", "SPATIAL_VIEWS_DATABASE_URL", "SPATIAL_VIEWS_EXPERIMENTAL", "NODE_CHANNEL_FD", "NODE_CHANNEL_SERIALIZATION_MODE"])
|
|
37
|
+
delete out[k];
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/** examples/platform, copied out; each repo marked as one (a .git folder), so add_source sees a repo. */
|
|
41
|
+
export async function copyPlatform(to) {
|
|
42
|
+
await cp(EXAMPLES, to, { recursive: true });
|
|
43
|
+
for (const s of SOURCES)
|
|
44
|
+
if (s !== "docs")
|
|
45
|
+
await mkdir(join(to, s, ".git"), { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
/** A client for the canvas's local API. */
|
|
48
|
+
export function httpClient(base) {
|
|
49
|
+
return async (method, path, body) => {
|
|
50
|
+
const res = await fetch(base + path, {
|
|
51
|
+
method,
|
|
52
|
+
...(body !== undefined ? { headers: { "content-type": "application/json" }, body: JSON.stringify(body) } : {}),
|
|
53
|
+
});
|
|
54
|
+
const text = await res.text();
|
|
55
|
+
if (!res.ok)
|
|
56
|
+
throw new Error(`${method} ${path}: ${res.status} ${text}`);
|
|
57
|
+
return (text ? JSON.parse(text) : undefined);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** An MCP tool call that returns {isError, text}, like the tests' helpers. */
|
|
61
|
+
export function mcpCall(client) {
|
|
62
|
+
return async (name, args = {}) => {
|
|
63
|
+
const res = (await client.callTool({ name, arguments: args }));
|
|
64
|
+
return { isError: res.isError === true, text: res.content.map((c) => c.text).join("\n") };
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function waitForCanvas(base, child, err) {
|
|
68
|
+
for (let i = 0; i < 150; i++) {
|
|
69
|
+
if (child.exitCode !== null)
|
|
70
|
+
throw new Error(`the canvas stopped before it started:\n${err()}`);
|
|
71
|
+
if (await fetch(`${base}/api/projects`).then((r) => r.ok, () => false))
|
|
72
|
+
return;
|
|
73
|
+
await sleep(100);
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`the canvas did not start on ${base}:\n${err()}`);
|
|
76
|
+
}
|
|
77
|
+
/** Space (in the window or this terminal) or a timer: when to go on. */
|
|
78
|
+
class Advance {
|
|
79
|
+
opts;
|
|
80
|
+
screen;
|
|
81
|
+
resolve = null;
|
|
82
|
+
constructor(opts, screen) {
|
|
83
|
+
this.opts = opts;
|
|
84
|
+
this.screen = screen;
|
|
85
|
+
}
|
|
86
|
+
/** A space press, from the page or the terminal. Ignored unless something is waiting for it. */
|
|
87
|
+
fire() {
|
|
88
|
+
const r = this.resolve;
|
|
89
|
+
this.resolve = null;
|
|
90
|
+
r?.();
|
|
91
|
+
}
|
|
92
|
+
async next(label, ms = this.opts.delay) {
|
|
93
|
+
if (this.opts.auto) {
|
|
94
|
+
console.log(` ${label}`);
|
|
95
|
+
return sleep(ms);
|
|
96
|
+
}
|
|
97
|
+
console.log(` [space] ${label}`);
|
|
98
|
+
await this.screen()?.waiting(true);
|
|
99
|
+
await new Promise((r) => (this.resolve = r));
|
|
100
|
+
await this.screen()?.waiting(false);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export async function runDemo(argv, cli) {
|
|
104
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
105
|
+
console.log(DEMO_USAGE);
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
const opts = parseDemoArgs(argv, STEP_COUNT);
|
|
109
|
+
if (!(await stat(EXAMPLES).catch(() => null))?.isDirectory())
|
|
110
|
+
throw new UserError(`the demo's example platform is missing (${EXAMPLES})`);
|
|
111
|
+
// Fail before anything starts if the browser driver is not there.
|
|
112
|
+
await loadChromium();
|
|
113
|
+
const tmp = await mkdtemp(join(tmpdir(), "sv-demo-"));
|
|
114
|
+
const home = join(tmp, "home");
|
|
115
|
+
const disk = join(tmp, "platform");
|
|
116
|
+
// The app adds an example toolbox to a home with no toolboxes/ folder: make it, so the Toolbox stays as shipped.
|
|
117
|
+
await mkdir(join(home, "toolboxes"), { recursive: true });
|
|
118
|
+
await copyPlatform(disk);
|
|
119
|
+
const env = demoEnv(home);
|
|
120
|
+
const port = opts.port ?? (await freePort());
|
|
121
|
+
const base = `http://127.0.0.1:${port}`;
|
|
122
|
+
let canvas = null;
|
|
123
|
+
let ai = null;
|
|
124
|
+
let context = null;
|
|
125
|
+
let screen = null;
|
|
126
|
+
const advance = new Advance(opts, () => screen);
|
|
127
|
+
const tty = process.stdin.isTTY ? process.stdin : null;
|
|
128
|
+
let cleaning = null;
|
|
129
|
+
const cleanup = () => (cleaning ??= (async () => {
|
|
130
|
+
if (tty) {
|
|
131
|
+
tty.setRawMode(false);
|
|
132
|
+
tty.pause();
|
|
133
|
+
}
|
|
134
|
+
await context?.close().catch(() => undefined);
|
|
135
|
+
await ai?.close().catch(() => undefined);
|
|
136
|
+
canvas?.kill();
|
|
137
|
+
await rm(tmp, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 }).catch(() => undefined);
|
|
138
|
+
})());
|
|
139
|
+
const quit = (code) => void cleanup().finally(() => process.exit(code));
|
|
140
|
+
const onSignal = () => quit(130);
|
|
141
|
+
process.once("SIGINT", onSignal);
|
|
142
|
+
process.once("SIGTERM", onSignal);
|
|
143
|
+
if (tty) {
|
|
144
|
+
tty.setRawMode(true);
|
|
145
|
+
tty.resume();
|
|
146
|
+
tty.on("data", (b) => {
|
|
147
|
+
const k = b.toString();
|
|
148
|
+
if (k === "\u0003" || k === "q")
|
|
149
|
+
quit(130);
|
|
150
|
+
else if (k === " " || k === "\r" || k === "\n")
|
|
151
|
+
advance.fire();
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
let err = "";
|
|
156
|
+
canvas = spawn(process.execPath, [cli, "--port", String(port)], { env, cwd: home, stdio: ["ignore", "ignore", "pipe"] });
|
|
157
|
+
canvas.stderr?.on("data", (d) => (err = (err + d).slice(-4000)));
|
|
158
|
+
await waitForCanvas(base, canvas, () => err);
|
|
159
|
+
// The AI: the repo's own MCP server, global (no project until use_project), on the same home.
|
|
160
|
+
ai = new Client({ name: "claude-code", version: "1.0.0" });
|
|
161
|
+
await ai.connect(new StdioClientTransport({ command: process.execPath, args: [cli, "mcp", "--global"], env: env, cwd: home, stderr: "ignore" }));
|
|
162
|
+
const stage = { ai: mcpCall(ai), http: httpClient(base), disk };
|
|
163
|
+
const list = steps((rel) => readFile(join(disk, rel), "utf8"));
|
|
164
|
+
console.log(`Spatial Views demo on ${base} (a throwaway home: ${home})`);
|
|
165
|
+
for (let i = 0; i < opts.step - 1; i++)
|
|
166
|
+
await list[i].seed(stage);
|
|
167
|
+
if (opts.step > 1)
|
|
168
|
+
console.log(` ${opts.step === 2 ? "step 1" : `steps 1-${opts.step - 1}`} set up`);
|
|
169
|
+
const url = opts.step > 1 ? `${base}/#/view/${OVERVIEW_ID}` : `${base}/`;
|
|
170
|
+
const win = await openWindow(url, join(tmp, "browser"), opts.headless, () => advance.fire());
|
|
171
|
+
context = win.context;
|
|
172
|
+
const page = win.page;
|
|
173
|
+
// Closing the window ends the demo.
|
|
174
|
+
page.on("close", () => void (cleaning ?? quit(0)));
|
|
175
|
+
screen = new Screen(page, process.env.SV_SHOTS);
|
|
176
|
+
const human = new Human(page);
|
|
177
|
+
if (opts.step > 1)
|
|
178
|
+
await page.getByTestId("sv-crumbs").waitFor();
|
|
179
|
+
await human.place();
|
|
180
|
+
await screen.fit();
|
|
181
|
+
console.log(opts.auto ? `--auto: a step every ${opts.delay} ms` : "space (in the window or here) for the next step; q or Ctrl+C to stop");
|
|
182
|
+
for (let n = opts.step; n <= list.length; n++) {
|
|
183
|
+
const step = list[n - 1];
|
|
184
|
+
await advance.next(n === opts.step ? `ready: step ${n} of ${list.length}, ${step.title}` : `step ${n} of ${list.length}: ${step.title}`);
|
|
185
|
+
await screen.dismissToast();
|
|
186
|
+
await step.play(stage, { page, human, screen });
|
|
187
|
+
await screen.shot(`step-${n}`);
|
|
188
|
+
}
|
|
189
|
+
await screen.caption("");
|
|
190
|
+
await advance.next("done: space to close");
|
|
191
|
+
return 0;
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
process.off("SIGINT", onSignal);
|
|
195
|
+
process.off("SIGTERM", onSignal);
|
|
196
|
+
await cleanup();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { drawPlatform, must, SOURCES } from "./platform.js";
|
|
3
|
+
/**
|
|
4
|
+
* The demo, as a fixed list of steps. Each step can be played (on screen, at a
|
|
5
|
+
* person's pace: the AI's parts through the MCP server, the person's through
|
|
6
|
+
* Playwright) or seeded (its end state, at once, with no animation), so
|
|
7
|
+
* `--step N` seeds 1..N-1 and plays from N.
|
|
8
|
+
*/
|
|
9
|
+
export const PROJECT = "Platform";
|
|
10
|
+
export const PROJECT_SLUG = "platform";
|
|
11
|
+
export const OVERVIEW_ID = "system-overview";
|
|
12
|
+
/** The PRD the Docs step opens: the API gateway's, from examples/platform. */
|
|
13
|
+
export const PRD_TITLE = "API gateway";
|
|
14
|
+
const AI = "AI · over MCP";
|
|
15
|
+
const YOU = "You";
|
|
16
|
+
/** Parse the first text block of a tool reply as JSON. */
|
|
17
|
+
async function aiJson(s, tool, args = {}) {
|
|
18
|
+
const r = (await must(s.ai, tool, args));
|
|
19
|
+
return JSON.parse((r.text ?? "").split("\n(pending in Approvals")[0]);
|
|
20
|
+
}
|
|
21
|
+
const overview = (s) => s.http("GET", `/api/views/${OVERVIEW_ID}`);
|
|
22
|
+
const connection = (v, from, to) => v.connections.find((c) => c.from === from && c.to === to);
|
|
23
|
+
// ---- What each step does to the data (shared by play and seed) -------------------
|
|
24
|
+
/** pre-audit's first move: the project's sources. Each repo becomes a module on the System Overview. */
|
|
25
|
+
async function addSources(s, beat = async () => { }) {
|
|
26
|
+
await must(s.ai, "use_project", { project: PROJECT_SLUG });
|
|
27
|
+
for (const src of SOURCES) {
|
|
28
|
+
await must(s.ai, "add_source", { path: join(s.disk, src) });
|
|
29
|
+
await beat(src !== "docs");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** The person's edit, as the canvas would save it: Auth moved, a bend on Frontend to API, Products renamed. */
|
|
33
|
+
export function humanEdit(v) {
|
|
34
|
+
const next = structuredClone(v);
|
|
35
|
+
delete next.auto_layout;
|
|
36
|
+
const auth = next.modules.find((m) => m.id === "auth");
|
|
37
|
+
const api = next.modules.find((m) => m.id === "api");
|
|
38
|
+
if (auth)
|
|
39
|
+
auth.y += 60;
|
|
40
|
+
const products = next.modules.find((m) => m.id === "products");
|
|
41
|
+
if (products)
|
|
42
|
+
products.name = "Catalogue";
|
|
43
|
+
const frontend = next.modules.find((m) => m.id === "frontend");
|
|
44
|
+
const c = connection(next, "frontend", "api");
|
|
45
|
+
if (c && frontend && api)
|
|
46
|
+
c.bends = [{ x: Math.round(api.x + 160), y: Math.round((frontend.y + api.y) / 2) }];
|
|
47
|
+
return next;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The AI's amendment to the System Overview: a Notifications service (green),
|
|
51
|
+
* Auth renamed Identity (amber), the direct products feed to Pricing retired
|
|
52
|
+
* (red). The View has a person's Save on it, so every write waits in Approvals.
|
|
53
|
+
*/
|
|
54
|
+
async function propose(s, beat = async () => { }) {
|
|
55
|
+
await must(s.ai, "use_project", { project: PROJECT_SLUG });
|
|
56
|
+
await must(s.ai, "add_module", {
|
|
57
|
+
view: OVERVIEW_ID,
|
|
58
|
+
name: "Notifications",
|
|
59
|
+
type: "service",
|
|
60
|
+
description: "Tells a customer when their quote is ready.",
|
|
61
|
+
});
|
|
62
|
+
await beat();
|
|
63
|
+
await must(s.ai, "connect", { view: OVERVIEW_ID, from: "pricing", to: "Notifications", label: "quote ready" });
|
|
64
|
+
await beat();
|
|
65
|
+
await must(s.ai, "update_module", { module: "auth", in_view: OVERVIEW_ID, name: "Identity", description: "Sign-in, short-lived tokens and JWKS." });
|
|
66
|
+
await beat();
|
|
67
|
+
const v = await aiJson(s, "get_view", { view: OVERVIEW_ID, format: "json" });
|
|
68
|
+
const feed = connection(v, "products", "pricing");
|
|
69
|
+
if (feed)
|
|
70
|
+
await must(s.ai, "remove", { view: OVERVIEW_ID, connection: feed.id });
|
|
71
|
+
await beat();
|
|
72
|
+
}
|
|
73
|
+
const pendingApproval = async (s) => (await s.http("GET", "/api/approvals")).find((p) => p.status === "pending");
|
|
74
|
+
/**
|
|
75
|
+
* The PRD in the project's Specs (the Docs tree): made from the PRD template,
|
|
76
|
+
* as New PRD does, with the API gateway's PRD from examples/platform as its
|
|
77
|
+
* text. Set up rather than shown: MCP create_doc puts a home project's docs in
|
|
78
|
+
* its reports, which the Docs tree leaves out.
|
|
79
|
+
*/
|
|
80
|
+
export async function ensurePrd(s, readExample) {
|
|
81
|
+
const tree = await s.http("GET", "/api/tree");
|
|
82
|
+
const have = tree.items.find((i) => i.kind === "doc" && i.doc_type === "prd" && i.name.toLowerCase() === PRD_TITLE.toLowerCase());
|
|
83
|
+
if (have)
|
|
84
|
+
return have.ref;
|
|
85
|
+
const made = await s.http("POST", "/api/tree/new-doc", { type: "prd", title: PRD_TITLE });
|
|
86
|
+
const text = (await readExample("docs/api/PRD.md")).replace(/^# .*$/m, `# ${PRD_TITLE}`);
|
|
87
|
+
await s.http("PUT", `/api/doc?path=${encodeURIComponent(made.ref)}`, { text });
|
|
88
|
+
return made.ref;
|
|
89
|
+
}
|
|
90
|
+
/** The version to restore in step 7: the person's Save, from before the AI's change went live. */
|
|
91
|
+
async function restoreTarget(s) {
|
|
92
|
+
const rows = await s.http("GET", `/api/views/${OVERVIEW_ID}/versions`);
|
|
93
|
+
return rows.find((r) => r.by === "human") ?? rows[1];
|
|
94
|
+
}
|
|
95
|
+
// ---- On screen -------------------------------------------------------------------
|
|
96
|
+
const moduleNode = (page, name) => page.locator(".react-flow__node").filter({ has: page.getByText(name, { exact: true }) }).first();
|
|
97
|
+
/** A beat for the AI's drawing: let the change arrive, fit the View, hold. */
|
|
98
|
+
const settle = (show, hold) => async () => {
|
|
99
|
+
await show.human.pause(260);
|
|
100
|
+
await show.screen.fit();
|
|
101
|
+
await show.human.pause(hold);
|
|
102
|
+
};
|
|
103
|
+
/** A point along a connection's path (0: its start, 1: its end), on screen. */
|
|
104
|
+
async function edgePoint(page, id, at) {
|
|
105
|
+
return page.locator(`.react-flow__edge[data-id="${id}"] path.react-flow__edge-path`).first().evaluate((el, at) => {
|
|
106
|
+
// An SVG path (no DOM types on the Node side).
|
|
107
|
+
const path = el;
|
|
108
|
+
const p = path.getPointAtLength(path.getTotalLength() * at);
|
|
109
|
+
const m = path.getScreenCTM();
|
|
110
|
+
return { x: p.x * m.a + m.e, y: p.y * m.d + m.f };
|
|
111
|
+
}, at);
|
|
112
|
+
}
|
|
113
|
+
/** The bend handle nearest a point (a double-click can add more than one). */
|
|
114
|
+
async function nearestBend(page, p) {
|
|
115
|
+
const all = await page.getByTestId("sv-bend").all();
|
|
116
|
+
let best = null;
|
|
117
|
+
for (const [i, b] of all.entries()) {
|
|
118
|
+
const box = await b.boundingBox();
|
|
119
|
+
if (!box)
|
|
120
|
+
continue;
|
|
121
|
+
const d = Math.hypot(box.x + box.width / 2 - p.x, box.y + box.height / 2 - p.y);
|
|
122
|
+
if (!best || d < best.d)
|
|
123
|
+
best = { i, d };
|
|
124
|
+
}
|
|
125
|
+
return best ? all[best.i] : null;
|
|
126
|
+
}
|
|
127
|
+
export function steps(readExample) {
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
title: "Projects: an empty start, then a new project",
|
|
131
|
+
async seed(s) {
|
|
132
|
+
await s.http("POST", "/api/projects", { name: PROJECT });
|
|
133
|
+
},
|
|
134
|
+
async play(_s, { page, human, screen }) {
|
|
135
|
+
await screen.caption("A fresh install: no projects yet.", "Spatial Views");
|
|
136
|
+
await human.pause(1800);
|
|
137
|
+
await screen.caption("Start a project for the platform.", YOU);
|
|
138
|
+
await human.click(page.getByRole("textbox").first());
|
|
139
|
+
await human.type(PROJECT);
|
|
140
|
+
await human.pause(300);
|
|
141
|
+
await human.click(page.getByRole("button", { name: "Create" }));
|
|
142
|
+
await page.getByTestId("sv-crumbs").waitFor();
|
|
143
|
+
await human.pause(900);
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
title: "pre-audit draws the System Overview over MCP",
|
|
148
|
+
async seed(s) {
|
|
149
|
+
await addSources(s);
|
|
150
|
+
await drawPlatform(s.ai);
|
|
151
|
+
await must(s.ai, "record_audit", { kind: "pre-audit" });
|
|
152
|
+
},
|
|
153
|
+
async play(s, show) {
|
|
154
|
+
const { screen, human } = show;
|
|
155
|
+
await screen.caption("pre-audit reads the platform's five repos, and adds each one as a module.", AI);
|
|
156
|
+
await human.pause(900);
|
|
157
|
+
await addSources(s, async (repo) => {
|
|
158
|
+
if (repo)
|
|
159
|
+
await settle(show, 650)();
|
|
160
|
+
});
|
|
161
|
+
await screen.caption("It names and types each module, then connects them: the System Overview.", AI);
|
|
162
|
+
await human.pause(600);
|
|
163
|
+
let said = false;
|
|
164
|
+
await drawPlatform(s.ai, async (kind) => {
|
|
165
|
+
if (kind === "details") {
|
|
166
|
+
if (!said)
|
|
167
|
+
await screen.caption("Then a Sub View for each area, with its PRD and SDD pinned.", AI);
|
|
168
|
+
said = true;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
await settle(show, kind === "module" ? 450 : 650)();
|
|
172
|
+
});
|
|
173
|
+
await must(s.ai, "record_audit", { kind: "pre-audit" });
|
|
174
|
+
await settle(show, 1400)();
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
title: "Drill into the API, then back",
|
|
179
|
+
async seed() { },
|
|
180
|
+
async play(_s, { page, human, screen }) {
|
|
181
|
+
await screen.caption("Double-click a module to go into its Sub View.", YOU);
|
|
182
|
+
await human.dblclick(moduleNode(page, "API"));
|
|
183
|
+
await page.getByTestId("sv-crumbs").getByText("API", { exact: true }).waitFor();
|
|
184
|
+
await human.pause(600);
|
|
185
|
+
await screen.fit();
|
|
186
|
+
await human.pause(2600);
|
|
187
|
+
await screen.caption("And back up to the System Overview.", YOU);
|
|
188
|
+
await human.click(page.getByTestId("sv-crumbs").getByRole("button", { name: "System Overview" }));
|
|
189
|
+
await moduleNode(page, "Frontend").waitFor();
|
|
190
|
+
await human.pause(1200);
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
title: "A person's edit: drag, bend, rename, Save",
|
|
195
|
+
async seed(s) {
|
|
196
|
+
await s.http("PUT", `/api/views/${OVERVIEW_ID}`, humanEdit(await overview(s)));
|
|
197
|
+
},
|
|
198
|
+
async play(s, { page, human, screen }) {
|
|
199
|
+
await screen.caption("Arrange it by hand: drag a module…", YOU);
|
|
200
|
+
await human.pause(500);
|
|
201
|
+
await human.drag(moduleNode(page, "Auth"), { x: -40, y: 90 }, { dx: 30 });
|
|
202
|
+
await human.pause(700);
|
|
203
|
+
await screen.shot("step-4a-dragged");
|
|
204
|
+
await screen.caption("…double-click a connection to bend it, and drag the bend…", YOU);
|
|
205
|
+
const c = connection(await overview(s), "frontend", "api");
|
|
206
|
+
if (c) {
|
|
207
|
+
// A third of the way down, clear of the label.
|
|
208
|
+
const at = await edgePoint(page, c.id, 0.3);
|
|
209
|
+
await human.dblclick(at);
|
|
210
|
+
if (!(await page.getByTestId("sv-bend").count()))
|
|
211
|
+
await human.click(at);
|
|
212
|
+
const bend = await nearestBend(page, at);
|
|
213
|
+
if (bend)
|
|
214
|
+
await human.drag(bend, { x: 160, y: 0 });
|
|
215
|
+
await human.pause(500);
|
|
216
|
+
await screen.shot("step-4b-bend");
|
|
217
|
+
// Let go of the connection, so its Properties close.
|
|
218
|
+
await human.click({ x: 260, y: 200 });
|
|
219
|
+
}
|
|
220
|
+
await human.pause(500);
|
|
221
|
+
await screen.caption("…rename a module, and Save.", YOU);
|
|
222
|
+
await human.click(moduleNode(page, "Products"), { dx: 40 });
|
|
223
|
+
const name = page.getByTestId("sv-prop-name");
|
|
224
|
+
await human.click(name);
|
|
225
|
+
await human.press("Control+a");
|
|
226
|
+
await human.type("Catalogue");
|
|
227
|
+
await human.press("Enter");
|
|
228
|
+
await human.pause(600);
|
|
229
|
+
await screen.shot("step-4c-renamed");
|
|
230
|
+
await human.click(page.getByTestId("sv-save"));
|
|
231
|
+
await page.getByTestId("sv-unsaved").waitFor({ state: "hidden" });
|
|
232
|
+
await human.click({ x: 260, y: 200 });
|
|
233
|
+
await human.pause(1200);
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
title: "The AI amends the View; Approvals; Approve",
|
|
238
|
+
async seed(s) {
|
|
239
|
+
await propose(s);
|
|
240
|
+
const p = await pendingApproval(s);
|
|
241
|
+
if (p)
|
|
242
|
+
await s.http("POST", `/api/approvals/${encodeURIComponent(p.id)}/approve`, {});
|
|
243
|
+
},
|
|
244
|
+
async play(s, show) {
|
|
245
|
+
const { page, human, screen } = show;
|
|
246
|
+
await screen.caption("The AI proposes a change. It waits for a person to approve it.", AI);
|
|
247
|
+
await human.pause(900);
|
|
248
|
+
await propose(s, settle(show, 900));
|
|
249
|
+
await human.pause(800);
|
|
250
|
+
await screen.shot("step-5a-proposed");
|
|
251
|
+
await screen.dismissToast();
|
|
252
|
+
await screen.caption("Approvals: green added, amber amended, red removed.", YOU);
|
|
253
|
+
await human.click(page.getByRole("button", { name: /^Approvals/ }));
|
|
254
|
+
await page.getByTestId("sv-review").waitFor();
|
|
255
|
+
await human.pause(1800);
|
|
256
|
+
await screen.shot("step-5b-review");
|
|
257
|
+
const amended = page.getByTestId("sv-diff-after").locator('.sv-module[data-diff="amended"]').first();
|
|
258
|
+
if (await amended.count()) {
|
|
259
|
+
await human.click(amended);
|
|
260
|
+
await human.pause(1800);
|
|
261
|
+
await screen.shot("step-5c-amended");
|
|
262
|
+
}
|
|
263
|
+
await screen.caption("Approve, and it goes live.", YOU);
|
|
264
|
+
await human.click(page.getByRole("button", { name: /^Approve( all)?$/ }).first());
|
|
265
|
+
await page.getByTestId("sv-approval-status").getByText("approved").waitFor();
|
|
266
|
+
await human.pause(1200);
|
|
267
|
+
await human.click(page.getByRole("button", { name: "Close approvals", exact: true }));
|
|
268
|
+
await moduleNode(page, "Notifications").waitFor();
|
|
269
|
+
await screen.dismissToast();
|
|
270
|
+
await screen.fit();
|
|
271
|
+
await human.pause(1600);
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
title: "The Docs tree: open a PRD",
|
|
276
|
+
async seed(s) {
|
|
277
|
+
await ensurePrd(s, readExample);
|
|
278
|
+
},
|
|
279
|
+
async play(s, { page, human, screen }) {
|
|
280
|
+
const ref = await ensurePrd(s, readExample);
|
|
281
|
+
await screen.caption("The Docs tree: the project's specs, beside the picture.", YOU);
|
|
282
|
+
await human.click(page.getByTestId("sv-rbar-docs"));
|
|
283
|
+
const item = page.getByTestId("sv-docs-tree").locator(`[data-testid="sv-tree-item"][data-ref="${ref}"]`);
|
|
284
|
+
await item.waitFor();
|
|
285
|
+
await human.pause(900);
|
|
286
|
+
await screen.caption("Open the API gateway's PRD.", YOU);
|
|
287
|
+
await human.click(item.locator(".sv-tree-open").first());
|
|
288
|
+
await page.getByTestId("sv-doc-editor").waitFor();
|
|
289
|
+
await human.pause(1400);
|
|
290
|
+
await screen.shot("step-6a-prd");
|
|
291
|
+
await screen.caption("Close it, and the picture has the room again.", YOU);
|
|
292
|
+
await human.click(page.getByRole("button", { name: "Close the doc", exact: true }));
|
|
293
|
+
await human.click(page.getByRole("button", { name: "Close the Docs panel", exact: true }));
|
|
294
|
+
await human.pause(600);
|
|
295
|
+
await screen.fit();
|
|
296
|
+
await human.pause(1200);
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
title: "Version history, then restore",
|
|
301
|
+
async seed() { },
|
|
302
|
+
async play(s, { page, human, screen }) {
|
|
303
|
+
await screen.caption("Every save is a version. Open the View's history…", YOU);
|
|
304
|
+
await human.pause(500);
|
|
305
|
+
await human.click(page.getByTestId("sv-view-menu-btn"));
|
|
306
|
+
await human.click(page.getByTestId("sv-view-menu").getByRole("menuitem", { name: "Version history" }));
|
|
307
|
+
await page.getByTestId("sv-versions").waitFor();
|
|
308
|
+
await human.pause(1200);
|
|
309
|
+
await screen.shot("step-7a-history");
|
|
310
|
+
const target = await restoreTarget(s);
|
|
311
|
+
if (!target)
|
|
312
|
+
return;
|
|
313
|
+
await screen.caption("…preview the one from before the AI's change…", YOU);
|
|
314
|
+
await human.click(page.getByTestId(`sv-version-${target.n}`).locator(".sv-version-pick"));
|
|
315
|
+
await page.getByTestId("sv-version-canvas").waitFor();
|
|
316
|
+
await human.pause(2600);
|
|
317
|
+
await screen.shot("step-7b-preview");
|
|
318
|
+
await screen.caption("…and restore it. It comes back as a new version: nothing is lost.", YOU);
|
|
319
|
+
await human.click(page.getByTestId("sv-version-restore"));
|
|
320
|
+
await page.getByTestId("sv-version-preview").waitFor({ state: "hidden" });
|
|
321
|
+
await screen.fit();
|
|
322
|
+
await human.pause(2400);
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
];
|
|
326
|
+
}
|
|
327
|
+
/** How many steps there are (for --step), without building them. */
|
|
328
|
+
export const STEP_COUNT = 7;
|