From 157c49d6d012a0e9aa24a5a0419cb51ccbc2ddcc Mon Sep 17 00:00:00 2001 From: Clay Good Date: Wed, 19 Aug 2026 10:34:02 -0500 Subject: [PATCH 1/4] fix(guidance): teach the spec-inventory verb to generated guidance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `openspec list --specs` appeared in no generated skill, command, or artifact instruction, while `openspec list --json` — the in-flight CHANGE list — appeared throughout. An agent asked to read the existing specs first reached for the one enumeration verb it had been taught, got the change list, found it plausible, and reported the step complete against the wrong object. Explore now lists the spec inventory alongside the change list and says which is which. The spec-driven `proposal` and `specs` instructions name the command at the two points that need it: researching existing capabilities before filling in the Capabilities section, and confirming a delta's path matches an existing capability. Guidance text only — no CLI, parser, or archive behavior changes. Closes #1689 Co-Authored-By: Claude Opus 5 --- .changeset/teach-spec-inventory-verb.md | 5 ++ schemas/spec-driven/schema.yaml | 11 ++- skills/openspec-explore/SKILL.md | 6 ++ src/core/templates/workflows/explore.ts | 12 +++ .../templates/skill-templates-parity.test.ts | 6 +- test/core/templates/spec-inventory.test.ts | 79 +++++++++++++++++++ 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 .changeset/teach-spec-inventory-verb.md create mode 100644 test/core/templates/spec-inventory.test.ts diff --git a/.changeset/teach-spec-inventory-verb.md b/.changeset/teach-spec-inventory-verb.md new file mode 100644 index 0000000000..0f215b693a --- /dev/null +++ b/.changeset/teach-spec-inventory-verb.md @@ -0,0 +1,5 @@ +--- +"@fission-ai/openspec": patch +--- + +Teach the generated guidance how to list a project's specs. `openspec list --specs` appeared in no generated skill, command, or artifact instruction, while `openspec list --json` (the in-flight *change* list) appeared throughout, so an agent asked to read the existing specs first enumerated changes instead and reported the step complete against the wrong object. The explore skill and command now list the spec inventory alongside the change list and say which is which, and the spec-driven `proposal` and `specs` instructions name the command where they ask for existing capabilities to be researched and for a delta's path to match an existing one. Fixes #1689. diff --git a/schemas/spec-driven/schema.yaml b/schemas/spec-driven/schema.yaml index ae4d9eb336..c7eebbbbf1 100644 --- a/schemas/spec-driven/schema.yaml +++ b/schemas/spec-driven/schema.yaml @@ -18,7 +18,14 @@ artifacts: - **Impact**: Affected code, APIs, dependencies, or systems. IMPORTANT: The Capabilities section is critical. It creates the contract between - proposal and specs phases. Research existing specs before filling this in. + proposal and specs phases. Research existing specs before filling this in: + run `openspec list --specs` for the project's capability inventory (add + `--json` for ids and requirement counts, and `--store ""` when a + registered store is selected), then read + `openspec/specs//spec.md` for any that look related. + `openspec list` without `--specs` lists in-flight changes, not specs - it + never shows what the project already covers. Reuse an existing + capability's exact path instead of introducing a near-duplicate name. Each capability listed here will need a corresponding spec file. Every change must either declare at least one capability (new or @@ -63,7 +70,7 @@ artifacts: `` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path: - New capabilities: use the exact path from the proposal at `specs//spec.md`. Any path segment newly introduced in the proposal must be kebab-case. Follow the project's existing organization; do not add a new domain level when the project uses a flat layout. - - Modified capabilities: use the exact existing path from `openspec/specs//` when creating the delta at `specs//spec.md`. Do not move or rename the capability. + - Modified capabilities: use the exact existing path from `openspec/specs//` when creating the delta at `specs//spec.md`. Run `openspec list --specs` to confirm that path before writing the delta - a mistyped or invented path targets a capability that does not exist rather than the one you meant. Do not move or rename the capability. There must be at least one spec file unless the change's `.openspec.yaml` sets `skip_specs: true` (no spec-level behavior change) - `openspec validate` diff --git a/skills/openspec-explore/SKILL.md b/skills/openspec-explore/SKILL.md index 327c261489..d5493e5a37 100644 --- a/skills/openspec-explore/SKILL.md +++ b/skills/openspec-explore/SKILL.md @@ -93,6 +93,12 @@ This tells you: - Their names, schemas, and status - What the user might be working on +That is the *change* list - work in flight. It does not include the project's durable capabilities, so list those too: +```bash +openspec list --specs +``` +Add `--json` for ids and requirement counts, and `--store ""` when a registered store is selected. This is the inventory of what the project already claims to do, and `openspec list` on its own never shows it. Read `/openspec/specs//spec.md` for any capability that looks related before proposing new behavior. + Then read the project's own context from the resolved root - `/openspec/config.yaml` (or `config.yml`). Use the `root.path` returned above, and skip this if neither file exists: - `context`: project background - tech stack, conventions, constraints - `rules`: keyed by artifact id - the entries for an artifact apply only when you write that artifact diff --git a/src/core/templates/workflows/explore.ts b/src/core/templates/workflows/explore.ts index 211de65646..ccfd8c8cfd 100644 --- a/src/core/templates/workflows/explore.ts +++ b/src/core/templates/workflows/explore.ts @@ -95,6 +95,12 @@ This tells you: - Their names, schemas, and status - What the user might be working on +That is the *change* list - work in flight. It does not include the project's durable capabilities, so list those too: +\`\`\`bash +openspec list --specs +\`\`\` +Add \`--json\` for ids and requirement counts, and \`--store ""\` when a registered store is selected. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. + Then read the project's own context from the resolved root - \`/openspec/config.yaml\` (or \`config.yml\`). Use the \`root.path\` returned above, and skip this if neither file exists: - \`context\`: project background - tech stack, conventions, constraints - \`rules\`: keyed by artifact id - the entries for an artifact apply only when you write that artifact @@ -410,6 +416,12 @@ This tells you: - Their names, schemas, and status - What the user might be working on +That is the *change* list - work in flight. It does not include the project's durable capabilities, so list those too: +\`\`\`bash +openspec list --specs +\`\`\` +Add \`--json\` for ids and requirement counts, and \`--store ""\` when a registered store is selected. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. + Then read the project's own context from the resolved root - \`/openspec/config.yaml\` (or \`config.yml\`). Use the \`root.path\` returned above, and skip this if neither file exists: - \`context\`: project background - tech stack, conventions, constraints - \`rules\`: keyed by artifact id - the entries for an artifact apply only when you write that artifact diff --git a/test/core/templates/skill-templates-parity.test.ts b/test/core/templates/skill-templates-parity.test.ts index decad7b0b5..57495ec2a4 100644 --- a/test/core/templates/skill-templates-parity.test.ts +++ b/test/core/templates/skill-templates-parity.test.ts @@ -38,14 +38,14 @@ import { import { STORE_SELECTION_GUIDANCE } from '../../../src/core/templates/workflows/store-selection.js'; const EXPECTED_FUNCTION_HASHES: Record = { - getExploreSkillTemplate: '3efc37cddf342318ac37be7bb4ff5915f454b4c5bb127294ebdc7534ee21aa23', + getExploreSkillTemplate: '64e2f121985877941f6a1e4164810c338af5cde1fec2a7c28e58012738a2ad25', getNewChangeSkillTemplate: 'eabd1e895c5881dcb17dcbaa3fb26098dd59e8eacb318e400820b4dc811ef781', getContinueChangeSkillTemplate: '012136f6411a99c8fa228e2f9444cb64b0a89e0f56fdeac2fe03b2f5bee0c5d7', getApplyChangeSkillTemplate: 'd1e7d5ceb85193c0964057dbb88e9651526754bd33f84020e2440ff0621d5dbb', getFfChangeSkillTemplate: '5501740e7ec36ab23ab8c3a0d6dd0655a5e2f35433c7b90e82904fef5e7a326a', getSyncSpecsSkillTemplate: 'b099e2ff31859c9b10d928066e662524f9aad9ecf2be12fceacb732d718c4146', getOnboardSkillTemplate: '29b1d825179cff92fbc7b790694c1baef138575ea3de56848715e27d7e367946', - getOpsxExploreCommandTemplate: 'd2f70d11588f902c15c1e5ce9908cc4124c6b82fe78dc766ac5c3599c9e2a6f1', + getOpsxExploreCommandTemplate: '056249b459e124f4e347592489a3adac6b22b4b3a544b7158f0147306e9527b0', getOpsxNewCommandTemplate: 'f2d30e569798a4c92ba932859d6ba4e0ad10e18feccbade1cfee0957597b3463', getOpsxContinueCommandTemplate: 'e50e50266efa1b8e64ff9b6274ee8254f0a240d6adc1b862d126e2f1c9d3a559', getOpsxApplyCommandTemplate: 'e3579ac78f2e2c75fa3d3a7ac7dc3e49c395e96f7323398f0f041d94f8de9bb0', @@ -66,7 +66,7 @@ const EXPECTED_FUNCTION_HASHES: Record = { }; const EXPECTED_GENERATED_SKILL_CONTENT_HASHES: Record = { - 'openspec-explore': '4d9736372cc1faf8a5d8a66395a95bf77b9f3fcd2cda40411ad1db6927e8066a', + 'openspec-explore': '5c848086e19d6b31e217dc7b4d821af0f52e78964cf9d25946e0091541362edc', 'openspec-new-change': 'ec4529beef978e34634a6f7286fab55d68fad8fb374dceb45691d52caab33fbb', 'openspec-continue-change': 'bb6194a16c54891cdb253678e8f70ce53b2af86735243980f366ce551d37e42e', 'openspec-apply-change': '81ea96d9fa6ec8536cd23c1fe561ed28e1cc1cad0a8ceb700588e08974cc0e49', diff --git a/test/core/templates/spec-inventory.test.ts b/test/core/templates/spec-inventory.test.ts new file mode 100644 index 0000000000..7c595d6e0a --- /dev/null +++ b/test/core/templates/spec-inventory.test.ts @@ -0,0 +1,79 @@ +import path from 'path'; +import { fileURLToPath } from 'url'; +import { describe, expect, it } from 'vitest'; + +import { + getSkillTemplates, + getCommandTemplates, +} from '../../../src/core/shared/skill-generation.js'; +import { + getExploreSkillTemplate, + getOpsxExploreCommandTemplate, +} from '../../../src/core/templates/skill-templates.js'; +import { loadSchema } from '../../../src/core/artifact-graph/schema.js'; + +// #1689: 1.9.0 removed openspec/AGENTS.md, which carried the spec index, and +// nothing that replaced it ever named the verb that lists specs. Measured +// across one repo's generated surfaces: `openspec list --json` (the CHANGE +// list) appeared 10 times, `openspec list --specs` zero times. An agent told +// to "read the existing specs first" reaches for the one enumeration verb it +// was taught, gets the in-flight change list, and reports the step complete +// against the wrong object. +const SPEC_INVENTORY = 'openspec list --specs'; + +const repoRoot = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '../../..'); +const defaultSchema = loadSchema(path.join(repoRoot, 'schemas', 'spec-driven', 'schema.yaml')); + +function instructionFor(artifactId: string): string { + const artifact = defaultSchema.artifacts.find(entry => entry.id === artifactId); + expect(artifact, `spec-driven has no "${artifactId}" artifact`).toBeDefined(); + const instruction = artifact?.instruction; + expect(instruction, `spec-driven "${artifactId}" has no instruction`).toBeDefined(); + return instruction as string; +} + +const exploreBodies: Array<[string, string]> = [ + ['explore skill', getExploreSkillTemplate().instructions], + ['explore command', getOpsxExploreCommandTemplate().content], +]; + +describe('spec inventory vocabulary (#1689)', () => { + it('teaches the spec-inventory verb somewhere in the generated surfaces', () => { + const bodies = [ + ...getSkillTemplates().map(entry => entry.template.instructions), + ...getCommandTemplates().map(entry => entry.template.content), + ]; + + const carriers = bodies.filter(body => body.includes(SPEC_INVENTORY)); + expect( + carriers.length, + `no generated skill or command names "${SPEC_INVENTORY}", so the spec inventory is unreachable by any path the tool teaches` + ).toBeGreaterThan(0); + }); + + it('names the spec inventory in explore, where the agent orients', () => { + for (const [label, body] of exploreBodies) { + expect(body, label).toContain(SPEC_INVENTORY); + } + }); + + it('distinguishes the change list from the spec inventory in explore', () => { + // Naming the command is not enough on its own: `openspec list` defaults to + // changes, so the two enumerations have to be told apart explicitly. + for (const [label, body] of exploreBodies) { + expect(body, label).toContain('openspec list --json'); + expect(body, label).toContain('`openspec list` on its own never shows it'); + } + }); + + it('names the spec inventory where the proposal picks capabilities', () => { + // "Research existing specs before filling this in" named no command, which + // is how the Capabilities section ends up inventing a near-duplicate + // capability instead of reusing the existing one. + expect(instructionFor('proposal')).toContain(SPEC_INVENTORY); + }); + + it('names the spec inventory where a delta must match an existing path', () => { + expect(instructionFor('specs')).toContain(SPEC_INVENTORY); + }); +}); From 68fb239abcb91d520204b0b2b2ba3c00fc99909b Mon Sep 17 00:00:00 2001 From: Clay Good Date: Wed, 19 Aug 2026 10:44:01 -0500 Subject: [PATCH 2/4] fix(guidance): carry the store qualifier wherever the command is named MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A bare `openspec list --specs` reads the local inventory, so under a selected store it confirms a capability path against the wrong root. The proposal instruction carried the qualifier; the modified-capability instruction did not. All four sites now use the same wording, and the guard is scoped to the passage that names the command — every explore body already carries the qualifier in its unrelated capture steps, so a whole-body assertion would pass with it dropped here. Addresses CodeRabbit review on #1700. Co-Authored-By: Claude Opus 5 --- schemas/spec-driven/schema.yaml | 6 ++--- skills/openspec-explore/SKILL.md | 2 +- src/core/templates/workflows/explore.ts | 4 +-- .../templates/skill-templates-parity.test.ts | 6 ++--- test/core/templates/spec-inventory.test.ts | 25 +++++++++++++++++++ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/schemas/spec-driven/schema.yaml b/schemas/spec-driven/schema.yaml index c7eebbbbf1..f992113e8a 100644 --- a/schemas/spec-driven/schema.yaml +++ b/schemas/spec-driven/schema.yaml @@ -20,8 +20,8 @@ artifacts: IMPORTANT: The Capabilities section is critical. It creates the contract between proposal and specs phases. Research existing specs before filling this in: run `openspec list --specs` for the project's capability inventory (add - `--json` for ids and requirement counts, and `--store ""` when a - registered store is selected), then read + `--json` for ids and requirement counts, and `--store ""` only for a + registered standalone store), then read `openspec/specs//spec.md` for any that look related. `openspec list` without `--specs` lists in-flight changes, not specs - it never shows what the project already covers. Reuse an existing @@ -70,7 +70,7 @@ artifacts: `` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path: - New capabilities: use the exact path from the proposal at `specs//spec.md`. Any path segment newly introduced in the proposal must be kebab-case. Follow the project's existing organization; do not add a new domain level when the project uses a flat layout. - - Modified capabilities: use the exact existing path from `openspec/specs//` when creating the delta at `specs//spec.md`. Run `openspec list --specs` to confirm that path before writing the delta - a mistyped or invented path targets a capability that does not exist rather than the one you meant. Do not move or rename the capability. + - Modified capabilities: use the exact existing path from `openspec/specs//` when creating the delta at `specs//spec.md`. Run `openspec list --specs` to confirm that path before writing the delta, appending `--store ""` only for a registered standalone store - a mistyped or invented path targets a capability that does not exist rather than the one you meant. Do not move or rename the capability. There must be at least one spec file unless the change's `.openspec.yaml` sets `skip_specs: true` (no spec-level behavior change) - `openspec validate` diff --git a/skills/openspec-explore/SKILL.md b/skills/openspec-explore/SKILL.md index d5493e5a37..4001e04038 100644 --- a/skills/openspec-explore/SKILL.md +++ b/skills/openspec-explore/SKILL.md @@ -97,7 +97,7 @@ That is the *change* list - work in flight. It does not include the project's du ```bash openspec list --specs ``` -Add `--json` for ids and requirement counts, and `--store ""` when a registered store is selected. This is the inventory of what the project already claims to do, and `openspec list` on its own never shows it. Read `/openspec/specs//spec.md` for any capability that looks related before proposing new behavior. +Add `--json` for ids and requirement counts, and append `--store ""` only for a registered standalone store. This is the inventory of what the project already claims to do, and `openspec list` on its own never shows it. Read `/openspec/specs//spec.md` for any capability that looks related before proposing new behavior. Then read the project's own context from the resolved root - `/openspec/config.yaml` (or `config.yml`). Use the `root.path` returned above, and skip this if neither file exists: - `context`: project background - tech stack, conventions, constraints diff --git a/src/core/templates/workflows/explore.ts b/src/core/templates/workflows/explore.ts index ccfd8c8cfd..3f319f0eda 100644 --- a/src/core/templates/workflows/explore.ts +++ b/src/core/templates/workflows/explore.ts @@ -99,7 +99,7 @@ That is the *change* list - work in flight. It does not include the project's du \`\`\`bash openspec list --specs \`\`\` -Add \`--json\` for ids and requirement counts, and \`--store ""\` when a registered store is selected. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. +Add \`--json\` for ids and requirement counts, and append \`--store ""\` only for a registered standalone store. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. Then read the project's own context from the resolved root - \`/openspec/config.yaml\` (or \`config.yml\`). Use the \`root.path\` returned above, and skip this if neither file exists: - \`context\`: project background - tech stack, conventions, constraints @@ -420,7 +420,7 @@ That is the *change* list - work in flight. It does not include the project's du \`\`\`bash openspec list --specs \`\`\` -Add \`--json\` for ids and requirement counts, and \`--store ""\` when a registered store is selected. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. +Add \`--json\` for ids and requirement counts, and append \`--store ""\` only for a registered standalone store. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. Then read the project's own context from the resolved root - \`/openspec/config.yaml\` (or \`config.yml\`). Use the \`root.path\` returned above, and skip this if neither file exists: - \`context\`: project background - tech stack, conventions, constraints diff --git a/test/core/templates/skill-templates-parity.test.ts b/test/core/templates/skill-templates-parity.test.ts index 57495ec2a4..83d902b19d 100644 --- a/test/core/templates/skill-templates-parity.test.ts +++ b/test/core/templates/skill-templates-parity.test.ts @@ -38,14 +38,14 @@ import { import { STORE_SELECTION_GUIDANCE } from '../../../src/core/templates/workflows/store-selection.js'; const EXPECTED_FUNCTION_HASHES: Record = { - getExploreSkillTemplate: '64e2f121985877941f6a1e4164810c338af5cde1fec2a7c28e58012738a2ad25', + getExploreSkillTemplate: 'e3940891ca8334f94be4f33f3d680005728108e4eb8e1ed02cf5da42ab24500b', getNewChangeSkillTemplate: 'eabd1e895c5881dcb17dcbaa3fb26098dd59e8eacb318e400820b4dc811ef781', getContinueChangeSkillTemplate: '012136f6411a99c8fa228e2f9444cb64b0a89e0f56fdeac2fe03b2f5bee0c5d7', getApplyChangeSkillTemplate: 'd1e7d5ceb85193c0964057dbb88e9651526754bd33f84020e2440ff0621d5dbb', getFfChangeSkillTemplate: '5501740e7ec36ab23ab8c3a0d6dd0655a5e2f35433c7b90e82904fef5e7a326a', getSyncSpecsSkillTemplate: 'b099e2ff31859c9b10d928066e662524f9aad9ecf2be12fceacb732d718c4146', getOnboardSkillTemplate: '29b1d825179cff92fbc7b790694c1baef138575ea3de56848715e27d7e367946', - getOpsxExploreCommandTemplate: '056249b459e124f4e347592489a3adac6b22b4b3a544b7158f0147306e9527b0', + getOpsxExploreCommandTemplate: 'b4284eca8d95411c08b542f54c9be2b8451b53ab3c45ead74b95be2030f88a4e', getOpsxNewCommandTemplate: 'f2d30e569798a4c92ba932859d6ba4e0ad10e18feccbade1cfee0957597b3463', getOpsxContinueCommandTemplate: 'e50e50266efa1b8e64ff9b6274ee8254f0a240d6adc1b862d126e2f1c9d3a559', getOpsxApplyCommandTemplate: 'e3579ac78f2e2c75fa3d3a7ac7dc3e49c395e96f7323398f0f041d94f8de9bb0', @@ -66,7 +66,7 @@ const EXPECTED_FUNCTION_HASHES: Record = { }; const EXPECTED_GENERATED_SKILL_CONTENT_HASHES: Record = { - 'openspec-explore': '5c848086e19d6b31e217dc7b4d821af0f52e78964cf9d25946e0091541362edc', + 'openspec-explore': 'db652b920755f2a3a4466050087b55dfe60c57052eef09afda49ddf32905c77b', 'openspec-new-change': 'ec4529beef978e34634a6f7286fab55d68fad8fb374dceb45691d52caab33fbb', 'openspec-continue-change': 'bb6194a16c54891cdb253678e8f70ce53b2af86735243980f366ce551d37e42e', 'openspec-apply-change': '81ea96d9fa6ec8536cd23c1fe561ed28e1cc1cad0a8ceb700588e08974cc0e49', diff --git a/test/core/templates/spec-inventory.test.ts b/test/core/templates/spec-inventory.test.ts index 7c595d6e0a..b0539a889e 100644 --- a/test/core/templates/spec-inventory.test.ts +++ b/test/core/templates/spec-inventory.test.ts @@ -76,4 +76,29 @@ describe('spec inventory vocabulary (#1689)', () => { it('names the spec inventory where a delta must match an existing path', () => { expect(instructionFor('specs')).toContain(SPEC_INVENTORY); }); + + // A bare `openspec list --specs` reads the local inventory, so under a + // selected store it confirms a capability path against the wrong root. + // Every site that names the command must carry the store qualifier with it. + it('carries the store qualifier everywhere it names the command', () => { + const sites: Array<[string, string]> = [ + ...exploreBodies, + ['proposal instruction', instructionFor('proposal')], + ['specs instruction', instructionFor('specs')], + ]; + + for (const [label, body] of sites) { + const start = body.indexOf(SPEC_INVENTORY); + expect(start, label).toBeGreaterThanOrEqual(0); + + // Scoped to the passage that names the command: every explore body + // already carries the store qualifier in its unrelated capture steps, + // so a whole-body match would pass even with the qualifier dropped here. + const passage = body.slice(start, start + 400); + expect(passage, `${label} names the command without its store qualifier`).toContain( + 'registered standalone store' + ); + expect(passage, label).toContain('--store ""'); + } + }); }); From 0e0b894cadf39479db367645fdee02de7dadca05 Mon Sep 17 00:00:00 2001 From: Clay Good Date: Wed, 19 Aug 2026 11:00:44 -0500 Subject: [PATCH 3/4] fix(guidance): read a listed capability with the store-aware command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The read step I added defeated the fix under a store. It told the agent to list the inventory with `--store ""`, then read the result back from `openspec/specs//spec.md` — a local path. Verified against a registered store: `list --specs --store mystore` returns `store-only-capability`, and the corresponding local read fails outright (or, when a local capability happens to share the name, silently returns a different one). That is the same wrong-object failure #1689 is about, reintroduced one line later. Capabilities are now read with `openspec show "" --type spec --json --no-scenarios`, which resolves against the same root the listing came from and returns purpose plus requirement texts without pulling whole spec files into context. `--type spec` is load-bearing: a change and a spec sharing a name is an ambiguous_item error, and change names routinely mirror capability names. Also documents `--store` on `list` and `show` in docs/cli.md. Both already accepted the flag — the prose at line 228 says so — but neither options table listed it. Co-Authored-By: Claude Opus 5 --- .changeset/teach-spec-inventory-verb.md | 2 +- docs/cli.md | 2 ++ schemas/spec-driven/schema.yaml | 14 ++++++---- skills/openspec-explore/SKILL.md | 2 +- src/core/templates/workflows/explore.ts | 4 +-- .../templates/skill-templates-parity.test.ts | 6 ++-- test/core/templates/spec-inventory.test.ts | 28 ++++++++++++++++++- 7 files changed, 44 insertions(+), 14 deletions(-) diff --git a/.changeset/teach-spec-inventory-verb.md b/.changeset/teach-spec-inventory-verb.md index 0f215b693a..787a046261 100644 --- a/.changeset/teach-spec-inventory-verb.md +++ b/.changeset/teach-spec-inventory-verb.md @@ -2,4 +2,4 @@ "@fission-ai/openspec": patch --- -Teach the generated guidance how to list a project's specs. `openspec list --specs` appeared in no generated skill, command, or artifact instruction, while `openspec list --json` (the in-flight *change* list) appeared throughout, so an agent asked to read the existing specs first enumerated changes instead and reported the step complete against the wrong object. The explore skill and command now list the spec inventory alongside the change list and say which is which, and the spec-driven `proposal` and `specs` instructions name the command where they ask for existing capabilities to be researched and for a delta's path to match an existing one. Fixes #1689. +Teach the generated guidance how to find and read a project's specs. `openspec list --specs` appeared in no generated skill, command, or artifact instruction, while `openspec list --json` (the in-flight *change* list) appeared throughout, so an agent asked to read the existing specs first enumerated changes instead and reported the step complete against the wrong object. The explore skill and command now list the spec inventory alongside the change list and say which is which, and the spec-driven `proposal` and `specs` instructions name the command where they ask for existing capabilities to be researched and for a delta's path to match an existing one. Both steps carry `--store ""`, and capabilities are read with `openspec show "" --type spec --json --no-scenarios` so the read resolves against the same root the listing came from. `docs/cli.md` now documents the `--store` option on `list` and `show`, which both already accepted it. Fixes #1689. diff --git a/docs/cli.md b/docs/cli.md index d17c6d662f..27396c7e39 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -439,6 +439,7 @@ openspec list [options] | `--changes` | List changes (default) | | `--sort ` | Sort by `recent` (default) or `name` | | `--json` | Output as JSON | +| `--store ` | Use a registered store as the OpenSpec root | **Examples:** @@ -495,6 +496,7 @@ openspec show [item-name] [options] | `--type ` | Specify type: `change` or `spec` (auto-detected if unambiguous) | | `--json` | Output as JSON | | `--no-interactive` | Disable prompts | +| `--store ` | Use a registered store as the OpenSpec root | **Change-specific options:** diff --git a/schemas/spec-driven/schema.yaml b/schemas/spec-driven/schema.yaml index f992113e8a..37fec8bb90 100644 --- a/schemas/spec-driven/schema.yaml +++ b/schemas/spec-driven/schema.yaml @@ -19,12 +19,14 @@ artifacts: IMPORTANT: The Capabilities section is critical. It creates the contract between proposal and specs phases. Research existing specs before filling this in: - run `openspec list --specs` for the project's capability inventory (add - `--json` for ids and requirement counts, and `--store ""` only for a - registered standalone store), then read - `openspec/specs//spec.md` for any that look related. - `openspec list` without `--specs` lists in-flight changes, not specs - it - never shows what the project already covers. Reuse an existing + run `openspec list --specs` for the project's capability inventory, then + `openspec show "" --type spec --json --no-scenarios` for any that + look related - that returns a capability's purpose and requirement texts + without pulling whole spec files into context. Append `--store ""` to + both commands only for a registered standalone store, and keep `--type + spec`: a change and a spec sharing a name is otherwise an ambiguous-item + error. `openspec list` without `--specs` lists in-flight changes, not + specs - it never shows what the project already covers. Reuse an existing capability's exact path instead of introducing a near-duplicate name. Each capability listed here will need a corresponding spec file. diff --git a/skills/openspec-explore/SKILL.md b/skills/openspec-explore/SKILL.md index 4001e04038..d3ae07b9ff 100644 --- a/skills/openspec-explore/SKILL.md +++ b/skills/openspec-explore/SKILL.md @@ -97,7 +97,7 @@ That is the *change* list - work in flight. It does not include the project's du ```bash openspec list --specs ``` -Add `--json` for ids and requirement counts, and append `--store ""` only for a registered standalone store. This is the inventory of what the project already claims to do, and `openspec list` on its own never shows it. Read `/openspec/specs//spec.md` for any capability that looks related before proposing new behavior. +Add `--json` for ids and requirement counts, and append `--store ""` only for a registered standalone store. This is the inventory of what the project already claims to do, and `openspec list` on its own never shows it. To look at one, run `openspec show "" --type spec --json --no-scenarios` (same `--store` rule) - it returns that capability's purpose and requirement texts without pulling the whole spec file into context, and `--type spec` stops a change of the same name from making it ambiguous. Then read the project's own context from the resolved root - `/openspec/config.yaml` (or `config.yml`). Use the `root.path` returned above, and skip this if neither file exists: - `context`: project background - tech stack, conventions, constraints diff --git a/src/core/templates/workflows/explore.ts b/src/core/templates/workflows/explore.ts index 3f319f0eda..2ea55de258 100644 --- a/src/core/templates/workflows/explore.ts +++ b/src/core/templates/workflows/explore.ts @@ -99,7 +99,7 @@ That is the *change* list - work in flight. It does not include the project's du \`\`\`bash openspec list --specs \`\`\` -Add \`--json\` for ids and requirement counts, and append \`--store ""\` only for a registered standalone store. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. +Add \`--json\` for ids and requirement counts, and append \`--store ""\` only for a registered standalone store. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. To look at one, run \`openspec show "" --type spec --json --no-scenarios\` (same \`--store\` rule) - it returns that capability's purpose and requirement texts without pulling the whole spec file into context, and \`--type spec\` stops a change of the same name from making it ambiguous. Then read the project's own context from the resolved root - \`/openspec/config.yaml\` (or \`config.yml\`). Use the \`root.path\` returned above, and skip this if neither file exists: - \`context\`: project background - tech stack, conventions, constraints @@ -420,7 +420,7 @@ That is the *change* list - work in flight. It does not include the project's du \`\`\`bash openspec list --specs \`\`\` -Add \`--json\` for ids and requirement counts, and append \`--store ""\` only for a registered standalone store. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. Read \`/openspec/specs//spec.md\` for any capability that looks related before proposing new behavior. +Add \`--json\` for ids and requirement counts, and append \`--store ""\` only for a registered standalone store. This is the inventory of what the project already claims to do, and \`openspec list\` on its own never shows it. To look at one, run \`openspec show "" --type spec --json --no-scenarios\` (same \`--store\` rule) - it returns that capability's purpose and requirement texts without pulling the whole spec file into context, and \`--type spec\` stops a change of the same name from making it ambiguous. Then read the project's own context from the resolved root - \`/openspec/config.yaml\` (or \`config.yml\`). Use the \`root.path\` returned above, and skip this if neither file exists: - \`context\`: project background - tech stack, conventions, constraints diff --git a/test/core/templates/skill-templates-parity.test.ts b/test/core/templates/skill-templates-parity.test.ts index 83d902b19d..da684e35f8 100644 --- a/test/core/templates/skill-templates-parity.test.ts +++ b/test/core/templates/skill-templates-parity.test.ts @@ -38,14 +38,14 @@ import { import { STORE_SELECTION_GUIDANCE } from '../../../src/core/templates/workflows/store-selection.js'; const EXPECTED_FUNCTION_HASHES: Record = { - getExploreSkillTemplate: 'e3940891ca8334f94be4f33f3d680005728108e4eb8e1ed02cf5da42ab24500b', + getExploreSkillTemplate: '8dcf8890d5e7e44c379b7c019fd5e496cf469f8350121cce1d5583d4d54ce047', getNewChangeSkillTemplate: 'eabd1e895c5881dcb17dcbaa3fb26098dd59e8eacb318e400820b4dc811ef781', getContinueChangeSkillTemplate: '012136f6411a99c8fa228e2f9444cb64b0a89e0f56fdeac2fe03b2f5bee0c5d7', getApplyChangeSkillTemplate: 'd1e7d5ceb85193c0964057dbb88e9651526754bd33f84020e2440ff0621d5dbb', getFfChangeSkillTemplate: '5501740e7ec36ab23ab8c3a0d6dd0655a5e2f35433c7b90e82904fef5e7a326a', getSyncSpecsSkillTemplate: 'b099e2ff31859c9b10d928066e662524f9aad9ecf2be12fceacb732d718c4146', getOnboardSkillTemplate: '29b1d825179cff92fbc7b790694c1baef138575ea3de56848715e27d7e367946', - getOpsxExploreCommandTemplate: 'b4284eca8d95411c08b542f54c9be2b8451b53ab3c45ead74b95be2030f88a4e', + getOpsxExploreCommandTemplate: '3bf4bf57784166ed04be68946a4c45e8df629f69d4d52f57f4a863fa69a5ce1d', getOpsxNewCommandTemplate: 'f2d30e569798a4c92ba932859d6ba4e0ad10e18feccbade1cfee0957597b3463', getOpsxContinueCommandTemplate: 'e50e50266efa1b8e64ff9b6274ee8254f0a240d6adc1b862d126e2f1c9d3a559', getOpsxApplyCommandTemplate: 'e3579ac78f2e2c75fa3d3a7ac7dc3e49c395e96f7323398f0f041d94f8de9bb0', @@ -66,7 +66,7 @@ const EXPECTED_FUNCTION_HASHES: Record = { }; const EXPECTED_GENERATED_SKILL_CONTENT_HASHES: Record = { - 'openspec-explore': 'db652b920755f2a3a4466050087b55dfe60c57052eef09afda49ddf32905c77b', + 'openspec-explore': 'd5b0a30e36edaf353d30562ca304ee8145c26e0d8b935221bc233755e9da91b7', 'openspec-new-change': 'ec4529beef978e34634a6f7286fab55d68fad8fb374dceb45691d52caab33fbb', 'openspec-continue-change': 'bb6194a16c54891cdb253678e8f70ce53b2af86735243980f366ce551d37e42e', 'openspec-apply-change': '81ea96d9fa6ec8536cd23c1fe561ed28e1cc1cad0a8ceb700588e08974cc0e49', diff --git a/test/core/templates/spec-inventory.test.ts b/test/core/templates/spec-inventory.test.ts index b0539a889e..aeed205d0c 100644 --- a/test/core/templates/spec-inventory.test.ts +++ b/test/core/templates/spec-inventory.test.ts @@ -21,6 +21,11 @@ import { loadSchema } from '../../../src/core/artifact-graph/schema.js'; // against the wrong object. const SPEC_INVENTORY = 'openspec list --specs'; +// Assertions about the guidance attached to the command are scoped to a window +// after it rather than to the whole body, so an unrelated occurrence elsewhere +// in a long template cannot stand in for the passage under test. +const PASSAGE_WINDOW = 700; + const repoRoot = path.resolve(fileURLToPath(new URL('.', import.meta.url)), '../../..'); const defaultSchema = loadSchema(path.join(repoRoot, 'schemas', 'spec-driven', 'schema.yaml')); @@ -94,11 +99,32 @@ describe('spec inventory vocabulary (#1689)', () => { // Scoped to the passage that names the command: every explore body // already carries the store qualifier in its unrelated capture steps, // so a whole-body match would pass even with the qualifier dropped here. - const passage = body.slice(start, start + 400); + const passage = body.slice(start, start + PASSAGE_WINDOW); expect(passage, `${label} names the command without its store qualifier`).toContain( 'registered standalone store' ); expect(passage, label).toContain('--store ""'); } }); + + // Reading the inventory back by raw path defeats the fix under a store: the + // ids `list --specs --store ` returns are not present under the local + // `openspec/specs/`, so the read either fails or silently lands on a + // same-named local capability - the wrong-object failure #1689 is about. + // `openspec show` resolves against the same root the listing came from. + it('reads a listed capability with the store-aware command', () => { + const sites: Array<[string, string]> = [ + ...exploreBodies, + ['proposal instruction', instructionFor('proposal')], + ]; + + for (const [label, body] of sites) { + const start = body.indexOf(SPEC_INVENTORY); + const passage = body.slice(start, start + PASSAGE_WINDOW); + expect(passage, `${label} does not name a store-aware read`).toContain('openspec show'); + // A change and a spec may share a name; without --type that is an + // ambiguous-item error rather than the spec the agent asked for. + expect(passage, `${label} omits the --type spec disambiguator`).toContain('--type spec'); + } + }); }); From d34bb31ffd8c6e5bf599536c52949682a7dd36a7 Mon Sep 17 00:00:00 2001 From: Clay Good Date: Mon, 24 Aug 2026 14:38:43 -0500 Subject: [PATCH 4/4] test(guidance): pin store-aware spec reads --- test/core/templates/spec-inventory.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/core/templates/spec-inventory.test.ts b/test/core/templates/spec-inventory.test.ts index 97dfb8dd6d..3f74e810e9 100644 --- a/test/core/templates/spec-inventory.test.ts +++ b/test/core/templates/spec-inventory.test.ts @@ -20,6 +20,7 @@ import { loadSchema } from '../../../src/core/artifact-graph/schema.js'; // was taught, gets the in-flight change list, and reports the step complete // against the wrong object. const SPEC_INVENTORY = 'openspec list --specs'; +const SPEC_READ = 'openspec show "" --type spec --json --no-scenarios'; // Assertions about the guidance attached to the command are scoped to a window // after it rather than to the whole body, so an unrelated occurrence elsewhere @@ -125,7 +126,16 @@ describe('spec inventory vocabulary (#1689)', () => { // disambiguates a same-named change, JSON makes the result structured, // and --no-scenarios avoids pulling every scenario into context. expect(passage, `${label} does not name the complete store-aware read`).toContain( - 'openspec show "" --type spec --json --no-scenarios' + SPEC_READ + ); + + // Tie the conditional store qualifier to the read itself. A separate + // --store mention for the inventory list must not let a local-root read + // pass this guard. + const readStart = passage.indexOf(SPEC_READ); + const readContext = passage.slice(readStart, readStart + 350); + expect(readContext, `${label} does not apply the store rule to the read`).toMatch( + /(?:same `--store` rule|Append `--store ""` to\s+both commands only for a registered standalone store)/ ); } });