pipeline-sdk 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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +146 -0
  3. package/package.json +63 -0
  4. package/schemas/pipeline.schema.json +158 -0
  5. package/src/adapters/claude-code.ts +112 -0
  6. package/src/adapters/detector.ts +26 -0
  7. package/src/adapters/generic.ts +30 -0
  8. package/src/adapters/interface.ts +7 -0
  9. package/src/cli/advance.ts +27 -0
  10. package/src/cli/cleanup.ts +55 -0
  11. package/src/cli/helpers.ts +52 -0
  12. package/src/cli/index.ts +92 -0
  13. package/src/cli/init.ts +248 -0
  14. package/src/cli/resume.ts +45 -0
  15. package/src/cli/signal.ts +21 -0
  16. package/src/cli/start.ts +33 -0
  17. package/src/cli/status.ts +24 -0
  18. package/src/cli/template.ts +28 -0
  19. package/src/cli/validate.ts +21 -0
  20. package/src/cli/verify.ts +33 -0
  21. package/src/cli/visualize.ts +36 -0
  22. package/src/core/cleanup.ts +75 -0
  23. package/src/core/evidence.ts +144 -0
  24. package/src/core/gate-runner.ts +109 -0
  25. package/src/core/loader.ts +125 -0
  26. package/src/core/state-machine.ts +119 -0
  27. package/src/daemon/ipc.ts +56 -0
  28. package/src/daemon/server.ts +144 -0
  29. package/src/daemon/state-file.ts +65 -0
  30. package/src/gates/async.ts +60 -0
  31. package/src/gates/builtin.ts +40 -0
  32. package/src/gates/custom.ts +71 -0
  33. package/src/index.ts +20 -0
  34. package/src/mcp/prompts.ts +40 -0
  35. package/src/mcp/resources.ts +71 -0
  36. package/src/mcp/server.ts +211 -0
  37. package/src/mcp/tools.ts +52 -0
  38. package/src/templates/infra-gitops.yaml +37 -0
  39. package/src/templates/sdlc-full.yaml +69 -0
  40. package/src/templates/static-site.yaml +45 -0
  41. package/src/templates/zship.yaml +224 -0
  42. package/src/types.ts +210 -0
