@lumenflow/cli 5.5.0 → 5.7.12

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 (213) hide show
  1. package/README.md +42 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/gate-defaults.js +37 -0
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  9. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  10. package/dist/gates/prod-migration-drift.js +207 -0
  11. package/dist/gates/prod-migration-drift.js.map +1 -0
  12. package/dist/gates/test-over-deletion-guard.js +255 -0
  13. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  14. package/dist/gates-runners.js +44 -3
  15. package/dist/gates-runners.js.map +1 -1
  16. package/dist/gates.js +3 -2
  17. package/dist/gates.js.map +1 -1
  18. package/dist/lumenflow-setup.js +144 -0
  19. package/dist/lumenflow-setup.js.map +1 -0
  20. package/dist/lumenflow-upgrade.js +2 -1
  21. package/dist/lumenflow-upgrade.js.map +1 -1
  22. package/dist/mem-create.js +10 -1
  23. package/dist/mem-create.js.map +1 -1
  24. package/dist/mem-signal.js +21 -4
  25. package/dist/mem-signal.js.map +1 -1
  26. package/dist/orchestrate-initiative.js +28 -3
  27. package/dist/orchestrate-initiative.js.map +1 -1
  28. package/dist/public-manifest.js +17 -0
  29. package/dist/public-manifest.js.map +1 -1
  30. package/dist/release.js +53 -18
  31. package/dist/release.js.map +1 -1
  32. package/dist/wu-done-gates.js +13 -9
  33. package/dist/wu-done-gates.js.map +1 -1
  34. package/dist/wu-edit-operations.js +74 -0
  35. package/dist/wu-edit-operations.js.map +1 -1
  36. package/dist/wu-edit-validators.js +58 -0
  37. package/dist/wu-edit-validators.js.map +1 -1
  38. package/dist/wu-edit.js +106 -4
  39. package/dist/wu-edit.js.map +1 -1
  40. package/dist/wu-prep.js +41 -7
  41. package/dist/wu-prep.js.map +1 -1
  42. package/dist/wu-recover.js +6 -0
  43. package/dist/wu-recover.js.map +1 -1
  44. package/dist/wu-release.js +120 -2
  45. package/dist/wu-release.js.map +1 -1
  46. package/dist/wu-sizing-validation.js +47 -17
  47. package/dist/wu-sizing-validation.js.map +1 -1
  48. package/dist/wu-status.js +33 -0
  49. package/dist/wu-status.js.map +1 -1
  50. package/package.json +13 -11
  51. package/packs/agent-runtime/package.json +1 -1
  52. package/packs/sidekick/package.json +1 -1
  53. package/packs/software-delivery/package.json +1 -1
  54. package/templates/core/AGENTS.md.template +67 -3
  55. package/templates/core/LUMENFLOW.md.template +197 -47
  56. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  57. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  58. package/packs/agent-runtime/capability-factory.ts +0 -104
  59. package/packs/agent-runtime/constants.ts +0 -21
  60. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  61. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  62. package/packs/agent-runtime/delegation-tree.ts +0 -328
  63. package/packs/agent-runtime/index.ts +0 -20
  64. package/packs/agent-runtime/manifest.ts +0 -348
  65. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  66. package/packs/agent-runtime/orchestration.ts +0 -2027
  67. package/packs/agent-runtime/pack-registration.ts +0 -110
  68. package/packs/agent-runtime/policy-factory.ts +0 -165
  69. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  70. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  71. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  72. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  73. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  74. package/packs/agent-runtime/session-schema.ts +0 -467
  75. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  76. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  77. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  78. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  79. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  80. package/packs/agent-runtime/tools/index.ts +0 -4
  81. package/packs/agent-runtime/tools/types.ts +0 -47
  82. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  83. package/packs/agent-runtime/types.ts +0 -128
  84. package/packs/agent-runtime/vitest.config.ts +0 -11
  85. package/packs/sidekick/channel-ingress.ts +0 -137
  86. package/packs/sidekick/constants.ts +0 -10
  87. package/packs/sidekick/index.ts +0 -8
  88. package/packs/sidekick/manifest-schema.ts +0 -49
  89. package/packs/sidekick/manifest.ts +0 -512
  90. package/packs/sidekick/pack-registration.ts +0 -110
  91. package/packs/sidekick/policy-factory.ts +0 -38
  92. package/packs/sidekick/sidekick-events.ts +0 -694
  93. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  94. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  95. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  96. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  97. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  98. package/packs/sidekick/src/routines/commit.ts +0 -74
  99. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  100. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  101. package/packs/sidekick/tool-impl/index.ts +0 -29
  102. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  103. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  104. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  105. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  106. package/packs/sidekick/tool-impl/shared.ts +0 -125
  107. package/packs/sidekick/tool-impl/storage.ts +0 -325
  108. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  109. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  110. package/packs/sidekick/tools/channel-tools.ts +0 -53
  111. package/packs/sidekick/tools/index.ts +0 -9
  112. package/packs/sidekick/tools/memory-tools.ts +0 -53
  113. package/packs/sidekick/tools/routine-tools.ts +0 -53
  114. package/packs/sidekick/tools/system-tools.ts +0 -47
  115. package/packs/sidekick/tools/task-tools.ts +0 -61
  116. package/packs/sidekick/tools/types.ts +0 -57
  117. package/packs/sidekick/vitest.config.ts +0 -11
  118. package/packs/software-delivery/constants.ts +0 -10
  119. package/packs/software-delivery/extensions.ts +0 -140
  120. package/packs/software-delivery/gate-policies.ts +0 -134
  121. package/packs/software-delivery/index.ts +0 -8
  122. package/packs/software-delivery/manifest-schema.ts +0 -268
  123. package/packs/software-delivery/manifest.ts +0 -657
  124. package/packs/software-delivery/pack-registration.ts +0 -113
  125. package/packs/software-delivery/src/commands/index.ts +0 -5
  126. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  127. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  128. package/packs/software-delivery/src/config/index.ts +0 -8
  129. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  130. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  131. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  132. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  133. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  134. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  135. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  136. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  137. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  138. package/packs/software-delivery/src/constants/index.ts +0 -29
  139. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  140. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  141. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  142. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
  143. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  144. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  145. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  146. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  147. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  148. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  149. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  150. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  151. package/packs/software-delivery/src/domain/index.ts +0 -5
  152. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  153. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  154. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  155. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  156. package/packs/software-delivery/src/methodology/index.ts +0 -6
  157. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  158. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  159. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  160. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  161. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  162. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  163. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  164. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  165. package/packs/software-delivery/src/policy/index.ts +0 -22
  166. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  167. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  168. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  169. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  170. package/packs/software-delivery/src/ports/index.ts +0 -10
  171. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  172. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  173. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  174. package/packs/software-delivery/src/primitives/index.ts +0 -5
  175. package/packs/software-delivery/src/runtime/index.ts +0 -6
  176. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  177. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  178. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  179. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  180. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  181. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  182. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  183. package/packs/software-delivery/src/schemas/index.ts +0 -5
  184. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  185. package/packs/software-delivery/src/state/index.ts +0 -15
  186. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  187. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  188. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  189. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  190. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  191. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  192. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  193. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  194. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  195. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  196. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  197. package/packs/software-delivery/tool-impl/index.ts +0 -15
  198. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  199. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  200. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  201. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  202. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  203. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  204. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  205. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  206. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  207. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  208. package/packs/software-delivery/tools/git-tools.ts +0 -55
  209. package/packs/software-delivery/tools/index.ts +0 -8
  210. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  211. package/packs/software-delivery/tools/types.ts +0 -71
  212. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  213. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,119 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Software Delivery State Machine (WU-2664, INIT-058 Layer 1 Cohort B)
