speccrew 0.7.39 → 0.7.41

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.
@@ -160,7 +160,7 @@ ${api_list.error_codes}</field>
160
160
  <block type="gateway" id="G4" mode="exclusive" desc="Update progress based on mode">
161
161
  <branch test="${feature_id} != null" name="Feature mode">
162
162
  <block type="task" id="B10" action="run-script" desc="Update workflow progress for feature">
163
- <field name="command">node "${workspace_path}/scripts/update-progress.js" update-task --file "${iteration_path}/WORKFLOW-PROGRESS.json" --task-id "${feature_id}" --status confirmed --outputs '["02.feature-design/${feature_id}-${feature_name}-feature-spec.md","03.api-contract/${feature_id}-${feature_name}-api-contract.md"]'</field>
163
+ <field name="command">node "${workspace_path}/scripts/update-progress.js" update-task --file "${iteration_path}/WORKFLOW-PROGRESS.json" --stage 03_api_contract --task-id "${feature_id}" --status confirmed --outputs '["02.feature-design/${feature_id}-${feature_name}-feature-spec.md","03.api-contract/${feature_id}-${feature_name}-api-contract.md"]'</field>
164
164
  </block>
165
165
  </branch>
166
166
  <branch default="true" name="Module mode">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speccrew",
3
- "version": "0.7.39",
3
+ "version": "0.7.41",
4
4
  "description": "Spec-Driven Development toolkit for AI-powered IDEs",
5
5
  "author": "charlesmu99",
6
6
  "repository": {
@@ -152,7 +152,7 @@ function acquireLock(filePath) {
152
152
  try {
153
153
  const lockStat = fs.statSync(lockPath);
154
154
  const ageSeconds = (Date.now() - lockStat.mtimeMs) / 1000;
155
- if (ageSeconds > 120) {
155
+ if (ageSeconds > 30) {
156
156
  console.error(`Warning: Stale lock file detected (age: ${Math.round(ageSeconds)}s), removing: ${lockPath}`);
157
157
  fs.unlinkSync(lockPath);
158
158
  // Do not consume retry count, continue to next loop attempt to acquire lock
@@ -161,10 +161,32 @@ function acquireLock(filePath) {
161
161
  } catch (statErr) {
162
162
  // Lock file was deleted during stat, continue retrying
163
163
  }
164
+ } else {
165
+ // Non-EEXIST error (EACCES, EPERM, etc.) - log for debugging
166
+ if (retryCount === 0) {
167
+ console.error(`Warning: Lock creation failed with ${error.code} for: ${lockPath}`);
168
+ }
164
169
  }
165
170
  retryCount++;
166
171
  if (retryCount >= maxRetries) {
167
- throw new Error(`Failed to acquire file lock for '${filePath}' after ${maxRetries} attempts`);
172
+ // Force acquire as last resort
173
+ try {
174
+ // Remove any existing lock file regardless of age
175
+ if (fs.existsSync(lockPath)) {
176
+ fs.unlinkSync(lockPath);
177
+ }
178
+ // Brief random delay to avoid thundering herd on force acquire
179
+ const forceDelay = Math.floor(Math.random() * 500);
180
+ const forceStart = Date.now();
181
+ while (Date.now() - forceStart < forceDelay) {}
182
+
183
+ const fd = fs.openSync(lockPath, 'wx');
184
+ fs.closeSync(fd);
185
+ console.error(`Warning: Lock acquired by force after ${maxRetries} retries for: ${filePath}`);
186
+ return lockPath;
187
+ } catch (forceErr) {
188
+ throw new Error(`Failed to acquire file lock for '${filePath}' after ${maxRetries} attempts (force acquire also failed: ${forceErr.code})`);
189
+ }
168
190
  }
169
191
  // Retry with jitter to avoid thundering herd
170
192
  const delay = 200 + Math.floor(Math.random() * 300);
@@ -630,13 +652,16 @@ function cmdUpdateTask(args) {
630
652
  outputError(`Stage not found: ${args.stage}`);
631
653
  }
632
654
  targetStage = data.stages[args.stage];
633
- if (!targetStage.features || !Array.isArray(targetStage.features)) {
634
- outputError(`Stage has no features array: ${args.stage}`);
655
+ if (!targetStage.features) {
656
+ targetStage.features = [];
635
657
  }
636
658
  taskArray = targetStage.features;
637
659
  taskIndex = taskArray.findIndex(t => t.id === args.taskId);
638
660
  if (taskIndex === -1) {
639
- outputError(`Task not found in stage ${args.stage}: ${args.taskId}`);
661
+ // UPSERT: Task not found, create new entry
662
+ console.error(`Info: Task ${args.taskId} not found in stage ${args.stage}, creating new entry`);
663
+ taskArray.push({ id: args.taskId, status: 'pending' });
664
+ taskIndex = taskArray.length - 1;
640
665
  }
641
666
  } else {
642
667
  // Flat structure: data.tasks