@gonovus-ai/spec-flow-cli 0.7.0 → 1.0.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.
@@ -0,0 +1,132 @@
1
+ import { execFile } from "node:child_process";
2
+ import { access, readFile, realpath } from "node:fs/promises";
3
+ import { isAbsolute, join, resolve, win32 } from "node:path";
4
+ import { promisify } from "node:util";
5
+ import { lock } from "proper-lockfile";
6
+ import { lt, valid } from "semver";
7
+ import { z } from "zod";
8
+ export const cliPackageName = "@gonovus-ai/spec-flow-cli";
9
+ const runFile = promisify(execFile);
10
+ /** npm must finish or fail; a stalled registry socket must not hold the upgrade lock forever. */
11
+ export const npmExecutionOptions = { shell: false, timeout: 10 * 60 * 1_000 };
12
+ /**
13
+ * Serialize upgrades of one npm prefix for every user who can write it. The lock lives in the
14
+ * global node_modules directory npm itself writes, beside (never inside) the package npm
15
+ * replaces; the prefix root is often root-owned even where that directory is writable.
16
+ */
17
+ export function upgradeLockPath(realPrefix, platform = process.platform) {
18
+ return join(realPrefix, globalModulesDirectory(platform), ".specflow-cli-upgrade");
19
+ }
20
+ function globalModulesDirectory(platform) {
21
+ return platform === "win32" ? "node_modules" : "lib/node_modules";
22
+ }
23
+ async function npmRunner() {
24
+ if (process.platform !== "win32")
25
+ return (args) => runFile("npm", args, npmExecutionOptions);
26
+ return resolveWindowsNpm({
27
+ path: process.env.PATH ?? process.env.Path ?? "",
28
+ nodeExecutable: process.execPath,
29
+ exists: isAccessible,
30
+ run: (file, args) => runFile(file, args, npmExecutionOptions),
31
+ });
32
+ }
33
+ /**
34
+ * npm.cmd cannot run without cmd.exe, so mirror what the shim does with plain
35
+ * argument vectors: prefer node.exe beside the shim, ask npm-prefix.js for the
36
+ * configured global prefix, and delegate to the npm installed under that prefix
37
+ * when present (the shim's own self-upgrade rule), else the npm beside the shim.
38
+ */
39
+ export async function resolveWindowsNpm(host) {
40
+ for (const entry of host.path.split(";")) {
41
+ const directory = entry.trim().replace(/^"|"$/gu, "");
42
+ if (!win32.isAbsolute(directory))
43
+ continue;
44
+ // A native npm.exe earlier on PATH wins, exactly as Windows command resolution would.
45
+ const npmExe = win32.join(directory, "npm.exe");
46
+ if (await host.exists(npmExe))
47
+ return (args) => host.run(npmExe, args);
48
+ if (!(await host.exists(win32.join(directory, "npm.cmd"))))
49
+ continue;
50
+ const besideNode = win32.join(directory, "node.exe");
51
+ const node = (await host.exists(besideNode)) ? besideNode : host.nodeExecutable;
52
+ const npmBin = win32.join(directory, "node_modules", "npm", "bin");
53
+ let npmCli = win32.join(npmBin, "npm-cli.js");
54
+ if (!(await host.exists(npmCli)))
55
+ continue;
56
+ const prefixScript = win32.join(npmBin, "npm-prefix.js");
57
+ if (await host.exists(prefixScript)) {
58
+ const prefix = (await host.run(node, [prefixScript])).stdout.trim();
59
+ const prefixCli = win32.join(prefix, "node_modules", "npm", "bin", "npm-cli.js");
60
+ if (win32.isAbsolute(prefix) && (await host.exists(prefixCli)))
61
+ npmCli = prefixCli;
62
+ }
63
+ return (args) => host.run(node, [npmCli, ...args]);
64
+ }
65
+ throw new Error("npm.cmd was not found");
66
+ }
67
+ async function isAccessible(path) {
68
+ try {
69
+ await access(path);
70
+ return true;
71
+ }
72
+ catch (error) {
73
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
74
+ return false;
75
+ throw error;
76
+ }
77
+ }
78
+ function isPermissionError(error) {
79
+ return (error instanceof Error &&
80
+ ["code" in error ? error.code : "", "stderr" in error ? error.stderr : ""].some((value) => typeof value === "string" && /\b(?:EACCES|EPERM)\b/u.test(value)));
81
+ }
82
+ async function installedVersion(manifest) {
83
+ return (z
84
+ // The installed CLI may be a prerelease; only upgrade targets must be release versions.
85
+ .object({
86
+ name: z.literal(cliPackageName),
87
+ version: z.string().refine((value) => valid(value) === value),
88
+ })
89
+ .parse(JSON.parse(await readFile(manifest, "utf8"))).version);
90
+ }
91
+ export async function upgradeWithNpm(target, explicit) {
92
+ let installationStarted = false;
93
+ try {
94
+ const npm = await npmRunner();
95
+ const prefix = (await npm(["prefix", "-g"])).stdout.trim();
96
+ if (!isAbsolute(prefix) || process.argv[1] === undefined)
97
+ return "manual";
98
+ const modules = globalModulesDirectory(process.platform);
99
+ const packageDirectory = join(prefix, modules, cliPackageName);
100
+ const realPrefix = await realpath(prefix);
101
+ const packageRoot = resolve(realPrefix, modules, cliPackageName);
102
+ // Linked development installs and other package managers can put shims under a prefix.
103
+ if ((await realpath(packageDirectory)) !== packageRoot ||
104
+ (await realpath(process.argv[1])) !== join(packageRoot, "dist", "bin.js"))
105
+ return "manual";
106
+ const manifest = join(packageDirectory, "package.json");
107
+ const release = await lock(upgradeLockPath(realPrefix), {
108
+ realpath: false,
109
+ stale: 120_000,
110
+ onCompromised: () => undefined,
111
+ });
112
+ try {
113
+ const current = await installedVersion(manifest);
114
+ if (!explicit && lt(target, current))
115
+ return "downgrade";
116
+ installationStarted = true;
117
+ await npm(["install", "--global", "--prefix", prefix, `${cliPackageName}@${target}`]);
118
+ return (await installedVersion(manifest)) === target ? "installed" : "failed";
119
+ }
120
+ finally {
121
+ await release();
122
+ }
123
+ }
124
+ catch (error) {
125
+ if (error instanceof Error && "code" in error && error.code === "ELOCKED")
126
+ return "busy";
127
+ if (isPermissionError(error))
128
+ return "permission";
129
+ return installationStarted ? "failed" : "manual";
130
+ }
131
+ }
132
+ //# sourceMappingURL=npm-upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm-upgrade.js","sourceRoot":"","sources":["../../src/runtime/npm-upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAA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E,OAAO,MAAM,CAAC;QACzF,IAAI,iBAAiB,CAAC,KAAK,CAAC;YAAE,OAAO,YAAY,CAAC;QAClD,OAAO,mBAAmB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACnD,CAAC;AACH,CAAC"}
@@ -0,0 +1,178 @@
1
+ # authoring
2
+
3
+ Spec authoring, canonical Markdown, Scenario IDs, and draft proposals.
4
+
5
+ - Read and author shared Specs with `specflow spec list|read|create|edit` and
6
+ `specflow capability create|update|delete`, passing `--workspace-id <workspaceId>`.
7
+ Read the Capability tree from `specflow spec list --workspace-id <workspaceId>`.
8
+ Use the same Workspace for draft, owner, publish, rollback, state and delete commands.
9
+ A Project filter selects Specs linked from its Work Items, never Project-owned copies.
10
+
11
+ - Organize Capability and Spec resources, persist only bounded Source References, and
12
+ edit Spec or Glossary Working Drafts through the logical CLI commands. Do not
13
+ implement a collaboration protocol or connect to the collaboration gateway.
14
+ - Read shared Spec provenance with `specflow authoring-history --workspace-id <workspaceId>`.
15
+ - Use `proposal create-spec` or `proposal create-glossary` only when preview-before-apply
16
+ is useful. Bind it to the exact logical baseline you read, report only available
17
+ Agent revision/model and Source Reference IDs, and use `proposal list`, `apply`, or
18
+ `discard` as independent resource operations. Direct `spec edit` and `workspace glossary edit`
19
+ remain the default and may report the same bounded provenance fields.
20
+ - Treat `Resource Changed` from Proposal apply as a protected Human edit: reread the
21
+ Working Draft and Proposal, then require deliberate conflict resolution. Never
22
+ convert it into a blind direct edit or silently recreate the Proposal.
23
+ - Apply the current Workspace Role to Finding operations. Never attempt
24
+ to turn a Permission Denied result into broader authority.
25
+
26
+ Before deciding Spec boundaries, use current Workspace knowledge context already supplied by the
27
+ task. When authoring against SpecFlow, read any missing Capability tree, Published
28
+ Glossary, and relevant existing Specs through the CLI. Use that context to choose one
29
+ of four outcomes: create a Spec, update or reuse an existing Spec, avoid a duplicate,
30
+ or report a conflict that needs resolution.
31
+
32
+ For each new Spec, write its title and all authored Spec prose (titles,
33
+ Goals, Rules, Scenario lines, and explanatory table content) in the User's language.
34
+ Use the User's explicit output-language request first, then their established
35
+ language preference, and otherwise the language of their own task instructions.
36
+ Reference material and this Skill do not determine the Spec's prose language.
37
+ Use Published Canonical Terms verbatim even when the surrounding prose uses
38
+ another language, and preserve literal values.
39
+
40
+ Workspace creation accepts `--spec-language zh-CN|en` (default `zh-CN`). `workspace settings read|update --workspace-id <workspaceId>` owns subsequent language changes; published Revisions keep their language; unpublished outlines serialize with the new labels. Read `specLanguage` from Workspace knowledge context. Project-shaped adapters read that same value. This controls syntax, not authored prose.
41
+
42
+ Consult the Glossary guide for normative vocabulary and terminology conflict handling before drafting.
43
+
44
+ When a provided Capability owns the goal's business object and changed state, use
45
+ that placement. Otherwise create the Spec without `--capability-id`; Unassigned is
46
+ not a hidden Capability. Move an existing Spec to Unassigned with `spec update
47
+ --capability-id none` and its observed version. Choose one existing Capability when
48
+ organizing later; an actor's account does not determine placement.
49
+
50
+ Use Example Mapping before writing Spec Content:
51
+
52
+ 1. Identify each distinct User goal by the outcome the User wants to complete, not by
53
+ each step, command, or state on the way to that outcome.
54
+ 2. List the business Rules governing each goal.
55
+ 3. Give each Rule concrete success, rejection, failure, and boundary Examples.
56
+ 4. Record unresolved Questions instead of inventing answers.
57
+
58
+ Map one User goal to one Spec with one Title and Goal. Keep that goal's success, rejection,
59
+ failure, and boundary paths in the same Spec. Split independent goals into separate
60
+ Specs even when they share a page, API, actor, or implementation; shared
61
+ surfaces are not a reason to merge goals. A behavior is an independent goal only when
62
+ it has a useful completion outcome apart from the end-to-end journey.
63
+
64
+ A step that only creates pending work and the later authorized step that accepts,
65
+ rejects, or realizes it remain one end-to-end goal when the requirement describes one
66
+ business result. A handoff between actors does not by itself create another goal.
67
+
68
+ A setting and the behavior it enables or disables remain one goal when the setting
69
+ has no useful outcome apart from controlling that behavior. Keep enabling, disabling,
70
+ and the resulting execution or suppression in the same Spec.
71
+
72
+ For example, starting checkout, completing payment, and handling a declined payment
73
+ remain one purchase Spec. Viewing past orders is a separate goal even on the same
74
+ page.
75
+
76
+ Write canonical Markdown in this fixed order: Title, Goal, optional Rules,
77
+ optional Shared Preconditions, Scenarios, and optional Open Questions. Goal is one
78
+ paragraph saying who wants what and why. Rules are numbered normative statements;
79
+ they have no IDs. Shared Preconditions are a bullet list that holds for every
80
+ Scenario. Each Scenario has a heading, an optional explanation, and ordered
81
+ Precondition, Action, or Outcome lines. At least one Outcome is required. One
82
+ optional pipe table records example values. Open Questions are a numbered list;
83
+ they never block Publish and are supplied to Review as context.
84
+
85
+ Use `#` for the Title, `##` for sections, and `###` for each Scenario heading.
86
+ English line labels are `Given`, `When`, and `Then`, followed by `: `.
87
+ Chinese sections are `目标 / 规则 / 共同前提 / 情形 / 待确认`; line labels are
88
+ `前提 / 操作 / 结果`, followed by `:`, as in `- 操作:顾客确认使用已保存的卡。`.
89
+ Sentences use natural language without step-matching rules. Escape structural
90
+ prefixes in authored text with a backslash and escape pipes inside table cells.
91
+ Use one blank line between blocks and exactly one trailing newline.
92
+
93
+ For example, an English Spec after Scenario ID assignment reads:
94
+
95
+ ```markdown
96
+ # Pay for an order
97
+
98
+ ## Goal
99
+
100
+ A customer pays for an order to complete checkout.
101
+
102
+ ## Rules
103
+
104
+ 1. The customer must be charged at most once.
105
+
106
+ ## Shared Preconditions
107
+
108
+ - The order is unpaid.
109
+
110
+ ## Scenarios
111
+
112
+ ### PAY-S123-4 Pay with a saved card
113
+
114
+ - Given: The customer has a saved card.
115
+ - When: The customer confirms payment.
116
+ - Then: The order is paid.
117
+
118
+ ## Open Questions
119
+
120
+ 1. How long may payment confirmation take?
121
+ ```
122
+
123
+ Every Scenario carries a stable Spec-scoped Scenario ID in its heading, such as
124
+ `PAY-S123-4`, that SpecFlow assigns, never the Agent. When editing a Working Draft,
125
+ preserve each existing Scenario ID verbatim: never invent, renumber, reorder, or
126
+ hand-assign Scenario IDs, and never put test-case-document numbering into Scenario
127
+ titles. Keep the ID when reordering or editing a Scenario inside the same Spec; when
128
+ copying a Scenario from another Spec, remove its Scenario ID before saving so
129
+ assignment issues fresh IDs. After editing and before Publish, run
130
+ `specflow spec assign-scenario-ids --workspace-id <workspace-id> --spec-id <spec-id>`
131
+ to fill missing IDs and repair invalid, duplicate, or foreign ones while leaving
132
+ valid IDs unchanged. Refer to scenarios by their Scenario ID in questions,
133
+ findings, and reports. Spec Content has no tags.
134
+
135
+ Read Markdown with `specflow spec read --workspace-id <workspace-id> --spec-id
136
+ <spec-id>`: `workingDraftSource` holds the current Draft and
137
+ `currentRevision.content` holds Published Content. Start a Draft when needed with
138
+ `specflow spec draft --workspace-id <workspace-id> --spec-id <spec-id>
139
+ --expected-version <version>`. Write it with `specflow spec edit
140
+ --workspace-id <workspace-id> --spec-id <spec-id> --content <markdown>`; its response
141
+ contains `draft.content`. Content that does not parse as canonical Markdown is
142
+ rejected as a whole with `Invalid Operation` diagnostics and leaves the Working
143
+ Draft unchanged; correct the reported lines and send the full content again.
144
+ Workspace knowledge context returns `specLanguage`; Project-shaped adapters read the same value. A Spec Proposal
145
+ uses `proposal create-spec --workspace-id <workspace-id> --spec-id <spec-id>
146
+ --baseline-content <baseline> --proposed-content <markdown>` and carries
147
+ `baselineContent` and `proposedContent`. Keep the baseline exactly as read.
148
+
149
+ Ask the smallest focused Question before editing only when a missing goal, acting
150
+ authority, or business policy prevents a correct Spec boundary, Rule, or observable
151
+ outcome without choosing among plausible answers. Otherwise continue directly without
152
+ asking or recording a Question. Keep details abstract when the requested behavior is
153
+ already clear without them. A stated actor is sufficient unless multiple plausible
154
+ authority levels would change the behavior. Stop asking once every goal, required
155
+ authority, and outcome-changing policy is known; wording and other reversible
156
+ authoring choices do not block drafting.
157
+
158
+ Phrase each blocking Question as one direct choice using the requirement's own domain
159
+ terms and the same language as the requirement. Use the compact form that matches the
160
+ missing decision: who may perform the named action for authority; after the named
161
+ state, whether the named action is allowed and how rejection is handled for policy;
162
+ whether named goal A and named goal B are the same goal or independent goals for a
163
+ boundary; or, for a meaning conflict between a requirement and a term the Published
164
+ Glossary defines, "the Published Glossary defines the named Canonical Term as the
165
+ quoted Definition; this requirement uses it as the quoted meaning; which governs, the
166
+ Glossary or the requirement?". That conflict form asks only the one governing choice
167
+ and never asks whether the Glossary should change. Replace every generic placeholder
168
+ with the exact actor, action, object, goal, or term from the requirement; never
169
+ return template wording literally. Do not replace the choice
170
+ with a menu of examples or a broader process question. When the current
171
+ step asks only for clarification, return the blocking Questions and no Specs or
172
+ Spec Content until the answers are supplied.
173
+
174
+ A Workspace read-only Token (`SPEC_FLOW_WORKSPACE_READ_TOKEN`) can read `spec
175
+ current` and `spec revision` without a Session; see the workspace-admin guide for its
176
+ scope. When reporting an authoring outcome, list the Canonical Term substitutions
177
+ made, undefined material terms suggested as Glossary candidates, and existing Specs
178
+ that disagree with the Published Glossary.
@@ -0,0 +1,60 @@
1
+ # delivery
2
+
3
+ Development branches, releases, acceptance, and transfers.
4
+
5
+ ## Development branches
6
+
7
+ Before creating a branch for an approved Work Item, use the CLI branch-name
8
+ command and create the Git branch using its returned `branchName` exactly:
9
+
10
+ ```sh
11
+ specflow work-item branch-name --project-id PROJECT --work-item-id GON-78
12
+ ```
13
+
14
+ This writes the branch claim on the server. Do not derive the branch name from
15
+ the title yourself: Projects configure their branch template, and the exact claim
16
+ links a subsequent PR even when its title has no Work Item number. Claiming the
17
+ same branch again assigns it to the most recently selected Work Item. PR titles
18
+ may identify multiple Work Items with complete IDs; PR bodies and comments do not
19
+ associate Work Items. Use `work-item github-link-pr` for a manual PR association;
20
+ `resource-link add --kind other` is for ordinary reference URLs and rejects GitHub
21
+ pull-request URLs. Manual PR associations default to `closes`; `references`
22
+ never changes Work Item status.
23
+
24
+ ## Delivery and acceptance (ADR 0143)
25
+
26
+ Merging enters delivery rather than completing a Work Item. CI or signed GitHub
27
+ successful deployment status records releases; manual completion requires a User
28
+ with `workItem:update` to accept an In QA Work Item. Return requires a reason and
29
+ moves it to In Progress, recording the reason as a comment. Acceptance is attributed
30
+ to the authenticated human, including when an Agent acts on that User's behalf.
31
+ Automation changes require `project:update` and replace the complete settings.
32
+
33
+ ```sh
34
+ specflow work-item delivery --project-id PROJECT --work-item-id PAY-1 --json
35
+ specflow work-item accept --project-id PROJECT --work-item-id PAY-1 --expected-version '"7"' --idempotency-key UUID
36
+ specflow work-item return --project-id PROJECT --work-item-id PAY-1 --reason 'Missing acceptance criterion' --expected-version '"7"' --idempotency-key UUID
37
+ specflow work-item release --project-id PROJECT --work-item-id PAY-1 --environment staging --released-at 2026-11-08T00:00:00Z --expected-version '"7"' --idempotency-key UUID
38
+ specflow project work-item-automation read --project-id PROJECT
39
+ specflow project work-item-automation update --project-id PROJECT --input '<complete settings JSON>' --expected-version '"1"' --idempotency-key UUID
40
+ specflow work-item transfer-preview --project-id PROJECT --work-item-id PAY-1 --destination-project-id TARGET
41
+ specflow work-item location --project-id PROJECT --work-item-id PAY-1
42
+ ```
43
+
44
+ All commands emit JSON and accept `--json`. Release time defaults to current UTC;
45
+ when retrying a CI command, retain its original timestamp, UUID and observed version.
46
+ Read the Work Item version with `work-item read`; automation read returns its own
47
+ version. Use the `settings` object alone as automation update input. Settings include
48
+ review/merge columns, ordered branch rules, testing/production environments,
49
+ completion mode and automatic archive configuration. A null column means no move.
50
+
51
+ Assistant and MCP expose `readWorkItemAutomation`, `updateWorkItemAutomation`,
52
+ `readWorkItemDelivery`, `recordWorkItemAcceptance`, `recordWorkItemRelease`,
53
+ `previewWorkItemTransfer` and `resolveWorkItemLocation`. Reads execute as reads.
54
+ Assistant writes require the conversation owner's approval; MCP uses existing
55
+ OAuth authority and routine `call_write`, original version preconditions and native
56
+ idempotency receipts. No additional connector admission reservation is needed.
57
+ The release operation reports an already successful release, like other explicit
58
+ integration commands; it does not deploy or impersonate a GitHub webhook. Only
59
+ report an actual release requested by the User. No automatic acceptance follows a
60
+ merge; production-mode completion is a separate Project setting.
@@ -0,0 +1,32 @@
1
+ # discussions-audit
2
+
3
+ Spec responsibility, Scenario discussion threads, and audit history.
4
+
5
+ Use `spec owner read|candidates|assign|clear --workspace-id W --spec-id SPEC`
6
+ when the User asks to inspect or change responsibility. Assignment requires an
7
+ eligible candidate's `--user-id`; clearing is explicit. Both writes require the
8
+ Owner read's `--expected-version` and a retained `--idempotency-key` UUID.
9
+ Responsibility never grants access.
10
+
11
+ Use `spec discussion targets` before starting or replying to a Scenario thread.
12
+ Pass explicit Workspace/Spec IDs and `--context-kind Published|WorkingDraft`
13
+ (default Published). Preserve allocated Scenario IDs and the selected target's
14
+ `context.hash` as `--context-hash`; never invent them. Read paginated threads with
15
+ `list` and comments with `comments --thread-id UUID`, following `nextCursor` via
16
+ `--cursor` with the same view/filter. Use `start --scenario-id ID --context-hash HASH
17
+ --content TEXT` or `reply --thread-id UUID --context-hash HASH --content TEXT`.
18
+ On `SPEC_DISCUSSION_CONTEXT_CHANGED`, reread the selected view and deliberately
19
+ reapply intent; never replace the hash silently.
20
+
21
+ Use `edit-comment` or `delete-comment` only for the User's own comment, passing
22
+ `--thread-id`, `--comment-id`, and that comment's observed version. Edits retain
23
+ original context and deletion leaves a tombstone. `resolve` / `reopen` use the
24
+ thread's observed version, independently of comment versions. Every discussion
25
+ write requires the same retained UUID `--idempotency-key` for retries.
26
+
27
+ Read authorized audit pages with `project audit-log
28
+ --project-id ID` or `workspace audit-log --workspace-id ID`, using `--limit 1..100`
29
+ and `--cursor` for further pages. Preserve source and actor attribution in reports.
30
+
31
+ Related guides: Spec authoring history (`authoring-history`) and Findings are in
32
+ authoring.
@@ -0,0 +1,41 @@
1
+ # errors
2
+
3
+ Skill Errors, stale versions, and uncertain outcomes.
4
+
5
+ Use the singular resource commands shown by `specflow --help`. A successful
6
+ resource command emits one JSON object on stdout. Diagnostics and the final
7
+ Skill Error are NDJSON on stderr.
8
+
9
+ Handle the final `error.reason` exactly. Newer CLI responses also carry the public
10
+ `error.code`, HTTP `error.status` when a response exists, and optional `error.issues`
11
+ with `location`, `path`, `rule` and `message`. Use those fields to correct input;
12
+ never assume a missing HTTP status means the server accepted the command. Existing
13
+ `reason`, exit codes and Markdown `diagnostics` remain the compatibility contract.
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;
16
+ a 428 requires the current observed version, not waiting and retrying unchanged.
17
+
18
+ - `Authentication Failed`: stop and ask the User to authenticate again.
19
+ - `Project Not Accessible`: stop; do not probe the Project with another identifier.
20
+ - `Permission Denied`: stop; the current User Role does not allow the operation.
21
+ - `Resource Not Found`: reread the selected Project directory or resource identity.
22
+ - `Resource Changed`: reread the resource before deliberately reapplying the User's
23
+ intent with its new opaque version.
24
+ - `Invalid Operation`: correct the domain input; never auto-restore, auto-publish, or
25
+ bypass the stated rule. When `error.diagnostics` is present, each entry names the
26
+ `reason`, `message`, and the `line`/`column` of one problem in the Markdown
27
+ content. For `scenario-id-*` reasons on Spec Publish, run `specflow spec assign-scenario-ids --workspace-id <workspace-id> --spec-id <spec-id>` to repair the
28
+ Working Draft, then retry the Publish. For `scenario-id-*` reasons on Spec
29
+ Rollback, the stored Revision cannot be repaired in place: read its source, save
30
+ it to the Working Draft, run `specflow spec assign-scenario-ids`, and Publish
31
+ instead. Never hand-edit Scenario IDs; assignment is the only repair path.
32
+ - `Temporary Failure`: retry only when `retryable` is true, and honor `retryAfter` when
33
+ present.
34
+
35
+ Disabled Users, revoked or expired Sessions, Role downgrade, Project Archive, and
36
+ stale expected versions are authoritative current-state failures. Do not reuse cached
37
+ authority or silently broaden the credential's explicit grants.
38
+
39
+ `LOCAL_OUTPUT_FAILED` means local formatting or output failed after possible server
40
+ success: read the resource before deliberately retrying. It never permits a blind
41
+ write retry. Diagnostics stay on stderr and stdout remains business JSON.
@@ -0,0 +1,40 @@
1
+ # glossary
2
+
3
+ Published vocabulary, terminology conflicts, and Glossary drafts.
4
+
5
+ The current Published Workspace Glossary is the only normative vocabulary for
6
+ shared Spec authoring. Read it with `specflow workspace glossary read --workspace-id <workspaceId>`.
7
+ Treat Glossary Working Draft entries like undefined terms: usable, never normative.
8
+ When the Published Glossary defines the concept a requirement refers to, write
9
+ the Canonical Term in Title, Goal, Rule, Scenario, and line text even when the
10
+ requirement uses a different word for the same meaning. Substituting a
11
+ requirement synonym is not a blocking Question.
12
+
13
+ When the requirement uses a term the Published Glossary defines with a meaning
14
+ that differs from its Definition, ask one blocking Question using the conflict form in
15
+ the authoring guide and draft nothing for the affected goal until the answer arrives. When the
16
+ requirement governs, write the Spec per the requirement and report that the
17
+ named Glossary Entry now disagrees with it; do not edit the Glossary or create a
18
+ Terminology Finding.
19
+
20
+ A material term the Published Glossary lacks never blocks drafting and never
21
+ causes a Glossary Working Draft edit or Glossary Proposal on the Agent's own
22
+ initiative. Materiality follows the Terminology Finding definition: the term
23
+ must affect behavioral interpretation, so an unfamiliar ordinary word is not
24
+ sufficient. When an existing Spec read for context disagrees with the Published
25
+ Glossary, report the Spec and the Glossary Entry, and create a Terminology
26
+ Finding only when the User asks. Keep each required conflict report
27
+ self-contained: retain both source meanings or concrete conflicting values, even
28
+ when a Question also quotes them. When reporting an authoring outcome to the
29
+ User, list the Canonical Term substitutions made, the undefined material terms
30
+ suggested as Glossary candidates, and the existing Specs that disagree with the
31
+ Published Glossary.
32
+
33
+ Use `specflow workspace glossary edit` for a direct Working Draft edit, or `specflow proposal create-glossary` when preview-before-apply is useful. See the authoring guide for exact baseline and conflict handling. Request explicit User confirmation immediately before Glossary Publish or Rollback.
34
+
35
+ Do not implement a collaboration protocol or connect to the collaboration gateway;
36
+ edit Glossary drafts only through these logical commands. A Workspace read-only
37
+ Token (`SPEC_FLOW_WORKSPACE_READ_TOKEN`) can read `workspace glossary revision`; see
38
+ the workspace-admin guide for its scope. When reporting an outcome, list the
39
+ Canonical Term substitutions made, undefined material terms suggested as Glossary
40
+ candidates, and existing Specs that disagree with the Published Glossary.
@@ -0,0 +1,31 @@
1
+ # map-and-screens
2
+
3
+ Product Map, screen placement, and local image files.
4
+
5
+ Read the shared map with `specflow map read --workspace-id <workspaceId>`. Its screen, journey, place, unplace and backstage commands use Workspace identity and the current Screen/Journey/Spec version. Task resource links use `--workspace-id` for the shared Spec target while the task retains `--project-id`.
6
+
7
+ For a local Screen image, reserve it with `map screen image-reserve`, save the
8
+ returned JSON to an owner-only file, and upload bytes with `work-item asset put
9
+ --reservation-file <path> --file <path>`. That byte-only command supports signed
10
+ S3 and Azure BlockBlob reservations and does not attach an image. Attach it with
11
+ `map screen image-finalize`, retaining the observed Screen version and original
12
+ command keys after an uncertain response. Never print a signed upload URL.
13
+
14
+ ## Local Screen image files (ZTA-881 CLI)
15
+
16
+ ```sh
17
+ specflow map screen image-upload --workspace-id WORKSPACE --screen-id SCREEN --file ./image.png --content-type image/png --expected-version '"1"' --idempotency-key RESERVE_KEY --finalize-key FINALIZE_KEY
18
+ specflow map screen image-download --workspace-id WORKSPACE --screen-id SCREEN --asset-id ASSET_UUID --output-file ./download.png
19
+ ```
20
+
21
+ Upload reserves against the observed Screen version, validates the returned fresh
22
+ HTTP(S) reservation, PUTs bytes without Session credentials or redirects, and
23
+ finalizes using a separate retained key and the same version. Local files must be
24
+ nonempty regular files of at most 10 MiB; server MIME/size checks still apply.
25
+ Retain both phase keys and identical inputs after failures. Once finalized, a new
26
+ reservation attempt with the old reserve key returns upload-expired; reread the
27
+ Screen to resolve an ambiguous completion. Existing image-reserve/image-finalize/
28
+ image-remove commands remain available for explicit phase control.
29
+ Download accepts only authorized Workspace/Screen/asset identities, never an
30
+ arbitrary URL, and creates a new owner-only file without overwriting existing files.
31
+ Assistant image handling is outside this CLI slice.
@@ -0,0 +1,9 @@
1
+ # search
2
+
3
+ Global object search and Published Spec search.
4
+
5
+ Use `specflow search-global --query 'payment' --limit 20 [--cursor '<nextCursor>']`
6
+ for tasks, Specs, Screens and Journeys across currently accessible resources.
7
+ Preserve returned object identities and totalCount; follow nextCursor with the
8
+ same query for complete results. No type filter is supported. Dedicated
9
+ `specflow spec search` still searches published Spec content only.