@lumenflow/core 2.2.2 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/active-wu-detector.d.ts +1 -1
- package/dist/active-wu-detector.js +1 -1
- package/dist/arg-parser.js +51 -18
- package/dist/backlog-generator.d.ts +4 -4
- package/dist/backlog-generator.js +4 -4
- package/dist/backlog-sync-validator.js +1 -1
- package/dist/cleanup-lock.d.ts +9 -2
- package/dist/cleanup-lock.js +17 -7
- package/dist/code-path-validator.d.ts +3 -3
- package/dist/code-path-validator.js +3 -3
- package/dist/compliance-parser.d.ts +1 -1
- package/dist/compliance-parser.js +1 -1
- package/dist/constants/backlog-patterns.d.ts +1 -1
- package/dist/constants/backlog-patterns.js +1 -1
- package/dist/constants/dora-constants.d.ts +1 -1
- package/dist/constants/dora-constants.js +1 -1
- package/dist/constants/gate-constants.d.ts +1 -1
- package/dist/constants/gate-constants.js +1 -1
- package/dist/constants/linter-constants.d.ts +1 -1
- package/dist/constants/linter-constants.js +1 -1
- package/dist/constants/tokenizer-constants.d.ts +1 -1
- package/dist/constants/tokenizer-constants.js +1 -1
- package/dist/context/location-resolver.js +2 -1
- package/dist/context-validation-integration.d.ts +1 -0
- package/dist/core/scope-checker.d.ts +3 -3
- package/dist/core/scope-checker.js +3 -3
- package/dist/core/tool-runner.d.ts +5 -5
- package/dist/core/tool-runner.js +5 -5
- package/dist/core/tool.constants.d.ts +1 -1
- package/dist/core/tool.constants.js +1 -1
- package/dist/core/tool.schemas.d.ts +2 -2
- package/dist/core/tool.schemas.js +1 -1
- package/dist/core/worktree-guard.d.ts +1 -1
- package/dist/core/worktree-guard.js +1 -1
- package/dist/coverage-gate.d.ts +12 -3
- package/dist/coverage-gate.js +15 -8
- package/dist/date-utils.d.ts +4 -4
- package/dist/date-utils.js +4 -4
- package/dist/dependency-graph.d.ts +6 -0
- package/dist/dependency-graph.js +43 -2
- package/dist/dependency-guard.d.ts +2 -2
- package/dist/dependency-guard.js +3 -3
- package/dist/dependency-validator.d.ts +4 -4
- package/dist/dependency-validator.js +4 -7
- package/dist/domain/orchestration.constants.d.ts +31 -10
- package/dist/domain/orchestration.constants.js +45 -16
- package/dist/domain/orchestration.schemas.d.ts +54 -28
- package/dist/domain/orchestration.schemas.js +2 -2
- package/dist/domain/orchestration.types.d.ts +2 -2
- package/dist/domain/orchestration.types.js +2 -2
- package/dist/error-handler.d.ts +10 -10
- package/dist/error-handler.js +10 -10
- package/dist/file-classifiers.d.ts +6 -6
- package/dist/file-classifiers.js +6 -6
- package/dist/gates-config.d.ts +74 -0
- package/dist/gates-config.js +209 -2
- package/dist/git-adapter.d.ts +11 -11
- package/dist/git-adapter.js +11 -11
- package/dist/git-context-extractor.d.ts +112 -0
- package/dist/git-context-extractor.js +559 -0
- package/dist/hardcoded-strings.d.ts +1 -1
- package/dist/hardcoded-strings.js +1 -1
- package/dist/incremental-lint.d.ts +1 -1
- package/dist/incremental-lint.js +2 -2
- package/dist/incremental-test.d.ts +1 -1
- package/dist/incremental-test.js +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +25 -0
- package/dist/invariants/check-automated-tests.d.ts +2 -2
- package/dist/invariants/check-automated-tests.js +3 -3
- package/dist/lane-checker.d.ts +28 -7
- package/dist/lane-checker.js +316 -159
- package/dist/lane-suggest-prompt.d.ts +108 -0
- package/dist/lane-suggest-prompt.js +359 -0
- package/dist/lane-validator.d.ts +3 -3
- package/dist/lane-validator.js +3 -3
- package/dist/logs-lib.d.ts +1 -1
- package/dist/logs-lib.js +1 -1
- package/dist/lumenflow-config-schema.d.ts +162 -0
- package/dist/lumenflow-config-schema.js +180 -0
- package/dist/manual-test-validator.d.ts +2 -2
- package/dist/manual-test-validator.js +3 -3
- package/dist/merge-lock.d.ts +8 -1
- package/dist/merge-lock.js +16 -7
- package/dist/micro-worktree.d.ts +81 -13
- package/dist/micro-worktree.js +98 -17
- package/dist/migration-deployer.d.ts +1 -1
- package/dist/migration-deployer.js +1 -1
- package/dist/orchestration-advisory-loader.d.ts +2 -2
- package/dist/orchestration-advisory-loader.js +10 -6
- package/dist/orchestration-advisory.d.ts +3 -3
- package/dist/orchestration-advisory.js +4 -4
- package/dist/orchestration-di.d.ts +4 -4
- package/dist/orchestration-di.js +4 -4
- package/dist/orchestration-rules.d.ts +4 -4
- package/dist/orchestration-rules.js +18 -10
- package/dist/orphan-detector.d.ts +3 -3
- package/dist/orphan-detector.js +3 -3
- package/dist/patrol-loop.d.ts +170 -0
- package/dist/patrol-loop.js +186 -0
- package/dist/process-detector.d.ts +5 -5
- package/dist/process-detector.js +5 -5
- package/dist/rebase-artifact-cleanup.d.ts +3 -3
- package/dist/rebase-artifact-cleanup.js +3 -3
- package/dist/resolve-policy.d.ts +195 -0
- package/dist/resolve-policy.js +203 -0
- package/dist/risk-detector.d.ts +2 -2
- package/dist/risk-detector.js +2 -2
- package/dist/rollback-utils.d.ts +1 -1
- package/dist/rollback-utils.js +1 -1
- package/dist/section-headings.d.ts +1 -1
- package/dist/section-headings.js +1 -1
- package/dist/spawn-escalation.d.ts +4 -4
- package/dist/spawn-escalation.js +3 -3
- package/dist/spawn-monitor.d.ts +4 -4
- package/dist/spawn-monitor.js +4 -4
- package/dist/spawn-recovery.d.ts +3 -3
- package/dist/spawn-recovery.js +3 -3
- package/dist/spawn-registry-schema.d.ts +2 -2
- package/dist/spawn-registry-schema.js +2 -2
- package/dist/spawn-registry-store.d.ts +2 -2
- package/dist/spawn-registry-store.js +2 -2
- package/dist/spawn-strategy.d.ts +17 -11
- package/dist/spawn-strategy.js +47 -44
- package/dist/spawn-tree.d.ts +3 -3
- package/dist/spawn-tree.js +3 -3
- package/dist/state-cleanup-core.d.ts +205 -0
- package/dist/state-cleanup-core.js +240 -0
- package/dist/state-doctor-core.d.ts +168 -0
- package/dist/state-doctor-core.js +251 -0
- package/dist/stream-error-handler.d.ts +67 -0
- package/dist/stream-error-handler.js +94 -0
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.js +1 -1
- package/dist/template-loader.d.ts +162 -0
- package/dist/template-loader.js +372 -0
- package/dist/test-baseline.d.ts +176 -0
- package/dist/test-baseline.js +282 -0
- package/dist/usecases/get-suggestions.usecase.d.ts +1 -1
- package/dist/validation/command-registry.js +37 -0
- package/dist/validators/backlog-sync.js +4 -2
- package/dist/worktree-scanner.d.ts +1 -1
- package/dist/worktree-scanner.js +1 -1
- package/dist/worktree-symlink.d.ts +3 -3
- package/dist/worktree-symlink.js +3 -3
- package/dist/wu-backlog-updater.d.ts +1 -1
- package/dist/wu-backlog-updater.js +1 -1
- package/dist/wu-claim-helpers.d.ts +1 -1
- package/dist/wu-claim-helpers.js +1 -1
- package/dist/wu-claim-resume.d.ts +1 -1
- package/dist/wu-claim-resume.js +1 -1
- package/dist/wu-consistency-checker.d.ts +1 -1
- package/dist/wu-consistency-checker.js +17 -11
- package/dist/wu-constants.d.ts +73 -21
- package/dist/wu-constants.js +65 -22
- package/dist/wu-done-branch-only.d.ts +1 -1
- package/dist/wu-done-branch-only.js +1 -1
- package/dist/wu-done-docs-generate.d.ts +1 -1
- package/dist/wu-done-docs-generate.js +1 -1
- package/dist/wu-done-messages.d.ts +2 -2
- package/dist/wu-done-messages.js +2 -2
- package/dist/wu-done-metadata.d.ts +3 -3
- package/dist/wu-done-metadata.js +3 -3
- package/dist/wu-done-pr.d.ts +1 -1
- package/dist/wu-done-pr.js +4 -2
- package/dist/wu-done-preflight.d.ts +8 -0
- package/dist/wu-done-preflight.js +18 -2
- package/dist/wu-done-ui.d.ts +3 -3
- package/dist/wu-done-ui.js +3 -3
- package/dist/wu-done-validation.d.ts +30 -0
- package/dist/wu-done-validation.js +106 -1
- package/dist/wu-done-worktree.d.ts +1 -1
- package/dist/wu-done-worktree.js +11 -1
- package/dist/wu-events-cleanup.d.ts +148 -0
- package/dist/wu-events-cleanup.js +401 -0
- package/dist/wu-helpers.d.ts +2 -2
- package/dist/wu-helpers.js +2 -2
- package/dist/wu-id-generator.d.ts +58 -0
- package/dist/wu-id-generator.js +103 -0
- package/dist/wu-lint.js +1 -1
- package/dist/wu-preflight-validators.d.ts +13 -1
- package/dist/wu-preflight-validators.js +56 -1
- package/dist/wu-recovery.d.ts +2 -2
- package/dist/wu-recovery.js +4 -4
- package/dist/wu-repair-core.d.ts +5 -5
- package/dist/wu-repair-core.js +6 -6
- package/dist/wu-schema-normalization.d.ts +1 -1
- package/dist/wu-schema-normalization.js +1 -1
- package/dist/wu-schema.d.ts +7 -7
- package/dist/wu-schema.js +8 -8
- package/dist/wu-spawn-context.d.ts +87 -0
- package/dist/wu-spawn-context.js +175 -0
- package/dist/wu-spawn-helpers.d.ts +1 -1
- package/dist/wu-spawn-helpers.js +1 -1
- package/dist/wu-spawn.d.ts +177 -4
- package/dist/wu-spawn.js +694 -72
- package/dist/wu-state-schema.d.ts +1 -1
- package/dist/wu-state-schema.js +1 -1
- package/dist/wu-state-store.d.ts +3 -3
- package/dist/wu-state-store.js +3 -3
- package/dist/wu-status-transition.d.ts +1 -1
- package/dist/wu-status-transition.js +1 -1
- package/dist/wu-status-updater.d.ts +3 -3
- package/dist/wu-status-updater.js +3 -3
- package/dist/wu-validation-constants.d.ts +2 -2
- package/dist/wu-validation-constants.js +2 -2
- package/dist/wu-validation.d.ts +3 -3
- package/dist/wu-validation.js +3 -3
- package/dist/wu-yaml-fixer.d.ts +2 -2
- package/dist/wu-yaml-fixer.js +3 -3
- package/dist/wu-yaml.d.ts +23 -0
- package/dist/wu-yaml.js +76 -2
- package/package.json +5 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream Error Handler
|
|
3
|
+
*
|
|
4
|
+
* WU-1233: Centralized EPIPE protection for CLI commands.
|
|
5
|
+
*
|
|
6
|
+
* When CLI output is piped through head/tail, the pipe may close before
|
|
7
|
+
* all output is written. Node.js throws EPIPE errors in this case.
|
|
8
|
+
* This handler catches those errors and exits gracefully.
|
|
9
|
+
*
|
|
10
|
+
* Unix convention: Exit with code 0 on EPIPE (the consumer got what it needed).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { StreamErrorHandler } from '@lumenflow/core';
|
|
15
|
+
*
|
|
16
|
+
* // In CLI entry point:
|
|
17
|
+
* const handler = StreamErrorHandler.createWithDefaults();
|
|
18
|
+
* handler.attach();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import type { WriteStream } from 'node:tty';
|
|
22
|
+
/**
|
|
23
|
+
* Dependencies for StreamErrorHandler
|
|
24
|
+
*
|
|
25
|
+
* Uses dependency injection for testability.
|
|
26
|
+
*/
|
|
27
|
+
export interface StreamErrorHandlerDeps {
|
|
28
|
+
/** Standard output stream */
|
|
29
|
+
stdout: WriteStream;
|
|
30
|
+
/** Standard error stream */
|
|
31
|
+
stderr: WriteStream;
|
|
32
|
+
/** Exit function (defaults to process.exit) */
|
|
33
|
+
exitFn: (code: number) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* StreamErrorHandler
|
|
37
|
+
*
|
|
38
|
+
* Attaches error listeners to stdout/stderr to handle EPIPE errors gracefully.
|
|
39
|
+
* Follows single responsibility principle - only handles stream errors.
|
|
40
|
+
*/
|
|
41
|
+
export declare class StreamErrorHandler {
|
|
42
|
+
private readonly deps;
|
|
43
|
+
private attached;
|
|
44
|
+
private stdoutHandler;
|
|
45
|
+
private stderrHandler;
|
|
46
|
+
constructor(deps: StreamErrorHandlerDeps);
|
|
47
|
+
/**
|
|
48
|
+
* Create a handler with default dependencies (process.stdout, process.stderr, process.exit)
|
|
49
|
+
*/
|
|
50
|
+
static createWithDefaults(): StreamErrorHandler;
|
|
51
|
+
/**
|
|
52
|
+
* Attach error listeners to stdout and stderr
|
|
53
|
+
*
|
|
54
|
+
* Safe to call multiple times - will not attach duplicate listeners.
|
|
55
|
+
*/
|
|
56
|
+
attach(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Detach error listeners from stdout and stderr
|
|
59
|
+
*
|
|
60
|
+
* Safe to call even if not attached.
|
|
61
|
+
*/
|
|
62
|
+
detach(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Create an error handler that catches EPIPE and exits gracefully
|
|
65
|
+
*/
|
|
66
|
+
private createErrorHandler;
|
|
67
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream Error Handler
|
|
3
|
+
*
|
|
4
|
+
* WU-1233: Centralized EPIPE protection for CLI commands.
|
|
5
|
+
*
|
|
6
|
+
* When CLI output is piped through head/tail, the pipe may close before
|
|
7
|
+
* all output is written. Node.js throws EPIPE errors in this case.
|
|
8
|
+
* This handler catches those errors and exits gracefully.
|
|
9
|
+
*
|
|
10
|
+
* Unix convention: Exit with code 0 on EPIPE (the consumer got what it needed).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { StreamErrorHandler } from '@lumenflow/core';
|
|
15
|
+
*
|
|
16
|
+
* // In CLI entry point:
|
|
17
|
+
* const handler = StreamErrorHandler.createWithDefaults();
|
|
18
|
+
* handler.attach();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { STREAM_ERRORS, EXIT_CODES } from './wu-constants.js';
|
|
22
|
+
/**
|
|
23
|
+
* StreamErrorHandler
|
|
24
|
+
*
|
|
25
|
+
* Attaches error listeners to stdout/stderr to handle EPIPE errors gracefully.
|
|
26
|
+
* Follows single responsibility principle - only handles stream errors.
|
|
27
|
+
*/
|
|
28
|
+
export class StreamErrorHandler {
|
|
29
|
+
deps;
|
|
30
|
+
attached = false;
|
|
31
|
+
stdoutHandler = null;
|
|
32
|
+
stderrHandler = null;
|
|
33
|
+
constructor(deps) {
|
|
34
|
+
this.deps = deps;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a handler with default dependencies (process.stdout, process.stderr, process.exit)
|
|
38
|
+
*/
|
|
39
|
+
static createWithDefaults() {
|
|
40
|
+
return new StreamErrorHandler({
|
|
41
|
+
stdout: process.stdout,
|
|
42
|
+
stderr: process.stderr,
|
|
43
|
+
exitFn: (code) => process.exit(code),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Attach error listeners to stdout and stderr
|
|
48
|
+
*
|
|
49
|
+
* Safe to call multiple times - will not attach duplicate listeners.
|
|
50
|
+
*/
|
|
51
|
+
attach() {
|
|
52
|
+
if (this.attached) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.stdoutHandler = this.createErrorHandler();
|
|
56
|
+
this.stderrHandler = this.createErrorHandler();
|
|
57
|
+
this.deps.stdout.on('error', this.stdoutHandler);
|
|
58
|
+
this.deps.stderr.on('error', this.stderrHandler);
|
|
59
|
+
this.attached = true;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Detach error listeners from stdout and stderr
|
|
63
|
+
*
|
|
64
|
+
* Safe to call even if not attached.
|
|
65
|
+
*/
|
|
66
|
+
detach() {
|
|
67
|
+
if (!this.attached) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (this.stdoutHandler) {
|
|
71
|
+
this.deps.stdout.removeListener('error', this.stdoutHandler);
|
|
72
|
+
this.stdoutHandler = null;
|
|
73
|
+
}
|
|
74
|
+
if (this.stderrHandler) {
|
|
75
|
+
this.deps.stderr.removeListener('error', this.stderrHandler);
|
|
76
|
+
this.stderrHandler = null;
|
|
77
|
+
}
|
|
78
|
+
this.attached = false;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create an error handler that catches EPIPE and exits gracefully
|
|
82
|
+
*/
|
|
83
|
+
createErrorHandler() {
|
|
84
|
+
return (err) => {
|
|
85
|
+
// Only handle EPIPE errors
|
|
86
|
+
if (err.code === STREAM_ERRORS.EPIPE) {
|
|
87
|
+
// Exit gracefully with success code (Unix convention)
|
|
88
|
+
// The consumer of the pipe got what it needed
|
|
89
|
+
this.deps.exitFn(EXIT_CODES.SUCCESS);
|
|
90
|
+
}
|
|
91
|
+
// Non-EPIPE errors are not handled here - let them propagate
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Telemetry Module - DORA/SPACE Metrics Emission
|
|
4
4
|
*
|
|
5
5
|
* Emits structured NDJSON telemetry for gates execution and WU flow metrics.
|
|
6
|
-
* Used by gates-local.
|
|
6
|
+
* Used by gates-local.ts and flow-report.ts.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* Emit a telemetry event as NDJSON
|
package/dist/telemetry.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Telemetry Module - DORA/SPACE Metrics Emission
|
|
4
4
|
*
|
|
5
5
|
* Emits structured NDJSON telemetry for gates execution and WU flow metrics.
|
|
6
|
-
* Used by gates-local.
|
|
6
|
+
* Used by gates-local.ts and flow-report.ts.
|
|
7
7
|
*/
|
|
8
8
|
import { appendFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
9
9
|
import { execSync } from 'node:child_process';
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Loader (WU-1253)
|
|
3
|
+
*
|
|
4
|
+
* Loads, parses, and assembles prompt templates from .lumenflow/templates/
|
|
5
|
+
* with YAML frontmatter support. Enables extraction of hardcoded templates
|
|
6
|
+
* from wu-spawn.ts into maintainable markdown files.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - YAML frontmatter parsing via gray-matter
|
|
10
|
+
* - Manifest-driven assembly order
|
|
11
|
+
* - Client-specific overrides (templates.claude/, templates.cursor/)
|
|
12
|
+
* - Token replacement ({WU_ID}, {LANE}, etc.)
|
|
13
|
+
* - Conditional template inclusion
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://lumenflow.dev/reference/template-system/} - Template documentation
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Template frontmatter parsed from YAML.
|
|
19
|
+
* All templates must include these fields in their frontmatter block.
|
|
20
|
+
*/
|
|
21
|
+
export interface TemplateFrontmatter {
|
|
22
|
+
/** Unique identifier matching manifest entry (e.g., 'tdd-directive') */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Human-readable name for debugging and documentation */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Whether this template must be present for assembly to succeed */
|
|
27
|
+
required: boolean;
|
|
28
|
+
/** Assembly position - lower numbers appear first in output */
|
|
29
|
+
order: number;
|
|
30
|
+
/** Token names for replacement (e.g., ['WU_ID', 'LANE']) */
|
|
31
|
+
tokens?: string[];
|
|
32
|
+
/** Conditional expression for inclusion (e.g., "type === 'feature'") */
|
|
33
|
+
condition?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Loaded template with content and metadata.
|
|
37
|
+
* Returned by loadTemplate() after parsing.
|
|
38
|
+
*/
|
|
39
|
+
export interface LoadedTemplate {
|
|
40
|
+
/** Parsed frontmatter fields */
|
|
41
|
+
frontmatter: TemplateFrontmatter;
|
|
42
|
+
/** Markdown content after frontmatter block */
|
|
43
|
+
content: string;
|
|
44
|
+
/** Original file path for debugging */
|
|
45
|
+
sourcePath: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Manifest entry defining a template's inclusion in assembly.
|
|
49
|
+
*/
|
|
50
|
+
export interface ManifestEntry {
|
|
51
|
+
/** Template identifier matching frontmatter id */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Relative path within templates/spawn-prompt/ */
|
|
54
|
+
path: string;
|
|
55
|
+
/** Must be present for assembly to succeed */
|
|
56
|
+
required: boolean;
|
|
57
|
+
/** Assembly position (ascending order) */
|
|
58
|
+
order: number;
|
|
59
|
+
/** Optional condition expression */
|
|
60
|
+
condition?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Complete manifest structure parsed from manifest.yaml.
|
|
64
|
+
*/
|
|
65
|
+
export interface TemplateManifest {
|
|
66
|
+
/** Manifest format version */
|
|
67
|
+
version: string;
|
|
68
|
+
/** Default settings for template processing */
|
|
69
|
+
defaults: {
|
|
70
|
+
/** Token format: '{TOKEN}' or '{{TOKEN}}' */
|
|
71
|
+
tokenFormat: string;
|
|
72
|
+
};
|
|
73
|
+
/** Ordered list of template entries */
|
|
74
|
+
templates: ManifestEntry[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Context for token replacement during assembly.
|
|
78
|
+
* Values are substituted for {TOKEN} placeholders.
|
|
79
|
+
*/
|
|
80
|
+
export interface TemplateContext {
|
|
81
|
+
/** Work Unit identifier (e.g., 'WU-1253') */
|
|
82
|
+
WU_ID: string;
|
|
83
|
+
/** Lane name (e.g., 'Framework: Core') */
|
|
84
|
+
LANE: string;
|
|
85
|
+
/** WU type (e.g., 'feature', 'bug', 'documentation') */
|
|
86
|
+
TYPE: string;
|
|
87
|
+
/** Optional WU title */
|
|
88
|
+
TITLE?: string;
|
|
89
|
+
/** Optional WU description */
|
|
90
|
+
DESCRIPTION?: string;
|
|
91
|
+
/** Optional worktree path */
|
|
92
|
+
WORKTREE_PATH?: string;
|
|
93
|
+
/** Optional parent lane extracted from LANE */
|
|
94
|
+
laneParent?: string;
|
|
95
|
+
/** Allow additional context properties */
|
|
96
|
+
[key: string]: string | undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Load and parse the template manifest.
|
|
100
|
+
*
|
|
101
|
+
* @param baseDir - Project root directory containing .lumenflow/
|
|
102
|
+
* @returns Parsed manifest with validated structure
|
|
103
|
+
* @throws If manifest is missing or has invalid structure
|
|
104
|
+
*/
|
|
105
|
+
export declare function loadManifest(baseDir: string): TemplateManifest;
|
|
106
|
+
/**
|
|
107
|
+
* Load a single template file with frontmatter parsing.
|
|
108
|
+
*
|
|
109
|
+
* Uses gray-matter with the yaml engine for robust parsing,
|
|
110
|
+
* matching the pattern established in backlog-parser.ts.
|
|
111
|
+
*
|
|
112
|
+
* @param templatePath - Absolute path to template file
|
|
113
|
+
* @returns Parsed template with frontmatter and content
|
|
114
|
+
* @throws If file is missing or frontmatter is invalid
|
|
115
|
+
*/
|
|
116
|
+
export declare function loadTemplate(templatePath: string): LoadedTemplate;
|
|
117
|
+
/**
|
|
118
|
+
* Load all templates from a directory, respecting client overrides.
|
|
119
|
+
*
|
|
120
|
+
* Override resolution order:
|
|
121
|
+
* 1. .lumenflow/templates.{client}/spawn-prompt/{template}.md (highest priority)
|
|
122
|
+
* 2. .lumenflow/templates/spawn-prompt/{template}.md (fallback)
|
|
123
|
+
*
|
|
124
|
+
* @param baseDir - Project root directory
|
|
125
|
+
* @param clientName - Client name for overrides (e.g., 'claude', 'cursor')
|
|
126
|
+
* @returns Map of template id to loaded template
|
|
127
|
+
*/
|
|
128
|
+
export declare function loadTemplatesWithOverrides(baseDir: string, clientName: string): Map<string, LoadedTemplate>;
|
|
129
|
+
/**
|
|
130
|
+
* Assemble templates in manifest order with token replacement.
|
|
131
|
+
*
|
|
132
|
+
* @param templates - Map of loaded templates by id
|
|
133
|
+
* @param manifest - Manifest defining assembly order
|
|
134
|
+
* @param context - Token values for replacement
|
|
135
|
+
* @returns Assembled content with all tokens replaced
|
|
136
|
+
* @throws If required template is missing
|
|
137
|
+
*/
|
|
138
|
+
export declare function assembleTemplates(templates: Map<string, LoadedTemplate>, manifest: TemplateManifest, context: TemplateContext): string;
|
|
139
|
+
/**
|
|
140
|
+
* Replace {TOKEN} placeholders with context values.
|
|
141
|
+
*
|
|
142
|
+
* @param content - Template content with placeholders
|
|
143
|
+
* @param tokens - Token name to value mapping
|
|
144
|
+
* @returns Content with tokens replaced
|
|
145
|
+
*/
|
|
146
|
+
export declare function replaceTokens(content: string, tokens: Record<string, string | undefined>): string;
|
|
147
|
+
/**
|
|
148
|
+
* Evaluate a simple condition expression against context.
|
|
149
|
+
*
|
|
150
|
+
* Supports:
|
|
151
|
+
* - Equality: type === 'feature'
|
|
152
|
+
* - Inequality: type !== 'documentation'
|
|
153
|
+
* - Truthy: worktreePath
|
|
154
|
+
* - AND: type === 'feature' && lane === 'Core'
|
|
155
|
+
* - OR: type === 'feature' || type === 'bug'
|
|
156
|
+
* - Dotted paths: policy.testing === 'tdd' (WU-1260)
|
|
157
|
+
*
|
|
158
|
+
* @param condition - Condition expression string
|
|
159
|
+
* @param context - Context values for evaluation
|
|
160
|
+
* @returns Whether condition evaluates to true
|
|
161
|
+
*/
|
|
162
|
+
export declare function evaluateCondition(condition: string | undefined, context: Record<string, unknown>): boolean;
|