@lumenflow/cli 3.12.6 → 3.12.7

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 (109) hide show
  1. package/dist/wu-claim.js +2 -1
  2. package/dist/wu-claim.js.map +1 -1
  3. package/dist/wu-done-policies.js +9 -9
  4. package/dist/wu-done-policies.js.map +1 -1
  5. package/dist/wu-spawn-strategy-resolver.js +14 -6
  6. package/dist/wu-spawn-strategy-resolver.js.map +1 -1
  7. package/package.json +8 -8
  8. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  9. package/packs/sidekick/package.json +1 -1
  10. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  11. package/packs/software-delivery/package.json +1 -1
  12. package/dist/chunk-2D2VOCA4.js +0 -37
  13. package/dist/chunk-2D5KFYGX.js +0 -284
  14. package/dist/chunk-2GXVIN57.js +0 -14072
  15. package/dist/chunk-2MQ7HZWZ.js +0 -26
  16. package/dist/chunk-2UFQ3A3C.js +0 -643
  17. package/dist/chunk-3RG5ZIWI.js +0 -10
  18. package/dist/chunk-4N74J3UT.js +0 -15
  19. package/dist/chunk-5GTOXFYR.js +0 -392
  20. package/dist/chunk-5VY6MQMC.js +0 -240
  21. package/dist/chunk-67XVPMRY.js +0 -1297
  22. package/dist/chunk-6HO4GWJE.js +0 -164
  23. package/dist/chunk-6W5XHWYV.js +0 -1890
  24. package/dist/chunk-6X4EMYJQ.js +0 -64
  25. package/dist/chunk-6XYXI2NQ.js +0 -772
  26. package/dist/chunk-7ANSOV6Q.js +0 -285
  27. package/dist/chunk-A624LFLB.js +0 -1380
  28. package/dist/chunk-ADN5NHG4.js +0 -126
  29. package/dist/chunk-B7YJYJKG.js +0 -33
  30. package/dist/chunk-CCLHCPKG.js +0 -210
  31. package/dist/chunk-CK36VROC.js +0 -1584
  32. package/dist/chunk-D3UOFRSB.js +0 -81
  33. package/dist/chunk-DFR4DJBM.js +0 -230
  34. package/dist/chunk-DSYBDHYH.js +0 -79
  35. package/dist/chunk-DWMLTXKQ.js +0 -1176
  36. package/dist/chunk-E3REJTAJ.js +0 -28
  37. package/dist/chunk-EA3IVO64.js +0 -633
  38. package/dist/chunk-EK2AKZKD.js +0 -55
  39. package/dist/chunk-ELD7JTTT.js +0 -343
  40. package/dist/chunk-EX6TT2XI.js +0 -195
  41. package/dist/chunk-EXINSFZE.js +0 -82
  42. package/dist/chunk-EZ6ZBYBM.js +0 -510
  43. package/dist/chunk-FBKAPTJ2.js +0 -16
  44. package/dist/chunk-FVLV5RYH.js +0 -1118
  45. package/dist/chunk-GDNSBQVK.js +0 -2485
  46. package/dist/chunk-GPQHMBNN.js +0 -278
  47. package/dist/chunk-GTFJB67L.js +0 -68
  48. package/dist/chunk-HANJXVKW.js +0 -1127
  49. package/dist/chunk-HEVS5YLD.js +0 -269
  50. package/dist/chunk-HMEVZKPQ.js +0 -9
  51. package/dist/chunk-HRGSYNLM.js +0 -3511
  52. package/dist/chunk-ISZR5N4K.js +0 -60
  53. package/dist/chunk-J6SUPR2C.js +0 -226
  54. package/dist/chunk-JERYVEIZ.js +0 -244
  55. package/dist/chunk-JHHWGL2N.js +0 -87
  56. package/dist/chunk-JONWQUB5.js +0 -775
  57. package/dist/chunk-K2DIWWDM.js +0 -1766
  58. package/dist/chunk-KY4PGL5V.js +0 -969
  59. package/dist/chunk-L737LQ4C.js +0 -1285
  60. package/dist/chunk-LFTWYIB2.js +0 -497
  61. package/dist/chunk-LV47RFNJ.js +0 -41
  62. package/dist/chunk-MKSAITI7.js +0 -15
  63. package/dist/chunk-MZ7RKIX4.js +0 -212
  64. package/dist/chunk-NAP6CFSO.js +0 -84
  65. package/dist/chunk-ND6MY37M.js +0 -16
  66. package/dist/chunk-NMG736UR.js +0 -683
  67. package/dist/chunk-NRAXROED.js +0 -32
  68. package/dist/chunk-NRIZR3A7.js +0 -690
  69. package/dist/chunk-NX43BG3M.js +0 -233
  70. package/dist/chunk-O645XLSI.js +0 -297
  71. package/dist/chunk-OMJD6A3S.js +0 -235
  72. package/dist/chunk-QB6SJD4T.js +0 -430
  73. package/dist/chunk-QFSTL4J3.js +0 -276
  74. package/dist/chunk-QLGDFMFX.js +0 -212
  75. package/dist/chunk-RIAAGL2E.js +0 -13
  76. package/dist/chunk-RWO5XMZ6.js +0 -86
  77. package/dist/chunk-RXRKBBSM.js +0 -149
  78. package/dist/chunk-RZOZMML6.js +0 -363
  79. package/dist/chunk-U7I7FS7T.js +0 -113
  80. package/dist/chunk-UI42RODY.js +0 -717
  81. package/dist/chunk-UTVMVSCO.js +0 -519
  82. package/dist/chunk-V6OJGLBA.js +0 -1746
  83. package/dist/chunk-W2JHVH7D.js +0 -152
  84. package/dist/chunk-WD3Y7VQN.js +0 -280
  85. package/dist/chunk-WOCTQ5MS.js +0 -303
  86. package/dist/chunk-WZR3ZUNN.js +0 -696
  87. package/dist/chunk-XGI665H7.js +0 -150
  88. package/dist/chunk-XKY65P2T.js +0 -304
  89. package/dist/chunk-Y4CQZY65.js +0 -57
  90. package/dist/chunk-YFEXKLVE.js +0 -194
  91. package/dist/chunk-YHO3HS5X.js +0 -287
  92. package/dist/chunk-YLS7AZSX.js +0 -738
  93. package/dist/chunk-ZE473AO6.js +0 -49
  94. package/dist/chunk-ZF747T3O.js +0 -644
  95. package/dist/chunk-ZHCZHZH3.js +0 -43
  96. package/dist/chunk-ZZNZX2XY.js +0 -87
  97. package/dist/constants-7QAP3VQ4.js +0 -23
  98. package/dist/dist-IY3UUMWK.js +0 -33
  99. package/dist/invariants-runner-W5RGHCSU.js +0 -27
  100. package/dist/lane-lock-6J36HD5O.js +0 -35
  101. package/dist/mem-checkpoint-core-EANG2GVN.js +0 -14
  102. package/dist/mem-signal-core-2LZ2WYHW.js +0 -19
  103. package/dist/memory-store-OLB5FO7K.js +0 -18
  104. package/dist/service-6BYCOCO5.js +0 -13
  105. package/dist/spawn-policy-resolver-NTSZYQ6R.js +0 -17
  106. package/dist/spawn-task-builder-R4E2BHSW.js +0 -22
  107. package/dist/wu-done-pr-WLFFFEPJ.js +0 -25
  108. package/dist/wu-done-validation-3J5E36FE.js +0 -30
  109. package/dist/wu-duplicate-id-detector-5S7JHELK.js +0 -232
