mspec 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **A minimalist Spec-Driven Development (SDD) toolkit for solo developers and AI agents.**
4
4
 
5
- `mspec` is a lightweight alternative to heavy SDD frameworks. It removes the "enterprise theater" (branch-per-feature, complex state files, and heavy daemon processes) and focuses strictly on **intent** (the Spec) and **execution** (the Tasks) using simple Markdown files.
5
+ `mspec` is a lightweight alternative to heavy SDD frameworks like `spec-kit` or `get-shit-done`. It removes the "enterprise theater" (branch-per-feature, complex state files, and heavy daemon processes) and focuses strictly on **intent** (the Spec) and **execution** (the Tasks) using simple Markdown files.
6
6
 
7
7
  It is designed to work seamlessly alongside your favorite AI coding agents: Claude Code, Gemini CLI, Cursor, OpenCode, or Zed.
8
8
 
@@ -10,7 +10,7 @@ It is designed to work seamlessly alongside your favorite AI coding agents: Clau
10
10
  - **Token Efficient:** Uses a single `SPEC.md` for context instead of massive chat histories.
11
11
  - **Visual-First:** Encourages Mermaid.js diagrams over long, confusing paragraphs.
12
12
  - **Data Dictionaries:** Uses simple Markdown tables for data modeling instead of strict, unreadable JSON schemas.
13
- - **Agent Handoff:** You design the spec; the AI breaks down the tasks; the AI implements the tasks sequentially.
13
+ - **Sub-Agent Orchestration:** It instructs your main AI agent to act as an orchestrator, delegating implementation to parallel sub-agents to preserve your context window.
14
14
 
15
15
  ---
16
16
 
@@ -28,13 +28,11 @@ npx mspec <command>
28
28
  npm install -g mspec
29
29
  ```
30
30
 
31
- *(Note: If you are cloning this repository locally for development, run `npm install`, then `npm run build`, and finally `npm link` to make the `mspec` command available globally on your machine).*
32
-
33
31
  ---
34
32
 
35
33
  ## How to Use
36
34
 
37
- The workflow follows a simple three-step loop: **Initialize -> Plan -> Implement**.
35
+ The workflow follows a simple three-step loop: **Initialize -> Plan -> Apply**.
38
36
 
39
37
  ### Step 1: Initialize the Project
40
38
  Run this command in the root of your project:
@@ -43,36 +41,52 @@ npx mspec init
43
41
  ```
44
42
  - It will prompt you for your preferred AI agent (Claude, Gemini, Cursor, etc.).
45
43
  - It will create the `.mspec/specs/` and `.mspec/tasks/` directories.
46
- - It will automatically inject a custom command/instruction file into your project (e.g., `.gemini/commands/mspec.toml` or `.cursor/rules/mspec.mdc`) so your AI agent understands the framework.
44
+ - It will automatically inject custom commands into your project (e.g., `.gemini/commands/mspec.plan.toml` or `.cursor/rules/mspec.apply.mdc`) so your AI agent natively understands the framework and provides autocomplete commands like `/mspec.spec`.
45
+
46
+ *(Note: After running `init`, you may need to restart your AI agent session so it can detect the new slash commands).*
47
47
 
48
48
  ### Step 2: The Inquiry (Creating a Spec)
49
- Talk to your AI agent and ask it to draft a specification using the `mspec` standard.
49
+ Use the native slash command in your AI agent to start drafting a specification.
50
50
 
51
- **Example Prompt to your AI:**
52
- > "Let's create a spec for a new authentication feature. Save it to `.mspec/specs/001-auth.md`. Include a markdown description, a mermaid sequence diagram for login, and a markdown data dictionary for the user object."
51
+ **Command:**
52
+ ```text
53
+ /mspec.spec Let's create a spec for a new authentication feature.
54
+ ```
55
+ - **Context Gathering:** The AI will automatically look at your existing codebase to understand your current architecture before answering.
56
+ - **The Inquiry:** It will stop and ask you targeted questions about edge cases, data models, and logic.
57
+ - **Drafting:** After you answer, it will generate a highly structured `.mspec/specs/001-auth.md` file featuring a Mermaid diagram and an Acceptance Criteria checklist.
58
+ - It will output the file path for your review and wait for you to say **"Approved"** or **"LGTM"** before automatically offering the next command.
53
59
 
