You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "Alexhans (via GitHub)" <gi...@apache.org> on 2026/07/07 02:37:34 UTC
[PR] feat(adapter/kiro): first-class Kiro CLI skill runtime [magpie]
Alexhans opened a new pull request, #768:
URL: https://github.com/apache/magpie/pull/768
## Summary
- Bring **Kiro CLI** (the rebranded Amazon Q Developer CLI — the subject of
#320) to first-class parity with Claude Code and OpenCode as a skill runtime,
following the `docs/adapters/add-a-harness.md` recipe (#741).
- **Discovery:** Kiro reads `.kiro/skills/` (not `.agents/skills/`), so this adds
a `kiro` row to the `skills/setup/agents.md` registry plus the per-skill
relays. The registry-driven adopt/verify/worktree-init logic then wires Kiro
automatically; `.agents` / `.github` / `.kiro` all carry the 69 `magpie-*`
relays.
- **Enforcement (agent-harness score: Kiro now 5/5 substrate tools):**
agent-guard (`--kiro` `preToolUse` adapter), sandbox-lint (`--kiro`),
permission-audit (`audit-kiro`), agent-isolation (`kiro-iso`), and spec-loop
(headless `kiro-cli chat --no-interactive`) all support Kiro.
## Context
#320 was filed for "Amazon Q Developer CLI"; Amazon Q was rebranded to **Kiro
CLI**, and the issue's suggested `~/.aws/amazonq/agents/<name>.json` path is
superseded by Kiro's `.kiro/skills/` + agent-config model — this PR implements
current Kiro.
Kiro's permission model is an allowlist/denylist (`toolsSettings.shell`
`allowedCommands` / `deniedCommands` = `\A..\z`-anchored regex, deny-before-allow,
`denyByDefault`, `autoAllowReadonly`) rather than OpenCode's per-command decision
map; the sandbox-lint / permission-audit invariants resolve through that. The
agent-guard adapter shares the harness-agnostic `dispatch()` core, so verdicts
are byte-identical across harnesses.
This follows the path paved by the OpenCode harness-adapter PRs (#686, #687,
#688) — the same shared-`dispatch()` / thin-adapter pattern applied to a third
harness. This is a a single PR (rather than OpenCode's incremental slices)
because Kiro additionally needs **discovery** wiring — the `skills/setup/agents.md`
registry row plus the per-skill relays — that OpenCode did not require (OpenCode
reads `.agents/skills/` for free).
## Type of change
- [x] Python package (`tools/*/` with `pyproject.toml`)
- [x] Tool / bridge contract (`tools/<system>/*.md`)
- [x] CI / dev loop (`prek`, validators)
- [x] Documentation (`docs/`, tool READMEs)
## Test plan
- [x] `prek run --all-files` passes
- [x] `uv run pytest` for each touched package (agent-guard, sandbox-lint,
permission-audit, agent-isolation, symlink-lint) passes; `ruff` + `mypy` clean
- [x] spec-loop `tests/test_runner_fixtures.sh` covers the Kiro launch argv
(`kiro-cli chat --no-interactive <prompt>`, no `--model`)
- [x] **Discovery proven:** a fresh `kiro-cli chat --no-interactive` discovers
all skills with the `.kiro/skills/` relays present, and **0 without**
(negative control); `symlink-lint` verifies the relays are cycle-free and
target-correct
- [x] **agent-guard proven end-to-end:** a real `.kiro` `preToolUse` hook
**blocks** a `Co-Authored-By` commit (commit not created) and allows a
clean one
- [x] `vendor-neutrality-score` regenerates with Kiro at 5/5 substrate tools
- [x] **Real-adopter end-to-end:** adopted this branch into a downstream repo (Apache
Airflow fork) via `/magpie-setup` — it auto-wired `.kiro/skills/`, and Kiro
**loaded and invoked** framework skills with no gotchas (default-agent auto-load)
- [x] **Custom agents covered too:** verified on `kiro-cli 2.11.1` that skills auto-load
for *both* default and custom agents — `/context show` shows the CLI injecting
workspace `.kiro/skills/*/SKILL.md` + global `~/.kiro/skills/*/SKILL.md` with no
explicit `skill://` resource. (The kiro.dev docs mention custom agents may need
`resources: [skill://…]`; this CLI version does not require it.)
## Known limitations
- `agent-isolation` covers the `env -i` credential-strip launcher (unit-tested);
the bubblewrap OS-sandbox layer is not exercised in CI (unprivileged user
namespaces unavailable in the dev environment) — deferred to a bwrap-capable
host, consistent with how OpenCode's OS-sandbox layer is treated.
- The `sandbox-lint` / `permission-audit` `--kiro` config-posture checks ship
alongside the agent-guard hook as defense-in-depth (OpenCode precedent). A
*general* `/magpie-setup` auto-installer for non-Claude harness enforcement is
out of scope here (Claude-only today; a follow-up would cover OpenCode + Kiro
together).
---
*Gen-AI disclosure: authored with Kiro CLI (Opus 4.8) and reviewed by me.
Commits carry a `Generated-by:` trailer; no AI `Co-Authored-By`.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(adapter/kiro): first-class Kiro CLI skill runtime [magpie]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on PR #768:
URL: https://github.com/apache/magpie/pull/768#issuecomment-4900955225
Nice, focused harness addition. The thin-adapter-over-shared-`dispatch()` pattern is
applied cleanly across all five substrate tools, the 69 `.kiro` relays match the existing
`.agents`/`.claude`/`.github` convention, and the test coverage is strong (including the
differential `--kiro`/`--opencode` verdict test). A couple of small observations, neither blocking.
### Smaller observations
- tools/permission-audit/src/permission_audit/cli.py — _cmd_audit_kiro reads the Kiro config through _read_opencode_config(...). It's functionally a generic JSON read, but the OpenCode-named helper on the Kiro path reads as a copy-paste artifact. A harness-neutral name (_read_json_config) would make audit-kiro self-documenting.
- `tools/sandbox-lint/src/sandbox_lint/kiro.py` and
`tools/permission-audit/src/permission_audit/kiro.py` duplicate `effective_shell_decision`,
`_regex_fullmatch_any`, and the `SHELL_TOOL_NAMES`/`WILDCARD_TOOL_NAMES`/`EXFIL_TOOLS`
constants near-verbatim. This tracks the existing per-tool duplication of the OpenCode
logic, so it's consistent with keeping the tool packages independently installable —
raising it only so the choice is deliberate rather than accidental.
> *This review was drafted by an AI-assisted tool and confirmed by a Magpie
> maintainer. The findings below are observations, not blockers; a Magpie
> maintainer — a real person — will take the next look at the PR. If you think a
> finding is mis-applied, please reply on the PR and a maintainer will weigh in.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(adapter/kiro): first-class Kiro CLI skill runtime [magpie]
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #768:
URL: https://github.com/apache/magpie/pull/768#discussion_r3534174708
##########
tools/sandbox-lint/src/sandbox_lint/__init__.py:
##########
@@ -279,6 +279,21 @@
return 1
+def _lint_kiro(config_path: Path) -> int:
+ """Lint a Kiro CLI agent-config permission policy (invariants only)."""
+ from sandbox_lint.kiro import check_kiro_invariants
+
+ config = _load_json(config_path)
+ errors = check_kiro_invariants(config)
+ if not errors:
+ print(f"sandbox-lint: OK ({config_path} permission policy satisfies the Kiro invariants)")
+ return 0
+ print(f"sandbox-lint: Kiro permission-policy violations in {config_path}:", file=sys.stderr)
+ for e in errors:
+ print(f" - {e}", file=sys.stderr)
Review Comment:
## CodeQL / Clear-text logging of sensitive information
This expression logs [sensitive data (secret)](1) as clear text.
[Show more details](https://github.com/apache/magpie/security/code-scanning/31)
##########
tools/agent-guard/tests/test_kiro.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests for the Kiro CLI adapter entry point.
+
+Kiro's ``preToolUse`` hook feeds ``{"tool_name", "tool_input": {"command"},
+"cwd"}`` on stdin and blocks a tool call on exit code 2 with the reason on
+STDERR. These tests drive the ``--kiro`` I/O shell and assert it reaches the
+same guard decisions as the shared :func:`agent_guard.dispatch` core that
+backs the Claude Code hook and the OpenCode adapter.
+"""
+
+from __future__ import annotations
+
+import io
+import json
+
+import pytest
+
+import agent_guard
Review Comment:
## CodeQL / Module is imported with 'import' and 'import from'
Module 'agent_guard' is imported with both 'import' and 'import from'.
[Show more details](https://github.com/apache/magpie/security/code-scanning/32)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(adapter/kiro): first-class Kiro CLI skill runtime [magpie]
Posted by "Alexhans (via GitHub)" <gi...@apache.org>.
Alexhans commented on PR #768:
URL: https://github.com/apache/magpie/pull/768#issuecomment-4916878366
Hey, sorry I've been unable to look and address the PR comments and create a new revision yesterday. I'll address any leftover comments in my next session.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(adapter/kiro): first-class Kiro CLI skill runtime [magpie]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #768:
URL: https://github.com/apache/magpie/pull/768#issuecomment-4916773967
I rebased this onto latest `main` and reconciled the overlaps with the two harness-adapter PRs that merged since you opened this:
- **agent-guard** `__init__.py`: combined your `kiro_main()` + `--kiro` routing with #765's `--check`/`--exec` modes and the `Segment` basename-normalization fix — all four adapters (Claude/OpenCode/Kiro + check/exec) coexist.
- **agent-isolation** `agent-iso.sh` / README: combined your `kiro-iso` entry with #764's generic `agent-iso <cli>` entry point and the no-push-gate posture note.
- **vendor-neutrality.md**: regenerated via `vendor-neutrality-score --in-place` (agent-isolation is now `agnostic` per #764, so it moved out of the Kiro/OpenCode-specific lists into `any harness`; Kiro lands at 4 enforcement tools alongside OpenCode).
- **CodeQL #32** (dual import in `test_kiro.py`): fixed by consolidating onto the `from agent_guard import …` line.
The remaining CodeQL alert (#31, clear-text logging in `sandbox_lint/__init__.py`) is a false positive — the flagged `print(f" - {e}")` is byte-identical to the pre-existing `_lint_opencode` path CodeQL already accepts; it only fires because the Kiro copy is new code. Dismissing it as such. Local `pytest` for all five touched packages + `ruff`/`mypy` pass. Thanks @Alexhans.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(adapter/kiro): first-class Kiro CLI skill runtime [magpie]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #768:
URL: https://github.com/apache/magpie/pull/768
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(adapter/kiro): first-class Kiro CLI skill runtime [magpie]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #768:
URL: https://github.com/apache/magpie/pull/768#discussion_r3537872501
##########
tools/sandbox-lint/src/sandbox_lint/__init__.py:
##########
@@ -279,6 +279,21 @@ def _lint_opencode(config_path: Path) -> int:
return 1
+def _lint_kiro(config_path: Path) -> int:
+ """Lint a Kiro CLI agent-config permission policy (invariants only)."""
+ from sandbox_lint.kiro import check_kiro_invariants
+
+ config = _load_json(config_path)
+ errors = check_kiro_invariants(config)
+ if not errors:
+ print(f"sandbox-lint: OK ({config_path} permission policy satisfies the Kiro invariants)")
+ return 0
+ print(f"sandbox-lint: Kiro permission-policy violations in {config_path}:", file=sys.stderr)
+ for e in errors:
+ print(f" - {e}", file=sys.stderr)
Review Comment:
**CI blocker (CodeQL alert #31 — clear-text logging of sensitive data).** The invariant messages in `e` inline `matched!r` (the adopter's config regex), and CodeQL's taint tracker treats that config-derived value as a secret reaching a log sink. This is a defensible false positive — echoing *which* rule tripped the invariant is the linter's whole job — but `CodeQL` is a required check and it's red, so it needs resolving before this can land. Two clean options: **(a)** refactor so the message names the offending rule without inlining the raw pattern, or **(b)** add a reviewed inline CodeQL suppression comment with a one-line justification. Either is fine.
##########
tools/agent-guard/tests/test_kiro.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests for the Kiro CLI adapter entry point.
+
+Kiro's ``preToolUse`` hook feeds ``{"tool_name", "tool_input": {"command"},
+"cwd"}`` on stdin and blocks a tool call on exit code 2 with the reason on
+STDERR. These tests drive the ``--kiro`` I/O shell and assert it reaches the
+same guard decisions as the shared :func:`agent_guard.dispatch` core that
+backs the Claude Code hook and the OpenCode adapter.
+"""
+
+from __future__ import annotations
+
+import io
+import json
+
+import pytest
+
+import agent_guard
+from agent_guard import ALLOW_EXIT, DENY_EXIT, kiro_main
Review Comment:
**CI blocker (CodeQL alert #32).** `agent_guard` is imported both as a module here and via `from agent_guard import …` on the next line — CodeQL flags the mixed style and it's failing the required `CodeQL` check. The bare `import agent_guard` is only used once (`agent_guard.opencode_main()` at line 106), so consolidating onto the `from` import clears it:
```suggestion
from agent_guard import ALLOW_EXIT, DENY_EXIT, kiro_main, opencode_main
```
…then update line 106 to call `opencode_main()` directly.
##########
tools/permission-audit/src/permission_audit/cli.py:
##########
@@ -136,6 +137,22 @@ def _cmd_audit_opencode(args: argparse.Namespace) -> int:
return 1 if result.forbidden else 0
+def _cmd_audit_kiro(args: argparse.Namespace) -> int:
+ config_path = Path(args.config_path).resolve()
+ config = _read_opencode_config(config_path)
Review Comment:
**Nit (non-blocking).** `_cmd_audit_kiro` loads the Kiro config via `_read_opencode_config(…)`. It works — both are plain JSON readers — but the `opencode` name is misleading on the Kiro path; a shared `_read_json_config` helper (or a Kiro-named wrapper) would read cleaner. Not a merge blocker.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org