@gonovus-ai/spec-flow-cli 2.0.1 → 2.2.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 (45) hide show
  1. package/README.md +4 -4
  2. package/dist/acceptance-commands.d.ts +7 -0
  3. package/dist/acceptance-commands.js +247 -0
  4. package/dist/acceptance-commands.js.map +1 -0
  5. package/dist/agent-session-commands.js +2 -0
  6. package/dist/agent-session-commands.js.map +1 -1
  7. package/dist/cli.js +13 -1
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands/work-item-output.d.ts +34 -10
  10. package/dist/context-command-support.d.ts +2 -2
  11. package/dist/github-connection-commands.js +2 -6
  12. package/dist/github-connection-commands.js.map +1 -1
  13. package/dist/group-notification-commands.d.ts +7 -0
  14. package/dist/group-notification-commands.js +245 -0
  15. package/dist/group-notification-commands.js.map +1 -0
  16. package/dist/runner/adapters/acp-adapter.js +2 -0
  17. package/dist/runner/adapters/acp-adapter.js.map +1 -1
  18. package/dist/runner/adapters/claude-stream.js +4 -1
  19. package/dist/runner/adapters/claude-stream.js.map +1 -1
  20. package/dist/runner/adapters/codex-app-server.js +5 -0
  21. package/dist/runner/adapters/codex-app-server.js.map +1 -1
  22. package/dist/runner/adapters/exec-adapter.js +8 -2
  23. package/dist/runner/adapters/exec-adapter.js.map +1 -1
  24. package/dist/runner/orchestrator.d.ts +16 -0
  25. package/dist/runner/orchestrator.js +226 -5
  26. package/dist/runner/orchestrator.js.map +1 -1
  27. package/dist/runner/redact.d.ts +1 -0
  28. package/dist/runner/redact.js +1 -0
  29. package/dist/runner/redact.js.map +1 -1
  30. package/dist/runner/telemetry-bridge.d.ts +30 -0
  31. package/dist/runner/telemetry-bridge.js +98 -2
  32. package/dist/runner/telemetry-bridge.js.map +1 -1
  33. package/dist/runner/types.d.ts +13 -2
  34. package/dist/runner/types.js +7 -0
  35. package/dist/runner/types.js.map +1 -1
  36. package/dist/runner/workflow.d.ts +25 -0
  37. package/dist/runner/workflow.js +51 -0
  38. package/dist/runner/workflow.js.map +1 -1
  39. package/dist/runtime/execute.d.ts +5 -0
  40. package/dist/runtime/execute.js +35 -12
  41. package/dist/runtime/execute.js.map +1 -1
  42. package/dist/runtime/session.d.ts +1 -1
  43. package/guides/agent-sessions.md +11 -2
  44. package/guides/errors.md +4 -2
  45. package/package.json +1 -1
@@ -1,5 +1,16 @@
1
1
  import { mapHttpFailure } from "./errors.js";
2
2
  export async function execute(request, client, options = {}) {
3
+ let sentKey = null;
4
+ const tracker = {
5
+ onRequest({ request: sent }) {
6
+ sentKey = sent.headers.get("idempotency-key");
7
+ return undefined;
8
+ },
9
+ };
10
+ client.use(tracker);
11
+ // Only a key the failing request actually sent is reported: a preview read, a
12
+ // continuation under a fresh key or a second key never borrows the command's key.
13
+ const reportedKey = () => [options.idempotencyKey, options.commandKey].find((key) => key !== undefined && key === sentKey);
3
14
  let result;
4
15
  try {
5
16
  result = await request(client);
@@ -13,9 +24,12 @@ export async function execute(request, client, options = {}) {
13
24
  message: "SpecFlow is temporarily unavailable",
14
25
  reason: "Temporary Failure",
15
26
  retryable: true,
16
- }, options.idempotencyKey),
27
+ }, reportedKey()),
17
28
  };
18
29
  }
30
+ finally {
31
+ client.eject(tracker);
32
+ }
19
33
  if (result.response.ok && result.data !== undefined) {
20
34
  const error = options.validateSuccess?.(result.data) ?? null;
21
35
  return error === null ? { ok: true, data: result.data } : { ok: false, error };
@@ -27,24 +41,33 @@ export async function execute(request, client, options = {}) {
27
41
  ok: false,
28
42
  error: withCommandKey(uncertain
29
43
  ? ambiguousMutationError(options.ambiguousOutcomeMessage)
30
- : mapHttpFailure(result.response, result.error), options.idempotencyKey),
44
+ : mapHttpFailure(result.response, result.error), reportedKey()),
31
45
  };
32
46
  }