54
60
  ### Step 3: Scaffold the Plan
55
- Once you are happy with the `001-auth.md` spec, run:
56
- ```bash
57
- npx mspec plan 001-auth
61
+ Once you are happy with the spec, use the planning command to break it down.
62
+
63
+ **Command:**
64
+ ```text
65
+ /mspec.plan
58
66
  ```
59
- - This validates that the spec exists.
60
- - It generates a boilerplate `.mspec/tasks/001-auth.tasks.md` file containing strict instructions for the AI.
61
- - **Next Action:** Tell your AI agent: *"Please read the spec and fill out the tasks file for 001-auth."* The AI will break the spec down into granular checkboxes.
67
+ - If you don't provide a spec name, the AI will ask you which spec you want to plan.
68
+ - **Sequencing:** The AI will read the spec and create a strict, logically sequenced checklist in `.mspec/tasks/001-auth.tasks.md` (Data -> Logic -> UI -> Edge Cases -> Automated Tests).
69
+ - It will show you the exact file path so you can review the generated tasks and ask for your approval before proceeding.
62
70
 
63
71
  ### Step 4: Implement and Execute
64
- Once the checklist is generated, it's time to hand the wheel over to the AI.
65
- ```bash
66
- npx mspec implement 001-auth
72
+ Once the checklist is generated, hand the wheel over to the AI to orchestrate the implementation.
73
+
74
+ **Command:**
75
+ ```text
76
+ /mspec.apply
67
77
  ```
68
- - This command analyzes the task list.
69
- - It outputs a highly structured prompt to your terminal.
70
- - **Next Action:** Copy the outputted prompt and paste it to your AI agent.
71
- - *What the AI does:* It will read the `.tasks.md` file, pick the first unchecked `- [ ]` task, implement the code, run your tests, change the checkbox to `- [x]`, and then **stop** to wait for your review.
78
+ - **Sub-Agent Delegation:** To prevent context bloat, the AI will read the first `- [ ]` task and delegate the actual coding to a sub-agent.
79
+ - **Parallelization:** If tasks are independent (e.g., backend and frontend), it will spawn multiple sub-agents to execute them simultaneously!
80
+ - **Empirical Verification:** The sub-agent will write the code, autonomously run your tests/linters, fix any errors, and only report back when the build is green.
81
+ - It will change the checkbox to `- [x]` and stop to wait for your review.
72
82
 
73
- #### Batch Execution
74
- If you trust the AI and want it to burn through the whole checklist without stopping for your approval between tasks, use the `--batch` flag:
83
+ #### Terminal Execution (Optional)
84
+ If you prefer, you can use the terminal CLI to generate a strict execution prompt that you can paste to your AI:
75
85
  ```bash
86
+ # Generate the prompt for one-by-one execution
87
+ npx mspec implement 001-auth
88
+
89
+ # Generate the prompt for batch execution (don't stop for review)
76
90
  npx mspec implement 001-auth --batch
77
91
  ```
78
92
 
@@ -89,6 +103,11 @@ your-project/
89
103
  │ │ └── 001-auth.md # The "Intent" (Markdown/Mermaid)
90
104
  │ └── tasks/
91
105
  │ └── 001-auth.tasks.md # The "Execution" (Checklists)
106
+ ├── .gemini/ # (Or .claude / .cursor depending on your agent)
107
+ │ └── commands/
108
+ │ ├── mspec.spec.toml
109
+ │ ├── mspec.plan.toml
110
+ │ └── mspec.apply.toml
92
111
  ├── src/ # Your actual code
93
112
  └── package.json
94
113
  ```
@@ -33,12 +33,13 @@ async function implementCommand(specName, options) {
33
33
  const isBatch = options.batch === true;
34
34
  const executionPrompt = `> **mspec execution directive:**
