@lumenflow/core 2.2.2 → 2.3.2

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/dist/active-wu-detector.d.ts +1 -1
  2. package/dist/active-wu-detector.js +1 -1
  3. package/dist/arg-parser.js +51 -18
  4. package/dist/backlog-generator.d.ts +4 -4
  5. package/dist/backlog-generator.js +4 -4
  6. package/dist/backlog-sync-validator.js +1 -1
  7. package/dist/cleanup-lock.d.ts +9 -2
  8. package/dist/cleanup-lock.js +17 -7
  9. package/dist/code-path-validator.d.ts +3 -3
  10. package/dist/code-path-validator.js +3 -3
  11. package/dist/compliance-parser.d.ts +1 -1
  12. package/dist/compliance-parser.js +1 -1
  13. package/dist/constants/backlog-patterns.d.ts +1 -1
  14. package/dist/constants/backlog-patterns.js +1 -1
  15. package/dist/constants/dora-constants.d.ts +1 -1
  16. package/dist/constants/dora-constants.js +1 -1
  17. package/dist/constants/gate-constants.d.ts +1 -1
  18. package/dist/constants/gate-constants.js +1 -1
  19. package/dist/constants/linter-constants.d.ts +1 -1
  20. package/dist/constants/linter-constants.js +1 -1
  21. package/dist/constants/tokenizer-constants.d.ts +1 -1
  22. package/dist/constants/tokenizer-constants.js +1 -1
  23. package/dist/context/location-resolver.js +2 -1
  24. package/dist/context-validation-integration.d.ts +1 -0
  25. package/dist/core/scope-checker.d.ts +3 -3
  26. package/dist/core/scope-checker.js +3 -3
  27. package/dist/core/tool-runner.d.ts +5 -5
  28. package/dist/core/tool-runner.js +5 -5
  29. package/dist/core/tool.constants.d.ts +1 -1
  30. package/dist/core/tool.constants.js +1 -1
  31. package/dist/core/tool.schemas.d.ts +2 -2
  32. package/dist/core/tool.schemas.js +1 -1
  33. package/dist/core/worktree-guard.d.ts +1 -1
  34. package/dist/core/worktree-guard.js +1 -1
  35. package/dist/coverage-gate.d.ts +12 -3
  36. package/dist/coverage-gate.js +15 -8
  37. package/dist/date-utils.d.ts +4 -4
  38. package/dist/date-utils.js +4 -4
  39. package/dist/dependency-graph.d.ts +6 -0
  40. package/dist/dependency-graph.js +43 -2
  41. package/dist/dependency-guard.d.ts +2 -2
  42. package/dist/dependency-guard.js +3 -3
  43. package/dist/dependency-validator.d.ts +4 -4
  44. package/dist/dependency-validator.js +4 -7
  45. package/dist/domain/orchestration.constants.d.ts +31 -10
  46. package/dist/domain/orchestration.constants.js +45 -16
  47. package/dist/domain/orchestration.schemas.d.ts +54 -28
  48. package/dist/domain/orchestration.schemas.js +2 -2
  49. package/dist/domain/orchestration.types.d.ts +2 -2
  50. package/dist/domain/orchestration.types.js +2 -2
  51. package/dist/error-handler.d.ts +10 -10
  52. package/dist/error-handler.js +10 -10
  53. package/dist/file-classifiers.d.ts +6 -6
  54. package/dist/file-classifiers.js +6 -6
  55. package/dist/gates-config.d.ts +74 -0
  56. package/dist/gates-config.js +209 -2
  57. package/dist/git-adapter.d.ts +11 -11
  58. package/dist/git-adapter.js +11 -11
  59. package/dist/git-context-extractor.d.ts +112 -0
  60. package/dist/git-context-extractor.js +559 -0
  61. package/dist/hardcoded-strings.d.ts +1 -1
  62. package/dist/hardcoded-strings.js +1 -1
  63. package/dist/incremental-lint.d.ts +1 -1
  64. package/dist/incremental-lint.js +2 -2
  65. package/dist/incremental-test.d.ts +1 -1
  66. package/dist/incremental-test.js +1 -1
  67. package/dist/index.d.ts +13 -0
  68. package/dist/index.js +25 -0
  69. package/dist/invariants/check-automated-tests.d.ts +2 -2
  70. package/dist/invariants/check-automated-tests.js +3 -3
  71. package/dist/lane-checker.d.ts +28 -7
  72. package/dist/lane-checker.js +316 -159
  73. package/dist/lane-suggest-prompt.d.ts +108 -0
  74. package/dist/lane-suggest-prompt.js +359 -0
  75. package/dist/lane-validator.d.ts +3 -3
  76. package/dist/lane-validator.js +3 -3
  77. package/dist/logs-lib.d.ts +1 -1
  78. package/dist/logs-lib.js +1 -1
  79. package/dist/lumenflow-config-schema.d.ts +162 -0
  80. package/dist/lumenflow-config-schema.js +180 -0
  81. package/dist/manual-test-validator.d.ts +2 -2
  82. package/dist/manual-test-validator.js +3 -3
  83. package/dist/merge-lock.d.ts +8 -1
  84. package/dist/merge-lock.js +16 -7
  85. package/dist/micro-worktree.d.ts +81 -13
  86. package/dist/micro-worktree.js +98 -17
  87. package/dist/migration-deployer.d.ts +1 -1
  88. package/dist/migration-deployer.js +1 -1
  89. package/dist/orchestration-advisory-loader.d.ts +2 -2
  90. package/dist/orchestration-advisory-loader.js +10 -6
  91. package/dist/orchestration-advisory.d.ts +3 -3
  92. package/dist/orchestration-advisory.js +4 -4
  93. package/dist/orchestration-di.d.ts +4 -4
  94. package/dist/orchestration-di.js +4 -4
  95. package/dist/orchestration-rules.d.ts +4 -4
  96. package/dist/orchestration-rules.js +18 -10
  97. package/dist/orphan-detector.d.ts +3 -3
  98. package/dist/orphan-detector.js +3 -3
  99. package/dist/patrol-loop.d.ts +170 -0
  100. package/dist/patrol-loop.js +186 -0
  101. package/dist/process-detector.d.ts +5 -5
  102. package/dist/process-detector.js +5 -5
  103. package/dist/rebase-artifact-cleanup.d.ts +3 -3
  104. package/dist/rebase-artifact-cleanup.js +3 -3
  105. package/dist/resolve-policy.d.ts +195 -0
  106. package/dist/resolve-policy.js +203 -0
  107. package/dist/risk-detector.d.ts +2 -2
  108. package/dist/risk-detector.js +2 -2
  109. package/dist/rollback-utils.d.ts +1 -1
  110. package/dist/rollback-utils.js +1 -1
  111. package/dist/section-headings.d.ts +1 -1
  112. package/dist/section-headings.js +1 -1
  113. package/dist/spawn-escalation.d.ts +4 -4
  114. package/dist/spawn-escalation.js +3 -3
  115. package/dist/spawn-monitor.d.ts +4 -4
  116. package/dist/spawn-monitor.js +4 -4
  117. package/dist/spawn-recovery.d.ts +3 -3
  118. package/dist/spawn-recovery.js +3 -3
  119. package/dist/spawn-registry-schema.d.ts +2 -2
  120. package/dist/spawn-registry-schema.js +2 -2
  121. package/dist/spawn-registry-store.d.ts +2 -2
  122. package/dist/spawn-registry-store.js +2 -2
  123. package/dist/spawn-strategy.d.ts +17 -11
  124. package/dist/spawn-strategy.js +47 -44
  125. package/dist/spawn-tree.d.ts +3 -3
  126. package/dist/spawn-tree.js +3 -3
  127. package/dist/state-cleanup-core.d.ts +205 -0
  128. package/dist/state-cleanup-core.js +240 -0
  129. package/dist/state-doctor-core.d.ts +168 -0
  130. package/dist/state-doctor-core.js +251 -0
  131. package/dist/stream-error-handler.d.ts +67 -0
  132. package/dist/stream-error-handler.js +94 -0
  133. package/dist/telemetry.d.ts +1 -1
  134. package/dist/telemetry.js +1 -1
  135. package/dist/template-loader.d.ts +162 -0
  136. package/dist/template-loader.js +372 -0
  137. package/dist/test-baseline.d.ts +176 -0
  138. package/dist/test-baseline.js +282 -0
  139. package/dist/usecases/get-suggestions.usecase.d.ts +1 -1
  140. package/dist/validation/command-registry.js +37 -0
  141. package/dist/validators/backlog-sync.js +4 -2
  142. package/dist/worktree-scanner.d.ts +1 -1
  143. package/dist/worktree-scanner.js +1 -1
  144. package/dist/worktree-symlink.d.ts +3 -3
  145. package/dist/worktree-symlink.js +3 -3
  146. package/dist/wu-backlog-updater.d.ts +1 -1
  147. package/dist/wu-backlog-updater.js +1 -1
  148. package/dist/wu-claim-helpers.d.ts +1 -1
  149. package/dist/wu-claim-helpers.js +1 -1
  150. package/dist/wu-claim-resume.d.ts +1 -1
  151. package/dist/wu-claim-resume.js +1 -1
  152. package/dist/wu-consistency-checker.d.ts +1 -1
  153. package/dist/wu-consistency-checker.js +17 -11
  154. package/dist/wu-constants.d.ts +73 -21
  155. package/dist/wu-constants.js +65 -22
  156. package/dist/wu-done-branch-only.d.ts +1 -1
  157. package/dist/wu-done-branch-only.js +1 -1
  158. package/dist/wu-done-docs-generate.d.ts +1 -1
  159. package/dist/wu-done-docs-generate.js +1 -1
  160. package/dist/wu-done-messages.d.ts +2 -2
  161. package/dist/wu-done-messages.js +2 -2
  162. package/dist/wu-done-metadata.d.ts +3 -3
  163. package/dist/wu-done-metadata.js +3 -3
  164. package/dist/wu-done-pr.d.ts +1 -1
  165. package/dist/wu-done-pr.js +4 -2
  166. package/dist/wu-done-preflight.d.ts +8 -0
  167. package/dist/wu-done-preflight.js +18 -2
  168. package/dist/wu-done-ui.d.ts +3 -3
  169. package/dist/wu-done-ui.js +3 -3
  170. package/dist/wu-done-validation.d.ts +30 -0
  171. package/dist/wu-done-validation.js +106 -1
  172. package/dist/wu-done-worktree.d.ts +1 -1
  173. package/dist/wu-done-worktree.js +11 -1
  174. package/dist/wu-events-cleanup.d.ts +148 -0
  175. package/dist/wu-events-cleanup.js +401 -0
  176. package/dist/wu-helpers.d.ts +2 -2
  177. package/dist/wu-helpers.js +2 -2
  178. package/dist/wu-id-generator.d.ts +58 -0
  179. package/dist/wu-id-generator.js +103 -0
  180. package/dist/wu-lint.js +1 -1
  181. package/dist/wu-preflight-validators.d.ts +13 -1
  182. package/dist/wu-preflight-validators.js +56 -1
  183. package/dist/wu-recovery.d.ts +2 -2
  184. package/dist/wu-recovery.js +4 -4
  185. package/dist/wu-repair-core.d.ts +5 -5
  186. package/dist/wu-repair-core.js +6 -6
  187. package/dist/wu-schema-normalization.d.ts +1 -1
  188. package/dist/wu-schema-normalization.js +1 -1
  189. package/dist/wu-schema.d.ts +7 -7
  190. package/dist/wu-schema.js +8 -8
  191. package/dist/wu-spawn-context.d.ts +87 -0
  192. package/dist/wu-spawn-context.js +175 -0
  193. package/dist/wu-spawn-helpers.d.ts +1 -1
  194. package/dist/wu-spawn-helpers.js +1 -1
  195. package/dist/wu-spawn.d.ts +177 -4
  196. package/dist/wu-spawn.js +694 -72
  197. package/dist/wu-state-schema.d.ts +1 -1
  198. package/dist/wu-state-schema.js +1 -1
  199. package/dist/wu-state-store.d.ts +3 -3
  200. package/dist/wu-state-store.js +3 -3
  201. package/dist/wu-status-transition.d.ts +1 -1
  202. package/dist/wu-status-transition.js +1 -1
  203. package/dist/wu-status-updater.d.ts +3 -3
  204. package/dist/wu-status-updater.js +3 -3
  205. package/dist/wu-validation-constants.d.ts +2 -2
  206. package/dist/wu-validation-constants.js +2 -2
  207. package/dist/wu-validation.d.ts +3 -3
  208. package/dist/wu-validation.js +3 -3
  209. package/dist/wu-yaml-fixer.d.ts +2 -2
  210. package/dist/wu-yaml-fixer.js +3 -3
  211. package/dist/wu-yaml.d.ts +23 -0
  212. package/dist/wu-yaml.js +76 -2
  213. package/package.json +5 -2
