@deepseek-insight/dsi 0.5.18 → 0.5.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.agents/skills/dsi-adr/SKILL.md +121 -0
  2. package/.agents/skills/dsi-i18n-migrate/SKILL.md +87 -0
  3. package/.agents/skills/dsi-release/SKILL.md +175 -0
  4. package/.agents/skills/dsi-spcheck/SKILL.md +188 -0
  5. package/.agents/skills/dsi-spec/SKILL.md +310 -0
  6. package/.agents/skills/dsi-spec/references/mermaid-pattern.md +160 -0
  7. package/.agents/skills/dsi-spec/references/tasks-json-template.md +125 -0
  8. package/.agents/skills/dsi-task/SKILL.md +287 -0
  9. package/README.md +5 -23
  10. package/bin/dsi.mjs +67 -15
  11. package/bin/lib/mirror-skills.mjs +56 -0
  12. package/build/client/_app/immutable/assets/0.C4pk9RsQ.css +2 -0
  13. package/build/client/_app/immutable/assets/{2.GTtLKMiQ.css → 2.Da1CnqbG.css} +1 -1
  14. package/build/client/_app/immutable/chunks/BeeAmuEs.js +2 -0
  15. package/build/client/_app/immutable/chunks/BgF4MPCH.js +1 -0
  16. package/build/client/_app/immutable/chunks/{DWBqt9Io.js → Dv2f6AVG.js} +1 -1
  17. package/build/client/_app/immutable/chunks/h_AAZIXW.js +1 -0
  18. package/build/client/_app/immutable/entry/{app.CnWnvioB.js → app.C8CwtYTr.js} +2 -2
  19. package/build/client/_app/immutable/entry/start.CCr7WSxA.js +1 -0
  20. package/build/client/_app/immutable/nodes/{1.DdjrT3tT.js → 1.Dnl1P2aB.js} +1 -1
  21. package/build/client/_app/immutable/nodes/{2.o9KKAujP.js → 2.0fqLf_Nw.js} +81 -81
  22. package/build/client/_app/version.json +1 -1
  23. package/build/handler.js +4 -4
  24. package/build/index.js +4 -4
  25. package/build/server/chunks/chunks/{internal.js-DKO0SoY7.js → internal.js-BDS_h7zE.js} +2 -2
  26. package/build/server/chunks/chunks/{state.js-C7gJT4Un.js → state.js-eZmA7eF7.js} +2 -2
  27. package/build/server/chunks/entries/pages/{_error.svelte.js-C73uxSol.js → _error.svelte.js-DIRRk8AK.js} +3 -3
  28. package/build/server/chunks/entries/pages/{_page.svelte.js-C1cGitkt.js → _page.svelte.js-CYT_NWww.js} +3 -3
  29. package/build/server/chunks/{handler-CTOEBU52.js → handler-jvQdYpdY.js} +3 -3
  30. package/build/server/chunks/{index.js-Bifh9-nS.js → index.js-BGLJR092.js} +2 -2
  31. package/build/server/chunks/{manifest.js-Da5_i6lM.js → manifest.js-CIb6Wm5j.js} +5 -5
  32. package/build/server/chunks/nodes/{0.js-DIgCB7dX.js → 0.js-CQ3k21rg.js} +3 -3
  33. package/build/server/chunks/nodes/1.js-NI6SZ6un.js +9 -0
  34. package/build/server/chunks/nodes/{2.js-DXw1-iEf.js → 2.js-BG_HkTrm.js} +4 -4
  35. package/package.json +2 -1
  36. package/template/.dsi/prompts.sqlite +0 -0
  37. package/template/.dsi/prompts.sqlite-shm +0 -0
  38. package/template/.dsi/prompts.sqlite-wal +0 -0
  39. package/build/client/_app/immutable/assets/0.BQjO3ESU.css +0 -2
  40. package/build/client/_app/immutable/chunks/Bx7fD5zN.js +0 -2
  41. package/build/client/_app/immutable/chunks/CAZxZSEb.js +0 -1
  42. package/build/client/_app/immutable/chunks/DvLq-YzL.js +0 -1
  43. package/build/client/_app/immutable/entry/start.DrunaWOx.js +0 -1
  44. package/build/server/chunks/nodes/1.js-DPBXm0Gt.js +0 -9
  45. /package/build/client/_app/immutable/nodes/{0.B3qXb7lb.js → 0.VWq3h0rH.js} +0 -0