33
- /** A keyed write that may have committed names the key to retry it with. */
47
+ /**
48
+ * A keyed write that may have committed, or that may be retried, names the key to retry it
49
+ * with: an unknown outcome is reread first, a retryable Temporary Failure is retried as is.
50
+ */
34
51
  function withCommandKey(error, idempotencyKey) {
35
- if (idempotencyKey === undefined ||
36
- (error.reason !== "Temporary Failure" && error.code !== "EXECUTION_OUTCOME_UNKNOWN"))
52
+ if (idempotencyKey === undefined)
37
53
  return error;
38
- return {
39
- ...error,
40
- message: `${error.message} (retry with --idempotency-key ${idempotencyKey} and the same inputs)`,
41
- idempotencyKey,
42
- };
54
+ const retry = `retry with --idempotency-key ${idempotencyKey} and the same inputs`;
55
+ if (error.code === "EXECUTION_OUTCOME_UNKNOWN")
56
+ return {
57
+ ...error,
58
+ message: error.message === UNKNOWN_OUTCOME
59
+ ? `Write outcome is unknown; read the target resource, and if the write did not land, ${retry}`
60
+ : `${error.message} (if the write did not land, ${retry})`,
61
+ idempotencyKey,
62
+ };
63
+ if (error.reason === "Temporary Failure" && error.retryable)
64
+ return { ...error, message: `${error.message} (${retry})`, idempotencyKey };
65
+ return error;
43
66
  }
67
+ const UNKNOWN_OUTCOME = "Write outcome is unknown; read the target resource before trying a new command identity";
44
68
  function ambiguousMutationError(message) {
45
69
  return {
46
- message: message ??
47
- "Write outcome is unknown; read the target resource before trying a new command identity",
70
+ message: message ?? UNKNOWN_OUTCOME,
48
71
  code: "EXECUTION_OUTCOME_UNKNOWN",
49
72
  reason: "Temporary Failure",
50
73
  retryable: false,
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/runtime/execute.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAC;AAyB9D,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,OAAkF,EAClF,MAA8C,EAC9C,UAA0B,EAAE;IAE5B,IAAI,MAAoB,CAAC;IACzB,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,cAAc,CACnB,OAAO,CAAC,kBAAkB,KAAK,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T,KAAK,EAAE,cAAc,CACnB,SAAS;YACP,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,uBAAuB,CAAC;YACzD,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,EACjD,WAAW,EAAE,CACd;KACF,CAAC;AACJ,CAAC;AACD;;;GAGG;AACH,SAAS,cAAc,CAAC,KAAiB,EAAE,cAAkC;IAC3E,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC/C,MAAM,KAAK,GAAG,gCAAgC,cAAc,sBAAsB,CAAC;IACnF,IAAI,KAAK,CAAC,IAAI,KAAK,2BAA2B;QAC5C,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EACL,KAAK,CAAC,OAAO,KAAK,eAAe;gBAC/B,CAAC,CAAC,sFAAsF,KAAK,EAAE;gBAC/F,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,gCAAgC,KAAK,GAAG;YAC9D,cAAc;SACf,CAAC;IACJ,IAAI,KAAK,CAAC,MAAM,KAAK,mBAAmB,IAAI,KAAK,CAAC,SAAS;QACzD,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,KAAK,KAAK,GAAG,EAAE,cAAc,EAAE,CAAC;IAC9E,OAAO,KAAK,CAAC;AACf,CAAC;AACD,MAAM,eAAe,GACnB,yFAAyF,CAAC;AAC5F,SAAS,sBAAsB,CAAC,OAAgB;IAC9C,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,eAAe;QACnC,IAAI,EAAE,2BAA2B;QACjC,MAAM,EAAE,mBAAmB;QAC3B,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC"}
@@ -9,7 +9,7 @@ export declare function selectSession(dependencies: CliDependencies, options: Ex
9
9
  } | {
10
10
  client: import("openapi-fetch").Client<paths, `${string}/${string}`>;
11
11
  identityClient: import("openapi-fetch").Client<paths, `${string}/${string}`>;
12
- credentialKind: "api-key" | "workspace-read-token" | "session";
12
+ credentialKind: "session" | "api-key" | "workspace-read-token";
13
13
  exitCode?: never;
14
14
  }>;
15
15
  export declare function rejectWorkspaceReadTokenOperation(dependencies: CliDependencies): number;
@@ -41,7 +41,8 @@ specflow agent run --workspace-id WORKSPACE_ID --agent my-agent --once --dry-run
41
41
  `@agentclientprotocol/sdk` (e.g. Gemini CLI, Goose, OpenHands, Copilot CLI).
42
42
  - `exec`: runs a custom shell command via `--exec <cmd>` receiving a JSON task envelope
43
43
  on stdin and emitting optional NDJSON events (`plan`, `thought`, `step`, `thread`,
44
- `complete`) or plain text on stdout.
44
+ `complete`) or plain text on stdout. A `step` with the same `stepId` as an earlier
45
+ one updates that step instead of adding a line.
45
46
  - Defaults and isolation:
46
47
  - `--workspace-mode worktree` (default for Git repositories) creates an isolated
47
48
  per-Work-Item Git worktree under `.specflow/worktrees/<SAFE_KEY>` and falls back to
@@ -105,10 +106,18 @@ explicitly mentions the Agent in comments), and link it with `--result-comment-i
105
106
  SPEC_FLOW_AGENT=my-agent specflow agent session start --project-id PROJECT_ID --work-item-id PAY-12 --summary 'Inspecting task requirements'
106
107
  SPEC_FLOW_AGENT=my-agent specflow agent session plan --project-id PROJECT_ID --session-id RUN_ID --steps-json '[{"id":"s1","title":"Inspect codebase","status":"in_progress"},{"id":"s2","title":"Run tests","status":"pending"}]' --summary 'Planned 2 steps'
107
108
  SPEC_FLOW_AGENT=my-agent specflow agent session thought --project-id PROJECT_ID --session-id RUN_ID --title 'Root cause' --body 'Sanitized summary of findings'
108
- SPEC_FLOW_AGENT=my-agent specflow agent session step --project-id PROJECT_ID --session-id RUN_ID --title 'Run unit tests' --tool vitest --status completed --duration-ms 1420 --command 'pnpm test' --output-summary '12 passed'
109
+ SPEC_FLOW_AGENT=my-agent specflow agent session step --project-id PROJECT_ID --session-id RUN_ID --step-id tests-1 --title 'Run unit tests' --tool vitest --status running --command 'pnpm test'
110
+ SPEC_FLOW_AGENT=my-agent specflow agent session step --project-id PROJECT_ID --session-id RUN_ID --step-id tests-1 --title 'Run unit tests' --tool vitest --status completed --duration-ms 1420 --command 'pnpm test' --output-summary '12 passed'
109
111
  SPEC_FLOW_AGENT=my-agent specflow agent session complete --project-id PROJECT_ID --session-id RUN_ID --summary 'Implemented fix and verified tests' --result-comment-id COMMENT_ID --checks-summary 'unit + typecheck passed'
110
112
  ```