@@ -15,8 +15,8 @@
15
15
  * healthcare domain (PHI, RLS, auth). No standard library exists for this
16
16
  * domain-specific classification.
17
17
  *
18
- * @see {@link tools/gates.mjs} - Consumer of risk detection
19
- * @see {@link tools/lib/file-classifiers.mjs} - File classification utilities
18
+ * @see {@link packages/@lumenflow/cli/src/gates.ts} - Consumer of risk detection
19
+ * @see {@link packages/@lumenflow/cli/src/lib/file-classifiers.ts} - File classification utilities
20
20
  */
21
21
  import path from 'node:path';
22
22
  import { isDocumentationPath } from './file-classifiers.js';
@@ -5,7 +5,7 @@
5
5
  * WU-1255: Per-file error tracking for robust rollback operations.
6
6
  * Ensures all files are attempted even if some fail, with clear error reporting.
7
7
  *
8
- * @see {@link tools/wu-done.mjs} - Consumer (rollbackTransaction function)
8
+ * @see {@link packages/@lumenflow/cli/src/wu-done.ts} - Consumer (rollbackTransaction function)
9
9
  */
10
10
  /**
11
11
  * Error entry for failed file restoration
@@ -5,7 +5,7 @@
5
5
  * WU-1255: Per-file error tracking for robust rollback operations.
6
6
  * Ensures all files are attempted even if some fail, with clear error reporting.
7
7
  *
8
- * @see {@link tools/wu-done.mjs} - Consumer (rollbackTransaction function)
8
+ * @see {@link packages/@lumenflow/cli/src/wu-done.ts} - Consumer (rollbackTransaction function)
9
9
  */
