magic-spec 1.3.0 → 1.4.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/CHANGELOG.md CHANGED
@@ -5,6 +5,56 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.4.0] - 2026-03-01
9
+
10
+ ### Added
11
+
12
+ - **Smart Sync Optimization (AOP)** in `analyze.md`: Automated detection of manual renames during project re-analysis. If an orphaned specification matches a new uncovered directory (>80% similarity or title match), it triggers a `[RESCUE]` action instead of delete/create cycle.
13
+ - **Manual Rename Rescue** in `spec.md`: Protocol to globally update references (INDEX, PLAN, TASKS) when a specification file is moved/renamed, preserving task progress.
14
+ - **Regression Tests (T48–T51)**: Added coverage for Engine Integrity guards, Analysis Depth Control, and Smart Sync mechanisms.
15
+
16
+ ### Changed
17
+
18
+ - **Test Suite Synchronization**: The `suite.md` version is now synchronized with the core engine version to prevent metadata confusion.
19
+
20
+ ## [1.3.2] - 2026-02-28
21
+
22
+ ### Added
23
+
24
+ - **Project Analysis Workflow** (`.magic/analyze.md`): Powerful reverse-engineering tool. Delegated automatically from `spec.md` or directly via `/magic.analyze`. Supports scanning existing source code to generate structured proposals with paired Layer 1 (Concept) and Layer 2 (Implementation) specifications. Features Depth Control for massive codebases.
25
+ - **Bootstrapping Exemption**: Special rules added to bypass standard Draft/RFC phases and create "Stable" specs directly when adopting existing working code into the SDD system.
26
+ - **Improv Mode (Live Simulation)** in `simulate.md`: Added ability for the simulation workflow to synthesize "crisis scenarios" (e.g., INDEX.md desync) and perform full SDK lifecycle stress tests end-to-end on its own, functioning as a fallback if the static test suite is missing.
27
+
28
+ ### Changed
29
+
30
+ - Expanded Test Suite (`.magic/tests/suite.md`) from 28 to 34 scenarios (+6), fully covering Analyze gap detection, L1/L2 generation asserts, depth control limits, and the missing test suite fallback.
31
+
32
+ ## [1.3.1] - 2026-02-27### Added
33
+
34
+ - **Workflow Test Suite** (`.magic/tests/suite.md`): 16 predefined regression test scenarios covering all 8 engine workflows. Run via `/magic.simulate test`.
35
+ - **Test Suite mode** in `simulate.md`: reads `suite.md` and reports PASS/FAIL for each scenario.
36
+ - **Template directory** (`.magic/templates/`): extracted inline templates from core workflow files:
37
+ - `specification.md` — Specification Template (from `spec.md`)
38
+ - `plan.md` — PLAN.md Template (from `task.md`)
39
+ - `tasks.md` — TASKS.md + phase-{n}.md Templates (from `task.md`)
40
+ - `retrospective.md` — RETROSPECTIVE.md Template (from `retrospective.md`)
41
+
42
+ ### Changed
43
+
44
+ - **AOP Optimization**: Compressed verbose prose in `spec.md` (Post-Update Review, Audit/Consistency Reports). ~17% token reduction across core workflows.
45
+ - **Stress-test hardening** across all workflows:
46
+ - `spec.md`: Intra-input self-contradiction guard, Deprecation Cascade (scan Related Specs for stale refs)
47
+ - `task.md`: Circular Dependency Guard, Phantom Done-task preservation (Archive not Cancel), Deprecated Done-task preservation, Convention Sync wording fix
48
+ - `run.md`: Mode Guard — HALT if execution mode not in RULES.md §7
49
+ - `rule.md`: Duplication Guard, convention-not-found handler, Workflow Dependency Check in Remove Impact Analysis
50
+ - `simulate.md`: Checksums mismatch upgraded to HALT, Checksum Rule (generate after approval only)
51
+ - `onboard.md`: Production collision HALT with backup/cancel, re-entry checks production PLAN.md
52
+ - `init.md`: Expanded post-init verification to all 5 artifacts, Maintainer Note for hardcoded RULES.md sync
53
+
54
+ ### Fixed
55
+
56
+ - Template references now explicitly point to `.magic/templates/*.md` in creation steps of `spec.md`, `task.md`, `retrospective.md`, and `onboard.md`.
57
+
8
58
  ## [1.3.0] - 2026-02-25
