Repository navigation
fix(agent-config): make the install gate block in OpenCode 2.x, Cline, Gemini CLI and Antigravity - #1140
Merged
Conversation
… Gemini and Antigravity - OpenCode: one plugin file for 2.x (setup) and 1.4+ (server); V1-only form did not load in 2.x. - Cline: read run_commands' commands list (also JSON text); gate every command; unreadable list blocks. - Gemini: --format gemini prints a JSON deny decision; agent-config says the folder must be trusted. - Antigravity: top-level named hook entry, stdout decision plus exit 2; user hooks kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Kit-Hook-Tree: 4ca51367da39b1d76c12283c6937505b81d437e5
…nt installers
- Cline {command, args} entries: each argv word is POSIX single-quoted before the gate parses
the line, so an argument with spaces, quotes, `;` or `&&` stays one word. Args that are not a
list of strings, or hold a NUL byte, make the call unreadable, and it is blocked.
- Cline run_commands: the list is also gated as one newline-joined script, so a `cd` or an
`export` in one command is seen by the next.
- OpenCode: no single plugin file loads in 1.0-1.3 (every export is called as a function) and in
2.x (the default export must be an object). kit reads `opencode --version`: 1.0-1.3 get the
function-only plugin, 1.4+ and 2.x the default-object plugin. With no version, kit keeps a
1.x plugin it wrote before and says so.
- Gemini, OpenCode, Cline and Antigravity installers move to src/agent-gate-installers.ts and
the hook command line to src/kit-invocation.ts; agent-config.ts re-exports them.
- Tests are table-driven: one fixture table per agent.
Test-Growth: four agents' hook contracts (Cline, Gemini CLI, Antigravity, OpenCode 1.x/1.4+/2.x) each need an end-to-end run of the installed hook with the agent's real payload, plus the three security cases; the fixtures are already one table per agent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kit-Hook-Tree: 7ac9db0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Kit-Hook-Tree: f313e77
…nary `opencode --version` ran whatever `opencode` resolved to, with the project as cwd; on Windows with a shell, cmd.exe looks in the current directory first, so a committed opencode.cmd would run during `kit agent-config`. kit now looks only in absolute PATH directories outside the project, reads the version from the npm package.json the binary belongs to, and runs nothing on Windows. On macOS and Linux, when there is no package.json, it runs that absolute binary without a shell from the home directory. A planted `opencode` in the project must not run (test). A default export that is a function with id/setup/server attached is not a fallback: OpenCode 2.x refuses a default export that is not an object (effect 4.1.0 SchemaAST.ts:3144). Also splits installInstallGateOpenCode and cmdGateBash below the complexity limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Kit-Hook-Tree: 1b9fc0e
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
There was a problem hiding this comment.
kit review gate at 6e9d38459eef: not approved.
- checks did not pass: CodeQL, Security gate, Stage 2 — SAST, build-and-test, linux shard 3/4, windows shard 3/4, windows-native
- touches protected paths (permissions), which the owner approves:
src/agent-config.ts,src/commands/gate.ts,src/install-gate-payload.test.ts,src/install-gate-payload.ts,src/install-gate.ts,src/opencode-gate.ts - 1725 changed lines, over the 1500-line limit for a gate-only approval
- pull-agent-files.test.ts read gate files from agent-config.ts only; the moved installers live in agent-gate-installers.ts, so it reads both. - gate.ts: a top-level type import instead of an inline import() type, which Semgrep could not parse. - The Cline hook shim is written through a temporary file and a rename, not in place after an existence check (CodeQL js/file-system-race). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Kit-Hook-Tree: 36e15c0
Resolves the conflict with #1136, which moved the Amazon Q, Kiro, Cursor and Droid installers into src/agent-gate-installers.ts and added src/kit-gate-command.ts: - the Gemini, OpenCode, Cline and Antigravity installers join them in agent-gate-installers.ts; src/kit-invocation.ts is dropped for kit-gate-command.ts. - Gemini and Antigravity treat an entry as kit's only on an exact isKitGateCommand match, so a look-alike is left alone; `--format gemini` is one of the forms kit writes. - the Gemini trust step and the OpenCode version notes use #1136's `next` steps, which `kit agent-config` prints. - this branch's tests move to src/agent-gate-contracts.test.ts. - pull-agent-files.test.ts now reads both installer files, which showed that `kit pull` did not name `.amazonq/cli-agents/` files; it does now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Kit-Hook-Tree: 20cae07
…eir own modules The Gemini CLI, OpenCode, Cline and Antigravity installers move from agent-gate-installers.ts to src/agent-gate-contracts.ts (tested by agent-gate-contracts.test.ts), and the hook-payload command extraction from install-gate.ts to install-gate-payload.ts (re-exported), so neither file grows past main's size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Kit-Hook-Tree: 931f4bd
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
There was a problem hiding this comment.
kit review gate at 25d9d66447f4: not approved.
- touches protected paths (permissions), which the owner approves:
src/agent-config.ts,src/commands/gate.ts,src/install-gate-payload.test.ts,src/install-gate-payload.ts,src/install-gate.ts,src/opencode-gate.ts - 1669 changed lines, over the 1500-line limit for a gate-only approval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
kit wires
kit gate-bashinto each agent's pre-tool hook. In four agents the gate did not block, and nothing said so.tool.execute.before, no default export). OpenCode 2.x loads onlyexport default { id, setup }or{ id, effect }, so the gate never loaded.packages/core/src/plugin/module.ts:81-93;services/site/src/docs/content/build/plugins/migrate-v1.mdx:10-12run_commandswithcommands(a list; JSON text in the VS Code payload). kit readpreToolUse.parameters.command, found nothing and allowed the call.sdk/packages/core/src/extensions/tools/schemas.ts:133-176;apps/vscode/src/sdk/hooks-adapter.ts:28-38,168-174;sdk/packages/core/src/hooks/hook-file-hooks.ts:845-867packages/core/src/hooks/hookRunner.ts:451-489,537-560;packages/core/src/hooks/hookRegistry.ts:171-186hooks.jsonis keyed by hook name at the top level. kit wrote{"hooks": {...}}. The exit-code meaning is not documented.What changed
OpenCode. No single file loads in every release:
packages/opencode/src/plugin/index.ts:41-44at v1.0.0,:86-92at v1.2.0,:119-124at v1.3.0).default.server(readV1Plugin,shared.ts:272-303at v1.4.0 and v1.19.6).SchemaAST.ts:3144).kit reads the installed version and writes the form that version loads: function exports for 1.0 to 1.3, and
export default { id, setup, server }for 1.4 and later, 2.x included. When kit cannot read the version, a new install gets the 1.4+ form with a notice. A 1.x plugin that kit wrote earlier is kept, also with a notice.Cline.
kit gate-bashreadscommandsfromtool_call.inputor from the JSON text inparameters. It still reads the oldcommandandcmdfields. It gates every command. Arun_commandscall whose commands kit cannot read is blocked. The block is still{cancel:true}, which is Cline's only block signal for file hooks, and it stops the whole Cline run.Gemini CLI. The hook runs with
--format gemini. On a deny it writes{"decision":"deny"}to stdout, writes the reason to stderr, and exits 2.kit agent-confignow says that the folder must be trusted with/permissions trust.Antigravity. kit writes a
kit-install-gateentry withenabled: true. It moves its gate out of the oldhooksentry and keeps every user hook there. kit refuses to overwrite ahooks.jsonit cannot parse. On a deny the gate writes the stdoutdecisionand also exits 2.Code layout. The Gemini, OpenCode, Cline and Antigravity installers moved to
src/agent-gate-contracts.ts, beside fix(agent-config): make the install gate run, and fail closed, in Codex, Amazon Q, Kiro, Cursor, Droid and Aider #1136'ssrc/agent-gate-installers.ts. The hook-payload extraction moved tosrc/install-gate-payload.ts. Gemini and Antigravity treat an entry as kit's only on an exactisKitGateCommandmatch (--format geminiis now one of the forms), so a look-alike is left alone. The Gemini trust step and the OpenCode version notes use thenextsteps thatkit agent-configprints.kit pull. It now names.amazonq/cli-agents/files. The installer-file test found the gap once it read every installer module.Security hardening (from review)
{command, args}entries. Cline runs these without a shell. kit now quotes each argv word in POSIX single quotes before the gate parses the line, so an argument with spaces, quotes,;or&&stays one word. When args are not a list of strings, or a word holds a NUL byte, kit blocks the call.cdor anexportin one command applies to the next one.opencodefrom the project. It looks only in absolute PATH directories outside the project root.package.jsonthat the binary belongs to.package.jsonis found. It runs it without a shell, from the home directory.What the tests prove
src/agent-gate-contracts.test.ts,src/install-gate-payload.test.tsand the changedsrc/agent-config.test.tsdo the following:/bin/sh), and the OpenCode plugin module.npm i some-untriaged-pkgis blocked andlsis allowed, with no network call.The tests also cover these cases:
sh -c '<install>') is blocked. An argument that only looks like one (echo '; npm i …') is allowed. Unreadable args are blocked. Acd subthennpm installlist is blocked as a script, and each command alone is allowed.setuphook, the 1.4+serverhook and the 1.0 to 1.3 function exports all block. A 1.x plugin is kept when the version is unknown. A plantedopencodein the project is never run.Before the fix, 16 of the 17 first-round tests failed on the old code.
Not verified
PreToolUse.ps1(apps/vscode/src/core/hooks/hook-factory.ts:988). kit does not write that file, so the Cline gate does not run on Windows.--versionoutput and the npm package name are not confirmed. kit accepts anypackage.jsonwhose name containsopencode./bin/shskip on Windows, and the CLI-level tests run there.🤖 Generated with Claude Code