Files
Clay GoodandClaude Opus 5 626269ed73 fix(templates): stop generated skills naming workflows the profile omits (#1775)
* fix(templates): stop generated skills naming workflows the profile omits

The `core` profile installs six of the twelve workflows, but the update
and apply templates named `/opsx:continue` (6 times) and `/opsx:new`
(twice) regardless. On a default install those became
`/openspec-continue-change` and `/openspec-new-change` — skills that were
never written — so `update-change` refused to create a missing artifact
and handed off to a dead end. The only guard was a sentence asking the
model to check availability at runtime, 70 lines above the two places it
hits the wall.

`command-references.ts` decides how a reference is spelled; nothing
decided whether it should be emitted at all. Add that: templates author
both wordings with `optionalWorkflow()`, and `getSkillTemplates()` /
`getCommandTemplates()` — the one place every generation path already
funnels the resolved workflow set through — pick a branch before the
reference transformers run. A profile that omits a workflow now gets a
concrete `openspec status` / `openspec instructions` fallback instead of
a reference to a skill that does not exist.

Closes #1734

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* chore(changeset): describe profile-aware workflow references

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(init): assert the core profile names no uninstalled workflow

The end-to-end init test pinned the runtime availability hedging that
#1734 is about, and asserted `/opsx:continue` appears in the default
profile's generated update workflow — the bug itself. Assert the fixed
behavior instead: neither `/opsx:continue` nor `/opsx:new` appears, and
the CLI fallback is stated outright, for both the update and apply
surfaces.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(templates): resolve every cross-workflow reference, not just core's

The first commit fixed the two templates the default profile broke on.
Every other cross-workflow handoff had the same shape, and arbitrary
subsets are reachable: a `custom` profile is whatever the user picked,
and `openspec update` re-derives a workflow set from what it finds on
disk (legacy tool overrides, inferred Codex workflows) without passing
it through getProfileWorkflows.

So resolve all of them:

- `apply` -> archive; `continue` -> apply, archive; `ff` -> apply;
  `new` -> continue; `propose` -> apply; `update` -> apply, archive;
  `archive` and `bulk-archive` -> sync.
- `onboard`'s two command-reference tables are built from the installed
  set rather than printed in full with an "only if installed" caveat, and
  its explore, resume and next-step prompts are resolved the same way.

Two supporting changes:

- `onlyWithWorkflow()` plus a whole-line rule in the resolver: a
  conditional that owns its line takes the line with it when it resolves
  to empty, so a dropped table row cannot leave a blank line that ends
  the table in markdown.
- `generateSkillContent()` and `generateCommand()` now throw on an
  unresolved marker. A generation path that skips the choke point fails
  loudly instead of writing `[[opsx:...]]` into a user's SKILL.md.

The propose and ff surfaces keep their deliberate wording difference
(#258): the command surface never invites "ask me to implement", so its
missing-`apply` fallback names the CLI rather than a conversation.

The guard test now runs the property over every subset that could expose
a reference — each workflow alone, everything but one, the empty set, and
the two shipped profiles — for skills and commands, in both spellings.
Twenty-plus of those cases fail against the previous commit.

Only `openspec-onboard` changes in the skills/ mirror: with every
workflow installed, all other templates render byte for byte as before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* chore(changeset): cover the full cross-workflow reference fix

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(templates): validate conditionals before choosing a branch

Resolution discarded the unselected branch and only then checked for
residual markers, so a truncated block inside the *missing* branch was
accepted for a profile that installs the workflow and rejected for one
that does not. Profile-dependent authoring errors are exactly what this
module exists to remove.

Validate the authored text up front instead: every marker must be one of
the three recognized forms, and they must appear as a flat sequence of
if / else / end. A malformed block now throws identically for every
profile. The post-resolution check stays as a backstop.

Caught by CodeRabbit on #1775.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs: state the profile-aware handoff rule in the skills reference

alfred-openspec on #1775: docs-lab/reference/skills.md described several
handoffs as unconditional while this change deliberately emits a CLI or
conversational fallback when the profile omits the target.

Stated once, above the entries, rather than as a caveat on each of the eleven
affected Response and Creates rows: the page's recipe is one fact per row, and
repeating the same conditional eleven times would bury the contracts it exists
to state. The rows keep naming the skill that owns the next step, which is the
fact a reader looks up; the rule above them says what happens when that skill
is not installed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(workflows): fold #1735 into the profile-aware references

#1735 fixes the same issue (#1734) by removing the optional handoffs outright.
This PR resolves them at generation time instead, which is strictly better for
the template layer: an install that has `continue` still gets told about it.
So the mechanism here wins and #1735's content is folded in, rather than the
two competing for the same lines.

What #1735 had that this did not:

- src/commands/workflow/instructions.ts. The CLI's own runtime strings named
  the openspec-continue-change skill. Those are chosen at run time, so
  optionalWorkflow() cannot reach them; taken from #1735 verbatim.
- The blocked-state fallback. It was a one-line pointer; it now carries #1735's
  full CLI recovery (select the next `ready` artifact, not `skipped` or
  `blocked`, read its rules with `openspec instructions`, keep the selected
  `--store` on both commands) plus the tracking-file repair path and the
  `missingArtifacts` field it branches on. The installed branch still names
  `/opsx:continue`, so neither audience loses.

#1735's update-change.ts rewrite is not carried over: this PR already covers
all six of those sites conditionally, which is the better answer.

Both of #1735's test suites come across, and they are worth more here than
there. test/core/templates/profile-handoffs.test.ts asserts that no generated
file names an uninstalled workflow across every tool and all three delivery
modes, which is the property this PR's mechanism exists to provide, and it
passes against it. test/commands/profile-handoffs.test.ts covers the runtime
CLI strings. The two guards are complementary: that one is broad on tools and
deliveries, this PR's own profile-workflow-references.test.ts is broad on
workflow subsets.

#1735's command-references.test.ts assertions could not be carried as written,
since they assume the reference is gone unconditionally. Replaced with a case
that resolves the template against a set without `continue` and asserts the
fallback carries the whole recovery. Verified it fails when the fallback is
shortened.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs: name the core-profile fallback on the two rows that hit it

The rule above the entries covers every profile, but apply-change and
update-change are Core skills whose rows name openspec-continue-change, which
the core profile never installs. On the default install those rows now say what
the generated skill points to instead: openspec status and openspec instructions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(changeset): drop em dashes from the release note

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-16 19:17:38 +00:00
..