sdd-flow 1.2.4 → 1.2.5

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
@@ -1,83 +1,85 @@
1
- # sdd-flow
2
-
3
- Spec Driven Development workflow for AI-assisted development.
4
-
5
- Installs a structured **Research → Plan → Implement → Validate** cycle into any project, powered by markdown artifacts and isolated agent sessions.
6
-
7
- Works with Claude Code, OpenCode, Cursor, Codex CLI, and any agentic IDE with filesystem access.
8
-
9
- ---
10
-
11
- ## Install
12
-
13
- ```bash
14
- npm install -g sdd-flow
15
- ```
16
-
17
- ---
18
-
19
- ## Usage
20
-
21
- ```bash
22
- sdd init # Instala o workflow no projeto atual
23
- sdd harness # Instala, troca ou remove o harness do agente
24
- sdd update # Atualiza prompts e regras, preserva dados do projeto
25
- sdd --version
26
- ```
27
-
28
- > Alias disponível: use `sdd` ou `sdd-cli` — ambos funcionam.
29
-
30
- ### New or existing project
31
-
32
- ```bash
33
- cd my-project
34
- sdd init
35
- ```
36
-
37
- Installs the `agents/` folder with all workflow files. Optionally installs safety hooks and slash commands for your agent (Claude Code or OpenCode).
38
-
39
- ### Add or switch harness after init
40
-
41
- ```bash
42
- sdd harness
43
- ```
44
-
45
- Installs, replaces, or removes the harness and slash commands at any time — no need to reinstall the package.
46
-
47
- ### Update workflow (preserves your project data)
48
-
49
- ```bash
50
- sdd update
51
- ```
52
-
53
- Updates `AGENTS.md`, `RULES.md`, `QUICKSTART.md`, and all prompts. Your `PROJECT.md`, `DECISIONS.md`, `skills/`, `specs/`, and `harness/` are never touched.
54
-
55
- ---
56
-
57
- ## After `init`
58
-
59
- 1. Open a new session with your agent
60
- 2. Instruct: *"Read and follow `agents/SETUP.md`"*
61
- 3. Provide your PRD or describe the project
62
- 4. Review the generated files and delete `agents/SETUP.md`
63
-
64
- ---
65
-
66
- ## The RPI Cycle
67
-
68
- Each feature goes through four isolated phases, each in its own agent session:
69
-
70
- | Phase | Slash command | Prompt file |
71
- |---|---|---|
72
- | Research | `/sdd-research 001-feature` | `agents/prompts/rpi-research.md` |
73
- | Plan | `/sdd-plan 001-feature` | `agents/prompts/rpi-plan.md` |
74
- | Implement | `/sdd-implement 001-feature` | `agents/prompts/rpi-implement.md` |
75
- | Validate | `/sdd-validate 001-feature` | `agents/prompts/rpi-validate.md` |
76
-
77
- > Slash commands require harness installation (`sdd harness`).
78
-
79
- ---
80
-
81
- ## Source
82
-
83
- [github.com/moisesuailab/spec-driven-workflow](https://github.com/moisesuailab/spec-driven-workflow)
1
+ # sdd-flow
2
+
3
+ Spec Driven Development workflow for AI-assisted development.
4
+
5
+ Installs a structured **Research → Plan → Implement → Validate** cycle into any project, powered by markdown artifacts and isolated agent sessions.
6
+
7
+ Works with Claude Code, OpenCode, Cursor, Codex CLI, and any agentic IDE with filesystem access.
8
+
9
+ ---
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install -g sdd-flow
15
+ ```
16
+
17
+ ---
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ sdd init # Installs the workflow into the current project
23
+ sdd new <name> # Creates a spec folder with auto-numbering
24
+ sdd harness # Installs, switches, or removes the agent harness
25
+ sdd update # Updates prompts and rules, preserves project data
26
+ sdd --version
27
+ ```
28
+
29
+ > Alias available: use `sdd` or `sdd-cli` — both work.
30
+
31
+ ---
32
+
33
+ ## After `init`
34
+
35
+ Open a new session with your agent and instruct:
36
+
37
+ ```
38
+ "Read and follow agents/SETUP.md"
39
+ ```
40
+
41
+ - **New project:** describe the project or provide a PRD — the agent generates PROJECT.md and skills
42
+ - **Existing project:** the agent scans the codebase automatically
43
+
44
+ Review the generated files and delete `agents/SETUP.md`.
45
+
46
+ ---
47
+
48
+ ## Add or switch harness after init
49
+
50
+ ```bash
51
+ sdd harness
52
+ ```
53
+
54
+ Installs, replaces, or removes the harness and slash commands at any time.
55
+
56
+ ---
57
+
58
+ ## Update workflow (preserves your project data)
59
+
60
+ ```bash
61
+ sdd update
62
+ ```
63
+
64
+ Updates `AGENTS.md`, `RULES.md`, `QUICKSTART.md`, and all prompts. Your `PROJECT.md`, `DECISIONS.md`, `skills/`, `specs/`, and `harness/` are never touched.
65
+
66
+ ---
67
+
68
+ ## The RPI Cycle
69
+
70
+ Each feature goes through four isolated phases, each in its own agent session:
71
+
72
+ | Phase | Slash command | Prompt file |
73
+ |---|---|---|
74
+ | Research | `/sdd-research 001-feature` | `agents/prompts/rpi-research.md` |
75
+ | Plan | `/sdd-plan 001-feature` | `agents/prompts/rpi-plan.md` |
76
+ | Implement | `/sdd-implement 001-feature` | `agents/prompts/rpi-implement.md` |
77
+ | Validate | `/sdd-validate 001-feature` | `agents/prompts/rpi-validate.md` |
78
+
79
+ > Slash commands require harness installation (`sdd harness`).
80
+
81
+ ---
82
+
83
+ ## Source
84
+
85
+ [github.com/moisesuailab/spec-driven-workflow](https://github.com/moisesuailab/spec-driven-workflow)
package/bin/cli.js CHANGED
@@ -1,380 +1,381 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
4
-
5
- const fs = require('fs');
6
- const path = require('path');
7
- const rl = require('readline');
8
-
9
- const TEMPLATES = path.join(__dirname, '..', 'templates');
10
- const CWD = process.cwd();
11
- const VERSION = require('../package.json').version;
12
- const useColor = process.stdout.isTTY && !process.env.NO_COLOR;
13
-
14
- const c = useColor
15
- ? { reset: '\x1b[0m', bold: '\x1b[1m', green: '\x1b[32m',
16
- yellow: '\x1b[33m', cyan: '\x1b[36m', red: '\x1b[31m', dim: '\x1b[2m' }
17
- : { reset: '', bold: '', green: '', yellow: '', cyan: '', red: '', dim: '' };
18
-
19
- const log = (msg = '') => console.log(msg);
20
- const ok = (msg) => console.log(`${c.green}✔${c.reset} ${msg}`);
21
- const warn = (msg) => console.log(`${c.yellow}⚠${c.reset} ${msg}`);
22
- const info = (msg) => console.log(`${c.cyan}ℹ${c.reset} ${msg}`);
23
- const error = (msg) => console.log(`${c.red}✖${c.reset} ${msg}`);
24
- const bold = (msg) => `${c.bold}${msg}${c.reset}`;
25
- const dim = (msg) => `${c.dim}${msg}${c.reset}`;
26
-
27
- function ask(prompt) {
28
- const iface = rl.createInterface({ input: process.stdin, output: process.stdout });
29
- return new Promise(resolve =>
30
- iface.question(prompt, answer => { iface.close(); resolve(answer.trim()); })
31
- );
32
- }
33
-
34
- function copy(src, dest) {
35
- fs.mkdirSync(path.dirname(dest), { recursive: true });
36
- fs.copyFileSync(src, dest);
37
- }
38
-
39
- function copyDir(src, dest, exclude = []) {
40
- fs.mkdirSync(dest, { recursive: true });
41
- for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
42
- if (exclude.includes(entry.name)) continue;
43
- const srcPath = path.join(src, entry.name);
44
- const destPath = path.join(dest, entry.name);
45
- entry.isDirectory() ? copyDir(srcPath, destPath) : copy(srcPath, destPath);
46
- }
47
- }
48
-
49
- const HARNESS_CONFIG = {
50
- '2': {
51
- name: 'claude-code',
52
- commandsDest: path.join(CWD, '.claude', 'commands'),
53
- },
54
- '3': {
55
- name: 'opencode',
56
- commandsDest: path.join(CWD, '.opencode', 'commands'),
57
- },
58
- };
59
-
60
- function showSlashCommands() {
61
- log(bold('Slash commands disponíveis:'));
62
- log(` ${c.cyan}/sdd-research${c.reset} 001-nome-da-feature`);
63
- log(` ${c.cyan}/sdd-plan${c.reset} 001-nome-da-feature`);
64
- log(` ${c.cyan}/sdd-implement${c.reset} 001-nome-da-feature`);
65
- log(` ${c.cyan}/sdd-validate${c.reset} 001-nome-da-feature`);
66
- }
67
-
68
- function removeSddCommands(commandsDest) {
69
- if (!fs.existsSync(commandsDest)) return;
70
- for (const f of fs.readdirSync(commandsDest)) {
71
- if (f.startsWith('sdd-')) fs.rmSync(path.join(commandsDest, f));
72
- }
73
- }
74
-
75
- async function init() {
76
- log();
77
- log(bold('sdd-cli') + dim(' — Spec Driven Development workflow'));
78
- log();
79
-
80
- const agentsDir = path.join(CWD, 'agents');
81
- if (fs.existsSync(agentsDir)) {
82
- warn('A pasta agents/ já existe neste projeto.');
83
- const answer = await ask(' Deseja sobrescrever os arquivos do workflow? (s/N) ');
84
- if (answer.toLowerCase() !== 's') {
85
- info('Operação cancelada. Use ' + bold('sdd update') + ' para atualizar prompts e regras.');
86
- log();
87
- process.exit(0);
88
- }
89
- log();
90
- }
91
-
92
- copy(path.join(TEMPLATES, 'AGENTS.md'), path.join(CWD, 'AGENTS.md'));
93
- ok('AGENTS.md criado na raiz do projeto');
94
-
95
- copy(path.join(TEMPLATES, 'QUICKSTART.md'), path.join(CWD, 'QUICKSTART.md'));
96
- ok('QUICKSTART.md criado na raiz do projeto');
97
-
98
- copyDir(path.join(TEMPLATES, 'agents'), agentsDir, ['harness']);
99
- ok('Workflow instalado em agents/');
100
-
101
- log();
102
- info('O harness instala hooks de segurança e slash commands ' + dim('(opcional)'));
103
- log(' 1) Pular esta etapa');
104
- log(' 2) Claude Code');
105
- log(' 3) OpenCode');
106
- const choice = await ask(' Escolha [1]: ');
107
-
108
- const harnessCfg = HARNESS_CONFIG[choice];
109
- let harnessInstalled = false;
110
-
111
- if (harnessCfg) {
112
- const { name, commandsDest } = harnessCfg;
113
- const harnessSrc = path.join(TEMPLATES, 'agents', 'harness', name);
114
-
115
- if (fs.existsSync(harnessSrc)) {
116
- copyDir(harnessSrc, path.join(agentsDir, 'harness', name), ['commands']);
117
- ok(`Harness instalado: ${name}`);
118
-
119
- const cmdSrc = path.join(harnessSrc, 'commands');
120
- if (fs.existsSync(cmdSrc)) {
121
- copyDir(cmdSrc, commandsDest);
122
- ok(`Slash commands instalados em ${path.relative(CWD, commandsDest)}/`);
123
- }
124
-
125
- harnessInstalled = true;
126
- } else {
127
- warn(`Harness "${name}" não encontrado. Use sdd harness para instalar depois.`);
128
- }
129
- } else {
130
- info('Harness ignorado. Use ' + bold('sdd harness') + ' para instalar depois.');
131
- }
132
-
133
- log();
134
- log(bold('Próximos passos:'));
135
- log(` ${c.cyan}1.${c.reset} Abra uma sessão do seu agente no projeto`);
136
- log(` ${c.cyan}2.${c.reset} Instrua: ${dim('"Leia e siga agents/SETUP.md"')}`);
137
- log(` ${c.cyan}3.${c.reset} Forneça seu PRD ou descreva o projeto`);
138
- log(` ${c.cyan}4.${c.reset} Revise os arquivos gerados e delete agents/SETUP.md`);
139
- log();
140
-
141
- if (harnessInstalled) {
142
- showSlashCommands();
143
- } else {
144
- log(dim(' Sem slash commands — consulte QUICKSTART.md para instruções manuais.'));
145
- log(dim(' Para instalar depois: sdd harness'));
146
- }
147
-
148
- log();
149
- log(dim(' Documentação: https://github.com/moisesuailab/spec-driven-workflow'));
150
- log();
151
- }
152
-
153
- async function harness() {
154
- log();
155
- log(bold('sdd harness'));
156
- log();
157
-
158
- const agentsDir = path.join(CWD, 'agents');
159
- if (!fs.existsSync(agentsDir)) {
160
- error('Pasta agents/ não encontrada. Rode ' + bold('sdd init') + ' primeiro.');
161
- log();
162
- process.exit(1);
163
- }
164
-
165
- info('O que deseja fazer?');
166
- log(' 1) Remover harness atual');
167
- log(' 2) Instalar / trocar para Claude Code');
168
- log(' 3) Instalar / trocar para OpenCode');
169
- const choice = await ask(' Escolha: ');
170
-
171
- if (choice === '1') {
172
- const harnessDir = path.join(agentsDir, 'harness');
173
- if (fs.existsSync(harnessDir)) {
174
- fs.rmSync(harnessDir, { recursive: true });
175
- ok('Hooks removidos de agents/harness/');
176
- }
177
- for (const cfg of Object.values(HARNESS_CONFIG)) {
178
- removeSddCommands(cfg.commandsDest);
179
- if (fs.existsSync(cfg.commandsDest)) {
180
- ok(`Slash commands removidos de ${path.relative(CWD, cfg.commandsDest)}/`);
181
- }
182
- }
183
- log();
184
- ok('Harness desinstalado.');
185
- log();
186
- return;
187
- }
188
-
189
- const harnessCfg = HARNESS_CONFIG[choice];
190
- if (!harnessCfg) {
191
- info('Operação cancelada.');
192
- log();
193
- process.exit(0);
194
- }
195
-
196
- const { name, commandsDest } = harnessCfg;
197
- const harnessSrc = path.join(TEMPLATES, 'agents', 'harness', name);
198
-
199
- if (!fs.existsSync(harnessSrc)) {
200
- error(`Harness "${name}" não encontrado nos templates.`);
201
- process.exit(1);
202
- }
203
-
204
- for (const cfg of Object.values(HARNESS_CONFIG)) {
205
- removeSddCommands(cfg.commandsDest);
206
- }
207
-
208
- copyDir(harnessSrc, path.join(agentsDir, 'harness', name), ['commands']);
209
- ok(`Harness instalado: ${name}`);
210
-
211
- const cmdSrc = path.join(harnessSrc, 'commands');
212
- if (fs.existsSync(cmdSrc)) {
213
- copyDir(cmdSrc, commandsDest);
214
- ok(`Slash commands instalados em ${path.relative(CWD, commandsDest)}/`);
215
- }
216
-
217
- log();
218
- showSlashCommands();
219
- log();
220
- }
221
-
222
- async function update() {
223
- log();
224
- log(bold('sdd update'));
225
- log();
226
-
227
- const agentsDir = path.join(CWD, 'agents');
228
- if (!fs.existsSync(agentsDir)) {
229
- error('Pasta agents/ não encontrada. Rode ' + bold('sdd init') + ' primeiro.');
230
- log();
231
- process.exit(1);
232
- }
233
-
234
- warn('Isso atualizará AGENTS.md, RULES.md, QUICKSTART.md e todos os prompts.');
235
- const answer = await ask(' Deseja continuar? (s/N) ');
236
- if (answer.toLowerCase() !== 's') {
237
- info('Operação cancelada.');
238
- log();
239
- process.exit(0);
240
- }
241
- log();
242
-
243
- const coreFiles = [
244
- { rel: ['AGENTS.md'], dest: path.join(CWD, 'AGENTS.md') },
245
- { rel: ['QUICKSTART.md'], dest: path.join(CWD, 'QUICKSTART.md') },
246
- { rel: ['agents', 'AGENTS.md'], dest: path.join(agentsDir, 'AGENTS.md') },
247
- { rel: ['agents', 'RULES.md'], dest: path.join(agentsDir, 'RULES.md') },
248
- ];
249
-
250
- for (const { rel, dest } of coreFiles) {
251
- copy(path.join(TEMPLATES, ...rel), dest);
252
- ok(`Atualizado: ${rel.join('/')}`);
253
- }
254
-
255
- copyDir(
256
- path.join(TEMPLATES, 'agents', 'prompts'),
257
- path.join(agentsDir, 'prompts')
258
- );
259
- ok('Atualizado: agents/prompts/');
260
-
261
- log();
262
- info('Preservados (dados do projeto):');
263
- ['agents/PROJECT.md', 'agents/DECISIONS.md', 'agents/skills/', 'agents/specs/', 'agents/harness/']
264
- .forEach(f => log(` ${dim(f)}`));
265
- log();
266
- ok('Workflow atualizado com sucesso.');
267
- log();
268
- }
269
-
270
- function nextSpecNumber(specsDir) {
271
- if (!fs.existsSync(specsDir)) return '001';
272
- const entries = fs.readdirSync(specsDir, { withFileTypes: true })
273
- .filter(e => e.isDirectory())
274
- .map(e => parseInt(e.name.slice(0, 3), 10))
275
- .filter(n => !isNaN(n));
276
- const max = entries.length ? Math.max(...entries) : 0;
277
- return String(max + 1).padStart(3, '0');
278
- }
279
-
280
- function newSpec(rawName) {
281
- log();
282
- log(bold('sdd new'));
283
- log();
284
-
285
- const agentsDir = path.join(CWD, 'agents');
286
- if (!fs.existsSync(agentsDir)) {
287
- error('Pasta agents/ não encontrada. Rode ' + bold('sdd init') + ' primeiro.');
288
- log();
289
- process.exit(1);
290
- }
291
-
292
- if (!rawName) {
293
- error('Informe o nome da feature: ' + bold('sdd new <nome-da-feature>'));
294
- log(' Exemplo: ' + dim('sdd new user-authentication'));
295
- log();
296
- process.exit(1);
297
- }
298
-
299
- const name = rawName.toLowerCase().trim().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
300
- if (!name) {
301
- error('Nome inválido. Use apenas letras, números e hífens.');
302
- log();
303
- process.exit(1);
304
- }
305
-
306
- const specsDir = path.join(agentsDir, 'specs');
307
- const num = nextSpecNumber(specsDir);
308
- const slug = num + '-' + name;
309
- const specDir = path.join(specsDir, slug);
310
-
311
- if (fs.existsSync(specDir)) {
312
- error('Spec já existe: agents/specs/' + slug + '/');
313
- log();
314
- process.exit(1);
315
- }
316
-
317
- fs.mkdirSync(specDir, { recursive: true });
318
- fs.writeFileSync(
319
- path.join(specDir, 'DECISIONS.md'),
320
- '# DECISIONS — ' + name + '\n\n(decisões arquiteturais registradas durante o ciclo)\n'
321
- );
322
-
323
- ok('Spec criada: agents/specs/' + slug + '/');
324
- log();
325
- log(bold('Próximo passo — inicie a fase de Research:'));
326
- log(' ' + c.cyan + '/sdd-research' + c.reset + ' ' + slug);
327
- log(' ' + dim('"Leia e siga agents/prompts/rpi-research.md. Spec: ' + slug + '"'));
328
- log();
329
- }
330
-
331
- function help() {
332
- log();
333
- log(bold('sdd-cli') + dim(' — Spec Driven Development workflow'));
334
- log();
335
- log('Uso:');
336
- log(` sdd-cli ${c.cyan}init${c.reset} Instala o workflow no projeto atual`);
337
- log(` sdd-cli ${c.cyan}new <nome>${c.reset} Cria pasta da spec com numeração automática`);
338
- log(` sdd-cli ${c.cyan}harness${c.reset} Instala, troca ou remove o harness do agente`);
339
- log(` sdd-cli ${c.cyan}update${c.reset} Atualiza prompts e regras, preserva dados do projeto`);
340
- log(` sdd-cli ${c.cyan}help${c.reset} Exibe esta mensagem`);
341
- log(` sdd-cli ${c.cyan}--version${c.reset} Exibe a versão instalada`);
342
- log();
343
- log(dim(' Alias: sdd init / sdd new / sdd harness / sdd update / sdd help / sdd --version'));
344
- log();
345
- log(dim(' Documentação: https://github.com/moisesuailab/spec-driven-workflow'));
346
- log();
347
- }
348
-
349
- const cmd = process.argv[2];
350
-
351
- switch (cmd) {
352
- case 'init':
353
- init().catch(e => { error(e.message); process.exit(1); });
354
- break;
355
- case 'new':
356
- newSpec(process.argv[3]);
357
- break;
358
- case 'harness':
359
- harness().catch(e => { error(e.message); process.exit(1); });
360
- break;
361
- case 'update':
362
- update().catch(e => { error(e.message); process.exit(1); });
363
- break;
364
- case 'help':
365
- case '--help':
366
- case '-h':
367
- help();
368
- break;
369
- case '--version':
370
- case '-v':
371
- log(VERSION);
372
- break;
373
- case undefined:
374
- help();
375
- break;
376
- default:
377
- error(`Comando desconhecido: "${cmd}"`);
378
- help();
379
- process.exit(1);
380
- }
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const rl = require('readline');
8
+
9
+ const TEMPLATES = path.join(__dirname, '..', 'templates');
10
+ const CWD = process.cwd();
11
+ const VERSION = require('../package.json').version;
12
+ const useColor = process.stdout.isTTY && !process.env.NO_COLOR;
13
+
14
+ const c = useColor
15
+ ? { reset: '\x1b[0m', bold: '\x1b[1m', green: '\x1b[32m',
16
+ yellow: '\x1b[33m', cyan: '\x1b[36m', red: '\x1b[31m', dim: '\x1b[2m' }
17
+ : { reset: '', bold: '', green: '', yellow: '', cyan: '', red: '', dim: '' };
18
+
19
+ const log = (msg = '') => console.log(msg);
20
+ const ok = (msg) => console.log(`${c.green}✔${c.reset} ${msg}`);
21
+ const warn = (msg) => console.log(`${c.yellow}⚠${c.reset} ${msg}`);
22
+ const info = (msg) => console.log(`${c.cyan}ℹ${c.reset} ${msg}`);
23
+ const error = (msg) => console.log(`${c.red}✖${c.reset} ${msg}`);
24
+ const bold = (msg) => `${c.bold}${msg}${c.reset}`;
25
+ const dim = (msg) => `${c.dim}${msg}${c.reset}`;
26
+
27
+ function ask(prompt) {
28
+ const iface = rl.createInterface({ input: process.stdin, output: process.stdout });
29
+ return new Promise(resolve =>
30
+ iface.question(prompt, answer => { iface.close(); resolve(answer.trim()); })
31
+ );
32
+ }
33
+
34
+ function copy(src, dest) {
35
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
36
+ fs.copyFileSync(src, dest);
37
+ }
38
+
39
+ function copyDir(src, dest, exclude = []) {
40
+ fs.mkdirSync(dest, { recursive: true });
41
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
42
+ if (exclude.includes(entry.name)) continue;
43
+ const srcPath = path.join(src, entry.name);
44
+ const destPath = path.join(dest, entry.name);
45
+ entry.isDirectory() ? copyDir(srcPath, destPath) : copy(srcPath, destPath);
46
+ }
47
+ }
48
+
49
+ const HARNESS_CONFIG = {
50
+ '2': {
51
+ name: 'claude-code',
52
+ commandsDest: path.join(CWD, '.claude', 'commands'),
53
+ },
54
+ '3': {
55
+ name: 'opencode',
56
+ commandsDest: path.join(CWD, '.opencode', 'commands'),
57
+ },
58
+ };
59
+
60
+ function showSlashCommands() {
61
+ log(bold('Slash commands disponíveis:'));
62
+ log(` ${c.cyan}/sdd-research${c.reset} 001-nome-da-feature`);
63
+ log(` ${c.cyan}/sdd-plan${c.reset} 001-nome-da-feature`);
64
+ log(` ${c.cyan}/sdd-implement${c.reset} 001-nome-da-feature`);
65
+ log(` ${c.cyan}/sdd-validate${c.reset} 001-nome-da-feature`);
66
+ }
67
+
68
+ function removeSddCommands(commandsDest) {
69
+ if (!fs.existsSync(commandsDest)) return;
70
+ for (const f of fs.readdirSync(commandsDest)) {
71
+ if (f.startsWith('sdd-')) fs.rmSync(path.join(commandsDest, f));
72
+ }
73
+ }
74
+
75
+ async function init() {
76
+ log();
77
+ log(bold('sdd-cli') + dim(' — Spec Driven Development workflow'));
78
+ log();
79
+
80
+ const agentsDir = path.join(CWD, 'agents');
81
+ if (fs.existsSync(agentsDir)) {
82
+ warn('A pasta agents/ já existe neste projeto.');
83
+ const answer = await ask(' Deseja sobrescrever os arquivos do workflow? (s/N) ');
84
+ if (answer.toLowerCase() !== 's') {
85
+ info('Operação cancelada. Use ' + bold('sdd update') + ' para atualizar prompts e regras.');
86
+ log();
87
+ process.exit(0);
88
+ }
89
+ log();
90
+ }
91
+
92
+ copy(path.join(TEMPLATES, 'AGENTS.md'), path.join(CWD, 'AGENTS.md'));
93
+ ok('AGENTS.md criado na raiz do projeto');
94
+
95
+ copy(path.join(TEMPLATES, 'QUICKSTART.md'), path.join(CWD, 'QUICKSTART.md'));
96
+ ok('QUICKSTART.md criado na raiz do projeto');
97
+
98
+ copyDir(path.join(TEMPLATES, 'agents'), agentsDir, ['harness']);
99
+ ok('Workflow instalado em agents/');
100
+
101
+ log();
102
+ info('O harness instala hooks de segurança e slash commands ' + dim('(opcional)'));
103
+ log(' 1) Pular esta etapa');
104
+ log(' 2) Claude Code');
105
+ log(' 3) OpenCode');
106
+ const choice = await ask(' Escolha [1]: ');
107
+
108
+ const harnessCfg = HARNESS_CONFIG[choice];
109
+ let harnessInstalled = false;
110
+
111
+ if (harnessCfg) {
112
+ const { name, commandsDest } = harnessCfg;
113
+ const harnessSrc = path.join(TEMPLATES, 'agents', 'harness', name);
114
+
115
+ if (fs.existsSync(harnessSrc)) {
116
+ copyDir(harnessSrc, path.join(agentsDir, 'harness', name), ['commands']);
117
+ ok(`Harness instalado: ${name}`);
118
+
119
+ const cmdSrc = path.join(harnessSrc, 'commands');
120
+ if (fs.existsSync(cmdSrc)) {
121
+ copyDir(cmdSrc, commandsDest);
122
+ ok(`Slash commands instalados em ${path.relative(CWD, commandsDest)}/`);
123
+ }
124
+
125
+ harnessInstalled = true;
126
+ } else {
127
+ warn(`Harness "${name}" não encontrado. Use sdd harness para instalar depois.`);
128
+ }
129
+ } else {
130
+ info('Harness ignorado. Use ' + bold('sdd harness') + ' para instalar depois.');
131
+ }
132
+
133
+ log();
134
+ log(bold('Próximos passos:'));
135
+ log(` ${c.cyan}1.${c.reset} Abra uma sessão do seu agente no projeto`);
136
+ log(` ${c.cyan}2.${c.reset} Instrua: ${dim('"Leia e siga agents/SETUP.md"')}`);
137
+ log(` ${dim('→ Projeto novo: descreva o projeto ou forneça o PRD')}`);
138
+ log(` ${dim('→ Projeto existente: o agente escaneia o código automaticamente')}`);
139
+ log(` ${c.cyan}3.${c.reset} Revise os arquivos gerados e delete agents/SETUP.md`);
140
+ log();
141
+
142
+ if (harnessInstalled) {
143
+ showSlashCommands();
144
+ } else {
145
+ log(dim(' Sem slash commands — consulte QUICKSTART.md para instruções manuais.'));
146
+ log(dim(' Para instalar depois: sdd harness'));
147
+ }
148
+
149
+ log();
150
+ log(dim(' Documentação: https://github.com/moisesuailab/spec-driven-workflow'));
151
+ log();
152
+ }
153
+
154
+ async function harness() {
155
+ log();
156
+ log(bold('sdd harness'));
157
+ log();
158
+
159
+ const agentsDir = path.join(CWD, 'agents');
160
+ if (!fs.existsSync(agentsDir)) {
161
+ error('Pasta agents/ não encontrada. Rode ' + bold('sdd init') + ' primeiro.');
162
+ log();
163
+ process.exit(1);
164
+ }
165
+
166
+ info('O que deseja fazer?');
167
+ log(' 1) Remover harness atual');
168
+ log(' 2) Instalar / trocar para Claude Code');
169
+ log(' 3) Instalar / trocar para OpenCode');
170
+ const choice = await ask(' Escolha: ');
171
+
172
+ if (choice === '1') {
173
+ const harnessDir = path.join(agentsDir, 'harness');
174
+ if (fs.existsSync(harnessDir)) {
175
+ fs.rmSync(harnessDir, { recursive: true });
176
+ ok('Hooks removidos de agents/harness/');
177
+ }
178
+ for (const cfg of Object.values(HARNESS_CONFIG)) {
179
+ removeSddCommands(cfg.commandsDest);
180
+ if (fs.existsSync(cfg.commandsDest)) {
181
+ ok(`Slash commands removidos de ${path.relative(CWD, cfg.commandsDest)}/`);
182
+ }
183
+ }
184
+ log();
185
+ ok('Harness desinstalado.');
186
+ log();
187
+ return;
188
+ }
189
+
190
+ const harnessCfg = HARNESS_CONFIG[choice];
191
+ if (!harnessCfg) {
192
+ info('Operação cancelada.');
193
+ log();
194
+ process.exit(0);
195
+ }
196
+
197
+ const { name, commandsDest } = harnessCfg;
198
+ const harnessSrc = path.join(TEMPLATES, 'agents', 'harness', name);
199
+
200
+ if (!fs.existsSync(harnessSrc)) {
201
+ error(`Harness "${name}" não encontrado nos templates.`);
202
+ process.exit(1);
203
+ }
204
+
205
+ for (const cfg of Object.values(HARNESS_CONFIG)) {
206
+ removeSddCommands(cfg.commandsDest);
207
+ }
208
+
209
+ copyDir(harnessSrc, path.join(agentsDir, 'harness', name), ['commands']);
210
+ ok(`Harness instalado: ${name}`);
211
+
212
+ const cmdSrc = path.join(harnessSrc, 'commands');
213
+ if (fs.existsSync(cmdSrc)) {
214
+ copyDir(cmdSrc, commandsDest);
215
+ ok(`Slash commands instalados em ${path.relative(CWD, commandsDest)}/`);
216
+ }
217
+
218
+ log();
219
+ showSlashCommands();
220
+ log();
221
+ }
222
+
223
+ async function update() {
224
+ log();
225
+ log(bold('sdd update'));
226
+ log();
227
+
228
+ const agentsDir = path.join(CWD, 'agents');
229
+ if (!fs.existsSync(agentsDir)) {
230
+ error('Pasta agents/ não encontrada. Rode ' + bold('sdd init') + ' primeiro.');
231
+ log();
232
+ process.exit(1);
233
+ }
234
+
235
+ warn('Isso atualizará AGENTS.md, RULES.md, QUICKSTART.md e todos os prompts.');
236
+ const answer = await ask(' Deseja continuar? (s/N) ');
237
+ if (answer.toLowerCase() !== 's') {
238
+ info('Operação cancelada.');
239
+ log();
240
+ process.exit(0);
241
+ }
242
+ log();
243
+
244
+ const coreFiles = [
245
+ { rel: ['AGENTS.md'], dest: path.join(CWD, 'AGENTS.md') },
246
+ { rel: ['QUICKSTART.md'], dest: path.join(CWD, 'QUICKSTART.md') },
247
+ { rel: ['agents', 'AGENTS.md'], dest: path.join(agentsDir, 'AGENTS.md') },
248
+ { rel: ['agents', 'RULES.md'], dest: path.join(agentsDir, 'RULES.md') },
249
+ ];
250
+
251
+ for (const { rel, dest } of coreFiles) {
252
+ copy(path.join(TEMPLATES, ...rel), dest);
253
+ ok(`Atualizado: ${rel.join('/')}`);
254
+ }
255
+
256
+ copyDir(
257
+ path.join(TEMPLATES, 'agents', 'prompts'),
258
+ path.join(agentsDir, 'prompts')
259
+ );
260
+ ok('Atualizado: agents/prompts/');
261
+
262
+ log();
263
+ info('Preservados (dados do projeto):');
264
+ ['agents/PROJECT.md', 'agents/DECISIONS.md', 'agents/skills/', 'agents/specs/', 'agents/harness/']
265
+ .forEach(f => log(` ${dim(f)}`));
266
+ log();
267
+ ok('Workflow atualizado com sucesso.');
268
+ log();
269
+ }
270
+
271
+ function nextSpecNumber(specsDir) {
272
+ if (!fs.existsSync(specsDir)) return '001';
273
+ const entries = fs.readdirSync(specsDir, { withFileTypes: true })
274
+ .filter(e => e.isDirectory())
275
+ .map(e => parseInt(e.name.slice(0, 3), 10))
276
+ .filter(n => !isNaN(n));
277
+ const max = entries.length ? Math.max(...entries) : 0;
278
+ return String(max + 1).padStart(3, '0');
279
+ }
280
+
281
+ function newSpec(rawName) {
282
+ log();
283
+ log(bold('sdd new'));
284
+ log();
285
+
286
+ const agentsDir = path.join(CWD, 'agents');
287
+ if (!fs.existsSync(agentsDir)) {
288
+ error('Pasta agents/ não encontrada. Rode ' + bold('sdd init') + ' primeiro.');
289
+ log();
290
+ process.exit(1);
291
+ }
292
+
293
+ if (!rawName) {
294
+ error('Informe o nome da feature: ' + bold('sdd new <nome-da-feature>'));
295
+ log(' Exemplo: ' + dim('sdd new user-authentication'));
296
+ log();
297
+ process.exit(1);
298
+ }
299
+
300
+ const name = rawName.toLowerCase().trim().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
301
+ if (!name) {
302
+ error('Nome inválido. Use apenas letras, números e hífens.');
303
+ log();
304
+ process.exit(1);
305
+ }
306
+
307
+ const specsDir = path.join(agentsDir, 'specs');
308
+ const num = nextSpecNumber(specsDir);
309
+ const slug = num + '-' + name;
310
+ const specDir = path.join(specsDir, slug);
311
+
312
+ if (fs.existsSync(specDir)) {
313
+ error('Spec já existe: agents/specs/' + slug + '/');
314
+ log();
315
+ process.exit(1);
316
+ }
317
+
318
+ fs.mkdirSync(specDir, { recursive: true });
319
+ fs.writeFileSync(
320
+ path.join(specDir, 'DECISIONS.md'),
321
+ '# DECISIONS — ' + name + '\n\n(decisões arquiteturais registradas durante o ciclo)\n'
322
+ );
323
+
324
+ ok('Spec criada: agents/specs/' + slug + '/');
325
+ log();
326
+ log(bold('Próximo passo — inicie a fase de Research:'));
327
+ log(' ' + c.cyan + '/sdd-research' + c.reset + ' ' + slug);
328
+ log(' ' + dim('"Leia e siga agents/prompts/rpi-research.md. Spec: ' + slug + '"'));
329
+ log();
330
+ }
331
+
332
+ function help() {
333
+ log();
334
+ log(bold('sdd-cli') + dim(' — Spec Driven Development workflow'));
335
+ log();
336
+ log('Uso:');
337
+ log(` sdd-cli ${c.cyan}init${c.reset} Instala o workflow no projeto atual`);
338
+ log(` sdd-cli ${c.cyan}new <nome>${c.reset} Cria pasta da spec com numeração automática`);
339
+ log(` sdd-cli ${c.cyan}harness${c.reset} Instala, troca ou remove o harness do agente`);
340
+ log(` sdd-cli ${c.cyan}update${c.reset} Atualiza prompts e regras, preserva dados do projeto`);
341
+ log(` sdd-cli ${c.cyan}help${c.reset} Exibe esta mensagem`);
342
+ log(` sdd-cli ${c.cyan}--version${c.reset} Exibe a versão instalada`);
343
+ log();
344
+ log(dim(' Alias: sdd init / sdd new / sdd harness / sdd update / sdd help / sdd --version'));
345
+ log();
346
+ log(dim(' Documentação: https://github.com/moisesuailab/spec-driven-workflow'));
347
+ log();
348
+ }
349
+
350
+ const cmd = process.argv[2];
351
+
352
+ switch (cmd) {
353
+ case 'init':
354
+ init().catch(e => { error(e.message); process.exit(1); });
355
+ break;
356
+ case 'new':
357
+ newSpec(process.argv[3]);
358
+ break;
359
+ case 'harness':
360
+ harness().catch(e => { error(e.message); process.exit(1); });
361
+ break;
362
+ case 'update':
363
+ update().catch(e => { error(e.message); process.exit(1); });
364
+ break;
365
+ case 'help':
366
+ case '--help':
367
+ case '-h':
368
+ help();
369
+ break;
370
+ case '--version':
371
+ case '-v':
372
+ log(VERSION);
373
+ break;
374
+ case undefined:
375
+ help();
376
+ break;
377
+ default:
378
+ error(`Comando desconhecido: "${cmd}"`);
379
+ help();
380
+ process.exit(1);
381
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdd-flow",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Spec Driven Development workflow for AI-assisted development (SDD + RPI)",
5
5
  "bin": {
6
6
  "sdd-cli": "bin/cli.js",
@@ -27,6 +27,6 @@
27
27
  "license": "MIT",
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "git+https://github.com/moisesuailab/spec-workflow-cli.git"
30
+ "url": "https://github.com/moisesuailab/sdd-flow.git"
31
31
  }
32
32
  }
