opencode-swarm 6.6.1 → 6.8.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.
Files changed (49) hide show
  1. package/README.md +50 -6
  2. package/dist/__tests__/security-adversarial.test.d.ts +1 -0
  3. package/dist/background/circuit-breaker.d.ts +149 -0
  4. package/dist/background/event-bus.d.ts +60 -0
  5. package/dist/background/evidence-summary-integration.d.ts +73 -0
  6. package/dist/background/index.d.ts +22 -0
  7. package/dist/background/manager.d.ts +122 -0
  8. package/dist/background/plan-sync-worker.d.ts +117 -0
  9. package/dist/background/queue.d.ts +116 -0
  10. package/dist/background/status-artifact.d.ts +115 -0
  11. package/dist/background/trigger.d.ts +175 -0
  12. package/dist/background/trigger.vulnerability.test.d.ts +1 -0
  13. package/dist/background/worker.d.ts +92 -0
  14. package/dist/commands/command-adapters.security.test.d.ts +14 -0
  15. package/dist/commands/commands.test.d.ts +1 -0
  16. package/dist/commands/diagnose.d.ts +1 -5
  17. package/dist/commands/doctor.d.ts +5 -0
  18. package/dist/commands/evidence.d.ts +1 -5
  19. package/dist/commands/export.d.ts +1 -5
  20. package/dist/commands/history.d.ts +1 -5
  21. package/dist/commands/index.d.ts +3 -0
  22. package/dist/commands/plan.d.ts +1 -1
  23. package/dist/commands/preflight.d.ts +1 -0
  24. package/dist/commands/status.d.ts +1 -2
  25. package/dist/commands/sync-plan.d.ts +8 -0
  26. package/dist/config/index.d.ts +2 -2
  27. package/dist/config/plan-schema.d.ts +4 -4
  28. package/dist/config/schema.d.ts +53 -0
  29. package/dist/hooks/index.d.ts +1 -0
  30. package/dist/hooks/phase-monitor.d.ts +16 -0
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +27786 -22900
  33. package/dist/plan/manager.d.ts +13 -6
  34. package/dist/services/config-doctor.d.ts +125 -0
  35. package/dist/services/config-doctor.security.test.d.ts +1 -0
  36. package/dist/services/config-doctor.test.d.ts +1 -0
  37. package/dist/services/decision-drift-analyzer.d.ts +96 -0
  38. package/dist/services/diagnose-service.d.ts +31 -0
  39. package/dist/services/evidence-service.d.ts +65 -0
  40. package/dist/services/evidence-summary-service.d.ts +75 -0
  41. package/dist/services/export-service.d.ts +23 -0
  42. package/dist/services/history-service.d.ts +35 -0
  43. package/dist/services/index.d.ts +11 -0
  44. package/dist/services/plan-service.d.ts +25 -0
  45. package/dist/services/preflight-integration.d.ts +38 -0
  46. package/dist/services/preflight-service.d.ts +62 -0
  47. package/dist/services/status-service.d.ts +28 -0
  48. package/dist/tools/secretscan.d.ts +4 -0
  49. package/package.json +1 -1
@@ -6,11 +6,17 @@ import { type Plan, type TaskStatus } from '../config/plan-schema';
6
6
  */
7
7
  export declare function loadPlanJsonOnly(directory: string): Promise<Plan | null>;
8
8
  /**
9
- * Load and validate plan from .swarm/plan.json with 4-step precedence:
10
- * 1. .swarm/plan.json exists AND validates → return parsed Plan
11
- * 2. .swarm/plan.json exists but FAILS validation → log warning, fall to step 3
12
- * 3. .swarm/plan.md exists call migrateLegacyPlan(), save result, return it
13
- * 4. Neither exists return null
9
+ * Load and validate plan from .swarm/plan.json with auto-heal sync.
10
+ *
11
+ * 4-step precedence with auto-heal:
12
+ * 1. .swarm/plan.json exists AND validates ->
13
+ * a) If plan.md missing or stale -> regenerate plan.md from plan.json
14
+ * b) Return parsed Plan
15
+ * 2. .swarm/plan.json exists but FAILS validation ->
16
+ * a) If plan.md exists -> migrate from plan.md, save valid plan.json, then derive plan.md
17
+ * b) Return migrated Plan
18
+ * 3. .swarm/plan.md exists only -> migrate from plan.md, save both files, return Plan
19
+ * 4. Neither exists -> return null
14
20
  */
