magic-spec 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.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Workflow for creating and managing the implementation plan.
3
+ ---
4
+
5
+ # Plan Workflow
6
+
7
+ **Triggers:** *"Create plan"*, *"Generate plan"*, *"Update plan"*, *"Reprioritize"*
8
+ **Scope:** Prioritization, phasing, dependency analysis, and implementation order.
9
+ Specification authoring is handled by `specification.md`.
10
+
11
+ > **Full implementation:** `.magic/plan.md`
12
+ > Read that file before proceeding. Do not execute any steps until it is read.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Workflow for analyzing SDD usage and generating improvement recommendations.
3
+ ---
4
+
5
+ # Retrospective Workflow
6
+
7
+ **Triggers:** *"Run retrospective"*, *"Analyze SDD"*, *"SDD health check"*
8
+ **Scope:** Collect statistics from `.design/` artifacts, generate observations and actionable recommendations.
9
+ Does not modify specs, plans, tasks, or RULES.md — only writes to `.design/RETROSPECTIVE.md`.
10
+
11
+ > **Full implementation:** `.magic/retrospective.md`
12
+ > Read that file before proceeding. Do not execute any steps until it is read.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Workflow for manually adding or amending project conventions in RULES.md.
3
+ ---
4
+
5
+ # Rule Workflow
6
+
7
+ **Triggers:** *"Add rule"*, *"Add convention"*, *"Amend rule"*, *"Remove rule"*
8
+ **Scope:** Direct management of RULES.md §7 Project Conventions.
9
+ Automatic rule capture during spec work is handled by `specification.md`.
10
+
11
+ > **Full implementation:** `.magic/rule.md`
12
+ > Read that file before proceeding. Do not execute any steps until it is read.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Workflow for creating and managing project specifications.
3
+ ---
4
+
5
+ # Specification Workflow
6
+
7
+ **Triggers:** *"Create spec"*, *"Update spec"*, *"Audit specs"*, *"Review registry"*
8
+ **Scope:** Specification authoring — what exists and how it is structured.
9
+ Planning and execution are handled by `plan.md` and `task.md`.
10
+
11
+ > **Full implementation:** `.magic/specification.md`
12
+ > Read that file before proceeding. Do not execute any steps until it is read.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Workflow for generating and executing implementation tasks.
3
+ ---
4
+
5
+ # Task Workflow
6
+
7
+ **Triggers:** *"Generate tasks"*, *"Create tasks"*, *"Start tasks"*, *"Next task"*, *"Continue"*, *"Update tasks"*, *"Sync tasks"*, *"Start parallel execution"*, *"Launch agents"*
8
+ **Scope:** Task generation, execution tracking, parallelism, and agent coordination.
9
+ Planning is handled by `plan.md`.
10
+
11
+ > **Full implementation:** `.magic/task.md`
12
+ > Read that file before proceeding. Do not execute any steps until it is read.
package/.magic/init.md ADDED
@@ -0,0 +1,63 @@
1
+ ---
2
+ description: Automatic pre-flight check for .design/ directory initialization.
3
+ ---
4
+
5
+ # Init — Automatic Pre-Flight Check
6
+
7
+ Verifies that `.design/` exists and contains all required system files. If anything is missing — creates it automatically.
8
+
9
+ > **This is NOT a user-facing workflow.** It is called automatically by every other workflow on first invocation. No manual command needed.
10
+
11
+ ## Agent Guidelines
12
+
13
+ 1. **Silent by Default**: When called automatically by another workflow, do not interrupt the user. Report init results briefly and continue with the original workflow.
14
+ 2. **Safe to Re-Run**: Skips files that already exist. Never overwrites existing `.design/` content.
15
+ 3. **First Run Only**: After successful initialization, suggest running the Spec Workflow to create the first specification.
16
+
17
+ ## When It Runs
18
+
19
+ This check is embedded as **Step 0** in every workflow (`specification.md`, `plan.md`, `task.md`, `rule.md`, `retrospective.md`). The agent executes it before any workflow-specific logic.
20
+
21
+ ```mermaid
22
+ graph TD
23
+ A["Any workflow triggered"] --> B{".design/ exists?"}
24
+ B -->|Yes| C{INDEX.md + RULES.md exist?}
25
+ B -->|No| D["Run init scripts"]
26
+ C -->|Yes| E["Continue with workflow"]
27
+ C -->|No| D
28
+ D --> F["Report: SDD initialized"]
29
+ F --> E
30
+ ```
31
+
32
+ ## Steps
33
+
34
+ 1. **Check `.design/`**: Verify directory exists.
35
+ 2. **Check system files**: Verify `INDEX.md` and `RULES.md` exist inside `.design/`.
36
+ 3. **If anything missing**: Detect OS and run the appropriate script:
37
+
38
+ | OS | Script | Run with |
39
+ | :--- | :--- | :--- |
40
+ | macOS / Linux | `.magic/scripts/init.sh` | `bash .magic/scripts/init.sh` |
41
+ | Windows | `.magic/scripts/init.ps1` | `pwsh .magic/scripts/init.ps1` |
42
+
43
+ 1. **Report result** (brief, inline with the calling workflow):
44
+
45
+ ```
46
+ SDD initialized — {YYYY-MM-DD}
47
+ Created: .design/INDEX.md, .design/RULES.md, .design/specifications/, .design/tasks/
48
+ Continuing with {workflow name}...
49
+ ```
50
+
51
+ 2. **If already initialized**: Skip silently. No output needed.
52
+
53
+ ## Directory Structure Created
54
+
55
+ ```plaintext
56
+ .design/
57
+ ├── INDEX.md # Spec registry
58
+ ├── RULES.md # Project constitution
59
+ ├── specifications/ # Spec files go here
60
+ └── tasks/ # Task files go here
61
+ ```
62
+
63
+ `PLAN.md`, `TASKS.md`, and `RETROSPECTIVE.md` are created by their respective workflows — not by init.
package/.magic/plan.md ADDED
@@ -0,0 +1,289 @@
1
+ ---
2
+ description: Workflow for creating and managing the implementation plan from existing specifications.
3
+ ---
4
+
5
+ # Plan Workflow
6
+
7
+ This workflow reads finalized specifications and produces a structured implementation plan (`.design/PLAN.md`).
8
+ It operates **after** the Spec Workflow — specifications are its input, not its concern.
9
+
10
+ > **Scope**: Prioritization, phasing, dependency analysis, and implementation order.
11
+ > Specification authoring is handled by the **Spec Workflow** (`specification.md`).
12
+
13
+ ## Agent Guidelines
14
+
15
+ **CRITICAL INSTRUCTIONS FOR AI:**
16
+
17
+ 1. **Specs First**: Never generate a plan without reading all spec files listed in `INDEX.md`. The plan reflects specs — it does not invent content.
18
+ 2. **Read Before Write**: Always read `.design/INDEX.md`, `.design/RULES.md`, and all spec files in `.design/specifications/` before producing any plan output.
19
+ 3. **Auto-Init**: If `.design/` or its system files are missing, automatically trigger the Init pre-flight check (`.magic/init.md`) before proceeding.
20
+ 4. **Confirm Before Commit**: Always show the proposed phase structure and dependency analysis to the user before writing `PLAN.md`.
21
+ 5. **No Duplication**: PLAN.md summarizes specs — it does not copy their content. Use references, not reproduction.
22
+ 6. **Dependency Integrity**: Never assign a spec to an earlier phase than its declared dependencies.
23
+ 7. **Checklist Before Done**: Every task must end with the *Task Completion Checklist*. A task is not complete until the checklist is presented.
24
+
25
+ ## Directory Structure
26
+
27
+ ```plaintext
28
+ .design/
29
+ ├── INDEX.md # Input: registry of all specs
30
+ ├── RULES.md # Input: project conventions
31
+ ├── PLAN.md # Output: implementation plan (managed by Plan Workflow)
32
+ ├── specifications/ # Input: spec files (managed by Spec Workflow)
33
+ │ └── *.md
34
+ └── tasks/ # Output: task files (managed by Task Workflow)
35
+ ├── TASKS.md
36
+ └── phase-{n}.md
37
+ ```
38
+
39
+ ## Workflow Steps
40
+
41
+ ### Creating a New Plan
42
+
43
+ Use when `.design/PLAN.md` does not exist or needs to be built from scratch.
44
+
45
+ **Trigger phrase**: *"Create plan"* or *"Generate plan"*
46
+
47
+ ```mermaid
48
+ graph TD
49
+ A[Trigger: Create Plan] --> B[Read INDEX.md + RULES.md]
50
+ B --> C[Read all spec files]
51
+ C --> D[Extract dependency graph]
52
+ D --> E[Identify critical path]
53
+ E --> F[Propose phase structure to user]
54
+ F -->|Approved| G[Write PLAN.md]
55
+ F -->|Adjusted| F
56
+ G --> H[Task Completion Checklist]
57
+ ```
58
+
59
+ 1. **Read INDEX.md**: Get the full list of existing spec files and their statuses. Path: `.design/INDEX.md`.
60
+ 2. **Read RULES.md**: Check for any project conventions that affect planning. Path: `.design/RULES.md`.
61
+ 3. **Read all spec files**: For each spec in `.design/specifications/`, extract:
62
+ - `Related Specifications` — direct dependencies
63
+ - `Status` — only `Stable` specs are ready for implementation; `Draft`/`RFC` specs are flagged
64
+ - `Implementation Notes` — if present, surface them in the plan
65
+ 4. **Build dependency graph**: Map which specs depend on which. Identify:
66
+ - **Roots** — specs with no dependencies (can start immediately)
67
+ - **Leaves** — specs nothing else depends on (can be deferred)
68
+ - **Critical path** — the longest dependency chain
69
+ 5. **Propose phase structure**: Show the user a draft before writing anything:
70
+
71
+ ```
72
+ Proposed Plan — {YYYY-MM-DD}
73
+
74
+ Dependency Graph (summary):
75
+ architecture.md → api.md, data-management.md, ui-components.md
76
+ data-management.md → settings-schema.md
77
+ ui-components.md → main-menu.md, settings-ui.md
78
+
79
+ Critical Path:
80
+ architecture.md → data-management.md → settings-schema.md
81
+
82
+ Proposed Phases:
83
+
84
+ Phase 1 — Foundation (suggested: start immediately)
85
+ - architecture.md [Draft] ← root, no dependencies
86
+ - api.md [Stable] ← depends on architecture.md
87
+ - settings-schema.md [Stable] ← depends on data-management.md
88
+
89
+ Phase 2 — Services & Data
90
+ - data-management.md [Draft] ← depends on architecture.md
91
+ - input-system.md [Draft] ← depends on architecture.md
92
+
93
+ Phase 3 — UI & Experience
94
+ - ui-components.md [Draft] ← depends on architecture.md
95
+ - main-menu.md [Draft] ← depends on ui-components.md, localization.md
96
+ - settings-ui.md [Draft] ← depends on settings-schema.md, ui-components.md
97
+ - localization.md [Draft] ← depends on ui-components.md, data-management.md
98
+
99
+ Phase 4 — Polish
100
+ - gameplay-config.md [Draft] ← depends on data-management.md
101
+
102
+ Unassigned (no spec file yet):
103
+ - Transition Orchestrator ← mentioned in specs but no .md file
104
+ - Theme Engine ← mentioned in specs but no .md file
105
+ - Accessibility ← mentioned in specs but no .md file
106
+
107
+ Flagged:
108
+ - 8 of 10 specs are in Draft status — plan will note implementation readiness per spec
109
+
110
+ Adjust phases or proceed? (yes / adjust)
111
+ ```
112
+
113
+ 6. **Write PLAN.md**: After user approval, create `.design/PLAN.md` using the *PLAN.md Template*.
114
+ 7. **Task Completion Checklist**: Present the checklist to the user.
115
+
116
+ ### Updating an Existing Plan
117
+
118
+ Use when specs have changed, new specs were added, or the user wants to reprioritize.
119
+
120
+ **Trigger phrase**: *"Update plan"* or *"Reprioritize"*
121
+
122
+ ```mermaid
123
+ graph TD
124
+ A[Trigger: Update Plan] --> B[Read current PLAN.md]
125
+ B --> C[Read .design/INDEX.md — detect changes]
126
+ C --> D{What changed?}
127
+ D -->|New spec added| E[Propose phase assignment]
128
+ D -->|Spec status changed| F[Update status marker in place]
129
+ D -->|User reprioritizes| G[Show current structure, propose moves]
130
+ D -->|Spec deprecated| H[Move to Archived section]
131
+ E & F & G & H --> I[Confirm with user]
132
+ I -->|Approved| J[Write changes to PLAN.md]
133
+ J --> K[Task Completion Checklist]
134
+ ```
135
+
136
+ #### New Spec Added
137
+
138
+ When a spec appears in `INDEX.md` that is not yet in `PLAN.md`:
139
+
140
+ ```
141
+ New spec detected: "{spec-name}.md"
142
+ Dependencies: {list from Related Specifications}
143
+
144
+ Suggested phase based on dependencies: Phase {N}
145
+
146
+ Assign to:
147
+ 1. Phase 1 — Foundation
148
+ 2. Phase 2 — Services & Data
149
+ 3. Phase 3 — UI & Experience
150
+ 4. A new phase — describe it
151
+ 5. Unassigned — add to backlog
152
+ ```
153
+
154
+ #### Spec Status Changed
155
+
156
+ When a spec transitions to `Stable`, update its marker in PLAN.md in place:
157
+
158
+ ```markdown
159
+ - **{Spec Name}** ([{spec-name}.md](specifications/{spec-name}.md)) — `Stable ✓`
160
+ ```
161
+
162
+ When a spec transitions to `Deprecated`, move its entry to the `Archived` section.
163
+
164
+ #### Reprioritization
165
+
166
+ When the user signals a change in order or priority:
167
+
168
+ 1. Show the current phase structure as a compact summary.
169
+ 2. Propose the specific moves with dependency impact noted:
170
+
171
+ ```
172
+ Moving settings-ui.md from Phase 3 → Phase 2.
173
+ ⚠️ Dependency warning: settings-ui.md depends on ui-components.md (currently Phase 3).
174
+ Moving it earlier would create a broken dependency chain.
175
+
176
+ Options:
177
+ a) Also move ui-components.md to Phase 2
178
+ b) Keep settings-ui.md in Phase 3
179
+ ```
180
+
181
+ 3. Wait for explicit confirmation before writing any changes.
182
+
183
+ #### Phase Completion
184
+
185
+ When all specs in a phase reach `Stable`:
186
+
187
+ ```markdown
188
+ ## Phase 1 — Foundation ✓ Completed {YYYY-MM-DD}
189
+ ```
190
+
191
+ Propose activating the next phase if not already open.
192
+
193
+ ### Task Completion Checklist
194
+
195
+ **Must be shown at the end of every plan operation — no exceptions.**
196
+
197
+ ```
198
+ Plan Task Completion Checklist — {task description}
199
+
200
+ Input Integrity
201
+ ☐ All spec files in INDEX.md were read before plan was written
202
+ ☐ No content copied from specs — only references used
203
+
204
+ Dependency Integrity
205
+ ☐ No spec assigned to a phase earlier than its dependencies allow
206
+ ☐ Dependency graph reflects current Related Specifications in all specs
207
+ ☐ Unassigned items (no spec file) listed explicitly
208
+
209
+ Status Accuracy
210
+ ☐ Each spec entry reflects its current status from INDEX.md
211
+ ☐ Draft/RFC specs flagged as not yet implementation-ready
212
+
213
+ Structure
214
+ ☐ PLAN.md written to .design/ root (not inside subdirectory)
215
+ ☐ Critical path identified and documented
216
+ ☐ Archived section present for deprecated specs
217
+
218
+ Confirmation
219
+ ☐ Phase structure confirmed by user before writing
220
+ ☐ Any dependency warnings surfaced and resolved
221
+ ```
222
+
223
+ ## Templates
224
+
225
+ ### PLAN.md Template
226
+
227
+ ```markdown
228
+ # Implementation Plan
229
+
230
+ **Version:** {X.Y.Z}
231
+ **Generated:** {YYYY-MM-DD}
232
+ **Based on:** .design/INDEX.md v{X.Y.Z}
233
+ **Status:** Active
234
+
235
+ ## Overview
236
+
237
+ Implementation plan derived from project specifications.
238
+ Specs are the source of truth. To update: *"Update plan"*.
239
+
240
+ ## Dependency Graph
241
+
242
+ ```mermaid
243
+ graph TD
244
+ architecture --> api
245
+ architecture --> data-management
246
+ architecture --> ui-components
247
+ data-management --> settings-schema
248
+ ui-components --> settings-ui
249
+ settings-schema --> settings-ui
250
+ ```
251
+
252
+ ## Critical Path
253
+
254
+ `architecture.md` → `data-management.md` → `settings-schema.md` → `settings-ui.md`
255
+
256
+ ## Phase 1 — Foundation
257
+
258
+ *Specs with no dependencies. Start here.*
259
+
260
+ - **Core Architecture** ([architecture.md](specifications/architecture.md)) — `Draft`
261
+ - Dependencies: none (root)
262
+ - Notes: must be stable before Phase 2
263
+
264
+ - **Public API** ([api.md](specifications/api.md)) — `Stable ✓`
265
+ - Dependencies: architecture.md
266
+
267
+ ## Phase 2 — {Phase Name}
268
+
269
+ *...*
270
+
271
+ - **{Spec Name}** ([{spec}.md](specifications/{spec}.md)) — `{Status}`
272
+ - Dependencies: {spec}.md
273
+ - Notes: {optional}
274
+
275
+ ## Unassigned (No Spec File Yet)
276
+
277
+ - **{Name}** — referenced in {spec}.md
278
+
279
+ ## Archived
280
+
281
+ <!-- Deprecated specs moved here -->
282
+
283
+ ## Plan History
284
+
285
+ | Version | Date | Author | Description |
286
+ | :--- | :--- | :--- | :--- |
287
+ | 1.0.0 | YYYY-MM-DD | Agent | Initial plan |
288
+
289
+ ```