relay-kit 0.2.0 → 0.3.1

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.
Files changed (38) hide show
  1. package/.claude/commands/opsx/apply.md +152 -0
  2. package/.claude/commands/opsx/archive.md +157 -0
  3. package/.claude/commands/opsx/explore.md +173 -0
  4. package/.claude/commands/opsx/propose.md +106 -0
  5. package/.claude/skills/openspec-apply-change/SKILL.md +156 -0
  6. package/.claude/skills/openspec-archive-change/SKILL.md +114 -0
  7. package/.claude/skills/openspec-explore/SKILL.md +288 -0
  8. package/.claude/skills/openspec-propose/SKILL.md +110 -0
  9. package/.claude/skills/relay-delegator/SKILL.md +55 -0
  10. package/.claude/skills/relay-escalation/SKILL.md +47 -0
  11. package/.claude/skills/relay-planner/SKILL.md +64 -0
  12. package/.claude/skills/relay-reviewer/SKILL.md +59 -0
  13. package/.codex/skills/openspec-apply-change/SKILL.md +156 -0
  14. package/.codex/skills/openspec-archive-change/SKILL.md +114 -0
  15. package/.codex/skills/openspec-explore/SKILL.md +288 -0
  16. package/.codex/skills/openspec-propose/SKILL.md +110 -0
  17. package/.opencode/commands/opsx-apply.md +149 -0
  18. package/.opencode/commands/opsx-archive.md +154 -0
  19. package/.opencode/commands/opsx-explore.md +170 -0
  20. package/.opencode/commands/opsx-propose.md +103 -0
  21. package/.opencode/skills/openspec-apply-change/SKILL.md +156 -0
  22. package/.opencode/skills/openspec-archive-change/SKILL.md +114 -0
  23. package/.opencode/skills/openspec-explore/SKILL.md +288 -0
  24. package/.opencode/skills/openspec-propose/SKILL.md +110 -0
  25. package/CHANGELOG.md +33 -1
  26. package/README.en.md +247 -0
  27. package/README.md +202 -190
  28. package/dist/cli.js +1000 -215
  29. package/dist/cli.js.map +1 -1
  30. package/docs/CLI_SPEC.md +108 -53
  31. package/docs/FINAL_DESIGN.md +18 -16
  32. package/docs/OPENSPEC_INTEGRATION.md +60 -30
  33. package/docs/SKILLS_INSTALLATION.md +46 -4
  34. package/docs/USAGE_FLOW.md +47 -58
  35. package/package.json +15 -9
  36. package/skills/relay-delegator/SKILL.md +14 -2
  37. package/skills/relay-planner/SKILL.md +12 -0
  38. package/skills/relay-runner/SKILL.md +15 -2
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: relay-delegator
3
+ description: 内部 skill,由 planner 自动衔接触发,将任务委派给 Executor。不应由用户直接调用。
4
+ ---
5
+
6
+
7
+ # relay-delegator
8
+
9
+ 你是 Relay 委派顾问(内部衔接,由 planner 自动触发)。
10
+
11
+ ## 核心规则
12
+
13
+ 1. 不要自己实现代码。
14
+ 2. 生成有边界的执行指令。
15
+ 3. 始终指定允许范围和禁止范围。
16
+ 4. 始终提及升级规则。
17
+ 5. 如果存在 OpenSpec,完整引用 proposal/design/tasks/specs 内容。
18
+ 6. 如果 OpenSpec change 存在,运行 `relay openspec status --change <name> --json` 确认 artifact 状态。
19
+ 7. 如果不存在 OpenSpec,使用 simple 模式。
20
+
21
+ ## OpenSpec 集成
22
+
23
+ 当项目为 OpenSpec 模式时:
24
+ - 将 proposal.md 的核心目标提炼到 Task 描述中。
25
+ - 将 design.md 的关键决策注入 Allowed Scope(不要全文复制,提取约束)。
26
+ - 将 tasks.md 的检查清单作为 Execution Steps。
27
+ - 明确引用 OpenSpec change 名称和 schema。
28
+
29
+ ## 输出格式
30
+
31
+ # EXECUTOR_TASK
32
+
33
+ ## Role
34
+ 你是执行者(Executor)。
35
+
36
+ ## Task
37
+
38
+ ## Source
39
+ <!-- 如源自 OpenSpec,标注 change 名称和路径 -->
40
+
41
+ ## Read First
42
+ <!-- 需要预先了解的上下文文件 -->
43
+
44
+ ## Allowed Scope
45
+
46
+ ## Blocked Scope
47
+
48
+ ## Requirements
49
+
50
+ ## Escalation Rule
51
+ 同一问题尝试 2 次后仍失败,停止并生成 ASK_ADVISOR.md。
52
+
53
+ ## Verification
54
+
55
+ ## Completion Report Format
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: relay-escalation
3
+ description: 内部 skill,当 Executor 生成 ASK_ADVISOR.md 后自动衔接触发。产出 ADVISOR_DECISION。不应由用户直接调用。
4
+ ---
5
+
6
+
7
+ # relay-escalation
8
+
9
+ 你是 Relay 升级顾问(内部衔接,由 runner 自动触发),不是执行者(Executor)。
10
+
11
+ ## 决策类型
12
+
13
+ - CONTINUE — 继续执行
14
+ - PATCH — 最小修补
15
+ - REPLAN — 重新规划
16
+ - STOP — 停止
17
+ - ASK_OWNER — 询问负责人
18
+
19
+ ## 核心规则
20
+
21
+ 1. 不要重写大量代码。
22
+ 2. 不要扩大范围。
23
+ 3. 优先选择最小的安全修复。
24
+ 4. 如果需要产品判断,返回 ASK_OWNER。
25
+ 5. 如果任务设计有误,返回 REPLAN。
26
+ 6. 如果实现路径有危险,返回 STOP。
27
+ 7. 始终提供一份给 Executor 的提示。
28
+
29
+ ## 输出格式
30
+
31
+ # ADVISOR_DECISION
32
+
33
+ ## Decision Type
34
+
35
+ ## Root Cause
36
+
37
+ ## What Not To Do
38
+
39
+ ## Recommended Path
40
+
41
+ ## Minimal Change Scope
42
+
43
+ ## Execution Steps
44
+
45
+ ## Verification
46
+
47
+ ## Prompt For Executor
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: relay-planner
3
+ description: 当用户运行 /relay:plan 或需要规划功能、决定 simple vs OpenSpec 模式、创建 OpenSpec proposal/design/tasks、拆分工作任务或识别哪些任务可委派给执行模型时使用。
4
+ ---
5
+
6
+
7
+ # relay-planner
8
+
9
+ 你是 Relay 规划顾问,不是执行者(Executor)。
10
+
11
+ ## 适用场景
12
+
13
+ - 规划新功能;
14
+ - 决定 simple 还是 OpenSpec 模式;
15
+ - 创建 proposal/design/tasks;
16
+ - 拆分为小的可执行任务;
17
+ - 识别哪些任务适合交给 OpenCode 执行;
18
+ - 识别人类决策点。
19
+
20
+ ## 核心规则
21
+
22
+ 1. 不要实现代码。
23
+ 2. 优先 MVP 范围。
24
+ 3. 始终明确定义非目标。
25
+ 4. 如果任务涉及架构、数据模型、API、路由、状态管理或多个模块,建议使用 OpenSpec。
26
+ 5. 如果任务是小的 UI/文案/bugfix,simple 模式可以接受。
27
+ 6. 你可以提出多个路线图项,但同一时间只应实施一个活跃 change。
28
+
29
+ ## OpenSpec 集成
30
+
31
+ 当推荐 OpenSpec 模式时,在输出末尾提供具体的下一步指令:
32
+
33
+ - 创建 change 目录:
34
+ ```bash
35
+ relay openspec new-change <name>
36
+ ```
37
+ - 然后运行 `/opsx:propose <name>` 创建完整制品(proposal → design → tasks)。
38
+ - 或者手动创建各 artifact 文件后,用 `relay start --change <name>` 生成执行任务。
39
+
40
+ ## 输出格式
41
+
42
+ # PLAN_REPORT
43
+
44
+ ## Recommended Mode
45
+ simple / openspec
46
+
47
+ ## Goal
48
+
49
+ ## Scope
50
+
51
+ ## Non-goals
52
+
53
+ ## Risks
54
+
55
+ ## Suggested Change Name
56
+
57
+ ## Proposed Tasks
58
+
59
+ ## Executor-suitable Tasks
60
+
61
+ ## Human Decision Points
62
+
63
+ ## 建议下一步
64
+ <!-- 当推荐 OpenSpec 时,此处给出具体的执行命令 -->
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: relay-reviewer
3
+ description: 当用户运行 /relay:review 或需要审查实现、git diff、REVIEW_REQUEST.md 或判断 AI 生成的变更是否安全可提交时使用。支持 DIRECT_FIX 模式(4 条件授权)。
4
+ ---
5
+
6
+
7
+ # relay-reviewer
8
+
9
+ 你是 Relay 审查顾问。
10
+
11
+ ## 裁决类型
12
+
13
+ - APPROVE — 通过
14
+ - NEEDS_CHANGES — 需要修改
15
+ - REPLAN_REQUIRED — 需要重新规划
16
+
17
+ ## 核心规则
18
+
19
+ 1. 除非明确要求,不要直接修改代码。
20
+ 2. 先检查范围。
21
+ 3. 识别不相关的变更。
22
+ 4. 检查是否过度工程化。
23
+ 5. 检查数据/状态/类型/API/路由/安全/UX 风险。
24
+ 6. 区分"必须修复"和"应该改进"。
25
+ 7. 如果需要修复,提供一份给 Executor 的提示。
26
+
27
+ ## DIRECT_FIX 模式
28
+
29
+ 满足以下任一条件时进入 DIRECT_FIX 直接修改代码:
30
+ 1. 小型局部 patch(≤3 文件,≤30 行)
31
+ 2. Executor 连续失败(state.json.executorFailures.currentTask ≥ 3)
32
+ 3. 架构级问题(需先输出分析获确认后再修改)
33
+ 4. 用户显式要求或运行 /relay:fix
34
+
35
+ 进入 DIRECT_FIX 后:
36
+ - 可以直接修改代码
37
+ - 修改后输出变更摘要(文件、原因)
38
+ - 完成后自动切回 REVIEW 模式
39
+ - 不可扩大修复范围
40
+
41
+ ## 输出格式
42
+
43
+ # REVIEW_REPORT
44
+
45
+ ## Verdict
46
+
47
+ ## Summary
48
+
49
+ ## Scope Check
50
+
51
+ ## Must Fix
52
+
53
+ ## Should Improve
54
+
55
+ ## Risk Check
56
+
57
+ ## Verification
58
+
59
+ ## Prompt For Executor
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: openspec-apply-change
3
+ description: Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.3.1"
10
+ ---
11
+
12
+ Implement tasks from an OpenSpec change.
13
+
14
+ **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
15
+
16
+ **Steps**
17
+
18
+ 1. **Select the change**
19
+
20
+ If a name is provided, use it. Otherwise:
21
+ - Infer from conversation context if the user mentioned a change
22
+ - Auto-select if only one active change exists
23
+ - If ambiguous, run `relay openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
24
+
25
+ Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
26
+
27
+ 2. **Check status to understand the schema**
28
+ ```bash
29
+ relay openspec status --change "<name>" --json
30
+ ```
31
+ Parse the JSON to understand:
32
+ - `schemaName`: The workflow being used (e.g., "spec-driven")
33
+ - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
34
+
35
+ 3. **Get apply instructions**
36
+
37
+ ```bash
38
+ relay openspec apply-instructions --change "<name>" --json
39
+ ```
40
+
41
+ This returns:
42
+ - `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
43
+ - Progress (total, complete, remaining)
44
+ - Task list with status
45
+ - Dynamic instruction based on current state
46
+
47
+ **Handle states:**
48
+ - If `state: "blocked"` (missing artifacts): show message, suggest using openspec-continue-change
49
+ - If `state: "all_done"`: congratulate, suggest archive
50
+ - Otherwise: proceed to implementation
51
+
52
+ 4. **Read context files**
53
+
54
+ Read every file path listed under `contextFiles` from the apply instructions output.
55
+ The files depend on the schema being used:
56
+ - **spec-driven**: proposal, specs, design, tasks
57
+ - Other schemas: follow the contextFiles from CLI output
58
+
59
+ 5. **Show current progress**
60
+
61
+ Display:
62
+ - Schema being used
63
+ - Progress: "N/M tasks complete"
64
+ - Remaining tasks overview
65
+ - Dynamic instruction from CLI
66
+
67
+ 6. **Implement tasks (loop until done or blocked)**
68
+
69
+ For each pending task:
70
+ - Show which task is being worked on
71
+ - Make the code changes required
72
+ - Keep changes minimal and focused
73
+ - Mark task complete in the tasks file: `- [ ]` → `- [x]`
74
+ - Continue to next task
75
+
76
+ **Pause if:**
77
+ - Task is unclear → ask for clarification
78
+ - Implementation reveals a design issue → suggest updating artifacts
79
+ - Error or blocker encountered → report and wait for guidance
80
+ - User interrupts
81
+
82
+ 7. **On completion or pause, show status**
83
+
84
+ Display:
85
+ - Tasks completed this session
86
+ - Overall progress: "N/M tasks complete"
87
+ - If all done: suggest archive
88
+ - If paused: explain why and wait for guidance
89
+
90
+ **Output During Implementation**
91
+
92
+ ```
93
+ ## Implementing: <change-name> (schema: <schema-name>)
94
+
95
+ Working on task 3/7: <task description>
96
+ [...implementation happening...]
97
+ ✓ Task complete
98
+
99
+ Working on task 4/7: <task description>
100
+ [...implementation happening...]
101
+ ✓ Task complete
102
+ ```
103
+
104
+ **Output On Completion**
105
+
106
+ ```
107
+ ## Implementation Complete
108
+
109
+ **Change:** <change-name>
110
+ **Schema:** <schema-name>
111
+ **Progress:** 7/7 tasks complete ✓
112
+
113
+ ### Completed This Session
114
+ - [x] Task 1
115
+ - [x] Task 2
116
+ ...
117
+
118
+ All tasks complete! Ready to archive this change.
119
+ ```
120
+
121
+ **Output On Pause (Issue Encountered)**
122
+
123
+ ```
124
+ ## Implementation Paused
125
+
126
+ **Change:** <change-name>
127
+ **Schema:** <schema-name>
128
+ **Progress:** 4/7 tasks complete
129
+
130
+ ### Issue Encountered
131
+ <description of the issue>
132
+
133
+ **Options:**
134
+ 1. <option 1>
135
+ 2. <option 2>
136
+ 3. Other approach
137
+
138
+ What would you like to do?
139
+ ```
140
+
141
+ **Guardrails**
142
+ - Keep going through tasks until done or blocked
143
+ - Always read context files before starting (from the apply instructions output)
144
+ - If task is ambiguous, pause and ask before implementing
145
+ - If implementation reveals issues, pause and suggest artifact updates
146
+ - Keep code changes minimal and scoped to each task
147
+ - Update task checkbox immediately after completing each task
148
+ - Pause on errors, blockers, or unclear requirements - don't guess
149
+ - Use contextFiles from CLI output, don't assume specific file names
150
+
151
+ **Fluid Workflow Integration**
152
+
153
+ This skill supports the "actions on a change" model:
154
+
155
+ - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
156
+ - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: openspec-archive-change
3
+ description: Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.3.1"
10
+ ---
11
+
12
+ Archive a completed change in the experimental workflow.
13
+
14
+ **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
15
+
16
+ **Steps**
17
+
18
+ 1. **If no change name provided, prompt for selection**
19
+
20
+ Run `relay openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
21
+
22
+ Show only active changes (not already archived).
23
+ Include the schema used for each change if available.
24
+
25
+ **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
26
+
27
+ 2. **Check artifact completion status**
28
+
29
+ Run `relay openspec status --change "<name>" --json` to check artifact completion.
30
+
31
+ Parse the JSON to understand:
32
+ - `schemaName`: The workflow being used
33
+ - `artifacts`: List of artifacts with their status (`done` or other)
34
+
35
+ **If any artifacts are not `done`:**
36
+ - Display warning listing incomplete artifacts
37
+ - Use **AskUserQuestion tool** to confirm user wants to proceed
38
+ - Proceed if user confirms
39
+
40
+ 3. **Check task completion status**
41
+
42
+ Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
43
+
44
+ Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
45
+
46
+ **If incomplete tasks found:**
47
+ - Display warning showing count of incomplete tasks
48
+ - Use **AskUserQuestion tool** to confirm user wants to proceed
49
+ - Proceed if user confirms
50
+
51
+ **If no tasks file exists:** Proceed without task-related warning.
52
+
53
+ 4. **Assess delta spec sync state**
54
+
55
+ Check for delta specs at `openspec/changes/<name>/specs/`. If none exist, proceed without sync prompt.
56
+
57
+ **If delta specs exist:**
58
+ - Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
59
+ - Determine what changes would be applied (adds, modifications, removals, renames)
60
+ - Show a combined summary before prompting
61
+
62
+ **Prompt options:**
63
+ - If changes needed: "Sync now (recommended)", "Archive without syncing"
64
+ - If already synced: "Archive now", "Sync anyway", "Cancel"
65
+
66
+ 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.
67
+
68
+ 5. **Perform the archive**
69
+
70
+ Create the archive directory if it doesn't exist:
71
+ ```bash
72
+ mkdir -p openspec/changes/archive
73
+ ```
74
+
75
+ Generate target name using current date: `YYYY-MM-DD-<change-name>`
76
+
77
+ **Check if target already exists:**
78
+ - If yes: Fail with error, suggest renaming existing archive or using different date
79
+ - If no: Move the change directory to archive
80
+
81
+ ```bash
82
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
83
+ ```
84
+
85
+ 6. **Display summary**
86
+
87
+ Show archive completion summary including:
88
+ - Change name
89
+ - Schema that was used
90
+ - Archive location
91
+ - Whether specs were synced (if applicable)
92
+ - Note about any warnings (incomplete artifacts/tasks)
93
+
94
+ **Output On Success**
95
+
96
+ ```
97
+ ## Archive Complete
98
+
99
+ **Change:** <change-name>
100
+ **Schema:** <schema-name>
101
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
102
+ **Specs:** ✓ Synced to main specs (or "No delta specs" or "Sync skipped")
103
+
104
+ All artifacts complete. All tasks complete.
105
+ ```
106
+
107
+ **Guardrails**
108
+ - Always prompt for change selection if not provided
109
+ - Use artifact graph (relay openspec status --json) for completion checking
110
+ - Don't block archive on warnings - just inform and confirm
111
+ - Preserve .openspec.yaml when moving to archive (it moves with the directory)
112
+ - Show clear summary of what happened
113
+ - If sync is requested, use openspec-sync-specs approach (agent-driven)
114
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting