stageflow 0.3.0 → 0.9.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 (164) hide show
  1. package/README.md +44 -14
  2. package/dist/agent/activity.d.ts +2 -0
  3. package/dist/agent/cursorProvider.d.ts +1 -10
  4. package/dist/agent/cursorProvider.js +18 -10
  5. package/dist/agent/fakeAgent.js +11 -7
  6. package/dist/agent/piAdapter.d.ts +2 -1
  7. package/dist/agent/piAdapter.js +28 -25
  8. package/dist/agent/port.d.ts +6 -1
  9. package/dist/agent/port.js +3 -0
  10. package/dist/cli/artifactCommand.d.ts +10 -0
  11. package/dist/cli/artifactCommand.js +120 -0
  12. package/dist/cli/envelopeCommand.d.ts +32 -0
  13. package/dist/cli/envelopeCommand.js +285 -0
  14. package/dist/cli/exportRunCommand.d.ts +10 -0
  15. package/dist/cli/exportRunCommand.js +150 -0
  16. package/dist/cli/handoffFormat.d.ts +22 -0
  17. package/dist/cli/handoffFormat.js +61 -0
  18. package/dist/cli/runCommand.d.ts +5 -1
  19. package/dist/cli/runCommand.js +36 -5
  20. package/dist/cli/runOutput.d.ts +4 -1
  21. package/dist/cli/runOutput.js +36 -8
  22. package/dist/cli/runsCommand.d.ts +22 -0
  23. package/dist/cli/runsCommand.js +591 -0
  24. package/dist/cli/skillsCommand.d.ts +16 -0
  25. package/dist/cli/skillsCommand.js +459 -0
  26. package/dist/cli/validateOutput.d.ts +2 -2
  27. package/dist/cli/validateOutput.js +2 -2
  28. package/dist/cli.js +110 -5
  29. package/dist/config/loadPipeline.js +5 -1
  30. package/dist/config/normalizePipelineStageEntry.d.ts +2 -0
  31. package/dist/config/normalizePipelineStageEntry.js +25 -1
  32. package/dist/config/pipelineStageKeys.js +1 -1
  33. package/dist/config/resolveForkEmitContext.d.ts +2 -1
  34. package/dist/config/resolveForkEmitContext.js +23 -1
  35. package/dist/config/resolvePipelineDag.js +36 -4
  36. package/dist/envelope/check.d.ts +2 -0
  37. package/dist/envelope/check.js +51 -0
  38. package/dist/envelope/cloneForks.d.ts +2 -0
  39. package/dist/envelope/cloneForks.js +62 -0
  40. package/dist/envelope/forkChoice.js +1 -1
  41. package/dist/index.d.ts +3 -1
  42. package/dist/index.js +3 -1
  43. package/dist/mcp/catalogTools.d.ts +3 -0
  44. package/dist/mcp/catalogTools.js +187 -0
  45. package/dist/mcp/controlTools.d.ts +3 -0
  46. package/dist/mcp/controlTools.js +147 -0
  47. package/dist/mcp/deps.d.ts +11 -0
  48. package/dist/mcp/deps.js +1 -0
  49. package/dist/mcp/projectRun.d.ts +1 -40
  50. package/dist/mcp/projectRun.js +1 -64
  51. package/dist/mcp/resources.d.ts +5 -0
  52. package/dist/mcp/resources.js +45 -0
  53. package/dist/mcp/server.d.ts +16 -3
  54. package/dist/mcp/server.js +159 -3
  55. package/dist/mcp/toolResults.d.ts +7 -0
  56. package/dist/mcp/toolResults.js +6 -0
  57. package/dist/mcp/tools.d.ts +2 -7
  58. package/dist/mcp/tools.js +52 -103
  59. package/dist/mcp/waitRun.d.ts +46 -0
  60. package/dist/mcp/waitRun.js +146 -0
  61. package/dist/mcp/waitingGates.d.ts +12 -0
  62. package/dist/mcp/waitingGates.js +83 -0
  63. package/dist/package-meta.d.ts +1 -0
  64. package/dist/package-meta.js +1 -0
  65. package/dist/projection/projectRun.d.ts +44 -0
  66. package/dist/projection/projectRun.js +71 -0
  67. package/dist/prompt/priorEnvelope.d.ts +1 -1
  68. package/dist/prompt/priorEnvelope.js +4 -1
  69. package/dist/runstore/paths.js +2 -0
  70. package/dist/runstore/pipelineDagSnapshot.d.ts +9 -0
  71. package/dist/runstore/pipelineDagSnapshot.js +90 -1
  72. package/dist/runstore/port.d.ts +13 -2
  73. package/dist/runstore/port.js +4 -1
  74. package/dist/runstore/runProjection.d.ts +1 -1
  75. package/dist/runstore/runProjection.js +14 -3
  76. package/dist/runstore/sqlite/SqliteRunStore.d.ts +3 -2
  77. package/dist/runstore/sqlite/SqliteRunStore.js +35 -3
  78. package/dist/runstore/stageInstanceId.d.ts +4 -0
  79. package/dist/runstore/stageInstanceId.js +23 -0
  80. package/dist/runstore/syntheticStageSnapshot.d.ts +1 -1
  81. package/dist/runstore/syntheticStageSnapshot.js +2 -1
  82. package/dist/runstore/trackProjection.js +28 -12
  83. package/dist/runstore/workspaceLayout.d.ts +1 -0
  84. package/dist/runstore/workspaceLayout.js +1 -1
  85. package/dist/runtime/cloneSchedule.d.ts +18 -0
  86. package/dist/runtime/cloneSchedule.js +233 -0
  87. package/dist/runtime/envelopeRouting.d.ts +2 -1
  88. package/dist/runtime/envelopeRouting.js +80 -13
  89. package/dist/runtime/pipelineScheduler.d.ts +6 -2
  90. package/dist/runtime/pipelineScheduler.js +166 -30
  91. package/dist/runtime/resumeReconstruct.js +8 -3
  92. package/dist/runtime/runChangeBus.d.ts +18 -0
  93. package/dist/runtime/runChangeBus.js +83 -0
  94. package/dist/runtime/runManager.d.ts +7 -0
  95. package/dist/runtime/runManager.js +31 -2
  96. package/dist/runtime/runRetryCoordinator.d.ts +2 -0
  97. package/dist/runtime/runRetryCoordinator.js +4 -1
  98. package/dist/runtime/stageAttemptBootstrap.d.ts +1 -0
  99. package/dist/runtime/stageAttemptBootstrap.js +17 -9
  100. package/dist/runtime/stageRunner.d.ts +1 -0
  101. package/dist/runtime/stageRunner.js +17 -15
  102. package/dist/runtime/stageWorker.js +11 -4
  103. package/dist/server/bootstrap.d.ts +32 -0
  104. package/dist/server/bootstrap.js +56 -0
  105. package/dist/server/createHttpHost.d.ts +34 -0
  106. package/dist/server/createHttpHost.js +70 -0
  107. package/dist/server/http.d.ts +6 -13
  108. package/dist/server/http.js +295 -374
  109. package/dist/server/mcpHost.d.ts +22 -0
  110. package/dist/server/mcpHost.js +21 -0
  111. package/dist/server/operatorResults.d.ts +13 -0
  112. package/dist/server/operatorResults.js +22 -0
  113. package/dist/tools/emitStageEnvelope.d.ts +11 -2
  114. package/dist/tools/emitStageEnvelope.js +22 -6
  115. package/dist/types/envelope.d.ts +2 -0
  116. package/dist/types/forkChoice.d.ts +22 -0
  117. package/dist/types/pipeline.d.ts +8 -0
  118. package/dist/ui/assets/{index-DefBlEvN.css → index-C3N7MXAC.css} +1 -1
  119. package/dist/ui/assets/index-CSoGDA3A.js +118 -0
  120. package/dist/ui/index.html +2 -2
  121. package/package.json +2 -1
  122. package/skills/install-suite.sh +107 -0
  123. package/skills/stageflow/SKILL.md +26 -0
  124. package/skills/stageflow/references/control-surface.md +28 -0
  125. package/skills/stageflow/scripts/detect-host.mjs +54 -0
  126. package/skills/stageflow/scripts/detect-host.test.mjs +97 -0
  127. package/skills/stageflow-author/SKILL.md +58 -0
  128. package/skills/stageflow-author/assets/examples/branch-decision/hotfix.yaml +10 -0
  129. package/skills/stageflow-author/assets/examples/branch-decision/release-gate.pipeline.yaml +12 -0
  130. package/skills/stageflow-author/assets/examples/branch-decision/run-tests.yaml +13 -0
  131. package/skills/stageflow-author/assets/examples/branch-decision/ship.yaml +10 -0
  132. package/skills/stageflow-author/assets/examples/linear-review/draft.yaml +9 -0
  133. package/skills/stageflow-author/assets/examples/linear-review/publish.yaml +10 -0
  134. package/skills/stageflow-author/assets/examples/linear-review/review-loop.pipeline.yaml +10 -0
  135. package/skills/stageflow-author/assets/examples/linear-review/review.yaml +15 -0
  136. package/skills/stageflow-author/assets/examples/non-sdlc-digest/gather.yaml +9 -0
  137. package/skills/stageflow-author/assets/examples/non-sdlc-digest/research-digest.pipeline.yaml +10 -0
  138. package/skills/stageflow-author/assets/examples/non-sdlc-digest/send.yaml +10 -0
  139. package/skills/stageflow-author/assets/examples/non-sdlc-digest/summarize.yaml +9 -0
  140. package/skills/stageflow-author/references/catalog-mapping.md +131 -0
  141. package/skills/stageflow-author/references/catalog-write-conventions.md +29 -0
  142. package/skills/stageflow-author/references/stage-prompt-template.md +55 -0
  143. package/skills/stageflow-author/references/validate-and-report.md +38 -0
  144. package/skills/stageflow-delegate/SKILL.md +18 -0
  145. package/skills/stageflow-delegate/references/authoring-or-run.md +15 -0
  146. package/skills/stageflow-delegate/references/example-walkthrough.md +30 -0
  147. package/skills/stageflow-delegate/references/pattern-detection.md +44 -0
  148. package/skills/stageflow-run/SKILL.md +182 -0
  149. package/skills/stageflow-run/references/mcp-call.md +17 -0
  150. package/skills/stageflow-run/references/native-question-ui.md +78 -0
  151. package/skills/stageflow-run/references/task-and-pipeline-selection.md +52 -0
  152. package/skills/stageflow-run/scripts/mcp-call.mjs +299 -0
  153. package/skills/stageflow-run/scripts/mcp-call.test.mjs +271 -0
  154. package/skills/stageflow-session-capture/SKILL.md +94 -0
  155. package/skills/stageflow-session-capture/assets/example-pipeline/example.pipeline.yaml +7 -0
  156. package/skills/stageflow-session-capture/assets/example-pipeline/implement.yaml +8 -0
  157. package/skills/stageflow-session-capture/assets/example-pipeline/research.yaml +8 -0
  158. package/skills/stageflow-session-capture/references/catalog-authoring.md +40 -0
  159. package/skills/stageflow-session-capture/references/transcript-sources.md +25 -0
  160. package/skills/stageflow-session-capture/scripts/check-provider-gate.mjs +43 -0
  161. package/skills/stageflow-session-capture/scripts/locate-session-transcript.mjs +141 -0
  162. package/skills/stageflow-session-capture/scripts/resolve-catalog-id.mjs +119 -0
  163. package/skills/stageflow-setup/SKILL.md +110 -0
  164. package/dist/ui/assets/index-CFSzDZje.js +0 -118
@@ -1,6 +1,7 @@
1
+ import type { RunStore } from "../runstore/port.js";
1
2
  import { type StartRunResult } from "../runtime/runManager.js";
2
3
  import { type CliRunReportIo } from "./runOutput.js";
3
- export declare const RUN_USAGE = "Usage:\n sf run --task <path> --pipeline <path> [--checkout <path>] [--json] [--skip-gates] [--git-sha <sha>] [--ci-pr-url <url>] [--ci-job-url <url>] [--operator-cwd <path>] [--operator-agent-dir <path>]";
4
+ export declare const RUN_USAGE = "Usage:\n sf run --task <path> --pipeline <path> [--checkout <path>] [--json] [--include stages] [--skip-gates] [--git-sha <sha>] [--ci-pr-url <url>] [--ci-job-url <url>] [--operator-cwd <path>] [--operator-agent-dir <path>]";
4
5
  export type RunCommandIo = CliRunReportIo;
5
6
  export type StartRunFn = (input: {
6
7
  task: string;
@@ -15,6 +16,8 @@ export declare function completeCliRun(started: Extract<StartRunResult, {
15
16
  ok: true;
16
17
  }>, io?: RunCommandIo, options?: {
17
18
  json?: boolean;
19
+ store?: RunStore;
20
+ includeStages?: boolean;
18
21
  }): Promise<number>;
19
22
  export declare function runRunCommand(args: string[], options?: {
20
23
  cwd?: string;
@@ -22,5 +25,6 @@ export declare function runRunCommand(args: string[], options?: {
22
25
  isGitProject?: boolean;
23
26
  io?: Partial<RunCommandIo>;
24
27
  startRun?: StartRunFn;
28
+ store?: RunStore;
25
29
  env?: Record<string, string | undefined>;
26
30
  }): Promise<number>;
@@ -8,17 +8,17 @@ import { resolveCiIdentity } from "./ciIdentity.js";
8
8
  import { resolveOperatorCatalog } from "./operatorCatalog.js";
9
9
  import { exitCodeForValidation, formatValidationHuman, formatValidationJson, } from "./validateOutput.js";
10
10
  export const RUN_USAGE = `Usage:
11
- sf run --task <path> --pipeline <path> [--checkout <path>] [--json] [--skip-gates] [--git-sha <sha>] [--ci-pr-url <url>] [--ci-job-url <url>] [--operator-cwd <path>] [--operator-agent-dir <path>]`;
11
+ sf run --task <path> --pipeline <path> [--checkout <path>] [--json] [--include stages] [--skip-gates] [--git-sha <sha>] [--ci-pr-url <url>] [--ci-job-url <url>] [--operator-cwd <path>] [--operator-agent-dir <path>]`;
12
12
  const defaultIo = {
13
13
  log: (line) => console.log(line),
14
14
  error: (line) => console.error(line),
15
15
  };
16
16
  function parseRunArgs(args) {
17
17
  if (args.length === 0) {
18
- return { help: false, json: false, skipGates: false };
18
+ return { help: false, json: false, includeStages: false, skipGates: false };
19
19
  }
20
20
  if (args[0] === "--help" || args[0] === "-h") {
21
- return { help: true, json: false, skipGates: false };
21
+ return { help: true, json: false, includeStages: false, skipGates: false };
22
22
  }
23
23
  let task;
24
24
  let pipeline;
@@ -29,6 +29,7 @@ function parseRunArgs(args) {
29
29
  let operatorCwd;
30
30
  let operatorAgentDir;
31
31
  let json = false;
32
+ let includeStages = false;
32
33
  let skipGates = false;
33
34
  let help = false;
34
35
  for (let i = 0; i < args.length; i++) {
@@ -95,6 +96,18 @@ function parseRunArgs(args) {
95
96
  else if (arg === "--json") {
96
97
  json = true;
97
98
  }
99
+ else if (arg === "--include") {
100
+ const value = args[++i];
101
+ if (value === undefined || value.length === 0) {
102
+ throw new Error("Missing value for --include");
103
+ }
104
+ if (value === "stages") {
105
+ includeStages = true;
106
+ }
107
+ else {
108
+ throw new Error(`Unknown --include value: ${value}`);
109
+ }
110
+ }
98
111
  else if (arg === "--skip-gates") {
99
112
  skipGates = true;
100
113
  }
@@ -108,6 +121,7 @@ function parseRunArgs(args) {
108
121
  return {
109
122
  help,
110
123
  json,
124
+ includeStages,
111
125
  skipGates,
112
126
  task,
113
127
  pipeline,
@@ -136,7 +150,12 @@ function defaultStartRun(cwd, projectRoot, isGitProject, operatorCatalog) {
136
150
  }
137
151
  export async function completeCliRun(started, io = defaultIo, options = {}) {
138
152
  const result = await started.done;
139
- return reportCliRun({ kind: "completion", result }, { json: options.json, io });
153
+ return reportCliRun({ kind: "completion", result }, {
154
+ json: options.json,
155
+ io,
156
+ store: options.store,
157
+ includeStages: options.includeStages,
158
+ });
140
159
  }
141
160
  export async function runRunCommand(args, options = {}) {
142
161
  const cwd = options.cwd ?? process.cwd();
@@ -162,6 +181,10 @@ export async function runRunCommand(args, options = {}) {
162
181
  out.error(RUN_USAGE);
163
182
  return 1;
164
183
  }
184
+ if (parsed.includeStages && !parsed.json) {
185
+ out.error("error: --include stages requires --json");
186
+ return 1;
187
+ }
165
188
  const operatorCatalog = resolveOperatorCatalog({
166
189
  flags: {
167
190
  operatorCwd: parsed.operatorCwd,
@@ -180,6 +203,10 @@ export async function runRunCommand(args, options = {}) {
180
203
  },
181
204
  env: options.env ?? process.env,
182
205
  });
206
+ const store = options.store ??
207
+ (parsed.includeStages
208
+ ? createRunStore({ rootDir: projectRoot })
209
+ : undefined);
183
210
  try {
184
211
  const started = await startRun({
185
212
  task: parsed.task,
@@ -191,7 +218,11 @@ export async function runRunCommand(args, options = {}) {
191
218
  if (!started.ok) {
192
219
  return reportCliRun({ kind: "start-failure", started }, { json: parsed.json, io: out });
193
220
  }
194
- return completeCliRun(started, out, { json: parsed.json });
221
+ return completeCliRun(started, out, {
222
+ json: parsed.json,
223
+ includeStages: parsed.includeStages,
224
+ store,
225
+ });
195
226
  }
196
227
  catch (err) {
197
228
  if (err instanceof PipelineValidationError) {
@@ -1,3 +1,4 @@
1
+ import type { RunStore } from "../runstore/port.js";
1
2
  import type { PipelineRunResult } from "../runtime/pipelineRunner.js";
2
3
  import type { StartRunResult } from "../runtime/runManager.js";
3
4
  export type CliRunReportIo = {
@@ -16,4 +17,6 @@ export type CliRunReportEvent = {
16
17
  export declare function reportCliRun(event: CliRunReportEvent, options: {
17
18
  json?: boolean;
18
19
  io: CliRunReportIo;
19
- }): number;
20
+ store?: RunStore;
21
+ includeStages?: boolean;
22
+ }): Promise<number>;
@@ -1,3 +1,4 @@
1
+ import { projectRun } from "../projection/projectRun.js";
1
2
  function stringify(payload) {
2
3
  return JSON.stringify(payload, null, 2);
3
4
  }
@@ -44,22 +45,22 @@ function formatStartFailureJson(started) {
44
45
  }
45
46
  return formatRunStartFailedJson(started);
46
47
  }
47
- function formatRunCompletionJson(result) {
48
+ function baseRunCompletionPayload(result) {
48
49
  if (result.outcome === "succeeded") {
49
- return stringify({
50
+ return {
50
51
  ok: true,
51
52
  outcome: "succeeded",
52
53
  runId: result.runId,
53
54
  runDir: result.runDir,
54
- });
55
+ };
55
56
  }
56
57
  if (result.outcome === "waiting") {
57
- return stringify({
58
+ return {
58
59
  ok: false,
59
60
  outcome: "waiting",
60
61
  runId: result.runId,
61
62
  runDir: result.runDir,
62
- });
63
+ };
63
64
  }
64
65
  const payload = {
65
66
  ok: false,
@@ -69,7 +70,18 @@ function formatRunCompletionJson(result) {
69
70
  };
70
71
  if (result.reason !== undefined)
71
72
  payload.reason = result.reason;
72
- return stringify(payload);
73
+ return payload;
74
+ }
75
+ function formatRunCompletionJson(result) {
76
+ return stringify(baseRunCompletionPayload(result));
77
+ }
78
+ async function formatRunCompletionJsonWithStages(result, store) {
79
+ const detail = await store.readRun(result.runId);
80
+ const projection = projectRun(detail);
81
+ return stringify({
82
+ ...baseRunCompletionPayload(result),
83
+ stages: projection.stages,
84
+ });
73
85
  }
74
86
  function writeStartFailureHuman(started, io) {
75
87
  const code = started.code ?? "error";
@@ -105,7 +117,7 @@ function exitCodeForRunOutcome(outcome) {
105
117
  return 1;
106
118
  }
107
119
  }
108
- export function reportCliRun(event, options) {
120
+ export async function reportCliRun(event, options) {
109
121
  if (event.kind === "start-failure") {
110
122
  if (options.json) {
111
123
  options.io.log(formatStartFailureJson(event.started));
@@ -116,7 +128,23 @@ export function reportCliRun(event, options) {
116
128
  return 1;
117
129
  }
118
130
  if (options.json) {
119
- options.io.log(formatRunCompletionJson(event.result));
131
+ if (options.includeStages) {
132
+ if (!options.store) {
133
+ options.io.error("error: --include stages requires an internal run store (report bug)");
134
+ return 1;
135
+ }
136
+ try {
137
+ options.io.log(await formatRunCompletionJsonWithStages(event.result, options.store));
138
+ }
139
+ catch (err) {
140
+ const message = err instanceof Error ? err.message : String(err);
141
+ options.io.error(`failed to read run for --include stages: ${message}`);
142
+ return 1;
143
+ }
144
+ }
145
+ else {
146
+ options.io.log(formatRunCompletionJson(event.result));
147
+ }
120
148
  }
121
149
  else {
122
150
  writeCompletionHuman(event.result, options.io);
@@ -0,0 +1,22 @@
1
+ import type { RunStore } from "../runstore/port.js";
2
+ import { RunManager } from "../runtime/runManager.js";
3
+ export declare const RUNS_USAGE = "Usage:\n sf runs list [--status created|running|succeeded|failed] [--since <iso>] [--pipeline <id-or-path>] [--json]\n sf runs show --run <runId> [--from <sf-run.json>] [--json]\n sf runs waiting [--run <runId>] [--json]\n sf runs wait --run <runId> [--from <sf-run.json>] [--until any|waiting|terminal] [--timeout-ms <n>] [--json]\n sf runs answer --run <runId> --stage <stageId> [--answer '<json>'] [--json]\n sf runs retry --run <runId> --stage <stageId> [--json]\n sf runs abandon --run <runId> --stage <stageId> [--json]\n sf runs rerun --run <runId> [--json]";
4
+ export type RunsCommandIo = {
5
+ log: (line: string) => void;
6
+ error: (line: string) => void;
7
+ };
8
+ export type HostProbeResult = "up" | "down";
9
+ export declare function defaultProbeHost(): Promise<HostProbeResult>;
10
+ export declare function runRunsCommand(args: string[], options?: {
11
+ cwd?: string;
12
+ projectRoot?: string;
13
+ isGitProject?: boolean;
14
+ io?: Partial<RunsCommandIo>;
15
+ store?: RunStore;
16
+ probeHost?: () => Promise<HostProbeResult>;
17
+ stdinIsTTY?: boolean;
18
+ readStdin?: () => string;
19
+ waitSignal?: AbortSignal;
20
+ env?: NodeJS.ProcessEnv;
21
+ createManager?: (store: RunStore) => RunManager;
22
+ }): Promise<number>;