15
21
  export declare function loadPlan(directory: string): Promise<Plan | null>;
16
22
  /**
@@ -24,7 +30,8 @@ export declare function savePlan(directory: string, plan: Plan): Promise<void>;
24
30
  */
25
31
  export declare function updateTaskStatus(directory: string, taskId: string, status: TaskStatus): Promise<Plan>;
26
32
  /**
27
- * Generate markdown view from plan object
33
+ * Generate deterministic markdown view from plan object.
34
+ * Ensures stable ordering: phases by ID (ascending), tasks by ID (natural numeric).
28
35
  */
29
36
  export declare function derivePlanMarkdown(plan: Plan): string;
30
37
  /**
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Config Doctor Service
3
+ *
4
+ * Validates opencode-swarm config shape, detects stale/invalid settings,
5
+ * classifies findings by severity, and proposes safe auto-fixes.
6
+ */
7
+ import type { PluginConfig } from '../config/schema';
8
+ /** Severity levels for config findings */
9
+ export type FindingSeverity = 'info' | 'warn' | 'error';
10
+ /** A single config finding */
11
+ export interface ConfigFinding {
12
+ /** Unique identifier for this finding type */
13
+ id: string;
14
+ /** Human-readable title */
15
+ title: string;
16
+ /** Detailed description */
17
+ description: string;
18
+ /** Severity level */
19
+ severity: FindingSeverity;
20
+ /** Path to the config key (dot notation) */
21
+ path: string;
22
+ /** Current invalid/stale value */
23
+ currentValue?: unknown;
24
+ /** Proposed safe fix (if available) */
25
+ proposedFix?: ConfigFix;
26
+ /** Whether this is auto-fixable (safe, non-destructive) */
27
+ autoFixable: boolean;
28
+ }
29
+ /** A proposed config fix */
30
+ export interface ConfigFix {
31
+ /** Type of fix */
32
+ type: 'remove' | 'update' | 'add';
33
+ /** Path to the config key (dot notation) */
34
+ path: string;
35
+ /** Value to set (for update/add) */
36
+ value?: unknown;
37
+ /** Description of what the fix does */
38
+ description: string;
39
+ /** Risk level - only 'low' is auto-fixable */
40
+ risk: 'low' | 'medium' | 'high';
41
+ }
42
+ /** Result of running the config doctor */
43
+ export interface ConfigDoctorResult {
44
+ /** All findings from the doctor run */
45
+ findings: ConfigFinding[];
46
+ /** Findings by severity */
47
+ summary: {
48
+ info: number;
49
+ warn: number;
50
+ error: number;
51
+ };
52
+ /** Whether any auto-fixable issues were found */
53
+ hasAutoFixableIssues: boolean;
54
+ /** Timestamp of the run */
55
+ timestamp: number;
56
+ /** The config that was analyzed */
57
+ configSource: string;
58
+ }
59
+ /** Backup artifact for rollback */
60
+ export interface ConfigBackup {
61
+ /** When the backup was created */
62
+ createdAt: number;
63
+ /** The backed up config content */
64
+ configPath: string;
65
+ /** The raw config content */
66
+ content: string;
67
+ /** Hash of content for integrity verification */
68
+ contentHash: string;
69
+ }
70
+ /**
71
+ * Get config file paths
72
+ */
73
+ export declare function getConfigPaths(directory: string): {
74
+ userConfigPath: string;
75
+ projectConfigPath: string;
76
+ };
77
+ /**
78
+ * Create a backup of the current config
79
+ */
80
+ export declare function createConfigBackup(directory: string): ConfigBackup | null;
81
+ /**
82
+ * Write a backup artifact to .swarm directory
83
+ * Persists full backup content to support rollback/restore
84
+ */
85
+ export declare function writeBackupArtifact(directory: string, backup: ConfigBackup): string;
86
+ /**
87
+ * Restore config from a backup artifact
88
+ * @param backupPath - Path to the backup artifact file
89
+ * @param directory - The working directory (for validating config paths)
90
+ * @returns the path to the restored config file, or null if restore failed
91
+ */
92
+ export declare function restoreFromBackup(backupPath: string, directory: string): string | null;
93
+ /**
94
+ * Run the config doctor on a loaded config
95
+ */
96
+ export declare function runConfigDoctor(config: PluginConfig, directory: string): ConfigDoctorResult;
97
+ /**
98
+ * Apply safe auto-fixes to config
99
+ * Only applies low-risk, non-destructive fixes
100
+ */
101
+ export declare function applySafeAutoFixes(directory: string, result: ConfigDoctorResult): {
102
+ appliedFixes: ConfigFix[];
103
+ updatedConfigPath: string | null;
104
+ };
105
+ /**
106
+ * Write doctor result to .swarm directory for GUI consumption
107
+ */
108
+ export declare function writeDoctorArtifact(directory: string, result: ConfigDoctorResult): string;
109
+ /**
110
+ * Check if config doctor should run on startup
111
+ */
112
+ export declare function shouldRunOnStartup(automationConfig: {
113
+ mode: string;
114
+ capabilities?: Record<string, boolean>;
115
+ } | undefined): boolean;
116
+ /**
117
+ * Full config doctor run with backup and fix application
118
+ */
119
+ export declare function runConfigDoctorWithFixes(directory: string, config: PluginConfig, autoFix?: boolean): Promise<{
120
+ result: ConfigDoctorResult;
121
+ backupPath: string | null;
122
+ appliedFixes: ConfigFix[];
123
+ updatedConfigPath: string | null;
124
+ artifactPath: string | null;
125
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Decision Drift Analyzer Service
3
+ *
4
+ * Analyzes decisions from context.md and current plan state to detect:
5
+ * 1. Stale decisions (age/phase mismatch or no recent confirmation)
6
+ * 2. Contradictions (new decisions conflicting with existing ones)
7
+ *
8
+ * Results are integrated into architect context injection.
9
+ */
10
+ /**
11
+ * Drift signal severity levels
12
+ */
13
+ export type DriftSeverity = 'warning' | 'error';
14
+ /**
15
+ * A single decision extracted from context.md
16
+ */
17
+ export interface Decision {
18
+ /** Raw decision text */
19
+ text: string;
20
+ /** Phase when decision was made (extracted or inferred) */
21
+ phase: number | null;
22
+ /** Whether decision has a confirmation marker */
23
+ confirmed: boolean;
24
+ /** Timestamp if available */
25
+ timestamp: string | null;
26
+ /** Line number in source file */
27
+ line: number;
28
+ }
29
+ /**
30
+ * A detected drift signal
31
+ */
32
+ export interface DriftSignal {
33
+ /** Unique identifier for this drift */
34
+ id: string;
35
+ /** Severity level */
36
+ severity: DriftSeverity;
37
+ /** Type of drift */
38
+ type: 'stale' | 'contradiction';
39
+ /** Human-readable description */
40
+ message: string;
41
+ /** Source reference (file and line) */
42
+ source: {
43
+ file: string;
44
+ line: number;
45
+ };
46
+ /** Related decisions if applicable */
47
+ relatedDecisions?: string[];
48
+ /** Suggested resolution hint */
49
+ hint?: string;
50
+ }
51
+ /**
52
+ * Result of drift analysis
53
+ */
54
+ export interface DriftAnalysisResult {
55
+ /** Whether drift was detected */
56
+ hasDrift: boolean;
57
+ /** List of drift signals */
58
+ signals: DriftSignal[];
59
+ /** Summary text for context injection */
60
+ summary: string;
61
+ /** Timestamp of analysis */
62
+ analyzedAt: string;
63
+ }
64
+ /**
65
+ * Configuration for drift analyzer
66
+ */
67
+ export interface DriftAnalyzerConfig {
68
+ /** Maximum age in phases before a decision is considered stale */
69
+ staleThresholdPhases: number;
70
+ /** Whether to detect contradictions */
71
+ detectContradictions: boolean;
72
+ /** Maximum signals to return */
73
+ maxSignals: number;
74
+ }
75
+ /**
76
+ * Default configuration
77
+ */
78
+ export declare const DEFAULT_DRIFT_CONFIG: DriftAnalyzerConfig;
79
+ /**
80
+ * Extract decisions from context.md content
81
+ */
82
+ export declare function extractDecisionsFromContext(contextContent: string): Decision[];
83
+ /**
84
+ * Simple keyword-based contradiction detection
85
+ * Looks for decisions that express opposite intentions
86
+ */
87
+ export declare function findContradictions(decisions: Decision[]): DriftSignal[];
88
+ /**
89
+ * Analyze decision drift
90
+ */
91
+ export declare function analyzeDecisionDrift(directory: string, config?: Partial<DriftAnalyzerConfig>): Promise<DriftAnalysisResult>;
92
+ /**
93
+ * Format drift signals as a structured section for context injection
94
+ * Returns bounded output suitable for LLM context
95
+ */
96
+ export declare function formatDriftForContext(result: DriftAnalysisResult): string;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A single health check result.
3
+ */
4
+ export interface HealthCheck {
5
+ name: string;
6
+ status: '✅' | '❌';
7
+ detail: string;
8
+ }
9
+ /**
10
+ * Structured diagnose data returned by the diagnose service.
11
+ */
12
+ export interface DiagnoseData {
13
+ checks: HealthCheck[];
14
+ passCount: number;
15
+ totalCount: number;
16
+ allPassed: boolean;
17
+ }
18
+ /**
19
+ * Get diagnose data from the swarm directory.
20
+ * Returns structured health checks for GUI, background flows, or commands.
21
+ */
22
+ export declare function getDiagnoseData(directory: string): Promise<DiagnoseData>;
23
+ /**
24
+ * Format diagnose data as markdown for command output.
25
+ */
26
+ export declare function formatDiagnoseMarkdown(diagnose: DiagnoseData): string;
27
+ /**
28
+ * Handle diagnose command - delegates to service and formats output.
29
+ * Kept for backward compatibility - thin adapter.
30
+ */
31
+ export declare function handleDiagnoseCommand(directory: string, _args: string[]): Promise<string>;
@@ -0,0 +1,65 @@
1
+ import type { Evidence } from '../config/evidence-schema';
2
+ /**
3
+ * Structured evidence entry for a task.
4
+ */
5
+ export interface EvidenceEntryData {
6
+ index: number;
7
+ entry: Evidence;
8
+ type: string;
9
+ verdict: string;
10
+ verdictIcon: string;
11
+ agent: string;
12
+ summary: string;
13
+ timestamp: string;
14
+ details: Record<string, string | number | undefined>;
15
+ }
16
+ /**
17
+ * Structured evidence data for a single task.
18
+ */
19
+ export interface TaskEvidenceData {
20
+ hasEvidence: boolean;
21
+ taskId: string;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ entries: EvidenceEntryData[];
25
+ }
26
+ /**
27
+ * Structured evidence list data for all tasks.
28
+ */
29
+ export interface EvidenceListData {
30
+ hasEvidence: boolean;
31
+ tasks: Array<{
32
+ taskId: string;
33
+ entryCount: number;
34
+ lastUpdated: string;
35
+ }>;
36
+ }
37
+ /**
38
+ * Get emoji for verdict type (exported for use in entry formatting).
39
+ */
40
+ export declare function getVerdictEmoji(verdict: string): string;
41
+ /**
42
+ * Get evidence data for a specific task.
43
+ */
44
+ export declare function getTaskEvidenceData(directory: string, taskId: string): Promise<TaskEvidenceData>;
45
+ /**
46
+ * Get list of all evidence bundles.
47
+ */
48
+ export declare function getEvidenceListData(directory: string): Promise<EvidenceListData>;
49
+ /**
50
+ * Format evidence list as markdown for command output.
51
+ */
52
+ export declare function formatEvidenceListMarkdown(list: EvidenceListData): string;
53
+ /**
54
+ * Format task evidence as markdown for command output.
55
+ */
56
+ export declare function formatTaskEvidenceMarkdown(evidence: TaskEvidenceData): string;
57
+ /**
58
+ * Handle evidence command - delegates to service and formats output.
59
+ * Kept for backward compatibility - thin adapter.
60
+ */
61
+ export declare function handleEvidenceCommand(directory: string, args: string[]): Promise<string>;
62
+ /**
63
+ * Handle evidence summary command - generates completion ratio and blockers report.
64
+ */
65
+ export declare function handleEvidenceSummaryCommand(directory: string): Promise<string>;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Evidence Summary Service
3
+ *
4
+ * Provides deterministic evidence aggregation per task and phase.
5
+ * Produces machine-readable and human-readable summary artifacts.
6
+ */
7
+ import type { PhaseStatus, TaskStatus } from '../config/plan-schema';
8
+ /** Evidence types required for task completion */
9
+ export declare const REQUIRED_EVIDENCE_TYPES: readonly ["review", "test"];
10
+ export type RequiredEvidenceType = (typeof REQUIRED_EVIDENCE_TYPES)[number];
11
+ /** Summary artifact schema version */
12
+ export declare const EVIDENCE_SUMMARY_VERSION = "1.0.0";
13
+ /** Evidence summary for a single task */
14
+ export interface TaskEvidenceSummary {
15
+ taskId: string;
16
+ phase: number;
17
+ taskStatus: TaskStatus;
18
+ evidenceCount: number;
19
+ hasReview: boolean;
20
+ hasTest: boolean;
21
+ hasApproval: boolean;
22
+ missingEvidence: string[];
23
+ isComplete: boolean;
24
+ blockers: string[];
25
+ lastEvidenceTimestamp: string | null;
26
+ }
27
+ /** Phase evidence summary */
28
+ export interface PhaseEvidenceSummary {
29
+ phaseId: number;
30
+ phaseName: string;
31
+ phaseStatus: PhaseStatus;
32
+ totalTasks: number;
33
+ completedTasks: number;
34
+ tasksWithEvidence: number;
35
+ tasksWithCompleteEvidence: number;
36
+ completionRatio: number;
37
+ missingEvidenceByType: Record<string, string[]>;
38
+ blockers: PhaseBlocker[];
39
+ tasks: TaskEvidenceSummary[];
40
+ }
41
+ /** Blockers preventing phase closure */
42
+ export interface PhaseBlocker {
43
+ type: 'missing_evidence' | 'incomplete_task' | 'blocked_task';
44
+ taskId: string;
45
+ reason: string;
46
+ severity: 'high' | 'medium' | 'low';
47
+ }
48
+ /** Full evidence summary artifact */
49
+ export interface EvidenceSummaryArtifact {
50
+ schema_version: typeof EVIDENCE_SUMMARY_VERSION;
51
+ generated_at: string;
52
+ planTitle: string;
53
+ currentPhase: number;
54
+ phaseSummaries: PhaseEvidenceSummary[];
55
+ overallCompletionRatio: number;
56
+ overallBlockers: PhaseBlocker[];
57
+ summaryText: string;
58
+ }
59
+ /**
60
+ * Build complete evidence summary artifact
61
+ *
62
+ * Aggregates evidence per task and phase, producing deterministic
63
+ * summary artifacts including completion ratio, missing evidence,
64
+ * blockers, and per-task status.
65
+ */
66
+ export declare function buildEvidenceSummary(directory: string, currentPhase?: number): Promise<EvidenceSummaryArtifact | null>;
67
+ /**
68
+ * Check if auto-summaries are enabled via feature flags
69
+ */
70
+ export declare function isAutoSummaryEnabled(automationConfig?: {
71
+ capabilities?: {
72
+ evidence_auto_summaries?: boolean;
73
+ };
74
+ mode?: string;
75
+ }): boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Structured export data.
3
+ */
4
+ export interface ExportData {
5
+ version: string;
6
+ exported: string;
7
+ plan: unknown;
8
+ context: string | null;
9
+ }
10
+ /**
11
+ * Get export data from the swarm directory.
12
+ * Returns structured data for GUI, background flows, or commands.
13
+ */
14
+ export declare function getExportData(directory: string): Promise<ExportData>;
15
+ /**
16
+ * Format export data as markdown with JSON code block for command output.
17
+ */
18
+ export declare function formatExportMarkdown(exportData: ExportData): string;
19
+ /**
20
+ * Handle export command - delegates to service and formats output.
21
+ * Kept for backward compatibility - thin adapter.
22
+ */
23
+ export declare function handleExportCommand(directory: string, _args: string[]): Promise<string>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Structured history data for a single phase.
3
+ */
4
+ export interface PhaseHistoryData {
5
+ id: number;
6
+ name: string;
7
+ status: 'complete' | 'in_progress' | 'pending' | 'blocked';
8
+ statusText: string;
9
+ statusIcon: string;
10
+ completedTasks: number;
11
+ totalTasks: number;
12
+ tasksDisplay: string;
13
+ }
14
+ /**
15
+ * Structured history data returned by the history service.
16
+ */
17
+ export interface HistoryData {
18
+ hasPlan: boolean;
19
+ phases: PhaseHistoryData[];
20
+ isLegacy: boolean;
21
+ }
22
+ /**
23
+ * Get history data from the swarm directory.
24
+ * Returns structured data for GUI, background flows, or commands.
25
+ */
26
+ export declare function getHistoryData(directory: string): Promise<HistoryData>;
27
+ /**
28
+ * Format history data as markdown for command output.
29
+ */
30
+ export declare function formatHistoryMarkdown(history: HistoryData): string;
31
+ /**
32
+ * Handle history command - delegates to service and formats output.
33
+ * Kept for backward compatibility - thin adapter.
34
+ */
35
+ export declare function handleHistoryCommand(directory: string, _args: string[]): Promise<string>;
@@ -0,0 +1,11 @@
1
+ export { analyzeDecisionDrift, DEFAULT_DRIFT_CONFIG, type Decision, type DriftAnalysisResult, type DriftAnalyzerConfig, type DriftSeverity, type DriftSignal, extractDecisionsFromContext, findContradictions, formatDriftForContext, } from './decision-drift-analyzer';
2
+ export { applySafeAutoFixes, type ConfigBackup, type ConfigDoctorResult, type ConfigFinding, type ConfigFix, createConfigBackup, type FindingSeverity, getConfigPaths, runConfigDoctor, runConfigDoctorWithFixes, shouldRunOnStartup, writeBackupArtifact, writeDoctorArtifact, } from './config-doctor';
3
+ export { type DiagnoseData, formatDiagnoseMarkdown, getDiagnoseData, type HealthCheck, handleDiagnoseCommand, } from './diagnose-service';
4
+ export { type EvidenceEntryData, type EvidenceListData, formatEvidenceListMarkdown, formatTaskEvidenceMarkdown, getEvidenceListData, getTaskEvidenceData, getVerdictEmoji, handleEvidenceCommand, type TaskEvidenceData, } from './evidence-service';
5
+ export { buildEvidenceSummary, EVIDENCE_SUMMARY_VERSION, type EvidenceSummaryArtifact, isAutoSummaryEnabled, type PhaseBlocker, type PhaseEvidenceSummary, REQUIRED_EVIDENCE_TYPES, type TaskEvidenceSummary, } from './evidence-summary-service';
6
+ export { type ExportData, formatExportMarkdown, getExportData, handleExportCommand, } from './export-service';
7
+ export { formatHistoryMarkdown, getHistoryData, type HistoryData, handleHistoryCommand, type PhaseHistoryData, } from './history-service';
8
+ export { formatPlanMarkdown, getPlanData, handlePlanCommand, type PlanData, } from './plan-service';
9
+ export { createPreflightIntegration, type PreflightIntegrationConfig, runManualPreflight, } from './preflight-integration';
10
+ export { formatPreflightMarkdown, handlePreflightCommand, type PreflightCheckResult, type PreflightCheckType, type PreflightConfig, type PreflightReport, runPreflight, } from './preflight-service';
11
+ export { formatStatusMarkdown, getStatusData, handleStatusCommand, type StatusData, } from './status-service';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Structured plan data for a specific phase or full plan.
3
+ */
4
+ export interface PlanData {
5
+ hasPlan: boolean;
6
+ fullMarkdown: string;
7
+ requestedPhase: number | null;
8
+ phaseMarkdown: string | null;
9
+ errorMessage: string | null;
10
+ isLegacy: boolean;
11
+ }
12
+ /**
13
+ * Get plan data from the swarm directory.
14
+ * Returns structured data for GUI, background flows, or commands.
15
+ */
16
+ export declare function getPlanData(directory: string, phaseArg?: string | number): Promise<PlanData>;
17
+ /**
18
+ * Format plan data as markdown for command output.
19
+ */
20
+ export declare function formatPlanMarkdown(planData: PlanData): string;
21
+ /**
22
+ * Handle plan command - delegates to service and formats output.
23
+ * Kept for backward compatibility - thin adapter.
24
+ */
25
+ export declare function handlePlanCommand(directory: string, args: string[]): Promise<string>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Preflight Background Integration
3
+ *
4
+ * Wires the preflight service to background automation:
5
+ * - Subscribes to preflight.requested events
6
+ * - Runs preflight checks
7
+ * - Updates status artifact with results
8
+ */
9
+ import { PreflightTriggerManager } from '../background/trigger';
10
+ import type { AutomationConfig } from '../config/schema';
11
+ import { type PreflightConfig, type PreflightReport } from '../services/preflight-service';
12
+ /** Integration configuration */
13
+ export interface PreflightIntegrationConfig {
14
+ /** Automation configuration (required for capability gating) */
15
+ automationConfig: AutomationConfig;
16
+ /** Directory to run preflight in */
17
+ directory: string;
18
+ /** Swarm directory for status artifact */
19
+ swarmDir: string;
20
+ /** Preflight check configuration */
21
+ preflightConfig?: PreflightConfig;
22
+ /** Whether to update status artifact (default true) */
23
+ updateStatusArtifact?: boolean;
24
+ }
25
+ /**
26
+ * Create preflight integration
27
+ *
28
+ * Sets up the handler that will be called when preflight is requested.
29
+ * Returns the trigger manager and cleanup function.
30
+ */
31
+ export declare function createPreflightIntegration(config: PreflightIntegrationConfig): {
32
+ manager: PreflightTriggerManager;
33
+ cleanup: () => void;
34
+ };
35
+ /**
36
+ * Run preflight manually (for testing or CLI)
37
+ */
38
+ export declare function runManualPreflight(directory: string, phase: number, config?: PreflightConfig): Promise<PreflightReport>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Preflight Automation Service
3
+ *
4
+ * Runs automated preflight checks for release readiness:
5
+ * - lint check
6
+ * - tests check (sane verification scope)
7
+ * - secrets check
8
+ * - evidence completeness check
9
+ * - version consistency check
10
+ *
11
+ * Returns deterministic structured result with per-check status + overall verdict.
12
+ * Callable by background flow (from preflight.requested events).
13
+ */
14
+ /** Preflight check types */
15
+ export type PreflightCheckType = 'lint' | 'tests' | 'secrets' | 'evidence' | 'version';
16
+ /** Individual check status */
17
+ export interface PreflightCheckResult {
18
+ type: PreflightCheckType;
19
+ status: 'pass' | 'fail' | 'skip' | 'error';
20
+ message: string;
21
+ details?: Record<string, unknown>;
22
+ durationMs?: number;
23
+ }
24
+ /** Preflight report structure */
25
+ export interface PreflightReport {
26
+ id: string;
27
+ timestamp: number;
28
+ phase: number;
29
+ overall: 'pass' | 'fail' | 'skipped';
30
+ checks: PreflightCheckResult[];
31
+ totalDurationMs: number;
32
+ message: string;
33
+ }
34
+ /** Preflight configuration */
35
+ export interface PreflightConfig {
36
+ /** Timeout per check in ms (default 60s, min 5s, max 300s) */
37
+ checkTimeoutMs?: number;
38
+ /** Skip tests check (default false) */
39
+ skipTests?: boolean;
40
+ /** Skip secrets check (default false) */
41
+ skipSecrets?: boolean;
42
+ /** Skip evidence check (default false) */
43
+ skipEvidence?: boolean;
44
+ /** Skip version check (default false) */
45
+ skipVersion?: boolean;
46
+ /** Test scope (default 'convention' for faster preflight) */
47
+ testScope?: 'all' | 'convention' | 'graph';
48
+ /** Linter to use (default 'biome') */
49
+ linter?: 'biome' | 'eslint';
50
+ }
51
+ /**
52
+ * Run all preflight checks
53
+ */
54
+ export declare function runPreflight(dir: string, phase: number, config?: PreflightConfig): Promise<PreflightReport>;
55
+ /**
56
+ * Format preflight report as markdown
57
+ */
58
+ export declare function formatPreflightMarkdown(report: PreflightReport): string;
59
+ /**
60
+ * Handle preflight command - thin adapter for CLI
61
+ */
62
+ export declare function handlePreflightCommand(directory: string, _args: string[]): Promise<string>;
@@ -0,0 +1,28 @@
1
+ import type { AgentDefinition } from '../agents';
2
+ /**
3
+ * Structured status data returned by the status service.
4
+ * This can be used by GUI, background flows, or command adapters.
5
+ */
6
+ export interface StatusData {
7
+ hasPlan: boolean;
8
+ currentPhase: string;
9
+ completedTasks: number;
10
+ totalTasks: number;
11
+ agentCount: number;
12
+ isLegacy: boolean;
13
+ }
14
+ /**
15
+ * Get status data from the swarm directory.
16
+ * Returns structured data that can be used by GUI, background flows, or commands.
17
+ */
18
+ export declare function getStatusData(directory: string, agents: Record<string, AgentDefinition>): Promise<StatusData>;
19
+ /**
20
+ * Format status data as markdown for command output.
21
+ * This is the thin adapter that delegates to the service.
22
+ */
23
+ export declare function formatStatusMarkdown(status: StatusData): string;
24
+ /**
25
+ * Handle status command - delegates to service and formats output.
26
+ * Kept for backward compatibility - thin adapter.
27
+ */
28
+ export declare function handleStatusCommand(directory: string, agents: Record<string, AgentDefinition>): Promise<string>;
@@ -28,4 +28,8 @@ export interface SecretscanErrorResult {
28
28
  skipped_files: 0;
29
29
  }
30
30
  export declare const secretscan: ReturnType<typeof tool>;
31
+ /**
32
+ * Run secretscan programmatically
33
+ */
34
+ export declare function runSecretscan(directory: string): Promise<SecretscanResult | SecretscanErrorResult>;
31
35
  export {};