Skip to content

fix(kiro): resolve a rule reference kiro does not write by where that rule is (0.8.5) - #25

Merged
llima merged 9 commits into
mainfrom
fix/cli-0-8-5
Oct 5, 2026
Merged

llima merged 9 commits into
mainfrom
fix/cli-0-8-5

Conversation

@llima

@llima llima commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR bumps the version to 0.8.5. Merging it publishes craftar@0.8.5 to npm once the release is approved in the npm environment.

What changes. Until now, the kiro emitter rewrote every .claude/rules/ into .kiro/steering/, whether or not kiro writes that file. A reference to a rule kiro does not write became a path to nothing. When claude-code was also a target, the path it replaced was the one that existed. This PR implements the approved spec rule references in the kiro files: each reference is now resolved by where the named rule actually is.

the named rule token link [t](.claude/rules/<x>.md)
kiro writes .kiro/steering/<x>.md (a rule or a steering ingredient) .kiro/steering/<x>.md, as before as before, fragment kept
claude-code writes it .claude/rules/<x>.md, as the Forge wrote it unchanged
only AGENTS.md holds it (agents-md is a target) AGENTS.md (rule: <x>) [t](AGENTS.md)
a rule that reaches no target <x> (rule not in this workspace) t (<x>, rule not in this workspace)
an unknown name .kiro/steering/<x>.md, as before, now reported as before
  • Where it applies. The resolution covers rule bodies, agent prompts and descriptions, command bodies, raw frontmatter, the description of a hand-written command (one with no raw frontmatter), and skill text files.
  • What is left alone. A steering body and the banner are untouched. Patterns and other non-references keep the directory rewrite.
  • One resolver. resolveRuleRefs in src/emitters/shared.ts serves both agents-md and kiro through a mode parameter. Its agents-md mode is byte-identical to 0.8.4: the reviewer fuzzed both modes against 0.8.4.
  • Agent resources do not move. agentResources still reads the original, blanket-rewritten text.
  • New warning. There is at most one kiro: warning about rule references per plan. It has two parts: the references reworded as "rule not in this workspace", and the unknown names, which are still rewritten. It never changes an exit code.

Which workspaces see update

Only files under .kiro/ change. The user approved the kiro byte change at the spec's checkpoint, before the commit, after seeing three things:

  • regen-golden produces no diff under test/golden/;
  • a Forge with the shape import produces keeps every byte;
  • the .kiro/ before/after of the spec's Forge for three target sets.
workspace at the first sync on 0.8.5
every rule a kiro text cites is one kiro writes (every workspace craftar import produced) no byte change; a cited unknown name now adds the warning
a cited rule kiro does not write, claude-code writes it the reference goes back to .claude/rules/<x>.md
a cited rule only AGENTS.md holds AGENTS.md (rule: <x>)
a cited rule that reaches no target <x> (rule not in this workspace), and the warning
a hand-written command whose description cites a rule the description is resolved, including the directory rewrite

An affected workspace shows those files as update, and craftar sync --check exits 1 until it syncs.

Tests

  • 17 spec tests, written literally.
    • On 0.8.4 they fail as the spec says. Tests 6, 7 and 10, the resources assertion of test 8 and the K1 part of test 15 pin output that must not move, and they pass on both versions.
  • Two tests added during review. Each failed before its fix:
    • a raw frontmatter block wins over the unused ingredient.yaml description;
    • a link fragment keeps the directory rewrite.
  • The only edit to an existing test file is the planFor helper in test/emitters/kiro.test.ts. It gained a targets parameter whose default is the old value.

Known limit, fixed by 0.8.6

Link text is treated as opaque. In particular, [`.claude/rules/cc-only.md`](.claude/rules/cc-only.md) for a rule kiro does not write keeps a .kiro/steering/cc-only.md path in its text. Spec §4.3 specifies this ("everything else keeps today's rewrite"), and AGENTS.md (0.8.4) behaves the same way. The user scheduled 0.8.6, right after this release, to fix link text in both emitters with its own byte checkpoint.

Disclosures

  • The YAML of a resolved command description is emitted unquoted (description: Opens per AGENTS.md (rule: md-only)). serializeFrontmatter writes values verbatim by design, for Claude Code round-trips.
  • The link regex is quadratic on long runs of unmatched [. It is unchanged from 0.8.4.
  • The spec asked for an extra warning assertion on the existing test rewrites .claude/rules/ references…. That test was not edited; spec test 9 covers the case.

Test plan

  • npm run typecheck: exit 0 on fd98af6.
  • npm run build: exit 0.
  • vitest without test/ci.test.ts (Linux): 840 passed / 5 skipped.
  • npx tsx test/helpers/regen-golden.ts: no diff under test/golden/.
  • Oracle: skipped. There is no fixture, and the user declined to use a client workspace. The byte evidence:
    • the goldens are unchanged;
    • the reviewer compared whole plans against 9328c40 for an imported sandbox and the spec's Forges, and only the lines in the spec's §4.4 move;
    • the approved before/after probes were re-run after every round, identical each time.
  • Reviews: node-cli-reviewer 2 rounds, the second without blocks or should-fixes; docs-author 2 rounds, the README clean. The nits that change no bytes are applied in fcc5edf and fd98af6.
  • CI green on this PR: 8 of 8 (ubuntu and windows × Node 22 and 24, runs 37289198703, 37289248338).

llima added 9 commits October 4, 2026 20:39
… rule is

Spec 17: a reference to a rule kiro does not write keeps .claude/rules/ when
claude-code writes it, points into AGENTS.md when only that holds it, or reads
"<x> (rule not in this workspace)"; unknown names keep the rewrite and are
reported. One resolver for agents-md and kiro.
…hat 0.8.5 changes

Kiro target paragraph now covers the same resolution agents-md does.
Upgrading section has the new to 0.8.5 notes.
0.8.4 → 0.8.5 in package.json, package-lock.json and src/cli.ts.
serializeFrontmatter ignores the description when frontmatterRaw is set,
so resolving it adds spurious entries to the kiro warning.
In kiro mode, K1 and unknown link fragments passed through unchanged.
Now they go through the blanket rewrite, matching 0.8.4's behavior.
…y once

- Restore the comment about right-boundary class not being RULE_NAME_CHARS
- Restore the comment about / going before - in otherPattern
- Restore offset and order comments for match collection and sorting
- Add UNKNOWN_NAME_KIND constant to make unknown discriminant explicit
- Read agent body once and derive both resolved and rewritten versions from it
- Clarify 'at most one kiro: warning about rule references per plan'
- Clarify 'every rule a kiro text cites is one kiro writes'
- Move parenthetical about agent/command/skill resolution to its own sentence
- Update to 0.8.4: '0.8.5 addresses it in part — see to 0.8.5'
0.8.5 builds the result forward, not reverse; cite spec 17 §4.3
(the contract table), not §4.6 (the no-move guarantee).
Restore three 0.8.4 comments the merge dropped.
A period makes the exception its own sentence; "Files are" clarifies
that the UTF-8/CRLF applies to all kiro output, not just unknown names.
@llima
llima merged commit 38c7c29 into main Oct 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant