Skip to content

fix(cli): keep workspace flags intact in bash auto-approve suggestions - #10388

Closed
markijbema wants to merge 7 commits into
mainfrom
mark/bash-permission-flag-arity
Closed

fix(cli): keep workspace flags intact in bash auto-approve suggestions#10388
markijbema wants to merge 7 commits into
mainfrom
mark/bash-permission-flag-arity

Conversation

@markijbema

@markijbema markijbema commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Permission rule chips for bash commands collapsed pnpm --filter web typecheck to pnpm --filter * because BashArity.prefix is purely positional and --filter accidentally counted as the second token of pnpm's arity-2 entry.

This adds a Kilo-owned KiloFlagArity wrapper that recognizes <command> <flag> <arg> pairs (pnpm --filter / -F, npm --workspace / -w, yarn --cwd, git -C, cargo --package / -p / --manifest-path), strips them before the upstream lookup, and re-injects them after. Result: the chip becomes pnpm --filter web typecheck *.

Merge-conflict isolation

All real logic and tests live under packages/opencode/src/kilocode/permission/ and packages/opencode/test/kilocode/permission/. The upstream diff against opencode is two lines in packages/opencode/src/tool/bash.ts (one new import, one swapped function call), both behind // kilocode_change markers. src/permission/arity.ts is unchanged.

Related: #10384

Permission rule suggestions ran tokens straight through BashArity.prefix,
which is purely positional. For 'pnpm --filter web typecheck' that produced
the chip 'pnpm --filter *' because '--filter' counted as the second token
of pnpm's arity-2 entry.

Add a Kilo-owned KiloFlagArity wrapper that recognizes a small set of
'<command> <flag> <arg>' pairs (pnpm --filter, npm --workspace, git -C,
cargo --package, ...), strips them before the dictionary lookup, and
re-injects them after. Wire bash.ts and bash-hierarchy.ts to use it.
Real logic + tests live under src/kilocode/, so the upstream diff is one
imported module and one swapped function call.
@kilo-code-bot

kilo-code-bot Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The incremental diff since the last review (637b0bd47) contains only two clean changes:

  • arity.ts: Export renamed from the never-typed dummy BashArity to BashArity_DoNotUse = { prefix }, properly exposing the prefix function for controlled downstream use.
  • arity.test.ts: Import updated to use the new export (aliased to BashArity), and the kilocode_change end marker repositioned correctly after the import block.

No new issues introduced. All previously reviewed logic remains clean.

Files Reviewed (7 files)
  • .changeset/flag-aware-bash-arity.md
  • packages/opencode/src/kilocode/bash-hierarchy.ts
  • packages/opencode/src/kilocode/permission/flag-arity.ts
  • packages/opencode/src/permission/arity.ts
  • packages/opencode/src/tool/bash.ts
  • packages/opencode/test/kilocode/permission/flag-arity.test.ts
  • packages/opencode/test/permission/arity.test.ts

Reviewed by claude-4.6-sonnet-20260217 · 179,588 tokens

Review guidance: REVIEW.md from base branch main

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