ssd-ql-workflow 0.1.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/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # @ql/sdd-cli
2
+
3
+ SDD (Skill-Driven Development) CLI Tool - 一键初始化 Trinity Workflow 配置。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ # 使用 npx(推荐)
9
+ npx @ql/sdd-cli init
10
+
11
+ # 或全局安装
12
+ npm install -g @ql/sdd-cli
13
+ sdd-cli init
14
+ ```
15
+
16
+ ## 快速开始
17
+
18
+ ```bash
19
+ # 在项目根目录执行
20
+ npx @ql/sdd-cli init
21
+
22
+ # 初始化成功后,可用的命令:
23
+ # /sdd-new <change-name> - 创建新的 SDD workflow
24
+ # /sdd-continue - 继续下一个 artifact
25
+ # /sdd-apply - 执行任务
26
+ # /sdd-status - 查看状态
27
+ ```
28
+
29
+ ## 命令
30
+
31
+ ### `init`
32
+
33
+ 初始化 SDD workflow 配置:
34
+
35
+ ```bash
36
+ npx @ql/sdd-cli init [options]
37
+
38
+ Options:
39
+ -f, --force 覆盖已存在的文件
40
+ --no-commands 跳过命令文件复制
41
+ --no-schema 跳过 schema 文件复制
42
+ ```
43
+
44
+ ### `list`
45
+
46
+ 列出可用的命令和 schema:
47
+
48
+ ```bash
49
+ npx @ql/sdd-cli list
50
+ ```
51
+
52
+ ## 生成的文件结构
53
+
54
+ ```
55
+ your-project/
56
+ ├── openspec/
57
+ │ ├── config.yaml # OpenSpec 配置
58
+ │ ├── project.md # 项目说明
59
+ │ ├── .active # 活动状态文件
60
+ │ ├── schemas/
61
+ │ │ └── trinity-workflow/
62
+ │ │ └── schema.yaml # 三位一体架构 schema
63
+ │ ├── specs/ # 规格文档目录
64
+ │ └── changes/ # 变更目录
65
+ └── .opencode/
66
+ └── commands/
67
+ ├── sdd-new.md # SDD 新建命令
68
+ ├── sdd-continue.md # SDD 继续命令
69
+ ├── sdd-apply.md # SDD 执行命令
70
+ ├── sdd-status.md # SDD 状态命令
71
+ └── opsx-*.md # OPSX 原生命令
72
+ ```
73
+
74
+ ## Trinity Workflow 架构
75
+
76
+ 三位一体架构整合了:
77
+
78
+ 1. **追踪层** (Planning-with-Files)
79
+ - `task_plan.md` - 阶段、目标、决策
80
+ - `findings.md` - 技术发现、架构决策
81
+ - `progress.md` - 会话进度日志
82
+
83
+ 2. **方法层** (阶段式产出)
84
+ - `proposal.md` - 需求探索
85
+ - `design.md` - 技术设计
86
+ - `specs/` - 功能规格
87
+ - `tasks.md` - 任务分解
88
+
89
+ 3. **执行层** (3-Strike 协议)
90
+ - Attempt 1: 诊断并修复
91
+ - Attempt 2: 尝试替代方案
92
+ - Attempt 3: 重新思考问题
93
+
94
+ ## SDD vs OPSX 命令对照
95
+
96
+ | SDD Command | OPSX Equivalent | 说明 |
97
+ |-------------|-----------------|------|
98
+ | `/sdd-new` | `/opsx-new --schema trinity-workflow` | 创建 change |
99
+ | `/sdd-continue` | `/opsx-continue` | 继续 artifact |
100
+ | `/sdd-apply` | `/opsx-apply` | 执行任务 |
101
+ | `/sdd-status` | `/opsx-status` | 查看状态 |
102
+
103
+ ## 开发
104
+
105
+ ```bash
106
+ # 安装依赖
107
+ cd packages/sdd-cli
108
+ npm install
109
+
110
+ # 本地测试
111
+ node bin/cli.js init
112
+ ```
113
+
114
+ ## License
115
+
116
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from 'commander';
4
+ import fs from 'fs-extra';
5
+ import path from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ import chalk from 'chalk';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+ const TEMPLATES_DIR = path.join(__dirname, '..', 'templates');
12
+
13
+ program
14
+ .name('sdd-cli')
15
+ .description('SDD (Skill-Driven Development) CLI Tool')
16
+ .version('0.1.0');
17
+
18
+ program
19
+ .command('init')
20
+ .description('Initialize SDD workflow configuration in current project')
21
+ .option('-f, --force', 'Overwrite existing files', false)
22
+ .option('--no-commands', 'Skip copying command files', false)
23
+ .option('--no-schema', 'Skip copying schema files', false)
24
+ .action(async (options) => {
25
+ const cwd = process.cwd();
26
+ console.log(chalk.blue('\n🚀 Initializing SDD workflow...\n'));
27
+
28
+ try {
29
+ // 1. Copy openspec config and schema
30
+ if (options.schema !== false) {
31
+ const openspecDir = path.join(cwd, 'openspec');
32
+
33
+ // Create openspec directory structure
34
+ await fs.ensureDir(path.join(openspecDir, 'schemas', 'trinity-workflow'));
35
+ await fs.ensureDir(path.join(openspecDir, 'specs'));
36
+ await fs.ensureDir(path.join(openspecDir, 'changes'));
37
+
38
+ // Copy config.yaml
39
+ const configSrc = path.join(TEMPLATES_DIR, 'openspec', 'config.yaml');
40
+ const configDest = path.join(openspecDir, 'config.yaml');
41
+
42
+ if (await fs.exists(configDest) && !options.force) {
43
+ console.log(chalk.yellow('⚠ config.yaml already exists, use --force to overwrite'));
44
+ } else {
45
+ await fs.copy(configSrc, configDest);
46
+ console.log(chalk.green('✓ Created openspec/config.yaml'));
47
+ }
48
+
49
+ // Copy trinity-workflow schema
50
+ const schemaSrc = path.join(TEMPLATES_DIR, 'openspec', 'schemas', 'trinity-workflow', 'schema.yaml');
51
+ const schemaDest = path.join(openspecDir, 'schemas', 'trinity-workflow', 'schema.yaml');
52
+
53
+ if (await fs.exists(schemaDest) && !options.force) {
54
+ console.log(chalk.yellow('⚠ trinity-workflow/schema.yaml already exists, use --force to overwrite'));
55
+ } else {
56
+ await fs.copy(schemaSrc, schemaDest);
57
+ console.log(chalk.green('✓ Created openspec/schemas/trinity-workflow/schema.yaml'));
58
+ }
59
+
60
+ // Create project.md template if not exists
61
+ const projectMdPath = path.join(openspecDir, 'project.md');
62
+ if (!await fs.exists(projectMdPath)) {
63
+ await fs.writeFile(projectMdPath, `# Project Overview\n\nDescribe your project here.\n`, 'utf8');
64
+ console.log(chalk.green('✓ Created openspec/project.md'));
65
+ }
66
+
67
+ // Create .active file
68
+ const activeFile = path.join(openspecDir, '.active');
69
+ if (!await fs.exists(activeFile)) {
70
+ await fs.writeFile(activeFile, '');
71
+ }
72
+ }
73
+
74
+ // 2. Copy opencode commands
75
+ if (options.commands !== false) {
76
+ const commandsDir = path.join(cwd, '.opencode', 'commands');
77
+ await fs.ensureDir(commandsDir);
78
+
79
+ const templateCommandsDir = path.join(TEMPLATES_DIR, 'opencode', 'commands');
80
+ const commands = await fs.readdir(templateCommandsDir);
81
+
82
+ let copiedCount = 0;
83
+ for (const cmd of commands) {
84
+ if (cmd.endsWith('.md')) {
85
+ const src = path.join(templateCommandsDir, cmd);
86
+ const dest = path.join(commandsDir, cmd);
87
+
88
+ if (await fs.exists(dest) && !options.force) {
89
+ console.log(chalk.gray(` ${cmd} already exists, skipping`));
90
+ } else {
91
+ await fs.copy(src, dest);
92
+ copiedCount++;
93
+ }
94
+ }
95
+ }
96
+ console.log(chalk.green(`✓ Copied ${copiedCount} command files to .opencode/commands/`));
97
+ }
98
+
99
+ console.log('\n' + chalk.green.bold('✅ SDD workflow initialized successfully!'));
100
+ console.log('\n📚 Next steps:');
101
+ console.log(chalk.cyan(' /sdd-new <change-name>') + ' - Start a new SDD workflow');
102
+ console.log(chalk.cyan(' /sdd-continue') + ' - Continue to next artifact');
103
+ console.log(chalk.cyan(' /sdd-apply') + ' - Execute tasks');
104
+ console.log(chalk.cyan(' /sdd-status') + ' - View workflow status\n');
105
+
106
+ } catch (error) {
107
+ console.error(chalk.red('\n❌ Initialization failed:'), error.message);
108
+ process.exit(1);
109
+ }
110
+ });
111
+
112
+ program
113
+ .command('list')
114
+ .description('List available commands and schemas')
115
+ .action(() => {
116
+ console.log(chalk.bold('\n📚 Available SDD Commands:'));
117
+ console.log(' /sdd-new - Start a new SDD workflow');
118
+ console.log(' /sdd-continue - Continue to next artifact');
119
+ console.log(' /sdd-apply - Execute tasks from workflow');
120
+ console.log(' /sdd-status - View workflow status');
121
+
122
+ console.log(chalk.bold('\n📦 Available Schemas:'));
123
+ console.log(' trinity-workflow - 三位一体架构工作流\n');
124
+ });
125
+
126
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "ssd-ql-workflow",
3
+ "version": "0.1.0",
4
+ "description": "SDD (Skill-Driven Development) CLI - Initialize trinity-workflow schema and commands",
5
+ "type": "module",
6
+ "bin": {
7
+ "sdd": "./bin/cli.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "templates"
12
+ ],
13
+ "keywords": [
14
+ "sdd",
15
+ "openspec",
16
+ "workflow",
17
+ "cli",
18
+ "trinity",
19
+ "claude",
20
+ "opencode"
21
+ ],
22
+ "author": "ql",
23
+ "license": "MIT",
24
+ "engines": {
25
+ "node": ">=18.0.0"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/ql-wade/sdd-cli"
30
+ },
31
+ "dependencies": {
32
+ "chalk": "^5.3.0",
33
+ "commander": "^12.0.0",
34
+ "fs-extra": "^11.2.0",
35
+ "ora": "^8.0.0"
36
+ }
37
+ }
@@ -0,0 +1,149 @@
1
+ ---
2
+ description: Implement tasks from an OpenSpec change (Experimental)
3
+ ---
4
+
5
+ Implement tasks from an OpenSpec change.
6
+
7
+ **Input**: Optionally specify a change name (e.g., `/opsx-apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
8
+
9
+ **Steps**
10
+
11
+ 1. **Select the change**
12
+
13
+ If a name is provided, use it. Otherwise:
14
+ - Infer from conversation context if the user mentioned a change
15
+ - Auto-select if only one active change exists
16
+ - If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
17
+
18
+ Always announce: "Using change: <name>" and how to override (e.g., `/opsx-apply <other>`).
19
+
20
+ 2. **Check status to understand the schema**
21
+ ```bash
22
+ openspec status --change "<name>" --json
23
+ ```
24
+ Parse the JSON to understand:
25
+ - `schemaName`: The workflow being used (e.g., "spec-driven")
26
+ - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
27
+
28
+ 3. **Get apply instructions**
29
+
30
+ ```bash
31
+ openspec instructions apply --change "<name>" --json
32
+ ```
33
+
34
+ This returns:
35
+ - Context file paths (varies by schema)
36
+ - Progress (total, complete, remaining)
37
+ - Task list with status
38
+ - Dynamic instruction based on current state
39
+
40
+ **Handle states:**
41
+ - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx-continue`
42
+ - If `state: "all_done"`: congratulate, suggest archive
43
+ - Otherwise: proceed to implementation
44
+
45
+ 4. **Read context files**
46
+
47
+ Read the files listed in `contextFiles` from the apply instructions output.
48
+ The files depend on the schema being used:
49
+ - **spec-driven**: proposal, specs, design, tasks
50
+ - Other schemas: follow the contextFiles from CLI output
51
+
52
+ 5. **Show current progress**
53
+
54
+ Display:
55
+ - Schema being used
56
+ - Progress: "N/M tasks complete"
57
+ - Remaining tasks overview
58
+ - Dynamic instruction from CLI
59
+
60
+ 6. **Implement tasks (loop until done or blocked)**
61
+
62
+ For each pending task:
63
+ - Show which task is being worked on
64
+ - Make the code changes required
65
+ - Keep changes minimal and focused
66
+ - Mark task complete in the tasks file: `- [ ]` → `- [x]`
67
+ - Continue to next task
68
+
69
+ **Pause if:**
70
+ - Task is unclear → ask for clarification
71
+ - Implementation reveals a design issue → suggest updating artifacts
72
+ - Error or blocker encountered → report and wait for guidance
73
+ - User interrupts
74
+
75
+ 7. **On completion or pause, show status**
76
+
77
+ Display:
78
+ - Tasks completed this session
79
+ - Overall progress: "N/M tasks complete"
80
+ - If all done: suggest archive
81
+ - If paused: explain why and wait for guidance
82
+
83
+ **Output During Implementation**
84
+
85
+ ```
86
+ ## Implementing: <change-name> (schema: <schema-name>)
87
+
88
+ Working on task 3/7: <task description>
89
+ [...implementation happening...]
90
+ ✓ Task complete
91
+
92
+ Working on task 4/7: <task description>
93
+ [...implementation happening...]
94
+ ✓ Task complete
95
+ ```
96
+
97
+ **Output On Completion**
98
+
99
+ ```
100
+ ## Implementation Complete
101
+
102
+ **Change:** <change-name>
103
+ **Schema:** <schema-name>
104
+ **Progress:** 7/7 tasks complete ✓
105
+
106
+ ### Completed This Session
107
+ - [x] Task 1
108
+ - [x] Task 2
109
+ ...
110
+
111
+ All tasks complete! You can archive this change with `/opsx-archive`.
112
+ ```
113
+
114
+ **Output On Pause (Issue Encountered)**
115
+
116
+ ```
117
+ ## Implementation Paused
118
+
119
+ **Change:** <change-name>
120
+ **Schema:** <schema-name>
121
+ **Progress:** 4/7 tasks complete
122
+
123
+ ### Issue Encountered
124
+ <description of the issue>
125
+
126
+ **Options:**
127
+ 1. <option 1>
128
+ 2. <option 2>
129
+ 3. Other approach
130
+
131
+ What would you like to do?
132
+ ```
133
+
134
+ **Guardrails**
135
+ - Keep going through tasks until done or blocked
136
+ - Always read context files before starting (from the apply instructions output)
137
+ - If task is ambiguous, pause and ask before implementing
138
+ - If implementation reveals issues, pause and suggest artifact updates
139
+ - Keep code changes minimal and scoped to each task
140
+ - Update task checkbox immediately after completing each task
141
+ - Pause on errors, blockers, or unclear requirements - don't guess
142
+ - Use contextFiles from CLI output, don't assume specific file names
143
+
144
+ **Fluid Workflow Integration**
145
+
146
+ This skill supports the "actions on a change" model:
147
+
148
+ - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
149
+ - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
@@ -0,0 +1,154 @@
1
+ ---
2
+ description: Archive a completed change in the experimental workflow
3
+ ---
4
+
5
+ Archive a completed change in the experimental workflow.
6
+
7
+ **Input**: Optionally specify a change name after `/opsx-archive` (e.g., `/opsx-archive add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
8
+
9
+ **Steps**
10
+
11
+ 1. **If no change name provided, prompt for selection**
12
+
13
+ Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
14
+
15
+ Show only active changes (not already archived).
16
+ Include the schema used for each change if available.
17
+
18
+ **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
19
+
20
+ 2. **Check artifact completion status**
21
+
22
+ Run `openspec status --change "<name>" --json` to check artifact completion.
23
+
24
+ Parse the JSON to understand:
25
+ - `schemaName`: The workflow being used
26
+ - `artifacts`: List of artifacts with their status (`done` or other)
27
+
28
+ **If any artifacts are not `done`:**
29
+ - Display warning listing incomplete artifacts
30
+ - Prompt user for confirmation to continue
31
+ - Proceed if user confirms
32
+
33
+ 3. **Check task completion status**
34
+
35
+ Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
36
+
37
+ Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
38
+
39
+ **If incomplete tasks found:**
40
+ - Display warning showing count of incomplete tasks
41
+ - Prompt user for confirmation to continue
42
+ - Proceed if user confirms
43
+
44
+ **If no tasks file exists:** Proceed without task-related warning.
45
+
46
+ 4. **Assess delta spec sync state**
47
+
48
+ Check for delta specs at `openspec/changes/<name>/specs/`. If none exist, proceed without sync prompt.
49
+
50
+ **If delta specs exist:**
51
+ - Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
52
+ - Determine what changes would be applied (adds, modifications, removals, renames)
53
+ - Show a combined summary before prompting
54
+
55
+ **Prompt options:**
56
+ - If changes needed: "Sync now (recommended)", "Archive without syncing"
57
+ - If already synced: "Archive now", "Sync anyway", "Cancel"
58
+
59
+ If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
60
+
61
+ 5. **Perform the archive**
62
+
63
+ Create the archive directory if it doesn't exist:
64
+ ```bash
65
+ mkdir -p openspec/changes/archive
66
+ ```
67
+
68
+ Generate target name using current date: `YYYY-MM-DD-<change-name>`
69
+
70
+ **Check if target already exists:**
71
+ - If yes: Fail with error, suggest renaming existing archive or using different date
72
+ - If no: Move the change directory to archive
73
+
74
+ ```bash
75
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
76
+ ```
77
+
78
+ 6. **Display summary**
79
+
80
+ Show archive completion summary including:
81
+ - Change name
82
+ - Schema that was used
83
+ - Archive location
84
+ - Spec sync status (synced / sync skipped / no delta specs)
85
+ - Note about any warnings (incomplete artifacts/tasks)
86
+
87
+ **Output On Success**
88
+
89
+ ```
90
+ ## Archive Complete
91
+
92
+ **Change:** <change-name>
93
+ **Schema:** <schema-name>
94
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
95
+ **Specs:** ✓ Synced to main specs
96
+
97
+ All artifacts complete. All tasks complete.
98
+ ```
99
+
100
+ **Output On Success (No Delta Specs)**
101
+
102
+ ```
103
+ ## Archive Complete
104
+
105
+ **Change:** <change-name>
106
+ **Schema:** <schema-name>
107
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
108
+ **Specs:** No delta specs
109
+
110
+ All artifacts complete. All tasks complete.
111
+ ```
112
+
113
+ **Output On Success With Warnings**
114
+
115
+ ```
116
+ ## Archive Complete (with warnings)
117
+
118
+ **Change:** <change-name>
119
+ **Schema:** <schema-name>
120
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
121
+ **Specs:** Sync skipped (user chose to skip)
122
+
123
+ **Warnings:**
124
+ - Archived with 2 incomplete artifacts
125
+ - Archived with 3 incomplete tasks
126
+ - Delta spec sync was skipped (user chose to skip)
127
+
128
+ Review the archive if this was not intentional.
129
+ ```
130
+
131
+ **Output On Error (Archive Exists)**
132
+
133
+ ```
134
+ ## Archive Failed
135
+
136
+ **Change:** <change-name>
137
+ **Target:** openspec/changes/archive/YYYY-MM-DD-<name>/
138
+
139
+ Target archive directory already exists.
140
+
141
+ **Options:**
142
+ 1. Rename the existing archive
143
+ 2. Delete the existing archive if it's a duplicate
144
+ 3. Wait until a different date to archive
145
+ ```
146
+
147
+ **Guardrails**
148
+ - Always prompt for change selection if not provided
149
+ - Use artifact graph (openspec status --json) for completion checking
150
+ - Don't block archive on warnings - just inform and confirm
151
+ - Preserve .openspec.yaml when moving to archive (it moves with the directory)
152
+ - Show clear summary of what happened
153
+ - If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven)
154
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting