@cristochang/spec-execution 0.1.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.
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Executor Interface
3
+ *
4
+ * Generic executor interface for running AI agents.
5
+ * Ralph is just one implementation; other executors can be plugged in.
6
+ */
7
+ import type { AssembledContext } from "../context.js";
8
+ /**
9
+ * Result from an executor execution
10
+ *
11
+ * Plain data structure - no logic, just the raw result
12
+ */
13
+ export interface ExecutorResult {
14
+ readonly success: boolean;
15
+ readonly output?: unknown;
16
+ readonly error?: unknown;
17
+ readonly tool?: string;
18
+ readonly filesModified?: string[];
19
+ readonly duration?: number;
20
+ }
21
+ /**
22
+ * Create a successful executor result
23
+ */
24
+ export declare function createSuccessResult(output: unknown, tool?: string, filesModified?: string[]): ExecutorResult;
25
+ /**
26
+ * Create a failed executor result
27
+ */
28
+ export declare function createFailureResult(error: unknown, tool?: string): ExecutorResult;
29
+ /**
30
+ * Generic executor interface
31
+ *
32
+ * Any AI agent can implement this to be used with spec-execution.
33
+ * The orchestrator doesn't care what's inside - only the result matters.
34
+ */
35
+ export interface Executor {
36
+ /**
37
+ * Execute with the given context
38
+ *
39
+ * @param context - Assembled execution context
40
+ * @returns Raw execution result
41
+ */
42
+ execute(context: AssembledContext): Promise<ExecutorResult>;
43
+ }
44
+ /**
45
+ * Check if an executor is available
46
+ */
47
+ export declare function isExecutorAvailable(executor: unknown): executor is Executor;
48
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/runner/executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAMrD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,IAAI,CAAC,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,cAAc,CAOhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,IAAI,CAAC,EAAE,MAAM,GACZ,cAAc,CAMhB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CAC5D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAO3E"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Runner Module
3
+ *
4
+ * Generic executor interface + Ralph adapter + Execution session orchestrator
5
+ */
6
+ export * from "./executor.js";
7
+ export * from "./ralph.js";
8
+ export * from "./session.js";
9
+ export type { ExecutionSessionConfig, SessionState, SessionStatus, IterationResult, } from "./session.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runner/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAG5B,YAAY,EACV,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,MAAM,cAAc,CAAA"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Ralph Adapter
3
+ *
4
+ * Thin adapter for Ralph Wiggum executor.
5
+ * No business logic - only call + translate.
6
+ */
7
+ import type { Executor, ExecutorResult } from "./executor.js";
8
+ import type { AssembledContext } from "../context.js";
9
+ export interface RalphConfig {
10
+ readonly command?: string;
11
+ readonly args?: readonly string[];
12
+ readonly timeout?: number;
13
+ readonly cwd?: string;
14
+ readonly apiUrl?: string;
15
+ }
16
+ export declare const DEFAULT_RALPH_CONFIG: RalphConfig;
17
+ export interface RalphInput {
18
+ readonly context: {
19
+ readonly prompt: string;
20
+ readonly tools: readonly string[];
21
+ readonly maxIterations: number;
22
+ };
23
+ readonly config: RalphConfig;
24
+ }
25
+ export interface RalphResult {
26
+ readonly success: boolean;
27
+ readonly output?: unknown;
28
+ readonly error?: unknown;
29
+ readonly lastTool?: string;
30
+ readonly filesModified?: string[];
31
+ }
32
+ export declare class RalphAdapter implements Executor {
33
+ private readonly _config;
34
+ constructor(config?: RalphConfig);
35
+ execute(context: AssembledContext): Promise<ExecutorResult>;
36
+ /**
37
+ * Call Ralph - IMPLEMENT THIS based on your Ralph setup
38
+ *
39
+ * Examples:
40
+ * - Spawn Ralph as child process
41
+ * - Call Ralph's HTTP API
42
+ * - Import Ralph module directly
43
+ */
44
+ private _callRalph;
45
+ }
46
+ export declare function createRalphAdapter(config?: RalphConfig): RalphAdapter;
47
+ export type { Executor, ExecutorResult };
48
+ //# sourceMappingURL=ralph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ralph.d.ts","sourceRoot":"","sources":["../../src/runner/ralph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAIrD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAA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 4. Result recording
9
+ * 5. Completion detection
10
+ * 6. Iteration
11
+ *
12
+ * The session owns all state; the executor is just a tool.
13
+ */
14
+ import type { SpecInfo } from "../types.js";
15
+ import { type GateResult } from "../gate.js";
16
+ import { type ExecutionContract } from "../contract.js";
17
+ import { ExecutionState, type CriteriaProgress } from "../state.js";
18
+ import { FailureMemory, type FailureMemoryConfig } from "../failure.js";
19
+ import { type AssembleOptions } from "../context.js";
20
+ import type { CompletionRecommendation } from "../completion.js";
21
+ import type { Executor, ExecutorResult } from "./executor.js";
22
+ /**
23
+ * Execution session configuration
24
+ */
25
+ export interface ExecutionSessionConfig {
26
+ readonly maxIterations: number;
27
+ readonly failureMemory: FailureMemoryConfig;
28
+ readonly contextAssembler?: AssembleOptions;
29
+ readonly executor: Executor;
30
+ }
31
+ /**
32
+ * Default session configuration
33
+ */
34
+ export declare const DEFAULT_SESSION_CONFIG: ExecutionSessionConfig;
35
+ /**
36
+ * Current state of an execution session
37
+ */
38
+ export interface SessionState {
39
+ readonly iteration: number;
40
+ readonly status: SessionStatus;
41
+ readonly startedAt: number;
42
+ readonly lastUpdate: number;
43
+ }
44
+ /**
45
+ * Session status
46
+ */
47
+ export type SessionStatus = "idle" | "running" | "paused" | "completed" | "blocked" | "failed" | "aborted";
48
+ /**
49
+ * Execution Session
50
+ *
51
+ * Orchestrates the execution loop. Owns all state; coordinates:
52
+ * - Gate checks (before execution)
53
+ * - Context assembly (for executor)
54
+ * - Result recording (after execution)
55
+ * - Completion detection (for exit)
56
+ */
57
+ export declare class ExecutionSession {
58
+ private readonly _config;
59
+ private readonly _spec;
60
+ private readonly _state;
61
+ private readonly _failures;
62
+ private readonly _contract;
63
+ private _sessionStatus;
64
+ private _iteration;
65
+ private _startedAt;
66
+ private _lastUpdate;
67
+ private _completionRecommendation;
68
+ constructor(spec: SpecInfo | null, config: ExecutionSessionConfig);
69
+ /**
70
+ * Get the current session state
71
+ */
72
+ getSessionState(): SessionState;
73
+ /**
74
+ * Get the completion recommendation (if any)
75
+ */
76
+ getCompletionRecommendation(): CompletionRecommendation | null;
77
+ /**
78
+ * Get the execution contract
79
+ */
80
+ getContract(): ExecutionContract | null;
81
+ /**
82
+ * Get the execution state
83
+ */
84
+ getExecutionState(): ExecutionState;
85
+ /**
86
+ * Get the failure memory
87
+ */
88
+ getFailureMemory(): FailureMemory;
89
+ /**
90
+ * Check if session is blocked by failures (for gate check)
91
+ */
92
+ isBlockedByFailures(): boolean;
93
+ /**
94
+ * Run one execution iteration
95
+ *
96
+ * This is the core loop method:
97
+ * 1. Gate check
98
+ * 2. Context assembly
99
+ * 3. Executor execution
100
+ * 4. Result recording
101
+ * 5. Completion detection
102
+ *
103
+ * @returns Result of the iteration
104
+ */
105
+ runIteration(): Promise<IterationResult>;
106
+ /**
107
+ * Run the full execution loop until completion
108
+ *
109
+ * @returns Final session state
110
+ */
111
+ run(): Promise<SessionState>;
112
+ /**
113
+ * Abort the session
114
+ */
115
+ abort(): void;
116
+ /**
117
+ * Step 1: Gate check
118
+ */
119
+ private _checkGate;
120
+ /**
121
+ * Step 2: Context assembly
122
+ */
123
+ private _assembleContext;
124
+ /**
125
+ * Step 3: Executor execution
126
+ */
127
+ private _execute;
128
+ /**
129
+ * Step 4: Record result
130
+ */
131
+ private _recordResult;
132
+ /**
133
+ * Step 5: Check completion
134
+ */
135
+ private _checkCompletion;
136
+ /**
137
+ * Build completion evidence from current state
138
+ */
139
+ private _buildEvidence;
140
+ /**
141
+ * Get criterion text by ID
142
+ */
143
+ private _getCriterionText;
144
+ /**
145
+ * Map gate reason to session status
146
+ */
147
+ private _mapGateReasonToStatus;
148
+ }
149
+ /**
150
+ * Result of a single iteration
151
+ */
152
+ export interface IterationResult {
153
+ readonly continue: boolean;
154
+ readonly reason?: string;
155
+ readonly gateResult?: GateResult;
156
+ readonly executorResult?: ExecutorResult;
157
+ readonly progress?: CriteriaProgress;
158
+ readonly completion?: CompletionRecommendation;
159
+ }
160
+ /**
161
+ * Create an execution session
162
+ */
163
+ export declare function createSession(spec: SpecInfo | null, config: ExecutionSessionConfig): ExecutionSession;
164
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/runner/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAyB,MAAM,aAAa,CAAA;AAC1F,OAAO,EAAE,aAAa,EAAoB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACzF,OAAO,EAA2C,KAAK,eAAe,EAAsB,MAAM,eAAe,CAAA;AAEjH,OAAO,KAAK,EAAE,wBAAwB,EAAsB,MAAM,kBAAkB,CAAA;AACpF,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAM7D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAA;IAC3C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,eAAe,CAAA;IAC3C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,sBAOpC,CAAA;AAMD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,M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AOtB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAKzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAa/B;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAA;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAA;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAA;IACpC,QAAQ,CAAC,UAAU,CAAC,EAAE,wBAAwB,CAAA;CAC/C;AAMD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,MAAM,EAAE,sBAAsB,GAC7B,gBAAgB,CAElB"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Execution State
3
+ *
4
+ * Tracks the progress of an execution session:
5
+ * - Files touched
6
+ * - Criteria status (partial completion tracking)
7
+ * - Tool call history
8
+ */
9
+ import type { CriterionStatus } from "./types.js";
10
+ /**
11
+ * Progress summary for all criteria
12
+ */
13
+ export interface CriteriaProgress {
14
+ readonly total: number;
15
+ readonly pending: number;
16
+ readonly inProgress: number;
17
+ readonly satisfied: number;
18
+ readonly verified: number;
19
+ readonly blocked: number;
20
+ readonly failed: number;
21
+ readonly percentage: number;
22
+ }
23
+ /**
24
+ * Compute progress from criteria status counts
25
+ */
26
+ export declare function computeProgress(counts: Record<CriterionStatus, number>, total: number): CriteriaProgress;
27
+ /**
28
+ * Summary of a tool call for tracking
29
+ */
30
+ export interface ToolCallSummary {
31
+ readonly tool: string;
32
+ readonly success: boolean;
33
+ readonly timestamp: number;
34
+ readonly files?: readonly string[];
35
+ readonly error?: string;
36
+ }
37
+ /**
38
+ * Create a tool call summary
39
+ */
40
+ export declare function createToolCallSummary(tool: string, success: boolean, files?: string[], error?: string): ToolCallSummary;
41
+ /**
42
+ * Execution state tracks progress during a session
43
+ */
44
+ export declare class ExecutionState {
45
+ private readonly _filesTouched;
46
+ private readonly _criteriaStatus;
47
+ private readonly _criteriaVerifiedAt;
48
+ private readonly _criteriaVerificationMethod;
49
+ private _lastToolCall?;
50
+ private _startedAt;
51
+ private _lastUpdated;
52
+ constructor();
53
+ /**
54
+ * Initialize criteria from a list of criterion IDs
55
+ */
56
+ initializeCriteria(criterionIds: readonly string[]): void;
57
+ /**
58
+ * Get the status of a criterion
59
+ */
60
+ getCriterionStatus(criterionId: string): CriterionStatus | undefined;
61
+ /**
62
+ * Set the status of a criterion
63
+ */
64
+ setCriterionStatus(criterionId: string, status: CriterionStatus, verifiedAt?: string, verificationMethod?: string): void;
65
+ /**
66
+ * Get all criteria statuses
67
+ */
68
+ getAllCriteriaStatus(): ReadonlyMap<string, CriterionStatus>;
69
+ /**
70
+ * Mark a file as touched
71
+ */
72
+ touchFile(file: string): void;
73
+ /**
74
+ * Mark multiple files as touched
75
+ */
76
+ touchFiles(files: readonly string[]): void;
77
+ /**
78
+ * Check if a file has been touched
79
+ */
80
+ hasTouchedFile(file: string): boolean;
81
+ /**
82
+ * Get all touched files
83
+ */
84
+ getTouchedFiles(): readonly string[];
85
+ /**
86
+ * Get count of touched files
87
+ */
88
+ getTouchedFileCount(): number;
89
+ /**
90
+ * Record a tool call
91
+ */
92
+ recordToolCall(summary: ToolCallSummary): void;
93
+ /**
94
+ * Get the last tool call summary
95
+ */
96
+ getLastToolCall(): ToolCallSummary | undefined;
97
+ /**
98
+ * Get progress summary for all criteria
99
+ */
100
+ getProgress(): CriteriaProgress;
101
+ /**
102
+ * Check if all criteria are verified
103
+ */
104
+ isAllVerified(): boolean;
105
+ /**
106
+ * Get criteria with a specific status
107
+ */
108
+ getCriteriaByStatus(status: CriterionStatus): string[];
109
+ /**
110
+ * Get the next pending criterion
111
+ */
112
+ getNextPendingCriterion(): string | undefined;
113
+ /**
114
+ * Get session duration in milliseconds
115
+ */
116
+ getDuration(): number;
117
+ /**
118
+ * Create a snapshot of the current state
119
+ */
120
+ snapshot(): ExecutionStateSnapshot;
121
+ /**
122
+ * Update internal timestamp
123
+ */
124
+ private _touch;
125
+ }
126
+ /**
127
+ * Immutable snapshot of execution state
128
+ */
129
+ export interface ExecutionStateSnapshot {
130
+ readonly filesTouched: readonly string[];
131
+ readonly criteriaStatus: Record<string, CriterionStatus>;
132
+ readonly lastToolCall?: ToolCallSummary;
133
+ readonly startedAt: number;
134
+ readonly lastUpdated: number;
135
+ readonly duration: number;
136
+ }
137
+ /**
138
+ * Restore execution state from a snapshot
139
+ */
140
+ export declare function restoreFromSnapshot(snapshot: ExecutionStateSnapshot): ExecutionState;
141
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAMjD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAWxG;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA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AAE,MAAM,GAAG,OAAO;IAIrC;;OAEG;IACH,eAAe,IAAI,SAAS,MAAM,EAAE;IAIpC;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAI7B;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAK9C;;OAEG;IACH,eAAe,IAAI,eAAe,GAAG,SAAS;IAI9C;;OAEG;IACH,WAAW,IAAI,gBAAgB;IAiB/B;;OAEG;IACH,aAAa,IAAI,OAAO;IAQxB;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,EAAE;IAUtD;;OAEG;IACH,uBAAuB,IAAI,MAAM,GAAG,SAAS;IAS7C;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,QAAQ,IAAI,sBAAsB;IAWlC;;OAEG;IACH,OAAO,CAAC,MAAM;CAGf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACxD,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAA;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,cAAc,CAyBpF"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @cristochang/spec-execution
3
+ *
4
+ * Core type definitions for the execution orchestration layer
5
+ */
6
+ /**
7
+ * The status of a single success criterion during execution
8
+ */
9
+ export type CriterionStatus = "pending" | "in_progress" | "satisfied" | "verified" | "blocked" | "failed";
10
+ /**
11
+ * A single success criterion with execution status
12
+ */
13
+ export interface SuccessCriterion {
14
+ id: string;
15
+ description: string;
16
+ status: CriterionStatus;
17
+ verifiedAt?: string;
18
+ verificationMethod?: string;
19
+ }
20
+ /**
21
+ * Verification mode determines how completion is verified
22
+ */
23
+ export type VerificationMode = "none" | "manual" | "automated";
24
+ /**
25
+ * Verification configuration
26
+ */
27
+ export interface VerificationConfig {
28
+ mode: VerificationMode;
29
+ }
30
+ /**
31
+ * Reasons why execution is denied
32
+ */
33
+ export type GateDeniedReason = "spec_not_found" | "spec_cancelled" | "spec_already_implemented" | "spec_not_approved" | "max_iterations_exceeded" | "blocked_by_failures";
34
+ /**
35
+ * Gate check result
36
+ */
37
+ export interface Gate {
38
+ readonly allowed: boolean;
39
+ readonly reason?: GateDeniedReason;
40
+ }
41
+ /**
42
+ * Boundary constraints for execution
43
+ */
44
+ export interface Boundaries {
45
+ readonly objective: string;
46
+ readonly inclusions: readonly string[];
47
+ readonly exclusions: readonly string[];
48
+ readonly constraints: readonly string[];
49
+ readonly maxIterations: number;
50
+ }
51
+ /**
52
+ * Completion configuration from the contract
53
+ */
54
+ export interface CompletionConfig {
55
+ readonly criteria: readonly SuccessCriterion[];
56
+ readonly verification: VerificationConfig;
57
+ }
58
+ /**
59
+ * Immutable snapshot of Spec state at contract creation
60
+ */
61
+ export interface SpecSnapshot {
62
+ readonly id: string;
63
+ readonly status: string;
64
+ readonly created: string;
65
+ }
66
+ /**
67
+ * Empty boundaries constant
68
+ */
69
+ export declare const EMPTY_BOUNDARIES: Boundaries;
70
+ /**
71
+ * Empty completion config constant
72
+ */
73
+ export declare const EMPTY_COMPLETION: CompletionConfig;
74
+ /**
75
+ * Empty spec snapshot constant
76
+ */
77
+ export declare const EMPTY_SNAPSHOT: SpecSnapshot;
78
+ /**
79
+ * Execution Contract
80
+ *
81
+ * Read-only adjudication structure derived from SpecInfo.
82
+ * Describes "what is allowed" and "how to judge completion".
83
+ * Does NOT contain execution commands.
84
+ */
85
+ export interface ExecutionContract {
86
+ /**
87
+ * Gate check - determines if execution is allowed
88
+ */
89
+ readonly gate: Gate;
90
+ /**
91
+ * Boundary constraints
92
+ */
93
+ readonly boundaries: Boundaries;
94
+ /**
95
+ * Completion conditions
96
+ */
97
+ readonly completion: CompletionConfig;
98
+ /**
99
+ * Spec state snapshot at contract creation
100
+ */
101
+ readonly specSnapshot: SpecSnapshot;
102
+ }
103
+ /**
104
+ * Import SpecInfo from spec-core for type references
105
+ * This is a re-export type to avoid requiring the full dependency
106
+ */
107
+ export type SpecInfo = {
108
+ readonly id: string;
109
+ readonly created: string;
110
+ readonly status: string;
111
+ readonly objective: string;
112
+ readonly scope: {
113
+ readonly inclusions: readonly string[];
114
+ readonly exclusions: readonly string[];
115
+ };
116
+ readonly successCriteria: readonly string[];
117
+ readonly constraints?: readonly string[];
118
+ readonly implementationNotes?: string;
119
+ readonly changes?: readonly string[];
120
+ readonly verification?: string;
121
+ };
122
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,aAAa,GACb,WAAW,GACX,UAAU,GACV,SAAS,GACT,QAAQ,CAAA;AAEZ;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAMD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAA;CACvB;AAMD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,gBAAgB,GAChB,0BAA0B,GAC1B,mBAAm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CACpC;AAMD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;QACtC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;KACvC,CAAA;IACD,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC/B,CAAA"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@cristochang/spec-execution",
3
+ "version": "0.1.0",
4
+ "description": "Spec execution orchestration layer for OpenCode",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "bun run build:js && bun run build:dts",
21
+ "build:js": "bunx esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:@cristochang/spec-core",
22
+ "build:dts": "bunx tsc --emitDeclarationOnly",
23
+ "test": "bun test"
24
+ },
25
+ "keywords": [
26
+ "opencode",
27
+ "spec",
28
+ "execution",
29
+ "orchestration",
30
+ "workflow"
31
+ ],
32
+ "author": "OpenCode",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "@cristochang/spec-core": "^0.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "22.13.9",
39
+ "esbuild": "0.27.2",
40
+ "typescript": "^5.0.0"
41
+ },
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ }
45
+ }