6
- *
7
- * Enforces canonical WU state transitions according to LumenFlow §2.4.
8
- *
9
- * The generic state-transition pattern (canonical state names, alias
10
- * resolution, transition table evaluation) lives in
11
- * `@lumenflow/kernel/primitives/state-machine`. This module keeps the
12
- * SDLC-specific WU state names and surfaces error codes that callers of
13
- * the software-delivery pack already depend on.
14
- *
15
- * WU state names (SDLC-specific):
16
- * - ready → in_progress (claim)
17
- * - in_progress → blocked (block)
18
- * - in_progress → waiting (implementation complete, awaiting sign-off)
19
- * - in_progress → done (direct completion)
20
- * - in_progress → ready (release — WU-1080: orphan recovery)
21
- * - blocked → in_progress (unblock)
22
- * - blocked → done (blocker resolved, direct completion)
23
- * - waiting → in_progress (changes requested)
24
- * - waiting → done (approved)
25
- * - done → (terminal, no transitions)
26
- */
27
-
28
- import {
29
- assertTransition as assertKernelTransition,
30
- TASK_LIFECYCLE_STATES,
31
- type TaskStateAliases,
32
- } from '@lumenflow/kernel/primitives/state-machine';
33
-
34
- import { createError, ErrorCodes } from '@lumenflow/kernel/primitives/error-handler';
35
-
36
- /**
37
- * SDLC-specific WU state names surfaced by the software-delivery pack.
38
- * The canonical kernel state name for `in_progress` is `active`; the alias
39
- * below bridges the two vocabularies.
40
- */
41
- type WuState = 'ready' | 'in_progress' | 'blocked' | 'waiting' | 'done';
42
-
43
- const VALID_STATES: ReadonlySet<WuState> = new Set<WuState>([
44
- 'ready',
45
- 'in_progress',
46
- 'blocked',
47
- 'waiting',
48
- 'done',
49
- ]);
50
-
51
- /**
52
- * Alias map used to translate SDLC WU state names to the kernel's canonical
53
- * state vocabulary. Defined once per module so the kernel lookup table is
54
- * built predictably.
55
- */
56
- const SDLC_STATE_ALIASES: TaskStateAliases = {
57
- [TASK_LIFECYCLE_STATES.ACTIVE]: 'in_progress',
58
- };
59
-
60
- function throwInvalidState(
61
- label: 'from' | 'to',
62
- value: string | null | undefined,
63
- other: string | null | undefined,
64
- wuid: string,
65
- reason?: string,
66
- ): never {
67
- if (value === null || value === undefined || value === '') {
68
- throw createError(ErrorCodes.STATE_ERROR, `Invalid state: ${value}`, {
69
- wuid,
70
- from: label === 'from' ? value : other,
71
- to: label === 'to' ? value : other,
72
- reason: reason ?? `${label} state is null/undefined/empty`,
73
- });
74
- }
75
- throw createError(ErrorCodes.STATE_ERROR, `Invalid state: ${value}`, {
76
- wuid,
77
- from: label === 'from' ? value : other,
78
- to: label === 'to' ? value : other,
79
- validStates: Array.from(VALID_STATES),
80
- });
81
- }
82
-
83
- /**
84
- * Validates a SDLC WU state transition and throws if illegal.
85
- *
86
- * Delegates graph evaluation to `@lumenflow/kernel/primitives/state-machine`
87
- * and rewraps kernel errors with the `STATE_ERROR` error code that core
88
- * callers already rely on.
89
- *
90
- * @param from Current WU status (e.g., `in_progress`, `blocked`).
91
- * @param to Desired WU status.
92
- * @param wuid Work Unit ID (e.g., `WU-416`) used in error messages.
93
- * @throws Error with `code === 'STATE_ERROR'` for invalid/illegal transitions.
94
- */
95
- export function assertTransition(
96
- from: string | null | undefined,
97
- to: string | null | undefined,
98
- wuid: string,
99
- ): void {
100
- if (from === null || from === undefined || from === '') {
101
- throwInvalidState('from', from, to, wuid);
102
- }
103
- if (to === null || to === undefined || to === '') {
104
- throwInvalidState('to', to, from, wuid);
105
- }
106
- if (!VALID_STATES.has(from as WuState)) {
107
- throwInvalidState('from', from, to, wuid);
108
- }
109
- if (!VALID_STATES.has(to as WuState)) {
110
- throwInvalidState('to', to, from, wuid);
111
- }
112
-
113
- try {
114
- assertKernelTransition(from, to, wuid, SDLC_STATE_ALIASES);
115
- } catch (err) {
116
- const message = err instanceof Error ? err.message : String(err);
117
- throw createError(ErrorCodes.STATE_ERROR, message, { wuid, from, to });
118
- }
119
- }
@@ -1,51 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * WU Document Type Definitions (WU-2044)
6
- *
7
- * Canonical type for parsed WU YAML documents. Previously independently
8
- * defined in 7+ files (spawn-agent-guidance.ts, wu-done-paths.ts,
9
- * code-path-validator.ts, lane-checker.ts, wu-repair-core.ts,
10
- * wu-status-transition.ts, wu-transaction-collectors.ts).
11
- *
12
- * This module defines a base type covering the superset of fields
13
- * needed across consumers. Files needing only a subset can use
14
- * Pick<WUDocBase, 'field1' | 'field2'>.
15
- *
16
- * @module wu-doc-types
17
- */
18
-
19
- /**
20
- * Base WU document interface representing a parsed WU YAML file.
21
- *
22
- * All fields are optional since they may not be present depending
23
- * on the WU's lifecycle stage or type.
24
- */
25
- export interface WUDocBase extends Record<string, unknown> {
26
- id?: string;
27
- title?: string;
28
- lane?: string;
29
- type?: string;
30
- status?: string;
31
- description?: string;
32
- acceptance?: string[];
33
- code_paths?: string[];
34
- spec_refs?: string[];
35
- notes?: string;
36
- risks?: string[];
37
- initiative?: string;
38
- worktree_path?: string;
39
- claimed_mode?: string;
40
- claimed_branch?: string;
41
- claimed_at?: string;
42
- locked?: boolean;
43
- created?: unknown;
44
- completed?: unknown;
45
- completed_at?: string;
46
- tests?: {
47
- manual?: string[];
48
- unit?: string[];
49
- e2e?: string[];
50
- };
51
- }
@@ -1,381 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * WU Paths - Centralized path management for Work Units
6
- *
7
- * All paths are configurable via workspace.yaml (`software_delivery`) config.
8
- *
9
- * @module wu-paths
10
- */
11
-
12
- import * as path from 'node:path';
13
-
14
- import { findProjectRoot } from '@lumenflow/kernel/primitives/project-root';
15
-
16
- import {
17
- getProjectRoot as getProjectRootFromConstants,
18
- toKebab,
19
- } from '../constants/wu-domain-constants.js';
20
- import {
21
- getDirectories,
22
- getStatePaths,
23
- type WorkspaceDirectories,
24
- type WorkspaceStatePaths,
25
- } from '../config/workspace-reader.js';
26
-
27
- /**
28
- * WU-2689 (INIT-058 L4): Pack-local project root resolver.
29
- *
30
- * Uses the kernel's `findProjectRoot(cwd)` primitive (which walks up from `cwd`
31
- * looking for `workspace.yaml` / `package.json`). Falls back to `process.cwd()`
32
- * if resolution fails — matches the behaviour of the core helper this replaces.
33
- */
34
- function getProjectRootFromConfig(options: { projectRoot?: string } = {}): string {
35
- if (options.projectRoot) {
36
- return options.projectRoot;
37
- }
38
- try {
39
- return findProjectRoot(process.cwd());
40
- } catch {
41
- return process.cwd();
42
- }
43
- }
44
-
45
- /**
46
- * WU-2689: Resolve the typed directory + state-path bundle the rest of this
47
- * module was previously sourcing from `getConfig()`. Threads `projectRoot`
48
- * through to the pack's workspace-reader so callers can override the root
49
- * (tests, multi-project tooling).
50
- */
51
- /**
52
- * WU-2689: Directory defaults used when the pack workspace-reader fails to
53
- * locate a workspace.yaml (e.g. tmpdir-based tests, sandbox environments).
54
- *
55
- * Kept in sync with `DIRECTORY_DEFAULTS` in the pack workspace-reader.
56
- */
57
- const FALLBACK_DIRECTORIES: WorkspaceDirectories = {
58
- appsWeb: '',
59
- worktrees: 'worktrees/',
60
- ai: 'ai/',
61
- claude: '.claude/',
62
- docs: 'docs/',
63
- packages: 'packages/',
64
- tools: 'tools/',
65
- memoryBank: 'memory-bank/',
66
- wuDir: 'docs/operations/tasks/wu',
67
- initiativesDir: 'docs/operations/tasks/initiatives',
68
- backlogPath: 'docs/operations/tasks/backlog.md',
69
- statusPath: 'docs/operations/tasks/status.md',
70
- skillsDir: '.lumenflow/skills',
71
- agentsDir: '.claude/agents',
72
- adrDir: 'docs/adr',
73
- plansDir: 'docs/operations/plans',
74
- templatesDir: '.lumenflow/templates',
75
- onboardingDir: 'docs/operations/_frameworks/lumenflow/agent/onboarding',
76
- completeGuidePath: 'LUMENFLOW.md',
77
- quickRefPath: 'docs/operations/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md',
78
- startingPromptPath: 'docs/operations/_frameworks/lumenflow/agent/onboarding/starting-prompt.md',
79
- sizingGuidePath: 'docs/operations/_frameworks/lumenflow/wu-sizing-guide.md',
80
- governancePath: 'docs/operations/_frameworks/lumenflow/governance.md',
81
- safeGitPath: 'scripts/safe-git',
82
- };
83
-
84
- const FALLBACK_STATE_PATHS: WorkspaceStatePaths = {
85
- base: '.lumenflow',
86
- stateDir: '.lumenflow/state',
87
- archiveDir: '.lumenflow/archive',
88
- stampsDir: '.lumenflow/stamps',
89
- mergeLock: '.lumenflow/merge.lock',
90
- telemetry: '.lumenflow/telemetry',
91
- flowLog: '.lumenflow/flow.log',
92
- sessions: '.lumenflow/sessions',
93
- incidents: '.lumenflow/incidents',
94
- commandsLog: '.lumenflow/commands.log',
95
- eventArchival: {
96
- archiveAfter: 90 * 24 * 60 * 60 * 1000,
97
- keepArchives: true,
98
- },
99
- };
100
-
101
- function resolveWorkspacePaths(options: { projectRoot?: string } = {}): {
102
- directories: WorkspaceDirectories;
103
- state: WorkspaceStatePaths;
104
- } {
105
- const cwd = options.projectRoot ?? getProjectRootFromConfig();
106
- // WU-2689: tolerate missing workspace.yaml (e.g. tmpdir-based tests) by
107
- // falling back to built-in defaults when the pack workspace-reader throws
108
- // (ENOENT on workspace.yaml or findProjectRoot exhaustion). Matches the
109
- // graceful behaviour of the former `@lumenflow/core` `getConfig({ projectRoot })`
110
- // path, which returned defaults for non-existent workspace configs.
111
- let directories: WorkspaceDirectories;
112
- let state: WorkspaceStatePaths;
113
- try {
114
- directories = getDirectories(cwd);
115
- } catch {
116
- directories = FALLBACK_DIRECTORIES;
117
- }
118
- try {
119
- state = getStatePaths(cwd);
120
- } catch {
121
- state = FALLBACK_STATE_PATHS;
122
- }
123
- return { directories, state };
124
- }
125
-
126
- /**
127
- * Resolve repo root from an absolute file path by traversing up N directory levels.
128
- *
129
- * @param absolutePath - Absolute path to a file within the repo
130
- * @param depth - Number of directory levels to traverse up
131
- * @returns Absolute path to repo root
132
- */
133
- export function resolveRepoRoot(absolutePath: string, depth: number): string {
134
- let result = absolutePath;
135
- for (let i = 0; i < depth; i++) {
136
- result = path.dirname(result);
137
- }
138
- return result;
139
- }
140
-
141
- /**
142
- * Compute the directory depth of a relative path (number of path segments).
143
- *
144
- * WU-1523: Used to dynamically determine backlog depth from config
145
- * instead of fixed depth assumptions. This ensures getStateStoreDirFromBacklog
146
- * works correctly for configured docs structures.
147
- *
148
- * @param relativePath - Relative file path (e.g., '<configured backlogPath>')
149
- * @returns Number of path segments for the configured path
150
- */
151
- function computePathDepth(relativePath: string): number {
152
- // Normalize separators and split on path separator
153
- const normalized = relativePath.replace(/\\/g, '/');
154
- return normalized.split('/').filter(Boolean).length;
155
- }
156
-
157
- /**
158
- * Get the state store directory path from backlog.md path.
159
- *
160
- * WU-1523: Now computes depth dynamically from configured backlog path
161
- * instead of using fixed depth values. This fixes empty backlog.md
162
- * and status.md rendering in scaffolded projects with non-default docs structures.
163
- *
164
- * @param backlogPath - Absolute path to backlog.md
165
- * @returns Absolute path to state store directory
166
- */
167
- export function getStateStoreDirFromBacklog(backlogPath: string): string {
168
- const { directories, state } = resolveWorkspacePaths();
169
- const depth = computePathDepth(directories.backlogPath);
170
- const repoRoot = resolveRepoRoot(backlogPath, depth);
171
- return path.join(repoRoot, state.stateDir);
172
- }
173
-
174
- /**
175
- * Create WU paths object with configurable base paths
176
- *
177
- * @param options - Options for path generation
178
- * @param options.projectRoot - Override project root
179
- * @returns WU paths object
180
- */
181
- export function createWuPaths(options: { projectRoot?: string } = {}) {
182
- const { directories, state } = resolveWorkspacePaths(options);
183
-
184
- return {
185
- /**
186
- * Get path to WU YAML file
187
- * @param id - WU ID (e.g., 'WU-123')
188
- * @returns Path to WU YAML file
189
- */
190
- WU: (id: string) => path.join(directories.wuDir, `${id}.yaml`),
191
-
192
- /**
193
- * Get path to WU directory
194
- * @returns Path to WU directory
195
- */
196
- WU_DIR: () => directories.wuDir,
197
-
198
- /**
199
- * Get path to status.md
200
- * @returns Path to status.md
201
- */
202
- STATUS: () => directories.statusPath,
203
-
204
- /**
205
- * Get path to backlog.md
206
- * @returns Path to backlog.md
207
- */
208
- BACKLOG: () => directories.backlogPath,
209
-
210
- /**
211
- * Get path to stamps directory
212
- * @returns Path to stamps directory
213
- */
214
- STAMPS_DIR: () => state.stampsDir,
215
-
216
- /**
217
- * Get path to WU done stamp file
218
- * @param id - WU ID (e.g., 'WU-123')
219
- * @returns Path to stamp file
220
- */
221
- STAMP: (id: string) => path.join(state.stampsDir, `${id}.done`),
222
-
223
- /**
224
- * Get path to state directory
225
- * @returns Path to state directory
226
- */
227
- STATE_DIR: () => state.stateDir,
228
-
229
- /**
230
- * Get path to initiatives directory
231
- * @returns Path to initiatives directory
232
- */
233
- INITIATIVES_DIR: () => directories.initiativesDir,
234
-
235
- /**
236
- * Get path to initiative YAML file
237
- * @param id - Initiative ID (e.g., 'INIT-001')
238
- * @returns Path to initiative YAML file
239
- */
240
- INITIATIVE: (id: string) => path.join(directories.initiativesDir, `${id}.yaml`),
241
-
242
- /**
243
- * Get path to worktrees directory
244
- * @returns Path to worktrees directory
245
- */
246
- WORKTREES_DIR: () => directories.worktrees,
247
-
248
- /**
249
- * Get path to a specific worktree directory
250
- * @param lane - Lane name (e.g., 'Framework: Core')
251
- * @param id - WU ID (e.g., 'WU-123')
252
- * @returns Path to worktree directory
253
- */
254
- WORKTREE: (lane: string, id: string) =>
255
- path.join(directories.worktrees, `${toKebab(lane)}-${id.toLowerCase()}`),
256
-
257
- /**
258
- * Get path to plans directory
259
- * @returns Path to plans directory (WU-1301)
260
- */
261
- PLANS_DIR: () => directories.plansDir,
262
-
263
- /**
264
- * Get path to templates directory
265
- * @returns Path to templates directory (WU-1310)
266
- */
267
- TEMPLATES_DIR: () => directories.templatesDir,
268
-
269
- /**
270
- * Get path to onboarding directory
271
- * @returns Path to onboarding directory (WU-1310)
272
- */
273
- ONBOARDING_DIR: () => directories.onboardingDir,
274
-
275
- /**
276
- * Get path to LumenFlow complete guide
277
- * @returns Path to complete guide markdown
278
- */
279
- COMPLETE_GUIDE_PATH: () => directories.completeGuidePath,
280
-
281
- /**
282
- * Get path to onboarding quick reference commands
283
- * @returns Path to quick reference markdown
284
- */
285
- QUICK_REF_PATH: () => directories.quickRefPath,
286
-
287
- /**
288
- * Get path to onboarding starting prompt
289
- * @returns Path to starting prompt markdown
290
- */
291
- STARTING_PROMPT_PATH: () => directories.startingPromptPath,
292
-
293
- /**
294
- * Get path to WU sizing guide
295
- * @returns Path to sizing guide markdown
296
- */
297
- SIZING_GUIDE_PATH: () => directories.sizingGuidePath,
298
-
299
- /**
300
- * Get path to governance document
301
- * @returns Path to governance markdown
302
- */
303
- GOVERNANCE_PATH: () => directories.governancePath,
304
- };
305
- }
306
-
307
- /**
308
- * Default WU paths using default config
309
- * For backwards compatibility with existing code
310
- */
311
- export const WU_PATHS = createWuPaths();
312
-
313
- /**
314
- * Generate default worktree path from WU document
315
- *
316
- * @param doc - WU document with lane and id fields
317
- * @returns Worktree path or null if inputs are invalid
318
- */
319
- export function defaultWorktreeFrom(
320
- doc: { lane?: string; id?: string } | null | undefined,
321
- ): string | null {
322
- if (!doc) return null;
323
- const lane = doc.lane;
324
- const id = doc.id;
325
-
326
- // Validate inputs
327
- if (!lane || !id) return null;
328
-
329
- // Convert to string and trim
330
- const laneStr = String(lane).trim();
331
- const idStr = String(id).trim();
332
-
333
- // Check for empty strings after trimming
334
- if (laneStr === '' || idStr === '') return null;
335
-
336
- return createWuPaths().WORKTREE(laneStr, idStr);
337
- }
338
-
339
- /**
340
- * Resolve a repo-root-relative path to an absolute path using project root.
341
- *
342
- * @param relativePath - Path relative to project root
343
- * @param moduleUrl - import.meta.url of the calling module (for backwards compat)
344
- * @returns Absolute path resolved from project root
345
- */
346
- export function resolveFromProjectRoot(relativePath: string, moduleUrl?: string): string {
347
- // Try config-based project root first, fall back to constants-based
348
- let projectRoot: string;
349
- try {
350
- projectRoot = getProjectRootFromConfig();
351
- } catch {
352
- projectRoot = moduleUrl ? getProjectRootFromConstants(moduleUrl) : process.cwd();
353
- }
354
- return path.join(projectRoot, relativePath);
355
- }
356
-
357
- /**
358
- * Get absolute path to WU YAML file
359
- *
360
- * @param id - WU ID (e.g., 'WU-123')
361
- * @param options - Options
362
- * @returns Absolute path to WU YAML file
363
- */
364
- export function getAbsoluteWuPath(id: string, options: { projectRoot?: string } = {}): string {
365
- const projectRoot = options.projectRoot || getProjectRootFromConfig();
366
- const paths = createWuPaths({ projectRoot });
367
- return path.join(projectRoot, paths.WU(id));
368
- }
369
-
370
- /**
371
- * Get absolute path to stamp file
372
- *
373
- * @param id - WU ID (e.g., 'WU-123')
374
- * @param options - Options
375
- * @returns Absolute path to stamp file
376
- */
377
- export function getAbsoluteStampPath(id: string, options: { projectRoot?: string } = {}): string {
378
- const projectRoot = options.projectRoot || getProjectRootFromConfig();
379
- const paths = createWuPaths({ projectRoot });
380
- return path.join(projectRoot, paths.STAMP(id));
381
- }