@@ -1,43 +0,0 @@
1
- import {
2
- getConfig
3
- } from "./chunk-V6OJGLBA.js";
4
-
5
- // ../initiatives/dist/initiative-paths.js
6
- import path from "path";
7
- var INIT_PATHS = {
8
- /**
9
- * Get path to Initiative YAML file
10
- * Uses getConfig().directories.initiativesDir for config-aware resolution.
11
- *
12
- * @param {string} id - Initiative ID (e.g., 'INIT-001')
13
- * @returns {string} Path to Initiative YAML file
14
- */
15
- INITIATIVE: (id) => {
16
- const config = getConfig();
17
- return path.join(config.directories.initiativesDir, `${id}.yaml`);
18
- },
19
- /**
20
- * Get path to initiatives directory
21
- * Uses getConfig().directories.initiativesDir for config-aware resolution.
22
- *
23
- * @returns {string} Path to initiatives directory
24
- */
25
- INITIATIVES_DIR: () => {
26
- const config = getConfig();
27
- return config.directories.initiativesDir;
28
- },
29
- /**
30
- * Get path to WU directory (for scanning WUs by initiative)
31
- * Uses getConfig().directories.wuDir for config-aware resolution.
32
- *
33
- * @returns {string} Path to WU directory
34
- */
35
- WU_DIR: () => {
36
- const config = getConfig();
37
- return config.directories.wuDir;
38
- }
39
- };
40
-
41
- export {
42
- INIT_PATHS
43
- };
@@ -1,87 +0,0 @@
1
- import {
2
- LUMENFLOW_MEMORY_PATHS
3
- } from "./chunk-4N74J3UT.js";
4
-
5
- // ../memory/dist/mem-init-core.js
6
- import fs from "fs/promises";
7
- import path from "path";
8
- import yaml from "yaml";
9
- var MEMORY_PATHS = {
10
- /** Memory directory relative to project root */
11
- MEMORY_DIR: LUMENFLOW_MEMORY_PATHS.MEMORY_DIR,
12
- /** Memory JSONL file name */
13
- MEMORY_FILE: "memory.jsonl",
14
- /** Config YAML file name */
15
- CONFIG_FILE: "config.yaml"
16
- };
17
- var DEFAULT_CONFIG = {
18
- /** Config schema version */
19
- version: 1,
20
- /** Retention policy for each lifecycle */
21
- retention: {
22
- /** Ephemeral nodes are discarded immediately after use */
23
- ephemeral: 0,
24
- /** Session nodes expire after 1 hour */
25
- session: 3600,
26
- /** WU nodes expire after 7 days */
27
- wu: 604800,
28
- /** Project nodes never expire (-1 = infinite) */
29
- project: -1
30
- }
31
- };
32
- async function fileExists(filePath) {
33
- try {
34
- await fs.access(filePath);
35
- return true;
36
- } catch {
37
- return false;
38
- }
39
- }
40
- function generateConfigYaml() {
41
- const header = "# Memory layer configuration\n# Generated by pnpm mem:init (WU-1464)\n";
42
- return header + yaml.stringify(DEFAULT_CONFIG);
43
- }
44
- async function initMemory(baseDir) {
45
- const memoryDir = path.join(baseDir, MEMORY_PATHS.MEMORY_DIR);
46
- const memoryJsonlPath = path.join(memoryDir, MEMORY_PATHS.MEMORY_FILE);
47
- const configYamlPath = path.join(memoryDir, MEMORY_PATHS.CONFIG_FILE);
48
- const result = {
49
- success: false,
50
- alreadyInitialized: false,
51
- paths: {
52
- memoryDir,
53
- memoryJsonl: memoryJsonlPath,
54
- configYaml: configYamlPath
55
- },
56
- created: {
57
- directory: false,
58
- memoryJsonl: false,
59
- configYaml: false
60
- }
61
- };
62
- const dirExists = await fileExists(memoryDir);
63
- const memoryExists = await fileExists(memoryJsonlPath);
64
- const configExists = await fileExists(configYamlPath);
65
- if (dirExists && memoryExists && configExists) {
66
- result.alreadyInitialized = true;
67
- }
68
- if (!dirExists) {
69
- await fs.mkdir(memoryDir, { recursive: true });
70
- result.created.directory = true;
71
- }
72
- if (!memoryExists) {
73
- await fs.writeFile(memoryJsonlPath, "", { encoding: "utf-8" });
74
- result.created.memoryJsonl = true;
75
- }
76
- if (!configExists) {
77
- const configContent = generateConfigYaml();
78
- await fs.writeFile(configYamlPath, configContent, { encoding: "utf-8" });
79
- result.created.configYaml = true;
80
- }
81
- result.success = true;
82
- return result;
83
- }
84
-
85
- export {
86
- initMemory
87
- };
@@ -1,23 +0,0 @@
1
- import {
2
- WU_LIFECYCLE_CLAIM_DEFAULTS,
3
- WU_LIFECYCLE_COMMANDS,
4
- WU_LIFECYCLE_EVENT_KINDS,
5
- WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
6
- WU_LIFECYCLE_SPEC_HASH,
7
- WU_LIFECYCLE_SYNC_CONFIG,
8
- WU_LIFECYCLE_SYNC_LOG_PREFIX,
9
- WU_LIFECYCLE_SYNC_RESULT_DEFAULTS,
10
- WU_LIFECYCLE_SYNC_SKIPPED_REASONS
11
- } from "./chunk-EK2AKZKD.js";
12
- import "./chunk-3RG5ZIWI.js";
13
- export {
14
- WU_LIFECYCLE_CLAIM_DEFAULTS,
15
- WU_LIFECYCLE_COMMANDS,
16
- WU_LIFECYCLE_EVENT_KINDS,
17
- WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
18
- WU_LIFECYCLE_SPEC_HASH,
19
- WU_LIFECYCLE_SYNC_CONFIG,
20
- WU_LIFECYCLE_SYNC_LOG_PREFIX,
21
- WU_LIFECYCLE_SYNC_RESULT_DEFAULTS,
22
- WU_LIFECYCLE_SYNC_SKIPPED_REASONS
23
- };
@@ -1,33 +0,0 @@
1
- import {
2
- CONTROL_PLANE_AUTH_TOKEN_ENV_PATTERN,
3
- CONTROL_PLANE_POLICY_MODES,
4
- CONTROL_PLANE_POLICY_MODE_VALUES,
5
- ControlPlaneConfigSchema,
6
- DEFAULT_CONTROL_PLANE_AUTH_TOKEN_ENV,
7
- HttpControlPlaneSyncPort,
8
- MockControlPlaneSyncPort,
9
- MockSignalSyncPort,
10
- WorkspaceControlPlaneSchema,
11
- applyPolicyMode,
12
- createHttpControlPlaneSyncPort,
13
- createMockControlPlaneSyncPort,
14
- createMockSignalSyncPort,
15
- parseWorkspaceControlPlaneConfig
16
- } from "./chunk-YLS7AZSX.js";
17
- import "./chunk-3RG5ZIWI.js";
18
- export {
19
- CONTROL_PLANE_AUTH_TOKEN_ENV_PATTERN,
20
- CONTROL_PLANE_POLICY_MODES,
21
- CONTROL_PLANE_POLICY_MODE_VALUES,
22
- ControlPlaneConfigSchema,
23
- DEFAULT_CONTROL_PLANE_AUTH_TOKEN_ENV,
24
- HttpControlPlaneSyncPort,
25
- MockControlPlaneSyncPort,
26
- MockSignalSyncPort,
27
- WorkspaceControlPlaneSchema,
28
- applyPolicyMode,
29
- createHttpControlPlaneSyncPort,
30
- createMockControlPlaneSyncPort,
31
- createMockSignalSyncPort,
32
- parseWorkspaceControlPlaneConfig
33
- };
@@ -1,27 +0,0 @@
1
- import {
2
- INVARIANT_TYPES,
3
- InvariantError,
4
- formatInvariantError,
5
- getInvariantChecker,
6
- loadInvariants,
7
- registerInvariantChecker,
8
- runInvariants,
9
- validateInvariants
10
- } from "./chunk-EZ6ZBYBM.js";
11
- import "./chunk-U7I7FS7T.js";
12
- import "./chunk-NRIZR3A7.js";
13
- import "./chunk-6HO4GWJE.js";
14
- import "./chunk-DWMLTXKQ.js";
15
- import "./chunk-V6OJGLBA.js";
16
- import "./chunk-RXRKBBSM.js";
17
- import "./chunk-3RG5ZIWI.js";
18
- export {
19
- INVARIANT_TYPES,
20
- InvariantError,
21
- formatInvariantError,
22
- getInvariantChecker,
23
- loadInvariants,
24
- registerInvariantChecker,
25
- runInvariants,
26
- validateInvariants
27
- };
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- acquireLaneLock,
4
- auditedUnlock,
5
- checkLaneLock,
6
- forceRemoveStaleLock,
7
- getAllLaneLocks,
8
- getLockFilePath,
9
- getLocksDir,
10
- getStaleThresholdMs,
11
- isLockStale,
12
- isZombieLock,
13
- readLockMetadata,
14
- releaseLaneLock
15
- } from "./chunk-JONWQUB5.js";
16
- import "./chunk-NRIZR3A7.js";
17
- import "./chunk-6HO4GWJE.js";
18
- import "./chunk-DWMLTXKQ.js";
19
- import "./chunk-V6OJGLBA.js";
20
- import "./chunk-RXRKBBSM.js";
21
- import "./chunk-3RG5ZIWI.js";
22
- export {
23
- acquireLaneLock,
24
- auditedUnlock,
25
- checkLaneLock,
26
- forceRemoveStaleLock,
27
- getAllLaneLocks,
28
- getLockFilePath,
29
- getLocksDir,
30
- getStaleThresholdMs,
31
- isLockStale,
32
- isZombieLock,
33
- readLockMetadata,
34
- releaseLaneLock
35
- };
@@ -1,14 +0,0 @@
1
- import {
2
- createCheckpoint
3
- } from "./chunk-RWO5XMZ6.js";
4
- import "./chunk-ND6MY37M.js";
5
- import "./chunk-RIAAGL2E.js";
6
- import "./chunk-DFR4DJBM.js";
7
- import "./chunk-4N74J3UT.js";
8
- import "./chunk-DWMLTXKQ.js";
9
- import "./chunk-V6OJGLBA.js";
10
- import "./chunk-RXRKBBSM.js";
11
- import "./chunk-3RG5ZIWI.js";
12
- export {
13
- createCheckpoint
14
- };
@@ -1,19 +0,0 @@
1
- import {
2
- SIGNAL_FILE_NAME,
3
- SIGNAL_RECEIPTS_FILE_NAME,
4
- createSignal,
5
- loadSignals,
6
- markSignalsAsRead
7
- } from "./chunk-OMJD6A3S.js";
8
- import "./chunk-4N74J3UT.js";
9
- import "./chunk-DWMLTXKQ.js";
10
- import "./chunk-V6OJGLBA.js";
11
- import "./chunk-RXRKBBSM.js";
12
- import "./chunk-3RG5ZIWI.js";
13
- export {
14
- SIGNAL_FILE_NAME,
15
- SIGNAL_RECEIPTS_FILE_NAME,
16
- createSignal,
17
- loadSignals,
18
- markSignalsAsRead
19
- };
@@ -1,18 +0,0 @@
1
- import {
2
- MEMORY_FILE_NAME,
3
- appendNode,
4
- loadMemory,
5
- loadMemoryAll,
6
- queryByWu,
7
- queryReady
8
- } from "./chunk-DFR4DJBM.js";
9
- import "./chunk-RXRKBBSM.js";
10
- import "./chunk-3RG5ZIWI.js";
11
- export {
12
- MEMORY_FILE_NAME,
13
- appendNode,
14
- loadMemory,
15
- loadMemoryAll,
16
- queryByWu,
17
- queryReady
18
- };
@@ -1,13 +0,0 @@
1
- import {
2
- buildWuLifecycleKernelEvent,
3
- flushWuLifecycleSync
4
- } from "./chunk-JERYVEIZ.js";
5
- import "./chunk-EK2AKZKD.js";
6
- import "./chunk-DWMLTXKQ.js";
7
- import "./chunk-V6OJGLBA.js";
8
- import "./chunk-RXRKBBSM.js";
9
- import "./chunk-3RG5ZIWI.js";
10
- export {
11
- buildWuLifecycleKernelEvent,
12
- flushWuLifecycleSync
13
- };
@@ -1,17 +0,0 @@
1
- import {
2
- emitMethodologyTelemetry
3
- } from "./chunk-6XYXI2NQ.js";
4
- import {
5
- generateEnforcementSummary,
6
- generateMandatoryStandards
7
- } from "./chunk-NMG736UR.js";
8
- import "./chunk-6HO4GWJE.js";
9
- import "./chunk-DWMLTXKQ.js";
10
- import "./chunk-V6OJGLBA.js";
11
- import "./chunk-RXRKBBSM.js";
12
- import "./chunk-3RG5ZIWI.js";
13
- export {
14
- emitMethodologyTelemetry,
15
- generateEnforcementSummary,
16
- generateMandatoryStandards
17
- };
@@ -1,22 +0,0 @@
1
- import {
2
- checkLaneOccupation,
3
- generateCodexPrompt,
4
- generateLaneOccupationWarning,
5
- generateTaskInvocation
6
- } from "./chunk-6W5XHWYV.js";
7
- import "./chunk-JONWQUB5.js";
8
- import "./chunk-NMG736UR.js";
9
- import "./chunk-EZ6ZBYBM.js";
10
- import "./chunk-U7I7FS7T.js";
11
- import "./chunk-NRIZR3A7.js";
12
- import "./chunk-6HO4GWJE.js";
13
- import "./chunk-DWMLTXKQ.js";
14
- import "./chunk-V6OJGLBA.js";
15
- import "./chunk-RXRKBBSM.js";
16
- import "./chunk-3RG5ZIWI.js";
17
- export {
18
- checkLaneOccupation,
19
- generateCodexPrompt,
20
- generateLaneOccupationWarning,
21
- generateTaskInvocation
22
- };
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- WU_DONE_COMPLETION_MODES,
4
- buildPRBody,
5
- createPR,
6
- isGhCliAvailable,
7
- isPRModeEnabled,
8
- printGhCliMissingMessage,
9
- printPRCreatedMessage
10
- } from "./chunk-XGI665H7.js";
11
- import "./chunk-2UFQ3A3C.js";
12
- import "./chunk-6HO4GWJE.js";
13
- import "./chunk-DWMLTXKQ.js";
14
- import "./chunk-V6OJGLBA.js";
15
- import "./chunk-RXRKBBSM.js";
16
- import "./chunk-3RG5ZIWI.js";
17
- export {
18
- WU_DONE_COMPLETION_MODES,
19
- buildPRBody,
20
- createPR,
21
- isGhCliAvailable,
22
- isPRModeEnabled,
23
- printGhCliMissingMessage,
24
- printPRCreatedMessage
25
- };
@@ -1,30 +0,0 @@
1
- import {
2
- applyExposureDefaults,
3
- buildCodePathsCommittedErrorMessage,
4
- buildTypeVsCodePathsErrorMessage,
5
- validateCodePathsCommittedBeforeDone,
6
- validateCodePathsExist,
7
- validatePostMutation,
8
- validateSpecCompleteness,
9
- validateTestPathsRequired,
10
- validateTypeVsCodePathsPreflight
11
- } from "./chunk-L737LQ4C.js";
12
- import "./chunk-2UFQ3A3C.js";
13
- import "./chunk-U7I7FS7T.js";
14
- import "./chunk-NRIZR3A7.js";
15
- import "./chunk-6HO4GWJE.js";
16
- import "./chunk-DWMLTXKQ.js";
17
- import "./chunk-V6OJGLBA.js";
18
- import "./chunk-RXRKBBSM.js";
19
- import "./chunk-3RG5ZIWI.js";
20
- export {
21
- applyExposureDefaults,
22
- buildCodePathsCommittedErrorMessage,
23
- buildTypeVsCodePathsErrorMessage,
24
- validateCodePathsCommittedBeforeDone,
25
- validateCodePathsExist,
26
- validatePostMutation,
27
- validateSpecCompleteness,
28
- validateTestPathsRequired,
29
- validateTypeVsCodePathsPreflight
30
- };
@@ -1,232 +0,0 @@
1
- import {
2
- WU_STATUS,
3
- getConfig
4
- } from "./chunk-V6OJGLBA.js";
5
- import "./chunk-RXRKBBSM.js";
6
- import "./chunk-3RG5ZIWI.js";
7
-
8
- // ../core/dist/wu-duplicate-id-detector.js
9
- import { readdirSync, readFileSync, writeFileSync, existsSync, renameSync } from "fs";
10
- import path from "path";
11
- import { parse, stringify } from "yaml";
12
- var WU_YAML_EXTENSION = ".yaml";
13
- var WU_ID_PREFIX = "WU-";
14
- var STAMP_SUFFIX = ".done";
15
- var EVENTS_FILE = "wu-events.jsonl";
16
- function scanYamlFiles(wuDirAbsolute) {
17
- const idToFiles = /* @__PURE__ */ new Map();
18
- if (!existsSync(wuDirAbsolute)) {
19
- return idToFiles;
20
- }
21
- const entries = readdirSync(wuDirAbsolute);
22
- for (const entry of entries) {
23
- if (!entry.endsWith(WU_YAML_EXTENSION))
24
- continue;
25
- const fullPath = path.join(wuDirAbsolute, entry);
26
- try {
27
- const content = readFileSync(fullPath, "utf-8");
28
- const doc = parse(content);
29
- if (!doc || typeof doc.id !== "string")
30
- continue;
31
- const id = doc.id;
32
- const existing = idToFiles.get(id) ?? [];
33
- existing.push(fullPath);
34
- idToFiles.set(id, existing);
35
- } catch {
36
- }
37
- }
38
- return idToFiles;
39
- }
40
- function findStamps(stampsDirAbsolute, id) {
41
- const stampFile = path.join(stampsDirAbsolute, `${id}${STAMP_SUFFIX}`);
42
- if (existsSync(stampFile)) {
43
- return [stampFile];
44
- }
45
- return [];
46
- }
47
- function findEvents(eventsFileAbsolute, id) {
48
- if (!existsSync(eventsFileAbsolute)) {
49
- return [];
50
- }
51
- const content = readFileSync(eventsFileAbsolute, "utf-8");
52
- const lines = content.split("\n");
53
- const results = [];
54
- for (let i = 0; i < lines.length; i++) {
55
- const line = lines[i]?.trim();
56
- if (!line)
57
- continue;
58
- try {
59
- const event = JSON.parse(line);
60
- if (event.wuId === id) {
61
- results.push({ line: i + 1, event });
62
- }
63
- } catch {
64
- }
65
- }
66
- return results;
67
- }
68
- async function detectDuplicateIds(projectRoot) {
69
- const config = getConfig({ projectRoot });
70
- const wuDirAbsolute = path.join(projectRoot, config.directories.wuDir);
71
- const stampsDirAbsolute = path.join(projectRoot, config.state.stampsDir);
72
- const eventsFileAbsolute = path.join(projectRoot, config.state.stateDir, EVENTS_FILE);
73
- const idToFiles = scanYamlFiles(wuDirAbsolute);
74
- const duplicates = [];
75
- let totalWUs = 0;
76
- for (const [id, files] of idToFiles) {
77
- totalWUs += files.length;
78
- if (files.length > 1) {
79
- duplicates.push({
80
- id,
81
- files,
82
- stamps: findStamps(stampsDirAbsolute, id),
83
- events: findEvents(eventsFileAbsolute, id)
84
- });
85
- }
86
- }
87
- for (const [, files] of idToFiles) {
88
- if (files.length === 1) {
89
- }
90
- }
91
- return { totalWUs, duplicates };
92
- }
93
- function nextAvailableId(existingIds) {
94
- let candidate = 1;
95
- while (existingIds.has(`${WU_ID_PREFIX}${candidate}`)) {
96
- candidate++;
97
- }
98
- return `${WU_ID_PREFIX}${candidate}`;
99
- }
100
- function chooseCanonical(id, files) {
101
- const expectedFilename = `${id}${WU_YAML_EXTENSION}`;
102
- for (let i = 0; i < files.length; i++) {
103
- if (path.basename(files[i]) === expectedFilename) {
104
- return i;
105
- }
106
- }
107
- return 0;
108
- }
109
- function collectAllIds(wuDirAbsolute) {
110
- const ids = /* @__PURE__ */ new Set();
111
- if (!existsSync(wuDirAbsolute))
112
- return ids;
113
- const entries = readdirSync(wuDirAbsolute);
114
- for (const entry of entries) {
115
- if (!entry.endsWith(WU_YAML_EXTENSION))
116
- continue;
117
- const fullPath = path.join(wuDirAbsolute, entry);
118
- try {
119
- const content = readFileSync(fullPath, "utf-8");
120
- const doc = parse(content);
121
- if (doc && typeof doc.id === "string") {
122
- ids.add(doc.id);
123
- }
124
- } catch {
125
- }
126
- }
127
- return ids;
128
- }
129
- function updateEvents(eventsFileAbsolute, oldId, newId, duplicateLane) {
130
- if (!existsSync(eventsFileAbsolute))
131
- return false;
132
- const content = readFileSync(eventsFileAbsolute, "utf-8");
133
- const lines = content.split("\n");
134
- let modified = false;
135
- const newLines = [];
136
- for (const rawLine of lines) {
137
- const line = rawLine.trim();
138
- if (!line) {
139
- newLines.push(rawLine);
140
- continue;
141
- }
142
- try {
143
- const event = JSON.parse(line);
144
- if (event.wuId === oldId) {
145
- if (duplicateLane && typeof event.lane === "string" && event.lane !== duplicateLane) {
146
- newLines.push(rawLine);
147
- continue;
148
- }
149
- event.wuId = newId;
150
- newLines.push(JSON.stringify(event));
151
- modified = true;
152
- } else {
153
- newLines.push(rawLine);
154
- }
155
- } catch {
156
- newLines.push(rawLine);
157
- }
158
- }
159
- if (modified) {
160
- writeFileSync(eventsFileAbsolute, newLines.join("\n"), "utf-8");
161
- }
162
- return modified;
163
- }
164
- async function repairDuplicateIds(projectRoot, options) {
165
- const report = await detectDuplicateIds(projectRoot);
166
- if (report.duplicates.length === 0) {
167
- return { applied: false, mappings: [] };
168
- }
169
- const config = getConfig({ projectRoot });
170
- const wuDirAbsolute = path.join(projectRoot, config.directories.wuDir);
171
- const stampsDirAbsolute = path.join(projectRoot, config.state.stampsDir);
172
- const eventsFileAbsolute = path.join(projectRoot, config.state.stateDir, EVENTS_FILE);
173
- const allIds = collectAllIds(wuDirAbsolute);
174
- const mappings = [];
175
- for (const group of report.duplicates) {
176
- const canonicalIdx = chooseCanonical(group.id, group.files);
177
- for (let i = 0; i < group.files.length; i++) {
178
- if (i === canonicalIdx)
179
- continue;
180
- const duplicateFile = group.files[i];
181
- const newId = nextAvailableId(allIds);
182
- allIds.add(newId);
183
- if (!options.apply) {
184
- mappings.push({
185
- oldId: group.id,
186
- newId,
187
- renamedFile: duplicateFile,
188
- touchedFiles: []
189
- });
190
- continue;
191
- }
192
- const touchedFiles = [];
193
- try {
194
- const content = readFileSync(duplicateFile, "utf-8");
195
- const doc = parse(content);
196
- const duplicateLane = typeof doc.lane === "string" ? doc.lane : void 0;
197
- doc.id = newId;
198
- writeFileSync(duplicateFile, stringify(doc, { lineWidth: 0 }), "utf-8");
199
- touchedFiles.push(duplicateFile);
200
- const newFilePath = path.join(wuDirAbsolute, `${newId}${WU_YAML_EXTENSION}`);
201
- renameSync(duplicateFile, newFilePath);
202
- touchedFiles[touchedFiles.length - 1] = newFilePath;
203
- const oldStampPath = path.join(stampsDirAbsolute, `${group.id}${STAMP_SUFFIX}`);
204
- const newStampPath = path.join(stampsDirAbsolute, `${newId}${STAMP_SUFFIX}`);
205
- if (existsSync(oldStampPath)) {
206
- if (doc.status === WU_STATUS.DONE) {
207
- writeFileSync(newStampPath, "", "utf-8");
208
- touchedFiles.push(newStampPath);
209
- }
210
- }
211
- if (updateEvents(eventsFileAbsolute, group.id, newId, duplicateLane)) {
212
- touchedFiles.push(eventsFileAbsolute);
213
- }
214
- mappings.push({
215
- oldId: group.id,
216
- newId,
217
- renamedFile: newFilePath,
218
- touchedFiles
219
- });
220
- } catch {
221
- }
222
- }
223
- }
224
- return {
225
- applied: options.apply,
226
- mappings
227
- };
228
- }
229
- export {
230
- detectDuplicateIds,
231
- repairDuplicateIds
232
- };