Skip to content

Commit e134c66

Browse files
nik13claude
andcommitted
fix(coding-agents): Kiro IDE installer warns about a Kiro CLI agent profile (TH-8286)
Kiro CLI sessions that use an agent profile running the Kiro CLI recipe's hooks (its --agent-profile setup) also load the Kiro IDE hook file, so they would be exported twice. The installer cannot know where that agent is used, so it warns and names the profile in ~/.kiro/agents (or $KIRO_HOME/agents) or the project's .kiro/agents. This is the reverse order of the Kiro CLI installer's new --agent-profile refusal. Test and page updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8879a06 commit e134c66

3 files changed

Lines changed: 62 additions & 4 deletions

File tree

‎examples/coding-agents/hook-to-otlp/tests/test_kiro_ide_hooks_config.py‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@ def test_unparenthesized_guard_would_lose_a_heredoc_payload(self):
180180

181181

182182
class KiroIdeInstallerTest(unittest.TestCase):
183-
def install(self, project, home, *args):
183+
def install(self, project, home, *args, cwd=None):
184184
return subprocess.run([str(EXAMPLE / "install.sh"), *(args or (str(project),))], capture_output=True,
185-
text=True, env={"PATH": os.environ.get("PATH", ""), "HOME": str(home)})
185+
text=True, env={"PATH": os.environ.get("PATH", ""), "HOME": str(home)},
186+
cwd=cwd or project.parent)
186187

187188
def test_refuses_when_the_kiro_cli_recipe_shares_a_scope(self):
188189
for where in ("project", "home"):
@@ -211,6 +212,39 @@ def test_keeps_an_existing_hook_file_and_says_when_it_is_stale(self):
211212
self.assertIn("differs from the shipped template", result.stdout)
212213
self.assertEqual((hooks / "fi-hook-to-otlp.json").read_text(), old)
213214

215+
def test_warns_when_a_kiro_cli_agent_profile_runs_the_cli_recipe(self):
216+
# The Kiro CLI recipe's --agent-profile entries, as pasted into a CLI agent profile.
217+
cli_entries = json.dumps({"hooks": [{"trigger": "Stop", "action": {
218+
"type": "command",
219+
"command": '(python3 -B "$HOME/.kiro/fi-hook-to-otlp-kiro-cli/emit.py" kiro_cli Stop 2>/dev/null || true)'}}]})
220+
with tempfile.TemporaryDirectory() as tmp:
221+
root = Path(tmp).resolve() # matches the installer's working-directory paths (/var -> /private/var)
222+
project, home = root / "project", root / "home"
223+
project.mkdir()
224+
home.mkdir()
225+
self.assertEqual(self.install(project, home).stderr, "")
226+
(project / ".kiro/hooks/fi-hook-to-otlp.json").unlink()
227+
228+
profile = home / ".kiro/agents/team/reviewer.json"
229+
profile.parent.mkdir(parents=True)
230+
profile.write_text(cli_entries)
231+
result = self.install(project, home)
232+
self.assertEqual(result.returncode, 0, result.stderr)
233+
self.assertIn(f"warning: {profile} is a Kiro CLI agent profile", result.stderr)
234+
self.assertIn(f"sessions that use that agent in {project} also load this hook file", result.stderr)
235+
self.assertTrue((project / ".kiro/hooks/fi-hook-to-otlp.json").exists(), "a warning, not a refusal")
236+
237+
local = project / ".kiro/agents/local.md"
238+
local.parent.mkdir(parents=True)
239+
local.write_text(f"---\nname: local\n---\n{cli_entries}")
240+
result = self.install(project, home, "--user", cwd=project)
241+
self.assertEqual(result.returncode, 0, result.stderr)
242+
for path in (profile, local):
243+
self.assertIn(f"warning: {path} is a Kiro CLI agent profile", result.stderr)
244+
# From the home directory, ~/.kiro/agents is listed once, not again as a project's agents.
245+
result = self.install(project, home, "--user", cwd=home)
246+
self.assertEqual(result.stderr.count("warning:"), 1, result.stderr)
247+
214248

215249
if __name__ == "__main__":
216250
unittest.main()

