oreshnik-cli 0.1.1 → 0.1.3

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/dist/cli.js CHANGED
@@ -364,8 +364,16 @@ async function initCommand(options) {
364
364
  mkdirSync(vaultDir, { recursive: true });
365
365
  mkdirSync(handoffsDir, { recursive: true });
366
366
  writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
367
- writeFileSync(join(varDir, "task-board.json"), JSON.stringify(taskBoard, null, 2) + "\n", "utf8");
368
- writeFileSync(join(varDir, ".mother-version.json"), JSON.stringify({ version: 1, current: mainBranch, branches: [] }, null, 2) + "\n", "utf8");
367
+ const taskBoardPath = join(varDir, "task-board.json");
368
+ if (existsSync(taskBoardPath)) {
369
+ log("WARN", "task-board.json already exists \u2014 not overwriting. Use --force to overwrite all files.");
370
+ } else {
371
+ writeFileSync(taskBoardPath, JSON.stringify(taskBoard, null, 2) + "\n", "utf8");
372
+ }
373
+ const motherPath = join(varDir, ".mother-version.json");
374
+ if (!existsSync(motherPath) || options.force) {
375
+ writeFileSync(motherPath, JSON.stringify({ version: 1, current: mainBranch, branches: [] }, null, 2) + "\n", "utf8");
376
+ }
369
377
  writeFileSync(join(handoffsDir, "zone-map.json"), JSON.stringify(zoneMap, null, 2) + "\n", "utf8");
370
378
  writeFileSync(join(vaultDir, config.vault.centralDoc), generateCentralDoc(projectNameFinal), "utf8");
371
379
  const collabDir = join(vaultDir, "COLABORADORES");
@@ -3950,6 +3958,31 @@ async function preflightCommand(options) {
3950
3958
  console.log("");
3951
3959
  }
3952
3960
  }
3961
+ const zoneMapPathEarly = join11(ROOT2, "docs", "07_handoffs", "zone-map.json");
3962
+ if (sprint && existsSync10(zoneMapPathEarly)) {
3963
+ try {
3964
+ const zoneRaw = JSON.parse(readFileSync10(zoneMapPathEarly, "utf8").replace(/^\uFEFF/, ""));
3965
+ const zones = zoneRaw.zones || {};
3966
+ let acquiredCount = 0;
3967
+ for (const [pattern, zone] of Object.entries(zones)) {
3968
+ const lockStr = zone.lock || "";
3969
+ const ownerStr = zone.owner || "";
3970
+ const sprints = zone.sprints || [];
3971
+ if (ownerStr !== "none" && lockStr !== "forbidden") {
3972
+ const myLock = lockResult.ok ? lockResult.value.active.find((l) => l.operator === operator && l.zone === pattern) : null;
3973
+ if (!myLock) {
3974
+ const acquireResult = lockService.acquire(pattern, operator, sprint, 7200);
3975
+ if (acquireResult.ok && acquireResult.value.acquired) acquiredCount++;
3976
+ }
3977
+ }
3978
+ }
3979
+ if (acquiredCount > 0) {
3980
+ console.log(` [LOCK] Auto-acquired ${acquiredCount} zone lock(s) for sprint ${sprint}`);
3981
+ console.log("");
3982
+ }
3983
+ } catch {
3984
+ }
3985
+ }
3953
3986
  log("INFO", "5/11 Canonical alignment");
3954
3987
  const canonical2 = createCanonicalService(state, ROOT2);
3955
3988
  const taskBoardPath = join11(ROOT2, "var", "oreshnik", "task-board.json");
@@ -5242,6 +5275,22 @@ async function closeCommand(options) {
5242
5275
  mustGit(git4.push("origin", newMother), `Failed to push mother branch ${newMother}`);
5243
5276
  mustGit(git4.pushTag("origin", tagName), `Failed to push checkpoint tag ${tagName}`);
5244
5277
  log("OK", "Pushed child branch, mother branch, and checkpoint tag.");
5278
+ try {
5279
+ const { createLockService: createLockService2 } = await Promise.resolve().then(() => (init_lock_service(), lock_service_exports));
5280
+ const lockService = createLockService2(ROOT13);
5281
+ const zoneMapPath = join14(ROOT13, "docs", "07_handoffs", "zone-map.json");
5282
+ if (existsSync14(zoneMapPath)) {
5283
+ const zoneRaw = JSON.parse(readFileSync13(zoneMapPath, "utf8").replace(/^\uFEFF/, ""));
5284
+ const zones = zoneRaw.zones || {};
5285
+ let released = 0;
5286
+ for (const [pattern] of Object.entries(zones)) {
5287
+ lockService.release(pattern);
5288
+ released++;
5289
+ }
5290
+ if (released > 0) log("INFO", `Released ${released} zone lock(s).`);
5291
+ }
5292
+ } catch {
5293
+ }
5245
5294
  mustGit(git4.checkout(branch), `Failed to checkout ${branch}`);
5246
5295
  console.log("");
5247
5296
  console.log(`SPRINT CLOSED: ${sprint}`);