specline 1.3.2 → 1.3.4

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/cli.mjs CHANGED
@@ -5,6 +5,8 @@ import { join, dirname, resolve, relative, basename } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { createHash } from 'crypto';
7
7
  import { get } from 'https';
8
+ import { execSync, spawnSync } from 'child_process';
9
+ import { createInterface } from 'readline/promises';
8
10
 
9
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
10
12
  const TEMPLATES_DIR = join(__dirname, 'templates');
@@ -366,7 +368,6 @@ function cmd_init(targetPath) {
366
368
  // 创建目录结构
367
369
  const dirs = [
368
370
  '.cursor/agents',
369
- '.cursor/commands',
370
371
  '.cursor/skills',
371
372
  '.cursor/hooks',
372
373
  'specline/changes/archive',
@@ -402,12 +403,11 @@ function cmd_init(targetPath) {
402
403
  }
403
404
 
404
405
  const agentsCount = countFiles(join(target, '.cursor', 'agents'));
405
- const commandsCount = countFiles(join(target, '.cursor', 'commands'));
406
406
  const skillsCount = countFiles(join(target, '.cursor', 'skills'));
407
407
  const hooksCount = countFiles(join(target, '.cursor', 'hooks'));
408
408
 
409
409
  success('Specline 初始化完成');
410
- log(`📁 文件: ${commandsCount} commands, ${skillsCount} skills, ${agentsCount} agents, ${hooksCount} hooks`);
410
+ log(`📁 文件: ${skillsCount} skills, ${agentsCount} agents, ${hooksCount} hooks`);
411
411
  log('');
412
412
  log('🚀 试试在 Cursor 中输入:');
413
413
  log(' /specline-pipeline "你的第一个需求"');
@@ -455,7 +455,26 @@ function fetchLatestVersion() {
455
455
  });
456
456
  }
457
457
 