10
10
  /* eslint-disable security/detect-non-literal-fs-filename */
11
11
  import { writeFileSync, unlinkSync } from 'node:fs';
@@ -9,7 +9,7 @@
9
9
  */
10
10
  /**
11
11
  * Default section headings (fallbacks when frontmatter is missing)
12
- * Re-exports from wu-constants.mjs for backwards compatibility
12
+ * Re-exports from wu-constants.ts for backwards compatibility
13
13
  */
14
14
  export declare const DEFAULT_SECTION_HEADINGS: {
15
15
  backlog: {
@@ -11,7 +11,7 @@ import { getSectionHeadings } from './backlog-parser.js';
11
11
  import { BACKLOG_SECTIONS, STATUS_SECTIONS } from './wu-constants.js';
12
12
  /**
13
13
  * Default section headings (fallbacks when frontmatter is missing)
14
- * Re-exports from wu-constants.mjs for backwards compatibility
14
+ * Re-exports from wu-constants.ts for backwards compatibility
15
15
  */
16
16
  export const DEFAULT_SECTION_HEADINGS = {
17
17
  backlog: {
@@ -14,9 +14,9 @@
14
14
  * PatientPath's custom spawn-registry.jsonl and memory bus patterns.
15
15
  * No external library exists for this domain-specific agent lifecycle management.
16
16
  *
17
- * @see {@link tools/lib/__tests__/spawn-escalation.test.mjs} - Tests
18
- * @see {@link tools/lib/spawn-recovery.mjs} - Recovery logic
19
- * @see {@link tools/lib/mem-signal-core.mjs} - Signal creation
17
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-escalation.test.ts} - Tests
18
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-recovery.ts} - Recovery logic
19
+ * @see {@link packages/@lumenflow/cli/src/lib/mem-signal-core.ts} - Signal creation
20
20
  */
21
21
  /**
22
22
  * Signal type for spawn failures
@@ -83,7 +83,7 @@ export declare function escalateStuckSpawn(spawnId: any, options?: EscalateStuck
83
83
  recovery_action: any;
84
84
  recovery_attempts: any;
85
85
  last_checkpoint: any;
86
- suggested_action: "retry" | "block" | "human_escalate";
86
+ suggested_action: "block" | "retry" | "human_escalate";
87
87
  message: string;
88
88
  };
89
89
  spawnStatus: "escalated";
@@ -14,9 +14,9 @@
14
14
  * PatientPath's custom spawn-registry.jsonl and memory bus patterns.
15
15
  * No external library exists for this domain-specific agent lifecycle management.
16
16
  *
17
- * @see {@link tools/lib/__tests__/spawn-escalation.test.mjs} - Tests
18
- * @see {@link tools/lib/spawn-recovery.mjs} - Recovery logic
19
- * @see {@link tools/lib/mem-signal-core.mjs} - Signal creation
17
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-escalation.test.ts} - Tests
18
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-recovery.ts} - Recovery logic
19
+ * @see {@link packages/@lumenflow/cli/src/lib/mem-signal-core.ts} - Signal creation
20
20
  */
21
21
  import fs from 'node:fs/promises';
22
22
  import path from 'node:path';
@@ -15,10 +15,10 @@
15
15
  * PatientPath's spawn-registry.jsonl and lane-lock files. No external
16
16
  * library exists for this custom format.
17
17
  *
18
- * @see {@link tools/__tests__/orchestrate-monitor.test.mjs} - Tests
19
- * @see {@link tools/lib/__tests__/spawn-monitor.test.mjs} - Signal handler tests
20
- * @see {@link tools/orchestrate-monitor.mjs} - CLI entry point
21
- * @see {@link tools/lib/spawn-registry-store.mjs} - Registry storage
18
+ * @see {@link packages/@lumenflow/cli/src/__tests__/orchestrate-monitor.test.ts} - Tests
19
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-monitor.test.ts} - Signal handler tests
20
+ * @see {@link packages/@lumenflow/cli/src/orchestrate-monitor.ts} - CLI entry point
21
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Registry storage
22
22
  */
23
23
  /**
24
24
  * Default threshold for stuck spawn detection (in minutes)
@@ -15,10 +15,10 @@
15
15
  * PatientPath's spawn-registry.jsonl and lane-lock files. No external
16
16
  * library exists for this custom format.
17
17
  *
18
- * @see {@link tools/__tests__/orchestrate-monitor.test.mjs} - Tests
19
- * @see {@link tools/lib/__tests__/spawn-monitor.test.mjs} - Signal handler tests
20
- * @see {@link tools/orchestrate-monitor.mjs} - CLI entry point
21
- * @see {@link tools/lib/spawn-registry-store.mjs} - Registry storage
18
+ * @see {@link packages/@lumenflow/cli/src/__tests__/orchestrate-monitor.test.ts} - Tests
19
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-monitor.test.ts} - Signal handler tests
20
+ * @see {@link packages/@lumenflow/cli/src/orchestrate-monitor.ts} - CLI entry point
21
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Registry storage
22
22
  */
23
23
  import fs from 'node:fs/promises';
24
24
  import path from 'node:path';
@@ -15,9 +15,9 @@
15
15
  * PatientPath's custom spawn-registry.jsonl, lane-lock, and memory-store.
16
16
  * No external library exists for this domain-specific agent lifecycle management.
17
17
  *
18
- * @see {@link tools/lib/__tests__/spawn-recovery.test.mjs} - Tests
19
- * @see {@link tools/lib/spawn-monitor.mjs} - Monitoring logic
20
- * @see {@link tools/lib/spawn-registry-store.mjs} - Spawn state
18
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-recovery.test.ts} - Tests
19
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-monitor.ts} - Monitoring logic
20
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Spawn state
21
21
  */