35
35
  > Please read \`.mspec/tasks/${specName}.tasks.md\`.
36
- > 1. Find the first incomplete task marked with \`- [ ]\`.
37
- > 2. Implement the requirements for that specific task.
38
- > 3. Verify your implementation (run tests/build).
39
- > 4. If successful, change the task to \`- [x]\` in the file.
40
- > 5. ${isBatch
41
- ? 'Continue to the next task until all tasks in the current phase are complete.'
36
+ > 1. Analyze the incomplete tasks marked with \`- [ ]\`.
37
+ > 2. CRITICAL: Delegate the actual coding to a sub-agent to preserve your context.
38
+ > 3. If tasks are independent (e.g., backend/frontend), run multiple sub-agents in parallel. Otherwise, pick the first task.
39
+ > 4. Instruct the sub-agent to implement the task, empirically verify it (run tests/build), and fix errors autonomously.
40
+ > 5. Once the sub-agent succeeds, change the task to \`- [x]\` in the file.
41
+ > 6. ${isBatch
42
+ ? 'Continue delegating the next task(s) until all tasks in the current phase are complete.'
42
43
  : 'Stop and wait for my approval before moving to the next task.'}`;
43
44
  // 4. Output the prompt
44
45
  console.log(chalk_1.default.magenta('\n=== Copy the text below and paste it to your AI agent ===\n'));
@@ -78,7 +78,7 @@ describe('implementCommand', () => {
78
78
  expect(mockExit).not.toHaveBeenCalled();
79
79
  const promptOutput = mockConsoleLog.mock.calls[1][0];
80
80
  expect(promptOutput).toContain('mspec execution directive:');
81
- expect(promptOutput).toContain('Continue to the next task until all tasks');
81
+ expect(promptOutput).toContain('Continue delegating the next task(s) until all tasks');
82
82
  });
