@gonovus-ai/spec-flow-cli 1.1.0 → 1.2.1
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.
- package/README.md +3 -3
- package/dist/agent-commands.d.ts +11 -0
- package/dist/agent-commands.js +613 -0
- package/dist/agent-commands.js.map +1 -0
- package/dist/agent-session-commands.d.ts +3 -0
- package/dist/agent-session-commands.js +367 -0
- package/dist/agent-session-commands.js.map +1 -0
- package/dist/cli.js +103 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/work-item-output.d.ts +182 -0
- package/dist/commands/work-item-output.js +1 -0
- package/dist/commands/work-item-output.js.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/program.js +1 -0
- package/dist/program.js.map +1 -1
- package/dist/resource-command-runtime.d.ts +1 -0
- package/dist/runtime/errors.d.ts +4 -0
- package/dist/runtime/errors.js +31 -1
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/execute.d.ts +1 -0
- package/dist/runtime/execute.js.map +1 -1
- package/dist/runtime/session.d.ts +1 -1
- package/dist/runtime/session.js +22 -11
- package/dist/runtime/session.js.map +1 -1
- package/dist/work-item-query-commands.js +9 -4
- package/dist/work-item-query-commands.js.map +1 -1
- package/dist/work-item-thread-commands.js +14 -1
- package/dist/work-item-thread-commands.js.map +1 -1
- package/guides/agent-sessions.md +113 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CommanderError, InvalidArgumentError } from "commander";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { registerAgentCommands } from "./agent-commands.js";
|
|
4
5
|
import { addAuthenticationCommandTopology } from "./authentication-command-topology.js";
|
|
5
6
|
import { registerBoardCommands } from "./board-commands.js";
|
|
6
7
|
import { registerClientCompatibilityCommands } from "./commands/client-compatibility.js";
|
|
@@ -36,6 +37,7 @@ const workItemBulkActions = [
|
|
|
36
37
|
"updateStatus",
|
|
37
38
|
"updatePriority",
|
|
38
39
|
"updateAssignee",
|
|
40
|
+
"updateAssignedAgent",
|
|
39
41
|
"delete",
|
|
40
42
|
"addLabel",
|
|
41
43
|
"removeLabel",
|
|
@@ -173,7 +175,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
173
175
|
exitCode = code;
|
|
174
176
|
});
|
|
175
177
|
const run = async (request, options = {}) => {
|
|
176
|
-
const selected = await selectSession(dependencies, options, program.getOptionValue("server"), program.getOptionValue("apiKeyId"));
|
|
178
|
+
const selected = await selectSession(dependencies, options, program.getOptionValue("server"), program.getOptionValue("apiKeyId"), program.getOptionValue("agent"));
|
|
177
179
|
if ("exitCode" in selected)
|
|
178
180
|
return selected.exitCode;
|
|
179
181
|
let me;
|
|
@@ -225,6 +227,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
225
227
|
"work-item read",
|
|
226
228
|
"work-item update",
|
|
227
229
|
"work-item assign",
|
|
230
|
+
"work-item assign-agent",
|
|
228
231
|
"work-item list",
|
|
229
232
|
"work-item relation create",
|
|
230
233
|
"work-item relation list",
|
|
@@ -1658,6 +1661,18 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1658
1661
|
rejectWrite: () => rejectTokenWrite(dependencies),
|
|
1659
1662
|
});
|
|
1660
1663
|
registerWorkItemThreadCommands(workItem, resourceRuntime);
|
|
1664
|
+
const readRootStringFlag = (name) => {
|
|
1665
|
+
const value = program.getOptionValue(name);
|
|
1666
|
+
return typeof value === "string" ? value : undefined;
|
|
1667
|
+
};
|
|
1668
|
+
registerAgentCommands(program, {
|
|
1669
|
+
...resourceRuntime,
|
|
1670
|
+
dependencies,
|
|
1671
|
+
getServerFlag: () => readRootStringFlag("server"),
|
|
1672
|
+
getApiKeyIdFlag: () => readRootStringFlag("apiKeyId"),
|
|
1673
|
+
getAgentFlag: () => readRootStringFlag("agent"),
|
|
1674
|
+
parseProjectId,
|
|
1675
|
+
});
|
|
1661
1676
|
const contextRuntime = {
|
|
1662
1677
|
dependencies,
|
|
1663
1678
|
run,
|
|
@@ -1713,14 +1728,19 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1713
1728
|
.requiredOption("--project-id <projectId>")
|
|
1714
1729
|
.requiredOption("--work-item-id <workItemId>")
|
|
1715
1730
|
.requiredOption("--content <markdown>", "Markdown comment body, up to 20000 characters", parseCommentContent)
|
|
1731
|
+
.option("--mention <id>", "User ID, Agent ID, or Agent slug to mention; repeat for several", collectOption, [])
|
|
1716
1732
|
.requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseCommentCommandKey)
|
|
1717
1733
|
.action(async (options) => {
|
|
1718
1734
|
if (hasWorkspaceReadToken(dependencies.environment)) {
|
|
1719
1735
|
exitCode = rejectTokenWrite(dependencies);
|
|
1720
1736
|
return;
|
|
1721
1737
|
}
|
|
1738
|
+
const mentions = [...new Set(options.mention.map((item) => item.trim()).filter(Boolean))];
|
|
1722
1739
|
exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/comments", {
|
|
1723
|
-
body: {
|
|
1740
|
+
body: {
|
|
1741
|
+
content: options.content,
|
|
1742
|
+
...(mentions.length === 0 ? {} : { mentions }),
|
|
1743
|
+
},
|
|
1724
1744
|
params: {
|
|
1725
1745
|
path: { projectId: options.projectId, workItemId: options.workItemId },
|
|
1726
1746
|
header: { "idempotency-key": options.idempotencyKey },
|
|
@@ -1736,6 +1756,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1736
1756
|
.requiredOption("--work-item-id <workItemId>")
|
|
1737
1757
|
.requiredOption("--comment-id <commentId>", "Identifier returned by comments", parseCommentId)
|
|
1738
1758
|
.requiredOption("--content <markdown>", "Markdown comment body, up to 20000 characters", parseCommentContent)
|
|
1759
|
+
.option("--mention <id>", "User ID, Agent ID, or Agent slug to mention; repeat for several", collectOption, [])
|
|
1739
1760
|
.requiredOption("--expected-version <version>", "Opaque comment version returned by SpecFlow", parseOpaqueVersion)
|
|
1740
1761
|
.requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseCommentCommandKey)
|
|
1741
1762
|
.action(async (options) => {
|
|
@@ -1743,8 +1764,12 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1743
1764
|
exitCode = rejectTokenWrite(dependencies);
|
|
1744
1765
|
return;
|
|
1745
1766
|
}
|
|
1767
|
+
const mentions = [...new Set(options.mention.map((item) => item.trim()).filter(Boolean))];
|
|
1746
1768
|
exitCode = await run((client) => client.PATCH("/v1/projects/{projectId}/work-items/{workItemId}/comments/{commentId}", {
|
|
1747
|
-
body: {
|
|
1769
|
+
body: {
|
|
1770
|
+
content: options.content,
|
|
1771
|
+
...(mentions.length === 0 ? {} : { mentions }),
|
|
1772
|
+
},
|
|
1748
1773
|
params: {
|
|
1749
1774
|
path: {
|
|
1750
1775
|
projectId: options.projectId,
|
|
@@ -2025,6 +2050,15 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2025
2050
|
params: { path: options },
|
|
2026
2051
|
}));
|
|
2027
2052
|
});
|
|
2053
|
+
workItem
|
|
2054
|
+
.command("agents")
|
|
2055
|
+
.description("List active Agents granted to this Project")
|
|
2056
|
+
.requiredOption("--project-id <projectId>")
|
|
2057
|
+
.action(async (options) => {
|
|
2058
|
+
exitCode = await run((client) => client.GET("/v1/projects/{projectId}/agents", {
|
|
2059
|
+
params: { path: options },
|
|
2060
|
+
}), { rejectWorkspaceReadToken: true });
|
|
2061
|
+
});
|
|
2028
2062
|
workItem
|
|
2029
2063
|
.command("create")
|
|
2030
2064
|
.requiredOption("--project-id <projectId>")
|
|
@@ -2033,6 +2067,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2033
2067
|
.option("--description-file <path>", "Read description from a UTF-8 regular file, or - for piped stdin", singleDescriptionSource)
|
|
2034
2068
|
.option("--label <labelId>", "Workspace label definition ID; repeat for several labels", collectOption, [])
|
|
2035
2069
|
.option("--assignee <assignee>", "Workspace member User ID, or me for the selected credential")
|
|
2070
|
+
.option("--assigned-agent <agentId>", "Eligible Workspace Agent ID to assign for execution")
|
|
2036
2071
|
.option("--custom-field <fieldId=value>", "Custom Field value as fieldId=value; repeat for several fields", collectOption, [])
|
|
2037
2072
|
.option("--priority <priority>", "Work Item priority", parseWorkItemPriority)
|
|
2038
2073
|
.option("--start-date <startDate>", "ISO 8601 date", parseWorkItemDate)
|
|
@@ -2084,6 +2119,9 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2084
2119
|
exitCode = await run((client, me) => client.POST("/v1/projects/{projectId}/work-items", {
|
|
2085
2120
|
body: {
|
|
2086
2121
|
...(options.assignee === undefined ? {} : { assigneeId: me ?? options.assignee }),
|
|
2122
|
+
...(options.assignedAgent === undefined
|
|
2123
|
+
? {}
|
|
2124
|
+
: { assignedAgentId: options.assignedAgent }),
|
|
2087
2125
|
...(options.customField.length === 0
|
|
2088
2126
|
? {}
|
|
2089
2127
|
: {
|
|
@@ -2225,6 +2263,46 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2225
2263
|
retryTransportOnce: true,
|
|
2226
2264
|
});
|
|
2227
2265
|
});
|
|
2266
|
+
workItem
|
|
2267
|
+
.command("assign-agent")
|
|
2268
|
+
.description("Assign or clear the executing Workspace Agent for a Work Item")
|
|
2269
|
+
.requiredOption("--project-id <projectId>")
|
|
2270
|
+
.requiredOption("--work-item-id <workItemId>")
|
|
2271
|
+
.requiredOption("--expected-version <expectedVersion>", "Opaque version returned by SpecFlow", parseOpaqueVersion)
|
|
2272
|
+
.option("--agent-id <agentId>", "Eligible Workspace Agent ID to assign")
|
|
2273
|
+
.option("--clear", "Clear the executing Agent")
|
|
2274
|
+
.action(async (options) => {
|
|
2275
|
+
if (hasWorkspaceReadToken(dependencies.environment)) {
|
|
2276
|
+
exitCode = rejectTokenWrite(dependencies);
|
|
2277
|
+
return;
|
|
2278
|
+
}
|
|
2279
|
+
if (options.agentId === undefined && options.clear !== true) {
|
|
2280
|
+
throw invalidArgument("Work Item assign-agent requires --agent-id or --clear");
|
|
2281
|
+
}
|
|
2282
|
+
if (options.agentId !== undefined && options.clear === true) {
|
|
2283
|
+
throw invalidArgument("Work Item assign-agent cannot combine --agent-id and --clear");
|
|
2284
|
+
}
|
|
2285
|
+
const idempotencyKey = randomUUID();
|
|
2286
|
+
exitCode = await run((client) => client.PUT("/v1/projects/{projectId}/work-items/{workItemId}/assigned-agent", {
|
|
2287
|
+
body: {
|
|
2288
|
+
assignedAgentId: options.clear === true ? null : (options.agentId ?? null),
|
|
2289
|
+
},
|
|
2290
|
+
params: {
|
|
2291
|
+
header: {
|
|
2292
|
+
"idempotency-key": idempotencyKey,
|
|
2293
|
+
"if-match": options.expectedVersion,
|
|
2294
|
+
},
|
|
2295
|
+
path: {
|
|
2296
|
+
projectId: options.projectId,
|
|
2297
|
+
workItemId: options.workItemId,
|
|
2298
|
+
},
|
|
2299
|
+
},
|
|
2300
|
+
}), {
|
|
2301
|
+
project: (data) => itemOutput(data, outputMode, warnMissingUrl),
|
|
2302
|
+
ambiguousOutcomeMessage: "Work Item Agent assignment outcome is unknown; read the Work Item before retrying",
|
|
2303
|
+
retryTransportOnce: true,
|
|
2304
|
+
});
|
|
2305
|
+
});
|
|
2228
2306
|
workItem
|
|
2229
2307
|
.command("delete")
|
|
2230
2308
|
.requiredOption("--project-id <projectId>")
|
|
@@ -2274,6 +2352,8 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2274
2352
|
.option("--priority <priority>", "Priority (updatePriority)", parseWorkItemPriority)
|
|
2275
2353
|
.option("--assignee <assignee>", "Assignee User ID only (updateAssignee); me is not supported")
|
|
2276
2354
|
.option("--unassign", "Clear the assignee (updateAssignee)")
|
|
2355
|
+
.option("--assigned-agent <agentId>", "Executing Workspace Agent ID (updateAssignedAgent)")
|
|
2356
|
+
.option("--clear-assigned-agent", "Clear the executing Agent (updateAssignedAgent)")
|
|
2277
2357
|
.option("--label-id <labelId>", "Work Item Label ID (addLabel/removeLabel)")
|
|
2278
2358
|
.option("--due-date <dueDate>", "Due date (updateDueDate)", parseWorkItemDate)
|
|
2279
2359
|
.option("--clear-due-date", "Clear the due date (updateDueDate)")
|
|
@@ -2292,6 +2372,15 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2292
2372
|
exitCode = 1;
|
|
2293
2373
|
return;
|
|
2294
2374
|
}
|
|
2375
|
+
if (options.clearAssignedAgent === true && options.assignedAgent !== undefined) {
|
|
2376
|
+
writeSkillError(dependencies, {
|
|
2377
|
+
message: "--assigned-agent and --clear-assigned-agent cannot be combined for updateAssignedAgent",
|
|
2378
|
+
reason: "Invalid Operation",
|
|
2379
|
+
retryable: false,
|
|
2380
|
+
});
|
|
2381
|
+
exitCode = 1;
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2295
2384
|
if (options.clearDueDate === true && options.dueDate !== undefined) {
|
|
2296
2385
|
writeSkillError(dependencies, {
|
|
2297
2386
|
message: "--due-date and --clear-due-date cannot be combined for updateDueDate",
|
|
@@ -2312,6 +2401,13 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2312
2401
|
? {}
|
|
2313
2402
|
: { assigneeId: options.assignee }
|
|
2314
2403
|
: {}),
|
|
2404
|
+
...(options.action === "updateAssignedAgent"
|
|
2405
|
+
? options.clearAssignedAgent === true
|
|
2406
|
+
? { assignedAgentId: null }
|
|
2407
|
+
: options.assignedAgent === undefined
|
|
2408
|
+
? {}
|
|
2409
|
+
: { assignedAgentId: options.assignedAgent }
|
|
2410
|
+
: {}),
|
|
2315
2411
|
...(options.action === "updateDueDate"
|
|
2316
2412
|
? options.clearDueDate === true
|
|
2317
2413
|
? { dueDate: null }
|
|
@@ -3264,6 +3360,9 @@ function workItemSelectionQuery(options) {
|
|
|
3264
3360
|
: { creator: options.creator.join(",") }),
|
|
3265
3361
|
...Object.fromEntries(["operators", "created", "updated", "relations", "specs", "pullRequests"].flatMap((key) => (options[key] === undefined ? [] : [[key, options[key]]]))),
|
|
3266
3362
|
...(options.assignee.length === 0 ? {} : { assignee: options.assignee.join(",") }),
|
|
3363
|
+
...(options.assignedAgent.length === 0
|
|
3364
|
+
? {}
|
|
3365
|
+
: { assignedAgent: options.assignedAgent.join(",") }),
|
|
3267
3366
|
...(options.watcher.length === 0 ? {} : { watcher: options.watcher.join(",") }),
|
|
3268
3367
|
...(Object.keys(customFields).length === 0
|
|
3269
3368
|
? {}
|
|
@@ -3306,6 +3405,7 @@ function workItemSelectionFlags(command) {
|
|
|
3306
3405
|
.option("--specs <csv>", "Linked Spec IDs, or none")
|
|
3307
3406
|
.option("--pull-requests <csv>", "none,draft,open,merged,closed; synchronized state only")
|
|
3308
3407
|
.option("--assignee <assignee>", "Filter by assignee User ID, me, or unassigned; repeat for several", collectOption, [])
|
|
3408
|
+
.option("--assigned-agent <agentId>", "Filter by executing Agent ID or unassigned; repeat for several", collectOption, [])
|
|
3309
3409
|
.option("--watcher <userId>", "Filter by watcher User ID or me; repeat for several", collectOption, [])
|
|
3310
3410
|
.option("--custom-field <fieldId=value>", "Filter by Custom Field value; repeat to OR values or combine fields", collectOption, [])
|
|
3311
3411
|
.option("--due <filter>", "Filter by due bucket: dueThisWeek, dueNextWeek, or noDueDate; repeat for several", (value, previous) => [
|