22
22
  /**
23
23
  * Recovery action constants
@@ -15,9 +15,9 @@
15
15
  * PatientPath's custom spawn-registry.jsonl, lane-lock, and memory-store.
16
16
  * No external library exists for this domain-specific agent lifecycle management.
17
17
  *
18
- * @see {@link tools/lib/__tests__/spawn-recovery.test.mjs} - Tests
19
- * @see {@link tools/lib/spawn-monitor.mjs} - Monitoring logic
20
- * @see {@link tools/lib/spawn-registry-store.mjs} - Spawn state
18
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-recovery.test.ts} - Tests
19
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-monitor.ts} - Monitoring logic
20
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Spawn state
21
21
  */
22
22
  import fs from 'node:fs/promises';
23
23
  import path from 'node:path';
@@ -4,8 +4,8 @@
4
4
  * Zod schemas for spawn event validation.
5
5
  * Defines schema for tracking sub-agent spawns by orchestrators.
6
6
  *
7
- * @see {@link tools/lib/__tests__/spawn-registry-store.test.mjs} - Tests
8
- * @see {@link tools/lib/spawn-registry-store.mjs} - Store implementation
7
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-registry-store.test.ts} - Tests
8
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Store implementation
9
9
  */
10
10
  import { z } from 'zod';