83
83
  it('should support nested spec names like feature/001-auth', async () => {
84
84
  const tasksDir = path_1.default.join(tmpDir, '.mspec', 'tasks', 'feature');
@@ -28,10 +28,10 @@ describe('initCommand', () => {
28
28
  jest.restoreAllMocks();
29
29
  });
30
30
  const providers = [
31
- { agent: 'claude', expectedFiles: ['.claude/commands/mspec.spec.md', '.claude/commands/mspec.plan.md', '.claude/commands/mspec.apply.md'] },
32
- { agent: 'gemini', expectedFiles: ['.gemini/commands/mspec.spec.toml', '.gemini/commands/mspec.plan.toml', '.gemini/commands/mspec.apply.toml'] },
33
- { agent: 'cursor', expectedFiles: ['.cursor/rules/mspec.spec.mdc', '.cursor/rules/mspec.plan.mdc', '.cursor/rules/mspec.apply.mdc'] },
34
- { agent: 'opencode', expectedFiles: ['.opencode/commands/mspec.spec.md', '.opencode/commands/mspec.plan.md', '.opencode/commands/mspec.apply.md'] },
31
+ { agent: 'claude', expectedFiles: ['.claude/commands/mspec.spec.md', '.claude/commands/mspec.plan.md', '.claude/commands/mspec.implement.md'] },
32
+ { agent: 'gemini', expectedFiles: ['.gemini/commands/mspec.spec.toml', '.gemini/commands/mspec.plan.toml', '.gemini/commands/mspec.implement.toml'] },
33
+ { agent: 'cursor', expectedFiles: ['.cursor/rules/mspec.spec.mdc', '.cursor/rules/mspec.plan.mdc', '.cursor/rules/mspec.implement.mdc'] },
34
+ { agent: 'opencode', expectedFiles: ['.opencode/commands/mspec.spec.md', '.opencode/commands/mspec.plan.md', '.opencode/commands/mspec.implement.md'] },
35
35
  { agent: 'zed', expectedFiles: ['.mspec/INSTRUCTIONS.md'] },
36
36
  { agent: 'generic', expectedFiles: ['.mspec/INSTRUCTIONS.md'] }
37
37
  ];
@@ -2,55 +2,140 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.templates = void 0;
4
4
  exports.getTemplates = getTemplates;
5
- const commands = [
6
- { name: 'mspec.spec', desc: 'Create a new spec' },
7
- { name: 'mspec.plan', desc: 'Plan tasks for a spec' },
8
- { name: 'mspec.apply', desc: 'Implement tasks for a spec' }
9
- ];
5
+ const commandPrompts = {
6
+ 'mspec.spec': {
7
+ desc: 'Start an inquiry to create a new spec',
8
+ prompt: `You are an AI Spec Architect using the mspec framework.
9
+ When asked to /mspec.spec, follow this strict protocol:
10
+
11
+ PHASE 0: CONTEXT GATHERING
12
+ 1. Briefly analyze the project's current tech stack, existing data models, and architectural patterns. Do not guess.
13
+
14
+ PHASE 1: INQUIRY
15
+ 2. DO NOT generate the specification file immediately.
16
+ 3. Ask the user 3-5 targeted questions to clarify the feature, incorporating any context you found in Phase 0. To build a strong spec, you must extract:
17
+ - Core Objective: What is the exact goal and business logic?
18
+ - Edge Cases & Error Handling: What happens on failure, empty states, or invalid input?
19
+ - Data Structures: What exact fields, types, and constraints are required?
20
+ - Dependencies: Does this rely on external APIs, existing UI components, or specific libraries?
21
+ 4. Wait for the user to answer. Iterate if necessary until ambiguity is eliminated.
22
+
23
+ PHASE 2: DRAFTING
24
+ 5. Generate the spec file in .mspec/specs/ using the exact filename requested or a logical slug (e.g., 001-auth.md).
25
+ 6. The spec MUST strictly follow this structure:
26
+ # Spec: [Feature Name]
27
+ ## 1. Goal & Context
28
+ (Clear explanation of the feature and business value)
29
+ ## 2. Logic Flow
30
+ (A Mermaid.js sequenceDiagram or stateDiagram-v2 mapping the exact logic, error states, and system boundaries)
31
+ ## 3. Data Dictionary
32
+ (A Markdown table defining schemas: Field | Type | Description | Constraints)
33
+ ## 4. Edge Cases & Error Handling
34
+ (Explicit list of what can go wrong and how the system should react)
35
+ ## 5. Acceptance Criteria
36
+ (Checklist of what must be true for this feature to be considered complete)
37
+
38
+ PHASE 3: REVIEW
39
+ 7. AFTER generating the spec file, ask the user for confirmation. DO NOT consider the task completed until the user explicitly replies with "Approved" or "LGTM".
40
+ 8. If the user provides feedback, revise the spec and ask for confirmation again.
41
+ 9. Once approved, output the exact path to the generated spec file so the user can easily open it.
42
+ 10. Finally, offer to move to the next phase by asking: "Would you like me to generate the implementation tasks now using /mspec.plan [spec-name]?"`
43
+ },
44
+ 'mspec.plan': {
45
+ desc: 'Plan tasks for an existing spec',
46
+ prompt: `You are an AI Technical Lead using the mspec framework.
47
+ When asked to /mspec.plan, follow this strict protocol:
48
+
49
+ PHASE 0: SPEC COMPREHENSION
50
+ 1. First, determine which spec the user wants to plan. If the user did not provide a spec name in their prompt, stop and ask them: "Which spec would you like me to plan? (e.g., 001-auth)". DO NOT GUESS.
51
+ 2. Once the spec is identified, check if the file exists in .mspec/specs/.
52
+ 3. Read the specification file thoroughly. Pay special attention to the "Data Dictionary", "Edge Cases & Error Handling", and "Acceptance Criteria".
53
+
54
+ PHASE 1: TASK BREAKDOWN & SEQUENCING
55
+ 4. Break the requirements down into atomic, actionable tasks. A task should be small enough to be implemented in a single step.
56
+ 5. Sequence the tasks logically to avoid dependency blockers. Use this recommended standard order:
57
+ - Phase 1: Data Models & Types (Interfaces, schemas, database migrations)
58
+ - Phase 2: Core Logic & State (API routes, services, state management)
59
+ - Phase 3: UI & Integration (Components, wiring up data to views)
60
+ - Phase 4: Edge Cases & Error Handling (Implementing specific failure states from the spec)
61
+ - Phase 5: Automated Testing & Validation (Writing unit/integration tests to satisfy the Acceptance Criteria)
62
+ 6. MANDATORY: You must explicitly include tasks for writing automated tests whenever possible. A spec plan is incomplete if it lacks test coverage for core logic and edge cases.
63
+
64
+ PHASE 2: DRAFTING
65
+ 7. Write the tasks as a markdown checklist (- [ ]) grouped by the phases above.
66
+ 8. Make tasks explicit. Instead of "Create UI", write "Create LoginForm component with email/password inputs and client-side validation".
67
+ 9. Create a new file in .mspec/tasks/ using the same name as the spec but with the .tasks.md extension.
68
+ 10. Save the generated checklist into this new file.
69
+
70
+ PHASE 3: REVIEW & HANDOFF
71
+ 11. Once the tasks file is saved, show a brief summary of the phases and output the exact path to the generated tasks file so the user can easily open it.
72
+ 12. Ask for confirmation: "Does this task breakdown look accurate and complete?"
73
+ 13. Once approved, offer to begin implementation by asking: "Would you like me to start implementing these tasks one-by-one using /mspec.implement [spec-name]?"`
74
+ },
75
+ 'mspec.implement': {
76
+ desc: 'Implement tasks from a checklist using sub-agents',
77
+ prompt: `You are a Senior Software Engineer and Orchestrator using the mspec framework.
78
+ When asked to /mspec.implement, follow this strict Execution Loop:
79
+
80
+ PHASE 0: TASK IDENTIFICATION
81
+ 1. First, determine which tasks file the user wants to implement. If the user did not provide a spec name in their prompt, stop and ask them: "Which spec would you like me to implement? (e.g., 001-auth)". DO NOT GUESS.
82
+ 2. Once identified, read the corresponding tasks file in .mspec/tasks/.
83
+
84
+ PHASE 1: DELEGATION STRATEGY
85
+ 3. Analyze the incomplete tasks marked with '- [ ]'.
86
+ 4. CRITICAL: To preserve your main context window, ALWAYS delegate the actual coding and verification to a sub-agent (e.g., 'generalist' or equivalent coding tool). Do not write the code directly in your main loop.
87
+ 5. Identify if there are multiple independent tasks (e.g., frontend component vs backend database migration). If so, spawn multiple sub-agents in parallel to execute them.
88
+ 6. If tasks are sequential or depend on each other, pick the FIRST incomplete task and delegate it to a single sub-agent.
89
+
90
+ PHASE 2: EXECUTION (Handled by Sub-Agent)
91
+ 7. Instruct your sub-agent with a strict prompt to:
92
+ - Investigate the codebase for established patterns.
93
+ - Implement the specific task adhering to high standards (strict typing, DRY, tightly scoped).
94
+ - EMPIRICALLY VERIFY the work (run build, linters, tests).
95
+ - Diagnose and fix any errors autonomously until tests pass.
96
+
97
+ PHASE 3: CHECKPOINT
98
+ 8. Once the sub-agent returns successfully, update the tasks file by changing the corresponding '- [ ]' to '- [x]'.
99
+ 9. Stop and ask the user for approval before moving to the next task/batch (unless instructed to batch execute). Briefly summarize what the sub-agent accomplished.
100
+ 10. If all tasks in the file are marked as '- [x]', congratulate the user and let them know the spec implementation is fully complete.`
101
+ }
102
+ };
10
103
  exports.templates = {
11
- claude: commands.map(cmd => ({
104
+ claude: Object.entries(commandPrompts).map(([name, data]) => ({
12
105
  dir: '.claude/commands',
13
- file: `${cmd.name}.md`,
106
+ file: `${name}.md`,
14
107
  content: `---
15
- description: "${cmd.desc} using mspec"
108
+ description: "${data.desc}"
16
109
  ---
17
- You are an AI assistant using the mspec framework.
18
- When asked to /${cmd.name}, follow the minimalist spec-driven development guidelines.
19
- Specs are in .mspec/specs. Tasks are in .mspec/tasks.
110
+ ${data.prompt}
20
111
  `
21
112
  })),
22
- gemini: commands.map(cmd => ({
113
+ gemini: Object.entries(commandPrompts).map(([name, data]) => ({
23
114
  dir: '.gemini/commands',
24
- file: `${cmd.name}.toml`,
25
- content: `description = "${cmd.desc} using mspec"
115
+ file: `${name}.toml`,
116
+ content: `description = "${data.desc}"
26
117
  prompt = """
27
- You are an AI assistant using the mspec framework.
28
- When asked to /${cmd.name}, follow the minimalist spec-driven development guidelines.
29
- Specs are in .mspec/specs. Tasks are in .mspec/tasks.
118
+ ${data.prompt}
30
119
  """
31
120
  `
32
121
  })),
33
- cursor: commands.map(cmd => ({
122
+ cursor: Object.entries(commandPrompts).map(([name, data]) => ({
34
123
  dir: '.cursor/rules',
35
- file: `${cmd.name}.mdc`,
124
+ file: `${name}.mdc`,
36
125
  content: `---
37
- description: ${cmd.desc} using mspec
126
+ description: ${data.desc}
38
127
  globs: *
39
128
  ---
40
- You are an AI assistant using the mspec framework.
41
- When asked to /${cmd.name}, follow the minimalist spec-driven development guidelines.
42
- Specs are in .mspec/specs. Tasks are in .mspec/tasks.
129
+ ${data.prompt}
43
130
  `
44
131
  })),
45
- opencode: commands.map(cmd => ({
132
+ opencode: Object.entries(commandPrompts).map(([name, data]) => ({
46
133
  dir: '.opencode/commands',
47
- file: `${cmd.name}.md`,
134
+ file: `${name}.md`,
48
135
  content: `---
49
- description: "${cmd.desc} using mspec"
136
+ description: "${data.desc}"
50
137
  ---
51
- You are an AI assistant using the mspec framework.
52
- When asked to /${cmd.name}, follow the minimalist spec-driven development guidelines.
53
- Specs are in .mspec/specs. Tasks are in .mspec/tasks.
138
+ ${data.prompt}
54
139
  `
55
140
  })),
56
141
  zed: [{
@@ -58,9 +143,7 @@ Specs are in .mspec/specs. Tasks are in .mspec/tasks.
58
143
  file: 'INSTRUCTIONS.md',
59
144
  content: `# mspec Instructions
60
145
 
61
- You are an AI assistant using the mspec framework.
62
- When asked to /mspec.spec, /mspec.plan, or /mspec.apply, follow the minimalist spec-driven development guidelines.
63
- Specs are in .mspec/specs. Tasks are in .mspec/tasks.
146
+ ${Object.entries(commandPrompts).map(([name, data]) => `## ${name}\n${data.prompt}`).join('\n\n')}
64
147
  `
65
148
  }],
66
149
  generic: [{
@@ -68,9 +151,7 @@ Specs are in .mspec/specs. Tasks are in .mspec/tasks.
68
151
  file: 'INSTRUCTIONS.md',
69
152
  content: `# mspec Instructions
70
153
 
71
- You are an AI assistant using the mspec framework.
72
- When asked to /mspec.spec, /mspec.plan, or /mspec.apply, follow the minimalist spec-driven development guidelines.
73
- Specs are in .mspec/specs. Tasks are in .mspec/tasks.
154
+ ${Object.entries(commandPrompts).map(([name, data]) => `## ${name}\n${data.prompt}`).join('\n\n')}
74
155
  `
75
156
  }]
76
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mspec",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A minimalist Spec-Driven Development (SDD) toolkit for solo developers and AI agents",
5
5
  "main": "index.js",
6
6
  "scripts": {