specweave 0.21.3 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +409 -6
- package/README.md +38 -8
- package/bin/specweave.js +5 -8
- package/dist/plugins/specweave-github/lib/CodeValidator.d.ts +101 -0
- package/dist/plugins/specweave-github/lib/CodeValidator.d.ts.map +1 -0
- package/dist/plugins/specweave-github/lib/CodeValidator.js +219 -0
- package/dist/plugins/specweave-github/lib/CodeValidator.js.map +1 -0
- package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.d.ts +182 -0
- package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.d.ts.map +1 -0
- package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.js +603 -0
- package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.js.map +1 -0
- package/dist/plugins/specweave-github/lib/github-client-v2.d.ts +10 -0
- package/dist/plugins/specweave-github/lib/github-client-v2.d.ts.map +1 -1
- package/dist/plugins/specweave-github/lib/github-client-v2.js +26 -0
- package/dist/plugins/specweave-github/lib/github-client-v2.js.map +1 -1
- package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
- package/dist/plugins/specweave-github/lib/task-sync.js +7 -0
- package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
- package/dist/plugins/specweave-github/lib/types.d.ts +34 -0
- package/dist/plugins/specweave-github/lib/types.d.ts.map +1 -1
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +60 -5
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/migrate-to-profiles.d.ts +1 -0
- package/dist/src/cli/commands/migrate-to-profiles.d.ts.map +1 -1
- package/dist/src/cli/commands/migrate-to-profiles.js +12 -1
- package/dist/src/cli/commands/migrate-to-profiles.js.map +1 -1
- package/dist/src/cli/commands/next-command.d.ts +52 -0
- package/dist/src/cli/commands/next-command.d.ts.map +1 -0
- package/dist/src/cli/commands/next-command.js +204 -0
- package/dist/src/cli/commands/next-command.js.map +1 -0
- package/dist/src/cli/commands/sync-specs.d.ts +16 -0
- package/dist/src/cli/commands/sync-specs.d.ts.map +1 -0
- package/dist/src/cli/commands/sync-specs.js +130 -0
- package/dist/src/cli/commands/sync-specs.js.map +1 -0
- package/dist/src/cli/count-tasks.d.ts +20 -0
- package/dist/src/cli/count-tasks.d.ts.map +1 -0
- package/dist/src/cli/count-tasks.js +50 -0
- package/dist/src/cli/count-tasks.js.map +1 -0
- package/dist/src/config/ConfigManager.d.ts.map +1 -1
- package/dist/src/config/ConfigManager.js +2 -1
- package/dist/src/config/ConfigManager.js.map +1 -1
- package/dist/src/config/types.d.ts +58 -58
- package/dist/src/core/cicd/state-manager.d.ts +8 -0
- package/dist/src/core/cicd/state-manager.d.ts.map +1 -1
- package/dist/src/core/cicd/state-manager.js +60 -15
- package/dist/src/core/cicd/state-manager.js.map +1 -1
- package/dist/src/core/cost-tracker.d.ts.map +1 -1
- package/dist/src/core/cost-tracker.js +2 -1
- package/dist/src/core/cost-tracker.js.map +1 -1
- package/dist/src/core/iac/template-engine.d.ts.map +1 -1
- package/dist/src/core/iac/template-engine.js +28 -0
- package/dist/src/core/iac/template-engine.js.map +1 -1
- package/dist/src/core/iac/template-generator.d.ts +53 -0
- package/dist/src/core/iac/template-generator.d.ts.map +1 -0
- package/dist/src/core/iac/template-generator.js +125 -0
- package/dist/src/core/iac/template-generator.js.map +1 -0
- package/dist/src/core/increment/status-auto-transition.js +3 -3
- package/dist/src/core/increment/status-auto-transition.js.map +1 -1
- package/dist/src/core/living-docs/CodeValidator.js +1 -1
- package/dist/src/core/living-docs/CodeValidator.js.map +1 -1
- package/dist/src/core/living-docs/CompletionPropagator.d.ts.map +1 -1
- package/dist/src/core/living-docs/CompletionPropagator.js +4 -3
- package/dist/src/core/living-docs/CompletionPropagator.js.map +1 -1
- package/dist/src/core/living-docs/SpecDistributor.d.ts +5 -0
- package/dist/src/core/living-docs/SpecDistributor.d.ts.map +1 -1
- package/dist/src/core/living-docs/SpecDistributor.js +12 -0
- package/dist/src/core/living-docs/SpecDistributor.js.map +1 -1
- package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -1
- package/dist/src/core/living-docs/content-distributor.js +11 -1
- package/dist/src/core/living-docs/content-distributor.js.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.d.ts +166 -0
- package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -0
- package/dist/src/core/living-docs/living-docs-sync.js +726 -0
- package/dist/src/core/living-docs/living-docs-sync.js.map +1 -0
- package/dist/src/core/living-docs/project-detector.d.ts.map +1 -1
- package/dist/src/core/living-docs/project-detector.js +38 -0
- package/dist/src/core/living-docs/project-detector.js.map +1 -1
- package/dist/src/core/living-docs/task-project-specific-generator.d.ts +7 -3
- package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
- package/dist/src/core/living-docs/task-project-specific-generator.js +40 -24
- package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
- package/dist/src/core/plugin-loader.d.ts +7 -0
- package/dist/src/core/plugin-loader.d.ts.map +1 -1
- package/dist/src/core/plugin-loader.js +18 -1
- package/dist/src/core/plugin-loader.js.map +1 -1
- package/dist/src/core/serverless/platform-data-loader.d.ts +8 -0
- package/dist/src/core/serverless/platform-data-loader.d.ts.map +1 -1
- package/dist/src/core/serverless/platform-data-loader.js +14 -0
- package/dist/src/core/serverless/platform-data-loader.js.map +1 -1
- package/dist/src/core/serverless/types.d.ts +1 -1
- package/dist/src/core/serverless/types.d.ts.map +1 -1
- package/dist/src/core/status-line/status-line-manager.d.ts +6 -2
- package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
- package/dist/src/core/status-line/status-line-manager.js +11 -5
- package/dist/src/core/status-line/status-line-manager.js.map +1 -1
- package/dist/src/core/status-line/task-counter.d.ts +69 -0
- package/dist/src/core/status-line/task-counter.d.ts.map +1 -0
- package/dist/src/core/status-line/task-counter.js +107 -0
- package/dist/src/core/status-line/task-counter.js.map +1 -0
- package/dist/src/core/types/config.d.ts +23 -0
- package/dist/src/core/types/config.d.ts.map +1 -1
- package/dist/src/core/types/config.js +10 -0
- package/dist/src/core/types/config.js.map +1 -1
- package/dist/src/core/workflow/autonomous-executor.d.ts +111 -0
- package/dist/src/core/workflow/autonomous-executor.d.ts.map +1 -0
- package/dist/src/core/workflow/autonomous-executor.js +275 -0
- package/dist/src/core/workflow/autonomous-executor.js.map +1 -0
- package/dist/src/core/workflow/backlog-scanner.d.ts +94 -0
- package/dist/src/core/workflow/backlog-scanner.d.ts.map +1 -0
- package/dist/src/core/workflow/backlog-scanner.js +170 -0
- package/dist/src/core/workflow/backlog-scanner.js.map +1 -0
- package/dist/src/core/workflow/command-invoker.d.ts +86 -0
- package/dist/src/core/workflow/command-invoker.d.ts.map +1 -0
- package/dist/src/core/workflow/command-invoker.js +131 -0
- package/dist/src/core/workflow/command-invoker.js.map +1 -0
- package/dist/src/core/workflow/cost-estimator.d.ts +120 -0
- package/dist/src/core/workflow/cost-estimator.d.ts.map +1 -0
- package/dist/src/core/workflow/cost-estimator.js +222 -0
- package/dist/src/core/workflow/cost-estimator.js.map +1 -0
- package/dist/src/core/workflow/index.d.ts +20 -0
- package/dist/src/core/workflow/index.d.ts.map +1 -0
- package/dist/src/core/workflow/index.js +24 -0
- package/dist/src/core/workflow/index.js.map +1 -0
- package/dist/src/core/workflow/state-manager.d.ts +107 -0
- package/dist/src/core/workflow/state-manager.d.ts.map +1 -0
- package/dist/src/core/workflow/state-manager.js +126 -0
- package/dist/src/core/workflow/state-manager.js.map +1 -0
- package/dist/src/core/workflow/workflow-orchestrator.d.ts +93 -0
- package/dist/src/core/workflow/workflow-orchestrator.d.ts.map +1 -0
- package/dist/src/core/workflow/workflow-orchestrator.js +195 -0
- package/dist/src/core/workflow/workflow-orchestrator.js.map +1 -0
- package/dist/src/init/ArchitecturePresenter.d.ts +47 -0
- package/dist/src/init/ArchitecturePresenter.d.ts.map +1 -0
- package/dist/src/init/ArchitecturePresenter.js +180 -0
- package/dist/src/init/ArchitecturePresenter.js.map +1 -0
- package/dist/src/init/InitFlow.d.ts.map +1 -1
- package/dist/src/init/InitFlow.js +30 -1
- package/dist/src/init/InitFlow.js.map +1 -1
- package/dist/src/init/architecture/CostEstimator.d.ts +52 -0
- package/dist/src/init/architecture/CostEstimator.d.ts.map +1 -0
- package/dist/src/init/architecture/CostEstimator.js +107 -0
- package/dist/src/init/architecture/CostEstimator.js.map +1 -0
- package/dist/src/init/architecture/InfrastructureMapper.d.ts +41 -0
- package/dist/src/init/architecture/InfrastructureMapper.d.ts.map +1 -0
- package/dist/src/init/architecture/InfrastructureMapper.js +140 -0
- package/dist/src/init/architecture/InfrastructureMapper.js.map +1 -0
- package/dist/src/init/architecture/ProjectGenerator.d.ts +44 -0
- package/dist/src/init/architecture/ProjectGenerator.d.ts.map +1 -0
- package/dist/src/init/architecture/ProjectGenerator.js +216 -0
- package/dist/src/init/architecture/ProjectGenerator.js.map +1 -0
- package/dist/src/init/architecture/types.d.ts +10 -10
- package/dist/src/init/research/src/config/types.d.ts +8 -8
- package/dist/src/metrics/dora-calculator.js +2 -2
- package/dist/src/metrics/dora-calculator.js.map +1 -1
- package/dist/src/utils/pricing-constants.d.ts +5 -2
- package/dist/src/utils/pricing-constants.d.ts.map +1 -1
- package/dist/src/utils/pricing-constants.js +3 -2
- package/dist/src/utils/pricing-constants.js.map +1 -1
- package/package.json +9 -8
- package/plugins/specweave/agents/infrastructure/AGENT.md +88 -46
- package/plugins/specweave/agents/pm/AGENT.md +58 -1
- package/plugins/specweave/commands/specweave-archive-features.md +1 -1
- package/plugins/specweave/commands/specweave-archive-increments.md +1 -1
- package/plugins/specweave/commands/specweave-check-hooks.md +5 -0
- package/plugins/specweave/commands/specweave-done.md +12 -0
- package/plugins/specweave/commands/specweave-plan.md +1 -1
- package/plugins/specweave/commands/specweave-progress.md +108 -379
- package/plugins/specweave/commands/specweave-reopen.md +1 -1
- package/plugins/specweave/commands/specweave-restore-feature.md +1 -1
- package/plugins/specweave/commands/specweave-sync-specs.md +20 -48
- package/plugins/specweave/hooks/lib/update-status-line.sh +44 -35
- package/plugins/specweave/hooks/lib/validate-spec-status.sh +163 -0
- package/plugins/specweave/hooks/user-prompt-submit.sh +17 -35
- package/plugins/specweave/lib/hooks/update-tasks-md.js +52 -9
- package/plugins/specweave/lib/hooks/update-tasks-md.ts +77 -16
- package/plugins/specweave/templates/iac/aws-lambda/defaults.json +24 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/README.md.hbs +260 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/dev.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/prod.tfvars.hbs +37 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/staging.tfvars.hbs +35 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/outputs.tf.hbs +77 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/providers.tf.hbs +36 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/variables.tf.hbs +115 -0
- package/plugins/specweave/templates/iac/azure-functions/defaults.json +25 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/README.md.hbs +268 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/dev.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/prod.tfvars.hbs +46 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/staging.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/main.tf.hbs +225 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/outputs.tf.hbs +89 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/provider.tf.hbs +27 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/providers.tf.hbs +35 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/variables.tf.hbs +124 -0
- package/plugins/specweave/templates/iac/firebase/defaults.json +29 -0
- package/plugins/specweave/templates/iac/firebase/templates/README.md.hbs +35 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/dev.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/prod.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/staging.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/main.tf.hbs +90 -0
- package/plugins/specweave/templates/iac/firebase/templates/outputs.tf.hbs +15 -0
- package/plugins/specweave/templates/iac/firebase/templates/providers.tf.hbs +23 -0
- package/plugins/specweave/templates/iac/firebase/templates/variables.tf.hbs +42 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/defaults.json +26 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/README.md.hbs +299 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/dev.tfvars.hbs +36 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/prod.tfvars.hbs +48 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/staging.tfvars.hbs +41 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/main.tf.hbs +192 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/outputs.tf.hbs +66 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/providers.tf.hbs +25 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/variables.tf.hbs +119 -0
- package/plugins/specweave/templates/iac/supabase/defaults.json +15 -0
- package/plugins/specweave/templates/iac/supabase/templates/README.md.hbs +46 -0
- package/plugins/specweave/templates/iac/supabase/templates/main.tf.hbs +50 -0
- package/plugins/specweave-ado/lib/enhanced-ado-sync.js +170 -0
- package/plugins/specweave-github/agents/github-manager/AGENT.md +39 -7
- package/plugins/specweave-github/commands/specweave-github-create-issue.md +5 -5
- package/plugins/specweave-github/lib/CodeValidator.js +195 -0
- package/plugins/specweave-github/lib/CodeValidator.ts +284 -0
- package/plugins/specweave-github/lib/ThreeLayerSyncManager.js +545 -0
- package/plugins/specweave-github/lib/ThreeLayerSyncManager.ts +809 -0
- package/plugins/specweave-github/lib/github-client-v2.js +29 -0
- package/plugins/specweave-github/lib/github-client-v2.ts +30 -0
- package/plugins/specweave-github/lib/task-sync.js +4 -0
- package/plugins/specweave-github/lib/task-sync.ts +7 -0
- package/plugins/specweave-github/lib/types.ts +38 -0
- package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +3222 -0
- package/src/templates/AGENTS.md.template +22 -1
- package/src/templates/CLAUDE.md.template +31 -0
- package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts +0 -116
- package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts.map +0 -1
- package/dist/src/core/living-docs/ThreeLayerSyncManager.js +0 -356
- package/dist/src/core/living-docs/ThreeLayerSyncManager.js.map +0 -1
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autonomous Executor - Fully autonomous workflow execution
|
|
3
|
+
*
|
|
4
|
+
* Executes complete workflows without human intervention, with safety guardrails:
|
|
5
|
+
* - Max iteration limits
|
|
6
|
+
* - Infinite loop detection
|
|
7
|
+
* - Cost threshold enforcement
|
|
8
|
+
* - Checkpoint/recovery system
|
|
9
|
+
*
|
|
10
|
+
* Part of increment 0039: Ultra-Smart Next Command
|
|
11
|
+
*
|
|
12
|
+
* @module core/workflow/autonomous-executor
|
|
13
|
+
* @since v0.22.0
|
|
14
|
+
*/
|
|
15
|
+
import { WorkflowOrchestrator } from './workflow-orchestrator.js';
|
|
16
|
+
import { StateManager } from './state-manager.js';
|
|
17
|
+
import { CostEstimator } from './cost-estimator.js';
|
|
18
|
+
import { CommandInvoker } from './command-invoker.js';
|
|
19
|
+
import { WorkflowPhase } from './types.js';
|
|
20
|
+
import * as path from 'path';
|
|
21
|
+
/**
|
|
22
|
+
* Autonomous Executor - Fully autonomous workflow execution with safety guardrails
|
|
23
|
+
*/
|
|
24
|
+
export class AutonomousExecutor {
|
|
25
|
+
constructor(config = {}) {
|
|
26
|
+
this.config = config;
|
|
27
|
+
this.orchestrator = new WorkflowOrchestrator();
|
|
28
|
+
this.stateManager = new StateManager();
|
|
29
|
+
this.costEstimator = new CostEstimator();
|
|
30
|
+
this.commandInvoker = new CommandInvoker();
|
|
31
|
+
// Apply defaults
|
|
32
|
+
this.config.maxIterations = config.maxIterations || 50;
|
|
33
|
+
this.config.costThreshold = config.costThreshold || 20.0;
|
|
34
|
+
this.config.enableCheckpoints = config.enableCheckpoints !== false;
|
|
35
|
+
this.config.maxRetries = config.maxRetries || 3;
|
|
36
|
+
this.config.stopOnError = config.stopOnError || false;
|
|
37
|
+
this.config.verbose = config.verbose || false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Execute workflow autonomously
|
|
41
|
+
*
|
|
42
|
+
* @param incrementId - Increment ID to execute
|
|
43
|
+
* @param resumeCheckpointId - Optional checkpoint to resume from
|
|
44
|
+
* @returns Autonomous execution result
|
|
45
|
+
*/
|
|
46
|
+
async execute(incrementId, resumeCheckpointId) {
|
|
47
|
+
this.log(`🚀 Starting autonomous execution for increment ${incrementId}`);
|
|
48
|
+
// Initialize state
|
|
49
|
+
let state;
|
|
50
|
+
if (resumeCheckpointId) {
|
|
51
|
+
state = await this.resumeFromCheckpoint(incrementId, resumeCheckpointId);
|
|
52
|
+
this.log(`📂 Resumed from checkpoint ${resumeCheckpointId} (iteration ${state.iteration})`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
state = this.initializeState(incrementId);
|
|
56
|
+
this.log(`🆕 Starting fresh execution`);
|
|
57
|
+
}
|
|
58
|
+
// Pre-flight checks
|
|
59
|
+
const preflightResult = await this.preflightCheck(incrementId);
|
|
60
|
+
if (!preflightResult.passed) {
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
incrementId,
|
|
64
|
+
iterations: 0,
|
|
65
|
+
commandsExecuted: [],
|
|
66
|
+
totalCost: 0,
|
|
67
|
+
finalPhase: WorkflowPhase.UNKNOWN,
|
|
68
|
+
reason: `Preflight check failed: ${preflightResult.reason}`,
|
|
69
|
+
error: preflightResult.reason
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Main execution loop
|
|
73
|
+
try {
|
|
74
|
+
while (state.iteration < this.config.maxIterations) {
|
|
75
|
+
this.log(`\n📍 Iteration ${state.iteration + 1}/${this.config.maxIterations}`);
|
|
76
|
+
// Safety checks
|
|
77
|
+
const safetyCheck = this.checkSafety(state);
|
|
78
|
+
if (!safetyCheck.safe) {
|
|
79
|
+
return this.terminateExecution(state, safetyCheck.reason, false);
|
|
80
|
+
}
|
|
81
|
+
// Execute next step
|
|
82
|
+
const result = await this.executeStep(state);
|
|
83
|
+
// Handle execution result
|
|
84
|
+
if (!result.success) {
|
|
85
|
+
if (this.config.stopOnError) {
|
|
86
|
+
return this.terminateExecution(state, `Step failed: ${result.error}`, false);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.log(`⚠️ Step failed (continuing): ${result.error}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Update state
|
|
93
|
+
state.iteration++;
|
|
94
|
+
state.phase = result.phase;
|
|
95
|
+
state.phaseHistory.push(result.phase);
|
|
96
|
+
if (result.command) {
|
|
97
|
+
state.commandsExecuted.push(result.command);
|
|
98
|
+
}
|
|
99
|
+
// Save checkpoint
|
|
100
|
+
if (this.config.enableCheckpoints) {
|
|
101
|
+
await this.saveCheckpoint(state);
|
|
102
|
+
}
|
|
103
|
+
// Check completion
|
|
104
|
+
if (this.isComplete(state)) {
|
|
105
|
+
return this.terminateExecution(state, 'Workflow completed successfully', true);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Max iterations reached
|
|
109
|
+
return this.terminateExecution(state, `Max iterations (${this.config.maxIterations}) reached`, false);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
return this.terminateExecution(state, `Fatal error: ${error instanceof Error ? error.message : String(error)}`, false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Execute single step in workflow
|
|
117
|
+
*/
|
|
118
|
+
async executeStep(state) {
|
|
119
|
+
this.log(`🔍 Detecting current phase...`);
|
|
120
|
+
// Use orchestrator to detect phase and determine action
|
|
121
|
+
const result = await this.orchestrator.executeNext(state.incrementId, {
|
|
122
|
+
autonomous: true,
|
|
123
|
+
verbose: this.config.verbose
|
|
124
|
+
});
|
|
125
|
+
this.log(`📊 Phase: ${result.phase} (confidence: ${(result.confidence * 100).toFixed(0)}%)`);
|
|
126
|
+
this.log(`🎯 Action: ${result.action}`);
|
|
127
|
+
// Execute command if suggested
|
|
128
|
+
if (result.command && result.success) {
|
|
129
|
+
this.log(`⚡ Executing: ${result.command}`);
|
|
130
|
+
const invokeResult = await this.commandInvoker.invokeWithRetry(result.command, {
|
|
131
|
+
captureOutput: true
|
|
132
|
+
}, this.config.maxRetries);
|
|
133
|
+
if (!invokeResult.success) {
|
|
134
|
+
this.log(`❌ Command failed: ${invokeResult.error}`);
|
|
135
|
+
return {
|
|
136
|
+
...result,
|
|
137
|
+
success: false,
|
|
138
|
+
error: invokeResult.error
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
this.log(`✅ Command completed in ${(invokeResult.executionTime / 1000).toFixed(1)}s`);
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Preflight check before execution
|
|
147
|
+
*/
|
|
148
|
+
async preflightCheck(incrementId) {
|
|
149
|
+
// Check increment exists
|
|
150
|
+
const incrementPath = path.join(process.cwd(), '.specweave/increments', incrementId);
|
|
151
|
+
const fs = await import('fs-extra');
|
|
152
|
+
if (!await fs.pathExists(incrementPath)) {
|
|
153
|
+
return {
|
|
154
|
+
passed: false,
|
|
155
|
+
reason: `Increment ${incrementId} not found`
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// Estimate cost
|
|
159
|
+
const estimate = await this.costEstimator.estimateIncrement(incrementPath);
|
|
160
|
+
this.log(`💰 Estimated cost: $${estimate.estimatedCost.toFixed(2)} (${estimate.riskLevel.toUpperCase()})`);
|
|
161
|
+
if (estimate.estimatedCost > this.config.costThreshold) {
|
|
162
|
+
return {
|
|
163
|
+
passed: false,
|
|
164
|
+
reason: `Estimated cost ($${estimate.estimatedCost.toFixed(2)}) exceeds threshold ($${this.config.costThreshold})`
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return { passed: true };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Safety checks during execution
|
|
171
|
+
*/
|
|
172
|
+
checkSafety(state) {
|
|
173
|
+
// Check for infinite loop
|
|
174
|
+
if (this.stateManager.detectLoop(state.phaseHistory)) {
|
|
175
|
+
return {
|
|
176
|
+
safe: false,
|
|
177
|
+
reason: 'Infinite loop detected (same phase repeated 3+ times)'
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// Check cost threshold
|
|
181
|
+
if (state.totalCost > this.config.costThreshold) {
|
|
182
|
+
return {
|
|
183
|
+
safe: false,
|
|
184
|
+
reason: `Cost threshold ($${this.config.costThreshold}) exceeded (current: $${state.totalCost.toFixed(2)})`
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return { safe: true };
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check if workflow is complete
|
|
191
|
+
*/
|
|
192
|
+
isComplete(state) {
|
|
193
|
+
// Completion phase reached
|
|
194
|
+
if (state.phase === WorkflowPhase.COMPLETION) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
// Unknown phase with no further actions (stuck)
|
|
198
|
+
if (state.phase === WorkflowPhase.UNKNOWN && state.iteration > 5) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Initialize execution state
|
|
205
|
+
*/
|
|
206
|
+
initializeState(incrementId) {
|
|
207
|
+
return {
|
|
208
|
+
incrementId,
|
|
209
|
+
iteration: 0,
|
|
210
|
+
phase: WorkflowPhase.UNKNOWN,
|
|
211
|
+
commandsExecuted: [],
|
|
212
|
+
totalCost: 0,
|
|
213
|
+
phaseHistory: []
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Resume from checkpoint
|
|
218
|
+
*/
|
|
219
|
+
async resumeFromCheckpoint(incrementId, checkpointId) {
|
|
220
|
+
const checkpoints = await this.stateManager.loadCheckpoints(incrementId);
|
|
221
|
+
const checkpoint = checkpoints.find(c => c.id === checkpointId);
|
|
222
|
+
if (!checkpoint) {
|
|
223
|
+
throw new Error(`Checkpoint ${checkpointId} not found`);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
incrementId,
|
|
227
|
+
iteration: checkpoint.iteration,
|
|
228
|
+
phase: checkpoint.phase,
|
|
229
|
+
commandsExecuted: checkpoint.actions,
|
|
230
|
+
totalCost: 0, // Reset cost tracking
|
|
231
|
+
phaseHistory: [checkpoint.phase]
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Save execution checkpoint
|
|
236
|
+
*/
|
|
237
|
+
async saveCheckpoint(state) {
|
|
238
|
+
await this.stateManager.saveCheckpoint({
|
|
239
|
+
id: `autonomous-${Date.now()}`,
|
|
240
|
+
timestamp: Date.now(),
|
|
241
|
+
incrementId: state.incrementId,
|
|
242
|
+
phase: state.phase,
|
|
243
|
+
iteration: state.iteration,
|
|
244
|
+
actions: state.commandsExecuted
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Terminate execution and return result
|
|
249
|
+
*/
|
|
250
|
+
terminateExecution(state, reason, success) {
|
|
251
|
+
this.log(`\n${success ? '✅' : '❌'} ${reason}`);
|
|
252
|
+
this.log(`📊 Final stats:`);
|
|
253
|
+
this.log(` - Iterations: ${state.iteration}`);
|
|
254
|
+
this.log(` - Commands: ${state.commandsExecuted.length}`);
|
|
255
|
+
this.log(` - Cost: $${state.totalCost.toFixed(2)}`);
|
|
256
|
+
return {
|
|
257
|
+
success,
|
|
258
|
+
incrementId: state.incrementId,
|
|
259
|
+
iterations: state.iteration,
|
|
260
|
+
commandsExecuted: state.commandsExecuted,
|
|
261
|
+
totalCost: state.totalCost,
|
|
262
|
+
finalPhase: state.phase,
|
|
263
|
+
reason
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Log message (if verbose enabled)
|
|
268
|
+
*/
|
|
269
|
+
log(message) {
|
|
270
|
+
if (this.config.verbose) {
|
|
271
|
+
console.log(message);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=autonomous-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonomous-executor.js","sourceRoot":"","sources":["../../../../src/core/workflow/autonomous-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,oBAAoB,EAA2B,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAgB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAwD7B;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAM7B,YACU,SAA2B,EAAE;QAA7B,WAAM,GAAN,MAAM,CAAuB;QAErC,IAAI,CAAC,YAAY,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,EAAE,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xB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backlog Scanner - Intelligent backlog scanning and ranking
|
|
3
|
+
*
|
|
4
|
+
* Scans .specweave/increments/_backlog/ directory and ranks items
|
|
5
|
+
* by priority, dependencies, and project match.
|
|
6
|
+
*
|
|
7
|
+
* Part of increment 0039: Ultra-Smart Next Command
|
|
8
|
+
*
|
|
9
|
+
* @module core/workflow/backlog-scanner
|
|
10
|
+
* @since v0.22.0
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Backlog item metadata
|
|
14
|
+
*/
|
|
15
|
+
export interface BacklogItem {
|
|
16
|
+
/** Increment ID */
|
|
17
|
+
incrementId: string;
|
|
18
|
+
/** Full path to spec.md */
|
|
19
|
+
specPath: string;
|
|
20
|
+
/** Title */
|
|
21
|
+
title: string;
|
|
22
|
+
/** Priority (P0, P1, P2, P3) */
|
|
23
|
+
priority: string;
|
|
24
|
+
/** Project (if multi-project) */
|
|
25
|
+
project?: string;
|
|
26
|
+
/** Dependencies (other increment IDs) */
|
|
27
|
+
dependencies: string[];
|
|
28
|
+
/** Estimated effort (hours or weeks) */
|
|
29
|
+
estimatedEffort?: string;
|
|
30
|
+
/** Creation date */
|
|
31
|
+
created?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Ranked backlog item with score
|
|
35
|
+
*/
|
|
36
|
+
export interface RankedBacklogItem extends BacklogItem {
|
|
37
|
+
/** Ranking score (higher = better) */
|
|
38
|
+
score: number;
|
|
39
|
+
/** Ranking explanation */
|
|
40
|
+
reason: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Backlog recommendation
|
|
44
|
+
*/
|
|
45
|
+
export interface BacklogRecommendation {
|
|
46
|
+
/** Recommended items (top N) */
|
|
47
|
+
items: RankedBacklogItem[];
|
|
48
|
+
/** Total backlog size */
|
|
49
|
+
totalItems: number;
|
|
50
|
+
/** Explanation */
|
|
51
|
+
summary: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Backlog Scanner - Scan and rank backlog items
|
|
55
|
+
*/
|
|
56
|
+
export declare class BacklogScanner {
|
|
57
|
+
private backlogDir;
|
|
58
|
+
constructor(rootDir?: string);
|
|
59
|
+
/**
|
|
60
|
+
* Scan backlog directory
|
|
61
|
+
*
|
|
62
|
+
* @returns Array of backlog items
|
|
63
|
+
*/
|
|
64
|
+
scanBacklog(): Promise<BacklogItem[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Parse backlog item from spec.md
|
|
67
|
+
*/
|
|
68
|
+
private parseBacklogItem;
|
|
69
|
+
/**
|
|
70
|
+
* Rank backlog items by priority, dependencies, and project match
|
|
71
|
+
*
|
|
72
|
+
* Ranking algorithm:
|
|
73
|
+
* - Priority: P0=10, P1=7, P2=5, P3=3
|
|
74
|
+
* - Dependencies met: +5
|
|
75
|
+
* - Project match: +3
|
|
76
|
+
* - Recently created: +2
|
|
77
|
+
*
|
|
78
|
+
* @param items - Backlog items to rank
|
|
79
|
+
* @param currentProject - Current project (for filtering)
|
|
80
|
+
* @param completedIncrements - List of completed increment IDs
|
|
81
|
+
* @returns Ranked items (sorted by score descending)
|
|
82
|
+
*/
|
|
83
|
+
rankItems(items: BacklogItem[], currentProject?: string, completedIncrements?: string[]): RankedBacklogItem[];
|
|
84
|
+
/**
|
|
85
|
+
* Get top N recommendations
|
|
86
|
+
*
|
|
87
|
+
* @param n - Number of recommendations (default: 3)
|
|
88
|
+
* @param currentProject - Current project filter
|
|
89
|
+
* @param completedIncrements - Completed increments
|
|
90
|
+
* @returns Backlog recommendations
|
|
91
|
+
*/
|
|
92
|
+
getTopRecommendations(n?: number, currentProject?: string, completedIncrements?: string[]): Promise<BacklogRecommendation>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=backlog-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backlog-scanner.d.ts","sourceRoot":"","sources":["../../../../src/core/workflow/backlog-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,wCAAwC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,yBAAyB;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,GAAE,MAAsB;IAI3C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAmC3C;;OAEG;YACW,gBAAgB;IA2B9B;;;;;;;;;;;;;OAaG;IACH,SAAS,CACP,KAAK,EAAE,WAAW,EAAE,EACpB,cAAc,CAAC,EAAE,MAAM,EACvB,mBAAmB,GAAE,MAAM,EAAO,GACjC,iBAAiB,EAAE;IAoDtB;;;;;;;OAOG;IACG,qBAAqB,CACzB,CAAC,GAAE,MAAU,EACb,cAAc,CAAC,EAAE,MAAM,EACvB,mBAAmB,GAAE,MAAM,EAAO,GACjC,OAAO,CAAC,qBAAqB,CAAC;CAoBlC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backlog Scanner - Intelligent backlog scanning and ranking
|
|
3
|
+
*
|
|
4
|
+
* Scans .specweave/increments/_backlog/ directory and ranks items
|
|
5
|
+
* by priority, dependencies, and project match.
|
|
6
|
+
*
|
|
7
|
+
* Part of increment 0039: Ultra-Smart Next Command
|
|
8
|
+
*
|
|
9
|
+
* @module core/workflow/backlog-scanner
|
|
10
|
+
* @since v0.22.0
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from 'fs-extra';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import * as yaml from 'js-yaml';
|
|
15
|
+
/**
|
|
16
|
+
* Backlog Scanner - Scan and rank backlog items
|
|
17
|
+
*/
|
|
18
|
+
export class BacklogScanner {
|
|
19
|
+
constructor(rootDir = process.cwd()) {
|
|
20
|
+
this.backlogDir = path.join(rootDir, '.specweave/increments/_backlog');
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Scan backlog directory
|
|
24
|
+
*
|
|
25
|
+
* @returns Array of backlog items
|
|
26
|
+
*/
|
|
27
|
+
async scanBacklog() {
|
|
28
|
+
// Check if backlog directory exists
|
|
29
|
+
if (!await fs.pathExists(this.backlogDir)) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const items = [];
|
|
33
|
+
const dirs = await fs.readdir(this.backlogDir);
|
|
34
|
+
for (const dir of dirs) {
|
|
35
|
+
const dirPath = path.join(this.backlogDir, dir);
|
|
36
|
+
const stat = await fs.stat(dirPath);
|
|
37
|
+
if (!stat.isDirectory()) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// Check if spec.md exists
|
|
41
|
+
const specPath = path.join(dirPath, 'spec.md');
|
|
42
|
+
if (!await fs.pathExists(specPath)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
// Parse spec.md frontmatter
|
|
46
|
+
try {
|
|
47
|
+
const item = await this.parseBacklogItem(dir, specPath);
|
|
48
|
+
items.push(item);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.warn(`Failed to parse backlog item ${dir}:`, error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return items;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parse backlog item from spec.md
|
|
58
|
+
*/
|
|
59
|
+
async parseBacklogItem(incrementId, specPath) {
|
|
60
|
+
const content = await fs.readFile(specPath, 'utf-8');
|
|
61
|
+
// Extract YAML frontmatter
|
|
62
|
+
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
63
|
+
if (!frontmatterMatch) {
|
|
64
|
+
throw new Error('No YAML frontmatter found in spec.md');
|
|
65
|
+
}
|
|
66
|
+
const frontmatter = yaml.load(frontmatterMatch[1]);
|
|
67
|
+
// Extract title from first heading
|
|
68
|
+
const titleMatch = content.match(/^#\s+(.+)$/m);
|
|
69
|
+
const title = titleMatch ? titleMatch[1] : frontmatter.title || incrementId;
|
|
70
|
+
return {
|
|
71
|
+
incrementId,
|
|
72
|
+
specPath,
|
|
73
|
+
title,
|
|
74
|
+
priority: frontmatter.priority || 'P2',
|
|
75
|
+
project: frontmatter.project,
|
|
76
|
+
dependencies: frontmatter.dependencies || [],
|
|
77
|
+
estimatedEffort: frontmatter.estimated_effort || frontmatter.estimatedEffort,
|
|
78
|
+
created: frontmatter.created
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Rank backlog items by priority, dependencies, and project match
|
|
83
|
+
*
|
|
84
|
+
* Ranking algorithm:
|
|
85
|
+
* - Priority: P0=10, P1=7, P2=5, P3=3
|
|
86
|
+
* - Dependencies met: +5
|
|
87
|
+
* - Project match: +3
|
|
88
|
+
* - Recently created: +2
|
|
89
|
+
*
|
|
90
|
+
* @param items - Backlog items to rank
|
|
91
|
+
* @param currentProject - Current project (for filtering)
|
|
92
|
+
* @param completedIncrements - List of completed increment IDs
|
|
93
|
+
* @returns Ranked items (sorted by score descending)
|
|
94
|
+
*/
|
|
95
|
+
rankItems(items, currentProject, completedIncrements = []) {
|
|
96
|
+
const ranked = items.map(item => {
|
|
97
|
+
let score = 0;
|
|
98
|
+
const reasons = [];
|
|
99
|
+
// Priority score
|
|
100
|
+
const priorityScores = {
|
|
101
|
+
'P0': 10,
|
|
102
|
+
'P1': 7,
|
|
103
|
+
'P2': 5,
|
|
104
|
+
'P3': 3
|
|
105
|
+
};
|
|
106
|
+
const priorityScore = priorityScores[item.priority] || 3;
|
|
107
|
+
score += priorityScore;
|
|
108
|
+
reasons.push(`Priority ${item.priority} (${priorityScore} pts)`);
|
|
109
|
+
// Dependencies met
|
|
110
|
+
const unmetDeps = item.dependencies.filter(dep => !completedIncrements.includes(dep));
|
|
111
|
+
if (unmetDeps.length === 0 && item.dependencies.length > 0) {
|
|
112
|
+
score += 5;
|
|
113
|
+
reasons.push('All dependencies met (+5 pts)');
|
|
114
|
+
}
|
|
115
|
+
else if (unmetDeps.length > 0) {
|
|
116
|
+
reasons.push(`Blocked by: ${unmetDeps.join(', ')}`);
|
|
117
|
+
}
|
|
118
|
+
// Project match
|
|
119
|
+
if (currentProject && item.project === currentProject) {
|
|
120
|
+
score += 3;
|
|
121
|
+
reasons.push(`Project match: ${currentProject} (+3 pts)`);
|
|
122
|
+
}
|
|
123
|
+
// Recently created (bonus for new items)
|
|
124
|
+
if (item.created) {
|
|
125
|
+
const createdDate = new Date(item.created);
|
|
126
|
+
const daysSinceCreated = (Date.now() - createdDate.getTime()) / (1000 * 60 * 60 * 24);
|
|
127
|
+
if (daysSinceCreated < 7) {
|
|
128
|
+
score += 2;
|
|
129
|
+
reasons.push('Recently created (+2 pts)');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
...item,
|
|
134
|
+
score,
|
|
135
|
+
reason: reasons.join('; ')
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
// Sort by score (descending)
|
|
139
|
+
return ranked.sort((a, b) => b.score - a.score);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get top N recommendations
|
|
143
|
+
*
|
|
144
|
+
* @param n - Number of recommendations (default: 3)
|
|
145
|
+
* @param currentProject - Current project filter
|
|
146
|
+
* @param completedIncrements - Completed increments
|
|
147
|
+
* @returns Backlog recommendations
|
|
148
|
+
*/
|
|
149
|
+
async getTopRecommendations(n = 3, currentProject, completedIncrements = []) {
|
|
150
|
+
const items = await this.scanBacklog();
|
|
151
|
+
const ranked = this.rankItems(items, currentProject, completedIncrements);
|
|
152
|
+
const topItems = ranked.slice(0, n);
|
|
153
|
+
let summary = '';
|
|
154
|
+
if (items.length === 0) {
|
|
155
|
+
summary = 'No items in backlog. Use /specweave:increment to create new work.';
|
|
156
|
+
}
|
|
157
|
+
else if (topItems.length === 0) {
|
|
158
|
+
summary = 'No actionable items found (all blocked by dependencies).';
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
summary = `Found ${items.length} items in backlog. Top ${topItems.length} recommendations based on priority and dependencies.`;
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
items: topItems,
|
|
165
|
+
totalItems: items.length,
|
|
166
|
+
summary
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=backlog-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backlog-scanner.js","sourceRoot":"","sources":["../../../../src/core/workflow/backlog-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,IAAI,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C;QAED,OAAO;YACL,KAAK,EAAE,QAAQ;YACf,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,OAAO;SACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Invoker - Programmatic command execution
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities to invoke SpecWeave commands programmatically
|
|
5
|
+
* from within the workflow orchestration system.
|
|
6
|
+
*
|
|
7
|
+
* Part of increment 0039: Ultra-Smart Next Command
|
|
8
|
+
*
|
|
9
|
+
* @module core/workflow/command-invoker
|
|
10
|
+
* @since v0.22.0
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Command invocation options
|
|
14
|
+
*/
|
|
15
|
+
export interface InvokeOptions {
|
|
16
|
+
/** Command arguments */
|
|
17
|
+
args?: string[];
|
|
18
|
+
/** Working directory */
|
|
19
|
+
cwd?: string;
|
|
20
|
+
/** Timeout in milliseconds */
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/** Capture stdout */
|
|
23
|
+
captureOutput?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Command invocation result
|
|
27
|
+
*/
|
|
28
|
+
export interface InvokeResult {
|
|
29
|
+
/** Command succeeded */
|
|
30
|
+
success: boolean;
|
|
31
|
+
/** Exit code */
|
|
32
|
+
exitCode: number;
|
|
33
|
+
/** Standard output */
|
|
34
|
+
stdout?: string;
|
|
35
|
+
/** Standard error */
|
|
36
|
+
stderr?: string;
|
|
37
|
+
/** Error message */
|
|
38
|
+
error?: string;
|
|
39
|
+
/** Execution time in milliseconds */
|
|
40
|
+
executionTime: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Error severity level
|
|
44
|
+
*/
|
|
45
|
+
export declare enum ErrorSeverity {
|
|
46
|
+
INFO = "info",
|
|
47
|
+
WARNING = "warning",
|
|
48
|
+
ERROR = "error",
|
|
49
|
+
CRITICAL = "critical"
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Command Invoker - Execute SpecWeave commands programmatically
|
|
53
|
+
*/
|
|
54
|
+
export declare class CommandInvoker {
|
|
55
|
+
/**
|
|
56
|
+
* Invoke a SpecWeave command
|
|
57
|
+
*
|
|
58
|
+
* @param command - Command name (e.g., 'plan', 'do', 'validate')
|
|
59
|
+
* @param options - Invocation options
|
|
60
|
+
* @returns Command execution result
|
|
61
|
+
*/
|
|
62
|
+
invoke(command: string, options?: InvokeOptions): Promise<InvokeResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Invoke command with automatic retry on transient failures
|
|
65
|
+
*
|
|
66
|
+
* @param command - Command name
|
|
67
|
+
* @param options - Invocation options
|
|
68
|
+
* @param maxRetries - Maximum retry attempts (default: 3)
|
|
69
|
+
* @returns Command execution result
|
|
70
|
+
*/
|
|
71
|
+
invokeWithRetry(command: string, options?: InvokeOptions, maxRetries?: number): Promise<InvokeResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Classify error severity
|
|
74
|
+
*
|
|
75
|
+
* @param result - Command result
|
|
76
|
+
* @returns Error severity level
|
|
77
|
+
*/
|
|
78
|
+
classifyError(result: InvokeResult): ErrorSeverity;
|
|
79
|
+
/**
|
|
80
|
+
* Delay execution
|
|
81
|
+
*
|
|
82
|
+
* @param ms - Milliseconds to delay
|
|
83
|
+
*/
|
|
84
|
+
private delay;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=command-invoker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-invoker.d.ts","sourceRoot":"","sources":["../../../../src/core/workflow/command-invoker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;;OAMG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAsCjF;;;;;;;OAOG;IACG,eAAe,CACnB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,aAAkB,EAC3B,UAAU,GAAE,MAAU,GACrB,OAAO,CAAC,YAAY,CAAC;IA+BxB;;;;;OAKG;IACH,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa;IAqBlD;;;;OAIG;IACH,OAAO,CAAC,KAAK;CAGd"}
|