11
11
  /**
@@ -4,8 +4,8 @@
4
4
  * Zod schemas for spawn event validation.
5
5
  * Defines schema for tracking sub-agent spawns by orchestrators.
6
6
  *
7
- * @see {@link tools/lib/__tests__/spawn-registry-store.test.mjs} - Tests
8
- * @see {@link tools/lib/spawn-registry-store.mjs} - Store implementation
7
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-registry-store.test.ts} - Tests
8
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Store implementation
9
9
  */
10
10
  import { z } from 'zod';
11
11
  import crypto from 'node:crypto';
@@ -9,8 +9,8 @@
9
9
  * - Atomic append operations
10
10
  * - O(1) queries by parent WU, target WU, and status
11
11
  *
12
- * @see {@link tools/lib/__tests__/spawn-registry-store.test.mjs} - Tests
13
- * @see {@link tools/lib/spawn-registry-schema.mjs} - Schema definitions
12
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-registry-store.test.ts} - Tests
13
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-schema.ts} - Schema definitions
14
14
  */
15
15
  import { type SpawnEvent } from './spawn-registry-schema.js';
16
16
  /**
@@ -9,8 +9,8 @@
9
9
  * - Atomic append operations
10
10
  * - O(1) queries by parent WU, target WU, and status
11
11
  *
12
- * @see {@link tools/lib/__tests__/spawn-registry-store.test.mjs} - Tests
13
- * @see {@link tools/lib/spawn-registry-schema.mjs} - Schema definitions
12
+ * @see {@link packages/@lumenflow/cli/src/lib/__tests__/spawn-registry-store.test.ts} - Tests
13
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-schema.ts} - Schema definitions
14
14
  */
15
15
  import fs from 'node:fs/promises';
16
16
  import path from 'node:path';
