@gonovus-ai/spec-flow-cli 1.0.1 → 1.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.
- package/README.md +24 -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/board-commands.d.ts +3 -0
- package/dist/board-commands.js +381 -0
- package/dist/board-commands.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +117 -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/context-agents-block.d.ts +57 -0
- package/dist/context-agents-block.js +331 -0
- package/dist/context-agents-block.js.map +1 -0
- package/dist/context-command-support.d.ts +186 -0
- package/dist/context-command-support.js +176 -0
- package/dist/context-command-support.js.map +1 -0
- package/dist/context-document-commands.d.ts +5 -0
- package/dist/context-document-commands.js +674 -0
- package/dist/context-document-commands.js.map +1 -0
- package/dist/index.js +42 -2
- 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 +21 -0
- package/dist/runtime/errors.js +92 -1
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/execute.d.ts +9 -0
- package/dist/runtime/execute.js +18 -4
- 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 +48 -6
- package/dist/work-item-query-commands.js.map +1 -1
- package/dist/work-item-resource-link-commands.js +36 -0
- package/dist/work-item-resource-link-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 +110 -0
- package/guides/boards.md +123 -0
- package/guides/context-documents.md +181 -0
- package/guides/errors.md +15 -0
- package/guides/work-items.md +7 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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";
|
|
6
|
+
import { registerBoardCommands } from "./board-commands.js";
|
|
5
7
|
import { registerClientCompatibilityCommands } from "./commands/client-compatibility.js";
|
|
6
8
|
import { itemOutput, itemListOutput, relationListOutput, relationReceiptOutput, } from "./commands/work-item-output.js";
|
|
9
|
+
import { registerContextDocumentCommands } from "./context-document-commands.js";
|
|
7
10
|
import { registerCustomFieldColorCommands, parseOptionColors, } from "./custom-field-color-commands.js";
|
|
8
11
|
import { registerGitHubAccountCommands } from "./github-account-commands.js";
|
|
9
12
|
import { readDescription, singleDescriptionSource } from "./input/text-source.js";
|
|
@@ -34,6 +37,7 @@ const workItemBulkActions = [
|
|
|
34
37
|
"updateStatus",
|
|
35
38
|
"updatePriority",
|
|
36
39
|
"updateAssignee",
|
|
40
|
+
"updateAssignedAgent",
|
|
37
41
|
"delete",
|
|
38
42
|
"addLabel",
|
|
39
43
|
"removeLabel",
|
|
@@ -171,7 +175,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
171
175
|
exitCode = code;
|
|
172
176
|
});
|
|
173
177
|
const run = async (request, options = {}) => {
|
|
174
|
-
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"));
|
|
175
179
|
if ("exitCode" in selected)
|
|
176
180
|
return selected.exitCode;
|
|
177
181
|
let me;
|
|
@@ -223,6 +227,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
223
227
|
"work-item read",
|
|
224
228
|
"work-item update",
|
|
225
229
|
"work-item assign",
|
|
230
|
+
"work-item assign-agent",
|
|
226
231
|
"work-item list",
|
|
227
232
|
"work-item relation create",
|
|
228
233
|
"work-item relation list",
|
|
@@ -1656,6 +1661,30 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1656
1661
|
rejectWrite: () => rejectTokenWrite(dependencies),
|
|
1657
1662
|
});
|
|
1658
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
|
+
});
|
|
1676
|
+
const contextRuntime = {
|
|
1677
|
+
dependencies,
|
|
1678
|
+
run,
|
|
1679
|
+
setExitCode: (value) => {
|
|
1680
|
+
exitCode = value;
|
|
1681
|
+
},
|
|
1682
|
+
canWrite: () => !hasWorkspaceReadToken(dependencies.environment),
|
|
1683
|
+
rejectWrite: () => rejectTokenWrite(dependencies),
|
|
1684
|
+
isReadToken: () => hasWorkspaceReadToken(dependencies.environment),
|
|
1685
|
+
};
|
|
1686
|
+
registerContextDocumentCommands(program, contextRuntime);
|
|
1687
|
+
registerBoardCommands(program, contextRuntime);
|
|
1659
1688
|
const workItemComment = workItem
|
|
1660
1689
|
.command("comment")
|
|
1661
1690
|
.description("Read and manage authored task comments");
|
|
@@ -1699,14 +1728,19 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1699
1728
|
.requiredOption("--project-id <projectId>")
|
|
1700
1729
|
.requiredOption("--work-item-id <workItemId>")
|
|
1701
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, [])
|
|
1702
1732
|
.requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseCommentCommandKey)
|
|
1703
1733
|
.action(async (options) => {
|
|
1704
1734
|
if (hasWorkspaceReadToken(dependencies.environment)) {
|
|
1705
1735
|
exitCode = rejectTokenWrite(dependencies);
|
|
1706
1736
|
return;
|
|
1707
1737
|
}
|
|
1738
|
+
const mentions = [...new Set(options.mention.map((item) => item.trim()).filter(Boolean))];
|
|
1708
1739
|
exitCode = await run((client) => client.POST("/v1/projects/{projectId}/work-items/{workItemId}/comments", {
|
|
1709
|
-
body: {
|
|
1740
|
+
body: {
|
|
1741
|
+
content: options.content,
|
|
1742
|
+
...(mentions.length === 0 ? {} : { mentions }),
|
|
1743
|
+
},
|
|
1710
1744
|
params: {
|
|
1711
1745
|
path: { projectId: options.projectId, workItemId: options.workItemId },
|
|
1712
1746
|
header: { "idempotency-key": options.idempotencyKey },
|
|
@@ -1722,6 +1756,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1722
1756
|
.requiredOption("--work-item-id <workItemId>")
|
|
1723
1757
|
.requiredOption("--comment-id <commentId>", "Identifier returned by comments", parseCommentId)
|
|
1724
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, [])
|
|
1725
1760
|
.requiredOption("--expected-version <version>", "Opaque comment version returned by SpecFlow", parseOpaqueVersion)
|
|
1726
1761
|
.requiredOption("--idempotency-key <key>", "Reuse the same key and inputs when retrying", parseCommentCommandKey)
|
|
1727
1762
|
.action(async (options) => {
|
|
@@ -1729,8 +1764,12 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
1729
1764
|
exitCode = rejectTokenWrite(dependencies);
|
|
1730
1765
|
return;
|
|
1731
1766
|
}
|
|
1767
|
+
const mentions = [...new Set(options.mention.map((item) => item.trim()).filter(Boolean))];
|
|
1732
1768
|
exitCode = await run((client) => client.PATCH("/v1/projects/{projectId}/work-items/{workItemId}/comments/{commentId}", {
|
|
1733
|
-
body: {
|
|
1769
|
+
body: {
|
|
1770
|
+
content: options.content,
|
|
1771
|
+
...(mentions.length === 0 ? {} : { mentions }),
|
|
1772
|
+
},
|
|
1734
1773
|
params: {
|
|
1735
1774
|
path: {
|
|
1736
1775
|
projectId: options.projectId,
|
|
@@ -2011,6 +2050,15 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2011
2050
|
params: { path: options },
|
|
2012
2051
|
}));
|
|
2013
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
|
+
});
|
|
2014
2062
|
workItem
|
|
2015
2063
|
.command("create")
|
|
2016
2064
|
.requiredOption("--project-id <projectId>")
|
|
@@ -2019,6 +2067,7 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2019
2067
|
.option("--description-file <path>", "Read description from a UTF-8 regular file, or - for piped stdin", singleDescriptionSource)
|
|
2020
2068
|
.option("--label <labelId>", "Workspace label definition ID; repeat for several labels", collectOption, [])
|
|
2021
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")
|
|
2022
2071
|
.option("--custom-field <fieldId=value>", "Custom Field value as fieldId=value; repeat for several fields", collectOption, [])
|
|
2023
2072
|
.option("--priority <priority>", "Work Item priority", parseWorkItemPriority)
|
|
2024
2073
|
.option("--start-date <startDate>", "ISO 8601 date", parseWorkItemDate)
|
|
@@ -2070,6 +2119,9 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2070
2119
|
exitCode = await run((client, me) => client.POST("/v1/projects/{projectId}/work-items", {
|
|
2071
2120
|
body: {
|
|
2072
2121
|
...(options.assignee === undefined ? {} : { assigneeId: me ?? options.assignee }),
|
|
2122
|
+
...(options.assignedAgent === undefined
|
|
2123
|
+
? {}
|
|
2124
|
+
: { assignedAgentId: options.assignedAgent }),
|
|
2073
2125
|
...(options.customField.length === 0
|
|
2074
2126
|
? {}
|
|
2075
2127
|
: {
|
|
@@ -2211,6 +2263,46 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2211
2263
|
retryTransportOnce: true,
|
|
2212
2264
|
});
|
|
2213
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
|
+
});
|
|
2214
2306
|
workItem
|
|
2215
2307
|
.command("delete")
|
|
2216
2308
|
.requiredOption("--project-id <projectId>")
|
|
@@ -2260,6 +2352,8 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2260
2352
|
.option("--priority <priority>", "Priority (updatePriority)", parseWorkItemPriority)
|
|
2261
2353
|
.option("--assignee <assignee>", "Assignee User ID only (updateAssignee); me is not supported")
|
|
2262
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)")
|
|
2263
2357
|
.option("--label-id <labelId>", "Work Item Label ID (addLabel/removeLabel)")
|
|
2264
2358
|
.option("--due-date <dueDate>", "Due date (updateDueDate)", parseWorkItemDate)
|
|
2265
2359
|
.option("--clear-due-date", "Clear the due date (updateDueDate)")
|
|
@@ -2278,6 +2372,15 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2278
2372
|
exitCode = 1;
|
|
2279
2373
|
return;
|
|
2280
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
|
+
}
|
|
2281
2384
|
if (options.clearDueDate === true && options.dueDate !== undefined) {
|
|
2282
2385
|
writeSkillError(dependencies, {
|
|
2283
2386
|
message: "--due-date and --clear-due-date cannot be combined for updateDueDate",
|
|
@@ -2298,6 +2401,13 @@ export async function runCli(arguments_, originalDependencies) {
|
|
|
2298
2401
|
? {}
|
|
2299
2402
|
: { assigneeId: options.assignee }
|
|
2300
2403
|
: {}),
|
|
2404
|
+
...(options.action === "updateAssignedAgent"
|
|
2405
|
+
? options.clearAssignedAgent === true
|
|
2406
|
+
? { assignedAgentId: null }
|
|
2407
|
+
: options.assignedAgent === undefined
|
|
2408
|
+
? {}
|
|
2409
|
+
: { assignedAgentId: options.assignedAgent }
|
|
2410
|
+
: {}),
|
|
2301
2411
|
...(options.action === "updateDueDate"
|
|
2302
2412
|
? options.clearDueDate === true
|
|
2303
2413
|
? { dueDate: null }
|
|
@@ -3250,6 +3360,9 @@ function workItemSelectionQuery(options) {
|
|
|
3250
3360
|
: { creator: options.creator.join(",") }),
|
|
3251
3361
|
...Object.fromEntries(["operators", "created", "updated", "relations", "specs", "pullRequests"].flatMap((key) => (options[key] === undefined ? [] : [[key, options[key]]]))),
|
|
3252
3362
|
...(options.assignee.length === 0 ? {} : { assignee: options.assignee.join(",") }),
|
|
3363
|
+
...(options.assignedAgent.length === 0
|
|
3364
|
+
? {}
|
|
3365
|
+
: { assignedAgent: options.assignedAgent.join(",") }),
|
|
3253
3366
|
...(options.watcher.length === 0 ? {} : { watcher: options.watcher.join(",") }),
|
|
3254
3367
|
...(Object.keys(customFields).length === 0
|
|
3255
3368
|
? {}
|
|
@@ -3292,6 +3405,7 @@ function workItemSelectionFlags(command) {
|
|
|
3292
3405
|
.option("--specs <csv>", "Linked Spec IDs, or none")
|
|
3293
3406
|
.option("--pull-requests <csv>", "none,draft,open,merged,closed; synchronized state only")
|
|
3294
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, [])
|
|
3295
3409
|
.option("--watcher <userId>", "Filter by watcher User ID or me; repeat for several", collectOption, [])
|
|
3296
3410
|
.option("--custom-field <fieldId=value>", "Filter by Custom Field value; repeat to OR values or combine fields", collectOption, [])
|
|
3297
3411
|
.option("--due <filter>", "Filter by due bucket: dueThisWeek, dueNextWeek, or noDueDate; repeat for several", (value, previous) => [
|