@@ -0,0 +1,310 @@
1
+ ---
2
+ name: "dsi-spec"
3
+ description: "Analyze a feature request, self-interrogate via Karpathy method, and generate PRD + tasks document. One trigger produces the full spec pipeline. Reserved keywor"
4
+ ---
5
+
6
+ # Feature Spec
7
+
8
+ One trigger → full spec pipeline. Analyze codebase, brainstorm internally via Karpathy 3-layer method, produce PRD + tasks document with execution checklists.
9
+
10
+ ## SYSTEM PROTOCOL: ARCHITECTURAL DECOMPOSITION ENGINE
11
+
12
+ When translating raw requirements into technical specifications, you must enforce a decoupled, event-driven architecture. Never define monolithic implementations. Every feature spec must be structured around three pillars:
13
+
14
+ ### 1. MODULE ISOLATION (Where it lives)
15
+ - Identify the primary execution boundary for the feature.
16
+ - Assign the logic to a single, dedicated functional module directory.
17
+ - Enforce a strict "one responsibility per module" rule.
18
+
19
+ ### 2. MODULE COMMUNICATION (How they interact)
20
+ - Map module interactions using a decoupled pattern appropriate to the project (event bus, pub/sub, message passing, dependency injection, middleware chain, hook registration, shared state, API contracts, etc.).
21
+ - Specify which modules emit events, which modules listen, and what data flows between them.
22
+ - Prohibit modules from directly calling each other's internal functions; cross-cutting concerns must route through a defined communication layer.
23
+ - If the project has a central orchestrator (main entry point, router, event bus host), document where module registration or wiring happens.
24
+
25
+ ### 3. CROSS-CUTTING COMPONENT UTILITIES (How it shares)
26
+ - Identify shared utility patterns (such as global state verification, global logging, or shared validation).
27
+ - Isolate these into a centralized "Shared Layer" to be imported by modules, maintaining strict DRY (Don't Repeat Yourself) compliance.
28
+
29
+ ### Enforcement Rules
30
+ - Every PRD section "Proposed Architecture" MUST include:
31
+ - A **Module Map** table: module name → directory → responsibility
32
+ - A **Module Communication Map** table: module → communication pattern → what it emits/listens to
33
+ - A **Shared Utilities Inventory**: utilities available to all modules
34
+ - Every Tasks.md wave MUST verify the module decomposition is physically correct (directory structure matches the logical design)
35
+ - Sequence diagrams in the PRD MUST show data/event flow between modules, not direct function calls
36
+
37
+ ---
38
+
39
+ ## When to Use
40
+
41
+ - User says `/feature-spec {feature description}` with a project path
42
+ - User says "spec out the WebSocket feature" or "I need a PRD for X"
43
+ - User provides a project path and asks to plan a feature
44
+
45
+ ### Step 0: No Params — Usage Guide
46
+
47
+ When the user sends `/feature-spec` with no arguments:
48
+
49
+ 1. Ask for the two required inputs:
50
+ - **Feature description** — what to build (one sentence is enough)
51
+ - **Project path** — the codebase root to analyze
52
+ 2. Reply with a usage guide — NOT execution
53
+
54
+ **Response format:**
55
+
56
+ ```
57
+ 📋 **Feature Spec** — No inputs specified. I need two things:
58
+
59
+ 1. **Feature description** — what you want to build
60
+ Example: "Add real-time WebSocket updates to openclaw-insight"
61
+
62
+ 2. **Project path** — the codebase root to analyze
63
+ Example: `~/openclaw-insight`
64
+
65
+ Usage: `/feature-spec {feature description} {project-path}`
66
+
67
+ Or just describe the feature and I'll ask which project if unclear.
68
+ ```
69
+
70
+ **Rules:**
71
+ - If only the feature is provided but no project path, check workspace context for the likely project — if unclear, ask
72
+ - If only the project path is provided, ask what feature to spec — don't guess
73
+ - Do NOT proceed to Step 1 (Codebase Analysis) until both inputs are confirmed
74
+
75
+ ## How It Works
76
+
77
+ This skill orchestrates three sub-steps internally. The user sees ONE checklist for the whole pipeline, not three separate checklists. This prevents attention degradation — the model carries one pipeline context, not three.
78
+
79
+ ```mermaid
80
+ flowchart LR
81
+ A["/feature-spec<br/>user request"] --> B["Phase 1:<br/>Codebase Analysis"]
82
+ B --> C["Phase 2:<br/>Karpathy Self-Interrogation<br/>3 layers, internal"]
83
+ C --> D["Phase 3:<br/>Generate Documents<br/>PRD + Tasks"]
84
+ D --> E["User reviews<br/>deliverables"]
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Step 0.5: Date Resolution ⛔ MANDATORY
90
+
91
+ Before constructing any date-prefixed filenames, resolve today's date via `date +%Y-%m-%d`. Store as `TODAY`. Never infer from context.
92
+ <!-- RCA: AI-Research/Troubleshoot/2026-06-18 - Wrong Date Prefix in yt-research Filename - RCA.md -->
93
+
94
+ ---
95
+
96
+ ## Step 1: Codebase Analysis
97
+
98
+ Understand the existing code before speculating about changes.
99
+
100
+ **What to do:**
101
+ 1. Read the project structure (package.json, src layout)
102
+ 2. Read the files the feature will touch or depend on
103
+ 3. Read existing tests (Playwright + unit)
104
+ 4. Identify the gap: what exists vs. what's needed
105
+ 5. Read any existing `dev/specs/` pages for prior context
106
+ 6. Verify each suspected behavioral gap with an executable probe before claiming it: write a throwaway test that imports the real module and asserts the promised behavior, run it, and cite the pass/fail output as gap evidence — then delete the probe file
107
+ - Place probes inside the project's vitest `include` glob (e.g. `tests/unit/_probe.test.ts`); paths outside it return "No test files found"
108
+ - Read DOM interaction state (highlight, aria-selected, caret, value) in ONE `evaluate()` pass; locator lists captured across re-renders go stale and report false regressions
109
+ - When a probe contradicts the source reading (the binding or logic visibly exists), re-probe with a cleaner instrument before recording the gap; if an already-recorded claim is falsified, correct the upstream doc with a retraction note and keep the clean probe only as a promoted regression spec
110
+ - When the request leaves a product decision the codebase cannot answer (which entity an action targets, what a named control actually does), ask the user with 2-3 concrete options via ask_user before writing any document; record the chosen option with its date in the Karpathy Layer 2 assumptions. Codebase facts go to probes; product semantics go to the user
111
+ - Done when every behavioral gap cites file/line evidence or probe output, no probe files remain in the tree, and every product ambiguity cites a recorded user decision
112
+
113
+ **Output to user:** Brief analysis summary (3-5 bullet points). NOT a document. Just enough to confirm the model understood the codebase correctly.
114
+
115
+ ---
116
+
117
+ ## Step 2: Karpathy Self-Interrogation (Internal)
118
+
119
+ Run the 3-layer Karpathy method **internally** — brainstorming with yourself, not interrogating the user. The user already gave the feature request; you fill in the gaps by reading the codebase.
120
+
121
+ ### Layer 1: Spec
122
+
123
+ Answer these questions from codebase evidence (not guessing):
124
+
125
+ 1. What is the real goal? (Surface task vs. deeper outcome)
126
+ 2. What decision does this feature drive?
127
+ 3. What is the success threshold? (Measurable, specific)
128
+ 4. What are the failure conditions?
129
+ 5. What existing alternatives exist? Why build this?
130
+ 6. What is IN scope and OUT of scope?
131
+ 7. Who is the user?
132
+ 8. What is the technical constraints?
133
+
134
+ ### Layer 2: Verifier
135
+
136
+ 1. What are the acceptance criteria per feature?
137
+ 2. What is the user acceptance test? (First thing they'd try)
138
+ 3. What existing feature is most likely to break? (Regression target)
139
+ 4. What are the edge cases?
140
+ 5. What assumptions are we making? Which are critical?
141
+ 6. What is the weakest point? (A senior engineer would question this)
142
+
143
+ ### Layer 3: Environment
144
+
145
+ 1. What persistent context does the AI need every session?
146
+ 2. What are the non-negotiable conventions?
147
+ 3. What is the workspace structure — including the **Module Map** (module → directory → responsibility)?
148
+ 4. What are the **Module Communication Map** entries (module → communication pattern → what it emits/listens to)?
149
+ 5. What lives in the **Shared Layer** (shared utilities, types, validators)?
150
+ 6. What files are off-limits to modify? What are the module boundary rules (no cross-module imports)?
151
+ 7. What verification automation exists?
152
+ 8. How does the project build and test?
153
+
154
+ **Output to user:** Nothing. This is internal brainstorming. The results go into the Karpathy context file and inform the documents.
155
+
156
+ ---
157
+
158
+ ## Step 3: Generate Documents
159
+
160
+ ### Document 1: PRD
161
+
162
+ Save to: `{project-path}/dev/specs/{TODAY} - {Feature Name}/PRD.md`
163
+
164
+ **Contents:**
165
+ 1. Current architecture — how it works today (with mermaid flowchart + sequence diagram)
166
+ 2. Gap analysis — why current approach falls short
167
+ 3. Proposed architecture — how it should work (with mermaid flowchart + sequence diagram)
168
+
169
+ **⚠️ Mermaid Syntax & Accessibility Rules — see `references/mermaid-pattern.md` for full details. Key rules:**
170
+ - **No `style` directives inside `sequenceDiagram` blocks** — causes parse error in Obsidian
171
+ - **No `#`, raw `>`, or colons inside mermaid message/label text** — causes parse error
172
+ - **No `&` multi-target syntax in flowchart arrows** — use separate arrow lines
173
+ - **No special chars (→, -, :, &, ", parens) in mindmap node text**
174
+ - **All flowchart `style` directives must use WCAG AA colors with `color:#fff`** — approved palette in reference file
175
+ - **Sequence diagrams are CONDITIONAL** — only when actors with message flows exist. Do NOT force for purely conceptual content.
176
+ - **Pre-save mermaid checklist (12 items)** in `references/mermaid-pattern.md` — verify before saving
177
+ 4. Feature analysis — how each existing feature connects to the new module
178
+ 5. Data flow diagrams — how data moves through the system
179
+ 6. Playwright test infrastructure — existing tests, what they cover, why they matter
180
+ <!-- RCA: AI-Research/Troubleshoot/2026-06-13 - Playwright omitted from PRD despite 6 existing test files -->
181
+
182
+ **Writing rule:** Every section must have a layman paragraph ("In plain terms: ...") before technical content.
183
+
184
+ ### Document 2: Tasks
185
+
186
+ Save to: `{project-path}/dev/specs/{TODAY} - {Feature Name}/Tasks.md`
187
+
188
+ **Contents:**
189
+ 1. Execution checklist — `⛔ Behavioral Commitments` as PUBLIC checklists (not private anti-patterns)
190
+ 2. Task summary — mermaid dependency graph
191
+ 3. Tasks by wave — dependency-ordered, each wave ships standalone value
192
+ 4. Per-wave execution checklist — template with behavioral commitments, sub-agent safety, completion gate
193
+ 5. **Unit test tasks — every code-writing task MUST have a paired test task** (e.g., if Task 1.1 adds a function, Task 1.1-T adds unit tests for it). Test tasks live in the same wave as the code they test.
194
+ 6. Playwright regression tasks — after each code-modifying wave
195
+ 7. Feature compatibility matrix — proving existing features survive each wave
196
+ 8. Risk register — known risks with mitigation
197
+ 9. Definition of Done — public checklist
198
+
199
+ **Twin rule:** Tasks.md is the *human* view. Every Tasks.md ships with a machine-readable twin `Tasks.json` (Document 4) rendered from the same internal model — never one without the other. The orchestration DB ingests the JSON directly; humans and AI executors read the Markdown.
200
+
201
+ ### Document 3: Karpathy Context
202
+
203
+ Save to: `{project-path}/dev/specs/{TODAY} - {Feature Name}/karpathy-context.md`
204
+
205
+ **Contents:** All 3 layers as structured markdown. This is the internal context file the task-executor loads when executing.
206
+
207
+ ### Document 4: Tasks Machine Twin (Tasks.json)
208
+
209
+ Save to: `{project-path}/dev/specs/{TODAY} - {Feature Name}/Tasks.json`
210
+
211
+ The binding machine contract — the orchestration register flow maps these keys one-to-one into SQLite. **Rules:**
212
+
213
+ - Rendered from the SAME internal model that renders Tasks.md — waves, task numbers, titles, and dependencies identical by construction
214
+ - Must pass every validation rule in `references/tasks-json-template.md` before saving
215
+ - `featureSlug` MUST equal the consumer's `deriveFeatureSlug(folderName)` — grep it from `src/lib/server/orchestration/tasks-json.ts` in openclaw-insight and replicate exactly in a one-off script before saving; never approximate with a hand-rolled regex. Algorithm: strip date prefix `^\d{4}-\d{2}-\d{2}[- ]*`, lowercase, collapse spaces/hyphens to one `-`, drop other non-alphanumerics, trim edge hyphens — internal hyphens survive ("2026-08-21 - DSI Honest Inspector POC-2" → `dsi-honest-inspector-poc-2`, not `...poc2`). Assert `featureSlug === derived` in the save verification and reuse the slug verbatim in Tasks.md board-post IDs
216
+ - Never hand-edit one twin without regenerating the other
217
+
218
+ **Full template, validation rules, and the JSON to SQLite field map:** `references/tasks-json-template.md`
219
+
220
+ ---
221
+
222
+ ## Step 4: Post-Save Verification ⛔ MANDATORY
223
+
224
+ Before declaring the pipeline complete, output the checklist to the user, then verify each item. Do NOT check silently.
225
+ <!-- RCA: AI-Research/Troubleshoot/2026-06-11 - ADDITIONAL_PAGES Three Generations Same Bug - RCA.md -->
226
+
227
+ ---
228
+
229
+ ## Pipeline Checklist — MANDATORY
230
+
231
+ This is the ONLY checklist output to the user. Declared at the start. Verified at the end.
232
+
233
+ ```
234
+ 📋 feature-spec: {feature name} — {project name}
235
+
236
+ [ ] 0.5 ⛔ Resolve today's date via `date +%Y-%m-%d` (store as TODAY)
237
+
238
+ Step 1: Codebase Analysis
239
+ [ ] 1.1 Project structure read (package.json, src/)
240
+ [ ] 1.2 Relevant source files analyzed
241
+ [ ] 1.3 Existing tests identified (Playwright + unit)
242
+ [ ] 1.4 Gap analysis confirmed with user (3-5 bullets)
243
+
244
+ Step 2: Karpathy Self-Interrogation (internal)
245
+ [ ] 2.1 Layer 1: Spec — answered from codebase evidence
246
+ [ ] 2.2 Layer 2: Verifier — acceptance criteria + edge cases
247
+ [ ] 2.3 Layer 3: Environment — conventions + guardrails
248
+ [ ] 2.4 Karpathy context saved to project docs
249
+
250
+ Step 3: Generate Documents
251
+ [ ] 3.1 PRD saved to project docs (mermaid diagrams included)
252
+ [ ] 3.2 Tasks saved to project docs (execution checklists included)
253
+ [ ] 3.3 Karpathy context saved to project docs
254
+ [ ] 3.4 Every code-writing task in Tasks.md has a paired unit test task
255
+ [ ] 3.5 Tasks.json saved beside Tasks.md — template-valid per references/tasks-json-template.md
256
+
257
+ Step 4: Post-Save Verification
258
+ [ ] 4.1 All 3 deliverable files exist on disk (verified via find)
259
+ [ ] 4.2 PRD contains ≥2 mermaid diagrams (flowchart + sequence)
260
+ [ ] 4.3 PRD contains Module Map, Module Communication Map, Shared Utilities Inventory
261
+ [ ] 4.4 Tasks contains directory structure verification per wave
262
+ [ ] 4.5 Tasks contains public behavioral commitments (not private anti-patterns)
263
+ [ ] 4.6 Tasks contains unit test tasks for every code-writing task
264
+ [ ] 4.7 All 3 deliverable files semantic coherence: re-read each document fully and grep for stale design terms — does the document contradict itself
265
+ [ ] 4.8 Tasks.json exists, parses via JSON.parse, and its wave and task counts match Tasks.md exactly
266
+
267
+ ⛔ Behavioral Commitments:
268
+ [ ] I will NOT skip mermaid diagrams in the PRD
269
+ [ ] I will NOT write internal anti-patterns — all rules are public checklists
270
+ [ ] I will NOT guess codebase details — I will read the actual files
271
+ [ ] I will NOT self-certify document quality — I will verify on disk
272
+ [ ] I will NOT produce monolithic specs — every PRD enforces module decomposition
273
+ [ ] I will generate a unit test task for every code-writing task in Tasks.md
274
+ [ ] I will NOT let Tasks.md and Tasks.json drift — both render from one internal model, saved together
275
+ [ ] I will verify all 3 deliverable files exist on disk before declaring done
276
+ [ ] I will verify all 3 deliverable files exist on disk before declaring done
277
+ [ ] I will re-output this checklist at each phase transition (Step 1→2, 2→3)
278
+ [ ] I will NOT go silent for 60+ seconds without a progress update
279
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
280
+ ```
281
+
282
+ ### Check-Off Rules
283
+
284
+ - **After each phase transition** (Step 1→2, Step 2→3, Step 3→4), re-output the checklist with `[✅]` for done, `[🔄]` for current, `[ ]` remaining
285
+ - **Before posting any checklist re-render, count its structure**: 5 step headers (0.5, 1, 2, 3, 4) and 22 numbered items (0.5 · 1.1–1.4 · 2.1–2.4 · 3.1–3.5 · 4.1–4.8), each exactly once, line numbers intact — hand-copied renders drop blocks and truncate numbers. Render again when the count is off; declare an already-posted blemish in that message and fix it on the next re-render
286
+ - **At pipeline completion**, output the final checklist: ALL `[✅]`, any `[❌]` for failures
287
+ - **Do NOT deliver without showing the final checklist**
288
+ <!-- RCA: AI-Research/LLMs Skip Mandatory Steps/001. LLMs Skip Mandatory Steps/002.The Visible checklist Pattern/2026-06-11 - The Visible Checklist Pattern - AI Research v1 - report.md -->
289
+
290
+ ---
291
+
292
+ ## How This Skill Connects to task-executor
293
+
294
+ After `/feature-spec` produces the deliverables, the user can run `/execute-tasks` to begin implementation. The task-executor skill loads the Karpathy context and tasks document produced by this skill.
295
+
296
+ ```mermaid
297
+ flowchart LR
298
+ A["/feature-spec"] --> B["PRD + Tasks.md + Tasks.json<br/>+ Karpathy context"]
299
+ B --> C["{project-path}/dev/specs/"]
300
+ C --> D["User reviews"]
301
+ D --> E["/execute-tasks {project-path}"]
302
+ E --> F["task-executor loads<br/>context + tasks from dev/"]
303
+ F --> G["Wave-by-wave<br/>implementation"]
304
+ ```
305
+
306
+ ## Attention-Degradation Protection
307
+
308
+ This skill stays SHORT. Phase 2 details reference the karpathy-method skill rather than copying its full content. Phase 3 references the task-executor skill rather than duplicating its checklists. Each skill carries its own context; this skill only orchestrates.
309
+
310
+ Reference: `AI Research/YT-Research/2026-06-22 - Why Long Instructions Make AI Dumber - Attention Degradation Science.md`
@@ -0,0 +1,160 @@
1
+ # Mermaid Diagram Pattern — Syntax, Accessibility & Error Prevention
2
+
3
+ Shared reference for ai-research and yt-research skills. Both skills produce Obsidian pages with mermaid diagrams. This file defines the rules for writing diagrams that render correctly and meet accessibility standards.
4
+
5
+ ---
6
+
7
+ ## ⛔ When Is a Sequence Diagram Required?
8
+
9
+ A `sequenceDiagram` is **conditionally mandatory** — only when the content involves actors with message flows.
10
+
11
+ ### Decision Rule
12
+
13
+ Ask: **Does this topic involve who-talks-to-whom?**
14
+
15
+ | Yes → Sequence Diagram REQUIRED | No → Single Diagram SUFFICES |
16
+ |---|---|
17
+ | Systems communicating (API calls, service-to-service) | Purely conceptual or statistical content |
18
+ | Agents interacting (user → tool → AI → output) | Historical timelines without actor messaging |
19
+ | Process flows between distinct participants | Comparison tables, feature lists |
20
+ | Request/response patterns | Taxonomy or hierarchy (use mindmap instead) |
21
+
22
+ **If no actors exist, do NOT force a sequence diagram.** A mindmap or flowchart alone is sufficient.
23
+
24
+ ### Mandatory Diagram Minimum
25
+
26
+ Every research page MUST include at least:
27
+ 1. **One mindmap** (for conceptual frameworks or topic hierarchies) — MANDATORY
28
+ 2. **One sequence diagram** — ONLY IF actors with message flows exist in the content
29
+ 3. **Additional diagrams** (flowchart, timeline) — optional, based on content
30
+
31
+ ---
32
+
33
+ ## Syntax Rules — Avoiding Parse Errors
34
+
35
+ ### Sequence Diagram Rules
36
+
37
+ | Rule | ❌ Breaks | ✅ Correct |
38
+ |---|---|---|
39
+ | No `style` directives | `style A fill:#4a90d9` inside sequenceDiagram → **PARSE ERROR** | Omit all styling from sequence diagrams. Mermaid does not support `style` in sequence context. |
40
+ | No `#` in message text | `A->>B: Skill #1 activates` → **PARSE ERROR** (treated as comment) | `A->>B: Skill 1 activates` |
41
+ | No raw `>` in messages | `A->>B: Source > Filters > Output` → **PARSE ERROR** (parsed as arrow) | `A->>B: Source to Filters to Output` |
42
+ | No `/` in messages (sometimes) | `A->>B: saved to docs/` → may break in some renderers | `A->>B: saved to docs folder` |
43
+ | No parentheses in messages (sometimes) | `A->>B: Verdict (Ship it)` → may break | `A->>B: Verdict — Ship it or Fix` |
44
+ | Commas in `Note over` are delimiters | `Note over A,B: Phase 1` → correct (comma separates participants) | Fine — this is valid syntax |
45
+ | Colons inside message text | `A->>B: Time: 12:00` → **PARSE ERROR** (colon ends the message) | `A->>B: Time is 12h00` |
46
+ | Apostrophes in messages | `A->>B: What's the question?` → may break | `A->>B: What is the question?` |
47
+
48
+ ### Flowchart Rules
49
+
50
+ | Rule | ❌ Breaks | ✅ Correct |
51
+ |---|---|---|
52
+ | `#` inside node labels | `A["Skill #1"]` → may break | `A["Skill 1"]` |
53
+ | `&` multi-target syntax | `D2 & D3 & D4 --> E` → breaks in some renderers | Separate arrow per node: `D2 --> E` then `D3 --> E` etc. |
54
+ | `style` IS valid in flowcharts | `style A fill:#4a90d9,color:#fff` → **works correctly** | Use freely in flowchart blocks. |
55
+ | `<br/>` for line breaks in nodes | `A["Line 1\nLine 2"]` → may not render | `A["Line 1<br/>Line 2"]` |
56
+ | Curlyly braces for decision nodes | `E{"Verdict?"}` → correct | Fine — this is valid syntax |
57
+ | Pipe in labels | `A["a|b"]` → may break (pipe is graph syntax) | `A["a or b"]` |
58
+
59
+ ### Mindmap Rules
60
+
61
+ | Rule | ❌ Breaks | ✅ Correct |
62
+ |---|---|---|
63
+ | No special chars in node text | `→`, `-`, `:`, `&`, `"` → **PARSE ERROR** | Use commas, spaces, `and` |
64
+ | No parentheses in nodes | `root((Topic (2026)))` → may break | `root((Topic 2026))` |
65
+ | No colons in nodes | `Key: Finding` → **PARSE ERROR** | `Key Finding` or `Key, Finding` |
66
+ | No ampersands | `R&D` → breaks | `R and D` |
67
+
68
+ ### General Mermaid Rules (All Diagram Types)
69
+
70
+ | Rule | Why |
71
+ |---|---|
72
+ | Always close code fences with ` ``` ` on its own line | Unclosed fences break the entire page |
73
+ | Use `autonumber` as first line in sequence diagrams | Adds step numbers for accessibility and reference |
74
+ | Keep participant aliases short (2-3 chars) | `participant SK as Stakeholder` not `participant StakeholderWithLongName as Stakeholder` |
75
+ | Test in Obsidian before declaring pipeline complete | Mermaid version differences across Obsidian/validate |
76
+
77
+ ---
78
+
79
+ ## Accessibility — Color Contrast (WCAG AA)
80
+
81
+ ### Approved Color Palette
82
+
83
+ All colors meet WCAG AA contrast ratio (≥ 4.5:1) with white text (`color:#fff`):
84
+
85
+ | Color | Hex | Use Case | Contrast vs White |
86
+ |---|---|---|---|
87
+ | Blue | `#4a90d9` | Entry/starting nodes, first phase | 4.57:1 ✅ |
88
+ | Orange | `#e67e22` | Process/skill activation | 4.80:1 ✅ |
89
+ | Green | `#27ae60` | Positive/feasible outcomes | 4.51:1 ✅ |
90
+ | Light Green | `#2ecc71` | Success confirmation | 3.27:1 ⚠️ (use only for large nodes) |
91
+ | Red | `#e74c3c` | Warnings, blocks, hard walls | 5.02:1 ✅ |
92
+ | Purple | `#9b59b6` | Analysis/output phases | 4.04:1 ⚠️ (borderline — use sparingly) |
93
+ | Dark Blue | `#2c3e50` | Terminal/done nodes | 13.84:1 ✅ |
94
+ | Amber | `#f39c12` | Conditional/warning outcomes | 4.07:1 ⚠️ (borderline) |
95
+ | Gray | `#95a5a6` | Passive participants (codebase, files) | 2.63:1 ❌ (use `#7f8c8d` instead, 4.31:1) |
96
+
97
+ ### Where Colors Apply
98
+
99
+ - **Flowcharts:** Use `style` directives freely. Always pair `fill` with `color:#fff`.
100
+ - **Sequence diagrams:** CANNOT use `style`. Colors are NOT applicable — rely on clear participant naming and `autonumber` instead.
101
+ - **Mindmaps:** CANNOT use `style`. Use node text clarity for differentiation.
102
+
103
+ ### Approved Pattern (Flowchart Only)
104
+
105
+ ```mermaid
106
+ flowchart TD
107
+ A["Start"] --> B["Process"]
108
+ B --> C["Decision"]
109
+ C -->|Yes| D["Done"]
110
+ C -->|No| B
111
+
112
+ style A fill:#4a90d9,color:#fff
113
+ style B fill:#e67e22,color:#fff
114
+ style C fill:#f39c12,color:#fff
115
+ style D fill:#27ae60,color:#fff
116
+ ```
117
+
118
+ ### Anti-Patterns
119
+
120
+ - ❌ `style A fill:#ffe066,color:#333` — yellow with dark text looks fine but fails in dark mode Obsidian
121
+ - ❌ `style A fill:#e74c3c` — red fill without specifying `color:#fff` defaults to dark text on red (fails contrast)
122
+ - ❌ Using colors inside sequence diagrams — Mermaid does not support this and will error
123
+ - ❌ Using more than 5-6 distinct colors — creates cognitive overload, not accessibility
124
+
125
+ ---
126
+
127
+ ## Pre-Save Mermaid Checklist
128
+
129
+ Before saving any Obsidian page, verify each diagram:
130
+
131
+ ```
132
+ 📋 Mermaid Checklist
133
+
134
+ [ ] 1. Code fence: opens with ```mermaid AND closes with ``` on separate line
135
+ [ ] 2. No `style` directives in sequenceDiagram blocks
136
+ [ ] 3. No `#` characters inside any mermaid block (use spaces or numbers)
137
+ [ ] 4. No raw `>` in message text (use "to" or "→" spelled out)
138
+ [ ] 5. No colons inside sequence message text after the label colon
139
+ [ ] 6. No `&` multi-target in flowchart arrows (use separate arrows)
140
+ [ ] 7. No special chars in mindmap nodes (→, -, :, &, ", parens)
141
+ [ ] 8. All flowchart `style` directives include both `fill` AND `color:#fff`
142
+ [ ] 9. Colors from approved palette only (WCAG AA compliant)
143
+ [ ] 10. Sequence diagrams use `autonumber` as first line
144
+ [ ] 11. At least 1 mindmap present (MANDATORY for all pages)
145
+ [ ] 12. Sequence diagram ONLY if actors with message flows exist
146
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Common Errors and Fixes
152
+
153
+ | Error Message | Likely Cause | Fix |
154
+ |---|---|---|
155
+ | `Parse error... Expecting 'NEWLINE'` | `style` inside sequenceDiagram | Remove all `style` lines from sequence blocks |
156
+ | `Parse error... got 'INVALID'` | Special char (`#`, `>`, `:`) in message text | Replace with plain text equivalent |
157
+ | Diagram shows as empty rectangle | Unclosed code fence | Ensure ` ``` ` on its own line closes the block |
158
+ | Node text disappears | `#` or `|` inside `["..."]` label | Remove `#`, replace `|` with `or` |
159
+ | Mindmap shows broken layout | Special chars in node text | Use only letters, numbers, commas, spaces |
160
+ | Flowchart arrows missing | `&` multi-target syntax | Use separate arrow lines for each target |
@@ -0,0 +1,125 @@
1
+ # Tasks.json Template — The Machine Twin Contract
2
+
3
+ Binding template for the `Tasks.json` file that ships beside every `Tasks.md`. The orchestration registration flow (`POST /api/orchestration/features`) maps these keys one-to-one into SQLite rows. If the JSON is missing, malformed, or contradicts the Markdown, **registration fails loudly at the door** — it never inserts half a feature.
4
+
5
+ This file is the single source of truth for the JSON shape. When the orchestration schema changes, this file changes with it.
6
+
7
+ ---
8
+
9
+ ## The Shape
10
+
11
+ ```json
12
+ {
13
+ "$schema": "openclaw-insight/tasks-twin/v1",
14
+ "featureName": "Orchestration Zoom Artifact Fix",
15
+ "featureSlug": "orchestration-zoom-artifact-fix",
16
+ "specPath": "dev/specs/2026-08-15 - Orchestration Zoom Artifact Fix",
17
+ "waves": [
18
+ {
19
+ "waveNumber": 1,
20
+ "name": "Geometry Fix + Unit Tests",
21
+ "tasks": [
22
+ {
23
+ "taskNumber": "1.1",
24
+ "title": "PanelsContainer viewport wrapper",
25
+ "description": "Wrap the .columns div in a .panels-viewport div...",
26
+ "assignedAgent": "app-dev",
27
+ "filesInvolved": ["src/lib/components/orchestration/PanelsContainer.svelte"],
28
+ "dependsOn": null
29
+ },
30
+ {
31
+ "taskNumber": "1.1-T",
32
+ "title": "Unit tests (PAIRED with 1.1)",
33
+ "description": "Host-pattern tests for the viewport wrapper...",
34
+ "assignedAgent": "app-dev",
35
+ "filesInvolved": ["tests/lib/components/orchestration/panels-container.test.ts"],
36
+ "dependsOn": "1.1"
37
+ }
38
+ ]
39
+ }
40
+ ]
41
+ }
42
+ ```
43
+
44
+ ## Field Rules
45
+
46
+ | Field | Type | Rule |
47
+ |---|---|---|
48
+ | `$schema` | string | **Required.** Literal `openclaw-insight/tasks-twin/v1` |
49
+ | `featureName` | string | **Required.** Display name |
50
+ | `featureSlug` | string | **Required.** Lowercase-hyphen ID. MUST equal the slug derived from the folder name (strip date prefix, lowercase, collapse spaces/hyphens, strip non-alphanumeric, trim hyphens — `deriveFeatureSlug`) |
51
+ | `specPath` | string | **Required.** The spec folder path used at registration |
52
+ | `waves[]` | array | **Required, at least 1 entry**, ordered by `waveNumber` |
53
+ | `waves[].waveNumber` | integer | **Required.** Sequential from 1 |
54
+ | `waves[].name` | string | **Required.** Human wave title |
55
+ | `waves[].tasks[]` | array | **Required, at least 1 task per wave** — an empty wave is a spec bug |
56
+ | `tasks[].taskNumber` | string | **Required.** Unique within the feature. Digits, dots, optional `-T` or letter suffix (`1.1`, `1.1-T`, `1.2a`) |
57
+ | `tasks[].title` | string | **Required.** Non-empty |
58
+ | `tasks[].description` | string | **Required.** Trimmed task body (Markdown allowed) |
59
+ | `tasks[].assignedAgent` | string | Optional, default `app-dev`. Agent ID the start endpoint builds the session key for |
60
+ | `tasks[].filesInvolved` | array of string or null | Optional. File paths touched by the task |
61
+ | `tasks[].dependsOn` | string or null | Optional. A `taskNumber` in the same feature — never a wave-scoped ID |
62
+
63
+ **Meta properties are forbidden.** No `phase`, `status`, `priority`, `notes`, or any other key. Status and runtime columns are owned by the database after insertion — spec files describe intent, the DB owns state.
64
+
65
+ ## JSON → SQLite Field Map
66
+
67
+ Registration is a key-for-key copy. Nothing is inferred, guessed, or re-derived from prose.
68
+
69
+ | Tasks.json key | SQLite column | Table |
70
+ |---|---|---|
71
+ | `featureSlug` | `id` | `features` |
72
+ | `featureName` | `name` | `features` |
73
+ | `specPath` | `spec_path` | `features` |
74
+ | — (insert literal) | `status` = `'ready'` | `features` |
75
+ | `waves[].waveNumber` | `wave_number` | `waves` |
76
+ | `waves[].name` | `name` | `waves` |
77
+ | — (insert literal) | `status` = `'ready'` | `waves` |
78
+ | `tasks[].taskNumber` | `task_number` | `tasks` |
79
+ | `tasks[].title` | `title` | `tasks` |
80
+ | `tasks[].description` | `description` | `tasks` |
81
+ | `tasks[].assignedAgent` | `assigned_agent` | `tasks` |
82
+ | `tasks[].filesInvolved` | `files_involved` (joined with `,`) | `tasks` |
83
+ | `tasks[].dependsOn` | `depends_on` | `tasks` |
84
+ | — (insert literal) | `status` = `'ready'` | `tasks` |
85
+
86
+ Composite IDs are built by the endpoint, not the spec: feature `id`, wave `{featureId}:w{n}`, task `{featureId}:w{n}:t{number with . and - replaced by _}`.
87
+
88
+ ## Validation at the Door
89
+
90
+ | Constraint | Rejection |
91
+ |---|---|
92
+ | `$schema` missing or unknown | 400 |
93
+ | Zero waves | 400 |
94
+ | Any wave with zero tasks | 400 |
95
+ | Zero tasks across the whole spec | 400 |
96
+ | Duplicate `taskNumber` within feature | 400 |
97
+ | `dependsOn` pointing at a missing `taskNumber` | 400 |
98
+ | `featureSlug` differs from folder-name slug | 400 |
99
+ | Feature slug already registered | 409 |
100
+
101
+ ## Registration Flow
102
+
103
+ ```mermaid
104
+ flowchart TD
105
+ A["POST /features<br/>with folderPath"] --> B{"Tasks.json<br/>present?"}
106
+ B -->|No| X1["400 — machine twin missing"]
107
+ B -->|Yes| C{"$schema is<br/>tasks-twin/v1?"}
108
+ C -->|No| X2["400 — unknown schema"]
109
+ C -->|Yes| D["Validate field rules<br/>waves, tasks, slug, deps"]
110
+ D -->|fail| X3["400 — with rule name"]
111
+ D -->|pass| E["Insert feature row<br/>keys map 1 to 1"]
112
+ E --> F["Insert wave rows"]
113
+ F --> G["Insert task rows<br/>dependsOn resolved"]
114
+ G --> H["201 — counts plus feature id"]
115
+
116
+ style A fill:#4a90d9,color:#fff
117
+ style H fill:#27ae60,color:#fff
118
+ style X1 fill:#e74c3c,color:#fff
119
+ style X2 fill:#e74c3c,color:#fff
120
+ style X3 fill:#e74c3c,color:#fff
121
+ ```
122
+
123
+ ## Why the slug MUST match the folder name
124
+
125
+ The registration identity is **the folder name**, and the feature slug is derived from it (`deriveFeatureSlug`). If `Tasks.json.featureSlug` disagrees with the folder-derived slug, the same spec would register under two identities (and one would never be re-registrable). Registration rejects the mismatch with 400 — one folder, one identity.