package/src/types.ts ADDED
@@ -0,0 +1,210 @@
1
+ // ─── Pipeline Definition (YAML → parsed) ─────────────────
2
+
3
+ export interface PipelineDefinition {
4
+ id: string;
5
+ version: number;
6
+ description?: string;
7
+ initial: string;
8
+ execution?: ExecutionConfig;
9
+ stages: Record<string, StageDefinition>;
10
+ gates?: Record<string, GateDefinition>;
11
+ conditions?: Record<string, ConditionDefinition>;
12
+ }
13
+
14
+ export interface ExecutionConfig {
15
+ provider?: string;
16
+ mode?: "daemon" | "binary";
17
+ timeout?: string;
18
+ evidence_dir?: string;
19
+ webhook_port?: number;
20
+ webhook_secret?: string;
21
+ }
22
+
23
+ export interface StageDefinition {
24
+ description?: string;
25
+ type?: "terminal" | "parallel-child";
26
+ agent?: AgentConfig;
27
+ gates?: { entry?: string[]; exit?: string[] };
28
+ on?: Record<string, TransitionDefinition>;
29
+ parallel?: string[];
30
+ when?: string;
31
+ max_retries?: number;
32
+ cleanup?: CleanupHandler[];
33
+ on_enter?: OnEnterAction[];
34
+ trigger?: TriggerConfig;
35
+ }
36
+
37
+ export interface AgentConfig {
38
+ instructions?: string;
39
+ tools?: string[];
40
+ model?: string;
41
+ mode?: string;
42
+ }
43
+
44
+ export interface TransitionDefinition {
45
+ target: string;
46
+ guard?: string;
47
+ }
48
+
49
+ export interface GateDefinition {
50
+ type: "builtin" | "custom" | "async";
51
+ command?: string;
52
+ script?: string;
53
+ protocol?: string;
54
+ signal?: string;
55
+ timeout?: string;
56
+ escalate_after?: string;
57
+ expect?: Record<string, unknown>;
58
+ inputs?: Record<string, unknown>;
59
+ when?: string;
60
+ }
61
+
62
+ export interface ConditionDefinition {
63
+ check: string;
64
+ pattern?: string;
65
+ path?: string;
66
+ not?: string;
67
+ }
68
+
69
+ export interface CleanupHandler {
70
+ script: string;
71
+ inputs?: Record<string, unknown>;
72
+ }
73
+
74
+ export interface OnEnterAction {
75
+ script: string;
76
+ inputs?: Record<string, unknown>;
77
+ }
78
+
79
+ export interface TriggerConfig {
80
+ type: "schedule";
81
+ cron: string;
82
+ }
83
+
84
+ // ─── Runtime State ────────────────────────────────────────
85
+
86
+ export interface PipelineState {
87
+ pipeline_id: string;
88
+ current_stage: string;
89
+ started_at: string;
90
+ stages_completed: string[];
91
+ retry_count: Record<string, number>;
92
+ evidence_chain_head: string | null;
93
+ cleanup_pending?: string[];
94
+ }
95
+
96
+ // ─── Evidence ─────────────────────────────────────────────
97
+
98
+ export interface EvidenceRecord {
99
+ stage_id: string;
100
+ pipeline_id: string;
101
+ timestamp: string;
102
+ duration_ms: number;
103
+ agent: { provider: string; model?: string; session_id?: string };
104
+ gates_passed: GateResult[];
105
+ artifacts: ArtifactRef[];
106
+ git: { tree_sha: string; branch?: string; files_changed?: number };
107
+ previous_evidence_hash: string | null;
108
+ evidence_hash: string;
109
+ }
110
+
111
+ export interface GateResult {
112
+ gate: string;
113
+ exit_code: number;
114
+ duration_ms: number;
115
+ evidence?: { type: string; hash: string };
116
+ }
117
+
118
+ export interface ArtifactRef {
119
+ type: string;
120
+ path: string;
121
+ hash: string;
122
+ }
123
+
124
+ // ─── Gate Protocol ────────────────────────────────────────
125
+
126
+ export interface GateInput {
127
+ gate_id: string;
128
+ stage_id: string;
129
+ pipeline_id: string;
130
+ inputs: Record<string, unknown>;
131
+ evidence_chain: Array<{ stage: string; hash: string }>;
132
+ workspace: { root: string; packages?: string[] };
133
+ context: {
134
+ branch: string;
135
+ commit: string;
136
+ provider: string;
137
+ session_id?: string;
138
+ };
139
+ }
140
+
141
+ export interface GateVerdict {
142
+ status: "pass" | "fail" | "skip";
143
+ evidence?: {
144
+ type: string;
145
+ summary: string;
146
+ artifacts: ArtifactRef[];
147
+ details?: Record<string, unknown>;
148
+ };
149
+ message: string;
150
+ suggested_action?: string;
151
+ }
152
+
153
+ // ─── IPC Protocol ─────────────────────────────────────────
154
+
155
+ export interface IpcRequest {
156
+ type: "tool_check" | "advance" | "signal" | "status";
157
+ tool?: string;
158
+ command?: string;
159
+ event?: string;
160
+ signal?: string;
161
+ evidence?: Record<string, unknown>;
162
+ stage?: string;
163
+ session_id?: string;
164
+ source?: string;
165
+ }
166
+
167
+ export interface IpcResponse {
168
+ verdict?: "allow" | "deny" | "transition";
169
+ allowed?: boolean;
170
+ reason?: string;
171
+ current_stage?: string;
172
+ allowed_tools?: string[];
173
+ blocked_commands?: string[];
174
+ transitioned?: boolean;
175
+ new_stage?: string;
176
+ received?: boolean;
177
+ gate_cleared?: string;
178
+ stage?: string;
179
+ gates_remaining?: string[];
180
+ elapsed?: string;
181
+ completed_stages?: string[];
182
+ allowed_events?: string[];
183
+ error?: string;
184
+ }
185
+
186
+ // ─── Provider Adapter ─────────────────────────────────────
187
+
188
+ export interface ProviderCapabilities {
189
+ name: string;
190
+ hooks: boolean;
191
+ parallel: boolean;
192
+ session: boolean;
193
+ headless: boolean;
194
+ mcp: boolean;
195
+ }
196
+
197
+ export interface StageRequest {
198
+ stage_id: string;
199
+ instructions: string;
200
+ tools: string[];
201
+ context: Record<string, unknown>;
202
+ timeout?: number;
203
+ }
204
+
205
+ export interface StageOutput {
206
+ artifacts: ArtifactRef[];
207
+ stdout: string;
208
+ exit_code: number;
209
+ duration_ms: number;
210
+ }