9
59
 
10
60
  ### Added
package/README.md CHANGED
@@ -1,78 +1,258 @@
1
- # 🪄 Magic Spec
2
-
3
- [![NPM version](https://img.shields.io/npm/v/magic-spec?color=green&label=npm)](https://www.npmjs.com/package/magic-spec)
4
- [![PyPI version](https://img.shields.io/pypi/v/magic-spec?color=blue&label=pypi)](https://pypi.org/project/magic-spec/)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
6
-
7
- **The Specification-Driven Development (SDD) Operating System for AI Agents.**
8
-
9
- Stop your AI from writing code before it understands the problem. `magic-spec` installs a high-performance, structured pipeline *Thought → Spec → Task → Run → Code* — directly into any project.
10
-
11
- ---
12
-
13
- ## Features
14
-
15
- - 🏗️ **Deterministic Pipeline**: Forced structure ensures architectural integrity.
16
- - 🎯 **Multi-Agent Core**: Works with Cursor, Windsurf, Claude, Gemini, and more.
17
- - 🔍 **Auto-Retrospective**: Built-in self-analysis engine that improves your workflow automatically.
18
- - 📦 **Thin-Client Installers**: Lightweight Node.js and Python installers for zero-friction setup.
19
- - 🗺️ **Phased Planning**: Intelligent dependency tracking and implementation roadmaps.
20
-
21
- ---
22
-
23
- ## 🚀 Quick Start
24
-
25
- Works with **any project** — Rust, Go, Python, JavaScript, C++, or anything else.
26
-
27
- ### Option A: Node.js (npx)
28
-
29
- ```bash
30
- npx magic-spec@latest
31
- ```
32
-
33
- ### Option B: Python (uvx)
34
-
35
- ```bash
36
- uvx magic-spec
37
- ```
38
-
39
- **What happens next?**
40
-
41
- 1. Magic Spec deploys the `.magic/` engine and `.agent/` workflows.
42
- 2. An interactive onboarding tutorial (`magic.onboard`) helps you and your AI get started.
43
- 3. Your project gains a dedicated `.design/` workspace for Specifications, Rules, and Plans.
44
-
45
- ---
46
-
47
- ## 🧭 The Workflow
48
-
49
- 1. **Specification**: Convert raw ideas into formal, versioned specs.
50
- 2. **Task & Plan**: Generate a phased roadmap with atomic, trackable tasks.
51
- 3. **Run**: Execute the plan with automatic progress tracking and quality gates.
52
- 4. **Rule**: Manage project conventions in a central `RULES.md` constitution.
53
-
54
- ---
55
-
56
- ## 📖 Documentation & Guides
57
-
58
- - [**Main Documentation**](./docs/README.md) — Detailed guide on workflows and architecture.
59
- - [**Installers Guide**](./installers/README.md) — Advanced CLI options and platform specifics.
60
- - [**Contributing**](./docs/contributing.md) — How to develop and extend the engine.
61
-
62
- ---
63
-
64
- ## 🤝 Compatibility
65
-
66
- Magic Spec is optimized for the world's most powerful AI development environments:
67
-
68
- - [**Cursor**](https://cursor.com) (Rule definitions & Agent Mode)
69
- - [**Windsurf**](https://codeium.com/windsurf) (Cascade & Flows)
70
- - [**GitHub Copilot**](https://github.com/features/copilot) (Custom Instructions)
71
- - [**Claude**](https://claude.ai) (Project context)
72
-
73
- ---
74
-
75
- ## 📄 License
76
-
77
- Distributed under the [MIT License](./LICENSE).
78
- © 2026 Oleg Alexandrov & teratron. ✨
1
+ # 🪄 Magic Spec
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/magic-spec?color=green&label=npm)](https://www.npmjs.com/package/magic-spec)
4
+ [![PyPI version](https://img.shields.io/pypi/v/magic-spec?color=blue&label=pypi)](https://pypi.org/project/magic-spec/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
6
+
7
+ ## 📖 Description
8
+
9
+ **The Specification-Driven Development (SDD) Operating System for AI Coding Agents.**
10
+
11
+ Stop your AI from writing fragile code before it fully understands the problem. `magic-spec` installs a high-performance, structured pipeline — *Thought → Spec → Task → Run → Code* — directly into any project, regardless of the tech stack.
12
+
13
+ Whether you are a **coding novice** building your first application or a **senior engineer** architecting enterprise systems, Magic Spec brings **maximum automation** and professional rigor to your development process. It enforces a deterministic workflow that ensures your AI agent perfectly aligns with your vision before writing a single line of code.
14
+
15
+ ### The Core Concept
16
+
17
+ `magic-spec` is a set of **markdown-based workflow instructions** specifically designed for AI coding agents like Cursor, Windsurf, Claude, and Gemini. It acts as a project-level operating system that orchestrates agentic development.
18
+
19
+ Instead of chaotic prompt-engineering, Magic Spec provides a rigorous pipeline:
20
+
21
+ ```plaintext
22
+ 💡 Idea → 📋 Specification → 🗺️ Task & Plan → ⚡ Run → 🚀 Code
23
+ ```
24
+
25
+ Once initialized, your AI agent will automatically:
26
+
27
+ - Formulate a strong conceptual and technical specification.
28
+ - Build a phased implementation plan with hierarchical dependencies.
29
+ - Decompose the plan into prioritized, atomic, trackable tasks.
30
+ - Facilitate safe architectural brainstorming via **Explore Mode**.
31
+ - Analyze its own workflow and suggest improvements via Auto-Retrospectives.
32
+
33
+ ### What Gets Installed
34
+
35
+ After running the installer, your project directory will be augmented with the following structure:
36
+
37
+ ```plaintext
38
+ root-project/
39
+ ├── .agent/workflows/ # Slash commands wrapper (e.g., magic.spec, magic.task)
40
+ ├── .magic/ # The SDD Engine (workflow logic and scripts - read-only)
41
+ └── .design/ # Your Project Design Workspace (INDEX.md, RULES.md, PLAN.md)
42
+ ```
43
+
44
+ 1. **`.magic/`**: Deploys the core SDD engine.
45
+ 2. **`.agent/`**: Sets up workflows for your AI.
46
+ 3. **`.design/`**: Initializes your project's workspace for Specifications, Rules, and Plans.
47
+ 4. **Onboarding**: An interactive tutorial (`magic.onboard`) helps you and your AI get started smoothly.
48
+
49
+ > [!TIP]
50
+ > **Magic Workspaces**: Magic Spec supports multiple, isolated design environments within a single repository (e.g., `.design/engine/`, `.design/installers/`). This allows you to manage fundamentally different project domains without specification overlap, while sharing a single core engine. See [workspaces.md](./workspaces.md) for details.
51
+
52
+ ## 🖼️ Visuals
53
+
54
+ The engine enforces a rigorous, unskippable pipeline: **Idea → Specification → Task & Plan → Code**. AI agents are prevented from jumping straight to coding. They must first formally specify the solution, then break it down into a concrete plan and tasks, and only then proceed to execution.
55
+
56
+ ```mermaid
57
+ flowchart TB
58
+ IDEA(["💡 Идея"])
59
+
60
+ subgraph BOX ["Magic Spec"]
61
+ direction TB
62
+
63
+ SPEC["📋 Spec"]
64
+
65
+ subgraph TASK ["🗺️ Task"]
66
+ direction TB
67
+ PLAN["📐 Plan"]
68
+ TASKS["📌 Tasks"]
69
+ PLAN --> TASKS
70
+ end
71
+
72
+ RUN["⚡ Run"]
73
+
74
+ SPEC --> PLAN
75
+ TASKS --> RUN
76
+ end
77
+
78
+ CODE(["🚀 Код"])
79
+
80
+ IDEA --> SPEC
81
+ RUN --> CODE
82
+
83
+ style IDEA fill:#1e1e2e,stroke:#89b4fa,color:#cdd6f4
84
+ style CODE fill:#1e1e2e,stroke:#a6e3a1,color:#cdd6f4
85
+
86
+ style BOX fill:#181825,stroke:#fab387,stroke-width:3px,color:#fab387
87
+
88
+ style SPEC fill:#1e1e2e,stroke:#89b4fa,color:#cdd6f4
89
+ style RUN fill:#1e1e2e,stroke:#89b4fa,color:#cdd6f4
90
+
91
+ style TASK fill:#11111b,stroke:#89b4fa,stroke-dasharray:5 5,color:#89b4fa
92
+ style PLAN fill:#1e1e2e,stroke:#45475a,stroke-dasharray:4 4,color:#cdd6f4
93
+ style TASKS fill:#1e1e2e,stroke:#45475a,stroke-dasharray:4 4,color:#cdd6f4
94
+ ```
95
+
96
+ ## ⚙️ Requirements
97
+
98
+ Before installing Magic Spec, ensure you have one of the following available on your system:
99
+
100
+ | Requirement | Details |
101
+ | :--- | :--- |
102
+ | **Node.js** | Version `16.x` or higher (for `npx` method) |
103
+ | **Python** | Version `3.8` or higher (for `uvx` or `pipx` methods) |
104
+ | **Git** | Required for installing edge versions directly from GitHub |
105
+ | **Terminal** | `tar` utility (pre-installed on Windows/Linux/macOS) |
106
+
107
+ ## 📦 Installation
108
+
109
+ Works perfectly with **any project** — Rust, Go, Python, JavaScript, C++, or anything else. No runtime lock-in.
110
+
111
+ ### Option A: Node.js (`npx`)
112
+
113
+ **Stable Release:**
114
+
115
+ ```bash
116
+ # Basic installation (defaults to .agent/ folder)
117
+ npx magic-spec@latest
118
+
119
+ # Targeted installation for Cursor
120
+ npx magic-spec@latest --cursor
121
+ ```
122
+
123
+ **Edge Version (GitHub):**
124
+
125
+ ```bash
126
+ npx --yes github:teratron/magic-spec
127
+ ```
128
+
129
+ ### Option B: Python (`uvx`)
130
+
131
+ **Stable Release:**
132
+
133
+ ```bash
134
+ # Basic installation
135
+ uvx magic-spec
136
+
137
+ # Targeted installation for Windsurf
138
+ uvx magic-spec --windsurf
139
+ ```
140
+
141
+ **Edge Version (GitHub):**
142
+
143
+ ```bash
144
+ uvx --from git+https://github.com/teratron/magic-spec.git magic-spec
145
+ ```
146
+
147
+ ### Option C: Python (`pipx`)
148
+
149
+ ```bash
150
+ pipx run magic-spec
151
+ ```
152
+
153
+ ### Option D: Multi-Adapter Installation
154
+
155
+ You can install support for multiple adapters at once:
156
+
157
+ ```bash
158
+ npx magic-spec@latest --cursor --copilot --windsurf
159
+ ```
160
+
161
+ ### Option E: Manual Installation
162
+
163
+ If automated installers do not fit your environment:
164
+
165
+ 1. **Engine**: Download the `.magic/` folder from the [GitHub repository](https://github.com/teratron/magic-spec).
166
+ 2. **Workflows**: Download command wrappers from [`.agent/workflows/`](https://github.com/teratron/magic-spec/tree/main/.agent/workflows).
167
+ 3. **Deploy**: Place files into your AI agent's instruction directory (e.g., `.cursor/commands`).
168
+
169
+ ## 🔄 Updating
170
+
171
+ Keep your SDD engine up to date with the latest logic and features:
172
+
173
+ ```bash
174
+ # Check if update is available
175
+ npx magic-spec@latest --check
176
+
177
+ # Perform the update
178
+ npx magic-spec@latest --update
179
+ ```
180
+
181
+ > [!TIP]
182
+ > The update process preserves your `.design/` workspace and automatically creates backups of `.magic/` and `.agent/` folders. If you have modified core engine files, the installer will detect conflicts and ask for your preference (overwrite, skip, or abort).
183
+
184
+ ## 💬 Usage
185
+
186
+ Just talk to your AI agent naturally in your prompt interface. No complex commands to learn:
187
+
188
+ - *"Dispatch this thought into specs..."* → Triggers **Specification** workflow.
189
+ - *"Create an implementation plan"* → Triggers **Task & Plan** workflow.
190
+ - *"Execute the next task"* → Triggers **Run** workflow.
191
+ - *"Add a rule: always use Inter font"* → Triggers **Rule** workflow.
192
+
193
+ ### 🤝 Compatibility
194
+
195
+ Magic Spec is heavily optimized and provides native workflow generation for the world's most powerful AI development environments.
196
+
197
+ You can install support for a specific adapter using the shortcut flag (e.g., `--cursor`) or the environment flag (e.g., `--env cursor`).
198
+
199
+ | AI Agent / IDE | Shortcut Flag | Env Flag |
200
+ | :--- | :--- | :--- |
201
+ | [**Cursor**](https://cursor.com) (Agent Mode) | `--cursor` | `--env cursor` |
202
+ | [**Windsurf**](https://codeium.com/windsurf) (Cascade) | `--windsurf` | `--env windsurf` |
203
+ | [**Claude Code**](https://claude.ai/code) | `--claude` | `--env claude` |
204
+ | [**Gemini CLI**](https://gemini.google.com) | `--gemini` | `--env gemini` |
205
+ | [**GitHub Copilot**](https://github.com/features/copilot) | `--copilot` | `--env copilot` |
206
+ | **Roo Code** | `--roo` | `--env roo` |
207
+ | **Amp** | `--amp` | `--env amp` |
208
+ | **Amazon Q Developer** | `--q` | `--env q` |
209
+ | **Kilo Code** | `--kilocode` | `--env kilocode` |
210
+ | **Qwen Code** | `--qwen` | `--env qwen` |
211
+ | **OpenCode** | `--opencode` | `--env opencode` |
212
+ | **SHAI (OVHcloud)** | `--shai` | `--env shai` |
213
+ | **IBM Bob** | `--bob` | `--env bob` |
214
+ | **CodeBuddy** | `--codebuddy` | `--env codebuddy` |
215
+ | **Qoder IDE** | `--qoder` | `--env qoder` |
216
+ | **Codex CLI** | `--codex` | `--env codex` |
217
+ | **Auggie CLI** | `--augment` | `--env augment` |
218
+ | **Antigravity IDE** | `--antigravity` | `--env antigravity` |
219
+ | **Lingma IDE** | `--lingma` | `--env lingma` |
220
+
221
+ ## 📚 Documentation
222
+
223
+ - [**Main Documentation**](./docs/README.md) — Detailed guide on workflows, architecture, and advanced features.
224
+ - [**Installers Guide**](./installers/README.md) — Advanced CLI options and platform specifics.
225
+ - [**Contributing**](./docs/contributing.md) — How to develop, test, and extend the engine.
226
+
227
+ ## 🛟 Support
228
+
229
+ If you encounter issues or have questions:
230
+
231
+ - Open an [Issue](https://github.com/teratron/magic-spec/issues) on GitHub.
232
+ - Run `magic.onboard` in your agent to restart the interactive tutorial.
233
+
234
+ ## 🗺️ Roadmap
235
+
236
+ - [x] Multi-agent adapter system.
237
+ - [x] Phased implementation planning.
238
+ - [ ] Extended support for local-first LLM agents.
239
+ - [ ] Advanced visual dashboard for project health.
240
+ - [ ] Integration with CI/CD for automated spec validation.
241
+
242
+ ## 🏗️ Contributing
243
+
244
+ We welcome contributions! Whether it's a bug fix, a new adapter, or an improvement to the workflow logic.
245
+ Please see [**Contributing Guide**](./docs/contributing.md) for details.
246
+
247
+ ## 👥 Authors and Acknowledgments
248
+
249
+ - **Oleg Alexandrov** — Creator and Lead Maintainer.
250
+ - Special thanks to the AI agent community for inspiration and testing.
251
+
252
+ ## 📄 License
253
+
254
+ Distributed under the [MIT License](./LICENSE).
255
+
256
+ ## 📊 Project Status
257
+
258
+ **Active Development** (v1.x). We are constantly refining the SDD engine based on real-world usage.
@@ -6,6 +6,37 @@
6
6
  "agentDir": ".agent",
7
7
  "workflowsDir": "workflows",
8
8
  "defaultExt": ".md",
9
+ "workflows": [
10
+ "magic.onboard",
11
+ "magic.rule",
12
+ "magic.run",
13
+ "magic.simulate",
14
+ "magic.spec",
15
+ "magic.task"
16
+ ],
17
+ "magicFiles": [
18
+ "analyze.md",
19
+ "onboard.md",
20
+ "retrospective.md",
21
+ "rule.md",
22
+ "run.md",
23
+ "simulate.md",
24
+ "spec.md",
25
+ "task.md",
26
+ ".version",
27
+ ".checksums",
28
+ "scripts/check-prerequisites.ps1",
29
+ "scripts/check-prerequisites.sh",
30
+ "scripts/executor.js",
31
+ "scripts/generate-context.ps1",
32
+ "scripts/generate-context.sh",
33
+ "scripts/init.ps1",
34
+ "scripts/init.sh",
35
+ "templates/plan.md",
36
+ "templates/retrospective.md",
37
+ "templates/specification.md",
38
+ "templates/tasks.md"
39
+ ],
9
40
  "download": {
10
41
  "timeoutMs": 60000,
11
42
  "tempPrefix": "magic-spec-"
@@ -68,6 +68,14 @@ function loadInstallerConfig() {
68
68
  const agentDir = requireNonEmptyString(parsed.agentDir, 'agentDir');
69
69
  const workflowsDir = requireNonEmptyString(parsed.workflowsDir, 'workflowsDir');
70
70
  const defaultExt = requireNonEmptyString(parsed.defaultExt, 'defaultExt');
71
+ const workflows = Array.isArray(parsed.workflows) ? parsed.workflows : null;
72
+ if (!workflows) {
73
+ failConfig("field 'workflows' must be an array of strings");
74
+ }
75
+ const magicFiles = Array.isArray(parsed.magicFiles) ? parsed.magicFiles : null;
76
+ if (!magicFiles) {
77
+ failConfig("field 'magicFiles' must be an array of strings");
78
+ }
71
79
 
72
80
  return {
73
81
  githubRepo,
@@ -77,6 +85,8 @@ function loadInstallerConfig() {
77
85
  agentDir,
78
86
  workflowsDir,
79
87
  defaultExt,
88
+ workflows,
89
+ magicFiles,
80
90
  download: { timeoutMs, tempPrefix },
81
91
  userAgent: { node: nodeUserAgent },
82
92
  ejectTargets: parsed.eject.targets
@@ -90,6 +100,8 @@ const ENGINE_DIR = INSTALLER_CONFIG.engineDir;
90
100
  const AGENT_DIR = INSTALLER_CONFIG.agentDir;
91
101
  const WORKFLOWS_DIR = INSTALLER_CONFIG.workflowsDir;
92
102
  const DEFAULT_EXT = INSTALLER_CONFIG.defaultExt;
103
+ const WORKFLOWS = INSTALLER_CONFIG.workflows;
104
+ const MAGIC_FILES = INSTALLER_CONFIG.magicFiles;
93
105
  const DEFAULT_REMOVE_PREFIX = INSTALLER_CONFIG.removePrefix;
94
106
  const DOWNLOAD_TIMEOUT_MS = INSTALLER_CONFIG.download.timeoutMs;
95
107
  const NODE_USER_AGENT = INSTALLER_CONFIG.userAgent.node;
@@ -123,7 +135,7 @@ function collectEnvValues(argv) {
123
135
  return [...new Set(parsed)];
124
136
  }
125
137
 
126
- const envValues = collectEnvValues(args);
138
+ let envValues = collectEnvValues(args);
127
139
  let selectedEnv = envValues.length > 0 ? envValues[0] : null;
128
140
 
129
141
  function runListEnvs(adapters) {
@@ -143,7 +155,7 @@ function runListEnvs(adapters) {
143
155
  const dest = `${adapter.dest}/`.padEnd(28);
144
156
  console.log(` ${name}${padding}${dest}${adapter.description || ''}`);
145
157
  }
146
- console.log('\nUsage: npx magic-spec@latest --env <name>');
158
+ console.log('\nUsage: npx magic-spec@latest --env <name> OR --<name> (e.g. --cursor)');
147
159
  }
148
160
 
149
161
  function askQuestion(query) {
@@ -197,9 +209,11 @@ function installAdapter(sourceRoot, env, adapters) {
197
209
 
198
210
  fs.mkdirSync(destDir, { recursive: true });
199
211
 
200
- const files = fs.readdirSync(srcDir).filter(f => f.endsWith(DEFAULT_EXT));
201
- for (const file of files) {
212
+ for (const wfName of WORKFLOWS) {
213
+ const file = wfName + DEFAULT_EXT;
202
214
  const srcFile = path.join(srcDir, file);
215
+ if (!fs.existsSync(srcFile)) continue;
216
+
203
217
  let destName = file.replace(new RegExp(`${DEFAULT_EXT.replace('.', '\\.')}$`), adapter.ext);
204
218
  const removePrefix = adapter.hasOwnProperty('removePrefix') ? adapter.removePrefix : DEFAULT_REMOVE_PREFIX;
205
219
  if (removePrefix) {
@@ -646,6 +660,7 @@ async function main() {
646
660
  console.log(" --eject Remove magic-spec from project");
647
661
  console.log("\nOptions:");
648
662
  console.log(" --env <adapter> Specify environment adapter");
663
+ console.log(" --<adapter> Shortcut for --env <adapter> (e.g. --cursor)");
649
664
  console.log(" --update Update engine files only");
650
665
  console.log(" --fallback-main Pull payload from main branch");
651
666
  console.log(" --yes, -y Auto-accept prompts");
@@ -685,6 +700,12 @@ async function main() {
685
700
  }
686
701
 
687
702
  // Determine environment
703
+ for (const env in ADAPTERS) {
704
+ if (args.includes(`--${env}`)) {
705
+ if (!envValues.includes(env)) envValues.push(env);
706
+ }
707
+ }
708
+
688
709
  let selectedEnvResolved = null;
689
710
  if (envValues.length > 0) {
690
711
  selectedEnvResolved = envValues[0];
@@ -719,22 +740,20 @@ async function main() {
719
740
  }
720
741
  }
721
742
 
722
- // 1. Copy .magic
723
- if (conflictsToSkip.length > 0) {
724
- const srcMagic = path.join(sourceRoot, '.magic');
725
- const destMagic = path.join(cwd, '.magic');
726
- const items = fs.readdirSync(srcMagic, { withFileTypes: true });
727
- for (const item of items) {
728
- if (conflictsToSkip.includes(item.name)) continue;
729
- if (item.name === '.checksums') continue;
730
- if (item.isDirectory()) {
731
- copyDir(path.join(srcMagic, item.name), path.join(destMagic, item.name));
732
- } else {
733
- fs.copyFileSync(path.join(srcMagic, item.name), path.join(destMagic, item.name));
734
- }
743
+ // 1. Copy .magic (engine) - selective based on whitelist [T-3A01]
744
+ const srcMagic = path.join(sourceRoot, ENGINE_DIR);
745
+ const destMagic = path.join(cwd, ENGINE_DIR);
746
+ fs.mkdirSync(destMagic, { recursive: true });
747
+
748
+ for (const relPath of MAGIC_FILES) {
749
+ if (conflictsToSkip.includes(relPath)) continue;
750
+
751
+ const srcFile = path.join(srcMagic, relPath);
752
+ const destFile = path.join(destMagic, relPath);
753
+ if (fs.existsSync(srcFile)) {
754
+ fs.mkdirSync(path.dirname(destFile), { recursive: true });
755
+ fs.copyFileSync(srcFile, destFile);
735
756
  }
736
- } else {
737
- copyDir(path.join(sourceRoot, '.magic'), path.join(cwd, '.magic'));
738
757
  }
739
758
 
740
759
  // 2. Adapters
@@ -746,7 +765,30 @@ async function main() {
746
765
  } else if (selectedEnvResolved) {
747
766
  installAdapter(sourceRoot, selectedEnvResolved, ADAPTERS);
748
767
  } else {
749
- copyDir(path.join(sourceRoot, '.agent'), path.join(cwd, '.agent'));
768
+ // Default install
769
+ const srcEng = path.join(sourceRoot, AGENT_DIR);
770
+ const destEng = path.join(cwd, AGENT_DIR);
771
+ fs.mkdirSync(destEng, { recursive: true });
772
+ fs.mkdirSync(path.join(destEng, WORKFLOWS_DIR), { recursive: true });
773
+
774
+ for (const wfName of WORKFLOWS) {
775
+ const file = wfName + DEFAULT_EXT;
776
+ const srcWf = path.join(srcEng, WORKFLOWS_DIR, file);
777
+ if (fs.existsSync(srcWf)) {
778
+ fs.copyFileSync(srcWf, path.join(destEng, WORKFLOWS_DIR, file));
779
+ }
780
+ }
781
+
782
+ // Copy other files in .agent if any (not workflows subfolder which we handled selectively)
783
+ const items = fs.readdirSync(srcEng, { withFileTypes: true });
784
+ for (const item of items) {
785
+ if (item.name === WORKFLOWS_DIR) continue;
786
+ if (item.isDirectory()) {
787
+ copyDir(path.join(srcEng, item.name), path.join(destEng, item.name));
788
+ } else {
789
+ fs.copyFileSync(path.join(srcEng, item.name), path.join(destEng, item.name));
790
+ }
791
+ }
750
792
  }
751
793
  }
752
794
 
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "magic-spec",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Magic Specification-Driven Development (SDD) Workflow",
5
5
  "author": "Oleg Alexandrov <alexandrovoleg.ru@gmail.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/teratron/magic-spec",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/teratron/magic-spec.git"
11
+ },
8
12
  "main": "installers/node/index.js",
9
13
  "bin": {
10
14
  "magic-spec": "installers/node/index.js"