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.
package/.magic/task.md ADDED
@@ -0,0 +1,443 @@
1
+ ---
2
+ description: Workflow for generating and executing implementation tasks from the project plan.
3
+ ---
4
+
5
+ # Task Workflow
6
+
7
+ This workflow reads `.design/PLAN.md` and decomposes it into atomic, executable tasks.
8
+ It operates **after** the Plan Workflow — the plan is its input, not its concern.
9
+
10
+ > **Scope**: Task generation, execution tracking, parallelism, and agent coordination.
11
+ > Specification authoring → Spec Workflow. Planning → Plan Workflow. Execution → this workflow.
12
+
13
+ ## Agent Guidelines
14
+
15
+ **CRITICAL INSTRUCTIONS FOR AI:**
16
+
17
+ 1. **Plan First**: Never generate tasks without reading `.design/PLAN.md`. Tasks are derived from the plan — they do not invent scope.
18
+ 2. **Auto-Init**: If `.design/` or its system files are missing, automatically trigger the Init pre-flight check (`.magic/init.md`) before proceeding.
19
+ 3. **Atomic Tasks**: Each task must map to exactly one section of one spec file. A task that touches two specs is two tasks.
20
+ 4. **Dependency Respect**: Never mark a task as available if its declared dependencies are not `Done`.
21
+ 5. **Mode Awareness**: Always know the current execution mode (Sequential or Parallel). Behaviour differs significantly between them.
22
+ 6. **Manager Role**: In Parallel mode, the Manager Agent coordinates — it does not implement. It reads status, unblocks tracks, and escalates conflicts.
23
+ 7. **Checklist Before Done**: Every workflow operation must end with the *Task Completion Checklist*.
24
+
25
+ ## Directory Structure
26
+
27
+ ```plaintext
28
+ .design/
29
+ ├── INDEX.md
30
+ ├── RULES.md
31
+ ├── PLAN.md # Input: implementation plan
32
+ ├── specifications/
33
+ └── tasks/ # Output: task files
34
+ ├── TASKS.md # Master index: all tasks, all phases, all statuses
35
+ └── phase-{n}.md # Per-phase task breakdown with tracks
36
+ ```
37
+
38
+ ## Task Anatomy
39
+
40
+ Every task has a fixed structure:
41
+
42
+ ```
43
+ [T-{phase}{track}{seq}] {Title}
44
+ Spec: {spec-name}.md §{section}
45
+ Phase: {n} / Track {A|B|C...}
46
+ Depends: {T-ID, T-ID, ... | —}
47
+ Status: {Todo | In Progress | Done | Blocked}
48
+ Assignee: {Developer-A | Developer-B | ... | unassigned}
49
+ Notes: {optional}
50
+ ```
51
+
52
+ **ID format**: `T-1A01` = Phase 1, Track A, task 01.
53
+
54
+ **Status rules:**
55
+
56
+ - `Todo` — not yet started; dependencies may or may not be satisfied
57
+ - `In Progress` — actively being worked on
58
+ - `Done` — implementation complete, output verified
59
+ - `Blocked` — cannot proceed; blocking reason must be stated in Notes
60
+
61
+ ## Execution Tracks
62
+
63
+ Within each phase, tasks are grouped into **Execution Tracks**. Tasks in different tracks are independent and can run in parallel. Tasks within the same track run sequentially.
64
+
65
+ ```
66
+ Phase 2
67
+ Track A: [T-2A01] → [T-2A02] → [T-2A03] ══╗
68
+ ║ (parallel)
69
+ Track B: [T-2B01] → [T-2B02] ══╣
70
+
71
+ Track C: [T-2C01] (depends on A + B) ══╝ (after A and B complete)
72
+ ```
73
+
74
+ Track assignment is derived from the dependency graph in PLAN.md — specs that don't depend on each other can be different tracks.
75
+
76
+ ## Execution Modes
77
+
78
+ ### Sequential Mode
79
+
80
+ One agent works through tasks in track order, phase by phase. Default mode for solo development or single-agent setups.
81
+
82
+ ```
83
+ Manager Agent: reads TASKS.md, picks next available task, executes, updates status, repeats.
84
+ ```
85
+
86
+ ### Parallel Mode
87
+
88
+ Multiple Developer Agents work simultaneously, each owning one track. A Manager Agent coordinates.
89
+
90
+ ```
91
+ Manager Agent: reads TASKS.md → assigns tracks → monitors → unblocks → escalates
92
+ Developer Agent A: owns Track A → executes T-xA01, T-xA02... → reports Done/Blocked
93
+ Developer Agent B: owns Track B → executes T-xB01, T-xB02... → reports Done/Blocked
94
+ ```
95
+
96
+ The execution mode is stored in `RULES.md §7` as a Project Convention and does not need to be re-asked on subsequent runs.
97
+
98
+ ## Workflow Steps
99
+
100
+ ### Initializing Tasks
101
+
102
+ Use when `.design/tasks/TASKS.md` does not exist.
103
+
104
+ **Trigger phrase**: *"Generate tasks"* or *"Create tasks"*
105
+
106
+ ```mermaid
107
+ graph TD
108
+ A[Trigger: Generate Tasks] --> B[Read PLAN.md]
109
+ B --> C[Read all referenced spec files]
110
+ C --> D{First run?}
111
+ D -->|Yes| E[Ask execution mode]
112
+ D -->|No| F[Read mode from RULES.md §7]
113
+ E --> G[Save mode to RULES.md §7]
114
+ G --> H[Decompose phases into tasks]
115
+ F --> H
116
+ H --> I[Assign tracks based on dependency graph]
117
+ I --> J[Propose task breakdown to user]
118
+ J -->|Approved| K[Write TASKS.md + phase files]
119
+ J -->|Adjusted| H
120
+ K --> L[Task Completion Checklist]
121
+ ```
122
+
123
+ 1. **Read PLAN.md**: Get phases, specs per phase, dependency graph, and critical path.
124
+ 2. **Read spec files**: For each spec in PLAN.md, read its `Implementation Notes` (§4) if present — these directly inform task decomposition.
125
+ 3. **Ask execution mode** (first run only):
126
+
127
+ ```
128
+ How should tasks be executed?
129
+
130
+ A) Sequential — one agent works through tasks in order (default)
131
+ B) Parallel — Manager Agent + Developer Agents per track
132
+
133
+ This choice will be saved to RULES.md §7 and used for all future runs.
134
+ You can change it at any time with: "Switch to parallel mode"
135
+ ```
136
+
137
+ 4. **Decompose**: For each spec in each phase, extract atomic tasks from:
138
+ - Numbered sections in `Detailed Design`
139
+ - Steps listed in `Implementation Notes`
140
+ - Logical units implied by the spec's structure
141
+
142
+ One spec section = one task (or a few if the section is large). Never bundle multiple specs into one task.
143
+
144
+ 5. **Assign tracks**: Group tasks into tracks based on independence:
145
+ - Tasks with no shared dependencies → separate tracks (can run in parallel)
146
+ - Tasks that depend on the same prerequisite → may share a track or be sequenced
147
+
148
+ 6. **Propose breakdown**: Show the user the full task structure before writing:
149
+
150
+ ```
151
+ Proposed Task Breakdown — Phase 1
152
+
153
+ Execution mode: Sequential
154
+
155
+ Track A — Core Layer
156
+ [T-1A01] Define AppState FSM structure
157
+ Spec: architecture.md §3.1
158
+ Depends: —
159
+
160
+ [T-1A02] Implement Path Reliability (current_exe)
161
+ Spec: architecture.md §3.2
162
+ Depends: T-1A01
163
+
164
+ Track B — API Contract (parallel with A)
165
+ [T-1B01] Define LaunchpadBuilder interface
166
+ Spec: api.md §2.1
167
+ Depends: —
168
+
169
+ Track C — Settings Schema (after A)
170
+ [T-1C01] Define RON schema root structure
171
+ Spec: settings-schema.md §1.1
172
+ Depends: T-1A01
173
+
174
+ [T-1C02] Define Graphics and Audio blocks
175
+ Spec: settings-schema.md §2.1, §2.2
176
+ Depends: T-1C01
177
+
178
+ Total: 5 tasks, 3 tracks
179
+ Parallelisable at start: Track A and Track B simultaneously
180
+
181
+ Proceed? (yes / adjust)
182
+ ```
183
+
184
+ 7. **Write files**: Create `TASKS.md` (master index) and `phase-1.md`, `phase-2.md`... using the templates below.
185
+ 8. **Task Completion Checklist**: Present the checklist.
186
+
187
+ ### Executing Tasks (Sequential Mode)
188
+
189
+ **Trigger phrase**: *"Start tasks"*, *"Next task"*, *"Continue"*
190
+
191
+ ```mermaid
192
+ graph TD
193
+ A[Trigger: Execute] --> B[Read TASKS.md]
194
+ B --> C[Find next available task]
195
+ C --> D{Dependencies satisfied?}
196
+ D -->|No| E[Report blocked, show what is needed]
197
+ D -->|Yes| F[Execute task]
198
+ F --> G{Result?}
199
+ G -->|Done| H[Mark Done in TASKS.md + phase file]
200
+ G -->|Blocked| I[Mark Blocked, state reason in Notes]
201
+ H --> J[Check if phase complete]
202
+ J -->|Phase done| K[Auto-snapshot: run retrospective Level 1]
203
+ K --> L{Entire plan complete?}
204
+ L -->|Yes| M[Auto-run: full retrospective Level 2]
205
+ L -->|No| N[Report phase complete, propose next phase]
206
+ J -->|More tasks| C
207
+ I --> O[Escalate to user]
208
+ ```
209
+
210
+ 1. **Find next available task**: The task with status `Todo` whose all dependencies are `Done`. In sequential mode: pick the first one in track order.
211
+ 2. **Execute**: Perform the implementation work described by the task. Stay within the task's spec section — do not expand scope.
212
+ 3. **Update status**: Mark `In Progress` when starting, `Done` when complete, `Blocked` if a blocker is encountered.
213
+ 4. **Report**: After each task, briefly state what was done and what is next.
214
+ 5. **On phase completion**:
215
+ - Run **retrospective Level 1 (auto-snapshot)**: read INDEX.md, TASKS.md, RULES.md → count stats → append one row to `.design/RETROSPECTIVE.md` Snapshots table. Do this **silently** — no user confirmation needed.
216
+ - Check if the **entire plan** is complete (all phases, all tasks Done). If yes → auto-run **retrospective Level 2 (full)** as the final step.
217
+ - If not done → report phase complete and propose the next phase.
218
+
219
+ ### Executing Tasks (Parallel Mode)
220
+
221
+ **Trigger phrase**: *"Start parallel execution"*, *"Launch agents"*
222
+
223
+ ```mermaid
224
+ graph TD
225
+ A[Trigger: Parallel Execute] --> B[Manager: Read TASKS.md]
226
+ B --> C[Manager: Identify available tracks]
227
+ C --> D[Manager: Assign tracks to Developer Agents]
228
+ D --> E[Developer Agents: Execute in parallel]
229
+ E --> F{Agent reports}
230
+ F -->|Done| G[Manager: Update status, check for newly unblocked tasks]
231
+ F -->|Blocked| H[Manager: Resolve or escalate]
232
+ G --> I{All tasks done?}
233
+ I -->|No| C
234
+ I -->|Yes| J[Auto-snapshot: run retrospective Level 1]
235
+ J --> L{Entire plan complete?}
236
+ L -->|Yes| M[Auto-run: full retrospective Level 2]
237
+ L -->|No| N[Manager: Report phase complete]
238
+ H --> K[User decision]
239
+ K --> C
240
+ ```
241
+
242
+ #### Manager Agent Responsibilities
243
+
244
+ The Manager Agent does not write implementation code. Its job is coordination:
245
+
246
+ - **At start of phase**: Read TASKS.md, identify all `Todo` tasks whose dependencies are satisfied, assign each available track to a Developer Agent.
247
+ - **On task completion**: Update task status to `Done`, recalculate which tasks are now unblocked, assign newly available tasks.
248
+ - **On blocking**: Read the blocker reason, determine if it can be resolved (missing spec detail → consult spec file, dependency not done → reorder), escalate to user if not resolvable.
249
+ - **On conflict**: If two Developer Agents need to modify the same file simultaneously, Manager serializes access — one waits while the other finishes.
250
+ - **Status report**: After each round of completions, show a compact summary:
251
+
252
+ ```
253
+ Phase 2 Status — {timestamp}
254
+
255
+ Track A: [T-2A01] Done ✓ [T-2A02] In Progress...
256
+ Track B: [T-2B01] Done ✓ [T-2B02] Done ✓
257
+ Track C: [T-2C01] Blocked — waiting for T-2A02
258
+
259
+ Newly unblocked: none
260
+ Active agents: Developer-A (T-2A02)
261
+ ```
262
+
263
+ #### Developer Agent Responsibilities
264
+
265
+ Each Developer Agent owns one track for the duration of a phase:
266
+
267
+ - Execute tasks in track order, one at a time.
268
+ - Report `Done` to Manager when complete, `Blocked` with reason when stuck.
269
+ - Do not touch files outside the assigned track's scope without Manager approval.
270
+ - Do not start the next task until the current one is `Done`.
271
+
272
+ ### Updating Tasks
273
+
274
+ **Trigger phrase**: *"Update tasks"*, *"Sync tasks"*
275
+
276
+ Use when specs or the plan have changed after tasks were generated.
277
+
278
+ 1. Read current `TASKS.md` and compare against `PLAN.md`.
279
+ 2. Detect changes:
280
+ - New spec added to plan → propose new tasks for that spec
281
+ - Spec updated (new section) → propose additional task
282
+ - Spec deprecated → mark related tasks as `Cancelled` in TASKS.md
283
+ 3. Show diff to user before writing:
284
+
285
+ ```
286
+ Task sync detected changes:
287
+
288
+ + New tasks proposed (gameplay-config.md added to Phase 4):
289
+ [T-4A01] Implement gameplay.ron deserialization
290
+ [T-4A02] Implement hot-reload event (GameplayConfigChanged)
291
+
292
+ ~ Modified tasks (architecture.md §3.2 updated):
293
+ [T-1A02] "Implement Path Reliability" — spec section updated
294
+ → Recommend: re-verify if task is still accurate
295
+
296
+ Apply? (yes / select / skip)
297
+ ```
298
+
299
+ ### Task Completion Checklist
300
+
301
+ **Must be shown at the end of every task workflow operation.**
302
+
303
+ ```
304
+ Task Workflow Checklist — {operation description}
305
+
306
+ Input Integrity
307
+ ☐ PLAN.md was read before any tasks were generated or modified
308
+ ☐ All task-to-spec mappings reference real sections in real spec files
309
+
310
+ Task Structure
311
+ ☐ Each task maps to exactly one spec section (no cross-spec bundling)
312
+ ☐ All task IDs follow the T-{phase}{track}{seq} format
313
+ ☐ All dependencies declared explicitly (or marked —)
314
+
315
+ Track Integrity
316
+ ☐ Tasks in different tracks have no hidden shared dependencies
317
+ ☐ Track C (or later) tasks correctly depend on earlier track completions
318
+ ☐ No circular dependencies between tasks
319
+
320
+ Execution Mode
321
+ ☐ Execution mode recorded in RULES.md §7
322
+ ☐ In Parallel mode: Manager Agent role is clearly defined
323
+ ☐ In Parallel mode: no two agents assigned to the same file simultaneously
324
+
325
+ Status
326
+ ☐ TASKS.md updated to reflect current state
327
+ ☐ Per-phase files updated to match TASKS.md
328
+ ☐ All Blocked tasks have a reason stated in Notes
329
+ ```
330
+
331
+ ## Templates
332
+
333
+ ### TASKS.md — Master Index
334
+
335
+ ```markdown
336
+ # Task Index
337
+
338
+ **Version:** {X.Y.Z}
339
+ **Generated:** {YYYY-MM-DD}
340
+ **Based on:** .design/PLAN.md v{X.Y.Z}
341
+ **Execution Mode:** {Sequential | Parallel}
342
+ **Status:** Active
343
+
344
+ ## Overview
345
+
346
+ Master index of all implementation tasks. Detailed breakdowns: see `phase-{n}.md` files.
347
+
348
+ ## Summary
349
+
350
+ | Phase | Total | Todo | In Progress | Done | Blocked |
351
+ | :---- | ----: | ---: | ----------: | ---: | ------: |
352
+ | Phase 1 — Foundation | 5 | 3 | 1 | 1 | 0 |
353
+ | Phase 2 — Services & Data | 8 | 8 | 0 | 0 | 0 |
354
+ | **Total** | **13** | **11** | **1** | **1** | **0** |
355
+
356
+ ## Phase 1 — Foundation
357
+
358
+ See [phase-1.md](phase-1.md) for full breakdown.
359
+
360
+ | ID | Title | Track | Status |
361
+ | :- | :---- | :---- | :----- |
362
+ | T-1A01 | Define AppState FSM structure | A | Done ✓ |
363
+ | T-1A02 | Implement Path Reliability | A | In Progress |
364
+ | T-1B01 | Define LaunchpadBuilder interface | B | Todo |
365
+ | T-1C01 | Define RON schema root structure | C | Todo |
366
+
367
+ ## Phase 2 — Services & Data
368
+
369
+ See [phase-2.md](phase-2.md) for full breakdown.
370
+
371
+ | ID | Title | Track | Status |
372
+ | :- | :---- | :---- | :----- |
373
+ | T-2A01 | Implement Asset Manifest loader | A | Todo |
374
+
375
+ ## Archived / Cancelled
376
+
377
+ | ID | Title | Reason |
378
+ | :- | :---- | :----- |
379
+ <!-- Tasks cancelled due to spec deprecation appear here -->
380
+
381
+ ## Task History
382
+
383
+ | Version | Date | Author | Description |
384
+ | :--- | :--- | :--- | :--- |
385
+ | 1.0.0 | YYYY-MM-DD | Agent | Initial task generation |
386
+ ```
387
+
388
+ ### phase-{n}.md — Per-Phase Task File
389
+
390
+ ```markdown
391
+ # Phase {N} — {Phase Name}
392
+
393
+ **Status:** {Active | Completed}
394
+ **Execution Mode:** {Sequential | Parallel}
395
+ **Tracks:** {A, B, C...}
396
+
397
+ ## Track A — {Track Name}
398
+
399
+ ### [T-{N}A01] {Task Title}
400
+
401
+ - **Spec:** [{spec-name}.md](../specifications/{spec-name}.md) §{section}
402
+ - **Depends:** —
403
+ - **Status:** Todo
404
+ - **Assignee:** unassigned
405
+ - **Notes:** —
406
+
407
+ ### [T-{N}A02] {Task Title}
408
+
409
+ - **Spec:** [{spec-name}.md](../specifications/{spec-name}.md) §{section}
410
+ - **Depends:** T-{N}A01
411
+ - **Status:** Todo
412
+ - **Assignee:** unassigned
413
+ - **Notes:** —
414
+
415
+ ## Track B — {Track Name} *(parallel with A)*
416
+
417
+ ### [T-{N}B01] {Task Title}
418
+
419
+ - **Spec:** [{spec-name}.md](../specifications/{spec-name}.md) §{section}
420
+ - **Depends:** —
421
+ - **Status:** Todo
422
+ - **Assignee:** unassigned
423
+ - **Notes:** —
424
+
425
+ ## Track C — {Track Name} *(after A + B)*
426
+
427
+ ### [T-{N}C01] {Task Title}
428
+
429
+ - **Spec:** [{spec-name}.md](../specifications/{spec-name}.md) §{section}
430
+ - **Depends:** T-{N}A02, T-{N}B01
431
+ - **Status:** Todo
432
+ - **Assignee:** unassigned
433
+ - **Notes:** —
434
+
435
+ ## Phase Completion
436
+
437
+ - [ ] All tasks Done
438
+ - [ ] No open blockers
439
+ - [ ] TASKS.md summary updated
440
+ - [ ] Retrospective auto-snapshot appended to RETROSPECTIVE.md
441
+ - [ ] Next phase unlocked: Phase {N+1}
442
+ - [ ] If all phases complete: full retrospective (Level 2) was run
443
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oleg Alexandrov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,180 @@
1
+ # 🪄 Magic Spec
2
+
3
+ [![npm version](https://img.shields.io/npm/v/magic-spec)](https://www.npmjs.com/package/magic-spec)
4
+ [![PyPI version](https://img.shields.io/pypi/v/magic-spec)](https://pypi.org/project/magic-spec/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
6
+
7
+ **Specification-Driven Development (SDD) workflow for AI coding agents.**
8
+
9
+ Stop your AI from writing code before it understands the problem.
10
+ `magic-spec` installs a structured pipeline — *Thought → Spec → Plan → Task → Code* — directly into any project, regardless of stack.
11
+
12
+ ## ✨ What is Magic Spec?
13
+
14
+ `magic-spec` is a set of **markdown-based workflow instructions** for AI coding agents (Cursor, Claude, Gemini, Copilot, etc.). It acts as an operating system for agentic development, enforcing a rigorous, structured pipeline:
15
+
16
+ ```
17
+ 💡 Idea → 📋 Specification → 🗺️ Plan → ⚡ Task → 🚀 Code → 🔍 Retrospective
18
+ ```
19
+
20
+ Once installed, your AI agent will automatically:
21
+
22
+ - Convert raw thoughts into structured specification files.
23
+ - Build a phased implementation plan from approved specs.
24
+ - Decompose the plan into atomic, trackable tasks.
25
+ - Analyze its own workflow and suggest improvements.
26
+
27
+ **No code is written until a specification exists. No spec is implemented without a plan.**
28
+
29
+ ## 🚀 Quick Start
30
+
31
+ Works with **any project** — Rust, Go, Python, JavaScript, or anything else.
32
+ No runtime lock-in. Requires only Node.js *or* Python to install.
33
+
34
+ ### Option A — Node.js (npx)
35
+
36
+ ```bash
37
+ npx magic-spec@latest
38
+ ```
39
+
40
+ ### Option B — Python (uvx)
41
+
42
+ ```bash
43
+ uvx magic-spec
44
+ ```
45
+
46
+ Both commands do exactly the same thing:
47
+
48
+ 1. Copy `.magic/` (the SDD engine) into your project.
49
+ 2. Copy `.agent/workflows/magic/` (agent trigger wrappers) into your project.
50
+ 3. Run the init script — creates your `.design/` workspace with `INDEX.md` and `RULES.md`.
51
+
52
+ ## 🧭 Core Philosophy
53
+
54
+ | Principle | Description |
55
+ | :--- | :--- |
56
+ | **Specs First, Code Later** | The agent is forbidden from writing code from raw input. All ideas become specs first. |
57
+ | **Deterministic Process** | A strict pipeline is enforced: *Thought → Spec → Plan → Task → Code*. |
58
+ | **Constitution-Driven** | All project decisions live in `.design/RULES.md` — the project's living constitution. |
59
+ | **Self-Improving** | The Retrospective workflow analyzes real usage and generates improvement recommendations. |
60
+
61
+ ## 📁 What Gets Installed
62
+
63
+ After running `npx magic-spec@latest` in your project root:
64
+
65
+ ```plaintext
66
+ your-project/
67
+
68
+ ├── .agent/workflows/magic/ # Agent entry points (slash commands)
69
+ │ ├── plan.md
70
+ │ ├── retrospective.md
71
+ │ ├── rule.md
72
+ │ ├── specification.md
73
+ │ └── task.md
74
+
75
+ ├── .magic/ # SDD Engine (workflow logic, read-only)
76
+ │ ├── init.md
77
+ │ ├── plan.md
78
+ │ ├── retrospective.md
79
+ │ ├── rule.md
80
+ │ ├── specification.md
81
+ │ ├── task.md
82
+ │ └── scripts/
83
+ │ ├── init.sh # Init for macOS / Linux
84
+ │ └── init.ps1 # Init for Windows
85
+
86
+ └── .design/ # Your project workspace (generated)
87
+ ├── INDEX.md # Spec registry
88
+ ├── RULES.md # Project constitution
89
+ ├── PLAN.md # Implementation plan
90
+ ├── specifications/ # Your specification files
91
+ └── tasks/ # Task breakdowns per phase
92
+ ```
93
+
94
+ ## 🔗 The Workflow Pipeline
95
+
96
+ ```mermaid
97
+ graph TD
98
+ IDEA["💡 Idea"] --> INIT{"🏗️ Auto-Init"}
99
+ INIT -->|.design/ exists| SPEC
100
+ INIT -->|.design/ missing| CREATE["Create .design/ structure"] --> SPEC
101
+ SPEC["📋 Specification"] <--> RULE["📜 Rule"]
102
+ SPEC --> PLAN["🗺️ Plan"]
103
+ PLAN --> TASK["⚡ Task"]
104
+ TASK --> CODE["🚀 Code"]
105
+ CODE --> RETRO["🔍 Retrospective"]
106
+ RETRO -.->|Feedback loop| SPEC
107
+ ```
108
+
109
+ ### Core Workflows
110
+
111
+ | # | Workflow | Purpose |
112
+ | :--- | :--- | :--- |
113
+ | 1 | **Specification** | Converts raw thoughts into structured specs. Manages statuses: `Draft → RFC → Stable → Deprecated`. |
114
+ | 2 | **Plan** | Reads Stable specs, builds a dependency graph, and produces a phased `PLAN.md`. |
115
+ | 3 | **Task** | Decomposes the plan into atomic tasks with sequential and parallel execution tracks. |
116
+
117
+ ### Auxiliary Workflows
118
+
119
+ | Workflow | Purpose |
120
+ | :--- | :--- |
121
+ | **Rule** | Manages the project constitution (`RULES.md §7`). Add, amend, or remove conventions. |
122
+ | **Retrospective** | Analyzes SDD usage, collects metrics, and generates improvement recommendations. |
123
+
124
+ ## 💬 How to Use (with any AI agent)
125
+
126
+ Just talk to your AI agent naturally. Initialization is **automatic** — no setup command required.
127
+
128
+ ```plaintext
129
+ "Dispatch this thought into specs: I want a user auth system with JWT and Redis..."
130
+ → Runs Specification workflow
131
+
132
+ "Create an implementation plan"
133
+ → Runs Plan workflow
134
+
135
+ "Generate tasks for Phase 1"
136
+ → Runs Task workflow
137
+
138
+ "Execute the next task"
139
+ → Runs Task workflow (execution mode)
140
+
141
+ "Add rule: always use snake_case for file names"
142
+ → Runs Rule workflow
143
+
144
+ "Run retrospective"
145
+ → Runs Retrospective workflow
146
+ ```
147
+
148
+ The AI reads the corresponding `.magic/*.md` workflow file and executes the request within the bounds of the SDD system. **No code escapes the pipeline.** ✨
149
+
150
+ ## 🔄 Updating
151
+
152
+ Pull the latest engine improvements without touching your project data:
153
+
154
+ ```bash
155
+ # Node.js
156
+ npx magic-spec@latest --update
157
+
158
+ # Python
159
+ uvx magic-spec --update
160
+ ```
161
+
162
+ The update overwrites `.magic/` (the engine) but **never touches** `.design/` (your specs, plans, and tasks).
163
+
164
+ ## 🤝 Compatibility
165
+
166
+ Works with any AI coding agent that can read markdown workflow files:
167
+
168
+ - [Cursor](https://cursor.sh) (`.cursorrules` + Agent mode)
169
+ - [Claude](https://claude.ai) (Projects)
170
+ - [Gemini](https://gemini.google.com) (via Gemini Code)
171
+ - [GitHub Copilot](https://github.com/features/copilot) (Agent mode)
172
+ - Any terminal-based or API-driven agent
173
+
174
+ ## 📄 License
175
+
176
+ [MIT](./LICENSE) © 2026 Oleg Alexandrov
177
+
178
+ ---
179
+
180
+ ## TODO: Magic Spec
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "magic-spec",
3
+ "version": "1.0.0",
4
+ "description": "Magic Specification-Driven Development (SDD) Workflow Installer",
5
+ "author": "Oleg Alexandrov <alexandrovoleg.ru@gmail.com>",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/teratron/magic-spec",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/teratron/magic-spec.git"
11
+ },
12
+ "main": "src/index.js",
13
+ "bin": {
14
+ "magic-spec": "src/index.js"
15
+ },
16
+ "files": [
17
+ "src",
18
+ ".magic",
19
+ ".agent",
20
+ "adapters",
21
+ "README.md"
22
+ ],
23
+ "engines": {
24
+ "node": ">=16"
25
+ },
26
+ "scripts": {
27
+ "sync": "node -e \"const fs=require('fs'),p=require('path'),r=p.resolve(__dirname,'../..');['/.magic','/.agent','/adapters'].forEach(d=>fs.cpSync(r+d,p.join(__dirname,d),{recursive:true,force:true}));['README.md','LICENSE'].forEach(f=>{if(fs.existsSync(p.join(r,f)))fs.copyFileSync(p.join(r,f),p.join(__dirname,f))});console.log('✅ synced from root')\"",
28
+ "check": "npm run sync && npm pack --dry-run",
29
+ "publish": "npm run sync && node ../../scripts/publish-npm.js",
30
+ "publish:dry": "npm run sync && npm publish --access public --dry-run",
31
+ "test:link": "npm run sync && npm link",
32
+ "test:pack": "npm run sync && npm pack",
33
+ "version:patch": "npm version patch --no-git-tag-version",
34
+ "version:minor": "npm version minor --no-git-tag-version",
35
+ "version:major": "npm version major --no-git-tag-version"
36
+ }
37
+ }