@gonovus-ai/spec-flow-cli 1.2.0 → 1.3.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 (54) hide show
  1. package/README.md +20 -2
  2. package/dist/agent-commands.d.ts +30 -0
  3. package/dist/agent-commands.js +14 -17
  4. package/dist/agent-commands.js.map +1 -1
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.js.map +1 -1
  7. package/dist/credential-store.js +9 -8
  8. package/dist/credential-store.js.map +1 -1
  9. package/dist/index.js +16 -13
  10. package/dist/index.js.map +1 -1
  11. package/dist/input/text-source.js +5 -4
  12. package/dist/input/text-source.js.map +1 -1
  13. package/dist/runner/adapters/acp-adapter.d.ts +14 -0
  14. package/dist/runner/adapters/acp-adapter.js +593 -0
  15. package/dist/runner/adapters/acp-adapter.js.map +1 -0
  16. package/dist/runner/adapters/claude-stream.d.ts +7 -0
  17. package/dist/runner/adapters/claude-stream.js +324 -0
  18. package/dist/runner/adapters/claude-stream.js.map +1 -0
  19. package/dist/runner/adapters/codex-app-server.d.ts +8 -0
  20. package/dist/runner/adapters/codex-app-server.js +821 -0
  21. package/dist/runner/adapters/codex-app-server.js.map +1 -0
  22. package/dist/runner/adapters/exec-adapter.d.ts +13 -0
  23. package/dist/runner/adapters/exec-adapter.js +212 -0
  24. package/dist/runner/adapters/exec-adapter.js.map +1 -0
  25. package/dist/runner/orchestrator.d.ts +65 -0
  26. package/dist/runner/orchestrator.js +1166 -0
  27. package/dist/runner/orchestrator.js.map +1 -0
  28. package/dist/runner/process-utils.d.ts +22 -0
  29. package/dist/runner/process-utils.js +105 -0
  30. package/dist/runner/process-utils.js.map +1 -0
  31. package/dist/runner/redact.d.ts +26 -0
  32. package/dist/runner/redact.js +119 -0
  33. package/dist/runner/redact.js.map +1 -0
  34. package/dist/runner/run-command.d.ts +3 -0
  35. package/dist/runner/run-command.js +508 -0
  36. package/dist/runner/run-command.js.map +1 -0
  37. package/dist/runner/state-store.d.ts +18 -0
  38. package/dist/runner/state-store.js +156 -0
  39. package/dist/runner/state-store.js.map +1 -0
  40. package/dist/runner/telemetry-bridge.d.ts +44 -0
  41. package/dist/runner/telemetry-bridge.js +357 -0
  42. package/dist/runner/telemetry-bridge.js.map +1 -0
  43. package/dist/runner/types.d.ts +182 -0
  44. package/dist/runner/types.js +2 -0
  45. package/dist/runner/types.js.map +1 -0
  46. package/dist/runner/workflow.d.ts +4 -0
  47. package/dist/runner/workflow.js +272 -0
  48. package/dist/runner/workflow.js.map +1 -0
  49. package/dist/runner/workspace-manager.d.ts +29 -0
  50. package/dist/runner/workspace-manager.js +196 -0
  51. package/dist/runner/workspace-manager.js.map +1 -0
  52. package/dist/work-item-exchange-file.js +1 -1
  53. package/guides/agent-sessions.md +62 -14
  54. package/package.json +2 -1