@@ -17,7 +17,11 @@ export interface SpawnStrategy {
17
17
  declare abstract class BaseSpawnStrategy implements SpawnStrategy {
18
18
  protected getCorePreamble(wuId: string): string;
19
19
  abstract getPreamble(wuId: string): string;
20
- abstract getSkillLoadingInstruction(): string;
20
+ /**
21
+ * Default skill loading instruction - shared by GenericStrategy and GeminiCliStrategy
22
+ * ClaudeCodeStrategy overrides this with Claude-specific paths
23
+ */
24
+ getSkillLoadingInstruction(): string;
21
25
  }
22
26
  /**
23
27
  * Strategy for Claude Code (Local/Terminal)
@@ -28,26 +32,28 @@ export declare class ClaudeCodeStrategy extends BaseSpawnStrategy {
28
32
  }
29
33
  /**
30
34
  * Strategy for Gemini CLI (Multimodal/Ecosystem)
35
+ * Uses default getSkillLoadingInstruction from base class
31
36
  */
32
37
  export declare class GeminiCliStrategy extends BaseSpawnStrategy {
33
38
  getPreamble(wuId: string): string;
34
- getSkillLoadingInstruction(): string;
35
39
  }
36
40
  /**
37
41
  * Generic Strategy (Unknown/Other clients)
42
+ * Uses default getSkillLoadingInstruction from base class
38
43
  */
39
44
  export declare class GenericStrategy extends BaseSpawnStrategy {
40
45
  getPreamble(wuId: string): string;
41
- getSkillLoadingInstruction(): string;
42
46
  }
43
47
  /**
44
- * Factory for creating strategies
48
+ * Create a strategy for the given client
49
+ * @param clientName - Client name (e.g. 'claude-code', 'gemini-cli')
45
50
  */
46
- export declare class SpawnStrategyFactory {
47
- /**
48
- * Create a strategy for the given client
49
- * @param clientName - Client name (e.g. 'claude-code', 'gemini-cli')
50
- */
51
- static create(clientName: string): SpawnStrategy;
52
- }
51
+ export declare function createSpawnStrategy(clientName: string): SpawnStrategy;
52
+ /**
53
+ * Factory for creating strategies (legacy wrapper)
54
+ * @deprecated Use createSpawnStrategy function directly
55
+ */
56
+ export declare const SpawnStrategyFactory: {
57
+ create: typeof createSpawnStrategy;
58
+ };
53
59
  export {};
@@ -10,7 +10,18 @@ class BaseSpawnStrategy {
10
10
  2. Read .lumenflow/constraints.md (non-negotiable constraints)
11
11
  3. Read README.md (project structure and tech stack)
12
12
  4. Read docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md sections 1-7 (TDD, gates, Definition of Done)
13
- 5. Read docs/04-operations/tasks/wu/${wuId}.yaml (the specific WU you're working on)`;
13
+ 5. Read docs/04-operations/tasks/wu/${wuId}.yaml (the specific WU you're working on)
14
+ 6. Read docs/04-operations/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md (CLI tooling reference - USE THESE COMMANDS)`;
15
+ }
16
+ /**
17
+ * Default skill loading instruction - shared by GenericStrategy and GeminiCliStrategy
18
+ * ClaudeCodeStrategy overrides this with Claude-specific paths
19
+ */
20
+ getSkillLoadingInstruction() {
21
+ return `## Skills Selection
22
+
23
+ 1. Check \`.lumenflow/agents\` for available skills.
24
+ 2. Select relevant skills for this task.`;
14
25
  }
15
26
  }
16
27
  /**
@@ -27,7 +38,7 @@ export class ClaudeCodeStrategy extends BaseSpawnStrategy {
27
38
  // Actually, checking original behavior: CLAUDE.md was #1.
28
39
  // But new plan says LUMENFLOW.md is core.
29
40
  // We will append it as an overlay step.
30
- preamble += `\n6. Read .claude/CLAUDE.md (Claude-specific workflow overlay)`;
41
+ preamble += `\n7. Read .claude/CLAUDE.md (Claude-specific workflow overlay)`;
31
42
  }
32
43
  return preamble;
33
44
  }
@@ -41,66 +52,58 @@ export class ClaudeCodeStrategy extends BaseSpawnStrategy {
41
52
  }
42
53
  /**
43
54
  * Strategy for Gemini CLI (Multimodal/Ecosystem)
55
+ * Uses default getSkillLoadingInstruction from base class
44
56
  */
45
57
  export class GeminiCliStrategy extends BaseSpawnStrategy {
46
58
  getPreamble(wuId) {
47
59
  let preamble = this.getCorePreamble(wuId);
48
60
  if (existsSync('GEMINI.md')) {
49
- preamble += `\n6. Read GEMINI.md (Gemini-specific workflow overlay)`;
61
+ preamble += `\n7. Read GEMINI.md (Gemini-specific workflow overlay)`;
50
62
  }
51
63
  return preamble;
52
64
  }
53
- getSkillLoadingInstruction() {
54
- return `## Skills Selection
55
-
56
- 1. Check \`.lumenflow/agents\` for available skills.
57
- 2. Select relevant skills for this task.`;
58
- }
59
65
  }
60
66
  /**
61
67
  * Generic Strategy (Unknown/Other clients)
68
+ * Uses default getSkillLoadingInstruction from base class
62
69
  */
63
70
  export class GenericStrategy extends BaseSpawnStrategy {
64
71
  getPreamble(wuId) {
65
72
  return this.getCorePreamble(wuId);
66
73
  }
67
- getSkillLoadingInstruction() {
68
- return `## Skills Selection
69
-
70
- 1. Check \`.lumenflow/agents\` for available skills.
71
- 2. Select relevant skills for this task.`;
72
- }
73
74
  }
74
75
  /**
75
- * Factory for creating strategies
76
+ * Create a strategy for the given client
77
+ * @param clientName - Client name (e.g. 'claude-code', 'gemini-cli')
76
78
  */
77
- export class SpawnStrategyFactory {
78
- /**
79
- * Create a strategy for the given client
80
- * @param clientName - Client name (e.g. 'claude-code', 'gemini-cli')
81
- */
82
- static create(clientName) {
83
- switch (clientName.toLowerCase()) {
84
- case 'claude': // Legacy alias
85
- case 'claude-code':
86
- return new ClaudeCodeStrategy();
87
- case 'gemini': // Alias
88
- case 'gemini-cli':
89
- return new GeminiCliStrategy();
90
- case 'codex': // Deprecated alias
91
- case 'codex-cli':
92
- // Codex might need its own strategy later (sandbox), but for now generic or claude-like?
93
- // Plan says: "codex: preamble: false, strategy: cloud-sandbox" -> implies Generic or dedicated.
94
- // For now, let's map to Generic but maybe we should add CodexStrategy if it has diff behavior.
95
- // Re-reading plan: "CodexStrategy: Emphasizes cloud sandbox constraints"
96
- // But for this "Minimal" pass, let's stick to Generic with a comment,
97
- // OR essentially treat it as Generic since we don't have constraints logic here yet (it's in wu-spawn).
98
- // Actually, let's return GenericStrategy but we might handle constraints elsewhere.
99
- return new GenericStrategy();
100
- default:
101
- // Warn? The factory just creates. The caller should warn if it fell back.
102
- // But here we just return Generic.
103
- return new GenericStrategy();
104
- }
79
+ export function createSpawnStrategy(clientName) {
80
+ switch (clientName.toLowerCase()) {
81
+ case 'claude': // Legacy alias
82
+ case 'claude-code':
83
+ return new ClaudeCodeStrategy();
84
+ case 'gemini': // Alias
85
+ case 'gemini-cli':
86
+ return new GeminiCliStrategy();
87
+ case 'codex': // Deprecated alias
88
+ case 'codex-cli':
89
+ // Codex might need its own strategy later (sandbox), but for now generic or claude-like?
90
+ // Plan says: "codex: preamble: false, strategy: cloud-sandbox" -> implies Generic or dedicated.
91
+ // For now, let's map to Generic but maybe we should add CodexStrategy if it has diff behavior.
92
+ // Re-reading plan: "CodexStrategy: Emphasizes cloud sandbox constraints"
93
+ // But for this "Minimal" pass, let's stick to Generic with a comment,
94
+ // OR essentially treat it as Generic since we don't have constraints logic here yet (it's in wu-spawn).
95
+ // Actually, let's return GenericStrategy but we might handle constraints elsewhere.
96
+ return new GenericStrategy();
97
+ default:
98
+ // Warn? The factory just creates. The caller should warn if it fell back.
99
+ // But here we just return Generic.
100
+ return new GenericStrategy();
105
101
  }
106
102
  }
103
+ /**
104
+ * Factory for creating strategies (legacy wrapper)
105
+ * @deprecated Use createSpawnStrategy function directly
106
+ */
107
+ export const SpawnStrategyFactory = {
108
+ create: createSpawnStrategy,
109
+ };
@@ -8,9 +8,9 @@
8
8
  * Integrates with spawn-registry-store and spawn-registry-schema.
9
9
  * No external tree library needed - logic is tightly coupled to spawn data model.
10
10
  *
11
- * @see {@link tools/__tests__/spawn-list.test.mjs} - Tests
12
- * @see {@link tools/spawn-list.mjs} - CLI command
13
- * @see {@link tools/lib/spawn-registry-store.mjs} - Data source
11
+ * @see {@link packages/@lumenflow/cli/src/__tests__/spawn-list.test.ts} - Tests
12
+ * @see {@link packages/@lumenflow/cli/src/spawn-list.ts} - CLI command
13
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Data source
14
14
  */
15
15
  /**
16
16
  * Status indicators for terminal output.
@@ -8,9 +8,9 @@
8
8
  * Integrates with spawn-registry-store and spawn-registry-schema.
9
9
  * No external tree library needed - logic is tightly coupled to spawn data model.
10
10
  *
11
- * @see {@link tools/__tests__/spawn-list.test.mjs} - Tests
12
- * @see {@link tools/spawn-list.mjs} - CLI command
13
- * @see {@link tools/lib/spawn-registry-store.mjs} - Data source
11
+ * @see {@link packages/@lumenflow/cli/src/__tests__/spawn-list.test.ts} - Tests
12
+ * @see {@link packages/@lumenflow/cli/src/spawn-list.ts} - CLI command
13
+ * @see {@link packages/@lumenflow/cli/src/lib/spawn-registry-store.ts} - Data source
14
14
  */
15
15
  import fs from 'node:fs/promises';
16
16
  import path from 'node:path';
@@ -0,0 +1,205 @@
1
+ /**
2
+ * State Cleanup Core (WU-1208)
3
+ *
4
+ * Unified orchestration of all state cleanup operations:
5
+ * - Signal cleanup (TTL-based, from @lumenflow/memory)
6
+ * - Memory cleanup (lifecycle-based, from @lumenflow/memory)
7
+ * - Event archival (age-based, from @lumenflow/core)
8
+ *
9
+ * Cleanup order: signals -> memory -> events (dependency order)
10
+ *
11
+ * Design principles:
12
+ * - Non-fatal errors: failures in one cleanup type don't block others
13
+ * - Consistent summary: aggregated counts for all cleanup types
14
+ * - Configurable: supports --dry-run and type-specific flags
15
+ *
16
+ * @see {@link packages/@lumenflow/cli/src/state-cleanup.ts} - CLI wrapper
17
+ * @see {@link packages/@lumenflow/core/src/__tests__/state-cleanup-core.test.ts} - Tests
18
+ */
19
+ /**
20
+ * Cleanup types supported by state:cleanup
21
+ */
22
+ export type CleanupType = 'signals' | 'memory' | 'events';
23
+ /**
24
+ * Signal cleanup result (from @lumenflow/memory/signal-cleanup-core)
25
+ */
26
+ export interface SignalCleanupResult {
27
+ success: boolean;
28
+ removedIds: string[];
29
+ retainedIds: string[];
30
+ bytesFreed: number;
31
+ compactionRatio: number;
32
+ dryRun?: boolean;
33
+ breakdown: {
34
+ ttlExpired: number;
35
+ unreadTtlExpired: number;
36
+ countLimitExceeded: number;
37
+ activeWuProtected: number;
38
+ };
39
+ }
40
+ /**
41
+ * Memory cleanup result (from @lumenflow/memory/mem-cleanup-core)
42
+ */
43
+ export interface MemoryCleanupResult {
44
+ success: boolean;
45
+ removedIds: string[];
46
+ retainedIds: string[];
47
+ bytesFreed: number;
48
+ compactionRatio: number;
49
+ dryRun?: boolean;
50
+ breakdown: {
51
+ ephemeral: number;
52
+ session: number;
53
+ wu: number;
54
+ sensitive: number;
55
+ ttlExpired: number;
56
+ activeSessionProtected: number;
57
+ };
58
+ }
59
+ /**
60
+ * Event archival result (from @lumenflow/core/wu-events-cleanup)
61
+ */
62
+ export interface EventArchivalResult {
63
+ success: boolean;
64
+ archivedWuIds: string[];
65
+ retainedWuIds: string[];
66
+ archivedEventCount: number;
67
+ retainedEventCount: number;
68
+ bytesArchived: number;
69
+ dryRun?: boolean;
70
+ breakdown: {
71
+ archivedOlderThanThreshold: number;
72
+ retainedActiveWu: number;
73
+ retainedWithinThreshold: number;
74
+ };
75
+ }
76
+ /**
77
+ * Signal cleanup function type
78
+ */
79
+ export type CleanupSignalsFn = (baseDir: string, options: {
80
+ dryRun?: boolean;
81
+ }) => Promise<SignalCleanupResult>;
82
+ /**
83
+ * Memory cleanup function type
84
+ */
85
+ export type CleanupMemoryFn = (baseDir: string, options: {
86
+ dryRun?: boolean;
87
+ }) => Promise<MemoryCleanupResult>;
88
+ /**
89
+ * Event archival function type
90
+ */
91
+ export type ArchiveEventsFn = (baseDir: string, options: {
92
+ dryRun?: boolean;
93
+ }) => Promise<EventArchivalResult>;
94
+ /**
95
+ * Error that occurred during a specific cleanup type
96
+ */
97
+ export interface CleanupError {
98
+ type: CleanupType;
99
+ message: string;
100
+ error?: Error;
101
+ }
102
+ /**
103
+ * Summary of signal cleanup
104
+ */
105
+ export interface SignalCleanupSummary {
106
+ removedCount: number;
107
+ retainedCount: number;
108
+ bytesFreed: number;
109
+ breakdown: SignalCleanupResult['breakdown'];
110
+ }
111
+ /**
112
+ * Summary of memory cleanup
113
+ */
114
+ export interface MemoryCleanupSummary {
115
+ removedCount: number;
116
+ retainedCount: number;
117
+ bytesFreed: number;
118
+ breakdown: MemoryCleanupResult['breakdown'];
119
+ }
120
+ /**
121
+ * Summary of event archival
122
+ */
123
+ export interface EventArchivalSummary {
124
+ archivedWuCount: number;
125
+ retainedWuCount: number;
126
+ archivedEventCount: number;
127
+ retainedEventCount: number;
128
+ bytesArchived: number;
129
+ breakdown: EventArchivalResult['breakdown'];
130
+ }
131
+ /**
132
+ * Overall summary of state cleanup
133
+ */
134
+ export interface StateCleanupSummary {
135
+ totalBytesFreed: number;
136
+ typesExecuted: CleanupType[];
137
+ typesSkipped: CleanupType[];
138
+ }
139
+ /**
140
+ * Options for unified state cleanup
141
+ */
142
+ export interface StateCleanupOptions {
143
+ /** If true, preview without modifications */
144
+ dryRun?: boolean;
145
+ /** Only execute signal cleanup */
146
+ signalsOnly?: boolean;
147
+ /** Only execute memory cleanup */
148
+ memoryOnly?: boolean;
149
+ /** Only execute event archival */
150
+ eventsOnly?: boolean;
151
+ /** Signal cleanup function (injectable for testing) */
152
+ cleanupSignals?: CleanupSignalsFn;
153
+ /** Memory cleanup function (injectable for testing) */
154
+ cleanupMemory?: CleanupMemoryFn;
155
+ /** Event archival function (injectable for testing) */
156
+ archiveEvents?: ArchiveEventsFn;
157
+ }
158
+ /**
159
+ * Result of unified state cleanup
160
+ */
161
+ export interface StateCleanupResult {
162
+ /** Whether all executed cleanups succeeded */
163
+ success: boolean;
164
+ /** True if in dry-run mode */
165
+ dryRun?: boolean;
166
+ /** Signal cleanup summary (undefined if skipped) */
167
+ signals?: SignalCleanupSummary;
168
+ /** Memory cleanup summary (undefined if skipped) */
169
+ memory?: MemoryCleanupSummary;
170
+ /** Event archival summary (undefined if skipped) */
171
+ events?: EventArchivalSummary;
172
+ /** Errors from failed cleanups (non-fatal) */
173
+ errors: CleanupError[];
174
+ /** Aggregated summary */
175
+ summary: StateCleanupSummary;
176
+ }
177
+ /**
178
+ * Orchestrate all state cleanup operations in dependency order.
179
+ *
180
+ * Executes cleanups in order: signals -> memory -> events
181
+ *
182
+ * Non-fatal: failures in one cleanup type don't block others.
183
+ * All errors are collected and reported in the result.
184
+ *
185
+ * @param baseDir - Project base directory
186
+ * @param options - State cleanup options
187
+ * @returns Unified cleanup result with summaries and errors
188
+ *
189
+ * @example
190
+ * // Full cleanup with dry-run
191
+ * const result = await cleanupState(baseDir, { dryRun: true });
192
+ *
193
+ * @example
194
+ * // Signals only
195
+ * const result = await cleanupState(baseDir, { signalsOnly: true });
196
+ *
197
+ * @example
198
+ * // With injected cleanup functions (for testing or custom implementations)
199
+ * const result = await cleanupState(baseDir, {
200
+ * cleanupSignals: myCustomSignalCleanup,
201
+ * cleanupMemory: myCustomMemoryCleanup,
202
+ * archiveEvents: myCustomEventArchival,
203
+ * });
204
+ */
205
+ export declare function cleanupState(baseDir: string, options?: StateCleanupOptions): Promise<StateCleanupResult>;