sillyspec 3.7.21 → 3.7.23

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.7.21",
3
+ "version": "3.7.23",
4
4
  "description": "SillySpec CLI — 流程状态机,让 AI 严格按步骤来",
5
5
  "icon": "logo.jpg",
6
6
  "homepage": "https://sillyspec.ppdmq.top/",
package/src/index.js CHANGED
@@ -120,8 +120,8 @@ async function main() {
120
120
  case 'progress': {
121
121
  const pm = new ProgressManager();
122
122
  const subCommand = filteredArgs[1];
123
- const stageIdx = args.indexOf('--stage');
124
- const stage = stageIdx >= 0 && args[stageIdx + 1] ? args[stageIdx + 1] : null;
123
+ const stageIdx = filteredArgs.indexOf('--stage');
124
+ const stage = stageIdx >= 0 && filteredArgs[stageIdx + 1] ? filteredArgs[stageIdx + 1] : null;
125
125
 
126
126
  switch (subCommand) {
127
127
  case 'init':
package/src/init.js CHANGED
@@ -3,6 +3,7 @@ import { join, resolve, dirname, basename } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { homedir } from 'os';
5
5
  import { checkbox, select, confirm, input } from '@inquirer/prompts';
6
+ import { ProgressManager } from './progress.js';
6
7
  import chalk from 'chalk';
7
8
 
8
9
  const __filename = fileURLToPath(import.meta.url);
@@ -154,19 +155,8 @@ async function doInstall(projectDir, tools, isWorkspace, subprojects = []) {
154
155
  // 创建初始 progress.json
155
156
  const progressPath = join(runtimeDir, 'progress.json');
156
157
  if (!existsSync(progressPath)) {
157
- const initialProgress = {
158
- project: projectName,
159
- currentStage: '',
160
- stages: {
161
- brainstorm: { status: 'pending', steps: [], startedAt: null, completedAt: null },
162
- propose: { status: 'pending', steps: [], startedAt: null, completedAt: null },
163
- plan: { status: 'pending', steps: [], startedAt: null, completedAt: null },
164
- execute: { status: 'pending', steps: [], startedAt: null, completedAt: null },
165
- verify: { status: 'pending', steps: [], startedAt: null, completedAt: null }
166
- },
167
- lastActive: null
168
- };
169
- writeFileSync(progressPath, JSON.stringify(initialProgress, null, 2) + '\n');
158
+ const pm = new ProgressManager();
159
+ pm.init(dir);
170
160
  }
171
161
 
172
162
  // 创建初始 user-inputs.md
package/src/progress.js CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { existsSync, mkdirSync, readFileSync, writeFileSync, renameSync, readdirSync, unlinkSync } from 'fs';
10
- import { join, resolve, dirname } from 'path';
10
+ import { join, resolve, dirname, basename } from 'path';
11
11
  import { fileURLToPath } from 'url';
12
12
 
13
13
  const __filename = fileURLToPath(import.meta.url);
@@ -103,7 +103,7 @@ export class ProgressManager {
103
103
  return this.read(cwd);
104
104
  }
105
105
 
106
- const project = require('path').basename(cwd);
106
+ const project = basename(cwd);
107
107
  const data = makeInitialProgress(project);
108
108
  this._write(cwd, data);
109
109
  console.log(`✅ 已创建 ${join(RUNTIME_DIR, PROGRESS_FILE)}`);
@@ -209,7 +209,7 @@ export class ProgressManager {
209
209
 
210
210
  // 标记所有未完成步骤为 completed
211
211
  for (const step of stageData.steps) {
212
- if (step.status !== 'completed') step.status = 'completed';
212
+ if (step.status === 'pending') step.status = 'completed';
213
213
  }
214
214
 
215
215
  // 推进到下一个未完成阶段
@@ -358,7 +358,7 @@ export class ProgressManager {
358
358
  this._ensureDir(cwd);
359
359
  const progressPath = this._path(cwd, PROGRESS_FILE);
360
360
  if (!existsSync(progressPath)) {
361
- data = makeInitialProgress(require('path').basename(cwd));
361
+ data = makeInitialProgress(basename(cwd));
362
362
  this._write(cwd, data);
363
363
  } else {
364
364
  console.log('❌ progress.json 损坏,请运行 sillyspec progress validate');
package/src/run.js CHANGED
@@ -153,10 +153,10 @@ export function runCommand(args, cwd) {
153
153
  }
154
154
 
155
155
  // 默认:输出当前步骤
156
- return runStage(progress, stageName, cwd)
156
+ return runStage(pm, progress, stageName, cwd)
157
157
  }
158
158
 
159
- function runStage(progress, stageName, cwd) {
159
+ function runStage(pm, progress, stageName, cwd) {
160
160
  const stageData = progress.stages[stageName]
161
161
  if (!stageData || !stageData.steps) {
162
162
  console.error(`❌ 阶段 ${stageName} 未初始化`)
@@ -172,6 +172,7 @@ function runStage(progress, stageName, cwd) {
172
172
  stageData.status = 'in_progress'
173
173
  stageData.completedAt = null
174
174
  console.log(`🔄 ${stageName} 阶段已完成,重新开始...\n`)
175
+ pm._write(cwd, progress)
175
176
  currentIdx = 0
176
177
  }
177
178
 
@@ -193,13 +194,15 @@ function validateMetadata(cwd, stageName) {
193
194
  function walk(dir) {
194
195
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
195
196
  const full = join(dir, entry.name)
196
- if (entry.isDirectory()) { walk(full); continue }
197
- if (!/\.(md|yaml|yml)$/.test(entry.name)) continue
198
- const mtime = statSync(full).mtimeMs
199
- if (mtime < cutoff) continue
200
- const content = readFileSync(full, 'utf-8')
201
- if (!content.includes('author:') && !content.includes('author:')) missing.push(full)
202
- if (!content.includes('created_at:') && !content.includes('created_at:')) missing.push(full)
197
+ try {
198
+ if (entry.isDirectory()) { walk(full); continue }
199
+ if (!/\.(md|yaml|yml)$/.test(entry.name)) continue
200
+ const mtime = statSync(full).mtimeMs
201
+ if (mtime < cutoff) continue
202
+ const content = readFileSync(full, 'utf-8')
203
+ if (!content.includes('author:') && !content.includes('author:')) missing.push(full)
204
+ if (!content.includes('created_at:') && !content.includes('created_at:')) missing.push(full)
205
+ } catch (e) { /* skip unreadable files */ }
203
206
  }
204
207
  }
205
208