@lumenflow/core 1.4.0 → 1.6.0
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/README.md +362 -7
- package/dist/adapters/context-adapters.d.ts +90 -0
- package/dist/adapters/context-adapters.js +99 -0
- package/dist/adapters/index.d.ts +14 -0
- package/dist/adapters/index.js +18 -0
- package/dist/adapters/recovery-adapters.d.ts +40 -0
- package/dist/adapters/recovery-adapters.js +43 -0
- package/dist/adapters/validation-adapters.d.ts +52 -0
- package/dist/adapters/validation-adapters.js +59 -0
- package/dist/agent-patterns-registry.d.ts +100 -2
- package/dist/agent-patterns-registry.js +124 -0
- package/dist/arg-parser.js +7 -0
- package/dist/branch-check.d.ts +32 -3
- package/dist/branch-check.js +81 -15
- package/dist/color-support.d.ts +32 -0
- package/dist/color-support.js +64 -0
- package/dist/context/context-computer.d.ts +46 -0
- package/dist/context/context-computer.js +125 -0
- package/dist/context/git-state-reader.d.ts +51 -0
- package/dist/context/git-state-reader.js +61 -0
- package/dist/context/index.d.ts +17 -0
- package/dist/context/index.js +17 -0
- package/dist/context/location-resolver.d.ts +48 -0
- package/dist/context/location-resolver.js +175 -0
- package/dist/context/wu-state-reader.d.ts +37 -0
- package/dist/context/wu-state-reader.js +76 -0
- package/dist/context-di.d.ts +184 -0
- package/dist/context-di.js +178 -0
- package/dist/context-validation-integration.d.ts +77 -0
- package/dist/context-validation-integration.js +157 -0
- package/dist/cycle-detector.d.ts +51 -0
- package/dist/cycle-detector.js +89 -0
- package/dist/dependency-graph.js +1 -11
- package/dist/domain/context.schemas.d.ts +147 -0
- package/dist/domain/context.schemas.js +126 -0
- package/dist/domain/index.d.ts +14 -0
- package/dist/domain/index.js +18 -0
- package/dist/domain/recovery.schemas.d.ts +115 -0
- package/dist/domain/recovery.schemas.js +83 -0
- package/dist/domain/validation.schemas.d.ts +146 -0
- package/dist/domain/validation.schemas.js +114 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +47 -0
- package/dist/lumenflow-config-schema.d.ts +47 -0
- package/dist/lumenflow-config-schema.js +84 -4
- package/dist/ports/context.ports.d.ts +135 -0
- package/dist/ports/context.ports.js +21 -0
- package/dist/ports/index.d.ts +14 -0
- package/dist/ports/index.js +14 -0
- package/dist/ports/recovery.ports.d.ts +58 -0
- package/dist/ports/recovery.ports.js +17 -0
- package/dist/ports/validation.ports.d.ts +74 -0
- package/dist/ports/validation.ports.js +17 -0
- package/dist/recovery/index.d.ts +11 -0
- package/dist/recovery/index.js +11 -0
- package/dist/recovery/recovery-analyzer.d.ts +66 -0
- package/dist/recovery/recovery-analyzer.js +129 -0
- package/dist/usecases/analyze-recovery.usecase.d.ts +42 -0
- package/dist/usecases/analyze-recovery.usecase.js +45 -0
- package/dist/usecases/compute-context.usecase.d.ts +62 -0
- package/dist/usecases/compute-context.usecase.js +101 -0
- package/dist/usecases/index.d.ts +14 -0
- package/dist/usecases/index.js +18 -0
- package/dist/usecases/validate-command.usecase.d.ts +55 -0
- package/dist/usecases/validate-command.usecase.js +154 -0
- package/dist/validation/command-registry.d.ts +38 -0
- package/dist/validation/command-registry.js +229 -0
- package/dist/validation/index.d.ts +15 -0
- package/dist/validation/index.js +15 -0
- package/dist/validation/types.d.ts +135 -0
- package/dist/validation/types.js +11 -0
- package/dist/validation/validate-command.d.ts +27 -0
- package/dist/validation/validate-command.js +160 -0
- package/dist/wu-constants.d.ts +136 -0
- package/dist/wu-constants.js +124 -0
- package/dist/wu-done-preflight.js +8 -1
- package/dist/wu-helpers.d.ts +5 -1
- package/dist/wu-helpers.js +12 -1
- package/package.json +3 -6
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Schemas
|
|
3
|
+
*
|
|
4
|
+
* WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
|
|
5
|
+
*
|
|
6
|
+
* Zod schemas for validation-related types in the context-aware validation system.
|
|
7
|
+
* Types are inferred from Zod schemas using z.infer<> for single source of truth.
|
|
8
|
+
*
|
|
9
|
+
* @module domain/validation.schemas
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { LocationTypeSchema } from './context.schemas.js';
|
|
13
|
+
export { LocationTypeSchema };
|
|
14
|
+
/**
|
|
15
|
+
* Validation error code values
|
|
16
|
+
*
|
|
17
|
+
* Mirrors CONTEXT_VALIDATION.ERROR_CODES from wu-constants.ts
|
|
18
|
+
*/
|
|
19
|
+
export declare const VALIDATION_ERROR_CODE_VALUES: readonly ["WRONG_LOCATION", "WU_NOT_FOUND", "WU_ALREADY_EXISTS", "WRONG_WU_STATUS", "LANE_OCCUPIED", "WORKTREE_EXISTS", "WORKTREE_MISSING", "GATES_NOT_PASSED", "DIRTY_GIT", "REMOTE_UNAVAILABLE", "INCONSISTENT_STATE"];
|
|
20
|
+
/**
|
|
21
|
+
* Schema for validation error codes
|
|
22
|
+
*/
|
|
23
|
+
export declare const ValidationErrorCodeSchema: z.ZodEnum<{
|
|
24
|
+
WU_NOT_FOUND: "WU_NOT_FOUND";
|
|
25
|
+
WRONG_LOCATION: "WRONG_LOCATION";
|
|
26
|
+
WU_ALREADY_EXISTS: "WU_ALREADY_EXISTS";
|
|
27
|
+
WRONG_WU_STATUS: "WRONG_WU_STATUS";
|
|
28
|
+
LANE_OCCUPIED: "LANE_OCCUPIED";
|
|
29
|
+
WORKTREE_EXISTS: "WORKTREE_EXISTS";
|
|
30
|
+
WORKTREE_MISSING: "WORKTREE_MISSING";
|
|
31
|
+
GATES_NOT_PASSED: "GATES_NOT_PASSED";
|
|
32
|
+
DIRTY_GIT: "DIRTY_GIT";
|
|
33
|
+
REMOTE_UNAVAILABLE: "REMOTE_UNAVAILABLE";
|
|
34
|
+
INCONSISTENT_STATE: "INCONSISTENT_STATE";
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Severity values
|
|
38
|
+
*
|
|
39
|
+
* Mirrors CONTEXT_VALIDATION.SEVERITY from wu-constants.ts
|
|
40
|
+
*/
|
|
41
|
+
export declare const PREDICATE_SEVERITY_VALUES: readonly ["error", "warning"];
|
|
42
|
+
/**
|
|
43
|
+
* Schema for predicate severity
|
|
44
|
+
*/
|
|
45
|
+
export declare const PredicateSeveritySchema: z.ZodEnum<{
|
|
46
|
+
error: "error";
|
|
47
|
+
warning: "warning";
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Schema for validation error with fix guidance
|
|
51
|
+
*/
|
|
52
|
+
export declare const ValidationErrorSchema: z.ZodObject<{
|
|
53
|
+
code: z.ZodEnum<{
|
|
54
|
+
WU_NOT_FOUND: "WU_NOT_FOUND";
|
|
55
|
+
WRONG_LOCATION: "WRONG_LOCATION";
|
|
56
|
+
WU_ALREADY_EXISTS: "WU_ALREADY_EXISTS";
|
|
57
|
+
WRONG_WU_STATUS: "WRONG_WU_STATUS";
|
|
58
|
+
LANE_OCCUPIED: "LANE_OCCUPIED";
|
|
59
|
+
WORKTREE_EXISTS: "WORKTREE_EXISTS";
|
|
60
|
+
WORKTREE_MISSING: "WORKTREE_MISSING";
|
|
61
|
+
GATES_NOT_PASSED: "GATES_NOT_PASSED";
|
|
62
|
+
DIRTY_GIT: "DIRTY_GIT";
|
|
63
|
+
REMOTE_UNAVAILABLE: "REMOTE_UNAVAILABLE";
|
|
64
|
+
INCONSISTENT_STATE: "INCONSISTENT_STATE";
|
|
65
|
+
}>;
|
|
66
|
+
message: z.ZodString;
|
|
67
|
+
fixCommand: z.ZodNullable<z.ZodString>;
|
|
68
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
/**
|
|
71
|
+
* Schema for validation warning (non-blocking)
|
|
72
|
+
*/
|
|
73
|
+
export declare const ValidationWarningSchema: z.ZodObject<{
|
|
74
|
+
id: z.ZodString;
|
|
75
|
+
message: z.ZodString;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
/**
|
|
78
|
+
* Schema for validation result (partial, without context for serialization)
|
|
79
|
+
*
|
|
80
|
+
* Note: The full ValidationResult in types.ts includes the context object,
|
|
81
|
+
* but this schema is for serializable results without the context.
|
|
82
|
+
*/
|
|
83
|
+
export declare const ValidationResultSchema: z.ZodObject<{
|
|
84
|
+
valid: z.ZodBoolean;
|
|
85
|
+
errors: z.ZodArray<z.ZodObject<{
|
|
86
|
+
code: z.ZodEnum<{
|
|
87
|
+
WU_NOT_FOUND: "WU_NOT_FOUND";
|
|
88
|
+
WRONG_LOCATION: "WRONG_LOCATION";
|
|
89
|
+
WU_ALREADY_EXISTS: "WU_ALREADY_EXISTS";
|
|
90
|
+
WRONG_WU_STATUS: "WRONG_WU_STATUS";
|
|
91
|
+
LANE_OCCUPIED: "LANE_OCCUPIED";
|
|
92
|
+
WORKTREE_EXISTS: "WORKTREE_EXISTS";
|
|
93
|
+
WORKTREE_MISSING: "WORKTREE_MISSING";
|
|
94
|
+
GATES_NOT_PASSED: "GATES_NOT_PASSED";
|
|
95
|
+
DIRTY_GIT: "DIRTY_GIT";
|
|
96
|
+
REMOTE_UNAVAILABLE: "REMOTE_UNAVAILABLE";
|
|
97
|
+
INCONSISTENT_STATE: "INCONSISTENT_STATE";
|
|
98
|
+
}>;
|
|
99
|
+
message: z.ZodString;
|
|
100
|
+
fixCommand: z.ZodNullable<z.ZodString>;
|
|
101
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
warnings: z.ZodArray<z.ZodObject<{
|
|
104
|
+
id: z.ZodString;
|
|
105
|
+
message: z.ZodString;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
/**
|
|
109
|
+
* Schema for command predicate configuration (serializable)
|
|
110
|
+
*
|
|
111
|
+
* This schema represents the serializable configuration of a predicate,
|
|
112
|
+
* not the full CommandPredicate which includes the check function.
|
|
113
|
+
*/
|
|
114
|
+
export declare const CommandPredicateConfigSchema: z.ZodObject<{
|
|
115
|
+
id: z.ZodString;
|
|
116
|
+
description: z.ZodString;
|
|
117
|
+
severity: z.ZodEnum<{
|
|
118
|
+
error: "error";
|
|
119
|
+
warning: "warning";
|
|
120
|
+
}>;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
/**
|
|
123
|
+
* Schema for command definition configuration (serializable)
|
|
124
|
+
*
|
|
125
|
+
* This schema represents the serializable configuration of a command definition,
|
|
126
|
+
* not the full CommandDefinition which includes function references.
|
|
127
|
+
*/
|
|
128
|
+
export declare const CommandDefinitionConfigSchema: z.ZodObject<{
|
|
129
|
+
name: z.ZodString;
|
|
130
|
+
description: z.ZodString;
|
|
131
|
+
requiredLocation: z.ZodNullable<z.ZodEnum<{
|
|
132
|
+
unknown: "unknown";
|
|
133
|
+
main: "main";
|
|
134
|
+
worktree: "worktree";
|
|
135
|
+
detached: "detached";
|
|
136
|
+
}>>;
|
|
137
|
+
requiredWuStatus: z.ZodNullable<z.ZodString>;
|
|
138
|
+
predicateIds: z.ZodArray<z.ZodString>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
export type ValidationErrorCode = z.infer<typeof ValidationErrorCodeSchema>;
|
|
141
|
+
export type PredicateSeverity = z.infer<typeof PredicateSeveritySchema>;
|
|
142
|
+
export type ValidationError = z.infer<typeof ValidationErrorSchema>;
|
|
143
|
+
export type ValidationWarning = z.infer<typeof ValidationWarningSchema>;
|
|
144
|
+
export type ValidationResult = z.infer<typeof ValidationResultSchema>;
|
|
145
|
+
export type CommandPredicateConfig = z.infer<typeof CommandPredicateConfigSchema>;
|
|
146
|
+
export type CommandDefinitionConfig = z.infer<typeof CommandDefinitionConfigSchema>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Schemas
|
|
3
|
+
*
|
|
4
|
+
* WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
|
|
5
|
+
*
|
|
6
|
+
* Zod schemas for validation-related types in the context-aware validation system.
|
|
7
|
+
* Types are inferred from Zod schemas using z.infer<> for single source of truth.
|
|
8
|
+
*
|
|
9
|
+
* @module domain/validation.schemas
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { LocationTypeSchema } from './context.schemas.js';
|
|
13
|
+
// Re-export LocationTypeSchema for command definitions
|
|
14
|
+
export { LocationTypeSchema };
|
|
15
|
+
/**
|
|
16
|
+
* Validation error code values
|
|
17
|
+
*
|
|
18
|
+
* Mirrors CONTEXT_VALIDATION.ERROR_CODES from wu-constants.ts
|
|
19
|
+
*/
|
|
20
|
+
export const VALIDATION_ERROR_CODE_VALUES = [
|
|
21
|
+
'WRONG_LOCATION',
|
|
22
|
+
'WU_NOT_FOUND',
|
|
23
|
+
'WU_ALREADY_EXISTS',
|
|
24
|
+
'WRONG_WU_STATUS',
|
|
25
|
+
'LANE_OCCUPIED',
|
|
26
|
+
'WORKTREE_EXISTS',
|
|
27
|
+
'WORKTREE_MISSING',
|
|
28
|
+
'GATES_NOT_PASSED',
|
|
29
|
+
'DIRTY_GIT',
|
|
30
|
+
'REMOTE_UNAVAILABLE',
|
|
31
|
+
'INCONSISTENT_STATE',
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Schema for validation error codes
|
|
35
|
+
*/
|
|
36
|
+
export const ValidationErrorCodeSchema = z.enum(VALIDATION_ERROR_CODE_VALUES);
|
|
37
|
+
/**
|
|
38
|
+
* Severity values
|
|
39
|
+
*
|
|
40
|
+
* Mirrors CONTEXT_VALIDATION.SEVERITY from wu-constants.ts
|
|
41
|
+
*/
|
|
42
|
+
export const PREDICATE_SEVERITY_VALUES = ['error', 'warning'];
|
|
43
|
+
/**
|
|
44
|
+
* Schema for predicate severity
|
|
45
|
+
*/
|
|
46
|
+
export const PredicateSeveritySchema = z.enum(PREDICATE_SEVERITY_VALUES);
|
|
47
|
+
/**
|
|
48
|
+
* Schema for validation error with fix guidance
|
|
49
|
+
*/
|
|
50
|
+
export const ValidationErrorSchema = z.object({
|
|
51
|
+
/** Error code */
|
|
52
|
+
code: ValidationErrorCodeSchema,
|
|
53
|
+
/** Human-readable message */
|
|
54
|
+
message: z.string(),
|
|
55
|
+
/** Copy-paste ready fix command (if available) */
|
|
56
|
+
fixCommand: z.string().nullable(),
|
|
57
|
+
/** Additional context for debugging */
|
|
58
|
+
context: z.record(z.string(), z.unknown()).optional(),
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Schema for validation warning (non-blocking)
|
|
62
|
+
*/
|
|
63
|
+
export const ValidationWarningSchema = z.object({
|
|
64
|
+
/** Warning ID */
|
|
65
|
+
id: z.string(),
|
|
66
|
+
/** Human-readable message */
|
|
67
|
+
message: z.string(),
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Schema for validation result (partial, without context for serialization)
|
|
71
|
+
*
|
|
72
|
+
* Note: The full ValidationResult in types.ts includes the context object,
|
|
73
|
+
* but this schema is for serializable results without the context.
|
|
74
|
+
*/
|
|
75
|
+
export const ValidationResultSchema = z.object({
|
|
76
|
+
/** Whether command can proceed */
|
|
77
|
+
valid: z.boolean(),
|
|
78
|
+
/** Errors that block execution */
|
|
79
|
+
errors: z.array(ValidationErrorSchema),
|
|
80
|
+
/** Warnings that don't block execution */
|
|
81
|
+
warnings: z.array(ValidationWarningSchema),
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Schema for command predicate configuration (serializable)
|
|
85
|
+
*
|
|
86
|
+
* This schema represents the serializable configuration of a predicate,
|
|
87
|
+
* not the full CommandPredicate which includes the check function.
|
|
88
|
+
*/
|
|
89
|
+
export const CommandPredicateConfigSchema = z.object({
|
|
90
|
+
/** Unique identifier for the predicate */
|
|
91
|
+
id: z.string(),
|
|
92
|
+
/** Human-readable description */
|
|
93
|
+
description: z.string(),
|
|
94
|
+
/** Severity: 'error' blocks execution, 'warning' allows with warning */
|
|
95
|
+
severity: PredicateSeveritySchema,
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Schema for command definition configuration (serializable)
|
|
99
|
+
*
|
|
100
|
+
* This schema represents the serializable configuration of a command definition,
|
|
101
|
+
* not the full CommandDefinition which includes function references.
|
|
102
|
+
*/
|
|
103
|
+
export const CommandDefinitionConfigSchema = z.object({
|
|
104
|
+
/** Command name (e.g., 'wu:create') */
|
|
105
|
+
name: z.string(),
|
|
106
|
+
/** Human-readable description */
|
|
107
|
+
description: z.string(),
|
|
108
|
+
/** Required location type (null = any location) */
|
|
109
|
+
requiredLocation: LocationTypeSchema.nullable(),
|
|
110
|
+
/** Required WU status (null = no status requirement) */
|
|
111
|
+
requiredWuStatus: z.string().nullable(),
|
|
112
|
+
/** Predicate IDs for additional checks */
|
|
113
|
+
predicateIds: z.array(z.string()),
|
|
114
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './date-utils.js';
|
|
|
8
8
|
export * from './error-handler.js';
|
|
9
9
|
export * from './retry-strategy.js';
|
|
10
10
|
export * from './beacon-migration.js';
|
|
11
|
+
export * from './cycle-detector.js';
|
|
11
12
|
export { DEFAULT_DOMAIN, inferDefaultDomain, normalizeToEmail, isValidEmail, } from './user-normalizer.js';
|
|
12
13
|
export * from './git-adapter.js';
|
|
13
14
|
export * from './state-machine.js';
|
|
@@ -47,3 +48,19 @@ export * from './agent-patterns-registry.js';
|
|
|
47
48
|
export * from './lumenflow-home.js';
|
|
48
49
|
export * from './force-bypass-audit.js';
|
|
49
50
|
export { LUMENFLOW_PATHS, BEACON_PATHS } from './wu-constants.js';
|
|
51
|
+
export * from './color-support.js';
|
|
52
|
+
export * from './context/index.js';
|
|
53
|
+
export * from './validation/index.js';
|
|
54
|
+
export * from './recovery/index.js';
|
|
55
|
+
export * from './context-validation-integration.js';
|
|
56
|
+
export { CONTEXT_VALIDATION } from './wu-constants.js';
|
|
57
|
+
export type { LocationType, ValidationErrorCode, RecoveryActionType, RecoveryIssueCode, PredicateSeverity, ValidationMode, } from './wu-constants.js';
|
|
58
|
+
export type { ILocationResolver, IGitStateReader, IWuStateReader } from './ports/context.ports.js';
|
|
59
|
+
export type { ICommandRegistry } from './ports/validation.ports.js';
|
|
60
|
+
export type { IRecoveryAnalyzer } from './ports/recovery.ports.js';
|
|
61
|
+
export { LOCATION_TYPE_VALUES, LocationTypeSchema, LocationContextSchema, GitStateSchema, WuStateResultSchema, SessionStateSchema, WuContextSchema, } from './domain/context.schemas.js';
|
|
62
|
+
export { VALIDATION_ERROR_CODE_VALUES, ValidationErrorCodeSchema, PREDICATE_SEVERITY_VALUES, PredicateSeveritySchema, ValidationErrorSchema, ValidationWarningSchema, ValidationResultSchema, CommandPredicateConfigSchema, CommandDefinitionConfigSchema, type CommandPredicateConfig, type CommandDefinitionConfig, } from './domain/validation.schemas.js';
|
|
63
|
+
export { RECOVERY_ISSUE_CODE_VALUES, RecoveryIssueCodeSchema, RECOVERY_ACTION_TYPE_VALUES, RecoveryActionTypeSchema, RecoveryIssueSchema, RecoveryActionSchema, RecoveryAnalysisSchema, } from './domain/recovery.schemas.js';
|
|
64
|
+
export { SimpleGitLocationAdapter, SimpleGitStateAdapter, FileSystemWuStateAdapter, CommandRegistryAdapter, RecoveryAnalyzerAdapter, } from './adapters/index.js';
|
|
65
|
+
export { ComputeContextUseCase, type ComputeContextOptions, ValidateCommandUseCase, AnalyzeRecoveryUseCase, } from './usecases/index.js';
|
|
66
|
+
export { createContextAdapters, createValidationAdapters, createRecoveryAdapters, createComputeContextUseCase, createValidateCommandUseCase, createAnalyzeRecoveryUseCase, computeWuContext, validateCommand, analyzeRecoveryIssues, type ContextAdapters, type ValidationAdapters, type RecoveryAdapters, type CreateComputeContextOptions, type CreateValidateCommandOptions, type CreateAnalyzeRecoveryOptions, } from './context-di.js';
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,8 @@ export * from './error-handler.js';
|
|
|
11
11
|
export * from './retry-strategy.js';
|
|
12
12
|
// Migration utilities (WU-1075)
|
|
13
13
|
export * from './beacon-migration.js';
|
|
14
|
+
// Cycle detection (WU-1088 - extracted from initiatives to break circular dependency)
|
|
15
|
+
export * from './cycle-detector.js';
|
|
14
16
|
// User normalizer (explicit exports to avoid conflicts)
|
|
15
17
|
export { DEFAULT_DOMAIN, inferDefaultDomain, normalizeToEmail, isValidEmail, } from './user-normalizer.js';
|
|
16
18
|
// Git operations
|
|
@@ -73,3 +75,48 @@ export * from './lumenflow-home.js';
|
|
|
73
75
|
export * from './force-bypass-audit.js';
|
|
74
76
|
// WU-1075: LumenFlow directory paths (exported from wu-constants)
|
|
75
77
|
export { LUMENFLOW_PATHS, BEACON_PATHS } from './wu-constants.js';
|
|
78
|
+
// WU-1085: Color support for NO_COLOR/FORCE_COLOR/--no-color
|
|
79
|
+
export * from './color-support.js';
|
|
80
|
+
// WU-1090: Context-aware state machine for WU lifecycle commands
|
|
81
|
+
export * from './context/index.js';
|
|
82
|
+
export * from './validation/index.js';
|
|
83
|
+
export * from './recovery/index.js';
|
|
84
|
+
export * from './context-validation-integration.js';
|
|
85
|
+
// WU-1090: Context validation constants
|
|
86
|
+
export { CONTEXT_VALIDATION } from './wu-constants.js';
|
|
87
|
+
// WU-1093: Domain schemas for context-aware validation (Zod schemas)
|
|
88
|
+
// Note: Types like LocationContext, GitState are already exported from context/index.js
|
|
89
|
+
// so we only export the Zod schemas, not the inferred types.
|
|
90
|
+
export {
|
|
91
|
+
// Context schemas
|
|
92
|
+
LOCATION_TYPE_VALUES, LocationTypeSchema, LocationContextSchema, GitStateSchema, WuStateResultSchema, SessionStateSchema, WuContextSchema, } from './domain/context.schemas.js';
|
|
93
|
+
export {
|
|
94
|
+
// Validation schemas
|
|
95
|
+
VALIDATION_ERROR_CODE_VALUES, ValidationErrorCodeSchema, PREDICATE_SEVERITY_VALUES, PredicateSeveritySchema, ValidationErrorSchema, ValidationWarningSchema, ValidationResultSchema, CommandPredicateConfigSchema, CommandDefinitionConfigSchema, } from './domain/validation.schemas.js';
|
|
96
|
+
export {
|
|
97
|
+
// Recovery schemas
|
|
98
|
+
RECOVERY_ISSUE_CODE_VALUES, RecoveryIssueCodeSchema, RECOVERY_ACTION_TYPE_VALUES, RecoveryActionTypeSchema, RecoveryIssueSchema, RecoveryActionSchema, RecoveryAnalysisSchema, } from './domain/recovery.schemas.js';
|
|
99
|
+
// WU-1094: Adapters - Concrete implementations of port interfaces
|
|
100
|
+
export {
|
|
101
|
+
// Context adapters
|
|
102
|
+
SimpleGitLocationAdapter, SimpleGitStateAdapter, FileSystemWuStateAdapter,
|
|
103
|
+
// Validation adapters
|
|
104
|
+
CommandRegistryAdapter,
|
|
105
|
+
// Recovery adapters
|
|
106
|
+
RecoveryAnalyzerAdapter, } from './adapters/index.js';
|
|
107
|
+
// WU-1094: Use Cases - Application layer business logic
|
|
108
|
+
export {
|
|
109
|
+
// Context use cases
|
|
110
|
+
ComputeContextUseCase,
|
|
111
|
+
// Validation use cases
|
|
112
|
+
ValidateCommandUseCase,
|
|
113
|
+
// Recovery use cases
|
|
114
|
+
AnalyzeRecoveryUseCase, } from './usecases/index.js';
|
|
115
|
+
// WU-1094: Dependency Injection - Factory functions for wiring
|
|
116
|
+
export {
|
|
117
|
+
// Adapter factory functions
|
|
118
|
+
createContextAdapters, createValidationAdapters, createRecoveryAdapters,
|
|
119
|
+
// Use case factory functions
|
|
120
|
+
createComputeContextUseCase, createValidateCommandUseCase, createAnalyzeRecoveryUseCase,
|
|
121
|
+
// Backwards compatible convenience functions
|
|
122
|
+
computeWuContext, validateCommand, analyzeRecoveryIssues, } from './context-di.js';
|
|
@@ -53,6 +53,8 @@ export declare const GitConfigSchema: z.ZodObject<{
|
|
|
53
53
|
branchDriftWarning: z.ZodDefault<z.ZodNumber>;
|
|
54
54
|
branchDriftInfo: z.ZodDefault<z.ZodNumber>;
|
|
55
55
|
agentBranchPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
56
|
+
agentBranchPatternsOverride: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
|
+
disableAgentPatternRegistry: z.ZodDefault<z.ZodBoolean>;
|
|
56
58
|
}, z.core.$strip>;
|
|
57
59
|
/**
|
|
58
60
|
* WU (Work Unit) configuration
|
|
@@ -203,6 +205,29 @@ export declare const AgentsConfigSchema: z.ZodObject<{
|
|
|
203
205
|
notes: z.ZodOptional<z.ZodString>;
|
|
204
206
|
}, z.core.$strip>>;
|
|
205
207
|
}, z.core.$strip>;
|
|
208
|
+
/**
|
|
209
|
+
* Validation mode for context-aware commands
|
|
210
|
+
* WU-1090: Context-aware state machine for WU lifecycle commands
|
|
211
|
+
*/
|
|
212
|
+
export declare const ValidationModeSchema: z.ZodDefault<z.ZodEnum<{
|
|
213
|
+
error: "error";
|
|
214
|
+
off: "off";
|
|
215
|
+
warn: "warn";
|
|
216
|
+
}>>;
|
|
217
|
+
/**
|
|
218
|
+
* Experimental features configuration
|
|
219
|
+
* WU-1090: Feature flags for gradual rollout
|
|
220
|
+
*/
|
|
221
|
+
export declare const ExperimentalConfigSchema: z.ZodObject<{
|
|
222
|
+
context_validation: z.ZodDefault<z.ZodBoolean>;
|
|
223
|
+
validation_mode: z.ZodDefault<z.ZodEnum<{
|
|
224
|
+
error: "error";
|
|
225
|
+
off: "off";
|
|
226
|
+
warn: "warn";
|
|
227
|
+
}>>;
|
|
228
|
+
show_next_steps: z.ZodDefault<z.ZodBoolean>;
|
|
229
|
+
recovery_command: z.ZodDefault<z.ZodBoolean>;
|
|
230
|
+
}, z.core.$strip>;
|
|
206
231
|
/**
|
|
207
232
|
* Complete LumenFlow configuration schema
|
|
208
233
|
*/
|
|
@@ -245,6 +270,8 @@ export declare const LumenFlowConfigSchema: z.ZodObject<{
|
|
|
245
270
|
branchDriftWarning: z.ZodDefault<z.ZodNumber>;
|
|
246
271
|
branchDriftInfo: z.ZodDefault<z.ZodNumber>;
|
|
247
272
|
agentBranchPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
273
|
+
agentBranchPatternsOverride: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
274
|
+
disableAgentPatternRegistry: z.ZodDefault<z.ZodBoolean>;
|
|
248
275
|
}, z.core.$strip>>;
|
|
249
276
|
wu: z.ZodDefault<z.ZodObject<{
|
|
250
277
|
idPattern: z.ZodDefault<z.ZodString>;
|
|
@@ -331,6 +358,16 @@ export declare const LumenFlowConfigSchema: z.ZodObject<{
|
|
|
331
358
|
notes: z.ZodOptional<z.ZodString>;
|
|
332
359
|
}, z.core.$strip>>;
|
|
333
360
|
}, z.core.$strip>>;
|
|
361
|
+
experimental: z.ZodDefault<z.ZodObject<{
|
|
362
|
+
context_validation: z.ZodDefault<z.ZodBoolean>;
|
|
363
|
+
validation_mode: z.ZodDefault<z.ZodEnum<{
|
|
364
|
+
error: "error";
|
|
365
|
+
off: "off";
|
|
366
|
+
warn: "warn";
|
|
367
|
+
}>>;
|
|
368
|
+
show_next_steps: z.ZodDefault<z.ZodBoolean>;
|
|
369
|
+
recovery_command: z.ZodDefault<z.ZodBoolean>;
|
|
370
|
+
}, z.core.$strip>>;
|
|
334
371
|
}, z.core.$strip>;
|
|
335
372
|
/**
|
|
336
373
|
* TypeScript types inferred from schemas
|
|
@@ -348,6 +385,8 @@ export type ClientBlock = z.infer<typeof ClientBlockSchema>;
|
|
|
348
385
|
export type ClientSkills = z.infer<typeof ClientSkillsSchema>;
|
|
349
386
|
export type ClientConfig = z.infer<typeof ClientConfigSchema>;
|
|
350
387
|
export type AgentsConfig = z.infer<typeof AgentsConfigSchema>;
|
|
388
|
+
export type ExperimentalConfig = z.infer<typeof ExperimentalConfigSchema>;
|
|
389
|
+
export type ValidationMode = z.infer<typeof ValidationModeSchema>;
|
|
351
390
|
export type LumenFlowConfig = z.infer<typeof LumenFlowConfigSchema>;
|
|
352
391
|
/**
|
|
353
392
|
* Validate configuration data
|
|
@@ -394,6 +433,8 @@ export declare function validateConfig(data: unknown): z.ZodSafeParseResult<{
|
|
|
394
433
|
branchDriftWarning: number;
|
|
395
434
|
branchDriftInfo: number;
|
|
396
435
|
agentBranchPatterns: string[];
|
|
436
|
+
disableAgentPatternRegistry: boolean;
|
|
437
|
+
agentBranchPatternsOverride?: string[];
|
|
397
438
|
};
|
|
398
439
|
wu: {
|
|
399
440
|
idPattern: string;
|
|
@@ -477,6 +518,12 @@ export declare function validateConfig(data: unknown): z.ZodSafeParseResult<{
|
|
|
477
518
|
notes?: string;
|
|
478
519
|
};
|
|
479
520
|
};
|
|
521
|
+
experimental: {
|
|
522
|
+
context_validation: boolean;
|
|
523
|
+
validation_mode: "error" | "off" | "warn";
|
|
524
|
+
show_next_steps: boolean;
|
|
525
|
+
recovery_command: boolean;
|
|
526
|
+
};
|
|
480
527
|
}>;
|
|
481
528
|
/**
|
|
482
529
|
* Parse configuration with defaults
|
|
@@ -86,12 +86,55 @@ export const GitConfigSchema = z.object({
|
|
|
86
86
|
/** Info threshold for branch drift */
|
|
87
87
|
branchDriftInfo: z.number().int().positive().default(10),
|
|
88
88
|
/**
|
|
89
|
-
* Agent branch patterns
|
|
90
|
-
*
|
|
91
|
-
*
|
|
89
|
+
* Agent branch patterns to MERGE with the registry patterns.
|
|
90
|
+
* These patterns are merged with patterns from lumenflow.dev/registry/agent-patterns.json.
|
|
91
|
+
* Use this to add custom patterns that should work alongside the standard vendor patterns.
|
|
92
92
|
* Protected branches (mainBranch + 'master') are NEVER bypassed.
|
|
93
|
+
*
|
|
94
|
+
* WU-1089: Changed default from ['agent/*'] to [] to allow registry to be used by default.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```yaml
|
|
98
|
+
* git:
|
|
99
|
+
* agentBranchPatterns:
|
|
100
|
+
* - 'my-custom-agent/*'
|
|
101
|
+
* - 'internal-tool/*'
|
|
102
|
+
* ```
|
|
93
103
|
*/
|
|
94
|
-
agentBranchPatterns: z.array(z.string()).default([
|
|
104
|
+
agentBranchPatterns: z.array(z.string()).default([]),
|
|
105
|
+
/**
|
|
106
|
+
* Agent branch patterns that REPLACE the registry patterns entirely.
|
|
107
|
+
* When set, these patterns are used instead of fetching from the registry.
|
|
108
|
+
* The agentBranchPatterns field is ignored when this is set.
|
|
109
|
+
*
|
|
110
|
+
* Use this for strict control over which agent patterns are allowed.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```yaml
|
|
114
|
+
* git:
|
|
115
|
+
* agentBranchPatternsOverride:
|
|
116
|
+
* - 'claude/*'
|
|
117
|
+
* - 'codex/*'
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
agentBranchPatternsOverride: z.array(z.string()).optional(),
|
|
121
|
+
/**
|
|
122
|
+
* Disable fetching agent patterns from the registry (airgapped mode).
|
|
123
|
+
* When true, only uses agentBranchPatterns from config or defaults to ['agent/*'].
|
|
124
|
+
* Useful for environments without network access or strict security requirements.
|
|
125
|
+
*
|
|
126
|
+
* @default false
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```yaml
|
|
130
|
+
* git:
|
|
131
|
+
* disableAgentPatternRegistry: true
|
|
132
|
+
* agentBranchPatterns:
|
|
133
|
+
* - 'claude/*'
|
|
134
|
+
* - 'cursor/*'
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
disableAgentPatternRegistry: z.boolean().default(false),
|
|
95
138
|
});
|
|
96
139
|
/**
|
|
97
140
|
* WU (Work Unit) configuration
|
|
@@ -238,6 +281,41 @@ export const AgentsConfigSchema = z.object({
|
|
|
238
281
|
/** Project methodology defaults (agent-facing) */
|
|
239
282
|
methodology: MethodologyDefaultsSchema.default(() => MethodologyDefaultsSchema.parse({})),
|
|
240
283
|
});
|
|
284
|
+
/**
|
|
285
|
+
* Validation mode for context-aware commands
|
|
286
|
+
* WU-1090: Context-aware state machine for WU lifecycle commands
|
|
287
|
+
*/
|
|
288
|
+
export const ValidationModeSchema = z.enum(['off', 'warn', 'error']).default('warn');
|
|
289
|
+
/**
|
|
290
|
+
* Experimental features configuration
|
|
291
|
+
* WU-1090: Feature flags for gradual rollout
|
|
292
|
+
*/
|
|
293
|
+
export const ExperimentalConfigSchema = z.object({
|
|
294
|
+
/**
|
|
295
|
+
* Enable context-aware validation for wu:* commands
|
|
296
|
+
* When enabled, commands will check location, WU status, and predicates
|
|
297
|
+
* @default true
|
|
298
|
+
*/
|
|
299
|
+
context_validation: z.boolean().default(true),
|
|
300
|
+
/**
|
|
301
|
+
* Validation behavior mode
|
|
302
|
+
* - 'off': No validation (legacy behavior)
|
|
303
|
+
* - 'warn': Show warnings but proceed
|
|
304
|
+
* - 'error': Block on validation failures
|
|
305
|
+
* @default 'warn'
|
|
306
|
+
*/
|
|
307
|
+
validation_mode: ValidationModeSchema,
|
|
308
|
+
/**
|
|
309
|
+
* Show next steps guidance after successful command completion
|
|
310
|
+
* @default true
|
|
311
|
+
*/
|
|
312
|
+
show_next_steps: z.boolean().default(true),
|
|
313
|
+
/**
|
|
314
|
+
* Enable wu:recover command for state recovery
|
|
315
|
+
* @default true
|
|
316
|
+
*/
|
|
317
|
+
recovery_command: z.boolean().default(true),
|
|
318
|
+
});
|
|
241
319
|
/**
|
|
242
320
|
* Complete LumenFlow configuration schema
|
|
243
321
|
*/
|
|
@@ -262,6 +340,8 @@ export const LumenFlowConfigSchema = z.object({
|
|
|
262
340
|
yaml: YamlConfigSchema.default(() => YamlConfigSchema.parse({})),
|
|
263
341
|
/** Agents configuration */
|
|
264
342
|
agents: AgentsConfigSchema.default(() => AgentsConfigSchema.parse({})),
|
|
343
|
+
/** Experimental features (WU-1090) */
|
|
344
|
+
experimental: ExperimentalConfigSchema.default(() => ExperimentalConfigSchema.parse({})),
|
|
265
345
|
});
|
|
266
346
|
/**
|
|
267
347
|
* Validate configuration data
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Ports
|
|
3
|
+
*
|
|
4
|
+
* WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
|
|
5
|
+
*
|
|
6
|
+
* Port interfaces for context-aware validation system.
|
|
7
|
+
* These abstractions allow external users to inject custom implementations.
|
|
8
|
+
*
|
|
9
|
+
* Hexagonal Architecture - Input Ports:
|
|
10
|
+
* - ILocationResolver: Detect main checkout vs worktree
|
|
11
|
+
* - IGitStateReader: Read git branch, dirty state, ahead/behind
|
|
12
|
+
* - IWuStateReader: Read WU state from YAML and state store
|
|
13
|
+
*
|
|
14
|
+
* Current Implementations:
|
|
15
|
+
* - resolveLocation (location-resolver.ts)
|
|
16
|
+
* - readGitState (git-state-reader.ts)
|
|
17
|
+
* - readWuState (wu-state-reader.ts)
|
|
18
|
+
*
|
|
19
|
+
* @module ports/context
|
|
20
|
+
*/
|
|
21
|
+
import type { LocationContext } from '../context/location-resolver.js';
|
|
22
|
+
import type { GitState } from '../context/git-state-reader.js';
|
|
23
|
+
import type { WuStateResult } from '../context/wu-state-reader.js';
|
|
24
|
+
/**
|
|
25
|
+
* Location Resolver Port Interface
|
|
26
|
+
*
|
|
27
|
+
* Resolves the current working directory context to determine:
|
|
28
|
+
* - Whether in main checkout or a worktree
|
|
29
|
+
* - Path to main checkout
|
|
30
|
+
* - Worktree name and associated WU ID (if applicable)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Custom implementation for testing
|
|
34
|
+
* const mockResolver: ILocationResolver = {
|
|
35
|
+
* resolveLocation: async (cwd) => ({
|
|
36
|
+
* type: 'main',
|
|
37
|
+
* cwd: cwd || '/repo',
|
|
38
|
+
* gitRoot: '/repo',
|
|
39
|
+
* mainCheckout: '/repo',
|
|
40
|
+
* worktreeName: null,
|
|
41
|
+
* worktreeWuId: null,
|
|
42
|
+
* }),
|
|
43
|
+
* };
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Using default implementation
|
|
47
|
+
* import { resolveLocation } from './context/location-resolver.js';
|
|
48
|
+
* const resolver: ILocationResolver = { resolveLocation };
|
|
49
|
+
*/
|
|
50
|
+
export interface ILocationResolver {
|
|
51
|
+
/**
|
|
52
|
+
* Resolve location context for the given working directory.
|
|
53
|
+
*
|
|
54
|
+
* @param cwd - Current working directory (defaults to process.cwd())
|
|
55
|
+
* @returns Promise<LocationContext> - Resolved location context
|
|
56
|
+
*/
|
|
57
|
+
resolveLocation(cwd?: string): Promise<LocationContext>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Git State Reader Port Interface
|
|
61
|
+
*
|
|
62
|
+
* Reads the current git state including:
|
|
63
|
+
* - Current branch name
|
|
64
|
+
* - Whether HEAD is detached
|
|
65
|
+
* - Dirty working tree (uncommitted changes)
|
|
66
|
+
* - Staged changes
|
|
67
|
+
* - Commits ahead/behind tracking branch
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Custom implementation for testing
|
|
71
|
+
* const mockReader: IGitStateReader = {
|
|
72
|
+
* readGitState: async () => ({
|
|
73
|
+
* branch: 'main',
|
|
74
|
+
* isDetached: false,
|
|
75
|
+
* isDirty: false,
|
|
76
|
+
* hasStaged: false,
|
|
77
|
+
* ahead: 0,
|
|
78
|
+
* behind: 0,
|
|
79
|
+
* tracking: 'origin/main',
|
|
80
|
+
* modifiedFiles: [],
|
|
81
|
+
* hasError: false,
|
|
82
|
+
* errorMessage: null,
|
|
83
|
+
* }),
|
|
84
|
+
* };
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Using default implementation
|
|
88
|
+
* import { readGitState } from './context/git-state-reader.js';
|
|
89
|
+
* const reader: IGitStateReader = { readGitState };
|
|
90
|
+
*/
|
|
91
|
+
export interface IGitStateReader {
|
|
92
|
+
/**
|
|
93
|
+
* Read current git state for the given working directory.
|
|
94
|
+
*
|
|
95
|
+
* @param cwd - Current working directory (defaults to process.cwd())
|
|
96
|
+
* @returns Promise<GitState> - Current git state
|
|
97
|
+
*/
|
|
98
|
+
readGitState(cwd?: string): Promise<GitState>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* WU State Reader Port Interface
|
|
102
|
+
*
|
|
103
|
+
* Reads WU state from YAML file and optionally cross-references
|
|
104
|
+
* with state store for inconsistency detection.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* // Custom implementation for testing
|
|
108
|
+
* const mockReader: IWuStateReader = {
|
|
109
|
+
* readWuState: async (wuId, repoRoot) => ({
|
|
110
|
+
* id: wuId,
|
|
111
|
+
* status: 'in_progress',
|
|
112
|
+
* lane: 'Framework: Core',
|
|
113
|
+
* title: 'Test WU',
|
|
114
|
+
* yamlPath: `${repoRoot}/docs/04-operations/tasks/wu/${wuId}.yaml`,
|
|
115
|
+
* isConsistent: true,
|
|
116
|
+
* inconsistencyReason: null,
|
|
117
|
+
* }),
|
|
118
|
+
* };
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* // Using default implementation
|
|
122
|
+
* import { readWuState } from './context/wu-state-reader.js';
|
|
123
|
+
* const reader: IWuStateReader = { readWuState };
|
|
124
|
+
*/
|
|
125
|
+
export interface IWuStateReader {
|
|
126
|
+
/**
|
|
127
|
+
* Read WU state from YAML and detect inconsistencies.
|
|
128
|
+
*
|
|
129
|
+
* @param wuId - WU ID (e.g., 'WU-1093' or 'wu-1093')
|
|
130
|
+
* @param repoRoot - Repository root path
|
|
131
|
+
* @returns Promise<WuStateResult | null> - WU state or null if not found
|
|
132
|
+
*/
|
|
133
|
+
readWuState(wuId: string, repoRoot: string): Promise<WuStateResult | null>;
|
|
134
|
+
}
|
|
135
|
+
export type { LocationContext, GitState, WuStateResult };
|