111
113
 
114
+ - Thoughts are messages a person reads in the drawer: report one when the Agent has a new
115
+ finding, decision, or summary. Never mirror a terminal status bar, spinner, or elapsed
116
+ timer as thoughts; every report adds a line.
117
+ - Give each step a stable `--step-id` (for example the tool call id). Reporting the same
118
+ `--step-id` again, such as `running` and then `completed` or `failed`, updates that step
119
+ in place instead of adding a second line. Use it for live "what is running now" status
120
+ too: keep one id for the current command and update its title and status.
112
121
  - `specflow agent session start` attaches to an existing `pending` session for the same
113
122
  Agent on that Work Item (for example, a session created by `retry`) unless `--new` is
114
123
  passed.
package/guides/errors.md CHANGED
@@ -12,7 +12,9 @@ with `location`, `path`, `rule` and `message`. Use those fields to correct input
12
12
  never assume a missing HTTP status means the server accepted the command. Existing
13
13
  `reason`, exit codes and Markdown `diagnostics` remain the compatibility contract.
14
14
  If `code=EXECUTION_OUTCOME_UNKNOWN`, first reread the target resource; do not create
15
- a new command identity and blindly repeat the write. A 413 requires smaller input;
15
+ a new command identity and blindly repeat the write. When the error names an
16
+ `idempotencyKey` and the reread shows the write did not land, retry with that key and
17
+ the same inputs, never a fresh key: the earlier attempt may still commit. A 413 requires smaller input;
16
18
  a 428 requires the current observed version, not waiting and retrying unchanged.
17
19
 
18
20
  - `Authentication Failed`: stop and ask the User to authenticate again.
@@ -30,7 +32,7 @@ a 428 requires the current observed version, not waiting and retrying unchanged.
30
32
  it to the Working Draft, run `specflow spec assign-scenario-ids`, and Publish
31
33
  instead. Never hand-edit Scenario IDs; assignment is the only repair path.
32
34
  - `Temporary Failure`: retry only when `retryable` is true, and honor `retryAfter` when
33
- present.
35
+ present. A write retried after a Temporary Failure keeps its `idempotencyKey` and inputs.
34
36
 
35
37
  Disabled Users, revoked or expired Sessions, Role downgrade, Project Archive, and
36
38
  stale expected versions are authoritative current-state failures. Do not reuse cached
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonovus-ai/spec-flow-cli",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "SpecFlow supported command-line client",
5
5
  "repository": {
6
6
  "type": "git",