‎examples/coding-agents/kiro-ide/install.sh‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#
1010
# Kiro IDE and Kiro CLI V3 both load every .kiro/hooks/*.json file (project and
1111
# ~/.kiro/hooks/), so the Kiro IDE and Kiro CLI recipes cannot both be installed
12-
# where one session would load both: the installer refuses instead.
12+
# where one session would load both: the installer refuses instead. A Kiro CLI
13+
# agent profile that runs the Kiro CLI recipe (its --agent-profile setup) also
14+
# loads this hook file; the installer warns and names that profile.
1315
#
1416
# Uninstall: delete the hook file first, then the emitter directory:
1517
# rm .kiro/hooks/fi-hook-to-otlp.json && rm -r .kiro/fi-hook-to-otlp
@@ -65,6 +67,28 @@ else
6567
echo "hooks: $HOOK_FILE"
6668
fi
6769

70+
# Kiro CLI sessions that use an agent profile running the Kiro CLI recipe's hooks also load
71+
# this hook file. The installer cannot know where that agent is used, so it warns.
72+
if [[ "${1:-}" == "--user" ]]; then
73+
project_agents="$PWD/.kiro/agents"
74+
if [[ "$PWD/.kiro" -ef "$KIRO_DIR" ]]; then
75+
project_agents=""
76+
fi
77+
where=""
78+
else
79+
project_agents="$KIRO_DIR/agents"
80+
where=" in $(dirname "$KIRO_DIR")"
81+
fi
82+
for dir in "$HOME/.kiro/agents" ${KIRO_HOME:+"$KIRO_HOME/agents"} "$project_agents"; do
83+
if [[ -n "$dir" && -d "$dir" ]]; then
84+
grep -rlF -e "fi-hook-to-otlp-kiro-cli/emit.py" -- "$dir" 2>/dev/null || true
85+
fi
86+
done | sort -u | while IFS= read -r profile; do
87+
echo "warning: $profile is a Kiro CLI agent profile that runs the Kiro CLI recipe's hooks." >&2
88+
echo " Kiro CLI sessions that use that agent$where also load this hook file, so they would be" >&2
89+
echo " exported twice (as Kiro IDE and as Kiro CLI): remove its Future AGI entries." >&2
90+
done
91+
6892
echo
6993
echo "Credentials: put FI_API_KEY / FI_SECRET_KEY / FI_PROJECT_NAME in"
7094
echo "~/.config/fi-hook-to-otlp/env (chmod 600). Kiro may not see variables exported in your shell; the env file works either way."

‎src/pages/docs/integrations/coding-agents/kiro-ide.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Kiro sends no turn id and no tool call id. A `Stop` closes the open turn, and ea
117117
- **Daily usage metrics** from Kiro enterprise OpenTelemetry are not joined to sessions, and the IAM Identity Center user id or email from that feed is never added.
118118

119119
<Warning>
120-
**Kiro CLI in the same project.** Kiro CLI V3 also loads `.kiro/hooks/*.json` and `~/.kiro/hooks/*.json`. If you run Kiro CLI in a project that has this hook file, or anywhere after `install.sh --user`, those CLI sessions are exported as **Kiro IDE** sessions. The [Kiro CLI](https://docs.futureagi.com/docs/integrations/coding-agents/kiro-cli) recipe has the same reach in the other direction, so trace one Kiro surface per hook scope: installing both where one session would load both would export every session twice. The installer refuses when it finds the Kiro CLI hook file in the project or in `~/.kiro/hooks/`.
120+
**Kiro CLI in the same project.** Kiro CLI V3 also loads `.kiro/hooks/*.json` and `~/.kiro/hooks/*.json`. If you run Kiro CLI in a project that has this hook file, or anywhere after `install.sh --user`, those CLI sessions are exported as **Kiro IDE** sessions. The [Kiro CLI](https://docs.futureagi.com/docs/integrations/coding-agents/kiro-cli) recipe has the same reach in the other direction, so trace one Kiro surface per hook scope: installing both where one session would load both would export every session twice. The installer refuses when it finds the Kiro CLI hook file in the project or in `~/.kiro/hooks/`. Moving the Kiro CLI hooks into an agent profile (that recipe's `--agent-profile` setup) does not avoid this: CLI sessions that use the agent still load this hook file, so they are exported twice. The installer warns when a profile in `~/.kiro/agents/` or the project's `.kiro/agents/` runs the Kiro CLI emitter, and names it so you can remove its Future AGI entries.
121121
</Warning>
122122

123123
## Privacy

0 commit comments

Comments
 (0)