@wrongstack/sdd 1.0.7 → 1.0.9

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.
Files changed (2) hide show
  1. package/dist/index.js +54 -34
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1158,7 +1158,11 @@ var SddBoardStore = class {
1158
1158
  async load(runId) {
1159
1159
  try {
1160
1160
  const raw = await fsp3.readFile(this.snapshotPath(runId), "utf8");
1161
- return JSON.parse(raw);
1161
+ const value = JSON.parse(raw);
1162
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
1163
+ return value;
1164
+ }
1165
+ return null;
1162
1166
  } catch {
1163
1167
  return null;
1164
1168
  }
@@ -1287,12 +1291,7 @@ var SddBoardStore = class {
1287
1291
  } catch {
1288
1292
  return [];
1289
1293
  }
1290
- try {
1291
- await this.controlFileIO.truncate(filePath, 0);
1292
- } catch {
1293
- return [];
1294
- }
1295
- return raw.split("\n").filter((line) => line.trim()).map((line) => {
1294
+ const parseCommands = (s) => s.split("\n").filter((line) => line.trim()).map((line) => {
1296
1295
  try {
1297
1296
  return JSON.parse(line);
1298
1297
  } catch {
@@ -1301,6 +1300,16 @@ var SddBoardStore = class {
1301
1300
  }).filter(
1302
1301
  (command) => command !== null
1303
1302
  );
1303
+ try {
1304
+ await this.controlFileIO.truncate(filePath, 0);
1305
+ } catch {
1306
+ try {
1307
+ await atomicWrite3(filePath, "", { mode: 384 });
1308
+ } catch {
1309
+ return [];
1310
+ }
1311
+ }
1312
+ return parseCommands(raw);
1304
1313
  });
1305
1314
  }
1306
1315
  async readIndex() {
@@ -1324,27 +1333,29 @@ var SddBoardStore = class {
1324
1333
  return this.cachedIndex;
1325
1334
  }
1326
1335
  async updateIndex(snapshot) {
1327
- const current = await this.readIndex();
1328
- const index = {
1329
- version: 1,
1330
- entries: current.entries.map((entry2) => ({ ...entry2 }))
1331
- };
1332
- const entry = {
1333
- runId: snapshot.runId,
1334
- specId: snapshot.specId,
1335
- title: snapshot.title,
1336
- status: snapshot.status,
1337
- total: snapshot.progress.total,
1338
- completed: snapshot.progress.completed,
1339
- updatedAt: snapshot.updatedAt
1340
- };
1341
- const idx = index.entries.findIndex((e) => e.runId === snapshot.runId);
1342
- if (idx >= 0) index.entries[idx] = entry;
1343
- else index.entries.push(entry);
1344
- index.entries.sort((a, b) => b.updatedAt - a.updatedAt);
1345
- await atomicWrite3(this.indexPath, JSON.stringify(index, null, 2), { mode: 384 });
1346
- this.cachedIndex = index;
1347
- this.cachedIndexSignature = await this.indexSignature();
1336
+ await withFileLock(this.indexPath, async () => {
1337
+ const current = await this.readIndex();
1338
+ const index = {
1339
+ version: 1,
1340
+ entries: current.entries.map((entry2) => ({ ...entry2 }))
1341
+ };
1342
+ const entry = {
1343
+ runId: snapshot.runId,
1344
+ specId: snapshot.specId,
1345
+ title: snapshot.title,
1346
+ status: snapshot.status,
1347
+ total: snapshot.progress.total,
1348
+ completed: snapshot.progress.completed,
1349
+ updatedAt: snapshot.updatedAt
1350
+ };
1351
+ const idx = index.entries.findIndex((e) => e.runId === snapshot.runId);
1352
+ if (idx >= 0) index.entries[idx] = entry;
1353
+ else index.entries.push(entry);
1354
+ index.entries.sort((a, b) => b.updatedAt - a.updatedAt);
1355
+ await atomicWrite3(this.indexPath, JSON.stringify(index, null, 2), { mode: 384 });
1356
+ this.cachedIndex = index;
1357
+ this.cachedIndexSignature = await this.indexSignature();
1358
+ });
1348
1359
  }
1349
1360
  async removeFromIndex(runId) {
1350
1361
  const current = await this.readIndex();
@@ -3044,6 +3055,7 @@ async function executeSddTask(params) {
3044
3055
  if (merged.ok) {
3045
3056
  success = true;
3046
3057
  opts.tracker.updateNodeStatus(taskId, "completed");
3058
+ await params.resolveWorktrees([task]);
3047
3059
  params.emit("sdd.task.completed", {
3048
3060
  runId: params.runId,
3049
3061
  taskId,
@@ -4226,11 +4238,14 @@ async function listSddSnapshots(projectRoot, boardsDir, transport) {
4226
4238
  if (snapshots.length > 0) return snapshots;
4227
4239
  const legacy = await loadLegacySnapshots(legacyStore);
4228
4240
  for (const snapshot of legacy) {
4229
- await writeKanbanWorkflowState2(
4230
- projectRoot,
4231
- kanbanWorkflowId2("sdd", snapshot.runId),
4232
- snapshot
4233
- );
4241
+ try {
4242
+ await writeKanbanWorkflowState2(
4243
+ projectRoot,
4244
+ kanbanWorkflowId2("sdd", snapshot.runId),
4245
+ snapshot
4246
+ );
4247
+ } catch {
4248
+ }
4234
4249
  }
4235
4250
  return legacy;
4236
4251
  }
@@ -4241,7 +4256,12 @@ async function loadSddSnapshot(projectRoot, boardsDir, runId, transport) {
4241
4256
  if (transport !== "kanban") return legacyStore.load(runId);
4242
4257
  const state = await readKanbanWorkflowState(projectRoot, kanbanWorkflowId2("sdd", runId));
4243
4258
  if (isSddBoardSnapshot(state?.value)) return state.value;
4244
- const legacy = await legacyStore.load(runId);
4259
+ let legacy;
4260
+ try {
4261
+ legacy = await legacyStore.load(runId);
4262
+ } catch {
4263
+ return null;
4264
+ }
4245
4265
  if (legacy) {
4246
4266
  await writeKanbanWorkflowState2(projectRoot, kanbanWorkflowId2("sdd", runId), legacy);
4247
4267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/sdd",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack Spec-Driven Development engine — standalone package extracted from @wrongstack/core. Task graph generation, tracking, execution, lifecycle management, and AI-driven spec building for SDD workflows.",
6
6
  "repository": {
@@ -27,13 +27,13 @@
27
27
  "!dist/**/*.map"
28
28
  ],
29
29
  "dependencies": {
30
- "@wrongstack/core": "1.0.7",
31
- "@wrongstack/kanban": "1.0.7",
32
- "@wrongstack/primitives": "1.0.7",
33
- "@wrongstack/requirement-intake": "1.0.7"
30
+ "@wrongstack/core": "1.0.9",
31
+ "@wrongstack/kanban": "1.0.9",
32
+ "@wrongstack/primitives": "1.0.9",
33
+ "@wrongstack/requirement-intake": "1.0.9"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/node": "^26.2.0",
36
+ "@types/node": "^26.5.1",
37
37
  "typescript": "^7.0.2"
38
38
  },
39
39
  "publishConfig": {