sillyspec 3.12.4 → 3.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sillyspec",
3
- "version": "3.12.4",
3
+ "version": "3.12.5",
4
4
  "description": "SillySpec CLI — 流程状态机,让 AI 严格按步骤来",
5
5
  "icon": "logo.jpg",
6
6
  "homepage": "https://sillyspec.ppdmq.top/",
@@ -48,11 +48,11 @@ const DANGER_PREFIXES = ['sudo', 'rm -rf', 'rm -r', 'rmdir']
48
48
  const STAGE_HINTS = {
49
49
  '(none)': [
50
50
  '没有检测到活跃的 SillySpec 流程。',
51
- '你需要先启动一个任务流程才能修改源码:',
51
+ '你需要先启动一个任务流程才能修改源码(调用对应的 sillyspec skill):',
52
52
  '',
53
- ' 小改动(≤3 文件):sillyspec run quick "任务描述"',
54
- ' 大改动(>3 文件):sillyspec run brainstorm → plan → execute',
55
- ' 全自动模式: sillyspec run auto "任务描述"',
53
+ ' BUG修复(skill sillyspec-quick):sillyspec run quick "任务描述"',
54
+ ' 逻辑变更(skill sillyspec-brainstorm):sillyspec run brainstorm → plan → execute → verify → archive',
55
+ ' 全自动模式(skill sillyspec-auto):sillyspec run auto "任务描述"',
56
56
  ],
57
57
  'brainstorm': [
58
58
  '当前在 brainstorm(需求分析)阶段,这个阶段只写文档,不写代码。',
@@ -306,12 +306,8 @@ function isSingleCommandReadonly(cmd, extraReadonlyCommands = []) {
306
306
  return false
307
307
  }
308
308
 
309
- // sillyspec worktree 命令
310
- if (cmdName === 'sillyspec') {
311
- const sub = parts[1] || ''
312
- if (sub === 'worktree') return true
313
- return false
314
- }
309
+ // sillyspec 命令全部放行(CLI 工具本身安全)
310
+ if (cmdName === 'sillyspec') return true
315
311
 
316
312
  return false
317
313
  }
package/src/index.js CHANGED
@@ -268,7 +268,8 @@ async function main() {
268
268
  case 'worktree': {
269
269
  const { WorktreeManager } = await import('./worktree.js');
270
270
  const wtSubCmd = filteredArgs[1];
271
- const wtName = filteredArgs[2];
271
+ // 提取第一个非 -- 开头的位置参数作为 wtName
272
+ const wtName = filteredArgs.slice(2).find(a => !a.startsWith('-'));
272
273
  const wm = new WorktreeManager({ cwd: dir });
273
274
 
274
275
  if (!wtSubCmd || wtSubCmd === 'help' || wtSubCmd === '--help' || wtSubCmd === '-h') {
@@ -338,6 +339,11 @@ SillySpec worktree — git worktree 隔离管理
338
339
  } else {
339
340
  console.log(`✅ 已应用 ${result.changedFiles.length} 个文件变更`);
340
341
  }
342
+ if (result.warnings && result.warnings.length > 0) {
343
+ for (const w of result.warnings) {
344
+ console.log(`⚠️ ${w}`);
345
+ }
346
+ }
341
347
  break;
342
348
  }
343
349
  case 'list': {
package/src/run.js CHANGED
@@ -195,6 +195,24 @@ async function outputStep(stageName, stepIndex, steps, cwd, changeName, dbProjec
195
195
  if (projectName && promptText.includes('<project>')) {
196
196
  promptText = promptText.replace(/<project>/g, projectName)
197
197
  }
198
+ // 替换 <git-user> 占位符
199
+ if (promptText.includes('<git-user>')) {
200
+ const { execSync } = await import('child_process')
201
+ try {
202
+ const gitUser = execSync('git config user.name', { cwd, encoding: 'utf8', timeout: 5000 }).trim()
203
+ promptText = promptText.replace(/<git-user>/g, gitUser)
204
+ } catch {
205
+ promptText = promptText.replace(/<git-user>/g, 'unknown')
206
+ }
207
+ }
208
+ // 替换时间戳占位符
209
+ const now = new Date()
210
+ const nowDatetime = now.getFullYear() + '-' + String(now.getMonth()+1).padStart(2,'0') + '-' + String(now.getDate()).padStart(2,'0') + ' ' + String(now.getHours()).padStart(2,'0') + ':' + String(now.getMinutes()).padStart(2,'0') + ':' + String(now.getSeconds()).padStart(2,'0')
211
+ const nowTimestamp = now.getFullYear() + String(now.getMonth()+1).padStart(2,'0') + String(now.getDate()).padStart(2,'0') + '-' + String(now.getHours()).padStart(2,'0') + String(now.getMinutes()).padStart(2,'0') + String(now.getSeconds()).padStart(2,'0')
212
+ const nowDate = now.getFullYear() + '-' + String(now.getMonth()+1).padStart(2,'0') + '-' + String(now.getDate()).padStart(2,'0')
213
+ promptText = promptText.replace(/<now-datetime>/g, nowDatetime)
214
+ promptText = promptText.replace(/<now-timestamp>/g, nowTimestamp)
215
+ promptText = promptText.replace(/<now-date>/g, nowDate)
198
216
  console.log(promptText)
199
217
  console.log(`\n### ⚠️ 铁律`)
200
218
  console.log('- **文档是核心资产,代码是文档的产物。** 没有文档就没有代码——文档是 AI 的记忆,是团队协作的基础,是后续维护的唯一依据。任何代码产出必须先有对应的设计/规范文档支撑。')
@@ -46,8 +46,8 @@ export const definition = {
46
46
  \`\`\`markdown
47
47
  # 模块影响分析
48
48
 
49
- author: <git用户名>
50
- created_at: <YYYY-MM-DD HH:mm:ss>
49
+ author: <git-user>
50
+ created_at: <now-datetime>
51
51
 
52
52
  ## 变更:<change-name>
53
53
 
@@ -90,7 +90,7 @@ module-impact.md 路径 + 影响模块数量 + 未匹配文件数量`,
90
90
  - 更新:只改相关章节(当前设计/对外接口/依赖关系等),保持其他章节不变
91
91
  - 正文重写为当前状态,不追加历史
92
92
  - 底部"变更索引"追加一行:\`| <日期> | <变更名> | <一句话摘要> |\`
93
- d. 更新头部元数据:\`> 最后更新:YYYY-MM-DD\`、\`> 最近变更:<change-name>\`
93
+ d. 更新头部元数据:\`> 最后更新:<now-date>\`、\`> 最近变更:<change-name>\`
94
94
  4. 展示所有模块文档的更新内容(diff 摘要),请用户确认
95
95
  5. 用户确认后,写入 \`.sillyspec/docs/<project>/modules/*.md\`
96
96
  6. 用户拒绝时,不写入模块文档,但提示"module-impact.md 已保留,可稍后手动同步"
@@ -100,7 +100,7 @@ module-impact.md 路径 + 影响模块数量 + 未匹配文件数量`,
100
100
  \`\`\`markdown
101
101
  # <module-name>
102
102
 
103
- > 最后更新:YYYY-MM-DD
103
+ > 最后更新:<now-date>
104
104
  > 最近变更:<change-name>
105
105
  > 模块路径:<glob patterns>
106
106
 
@@ -24,10 +24,10 @@ export const definition = {
24
24
 
25
25
  ### 创建任务记录(必须执行)
26
26
  理解完任务后,立即创建记录文件:
27
- 1. \`git config user.name\` 获取用户名
28
- 2. 无 \`--change\`:创建 .sillyspec/quicklog/QUICKLOG-<git用户名>.md\`(已存在则追加),写入:
27
+ 1. 使用预注入的 git 用户名:\`<git-user>\`
28
+ 2. 无 \`--change\`:创建 .sillyspec/quicklog/QUICKLOG-\`<git-user>\`.md\`(已存在则追加),写入:
29
29
  \`\`\`
30
- ## YYYY-MM-DD HH:mm:ss — <一句话任务描述>
30
+ ## <now-datetime> — <一句话任务描述>
31
31
  状态:进行中
32
32
  文件:<预估要改的文件>
33
33
  \`\`\`
@@ -47,7 +47,7 @@ export const definition = {
47
47
  ### 操作
48
48
  1. 确定变更名(change name):
49
49
  - 如携带 \`--change <变更名>\`,使用该变更名
50
- - 否则,生成临时变更名:\`quick-<当前时间戳 YYYYMMDD-HHmmss>\`
50
+ - 否则,生成临时变更名:\`quick-<now-timestamp>\`
51
51
  2. 运行 \`sillyspec worktree create <变更名>\`
52
52
  3. 记录输出的 worktree 路径(后续步骤需要使用)
53
53
  4. 如果创建失败 → 报错并停止(不要在无隔离状态下继续)
@@ -265,7 +265,7 @@ _module-map.yaml 生成结果(已存在/已生成/模块列表)`,
265
265
  3. 按以下模板写入目标文件:
266
266
 
267
267
  # <module-name>
268
- > 最后更新:YYYY-MM-DD
268
+ > 最后更新:<now-date>
269
269
  > 最近变更:scan(初始生成)
270
270
  > 模块路径:<glob patterns>
271
271
 
@@ -251,8 +251,13 @@ export function applyWorktree(changeName, { cwd, checkOnly = false } = {}) {
251
251
 
252
252
  result.ok = true;
253
253
 
254
- // --- 8. 成功后自动 cleanup ---
255
- wm.cleanup(changeName);
254
+ // --- 8. 成功后自动 cleanup(失败不影响整体结果) ---
255
+ try {
256
+ wm.cleanup(changeName);
257
+ } catch (cleanupErr) {
258
+ result.warnings = result.warnings || [];
259
+ result.warnings.push(`cleanup 失败(不影响应用结果): ${cleanupErr.message}`);
260
+ }
256
261
 
257
262
  } catch (e) {
258
263
  result.errors.push(`patch 生成/应用异常: ${e.message}`);