specline 1.0.0 → 1.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.
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env bash
2
+ # specline-session-start.sh — sessionStart Hook
3
+ # 新会话启动时检测活跃 pipeline 并注入上下文到 Agent 系统提示
4
+ #
5
+ # Input (stdin JSON):
6
+ # { "session_id": "...", "is_background_agent": bool, "composer_mode": "agent"|"ask"|"edit", ... }
7
+ #
8
+ # Output (stdout JSON):
9
+ # { "additional_context": "<pipeline 上下文>" } 或 {}(无活跃 pipeline)
10
+
11
+ set -euo pipefail
12
+
13
+ input=$(cat)
14
+
15
+ # 跳过 background agent(子 Agent 不需要 pipeline 上下文)
16
+ is_bg=$(echo "$input" | jq -r '.is_background_agent // false')
17
+ if [ "$is_bg" = "true" ]; then
18
+ echo '{}'
19
+ exit 0
20
+ fi
21
+
22
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
23
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
24
+ CHANGES_DIR="$PROJECT_ROOT/specline/changes"
25
+
26
+ # 无 changes 目录 → 无 pipeline
27
+ if [ ! -d "$CHANGES_DIR" ]; then
28
+ echo '{}'
29
+ exit 0
30
+ fi
31
+
32
+ # 扫描活跃 pipeline(排除 archive/)
33
+ active_pipelines=""
34
+ pipeline_count=0
35
+ first_change=""
36
+ first_phase=""
37
+
38
+ for state_file in "$CHANGES_DIR"/*/.pipeline-state.json; do
39
+ [ -f "$state_file" ] || continue
40
+
41
+ # 跳过 archive/
42
+ parent_dir=$(dirname "$state_file")
43
+ if echo "$parent_dir" | grep -q "/archive/"; then
44
+ continue
45
+ fi
46
+
47
+ change_name=$(jq -r '.change_name // "unknown"' "$state_file" 2>/dev/null)
48
+ phase=$(jq -r '.current_phase // "unknown"' "$state_file" 2>/dev/null)
49
+ status=$(jq -r ".phases.${phase}.status // \"unknown\"" "$state_file" 2>/dev/null)
50
+
51
+ # 跳过已完成/已归档的
52
+ if [ "$phase" = "archive" ] || [ "$status" = "completed" ]; then
53
+ continue
54
+ fi
55
+
56
+ # 收集活跃 pipeline 信息
57
+ if [ $pipeline_count -eq 0 ]; then
58
+ first_change="$change_name"
59
+ first_phase="$phase"
60
+ fi
61
+ pipeline_count=$((pipeline_count + 1))
62
+
63
+ # 构建任务进度信息
64
+ completed=$(jq -r '[.phases.coding.tasks[]? | select(.status == "completed")] | length' "$state_file" 2>/dev/null || echo "0")
65
+ total=$(jq -r '[.phases.coding.tasks[]?] | length' "$state_file" 2>/dev/null || echo "0")
66
+
67
+ active_pipelines="${active_pipelines}- **${change_name}**: ${phase} 阶段"
68
+ if [ "$total" != "0" ] && [ "$phase" = "coding" ]; then
69
+ active_pipelines="${active_pipelines} (${completed}/${total} 任务完成)"
70
+ fi
71
+ active_pipelines="${active_pipelines}\n"
72
+ done
73
+
74
+ # 无活跃 pipeline → 透明放行
75
+ if [ $pipeline_count -eq 0 ]; then
76
+ echo '{}'
77
+ exit 0
78
+ fi
79
+
80
+ # 构建阶段约束说明
81
+ phase_constraints() {
82
+ case "$1" in
83
+ spec)
84
+ echo "- 只能通过 specline-spec-creator / specline-spec-reviewer 子 Agent 工作"
85
+ echo "- 禁止编辑任何应用代码文件(.ts/.tsx/.py/.go 等)"
86
+ echo "- 规划文件生成后需运行 Spec Gate"
87
+ ;;
88
+ coding)
89
+ echo "- 编码必须通过子 Agent:specline-frontend-dev / specline-backend-dev"
90
+ echo "- 禁止直接编辑应用代码文件"
91
+ echo "- 每批次任务完成后运行 Build Gate"
92
+ echo "- 每个 Task 完成后更新 tasks.md 的 checkbox"
93
+ ;;
94
+ code_review)
95
+ echo "- 只能运行 specline-code-reviewer + Lint Gate"
96
+ echo "- 如需修复代码,通过子 Agent 完成"
97
+ ;;
98
+ test)
99
+ echo "- 运行测试 Gate 链:unit → integration → e2e"
100
+ echo "- 测试失败时通过 specline-test-runner 分析原因"
101
+ echo "- 代码修复通过子 Agent,测试修复通过 specline-test-writer"
102
+ ;;
103
+ *)
104
+ echo "- 遵循 specline-pipeline SKILL 的当前阶段约束"
105
+ ;;
106
+ esac
107
+ }
108
+
109
+ # 生成上下文
110
+ constraints=$(phase_constraints "$first_phase")
111
+
112
+ # 用 printf 构建 JSON,避免 heredoc 中的转义问题
113
+ # 注意:additional_context 内容中的换行符和引号需要正确转义
114
+ context_text=""
115
+ context_text+="🚨 **Specline Pipeline 运行中**\n\n"
116
+ if [ $pipeline_count -eq 1 ]; then
117
+ context_text+="**当前变更**: ${first_change}\n"
118
+ context_text+="**当前阶段**: ${first_phase}\n\n"
119
+ else
120
+ context_text+="**活跃变更** (${pipeline_count} 个):\n${active_pipelines}\n"
121
+ fi
122
+ context_text+="**阶段约束**:\n${constraints}\n\n"
123
+ context_text+="**重要**: 你是 Specline Pipeline 编排者。上述约束具有最高优先级,必须在每个操作前检查是否符合当前阶段要求。"
124
+
125
+ # 转义 JSON 字符串
126
+ escaped_context=$(echo -e "$context_text" | jq -Rs '.')
127
+
128
+ cat << EOF
129
+ {
130
+ "additional_context": ${escaped_context}
131
+ }
132
+ EOF
133
+
134
+ exit 0
@@ -1,10 +1,31 @@
1
1
  {
2
2
  "version": 1,
3
3
  "hooks": {
4
+ "sessionStart": [
5
+ {
6
+ "command": ".cursor/hooks/specline-session-start.sh",
7
+ "timeout": 10
8
+ }
9
+ ],
10
+ "preToolUse": [
11
+ {
12
+ "command": ".cursor/hooks/specline-phase-guard.sh",
13
+ "matcher": "Write|StrReplace|EditNotebook|Task|Delete",
14
+ "timeout": 5,
15
+ "failClosed": false
16
+ }
17
+ ],
18
+ "postToolUse": [
19
+ {
20
+ "command": ".cursor/hooks/specline-reminder.sh",
21
+ "matcher": "Task|Write|StrReplace|Shell",
22
+ "timeout": 5
23
+ }
24
+ ],
4
25
  "subagentStart": [
5
26
  {
6
27
  "command": ".cursor/hooks/specline-agent-guard.sh",
7
- "matcher": "specline-spec-creator|specline-spec-reviewer|specline-frontend-dev|specline-backend-dev|specline-code-reviewer|specline-test-writer|specline-test-runner",
28
+ "matcher": "specline-spec-creator|specline-spec-reviewer|specline-frontend-dev|specline-backend-dev|specline-config-dev|specline-code-reviewer|specline-config-reviewer|specline-test-writer|specline-test-runner",
8
29
  "failClosed": true
9
30
  }
10
31
  ],
@@ -13,6 +13,27 @@ Implement tasks from a Specline change.
13
13
 
14
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
15
 
16
+ ## 速览 (Layer 1)
17
+
18
+ > **一句话**:实现 Specline change 中的编码任务。
19
+ > **入口**:`/specline-apply-change [change-name]` 或直接说「继续实现」
20
+ > **流程**:选 change → 读上下文 → 逐任务实现 → 标记完成
21
+
22
+ **Fluid Workflow Integration**
23
+
24
+ This skill supports the "actions on a change" model:
25
+ - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
26
+ - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
27
+
28
+ **开始前请确认:**
29
+ - [ ] Change 已选中(`/specline-pipeline --change <name>`)
30
+ - [ ] 已读取 proposal.md(知道做什么)
31
+ - [ ] 已读取 spec.md(知道需求和场景)
32
+ - [ ] 已读取 design.md(知道技术决策)
33
+ - [ ] 已读取 tasks.md(知道实现清单)
34
+
35
+ ## 详细步骤 — Happy Path (Layer 2)
36
+
16
37
  **Steps**
17
38
 
18
39
  1. **Select the change**
@@ -48,7 +69,7 @@ Implement tasks from a Specline change.
48
69
  - Progress: "N/M tasks complete"
49
70
  - Remaining tasks overview
50
71
 
51
- 6. **Implement tasks (loop until done or blocked)**
72
+ 5. **Implement tasks (loop until done or blocked)**
52
73
 
53
74
  For each pending task:
54
75
  - Show which task is being worked on
@@ -63,7 +84,7 @@ Implement tasks from a Specline change.
63
84
  - Error or blocker encountered → report and wait for guidance
64
85
  - User interrupts
65
86
 
66
- 7. **On completion or pause, show status**
87
+ 6. **On completion or pause, show status**
67
88
 
68
89
  Display:
69
90
  - Tasks completed this session
@@ -71,6 +92,10 @@ Implement tasks from a Specline change.
71
92
  - If all done: suggest archive
72
93
  - If paused: explain why and wait for guidance
73
94
 
95
+ ## 输出模板 & 高级话题 (Layer 3)
96
+
97
+ ### 输出模板
98
+
74
99
  **Output During Implementation**
75
100
 
76
101
  ```
@@ -122,7 +147,7 @@ All tasks complete! Ready to archive this change.
122
147
  What would you like to do?
123
148
  ```
124
149
 
125
- **Guardrails**
150
+ ### Guardrails
126
151
  - Keep going through tasks until done or blocked
127
152
  - Always read context files before starting (from the apply instructions output)
128
153
  - If task is ambiguous, pause and ask before implementing
@@ -131,10 +156,12 @@ What would you like to do?
131
156
  - Update task checkbox immediately after completing each task
132
157
  - Pause on errors, blockers, or unclear requirements - don't guess
133
158
  - Use contextFiles from CLI output, don't assume specific file names
159
+ - **Hook blocked → no silent fallback**: If this skill is invoked because a coding subagent (specline-frontend-dev / specline-backend-dev) was blocked by a hook, you MUST first notify the user of the blocking cause and attempt diagnosis. Do not silently execute tasks that should have been handled by the blocked subagent. Reference the Hook Blocking Resolution Protocol in the specline-pipeline skill.
134
160
 
135
- **Fluid Workflow Integration**
136
-
137
- This skill supports the "actions on a change" model:
161
+ ### 暂停场景处理
138
162
 
139
- - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
140
- - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
163
+ 当实现过程中出现以下情况时,暂停并等待用户指引:
164
+ - 任务描述不清晰 请求用户澄清
165
+ - 实现中暴露出设计问题 → 建议更新 Artifact(proposal / spec / design / tasks)
166
+ - 遇到错误或阻塞 → 报告具体问题并等待指导
167
+ - 用户主动中断 → 记录当前进度,下次可从断点继续
@@ -9,11 +9,31 @@ metadata:
9
9
  generatedBy: "1.3.1"
10
10
  ---
11
11
 
12
- Archive a completed change in the experimental workflow.
12
+ ## TL;DR (Layer 1)
13
+
14
+ > **一句话**:归档已完成的 Specline change。
15
+ > **入口**:`/specline-archive-change [change-name]`
16
+ > **流程**:选 change → 检查完成度 → Delta spec sync 决策 → 移动目录 → 完成
17
+
18
+ ### 归档前后目录结构变化
19
+
20
+ ```
21
+ 归档前 (活跃、可修改) 归档后 (只读、可追溯)
22
+
23
+ specline/changes/ specline/changes/
24
+ ├── my-change/ ──▶ ├── archive/
25
+ │ ├── proposal.md │ └── 2026-06-01-my-change/
26
+ │ ├── design.md │ ├── proposal.md
27
+ │ ├── tasks.md │ ├── design.md
28
+ │ └── specs/ │ ├── tasks.md
29
+ │ └── specs/
30
+ ```
13
31
 
14
32
  **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
33
 
16
- **Steps**
34
+ ---
35
+
36
+ ## Steps (Layer 2 — Happy Path)
17
37
 
18
38
  1. **If no change name provided, prompt for selection**
19
39
 
@@ -52,6 +72,18 @@ Archive a completed change in the experimental workflow.
52
72
 
53
73
  4. **Assess delta spec sync state**
54
74
 
75
+ **决策流程:**
76
+
77
+ ```
78
+ Delta specs 存在?
79
+ ├── 否 → 直接归档
80
+ └── 是 → 比较 delta spec 与 main spec
81
+ ├── 无差异 → 「已同步」→ 直接归档
82
+ └── 有差异 → 展示变更摘要 → 询问用户
83
+ ├── 同步 → 执行 sync → 归档
84
+ └── 跳过 → 归档
85
+ ```
86
+
55
87
  Check for delta specs at `specline/changes/<name>/specs/`. If none exist, proceed without sync prompt.
56
88
 
57
89
  **If delta specs exist:**
@@ -91,7 +123,7 @@ Archive a completed change in the experimental workflow.
91
123
  - Whether specs were synced (if applicable)
92
124
  - Note about any warnings (incomplete artifacts/tasks)
93
125
 
94
- **Output On Success**
126
+ ### Output On Success
95
127
 
96
128
  ```
97
129
  ## Archive Complete
@@ -104,7 +136,10 @@ Archive a completed change in the experimental workflow.
104
136
  All artifacts complete. All tasks complete.
105
137
  ```
106
138
 
107
- **Guardrails**
139
+ ---
140
+
141
+ ## Guardrails (Layer 3 — 高级话题)
142
+
108
143
  - Always prompt for change selection if not provided
109
144
  - Use artifact graph (specline-pipeline-gate.sh artifacts --json) for completion checking
110
145
  - Don't block archive on warnings - just inform and confirm
@@ -9,6 +9,11 @@ metadata:
9
9
  generatedBy: "1.3.1"
10
10
  ---
11
11
 
12
+ > **One-liner**: You're a thinking partner, not an implementer.
13
+ > **What you can do**: Read code, draw diagrams, compare options, ask questions, challenge assumptions
14
+ > **What you can't do**: Write implementation code
15
+ > **Characteristic**: No fixed steps, no mandatory outputs — the thinking itself is the value
16
+
12
17
  Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
13
18
 
14
19
  **IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create Specline artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing.
@@ -19,12 +24,21 @@ Enter explore mode. Think deeply. Visualize freely. Follow the conversation wher
19
24
 
20
25
  ## The Stance
21
26
 
22
- - **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
23
- - **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
24
- - **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
25
- - **Adaptive** - Follow interesting threads, pivot when new information emerges
26
- - **Patient** - Don't rush to conclusions, let the shape of the problem emerge
27
- - **Grounded** - Explore the actual codebase when relevant, don't just theorize
27
+ **✅ DO:**
28
+ - **Curious, not prescriptive** Ask questions naturally, don't follow a script
29
+ - **Open threads, not interrogations** Surface multiple directions, let the user follow what resonates
30
+ - **Visual** Use ASCII diagrams liberally
31
+ - **Adaptive** Follow interesting threads, pivot when new information emerges
32
+ - **Patient** Don't rush to conclusions, let patterns emerge
33
+ - **Grounded** — Explore the actual codebase, don't just theorize
34
+
35
+ **❌ DON'T:**
36
+ - **Don't implement** — Never write implementation code
37
+ - **Don't follow a script** — No fixed workflow or mandatory outputs
38
+ - **Don't rush to conclusions** — Thinking time is not task time
39
+ - **Don't force structure** — Let patterns emerge naturally
40
+ - **Don't auto-capture** — Offer to save insights, don't assume
41
+ - **Don't cut exploration short** — Follow valuable tangents
28
42
 
29
43
  ---
30
44
 
@@ -77,7 +91,7 @@ Depending on what the user brings, you might:
77
91
 
78
92
  ## Specline Awareness
79
93
 
80
- You have full context of the OpenSpec system. Use it naturally, don't force it.
94
+ You have full context of the Specline system. Use it naturally, don't force it.
81
95
 
82
96
  ### Check for context
83
97
 
@@ -132,17 +146,6 @@ If the user mentions a change or you detect one is relevant:
132
146
 
133
147
  ---
134
148
 
135
- ## What You Don't Have To Do
136
-
137
- - Follow a script
138
- - Ask the same questions every time
139
- - Produce a specific artifact
140
- - Reach a conclusion
141
- - Stay on topic if a tangent is valuable
142
- - Be brief (this is thinking time)
143
-
144
- ---
145
-
146
149
  ## Handling Different Entry Points
147
150
 
148
151
  **User brings a vague idea:**