@@ -0,0 +1,196 @@
1
+ import { execFile } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import { access, mkdir, realpath, rm } from "node:fs/promises";
4
+ import { isAbsolute, join, relative, resolve, sep } from "node:path";
5
+ import { promisify } from "node:util";
6
+ const execFileAsync = promisify(execFile);
7
+ /**
8
+ * Sanitize a Work Item key into a collision-resistant directory name following
9
+ * Symphony Section 9.5 invariants (only `[A-Za-z0-9._-]`).
10
+ */
11
+ export function deriveWorkspaceKey(workItemKey) {
12
+ const cleaned = workItemKey.trim().replace(/[^A-Za-z0-9._-]/gu, "_");
13
+ const safeBase = cleaned.length > 0 ? cleaned : "work-item";
14
+ if (safeBase === workItemKey.trim() && safeBase !== "." && safeBase !== "..") {
15
+ return safeBase;
16
+ }
17
+ const digest = createHash("sha256").update(workItemKey).digest("hex").slice(0, 16);
18
+ const normalizedBase = safeBase.replace(/^\.+/u, "_") || "work-item";
19
+ return `${normalizedBase}-${digest}`;
20
+ }
21
+ /**
22
+ * Enforce Symphony Invariant 2: a per-issue workspace path must strictly reside
23
+ * beneath the normalized workspace root (no traversal, cross-drive, or root escape).
24
+ */
25
+ export function assertWithinWorkspaceRoot(rootDir, candidatePath) {
26
+ const normalizedRoot = resolve(rootDir);
27
+ const normalizedCandidate = resolve(candidatePath);
28
+ const rel = relative(normalizedRoot, normalizedCandidate);
29
+ if (rel.length === 0 ||
30
+ isAbsolute(rel) ||
31
+ rel === ".." ||
32
+ rel.startsWith(`..${sep}`) ||
33
+ rel.startsWith("../") ||
34
+ rel.startsWith("..\\")) {
35
+ throw new Error(`Refusing workspace path outside root: ${normalizedCandidate} is not within ${normalizedRoot}`);
36
+ }
37
+ return normalizedCandidate;
38
+ }
39
+ async function pathExists(targetPath) {
40
+ try {
41
+ await access(targetPath);
42
+ return true;
43
+ }
44
+ catch {
45
+ return false;
46
+ }
47
+ }
48
+ async function resolveGitTopLevel(cwd) {
49
+ try {
50
+ const { stdout } = await execFileAsync("git", ["rev-parse", "--show-toplevel"], {
51
+ cwd,
52
+ timeout: 10_000,
53
+ });
54
+ const top = stdout.trim();
55
+ return top.length > 0 ? top : null;
56
+ }
57
+ catch {
58
+ return null;
59
+ }
60
+ }
61
+ export async function resolveEffectiveWorkspaceMode(cwd, requestedMode) {
62
+ if (requestedMode === "shared") {
63
+ return "shared";
64
+ }
65
+ const gitRoot = await resolveGitTopLevel(cwd);
66
+ return gitRoot === null ? "shared" : "worktree";
67
+ }
68
+ async function resolveCurrentHeadRef(gitRoot) {
69
+ try {
70
+ const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD"], {
71
+ cwd: gitRoot,
72
+ timeout: 10_000,
73
+ });
74
+ const sha = stdout.trim();
75
+ return sha.length > 0 ? sha : "HEAD";
76
+ }
77
+ catch {
78
+ return "HEAD";
79
+ }
80
+ }
81
+ async function cleanupFailedWorktree(gitRoot, worktreePath) {
82
+ try {
83
+ await execFileAsync("git", ["worktree", "remove", "--force", worktreePath], {
84
+ cwd: gitRoot,
85
+ timeout: 15_000,
86
+ });
87
+ }
88
+ catch {
89
+ await rm(worktreePath, { recursive: true, force: true }).catch(() => undefined);
90
+ await execFileAsync("git", ["worktree", "prune"], {
91
+ cwd: gitRoot,
92
+ timeout: 10_000,
93
+ }).catch(() => undefined);
94
+ }
95
+ }
96
+ export async function runLifecycleHook(hookScript, cwd, timeoutMs, env) {
97
+ if (hookScript === undefined || hookScript.trim().length === 0)
98
+ return;
99
+ const shell = process.platform === "win32" ? "cmd" : "bash";
100
+ const args = process.platform === "win32" ? ["/c", hookScript] : ["-c", hookScript];
101
+ await execFileAsync(shell, args, {
102
+ cwd,
103
+ env,
104
+ timeout: timeoutMs,
105
+ maxBuffer: 2 * 1024 * 1024,
106
+ });
107
+ }
108
+ export async function prepareWorkItemWorkspace(options) {
109
+ const normalizedBase = resolve(options.baseCwd);
110
+ if (options.mode === "shared") {
111
+ return { path: normalizedBase, mode: "shared", createdNow: false };
112
+ }
113
+ const gitRoot = await resolveGitTopLevel(normalizedBase);
114
+ if (gitRoot === null) {
115
+ options.onDiagnostic(`Directory ${normalizedBase} is not a Git repository; falling back to shared workspace mode.`);
116
+ return { path: normalizedBase, mode: "shared", createdNow: false };
117
+ }
118
+ const rootDir = resolve(options.worktreeRoot ?? join(gitRoot, ".specflow", "worktrees"));
119
+ await mkdir(rootDir, { recursive: true });
120
+ const realRootDir = await realpath(rootDir);
121
+ const workspaceKey = deriveWorkspaceKey(options.workItemKey);
122
+ const worktreePath = assertWithinWorkspaceRoot(realRootDir, join(realRootDir, workspaceKey));
123
+ const branchName = `specflow/${workspaceKey.toLowerCase()}`;
124
+ if (await pathExists(worktreePath)) {
125
+ const resolvedExisting = await realpath(worktreePath);
126
+ assertWithinWorkspaceRoot(realRootDir, resolvedExisting);
127
+ return {
128
+ path: resolvedExisting,
129
+ mode: "worktree",
130
+ createdNow: false,
131
+ worktreeBranch: branchName,
132
+ };
133
+ }
134
+ const baseRef = await resolveCurrentHeadRef(gitRoot);
135
+ try {
136
+ await execFileAsync("git", ["worktree", "add", "-b", branchName, worktreePath, baseRef], {
137
+ cwd: gitRoot,
138
+ timeout: 30_000,
139
+ });
140
+ }
141
+ catch {
142
+ // If branch already exists from an earlier run, check out detached or reuse existing branch.
143
+ try {
144
+ await execFileAsync("git", ["worktree", "add", worktreePath, branchName], {
145
+ cwd: gitRoot,
146
+ timeout: 30_000,
147
+ });
148
+ }
149
+ catch {
150
+ await execFileAsync("git", ["worktree", "add", "--detach", worktreePath, baseRef], {
151
+ cwd: gitRoot,
152
+ timeout: 30_000,
153
+ });
154
+ }
155
+ }
156
+ const resolvedCreated = await realpath(worktreePath);
157
+ assertWithinWorkspaceRoot(realRootDir, resolvedCreated);
158
+ if (options.hooks?.afterCreate !== undefined) {
159
+ try {
160
+ await runLifecycleHook(options.hooks.afterCreate, resolvedCreated, options.hooks.timeoutMs, options.hookEnv);
161
+ }
162
+ catch (error) {
163
+ await cleanupFailedWorktree(gitRoot, resolvedCreated);
164
+ throw error;
165
+ }
166
+ }
167
+ return {
168
+ path: resolvedCreated,
169
+ mode: "worktree",
170
+ createdNow: true,
171
+ worktreeBranch: branchName,
172
+ };
173
+ }
174
+ export async function summarizeWorkspaceChanges(cwd) {
175
+ try {
176
+ const { stdout } = await execFileAsync("git", ["status", "--short"], {
177
+ cwd,
178
+ timeout: 5_000,
179
+ });
180
+ const lines = stdout
181
+ .split("\n")
182
+ .map((line) => line.trim())
183
+ .filter((line) => line.length > 0);
184
+ if (lines.length === 0) {
185
+ return "Working tree clean (no uncommitted local edits).";
186
+ }
187
+ const preview = lines.slice(0, 6).join(", ");
188
+ return lines.length > 6
189
+ ? `${String(lines.length)} modified paths preserved in workspace (${preview}, …)`
190
+ : `${String(lines.length)} modified path(s) preserved in workspace (${preview})`;
191
+ }
192
+ catch {
193
+ return undefined;
194
+ }
195
+ }
196
+ //# sourceMappingURL=workspace-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-manager.js","sourceRoot":"","sources":["../../src/runner/workspace-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,M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AAM,GAAG,CAAC,CAAC,CAAC;QACrC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,kDAAkD,CAAC;QAC5D,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,2CAA2C,OAAO,MAAM;YACjF,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,6CAA6C,OAAO,GAAG,CAAC;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -10,7 +10,7 @@ const documentSchema = z
10
10
  .array(z
11
11
  .object({
12
12
  title: z.string().max(300),
13
- description: z.string().max(20_000).optional(),
13
+ description: z.string().max(65_536).optional(),
14
14
  status: z.string().max(200),
15
15
  priority: z.string().max(200).optional(),
16
16
  startDate: z.string().max(40).nullable().optional(),
@@ -16,10 +16,55 @@ Agent event listening, live execution sessions, structured plans, steps, elicita
16
16
  - Workspace read-only Tokens (`SPEC_FLOW_WORKSPACE_READ_TOKEN`) are rejected on all Agent
17
17
  event and session endpoints.
18
18
 
19
+ ## Running a local coding Agent worker (recommended)
20
+
21
+ Start a single-command local worker that listens for assignments, `@agent` mentions, and
22
+ live session controls (`prompt`, `answer`, `auth`, `stop`), runs a local coding agent
23
+ adapter, and streams live plans, reasoning summaries, tool steps, and confirmation cards
24
+ into the SpecFlow execution drawer:
25
+
26
+ ```sh
27
+ specflow agent run --workspace-id WORKSPACE_ID --agent my-agent --runner codex
28
+ specflow agent run --workspace-id WORKSPACE_ID --agent my-agent --runner claude
29
+ specflow agent run --workspace-id WORKSPACE_ID --agent my-agent --runner acp --acp-command 'gemini --experimental-acp'
30
+ specflow agent run --workspace-id WORKSPACE_ID --agent my-agent --runner exec --exec './scripts/worker.sh'
31
+ specflow agent run --workspace-id WORKSPACE_ID --agent my-agent --once --dry-run
32
+ ```
33
+
34
+ - Supported `--runner` adapters:
35
+ - `codex` (default): drives `codex app-server` over JSON-RPC 2.0 with live mid-turn
36
+ steering (`turn/steer`), cooperative stop (`turn/interrupt`), plan/reasoning/tool
37
+ streaming, and bidirectional confirmation/approval cards.
38
+ - `claude`: drives `claude -p --output-format stream-json --verbose` with `--resume`
39
+ thread continuity, `TodoWrite` plan mapping, and queued follow-up steering.
40
+ - `acp`: drives any Agent Client Protocol (ACP) agent via `--acp-command <cmd>` using
41
+ `@agentclientprotocol/sdk` (e.g. Gemini CLI, Goose, OpenHands, Copilot CLI).
42
+ - `exec`: runs a custom shell command via `--exec <cmd>` receiving a JSON task envelope
43
+ on stdin and emitting optional NDJSON events (`plan`, `thought`, `step`, `thread`,
44
+ `complete`) or plain text on stdout.
45
+ - Defaults and isolation:
46
+ - `--workspace-mode worktree` (default for Git repositories) creates an isolated
47
+ per-Work-Item Git worktree under `.specflow/worktrees/<SAFE_KEY>` and falls back to
48
+ `shared` for non-Git directories.
49
+ - `--sandbox workspace-write` and `--approval-policy auto` auto-approve operations inside
50
+ the sandbox while still surfacing explicit user questions (`requestUserInput` /
51
+ elicitation) as interactive cards in the SpecFlow Web drawer. Pass
52
+ `--approval-policy ask` to prompt on every command or file-change approval.
53
+ - Optional Symphony-style `WORKFLOW.md` (auto-loaded from `--cwd` or `--workflow <path>`)
54
+ configures prompt templates, concurrency, and hot-reloading. Explicit CLI flags always
55
+ override `WORKFLOW.md`. For safety, executable settings (`runner`, `sandbox`, `approval`,
56
+ `workspaceMode`, `worktreeRoot`, `acpCommand`, `execCommand`) and lifecycle hooks
57
+ (`after_create`, `before_run`, `after_run`) are only honored when `--workflow <path>` or
58
+ `--trust-workflow` is passed, and remain frozen after startup in `--workspace-mode shared`.
59
+ - Secrets (`Bearer`, API keys, tokens, JWTs, URL credentials) are redacted locally before
60
+ streaming to SpecFlow, and `SPEC_FLOW_API_KEY` / `SPEC_FLOW_WORKSPACE_READ_TOKEN` are
61
+ stripped from child agent environments and `WORKFLOW.md` expansion.
62
+
19
63
  ## Listening for durable Agent events
20
64
 
21
- Listen for assignments, `@agent` mentions, and live session control signals with cursor
22
- locking and atomic local cursor persistence:
65
+ For custom external schedulers or low-level integrations, listen for assignments, `@agent`
66
+ mentions, and live session control signals with cursor locking and atomic local cursor
67
+ persistence:
23
68
 
24
69
  ```sh
25
70
  specflow agent listen --workspace-id WORKSPACE_ID --agent my-agent
@@ -33,13 +78,15 @@ specflow agent listen --workspace-id WORKSPACE_ID --agent my-agent --wait 15 --c
33
78
  page.
34
79
  - `agent listen` streams NDJSON events to stdout (one event per line in continuous mode,
35
80
  full page JSON with `--once`). Event types include:
36
- - `work_item.assigned` and `work_item.mentioned` (task entry points; inspect the Work
37
- Item and comments before acting)
38
- - `agent_session.prompted` (human live steering instruction scoped to `sessionId`)
39
- - `agent_session.elicitation_responded` (human answered an open confirmation card)
40
- - `agent_session.auth_completed` (human completed an external authorization step)
41
- - `agent_session.stop_requested` (human requested cooperative stop)
42
- - `agent_session.retry_requested` (human spawned a fresh `pending` retry `sessionId`)
81
+ - `work_item.assigned` (delegation and retry entry points; inspect the Work Item,
82
+ comments, and any `sessionId` carried on the event before acting)
83
+ - `work_item.unassigned` (Agent delegation removed from a Work Item)
84
+ - `work_item.mentioned` and `work_item.comment_created` (discussion mentions and
85
+ follow-up comment activity)
86
+ - `session.prompted` (human live steering instruction scoped to `sessionId`)
87
+ - `session.elicitation_answered` (human answered an open confirmation card)
88
+ - `session.auth_completed` (human completed an external authorization step)
89
+ - `session.stop_requested` (human requested cooperative stop)
43
90
 
44
91
  ## Streaming a live execution session (SPF-73 M1.5)
45
92
 
@@ -60,7 +107,7 @@ SPEC_FLOW_AGENT=my-agent specflow agent session complete --project-id PROJECT_ID
60
107
  Agent on that Work Item (for example, a session created by `retry`) unless `--new` is
61
108
  passed.
62
109
  - Report failure with `specflow agent session fail --project-id PROJECT_ID --session-id RUN_ID --message 'Sanitized failure reason' [--code CODE]`.
63
- - When `agent_session.stop_requested` arrives, wrap up safely and acknowledge with
110
+ - When `session.stop_requested` arrives, wrap up safely and acknowledge with
64
111
  `specflow agent session stop-ack --project-id PROJECT_ID --session-id RUN_ID --summary 'Stopped cleanly' [--rollback-summary 'Reverted local temp edits']`.
65
112
  - Sanitization boundary: never write raw secrets, API keys, OAuth tokens, cookies, or
66
113
  unredacted external credentials into `--summary`, `--body`, `--command`,
@@ -77,10 +124,10 @@ SPEC_FLOW_AGENT=my-agent specflow agent session request-auth --project-id PROJEC
77
124
  ```
78
125
 
79
126
  - `ask` moves the session to `awaiting_input` (`elicitation`). Pass `--no-free-text` to
80
- restrict answers to the listed options. Wait for `agent_session.elicitation_responded`
127
+ restrict answers to the listed options. Wait for `session.elicitation_answered`
81
128
  and read the response via `specflow agent session read`.
82
129
  - `request-auth` moves the session to `awaiting_input` (`auth_required`) so a human can
83
- complete GitHub authorization in the browser. Wait for `agent_session.auth_completed`
130
+ complete GitHub authorization in the browser. Wait for `session.auth_completed`
84
131
  before retrying the external action.
85
132
 
86
133
  ## Reading sessions and running human controls
@@ -106,5 +153,6 @@ specflow agent session retry --project-id PROJECT_ID --session-id RUN_ID
106
153
  ```
107
154
 
108
155
  - `stop --force` is accepted only after 30 seconds have elapsed in the `stopping` state.
109
- - `retry` spawns a new `pending` `runId` from a `failed`, `stopped`, or `stale` session
110
- and notifies the target Agent with `agent_session.retry_requested`.
156
+ - `retry` spawns a new `pending` `sessionId` from a `failed`, `stopped`, or `stale`
157
+ session and notifies the target Agent with `work_item.assigned` carrying the new
158
+ `sessionId`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonovus-ai/spec-flow-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "SpecFlow supported command-line client",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,6 +44,7 @@
44
44
  "typecheck": "tsc -p tsconfig.json --noEmit"
45
45
  },
46
46
  "dependencies": {
47
+ "@agentclientprotocol/sdk": "^2.9.1",
47
48
  "@napi-rs/keyring": "1.3.0",
48
49
  "commander": "15.0.0",
49
50
  "open": "11.0.0",