458
+ /**
459
+ * 交互式确认提问:回车/Y/y/Yes/yes → true, N/n/No/no → false
460
+ * 非 TTY 环境直接返回 true(无人值守模式)
461
+ */
462
+ async function askConfirm(question) {
463
+ if (!process.stdin.isTTY) return true;
464
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
465
+ try {
466
+ const answer = await rl.question(question + ' ');
467
+ const trimmed = answer.trim().toLowerCase();
468
+ return trimmed === '' || trimmed === 'y' || trimmed === 'yes';
469
+ } catch {
470
+ return false;
471
+ } finally {
472
+ rl.close();
473
+ }
474
+ }
475
+
458
476
  async function cmd_update() {
477
+ // 1. 从 npm registry 获取最新版本
459
478
  let latest;
460
479
  try {
461
480
  latest = await fetchLatestVersion();
@@ -473,25 +492,60 @@ async function cmd_update() {
473
492
  process.exit(0);
474
493
  }
475
494
 
476
- const currentParts = VERSION.split('.').map(Number);
477
- const latestParts = latest.split('.').map(Number);
495
+ // 2. 版本比较
496
+ if (compareVersions(VERSION, latest) >= 0) {
497
+ success('已是最新版本 (v' + VERSION + ')');
498
+ process.exit(0);
499
+ }
478
500
 
479
- let isNewer = false;
480
- for (let i = 0; i < 3; i++) {
481
- const c = currentParts[i] || 0;
482
- const l = latestParts[i] || 0;
483
- if (l > c) {
484
- isNewer = true;
485
- break;
486
- } else if (l < c) {
487
- break;
501
+ // 3. 交互确认
502
+ log('✨ 新版本可用: v' + latest + '(当前: v' + VERSION + ')');
503
+
504
+ if (!process.stdin.isTTY) {
505
+ log('在非交互环境中无法自动升级,请手动执行: npm install -g specline@latest');
506
+ process.exit(0);
507
+ }
508
+
509
+ const proceed = await askConfirm('是否升级到 v' + latest + '?[Y/n]');
510
+ if (!proceed) {
511
+ log('已取消升级');
512
+ process.exit(0);
513
+ }
514
+
515
+ // 4. 执行 npm install -g specline@latest
516
+ log('正在升级 specline...');
517
+ try {
518
+ execSync('npm install -g specline@latest', { stdio: 'inherit' });
519
+ } catch (err) {
520
+ const stderr = (err.stderr || '').toString();
521
+ if (stderr.includes('EACCES') || stderr.includes('permission denied')) {
522
+ error('权限不足。请尝试:');
523
+ log(' sudo npm install -g specline@latest');
524
+ log(' 或使用 Node 版本管理器(nvm / fnm / n)');
525
+ } else {
526
+ error('升级失败:' + (stderr || err.message));
488
527
  }
528
+ process.exit(1);
489
529
  }
490
530
 
491
- if (isNewer) {
492
- log('✨ 新版本可用: v' + latest + '(当前: v' + VERSION + ')\n运行 npm install -g specline@latest 更新');
493
- } else {
494
- success('已是最新版本 (v' + VERSION + ')');
531
+ success('已升级至 v' + latest);
532
+
533
+ // 5. 检测是否为 specline 项目,询问是否同步模板
534
+ const cwd = process.cwd();
535
+ const lockFile = join(cwd, 'specline', '.specline-lock.yaml');
536
+ if (existsSync(lockFile)) {
537
+ const doSync = await askConfirm('检测到 specline 项目,是否同步最新模板?[Y/n]');
538
+ if (doSync) {
539
+ log('正在同步模板文件...');
540
+ try {
541
+ const result = spawnSync('specline', ['sync'], { stdio: 'inherit' });
542
+ if (result.status !== 0) {
543
+ warn('模板同步失败(退出码: ' + result.status + '),请手动运行 specline sync');
544
+ }
545
+ } catch (err) {
546
+ warn('无法运行 specline sync:' + err.message);
547
+ }
548
+ }
495
549
  }
496
550
 
497
551
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specline",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Spec-driven AI coding pipeline with deterministic quality gates for Cursor IDE",
5
5
  "bin": {
6
6
  "specline": "./cli.mjs"
@@ -1,182 +0,0 @@
1
- ---
2
- name: /specline-explore
3
- id: specline-explore
4
- category: Workflow
5
- description: "Enter explore mode - think through ideas, investigate problems, clarify requirements"
6
- ---
7
-
8
- ## ⚠️ 硬边界:探索模式禁止直接写代码
9
-
10
- **你只能做这些**:读取代码、画图、提问、比较方案、质疑假设、创建 Specline artifacts(proposal/design/specs)
11
- **你不能做这些**:写入/修改任何实现代码文件(Write、StrReplace、Delete、Shell 等会导致代码变更的操作)
12
-
13
- 如果用户要你写代码 → 提醒退出探索模式,先 `/specline-pipeline` 或 `/specline-quickfix`。
14
-
15
- ---
16
-
17
- Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
18
-
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.
20
-
21
- **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
22
-
23
- **Input**: The argument after `/specline-explore` is whatever the user wants to think about. Could be:
24
- - A vague idea: "real-time collaboration"
25
- - A specific problem: "the auth system is getting unwieldy"
26
- - A change name: "add-dark-mode" (to explore in context of that change)
27
- - A comparison: "postgres vs sqlite for this"
28
- - Nothing (just enter explore mode)
29
-
30
- ---
31
-
32
- ## The Stance
33
-
34
- - **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
35
- - **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.
36
- - **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
37
- - **Adaptive** - Follow interesting threads, pivot when new information emerges
38
- - **Patient** - Don't rush to conclusions, let the shape of the problem emerge
39
- - **Grounded** - Explore the actual codebase when relevant, don't just theorize
40
-
41
- ---
42
-
43
- ## What You Might Do
44
-
45
- Depending on what the user brings, you might:
46
-
47
- **Explore the problem space**
48
- - Ask clarifying questions that emerge from what they said
49
- - Challenge assumptions
50
- - Reframe the problem
51
- - Find analogies
52
-
53
- **Investigate the codebase**
54
- - Map existing architecture relevant to the discussion
55
- - Find integration points
56
- - Identify patterns already in use
57
- - Surface hidden complexity
58
-
59
- **Compare options**
60
- - Brainstorm multiple approaches
61
- - Build comparison tables
62
- - Sketch tradeoffs
63
- - Recommend a path (if asked)
64
-
65
- **Visualize**
66
- ```
67
- ┌─────────────────────────────────────────┐
68
- │ Use ASCII diagrams liberally │
69
- ├─────────────────────────────────────────┤
70
- │ │
71
- │ ┌────────┐ ┌────────┐ │
72
- │ │ State │────────▶│ State │ │
73
- │ │ A │ │ B │ │
74
- │ └────────┘ └────────┘ │
75
- │ │
76
- │ System diagrams, state machines, │
77
- │ data flows, architecture sketches, │
78
- │ dependency graphs, comparison tables │
79
- │ │
80
- └─────────────────────────────────────────┘
81
- ```
82
-
83
- **Surface risks and unknowns**
84
- - Identify what could go wrong
85
- - Find gaps in understanding
86
- - Suggest spikes or investigations
87
-
88
- ---
89
-
90
- ## Specline Awareness
91
-
92
- You have full context of the Specline system. Use it naturally, don't force it.
93
-
94
- ### Check for context
95
-
96
- At the start, quickly check what exists:
97
- ```bash
98
- specline-pipeline-gate.sh list --json
99
- ```
100
-
101
- This tells you:
102
- - If there are active changes
103
- - Their names, schemas, and status
104
- - What the user might be working on
105
-
106
- If the user mentioned a specific change name, read its artifacts for context.
107
-
108
- ### When no change exists
109
-
110
- Think freely. When insights crystallize, you might offer:
111
-
112
- - "This feels solid enough to start a change. Want me to create a proposal?"
113
- - Or keep exploring - no pressure to formalize
114
-
115
- ### When a change exists
116
-
117
- If the user mentions a change or you detect one is relevant:
118
-
119
- 1. **Read existing artifacts for context**
120
- - `specline/changes/<name>/proposal.md`
121
- - `specline/changes/<name>/design.md`
122
- - `specline/changes/<name>/tasks.md`
123
- - etc.
124
-
125
- 2. **Reference them naturally in conversation**
126
- - "Your design mentions using Redis, but we just realized SQLite fits better..."
127
- - "The proposal scopes this to premium users, but we're now thinking everyone..."
128
-
129
- 3. **Offer to capture when decisions are made**
130
-
131
- | Insight Type | Where to Capture |
132
- |----------------------------|--------------------------------|
133
- | New requirement discovered | `specs/<capability>/spec.md` |
134
- | Requirement changed | `specs/<capability>/spec.md` |
135
- | Design decision made | `design.md` |
136
- | Scope changed | `proposal.md` |
137
- | New work identified | `tasks.md` |
138
- | Assumption invalidated | Relevant artifact |
139
-
140
- Example offers:
141
- - "That's a design decision. Capture it in design.md?"
142
- - "This is a new requirement. Add it to specs?"
143
- - "This changes scope. Update the proposal?"
144
-
145
- 4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
146
-
147
- ---
148
-
149
- ## What You Don't Have To Do
150
-
151
- - Follow a script
152
- - Ask the same questions every time
153
- - Produce a specific artifact
154
- - Reach a conclusion
155
- - Stay on topic if a tangent is valuable
156
- - Be brief (this is thinking time)
157
-
158
- ---
159
-
160
- ## Ending Discovery
161
-
162
- There's no required ending. Discovery might:
163
-
164
- - **Flow into a proposal**: "Ready to start? I can create a change proposal."
165
- - **Result in artifact updates**: "Updated design.md with these decisions"
166
- - **Just provide clarity**: User has what they need, moves on
167
- - **Continue later**: "We can pick this up anytime"
168
-
169
- When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
170
-
171
- ---
172
-
173
- ## Guardrails
174
-
175
- - **Don't implement** - Never write code or implement features. Creating Specline artifacts is fine, writing application code is not.
176
- - **Don't fake understanding** - If something is unclear, dig deeper
177
- - **Don't rush** - Discovery is thinking time, not task time
178
- - **Don't force structure** - Let patterns emerge naturally
179
- - **Don't auto-capture** - Offer to save insights, don't just do it
180
- - **Do visualize** - A good diagram is worth many paragraphs
181
- - **Do explore the codebase** - Ground discussions in reality
182
- - **Do question assumptions** - Including the user's and your own
@@ -1,22 +0,0 @@
1
- ---
2
- name: /specline-pipeline
3
- id: specline-pipeline
4
- category: Workflow
5
- description: 开发流水线元 Skill —— 编排 Spec → Coding → Review → Test → Archive 全流程
6
- ---
7
-
8
- 开发流水线,自动编排从需求到归档的全流程。
9
-
10
- **用法:**
11
- - `/specline-pipeline <自然语言需求>` — 新建流水线
12
- - `/specline-pipeline --change <change-name>` — 恢复指定流水线
13
- - `/specline-pipeline` — 列出所有未完成流水线,选择继续
14
-
15
- **阶段:**
16
- 1. Spec 编写与审核(specline-spec-creator 生成 → specline-spec-reviewer 审核)
17
- 2. Coding 编码(基于 tasks.md 任务依赖分批并发)
18
- 3. Code Review 审查(specline-code-reviewer)
19
- 4. Test 测试链(单元 → 集成 → E2E,测试 Agent 为黑盒)
20
- 5. Archive 归档
21
-
22
- 每个阶段有确定性门禁(exit code 判定,零 LLM 参与),3 个人工检查点(Spec 确认、Review 复核、归档确认)。支持断点续跑。
@@ -1,24 +0,0 @@
1
- ---
2
- name: /specline-quickfix
3
- id: specline-quickfix
4
- category: Workflow
5
- description: 轻量修改 Skill —— 小改动用 quickfix,大功能用 pipeline
6
- ---
7
-
8
- 轻量修改流程,在不创建规划文档的情况下快速执行小改动。
9
-
10
- **用法:**
11
- - `/specline-quickfix <描述>` — 执行轻量修改流程(修 bug、改配置、文档微调等小改动)
12
-
13
- **阶段:**
14
- 1. UNDERSTAND — 读取相关代码,理解变更上下文
15
- 2. IMPLEMENT — 直接编辑文件(单 Agent,无子 Agent)
16
- 3. REVIEW — ReadLints 自动校验 + 修复(最多 2 次)+ Agent 自审
17
- 4. TEST — 运行项目已有单元测试(失败修复最多 2 次),无测试则跳过
18
- 5. ARCHIVE — 生成 summary.md + files-changed.json,询问 git commit
19
-
20
- **适用场景**:1-3 个文件改动、单一关注点、不涉及架构变更、不需要新测试。
21
-
22
- **不适合的场景**(应使用 `/specline-pipeline`):4+ 个文件改动、新增功能/重构、需要新测试、跨模块/多关注点。
23
-
24
- 0 个人工确认点,全程自动质量保证。