@@ -1,50 +1,70 @@
1
- # SDD Workflow — Quick Start
2
-
3
- ## Ciclo
4
-
5
- Cada feature passa por 4 fases em sessões isoladas:
6
-
7
- ```
8
- RESEARCH → PLAN → IMPLEMENT → VALIDATE
9
- ```
10
-
11
- ## Iniciando uma feature
12
-
13
- ### Com slash commands
14
-
15
- ```
16
- /sdd-research 001-nome-da-feature → produz RESEARCH.md
17
- /sdd-plan 001-nome-da-feature → produz SPEC.md + TASK.md + TEST.md
18
- /sdd-implement 001-nome-da-feature → implementa uma task por vez
19
- /sdd-validate 001-nome-da-feature → produz VALIDATION.md
20
- ```
21
-
22
- ### Sem slash commands
23
-
24
- Instrua seu agente em cada sessão:
25
-
26
- ```
27
- "Leia e siga agents/prompts/rpi-research.md. Spec: 001-nome-da-feature"
28
- "Leia e siga agents/prompts/rpi-plan.md. Spec: 001-nome-da-feature"
29
- "Leia e siga agents/prompts/rpi-implement.md. Spec: 001-nome-da-feature"
30
- "Leia e siga agents/prompts/rpi-validate.md. Spec: 001-nome-da-feature"
31
- ```
32
-
33
- ## Estrutura da spec após o ciclo completo
34
-
35
- ```
36
- agents/specs/001-nome-da-feature/
37
- RESEARCH.md ← fase 1
38
- SPEC.md ← fase 2
39
- TASK.md ← fase 2
40
- TEST.md ← fase 2
41
- PROGRESS.md ← atualizado na fase 3
42
- DECISIONS.md ← decisões arquiteturais
43
- VALIDATION.md ← fase 4
44
- ```
45
-
46
- ## Referências
47
-
48
- - Regras do processo → `agents/RULES.md`
49
- - Definição completa do workflow → `agents/AGENTS.md`
50
- - Documentação → https://github.com/moisesuailab/spec-driven-workflow
1
+ # SDD Workflow - Quick Start
2
+
3
+ ## Cycle
4
+
5
+ Each feature goes through 4 phases in isolated sessions:
6
+
7
+ ```
8
+ RESEARCH → PLAN → IMPLEMENT → VALIDATE
9
+ ```
10
+
11
+ ## Initial setup
12
+
13
+ After running `sdd init`, open your agent in the project and instruct:
14
+
15
+ ```
16
+ "Read and follow agents/SETUP.md"
17
+ ```
18
+
19
+ - **New project:** describe the project or provide the PRD — the agent generates PROJECT.md and the skills
20
+ - **Existing project:** the agent scans the code automatically
21
+
22
+ Review the generated files and delete `agents/SETUP.md`.
23
+
24
+ ## Starting a feature
25
+
26
+ ### With slash commands
27
+
28
+ ```
29
+ /sdd-research 001-feature-name → produces RESEARCH.md
30
+ /sdd-plan 001-feature-name → produces SPEC.md + TASK.md + TEST.md
31
+ /sdd-implement 001-feature-name → implements one task at a time
32
+ /sdd-validate 001-feature-name → produces VALIDATION.md
33
+ ```
34
+
35
+ ### Without slash commands
36
+
37
+ Instruct your agent in each session:
38
+
39
+ ```
40
+ "Read and follow agents/prompts/rpi-research.md. Spec: 001-feature-name"
41
+ "Read and follow agents/prompts/rpi-plan.md. Spec: 001-feature-name"
42
+ "Read and follow agents/prompts/rpi-implement.md. Spec: 001-feature-name"
43
+ "Read and follow agents/prompts/rpi-validate.md. Spec: 001-feature-name"
44
+ ```
45
+
46
+ ## Creating a new spec
47
+
48
+ ```bash
49
+ sdd new feature-name
50
+ # ✔ Spec created: agents/specs/001-feature-name/
51
+ ```
52
+
53
+ ## Spec structure after the full cycle
54
+
55
+ ```
56
+ agents/specs/001-feature-name/
57
+ RESEARCH.md ← phase 1
58
+ SPEC.md ← phase 2
59
+ TASK.md ← phase 2
60
+ TEST.md ← phase 2
61
+ PROGRESS.md ← updated in phase 3
62
+ DECISIONS.md ← architectural decisions
63
+ VALIDATION.md ← phase 4
64
+ ```
65
+
66
+ ## References
67
+
68
+ - Process rules → `agents/RULES.md`
69
+ - Full workflow definition → `agents/AGENTS.md`
70
+ - Documentation → https://github.com/moisesuailab/sdd-flow