-
Notifications
You must be signed in to change notification settings - Fork 0
Add kensai multi-agent code review plugin #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cd498fb
[kensai] add review MCP server with llmxml library
xobotyi 19c1639
[kensai] add pathindex module
xobotyi a9dfcb1
[kensai] add llmxml markup builder
xobotyi 110cc91
[kensai] add lineiter module
xobotyi a5e3cd7
[kensai] add git module
xobotyi 8cc9333
[kensai] add rg module
xobotyi 7a9c360
[kensai] add repofs scoped filesystem facade
xobotyi cb6c079
[kensai] add line metadata to path index entries
xobotyi 376c5b1
[kensai] add FindingsStorage with tests
xobotyi 8330df8
[kensai] add GroundingStorage with tests
xobotyi 14bee62
[kensai] add Session with diff collection and file manifest
xobotyi 998b1f8
[kensai] add MCP toolset infrastructure with tool stubs
xobotyi 01e5060
[kensai] wire tool handlers to session domain layer
xobotyi bf68b01
[kensai] implement tool response formatting from Go reference
xobotyi 6335f59
[kensai] add extended tool descriptions with usage guidance
xobotyi 63f8a69
[kensai] align agents and skill to MCP-first tooling
xobotyi 7cbc0c3
[kensai] prepare 0.1.0 release
xobotyi dffad41
[kensai] add project instruction resolution via directory chain walk
xobotyi 7321319
[kensai] add priming pagination, fix review findings, scope agent tools
xobotyi 181560c
[kensai] fix review findings, harden priming and error paths
xobotyi 3bb49db
[kensai] terse agent and skill prompts
xobotyi 155764b
[kensai] add CI workflow for review MCP server
xobotyi 8629403
[kensai] bundle ripgrep via @vscode/ripgrep
xobotyi 77a5ded
add npm publishing conventions and package config
xobotyi 0f6ef52
[kensai] fix tool schema mismatches in agent and doc prompts
xobotyi 1c4edf4
[kensai] harden path-escape handling and fix tool descriptions
xobotyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "name": "yatai", | ||
| "owner": { | ||
| "name": "Gaijin Entertainment", | ||
| "email": "a.zinoviev@gaijin.team" | ||
| }, | ||
| "metadata": { | ||
| "description": "Gaijin Entertainment Claude Code plugin marketplace", | ||
| "pluginRoot": "./claude" | ||
| }, | ||
| "plugins": [ | ||
| { | ||
| "name": "kensai", | ||
| "description": "Multi-agent code review pipeline with adversarial falsification, orchestrated by a stateful MCP server", | ||
| "source": "kensai", | ||
| "version": "0.1.0", | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "code-review", | ||
| "multi-agent", | ||
| "review-pipeline", | ||
| "falsification", | ||
| "proving", | ||
| "mcp" | ||
| ] | ||
| } | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "enabledPlugins": { | ||
| "ai-helpers@foundry": true, | ||
| "git-commit@foundry": true, | ||
| "skill-enforcer@foundry": true, | ||
| "the-coder@foundry": true, | ||
| "the-workflow@foundry": true, | ||
| "javascript@foundry": true | ||
| }, | ||
| "extraKnownMarketplaces": { | ||
| "foundry": { | ||
| "source": { | ||
| "source": "github", | ||
| "repo": "xobotyi/cc-foundry" | ||
| } | ||
| } | ||
| }, | ||
| "alwaysThinkingEnabled": true | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: Kensai Review MCP | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "claude/kensai/mcp/review/**" | ||
| - ".github/workflows/kensai-review-mcp.yml" | ||
| pull_request: | ||
| paths: | ||
| - "claude/kensai/mcp/review/**" | ||
| - ".github/workflows/kensai-review-mcp.yml" | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: claude/kensai/mcp/review | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| package_json_file: claude/kensai/mcp/review/package.json | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "26" | ||
| cache: pnpm | ||
| cache-dependency-path: claude/kensai/mcp/review/pnpm-lock.yaml | ||
|
|
||
| - run: pnpm install --frozen-lockfile | ||
|
|
||
| - run: pnpm lint | ||
|
|
||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: ["lts/*", "26"] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| package_json_file: claude/kensai/mcp/review/package.json | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: pnpm | ||
| cache-dependency-path: claude/kensai/mcp/review/pnpm-lock.yaml | ||
|
|
||
| - run: pnpm install --frozen-lockfile | ||
|
|
||
| - run: pnpm test |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .idea | ||
| node_modules/ | ||
| .DS_Store |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # yatai | ||
|
|
||
| Gaijin Entertainment plugin repository. Houses plugins for two ecosystems: Claude Code (`claude/`) and Pi (`pi/`). | ||
|
|
||
| ## Structure | ||
|
|
||
| ``` | ||
| yatai/ | ||
| ├── claude/ # Claude Code plugins | ||
| │ └── kensai/ # Multi-agent code review pipeline | ||
| └── pi/ # PI plugins (future) | ||
| ``` | ||
|
|
||
| Each ecosystem has its own instruction file (`CLAUDE.md`, `AGENTS.md`, etc.) with ecosystem-specific conventions. | ||
|
|
||
| ## Conventions | ||
|
|
||
| <conventions> | ||
|
|
||
| **Plugin context:** | ||
|
|
||
| - Each plugin has an agent-facing instruction file (`CLAUDE.md`, `AGENTS.md`, etc.) explaining its components | ||
| - Each plugin has `README.md` for humans | ||
|
|
||
| **Plugin documentation style:** | ||
|
|
||
| - **Agent-facing file** — brief prose introduction, then structured content: component tables, dependency diagrams, | ||
| bullet-list conventions. Optimize for LLM compliance — terse bullets over explanatory paragraphs. | ||
| - **README.md** — human-facing documentation. Explanatory prose that frames the plugin around the problem it solves, | ||
| explains what each component does and when to use it. | ||
|
|
||
| **Documentation maintenance:** Update plugin docs in the same work session as the code change: | ||
|
|
||
| - **Plugin agent-facing file** — update when: adding/removing/renaming components; changing purpose, scope, or | ||
| dependencies; adding/removing conventions | ||
| - **Plugin README.md** — update when: any change that affects what users see or install | ||
| - **Ecosystem instruction file** — update plugin table when: adding/removing a plugin | ||
| - **Root CLAUDE.md** — update structure diagram when: adding/removing a plugin or ecosystem | ||
|
|
||
| **Installation instructions:** | ||
|
|
||
| - All plugin READMEs must use marketplace commands: | ||
| ``` | ||
| /plugin marketplace add GaijinEntertainment/yatai | ||
| /plugin install <plugin-name> | ||
| ``` | ||
| - Do not use manual cp/ln installation methods | ||
|
|
||
| **Version management:** | ||
|
|
||
| - Plugin versions must be synchronized between each plugin's `.claude-plugin/plugin.json` and the repo-root | ||
| `.claude-plugin/marketplace.json` (which lists all plugins in a single file) | ||
| - Update both files when bumping versions | ||
|
|
||
| **Licensing:** | ||
|
|
||
| - Every plugin must contain a copy of the root `LICENSE` file in its directory | ||
| - When adding a new plugin, copy `LICENSE` from the repository root into the plugin directory | ||
|
|
||
| **npm packages:** | ||
|
|
||
| - Use `vp` for all toolchain operations — `vp install`, `vp check`, `vp test`, `vp build`. Never invoke `npm`, | ||
| `yarn`, or bare `pnpm` commands directly in instructions or CI | ||
| - Every `package.json` must include: `license` (matching the plugin license), `author`, `repository`, `type` (`module`), | ||
| `engines`, and `packageManager` fields | ||
| - Publishable packages must also include: `description`, `bin` or `exports`, `engines`, and `publishConfig` | ||
| - Publishable packages must have a `.npmignore` excluding tests, configs, lock files, and agent-facing docs | ||
| - Lock files (`pnpm-lock.yaml`) must be committed | ||
| - Pin `packageManager` in `package.json` to the exact pnpm version used by the project | ||
| - Use `--frozen-lockfile` in CI to catch uncommitted dependency changes | ||
|
|
||
| **npm supply chain protection:** | ||
|
|
||
| - Every package must have an `.npmrc` with `ignore-scripts=true` (blocks post-install script attacks) and | ||
| `minimum-release-age=7d` (rejects packages published less than 7 days ago) | ||
| - All publishable packages must set `"publishConfig": { "access": "public" }` in `package.json` | ||
| - The `@gaijin` npm scope must have 2FA enforced at the org level (manual npm setting) | ||
|
|
||
| </conventions> | ||
|
|
||
| <git-commit-config> | ||
| <extra-instructions> | ||
| Since the project is about plugins, the scope in the commit message, if defined, must not contain the ecosystem path | ||
| (`claude/` or `pi/`). Use the plugin name as the scope. | ||
| </extra-instructions> | ||
| </git-commit-config> | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Claude Code Plugins | ||
|
|
||
| Claude Code plugin ecosystem. Each subdirectory is a self-contained plugin. | ||
|
|
||
| ## Plugins | ||
|
|
||
| | Plugin | Purpose | | ||
| |--------|---------| | ||
| | [kensai](kensai/) | Multi-agent code review pipeline with adversarial falsification | | ||
|
|
||
| ## Conventions | ||
|
|
||
| <conventions> | ||
| **Formatting:** | ||
| - Agent instruction files and prompts use the MDX parser (block-level XML tag support) | ||
| - README.md files use GFM parser | ||
|
|
||
| **Skill structure:** | ||
|
|
||
| - Router pattern: SKILL.md routes to `references/` for detailed content | ||
| - Keep SKILL.md under 500 lines; move depth to references | ||
|
|
||
| **Installation instructions:** | ||
|
|
||
| - All plugin READMEs must use marketplace commands: | ||
| ``` | ||
| /plugin marketplace add GaijinEntertainment/yatai | ||
| /plugin install <plugin-name> | ||
| ``` | ||
| - Do not use manual cp/ln installation methods | ||
|
|
||
| **Version management:** | ||
|
|
||
| - Plugin versions must be synchronized between each plugin's `.claude-plugin/plugin.json` and the repo-root | ||
| `.claude-plugin/marketplace.json` (which lists all plugins in a single file) | ||
| - Update both files when bumping versions | ||
| </conventions> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "kensai", | ||
| "version": "0.1.0", | ||
| "description": "Multi-agent code review pipeline with adversarial falsification, orchestrated by a stateful MCP server", | ||
| "author": { | ||
| "name": "xobotyi", | ||
| "email": "a.zinoviev@gaijin.team" | ||
| }, | ||
| "repository": "https://github.com/GaijinEntertainment/yatai", | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "code-review", | ||
| "multi-agent", | ||
| "review-pipeline", | ||
| "falsification", | ||
| "proving", | ||
| "mcp" | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "mcpServers": { | ||
| "kensai": { | ||
| "type": "stdio", | ||
| "command": "node", | ||
| "args": ["${CLAUDE_PLUGIN_ROOT}/mcp/review/src/index.ts"], | ||
| "alwaysLoad": true | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Kensai | ||
|
|
||
| Multi-agent code review pipeline with adversarial falsification. A stateful MCP server orchestrates four phases — | ||
| grounding, surfacing, proving, filing — with dedicated agents per phase. | ||
|
|
||
| ## Pipeline | ||
|
|
||
| ``` | ||
| /kensai-review [mode] [path] | ||
| → mcp__kensai__session_start IDLE → GROUNDING | ||
| → mcp__kensai__grounding_store | ||
| → mcp__kensai__grounding_complete GROUNDING → SURFACING | ||
| → mcp__kensai__finding_surface / surface_clean | ||
| → mcp__kensai__surfacing_complete SURFACING → PROVING (or FILING if 0 findings) | ||
| → mcp__kensai__finding_verdict | ||
| → mcp__kensai__proving_complete PROVING → FILING | ||
| → mcp__kensai__filing_complete FILING → COMPLETE | ||
| ``` | ||
|
|
||
| ## Components | ||
|
|
||
| | Component | Purpose | | ||
| |-----------|---------| | ||
| | `mcp/review/src/index.ts` | MCP server — phase state machine, context persistence, handler-level phase enforcement | | ||
| | `skills/review/SKILL.md` | `/kensai-review` entry point — mode/path resolution, pipeline orchestration | | ||
| | `agents/review-grounder.md` | Grounding agent — maps the change, builds three-layer model, stores context via MCP | | ||
| | `agents/review-surfacer.md` | Surfacing agent — parallel read-only reviewer per dimension, records findings via MCP | | ||
| | `agents/review-prover.md` | Proving agent — adversarial falsification of surfaced findings, verdicts via MCP | | ||
|
|
||
| ## MCP Tools | ||
|
|
||
| ### Session lifecycle | ||
|
|
||
| | Tool | Purpose | | ||
| |------|---------| | ||
| | `session_start` | Initialize session (IDLE -> GROUNDING) | | ||
| | `session_state` | Current phase, mode, refs, file/finding counts | | ||
| | `session_priming` | Paginated full context: metadata, changed files, file stats, agent-instructions, diffs. Call with `page=N` for large changes. | | ||
| | `session_end` | Destroy session | | ||
|
|
||
| ### Filesystem and search (session-scoped) | ||
|
|
||
| | Tool | Purpose | | ||
| |------|---------| | ||
| | `read_file` | Read file with line numbers, binary detection | | ||
| | `list_dir` | Directory listing with depth control | | ||
| | `find_files` | Fuzzy file-name search | | ||
| | `grep` | Regex content search via ripgrep | | ||
|
|
||
| ### Git (session-scoped) | ||
|
|
||
| | Tool | Purpose | | ||
| |------|---------| | ||
| | `changed_files` | File list with status (A/M/D) and +/- counts | | ||
| | `diff_file` | Annotated unified diff for one file | | ||
| | `log` | Recent commit history | | ||
|
|
||
| ### Review pipeline | ||
|
|
||
| | Tool | Phase | Purpose | | ||
| |------|-------|---------| | ||
| | `observation_create` | GROUNDING | Record an observation | | ||
| | `observation_cancel` | GROUNDING | Retract an observation | | ||
| | `grounding_store` | GROUNDING | Persist grounding context | | ||
| | `grounding_get` | SURFACING+ | Retrieve grounding context | | ||
| | `grounding_complete` | GROUNDING -> SURFACING | Advance phase | | ||
| | `finding_surface` | SURFACING | Record a finding | | ||
| | `surface_clean` | SURFACING | Report a clean dimension | | ||
| | `finding_cancel` | SURFACING | Retract a finding | | ||
| | `surfacing_complete` | SURFACING -> PROVING/FILING | Advance (skip proving if 0 findings) | | ||
| | `findings_list` | PROVING+ | List findings with filter | | ||
| | `finding_get` | PROVING+ | Get single finding detail | | ||
| | `finding_verdict` | PROVING | Verdict a finding (pass/reject) | | ||
| | `proving_complete` | PROVING -> FILING | Advance phase | | ||
| | `filing_complete` | FILING -> COMPLETE | Mark review done | | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Agent teams: `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` | ||
| - Node.js 26+ (MCP server) | ||
|
|
||
| ## Design | ||
|
|
||
| - **MCP-first** — agents access codebase exclusively through `mcp__kensai__*` tools; no direct Read/Grep/Bash | ||
| - **Self-serve context** — agents call `session_priming` to receive full review context; no data threading from lead | ||
| - **Handler-level phase enforcement** — all tools always registered; invalid-phase calls return hard error via `#require()` | ||
| - **Dedicated completion tools** — `grounding_complete`, `surfacing_complete`, `proving_complete` (not generic `transition`) | ||
| - **0-findings shortcut** — `surfacing_complete` jumps to FILING when no findings, skipping PROVING | ||
| - **Recall over precision** — surfacers cast a wide net; prover applies falsification gates to filter | ||
| - **Read-only agents** — grounder, surfacers, and prover never edit files | ||
| - **Stable finding IDs** — F1, F2, ... carried across phase boundaries | ||
| - **Soft errors** — not-found/binary/empty return `ok("[marker]")` with path suggestions, not `err()` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 Gaijin Entertainment | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.