specweave 0.26.2 → 0.26.4
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/CLAUDE.md +172 -1413
- package/dist/src/cli/commands/plan/plan-orchestrator.js +2 -2
- package/dist/src/cli/commands/plan/plan-orchestrator.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +147 -55
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
- package/dist/src/core/increment/completion-validator.d.ts +4 -0
- package/dist/src/core/increment/completion-validator.d.ts.map +1 -1
- package/dist/src/core/increment/completion-validator.js +36 -0
- package/dist/src/core/increment/completion-validator.js.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.js +47 -13
- package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
- package/dist/src/core/us-sync-throttle.d.ts +113 -0
- package/dist/src/core/us-sync-throttle.d.ts.map +1 -0
- package/dist/src/core/us-sync-throttle.js +195 -0
- package/dist/src/core/us-sync-throttle.js.map +1 -0
- package/dist/src/utils/external-tool-drift-detector.d.ts +76 -0
- package/dist/src/utils/external-tool-drift-detector.d.ts.map +1 -0
- package/dist/src/utils/external-tool-drift-detector.js +235 -0
- package/dist/src/utils/external-tool-drift-detector.js.map +1 -0
- package/package.json +4 -4
- package/plugins/specweave/hooks/post-task-completion.sh +6 -6
- package/plugins/specweave/hooks/pre-increment-start.sh +6 -1
- package/plugins/specweave/lib/hooks/us-completion-orchestrator.js +62 -89
- package/plugins/specweave/lib/hooks/us-completion-orchestrator.ts +215 -0
- package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
- package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
- package/plugins/specweave-release/hooks/post-task-completion.sh +5 -1
- package/plugins/specweave/agents/pm/AGENT.md.bak +0 -1893
- package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
- package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
- package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +0 -245
- package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +0 -149
- package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +0 -163
- package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
- package/plugins/specweave/hooks/post-first-increment.sh.bak +0 -61
- package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
- package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
- package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
- package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
- package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
- package/plugins/specweave/hooks/post-spec-update.sh.bak +0 -158
- package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
- package/plugins/specweave/hooks/post-user-story-complete.sh.bak +0 -179
- package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
- package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +0 -83
- package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
- package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
- package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
- package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
- package/plugins/specweave/hooks/user-prompt-submit.sh.bak +0 -386
- package/plugins/specweave/lib/hooks/auto-transition.js.bak +0 -50
- package/plugins/specweave/lib/hooks/auto-transition.ts.bak +0 -84
- package/plugins/specweave/lib/hooks/git-diff-analyzer.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/git-diff-analyzer.d.ts.bak +0 -89
- package/plugins/specweave/lib/hooks/git-diff-analyzer.js.bak +0 -142
- package/plugins/specweave/lib/hooks/git-diff-analyzer.ts.bak +0 -269
- package/plugins/specweave/lib/hooks/invoke-translator-skill.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/invoke-translator-skill.d.ts.bak +0 -60
- package/plugins/specweave/lib/hooks/invoke-translator-skill.js.bak +0 -155
- package/plugins/specweave/lib/hooks/invoke-translator-skill.ts.bak +0 -264
- package/plugins/specweave/lib/hooks/prepare-reflection-context.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/prepare-reflection-context.d.ts.bak +0 -42
- package/plugins/specweave/lib/hooks/prepare-reflection-context.js.bak +0 -110
- package/plugins/specweave/lib/hooks/prepare-reflection-context.ts.bak +0 -178
- package/plugins/specweave/lib/hooks/reflection-config-loader.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/reflection-config-loader.d.ts.bak +0 -45
- package/plugins/specweave/lib/hooks/reflection-config-loader.js.bak +0 -92
- package/plugins/specweave/lib/hooks/reflection-config-loader.ts.bak +0 -156
- package/plugins/specweave/lib/hooks/reflection-parser.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/reflection-parser.d.ts.bak +0 -33
- package/plugins/specweave/lib/hooks/reflection-parser.js.bak +0 -301
- package/plugins/specweave/lib/hooks/reflection-parser.ts.bak +0 -484
- package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.ts.bak +0 -56
- package/plugins/specweave/lib/hooks/reflection-prompt-builder.js.bak +0 -182
- package/plugins/specweave/lib/hooks/reflection-prompt-builder.ts.bak +0 -306
- package/plugins/specweave/lib/hooks/reflection-storage.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/reflection-storage.d.ts.bak +0 -64
- package/plugins/specweave/lib/hooks/reflection-storage.js.bak +0 -231
- package/plugins/specweave/lib/hooks/reflection-storage.ts.bak +0 -369
- package/plugins/specweave/lib/hooks/run-self-reflection.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/run-self-reflection.d.ts.bak +0 -43
- package/plugins/specweave/lib/hooks/run-self-reflection.js.bak +0 -132
- package/plugins/specweave/lib/hooks/run-self-reflection.ts.bak +0 -258
- package/plugins/specweave/lib/hooks/sync-cache.js.bak +0 -294
- package/plugins/specweave/lib/hooks/sync-living-docs.d.js.bak +0 -1
- package/plugins/specweave/lib/hooks/sync-living-docs.d.ts.bak +0 -27
- package/plugins/specweave/lib/hooks/sync-living-docs.js.bak +0 -339
- package/plugins/specweave/lib/hooks/sync-us-tasks.js.bak +0 -476
- package/plugins/specweave/lib/hooks/translate-file.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/translate-file.d.ts.bak +0 -59
- package/plugins/specweave/lib/hooks/translate-file.js.bak +0 -289
- package/plugins/specweave/lib/hooks/translate-file.ts.bak +0 -428
- package/plugins/specweave/lib/hooks/translate-living-docs.d.js.bak +0 -0
- package/plugins/specweave/lib/hooks/translate-living-docs.d.ts.bak +0 -13
- package/plugins/specweave/lib/hooks/translate-living-docs.js.bak +0 -119
- package/plugins/specweave/lib/hooks/translate-living-docs.ts.bak +0 -224
- package/plugins/specweave/lib/hooks/update-ac-status.js.bak +0 -51
- package/plugins/specweave/lib/hooks/update-ac-status.ts.bak +0 -103
- package/plugins/specweave/lib/hooks/update-tasks-md.d.js.bak +0 -1
- package/plugins/specweave/lib/hooks/update-tasks-md.d.ts.bak +0 -29
- package/plugins/specweave/lib/hooks/update-tasks-md.js.bak +0 -296
- package/plugins/specweave/lib/hooks/update-tasks-md.ts.bak +0 -489
- package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
- package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
- package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
- package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -904
- package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
- package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -738
- package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { DEFAULT_REFLECTION_CONFIG } from "./types/reflection-types";
|
|
4
|
-
function findSpecweaveRoot(startDir = process.cwd()) {
|
|
5
|
-
let currentDir = startDir;
|
|
6
|
-
const root = path.parse(currentDir).root;
|
|
7
|
-
while (currentDir !== root) {
|
|
8
|
-
const specweavePath = path.join(currentDir, ".specweave");
|
|
9
|
-
if (fs.existsSync(specweavePath)) {
|
|
10
|
-
return currentDir;
|
|
11
|
-
}
|
|
12
|
-
currentDir = path.dirname(currentDir);
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
function loadReflectionConfig(projectRoot) {
|
|
17
|
-
const rootDir = projectRoot || findSpecweaveRoot();
|
|
18
|
-
if (!rootDir) {
|
|
19
|
-
return { ...DEFAULT_REFLECTION_CONFIG };
|
|
20
|
-
}
|
|
21
|
-
const configPath = path.join(rootDir, ".specweave", "config.json");
|
|
22
|
-
if (!fs.existsSync(configPath)) {
|
|
23
|
-
return { ...DEFAULT_REFLECTION_CONFIG };
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
27
|
-
const config = JSON.parse(configContent);
|
|
28
|
-
const userReflectionConfig = config.reflection || {};
|
|
29
|
-
const mergedConfig = {
|
|
30
|
-
enabled: userReflectionConfig.enabled ?? DEFAULT_REFLECTION_CONFIG.enabled,
|
|
31
|
-
mode: userReflectionConfig.mode ?? DEFAULT_REFLECTION_CONFIG.mode,
|
|
32
|
-
depth: userReflectionConfig.depth ?? DEFAULT_REFLECTION_CONFIG.depth,
|
|
33
|
-
model: userReflectionConfig.model ?? DEFAULT_REFLECTION_CONFIG.model,
|
|
34
|
-
categories: {
|
|
35
|
-
security: userReflectionConfig.categories?.security ?? DEFAULT_REFLECTION_CONFIG.categories.security,
|
|
36
|
-
quality: userReflectionConfig.categories?.quality ?? DEFAULT_REFLECTION_CONFIG.categories.quality,
|
|
37
|
-
testing: userReflectionConfig.categories?.testing ?? DEFAULT_REFLECTION_CONFIG.categories.testing,
|
|
38
|
-
performance: userReflectionConfig.categories?.performance ?? DEFAULT_REFLECTION_CONFIG.categories.performance,
|
|
39
|
-
technicalDebt: userReflectionConfig.categories?.technicalDebt ?? DEFAULT_REFLECTION_CONFIG.categories.technicalDebt
|
|
40
|
-
},
|
|
41
|
-
criticalThreshold: userReflectionConfig.criticalThreshold ?? DEFAULT_REFLECTION_CONFIG.criticalThreshold,
|
|
42
|
-
storeReflections: userReflectionConfig.storeReflections ?? DEFAULT_REFLECTION_CONFIG.storeReflections,
|
|
43
|
-
autoCreateFollowUpTasks: userReflectionConfig.autoCreateFollowUpTasks ?? DEFAULT_REFLECTION_CONFIG.autoCreateFollowUpTasks,
|
|
44
|
-
soundNotifications: userReflectionConfig.soundNotifications ?? DEFAULT_REFLECTION_CONFIG.soundNotifications
|
|
45
|
-
};
|
|
46
|
-
return mergedConfig;
|
|
47
|
-
} catch (error) {
|
|
48
|
-
if (error instanceof SyntaxError) {
|
|
49
|
-
throw new Error(`Invalid JSON in config file: ${configPath}. ${error.message}`);
|
|
50
|
-
}
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function validateReflectionConfig(config) {
|
|
55
|
-
const errors = [];
|
|
56
|
-
if (config.enabled && config.mode !== "disabled") {
|
|
57
|
-
const hasEnabledCategory = Object.values(config.categories).some((enabled) => enabled);
|
|
58
|
-
if (!hasEnabledCategory) {
|
|
59
|
-
errors.push("At least one analysis category must be enabled when reflection is active");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (!config.enabled && config.mode === "auto") {
|
|
63
|
-
errors.push('Reflection mode cannot be "auto" when reflection is disabled');
|
|
64
|
-
}
|
|
65
|
-
if (config.soundNotifications && !config.enabled) {
|
|
66
|
-
errors.push("Sound notifications require reflection to be enabled");
|
|
67
|
-
}
|
|
68
|
-
if (config.autoCreateFollowUpTasks && !config.storeReflections) {
|
|
69
|
-
errors.push("Auto-create follow-up tasks requires storeReflections to be enabled");
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
valid: errors.length === 0,
|
|
73
|
-
errors
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function loadAndValidateReflectionConfig(projectRoot) {
|
|
77
|
-
const config = loadReflectionConfig(projectRoot);
|
|
78
|
-
const validation = validateReflectionConfig(config);
|
|
79
|
-
if (!validation.valid) {
|
|
80
|
-
throw new Error(
|
|
81
|
-
`Invalid reflection configuration:
|
|
82
|
-
${validation.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return config;
|
|
86
|
-
}
|
|
87
|
-
export {
|
|
88
|
-
findSpecweaveRoot,
|
|
89
|
-
loadAndValidateReflectionConfig,
|
|
90
|
-
loadReflectionConfig,
|
|
91
|
-
validateReflectionConfig
|
|
92
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reflection Configuration Loader
|
|
3
|
-
*
|
|
4
|
-
* Loads and validates reflection configuration from .specweave/config.json
|
|
5
|
-
* Merges user config with defaults, validates against schema
|
|
6
|
-
*
|
|
7
|
-
* @module reflection-config-loader
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import fs from 'fs-extra';
|
|
11
|
-
import path from 'path';
|
|
12
|
-
import { DEFAULT_REFLECTION_CONFIG, ReflectionConfig } from './types/reflection-types';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Find .specweave directory by traversing up from current directory
|
|
16
|
-
* @param startDir Starting directory (defaults to cwd)
|
|
17
|
-
* @returns Path to .specweave directory or null if not found
|
|
18
|
-
*/
|
|
19
|
-
export function findSpecweaveRoot(startDir: string = process.cwd()): string | null {
|
|
20
|
-
let currentDir = startDir;
|
|
21
|
-
const root = path.parse(currentDir).root;
|
|
22
|
-
|
|
23
|
-
while (currentDir !== root) {
|
|
24
|
-
const specweavePath = path.join(currentDir, '.specweave');
|
|
25
|
-
if (fs.existsSync(specweavePath)) {
|
|
26
|
-
return currentDir;
|
|
27
|
-
}
|
|
28
|
-
currentDir = path.dirname(currentDir);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Load reflection configuration from .specweave/config.json
|
|
36
|
-
* Falls back to defaults if config file doesn't exist or reflection section is missing
|
|
37
|
-
*
|
|
38
|
-
* @param projectRoot Path to project root (optional, auto-detected if not provided)
|
|
39
|
-
* @returns Merged reflection configuration
|
|
40
|
-
* @throws Error if config file exists but has invalid JSON
|
|
41
|
-
*/
|
|
42
|
-
export function loadReflectionConfig(projectRoot?: string): ReflectionConfig {
|
|
43
|
-
// Auto-detect project root if not provided
|
|
44
|
-
const rootDir = projectRoot || findSpecweaveRoot();
|
|
45
|
-
|
|
46
|
-
if (!rootDir) {
|
|
47
|
-
// No .specweave directory found, return defaults
|
|
48
|
-
return { ...DEFAULT_REFLECTION_CONFIG };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const configPath = path.join(rootDir, '.specweave', 'config.json');
|
|
52
|
-
|
|
53
|
-
// Config file doesn't exist, return defaults
|
|
54
|
-
if (!fs.existsSync(configPath)) {
|
|
55
|
-
return { ...DEFAULT_REFLECTION_CONFIG };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
// Read and parse config file
|
|
60
|
-
const configContent = fs.readFileSync(configPath, 'utf-8');
|
|
61
|
-
const config = JSON.parse(configContent);
|
|
62
|
-
|
|
63
|
-
// Extract reflection section (may be undefined)
|
|
64
|
-
const userReflectionConfig = config.reflection || {};
|
|
65
|
-
|
|
66
|
-
// Deep merge with defaults (user config overrides defaults)
|
|
67
|
-
const mergedConfig: ReflectionConfig = {
|
|
68
|
-
enabled: userReflectionConfig.enabled ?? DEFAULT_REFLECTION_CONFIG.enabled,
|
|
69
|
-
mode: userReflectionConfig.mode ?? DEFAULT_REFLECTION_CONFIG.mode,
|
|
70
|
-
depth: userReflectionConfig.depth ?? DEFAULT_REFLECTION_CONFIG.depth,
|
|
71
|
-
model: userReflectionConfig.model ?? DEFAULT_REFLECTION_CONFIG.model,
|
|
72
|
-
categories: {
|
|
73
|
-
security: userReflectionConfig.categories?.security ?? DEFAULT_REFLECTION_CONFIG.categories.security,
|
|
74
|
-
quality: userReflectionConfig.categories?.quality ?? DEFAULT_REFLECTION_CONFIG.categories.quality,
|
|
75
|
-
testing: userReflectionConfig.categories?.testing ?? DEFAULT_REFLECTION_CONFIG.categories.testing,
|
|
76
|
-
performance: userReflectionConfig.categories?.performance ?? DEFAULT_REFLECTION_CONFIG.categories.performance,
|
|
77
|
-
technicalDebt: userReflectionConfig.categories?.technicalDebt ?? DEFAULT_REFLECTION_CONFIG.categories.technicalDebt,
|
|
78
|
-
},
|
|
79
|
-
criticalThreshold: userReflectionConfig.criticalThreshold ?? DEFAULT_REFLECTION_CONFIG.criticalThreshold,
|
|
80
|
-
storeReflections: userReflectionConfig.storeReflections ?? DEFAULT_REFLECTION_CONFIG.storeReflections,
|
|
81
|
-
autoCreateFollowUpTasks: userReflectionConfig.autoCreateFollowUpTasks ?? DEFAULT_REFLECTION_CONFIG.autoCreateFollowUpTasks,
|
|
82
|
-
soundNotifications: userReflectionConfig.soundNotifications ?? DEFAULT_REFLECTION_CONFIG.soundNotifications,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
return mergedConfig;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
// Invalid JSON or other error
|
|
88
|
-
if (error instanceof SyntaxError) {
|
|
89
|
-
throw new Error(`Invalid JSON in config file: ${configPath}. ${error.message}`);
|
|
90
|
-
}
|
|
91
|
-
throw error;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Validate reflection configuration against constraints
|
|
97
|
-
* Checks for logical inconsistencies (e.g., all categories disabled)
|
|
98
|
-
*
|
|
99
|
-
* @param config Reflection configuration to validate
|
|
100
|
-
* @returns Validation result with errors array
|
|
101
|
-
*/
|
|
102
|
-
export function validateReflectionConfig(config: ReflectionConfig): {
|
|
103
|
-
valid: boolean;
|
|
104
|
-
errors: string[];
|
|
105
|
-
} {
|
|
106
|
-
const errors: string[] = [];
|
|
107
|
-
|
|
108
|
-
// Check: If reflection enabled, at least one category must be enabled
|
|
109
|
-
if (config.enabled && config.mode !== 'disabled') {
|
|
110
|
-
const hasEnabledCategory = Object.values(config.categories).some(enabled => enabled);
|
|
111
|
-
if (!hasEnabledCategory) {
|
|
112
|
-
errors.push('At least one analysis category must be enabled when reflection is active');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Check: Mode cannot be 'auto' if reflection is disabled
|
|
117
|
-
if (!config.enabled && config.mode === 'auto') {
|
|
118
|
-
errors.push('Reflection mode cannot be "auto" when reflection is disabled');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Check: Sound notifications require reflection to be enabled
|
|
122
|
-
if (config.soundNotifications && !config.enabled) {
|
|
123
|
-
errors.push('Sound notifications require reflection to be enabled');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Check: Auto-create follow-up tasks requires storeReflections
|
|
127
|
-
if (config.autoCreateFollowUpTasks && !config.storeReflections) {
|
|
128
|
-
errors.push('Auto-create follow-up tasks requires storeReflections to be enabled');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
valid: errors.length === 0,
|
|
133
|
-
errors
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Load and validate reflection configuration
|
|
139
|
-
* Throws error if configuration is invalid
|
|
140
|
-
*
|
|
141
|
-
* @param projectRoot Path to project root (optional, auto-detected if not provided)
|
|
142
|
-
* @returns Valid reflection configuration
|
|
143
|
-
* @throws Error if configuration is invalid
|
|
144
|
-
*/
|
|
145
|
-
export function loadAndValidateReflectionConfig(projectRoot?: string): ReflectionConfig {
|
|
146
|
-
const config = loadReflectionConfig(projectRoot);
|
|
147
|
-
const validation = validateReflectionConfig(config);
|
|
148
|
-
|
|
149
|
-
if (!validation.valid) {
|
|
150
|
-
throw new Error(
|
|
151
|
-
`Invalid reflection configuration:\n${validation.errors.map(e => ` - ${e}`).join('\n')}`
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return config;
|
|
156
|
-
}
|
|
File without changes
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reflection Parser
|
|
3
|
-
*
|
|
4
|
-
* Parses markdown output from reflective-reviewer agent
|
|
5
|
-
* Extracts structured data (issues, metrics, lessons learned, etc.)
|
|
6
|
-
*
|
|
7
|
-
* @module reflection-parser
|
|
8
|
-
*/
|
|
9
|
-
import { ReflectionResult, ReflectionModel } from './types/reflection-types';
|
|
10
|
-
/**
|
|
11
|
-
* Parse complete reflection result from markdown
|
|
12
|
-
* Main parsing function
|
|
13
|
-
*
|
|
14
|
-
* @param markdown Reflection markdown from reflective-reviewer agent
|
|
15
|
-
* @param taskName Task name for result
|
|
16
|
-
* @param model Model used for reflection
|
|
17
|
-
* @param reflectionTime Time taken in seconds
|
|
18
|
-
* @param estimatedCost Estimated cost in USD
|
|
19
|
-
* @returns Complete ReflectionResult object
|
|
20
|
-
*/
|
|
21
|
-
export declare function parseReflectionMarkdown(markdown: string, taskName: string, model?: ReflectionModel, reflectionTime?: number, estimatedCost?: number): ReflectionResult;
|
|
22
|
-
/**
|
|
23
|
-
* Validate parsed reflection result
|
|
24
|
-
* Checks for required fields and data quality
|
|
25
|
-
*
|
|
26
|
-
* @param result Parsed reflection result
|
|
27
|
-
* @returns Validation result with errors
|
|
28
|
-
*/
|
|
29
|
-
export declare function validateReflectionResult(result: ReflectionResult): {
|
|
30
|
-
valid: boolean;
|
|
31
|
-
errors: string[];
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=reflection-parser.d.ts.map
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IssueSeverity,
|
|
3
|
-
IssueCategory,
|
|
4
|
-
ReflectionModel
|
|
5
|
-
} from "./types/reflection-types";
|
|
6
|
-
function extractSection(markdown, heading) {
|
|
7
|
-
const headingRegex = new RegExp(`^${heading}\\s*$`, "mi");
|
|
8
|
-
const match = markdown.match(headingRegex);
|
|
9
|
-
if (!match || match.index === void 0) {
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
const startIndex = match.index + match[0].length;
|
|
13
|
-
const afterHeading = markdown.slice(startIndex);
|
|
14
|
-
const nextHeadingMatch = afterHeading.match(/^#{1,3}\s+/m);
|
|
15
|
-
const endIndex = nextHeadingMatch?.index ?? afterHeading.length;
|
|
16
|
-
return afterHeading.slice(0, endIndex).trim();
|
|
17
|
-
}
|
|
18
|
-
function parseAccomplishments(markdown) {
|
|
19
|
-
const section = extractSection(markdown, "## \u2705 What Was Accomplished");
|
|
20
|
-
if (!section) return [];
|
|
21
|
-
const lines = section.split("\n").filter((line) => line.trim());
|
|
22
|
-
const accomplishments = [];
|
|
23
|
-
for (const line of lines) {
|
|
24
|
-
const trimmed = line.trim();
|
|
25
|
-
if (/^[-*+]\s+/.test(trimmed) || /^\d+\.\s+/.test(trimmed)) {
|
|
26
|
-
accomplishments.push(trimmed.replace(/^[-*+\d.]\s+/, "").trim());
|
|
27
|
-
} else if (trimmed.length > 10 && !trimmed.startsWith("#")) {
|
|
28
|
-
accomplishments.push(trimmed);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return accomplishments;
|
|
32
|
-
}
|
|
33
|
-
function parseStrengths(markdown) {
|
|
34
|
-
const section = extractSection(markdown, "### \u2705 Strengths");
|
|
35
|
-
if (!section) return [];
|
|
36
|
-
const lines = section.split("\n").filter((line) => line.trim());
|
|
37
|
-
const strengths = [];
|
|
38
|
-
for (const line of lines) {
|
|
39
|
-
const trimmed = line.trim();
|
|
40
|
-
if (trimmed.startsWith("- \u2705") || trimmed.startsWith("\u2705")) {
|
|
41
|
-
strengths.push(trimmed.replace(/^[-*+]?\s*✅\s*/, "").trim());
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return strengths;
|
|
45
|
-
}
|
|
46
|
-
function parseSeverity(text) {
|
|
47
|
-
if (/CRITICAL/i.test(text)) return IssueSeverity.CRITICAL;
|
|
48
|
-
if (/HIGH/i.test(text)) return IssueSeverity.HIGH;
|
|
49
|
-
if (/MEDIUM/i.test(text)) return IssueSeverity.MEDIUM;
|
|
50
|
-
if (/LOW/i.test(text)) return IssueSeverity.LOW;
|
|
51
|
-
return void 0;
|
|
52
|
-
}
|
|
53
|
-
function parseCategory(text) {
|
|
54
|
-
if (/SECURITY/i.test(text)) return IssueCategory.SECURITY;
|
|
55
|
-
if (/QUALITY/i.test(text)) return IssueCategory.QUALITY;
|
|
56
|
-
if (/TESTING/i.test(text)) return IssueCategory.TESTING;
|
|
57
|
-
if (/PERFORMANCE/i.test(text)) return IssueCategory.PERFORMANCE;
|
|
58
|
-
if (/TECHNICAL[_\s]DEBT/i.test(text)) return IssueCategory.TECHNICAL_DEBT;
|
|
59
|
-
return void 0;
|
|
60
|
-
}
|
|
61
|
-
function parseLocation(text) {
|
|
62
|
-
const locationMatch = text.match(/\*\*Location\*\*:\s*`([^`]+)`/i);
|
|
63
|
-
if (!locationMatch) return void 0;
|
|
64
|
-
const locationStr = locationMatch[1];
|
|
65
|
-
const [file, lineStr] = locationStr.split(":");
|
|
66
|
-
const line = lineStr ? parseInt(lineStr, 10) : void 0;
|
|
67
|
-
return {
|
|
68
|
-
file: file.trim(),
|
|
69
|
-
line
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function parseIssues(markdown) {
|
|
73
|
-
const section = extractSection(markdown, "### \u26A0\uFE0F Issues Identified");
|
|
74
|
-
if (!section) return [];
|
|
75
|
-
const issues = [];
|
|
76
|
-
const lines = section.split("\n");
|
|
77
|
-
let currentIssue = null;
|
|
78
|
-
let currentField = null;
|
|
79
|
-
for (const line of lines) {
|
|
80
|
-
const trimmed = line.trim();
|
|
81
|
-
const headerMatch = trimmed.match(/^\*\*(CRITICAL|HIGH|MEDIUM|LOW)\s*\(([^)]+)\)\*\*/i);
|
|
82
|
-
if (headerMatch) {
|
|
83
|
-
if (currentIssue && currentIssue.severity && currentIssue.category && currentIssue.description) {
|
|
84
|
-
issues.push(currentIssue);
|
|
85
|
-
}
|
|
86
|
-
currentIssue = {
|
|
87
|
-
severity: parseSeverity(headerMatch[1]),
|
|
88
|
-
category: parseCategory(headerMatch[2]),
|
|
89
|
-
description: "",
|
|
90
|
-
impact: "",
|
|
91
|
-
recommendation: ""
|
|
92
|
-
};
|
|
93
|
-
currentField = null;
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if ((trimmed.startsWith("- \u274C") || trimmed.startsWith("\u274C") || trimmed.startsWith("- \u26A0\uFE0F")) && currentIssue) {
|
|
97
|
-
currentField = "description";
|
|
98
|
-
const descText = trimmed.replace(/^[-*+]?\s*[❌⚠️]\s*/, "").trim();
|
|
99
|
-
currentIssue.description = descText;
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (trimmed.startsWith("- **Impact**:") || trimmed.startsWith("**Impact**:")) {
|
|
103
|
-
currentField = "impact";
|
|
104
|
-
const impactText = trimmed.replace(/^[-*+]?\s*\*\*Impact\*\*:\s*/, "").trim();
|
|
105
|
-
if (currentIssue) currentIssue.impact = impactText;
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (trimmed.startsWith("- **Recommendation**:") || trimmed.startsWith("**Recommendation**:")) {
|
|
109
|
-
currentField = "recommendation";
|
|
110
|
-
const recText = trimmed.replace(/^[-*+]?\s*\*\*Recommendation\*\*:\s*/, "").trim();
|
|
111
|
-
if (currentIssue) currentIssue.recommendation = recText;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (trimmed.startsWith("- **Location**:") || trimmed.startsWith("**Location**:")) {
|
|
115
|
-
if (currentIssue) {
|
|
116
|
-
const location = parseLocation(trimmed);
|
|
117
|
-
if (location) currentIssue.location = location;
|
|
118
|
-
}
|
|
119
|
-
currentField = null;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (currentField && currentIssue && trimmed && !trimmed.startsWith("#")) {
|
|
123
|
-
const fieldValue = currentIssue[currentField] || "";
|
|
124
|
-
currentIssue[currentField] = fieldValue + " " + trimmed;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (currentIssue && currentIssue.severity && currentIssue.category && currentIssue.description) {
|
|
128
|
-
issues.push(currentIssue);
|
|
129
|
-
}
|
|
130
|
-
return issues;
|
|
131
|
-
}
|
|
132
|
-
function parseRecommendedActions(markdown) {
|
|
133
|
-
const section = extractSection(markdown, "## \u{1F527} Recommended Follow-Up Actions");
|
|
134
|
-
const actions = {
|
|
135
|
-
priority1: [],
|
|
136
|
-
priority2: [],
|
|
137
|
-
priority3: []
|
|
138
|
-
};
|
|
139
|
-
if (!section) return actions;
|
|
140
|
-
const lines = section.split("\n");
|
|
141
|
-
let currentPriority = null;
|
|
142
|
-
for (const line of lines) {
|
|
143
|
-
const trimmed = line.trim();
|
|
144
|
-
if (/Priority 1|MUST FIX/i.test(trimmed)) {
|
|
145
|
-
currentPriority = "priority1";
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (/Priority 2|SHOULD FIX/i.test(trimmed)) {
|
|
149
|
-
currentPriority = "priority2";
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (/Priority 3|NICE TO HAVE/i.test(trimmed)) {
|
|
153
|
-
currentPriority = "priority3";
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (currentPriority && (/^\d+\.\s/.test(trimmed) || /^[-*+]\s/.test(trimmed))) {
|
|
157
|
-
const actionText = trimmed.replace(/^(\d+\.|-|\*|\+)\s+/, "").trim();
|
|
158
|
-
if (actionText.length > 0) {
|
|
159
|
-
actions[currentPriority].push(actionText);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return actions;
|
|
164
|
-
}
|
|
165
|
-
function parseLessonsLearned(markdown) {
|
|
166
|
-
const section = extractSection(markdown, "## \u{1F4DA} Lessons Learned");
|
|
167
|
-
const lessons = {
|
|
168
|
-
whatWentWell: [],
|
|
169
|
-
whatCouldImprove: [],
|
|
170
|
-
forNextTime: []
|
|
171
|
-
};
|
|
172
|
-
if (!section) return lessons;
|
|
173
|
-
const lines = section.split("\n");
|
|
174
|
-
let currentCategory = null;
|
|
175
|
-
for (const line of lines) {
|
|
176
|
-
const trimmed = line.trim();
|
|
177
|
-
if (/What went well/i.test(trimmed)) {
|
|
178
|
-
currentCategory = "whatWentWell";
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
if (/What could improve/i.test(trimmed)) {
|
|
182
|
-
currentCategory = "whatCouldImprove";
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
if (/For next time/i.test(trimmed)) {
|
|
186
|
-
currentCategory = "forNextTime";
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
if (currentCategory && /^[-*+]\s/.test(trimmed)) {
|
|
190
|
-
const text = trimmed.replace(/^[-*+]\s+/, "").trim();
|
|
191
|
-
if (text.length > 0) {
|
|
192
|
-
lessons[currentCategory].push(text);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return lessons;
|
|
197
|
-
}
|
|
198
|
-
function parseMetrics(markdown) {
|
|
199
|
-
const section = extractSection(markdown, "## \u{1F4CA} Metrics");
|
|
200
|
-
const metrics = {
|
|
201
|
-
codeQuality: 5,
|
|
202
|
-
security: 5,
|
|
203
|
-
testCoverage: void 0,
|
|
204
|
-
technicalDebt: "MEDIUM",
|
|
205
|
-
performance: "ACCEPTABLE"
|
|
206
|
-
};
|
|
207
|
-
if (!section) return metrics;
|
|
208
|
-
const qualityMatch = section.match(/Code Quality.*?(\d+)/i);
|
|
209
|
-
if (qualityMatch) {
|
|
210
|
-
metrics.codeQuality = parseInt(qualityMatch[1], 10);
|
|
211
|
-
}
|
|
212
|
-
const securityMatch = section.match(/Security.*?(\d+)/i);
|
|
213
|
-
if (securityMatch) {
|
|
214
|
-
metrics.security = parseInt(securityMatch[1], 10);
|
|
215
|
-
}
|
|
216
|
-
const coverageMatch = section.match(/Test Coverage.*?(\d+)%/i);
|
|
217
|
-
if (coverageMatch) {
|
|
218
|
-
metrics.testCoverage = parseInt(coverageMatch[1], 10);
|
|
219
|
-
}
|
|
220
|
-
const debtMatch = section.match(/Technical Debt.*?(LOW|MEDIUM|HIGH)/i);
|
|
221
|
-
if (debtMatch) {
|
|
222
|
-
metrics.technicalDebt = debtMatch[1].toUpperCase();
|
|
223
|
-
}
|
|
224
|
-
const perfMatch = section.match(/Performance.*?(GOOD|ACCEPTABLE|NEEDS[\s_]WORK)/i);
|
|
225
|
-
if (perfMatch) {
|
|
226
|
-
metrics.performance = perfMatch[1].toUpperCase().replace(/[\s_]/g, "_");
|
|
227
|
-
}
|
|
228
|
-
return metrics;
|
|
229
|
-
}
|
|
230
|
-
function parseReflectionMarkdown(markdown, taskName, model = ReflectionModel.HAIKU, reflectionTime = 0, estimatedCost = 0) {
|
|
231
|
-
const result = {
|
|
232
|
-
taskName,
|
|
233
|
-
completed: (/* @__PURE__ */ new Date()).toISOString(),
|
|
234
|
-
duration: reflectionTime > 0 ? `${reflectionTime}s` : void 0,
|
|
235
|
-
filesModified: {
|
|
236
|
-
count: 0,
|
|
237
|
-
linesAdded: 0,
|
|
238
|
-
linesRemoved: 0
|
|
239
|
-
},
|
|
240
|
-
accomplishments: parseAccomplishments(markdown),
|
|
241
|
-
strengths: parseStrengths(markdown),
|
|
242
|
-
issues: parseIssues(markdown),
|
|
243
|
-
recommendedActions: parseRecommendedActions(markdown),
|
|
244
|
-
lessonsLearned: parseLessonsLearned(markdown),
|
|
245
|
-
metrics: parseMetrics(markdown),
|
|
246
|
-
metadata: {
|
|
247
|
-
model,
|
|
248
|
-
reflectionTime,
|
|
249
|
-
estimatedCost
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
const filesChangedMatch = markdown.match(/\*\*Files Modified\*\*:\s*(\d+)\s*files?,\s*\+(\d+)\s*-(\d+)/i);
|
|
253
|
-
if (filesChangedMatch) {
|
|
254
|
-
result.filesModified = {
|
|
255
|
-
count: parseInt(filesChangedMatch[1], 10),
|
|
256
|
-
linesAdded: parseInt(filesChangedMatch[2], 10),
|
|
257
|
-
linesRemoved: parseInt(filesChangedMatch[3], 10)
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
return result;
|
|
261
|
-
}
|
|
262
|
-
function validateReflectionResult(result) {
|
|
263
|
-
const errors = [];
|
|
264
|
-
if (!result.taskName) {
|
|
265
|
-
errors.push("Missing task name");
|
|
266
|
-
}
|
|
267
|
-
if (!result.completed) {
|
|
268
|
-
errors.push("Missing completion timestamp");
|
|
269
|
-
}
|
|
270
|
-
if (result.accomplishments.length === 0 && result.strengths.length === 0) {
|
|
271
|
-
errors.push("No accomplishments or strengths identified (reflection too sparse)");
|
|
272
|
-
}
|
|
273
|
-
if (result.metrics.codeQuality < 1 || result.metrics.codeQuality > 10) {
|
|
274
|
-
errors.push("Code quality must be 1-10");
|
|
275
|
-
}
|
|
276
|
-
if (result.metrics.security < 1 || result.metrics.security > 10) {
|
|
277
|
-
errors.push("Security must be 1-10");
|
|
278
|
-
}
|
|
279
|
-
if (result.metrics.testCoverage !== void 0 && (result.metrics.testCoverage < 0 || result.metrics.testCoverage > 100)) {
|
|
280
|
-
errors.push("Test coverage must be 0-100%");
|
|
281
|
-
}
|
|
282
|
-
for (const issue of result.issues) {
|
|
283
|
-
if (!issue.description) {
|
|
284
|
-
errors.push("Issue missing description");
|
|
285
|
-
}
|
|
286
|
-
if (!issue.impact) {
|
|
287
|
-
errors.push("Issue missing impact explanation");
|
|
288
|
-
}
|
|
289
|
-
if (!issue.recommendation) {
|
|
290
|
-
errors.push("Issue missing recommendation");
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return {
|
|
294
|
-
valid: errors.length === 0,
|
|
295
|
-
errors
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
export {
|
|
299
|
-
parseReflectionMarkdown,
|
|
300
|
-
validateReflectionResult
|
|
301
|
-
};
|