Repository navigation
Add Kiro support - #84
Conversation
…he skill text
Kiro CLI is becoming a fourth host. Its skills are bare names, invoked
as /<name>. It reads project skills from .kiro/skills and user skills
from $KIRO_HOME/skills, default ~/.kiro/skills. Its plugin copy lives
under ${KIRO_HOME:-~/.kiro}/t3-pstack/.
Eight rules in tools/substitutions.json that name each host's own form
now name Kiro's as well. poteto-help says the installer covers Kiro and
that Kiro invokes the skill as /poteto-mode. poteto-agent's fallback
search looks in the Kiro copy's path, and that copy carries the
.claude-plugin/plugin.json the next sentence already names.
automate-me, create-verification-skill, and maintain-verification-skill
name .kiro/skills ahead of the .agents/skills fallback. Each derived
file gains only the new clause. bun tools/sync.mjs <component> e58dd04
--bootstrap wrote them at each component's pin.
At e58dd04, bun tools/sync.mjs --dry-run reports no undeclared fork and
no unmatched rule for pstack, cursor-team-kit, and thermos.
bun tools/generate.mjs --check passes.
GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000 passes 532
tests and skips 69.
Kiro will load t3-pstack from a copy of the plugin tree, as Antigravity does. The copy's install, its swap by rename, the byte-for-byte check of the session-start hook's files, and doctor's installed check move from antigravity.mjs to common.mjs, so both harnesses run one implementation. Antigravity's behavior does not change, and its tests pass unchanged.
… names Kiro runs a hook command from a hooks file in its home and names no plugin root, so session-start.sh takes a kiro mode whose second argument is the root. The mode prints the routing text, then a paragraph that a Kiro session needs: skills there have bare names with no t3-pstack: prefix, they load through links, so the plugin root cannot come from a skill's path, and T3's MCP tools may be deferred until loaded. The sheet turning the hook off prints nothing, as on Claude Code. tools/install/kiro.mjs builds the command, quoting each path for sh, so the hook tests run the command the installer will write. The kiro cases run every sheet case with CLAUDE_PLUGIN_ROOT pointing nowhere.
T3 starts a kiro instance on kiro-cli with the instance's KIRO_HOME, else ~/.kiro, and Kiro loads plain skills from <home>/skills and hooks from <home>/hooks. Kiro has no plugin marketplace, so the installer serves it the way it serves Antigravity. Home discovery finds each kiro instance in T3's settings, enabled or not, the built-in kiro instance when no settings entry names it and a project override turns it on, the shell's KIRO_HOME, and each --kiro-home. A machine where nothing names a Kiro home gets no Kiro row. One table per harness now holds its home variable, default home, and default CLI, so kiro-cli has one owner, and the discovery logic splits into smaller functions on the way. In each home, install copies the plugin to <home>/t3-pstack, links each skill from <home>/skills to the copy, and writes hooks/t3-pstack.json, which runs session-start.sh at SessionStart and PostCompact. Kiro has no skill namespace, so an entry of a skill's name that the installer did not make keeps that skill from loading: install leaves the entry as it is and links the rest, and doctor fails it by name with its kind and fix. Install repoints a link of its own at the wrong target, unlinks a skill the release dropped, and rewrites a changed hooks file. The unit tests cover discovery, a converging second run, each collision kind, dropped and misdirected links, a home reached through a symlink, a changed hooks file, the hook command from a path with a space and a quote, and one CLI run with a stand-in kiro-cli.
The unit tests prove what the installer writes, not that Kiro loads it. A new e2e suite, run when kiro-cli is on PATH, names a kiro instance in T3's settings with its KIRO_HOME under the throwaway HOME. Install converges that home with every check passing, a second install changes no file, and doctor passes. Then the suite starts kiro-cli as T3 does, with `acp --agent-engine=v3 --auth-method=cli` and T3's initialize, which opts into the hooks files in KIRO_HOME, and opens a session with a dummy API key. The session lists every plugin skill as a skill command, and Kiro's log shows both hooks registered and no warning naming hooks/t3-pstack.json. KIRO_HOME joins the variables each suite clears. A `kiro-cli chat` run with no account fails at the model call and can exit before Kiro sends the skill list, so the suite sends no prompt. Without the opt-in, Kiro loads no hooks file at all. Run on kiro-cli 3.5 with T3_PSTACK_E2E=1. With the PostCompact trigger misspelled, the suite fails on Kiro's warning for that hook.
README, CONTEXT, and CONTRIBUTING now name Kiro wherever they list the hosts. README's install section says which Kiro homes the installer finds, what it writes in each, what it leaves alone, and what doctor reports there, and gives Kiro's skill form, /<name>. CONTRIBUTING says the Kiro hooks file has no pin and that the e2e test runs its Kiro case when kiro-cli is on PATH.
Kiro threads load t3-pstack: the installer fills each Kiro home T3 runs with a copy of the plugin, a link per skill, and a hooks file, and the session-start hook routes a Kiro session with its plugin root and bare skill names. Minor, since it adds a harness. It syncs nothing from upstream, so the pins stay at e58dd04. The generator restamps the manifests, and README names v2.6.0. bun tools/generate.mjs --check passes, and GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000 passes 561 tests and skips 76.
Kiro settings have no home path, so T3 never reads config.homePath for a kiro instance; it starts Kiro with the instance's KIRO_HOME, else ~/.kiro. The installer read config.homePath first for every harness, so a kiro instance carrying one would get its copy, links, and hooks file in a home Kiro never reads. The harness table now says which harnesses have a home path setting, and only Claude Code and Codex do. The kiro discovery test gives both instances a homePath; it fails without this change and passes with it. GIT_CONFIG_GLOBAL=/dev/null bun test tests/install.test.mjs passes 50 tests.
… prints The Kiro e2e proved the hooks file loaded only through a line in Kiro's log, and never looked at the hook's text. With T3's opt-in, Kiro sends _kiro/hooks/didChange at session start, naming each hook it registered with its trigger, command, and standing. The suite now asserts both t3-pstack hooks are there, at SessionStart and PostCompact, enabled and active, and runs each command as Kiro registered it: each prints the routing text and names the copy as the plugin root. A model sees that text only at its first call, which needs an account. CHANGES states the check. T3_PSTACK_E2E=1 bun test tests/install-e2e.test.mjs -t "on a Kiro home" passes 3 tests with kiro-cli 3.5 on PATH, and fails when session-start.sh loses its kiro mode.
…stack The copy swap renamed whatever held the copy's path aside and deleted it, so a clone at ~/.kiro/t3-pstack lost its .git and files, and the run reported only "installed". The shared copy step now replaces a tree only when none is there or its manifest names t3-pstack. Otherwise install leaves it whole, and doctor's installed check fails, naming the path and saying to move it. A Kiro home with such a tree also gets no skill links or hooks file, since both point into the copy. An Antigravity profile's copy goes through the same step, so it gets the same check. New tests put a clone at a Kiro home's copy path and another plugin in an Antigravity profile's copy folder; both fail without this change. bun tools/generate.mjs --check passes, and GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000 passes.
The generator paragraph listed the hosts whose manifests and hooks files it stamps and checks without Kiro, then added two sentences about Kiro's hooks file. The manifest list now says a Kiro home's copy reports the Claude Code manifest's version, and the hooks sentence says the Kiro hooks file is not in the plugin and, like Antigravity's, has no pin. Doc-only. The readme-facts and generate tests pass.
Adds a CLI test whose T3 kiro instance sets KIRO_HOME to ~/.kiro-work and whose shell sets KIRO_HOME to the home folder. kiro-cli ignores both values and reads ~/.kiro, so the test expects one Kiro row at ~/.kiro with a KIRO_HOME warning that names each value, and nothing written to ~/.kiro-work or the home folder itself. It fails on this commit: the installer fills ~/.kiro-work and the home folder. Checked with `bun test tests/install.test.mjs -t "Kiro ignores"`.
…nores T3 passes a kiro instance's KIRO_HOME as written, and kiro-cli reads ~/.kiro in place of a relative value, such as ~/.kiro-work, or one that holds the home folder. The installer expanded `~` and resolved relative values, so it filled a home Kiro never reads. discoverHomes now applies Kiro's rule to each instance's KIRO_HOME and to the shell's, and records each ignored value on the home. doctorKiro warns first with each value and its source. The kiro path no longer goes through the homePath flag, so the flag is gone. The Kiro end-to-end suite now starts kiro-cli with the instance's literal KIRO_HOME, as T3 does, and expects the installer to fill ~/.kiro. CHANGES and README state the rule. Checked with `bun tools/generate.mjs --check`, `bun test tests/` (564 pass, 0 fail), and `T3_PSTACK_E2E=1 bun test tests/install-e2e.test.mjs -t "on a Kiro home"` on the real kiro-cli (3 pass, 66 skills listed).
Adds a CLI test whose T3 settings name two kiro instances, one per form T3 writes a secret variable in: a secret reference, and a value moved to T3's secret store. Both keep an empty `value` in settings.json, so the installer cannot know the home. The test expects no Kiro row, nothing written to ~/.kiro, a settings warning per instance with the `--kiro-home <dir>` fix, and exit status 0. It fails on this commit: both instances read as an empty KIRO_HOME and the installer fills ~/.kiro. Checked with `bun test tests/install.test.mjs -t "T3 secret"`.
T3 keeps a secret variable's value out of settings.json, as a secret reference or as a value moved to its secret store, and leaves `value` empty. The installer read that as an unset KIRO_HOME and filled ~/.kiro, which may not be the home T3 starts kiro-cli on. discoverHomes now adds no home for such an instance and lists it in `settings.secrets`. The installer turns each into a warning in `settings.checks`, counted with the other checks, whose fix reruns the install with `--kiro-home <dir>`. The report prints them under the T3 settings line. CHANGES and README name the case. Checked with `bun tools/generate.mjs --check` and `bun test tests/` (565 pass, 0 fail).
The two substitution rules that write poteto-help's install sentences listed Claude Code, Codex, and Kiro, a list that drifts each time the installer gains a host. Each now says the installer installs t3-pstack in every home T3 can run. The skill-naming rule keeps its per-host forms. Regenerated plugins/pstack/skills/poteto-help/SKILL.md with `bun tools/sync.mjs pstack e58dd04 --bootstrap`, which changed only those two sentences; its rewrite of the pin to a short SHA is not kept. CHANGES drops the poteto-help item from the Kiro forms it lists. Checked with `bun tools/generate.mjs --check` and `bun tools/sync.mjs <component> e58dd04 --dry-run` for pstack, cursor-team-kit, and thermos: no undeclared fork and no unmatched rule.
…cli does Adds a discoverHomes test whose shell KIRO_HOME is <root>/link-b/../c, where link-b is a symlink into <root>/x and <root>/x/c exists. kiro-cli collapses `..` before it resolves symlinks, so it reads <root>/c. It fails on this commit: existsSync follows link-b and finds <root>/x/c, then realpathSync collapses `..` first and throws ENOENT for <root>/c, which aborts the install. Checked with `bun test tests/install.test.mjs -t "collapses"`.
kiroHome passed the raw KIRO_HOME to real(). For <root>/link-b/../c, where link-b is a symlink, existsSync followed link-b to an existing directory, then realpathSync collapsed `..` first and threw ENOENT for <root>/c, so the install exited 2 and filled no home. kiro-cli collapses `..` before it resolves symlinks and reads <root>/c, so real() now gets resolve(dir), as the home it returns already does. Checked with `bun test tests/install.test.mjs -t "collapses"`, the full `bun test tests/`, and an installer run under `env -i` whose KIRO_HOME is <root>/link-b/../c: it fills <root>/c, the directory a kiro-cli 3.5.1-nightly.2 session with the same KIRO_HOME writes.
|
Thank you @ash663, this is great! The live Kiro runs and the tests made it a lot easier to look at. I had it reviewed before merging, and it turned up a few cases where the installer touches files it doesn't own. Each one reproduced in a throwaway home:
I'm a little apprehensive about installer code that writes into people's homes, and I'd want to be sure it never deletes something it didn't put there. Would you be up for taking a look? Happy to help if anything is unclear. The rest held up nicely, by the way. The other hosts' hook output didn't change, and skill collisions and clones were left alone. |
Each new test fails on the branch for the case its name gives. The installer writes through a symlinked hooks file and replaces a hand-written one. It replaces a hand copy of the plugin whose manifest names t3-pstack, personal file included. It never repairs a copy of its own that lost its manifest, on Kiro and, since 440c37e, on Antigravity. A kiro instance with no KIRO_HOME of its own gets ~/.kiro instead of the KIRO_HOME it inherits from the installer's environment. The branch-only Antigravity test for a foreign manifest goes, since main has no such check. The clone test expects the message that names the install record. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/install.test.mjs fails these 9 tests and passes the other 52.
…ecord The Kiro installer took any tree whose .claude-plugin/plugin.json named t3-pstack for its own, so a hand copy of the plugin lost a personal file on update, and it took a copy of its own that lost its manifest for someone else's, so update never repaired it. It wrote the hooks file through writeAtomic, which resolves a symlink, so a link there had its target overwritten, and it replaced any hooks file that differed. Each copy the installer makes carries .t3-pstack-install.json: the version, the relative path of every file it copied, and the sha256 of the hooks text it wrote for the copy. A tree without that record, or holding a file the record does not list, is left as it is, with no links or hooks file pointing into it, and doctor names it. The swap moves the old tree aside, checks that moved tree, and puts it back when the check fails, so a tree that changed during the run is never deleted. The hooks file is written only when it is missing or is the file an earlier release wrote, by that release's record, and the write renames over the path itself. Antigravity and common.mjs go back to main, so an Antigravity copy that lost its manifest reinstalls as it did there. The generator refuses a record in the shipped plugin tree, which would make a hand copy pass for the installer's. The record's name lives in plugin.mjs, which the generator and the installer already share. Testing: bun tools/generate.mjs --check passes. bun test tests/install.test.mjs passes all but the inherited-KIRO_HOME test, which the next commit fixes. A script that patches node:fs to change the copy's path between the first check and the swap keeps the user's file and folder in both cases.
T3 starts a kiro instance with the instance's environment merged over the server's own (provider-core instanceEnvironment.ts), so an instance with no KIRO_HOME entry inherits the one the installer runs with. The installer gave it ~/.kiro and added a second row for the shell's KIRO_HOME. An instance's own entry still wins, an empty one included, since T3 sets any string over the inherited value and kiro-cli reads ~/.kiro for an empty one. T3's built-in kiro instance, found through a project override, inherits the same way. A shell KIRO_HOME and an instance that inherits it name one directory, so discoverHomes merges them into one row with both sources. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000 passes. T3_PSTACK_E2E=1 GIT_CONFIG_GLOBAL=/dev/null bun test tests/install-e2e.test.mjs --timeout 300000 -t Kiro passes on Kiro CLI 3.5.
…_HOME The 2.6.0 entry and the README's Kiro paragraph name the record file, say that a copy holding a file the record does not list is left as it is, that the installer leaves a hooks file it did not write, and that update repairs a copy that lost its manifest. Both say that an instance with no KIRO_HOME of its own, and T3's built-in instance, inherit the installer's. The Antigravity sentence goes, since that check went back to main's. Testing: markdownlint-cli2 0.18.1 reports 0 errors on CHANGES.md and README.md.
The test for a recorded copy holding a personal file also deleted the copy's manifest, so it mixed a file the record does not list with a recorded file gone missing. It now sets the record's and the manifest's version to an earlier one, as an older release leaves them, so install would replace the copy but for the extra file. It checks that the whole tree is unchanged after install. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000 passes. The test fails at 751b6da, and it fails when copyState skips the extra-file check.
The Antigravity test for a copy that lost its manifest moves to the end
of describe("Antigravity"), directly above the Kiro helpers and tests,
so the tests for this change sit together. It keeps the Antigravity
helpers it uses, and its body is unchanged.
Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000
passes.
installKiro read the hooks path before the copy swap and the skill links, then renamed the new hooks file over that path without looking again. A file a user put there while the plugin copied was replaced. writeHooks now reads the state itself, right before the rename. It still judges a stale file by the record read before the swap, which names the text an earlier release wrote. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000 passes. A script that patches node:fs to put a user's hooks file at the path during the copy shows the file replaced before this change and kept after it.
…home The test put a symlink at the hooks path of an empty home, so install still made the copy and the skill links, and only the hooks path went unwritten. It now installs first, then swaps the installer's hooks file for a link to a file of the user's. Install then writes nothing, the link and its target stay byte for byte, and doctor fails the file. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000 passes. The test fails at 751b6da, where install rewrites the link's target.
A --source whose plugins/pstack is a symlink makes the Kiro copy a link into that source, so the installer writes its record into the user's tree. The test installs from such a source through the CLI, runs install again, and checks after each run that the source, its link and the plugin it links to included, is byte for byte as it was. The tree snapshot now reads bytes and records links, so the tests that check a hand copy is left whole compare bytes too. Testing: the test fails at 27755eb, where the record lands in the linked plugin.
replaceCopy ran cpSync on the plugin root as given. When a --source's plugins/pstack is a symlink, cpSync copies the link itself, so the copy in the Kiro home was a link into the source and the record went into the user's tree. The next install from a moved-on source failed with EEXIST and left a temp entry in the home. The copy now starts from the root's real path, so the installer never writes into the source. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/install.test.mjs --timeout 30000 -t Kiro passes, the new --source test included.
…d update An update that swaps the copy in and stops before writing the hooks file leaves the earlier release's hooks text, which the installer wrote. The test installs an earlier release with its own installer, a copy of this one that writes another hooks text at version 2.6.0-rc.1. It updates to this release, writes the earlier text back, as such a run leaves it, and expects the next install to rewrite it. Testing: the test fails at 27755eb, where the next install leaves the file as it is.
The record held only this release's hooks hash. A run that stopped after the swap and before writeHooks left the earlier release's hooks text, which the installer wrote, and every later run called it foreign. At the swap, the record's hooks now lists this release's hash plus the hash of the file at the hooks path when the old record names it, so at most two. hooksState reads the hash and the kind from one read of the file. readRecord reads an older record's single hash string as a list of one, so the rest of the installer sees only a list. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/install.test.mjs --timeout 30000 -t Kiro passes, the stopped-update test included.
The skill links and the hook command name the copy by the path the home was reached by, so a run by the other path repoints every link and rewrites the hooks file, and a later run calls that file foreign. The test installs through a symlink to the home, then through its real path, and expects the second run to change nothing and doctor to pass by both paths. It replaces the test that expected the repoint. Testing: the test fails at 27755eb, where the second run repoints the links and rewrites the hooks file.
copyPath joined the home's path as given, so the skill links and the hook command named the copy by the path the home was reached by. A home reached through a symlink and through its real path got two hook texts and two link targets, so each run by the other path rewrote them and a later run called the hooks file foreign. copyPath now starts from the home's real path, so the copy, the links and the hook text come from one path. A link an earlier run made by the other path still counts as the installer's and is repointed. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/install.test.mjs --timeout 30000 passes, the symlinked-home test included.
deletable restated the ownership rule that copyState and theirs define: a record from the installer and no file it does not list. The swap is the step that deletes, so it now checks the moved tree with that same rule, and deletable goes. Testing: GIT_CONFIG_GLOBAL=/dev/null bun test tests/install.test.mjs --timeout 30000 passes.
T3's desktop app takes only a fixed list of variables from the login shell, and KIRO_HOME is not on it (apps/desktop/src/shell/ DesktopShellEnvironment.ts, LOGIN_SHELL_ENV_NAMES). A T3 opened from the desktop can run its kiro instance at ~/.kiro while the installer's shell sets KIRO_HOME, so the README's Kiro paragraph says so and names --kiro-home ~/.kiro for that case. The 2.6.0 entry now says the record holds the hash of the hooks text the installer writes and of the earlier release's hooks file it replaces. Testing: markdownlint-cli2 0.18.1 reports 0 errors on CHANGES.md and README.md.
|
Thanks for the careful review. All four reproduced here too. They're fixed on the branch, now at 1504a21, with
Two related fixes came up while testing. The copy is made from the plugin source's real path, so a Each case below has a test in
Small windows I know of and left as they are:
Unit tests: 574 pass, 0 fail. End to end: 20 pass, 1 fail, with the 3 Kiro tests on the real |
Closes #42.
Summary
<home>/t3-pstack, links each skill from<home>/skills/<name>into that copy, and writes<home>/hooks/t3-pstack.jsonforSessionStartandPostCompact.session-start.shgets akiromode. Kiro gives a hook no plugin root, so the hooks file passes it as the second argument. The mode adds a paragraph on bare skill names, the plugin root, and loading the deferredt3-codetools.tools/substitutions.json. There are no new rules and no forks.Choices
poteto-modedirectly. A Power also needs a rootplugin.json, which this repo rules out..t3-pstack-install.json, written before the copy is swapped in. It lists every file the installer put there and the hashes of the hooks text it wrote.<home>/t3-pstackwithout that record is left whole, whatever its manifest says. So is a recorded copy that holds a file the record does not list.doctornames either one.updaterepairs it.lstatand never written through a symlink. It is rewritten only when it is missing or still holds text the installer wrote. Anything else stays, anddoctornames it.kiroinstance in T3's settings, T3's built-in Kiro instance when a project turns it on, the shell'sKIRO_HOME, and--kiro-home <dir>. An instance with noKIRO_HOMEof its own inherits the installer's, as T3 merges the instance's environment over its own. Kiro ignores aKIRO_HOMEthat is relative or that holds the home folder, and reads~/.kiroinstead. The installer resolves the value the same way, anddoctorwarns about the ignored value. If T3 stores an instance'sKIRO_HOMEas a secret, the installer skips that instance, anddoctorgives the--kiro-homefix. T3's desktop app does not readKIRO_HOMEfrom the login shell, so the README names--kiro-home ~/.kirofor that case.<home>/skillshas a plugin skill's name, the installer leaves it alone. It links the other skills, anddoctornames the collision.tools/install/antigravity.mjsandtools/install/common.mjsare identical tomain. Kiro does not trust hooks by hash, sotools/frozen-hooks.jsondoes not change, as with Antigravity.Testing
bun tools/generate.mjs --checkpasses.GIT_CONFIG_GLOBAL=/dev/null bun test tests/ --timeout 30000: 574 pass, 76 skip, 0 fail.shellcheck plugins/pstack/hooks/*.shpasses. The sync dry run passes for all three components at0b46ec3.T3_PSTACK_E2E=1 GIT_CONFIG_GLOBAL=/dev/null bun test tests/install-e2e.test.mjs --timeout 300000: 20 pass, 1 fail. The 3 Kiro tests run the realkiro-cli acp(Kiro CLI 3.5) with no account, on a home the installer filled. They check that it lists all 66 skills and that both hooks print the routing text. The failing test is "pins a GitHub or Git URL --source too ...". It fails the same way onmainon this machine.KIRO_HOMEgives one row and leaves~/.kiroalone. All 7 pass.kiro-cli chat --v3session ran on an installed home whose path has a space in it. The hook's output reached the model, and the model foundpoteto-mode.delegate_taskandtask_statusfromt3-code. It started adelegate_taskchild on Claude Code, and that child replied. This ran on a Kiro home set up by hand with the same skills and hook layout, not one this installer filled.