@pdxxxx/keel 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/ARCHITECTURE.md +52 -47
  2. package/CHANGELOG.md +20 -15
  3. package/LICENSE +21 -21
  4. package/README.md +46 -47
  5. package/README_CN.md +49 -50
  6. package/npm/bin/keel.js +25 -0
  7. package/npm/install.js +55 -0
  8. package/package.json +6 -27
  9. package/bin/keel.js +0 -4
  10. package/dist/cli.d.ts +0 -3
  11. package/dist/cli.js +0 -569
  12. package/dist/cli.js.map +0 -1
  13. package/dist/core/ablate.d.ts +0 -11
  14. package/dist/core/ablate.js +0 -54
  15. package/dist/core/ablate.js.map +0 -1
  16. package/dist/core/config.d.ts +0 -3
  17. package/dist/core/config.js +0 -60
  18. package/dist/core/config.js.map +0 -1
  19. package/dist/core/git.d.ts +0 -9
  20. package/dist/core/git.js +0 -48
  21. package/dist/core/git.js.map +0 -1
  22. package/dist/core/glob.d.ts +0 -8
  23. package/dist/core/glob.js +0 -61
  24. package/dist/core/glob.js.map +0 -1
  25. package/dist/core/hotspots.d.ts +0 -11
  26. package/dist/core/hotspots.js +0 -49
  27. package/dist/core/hotspots.js.map +0 -1
  28. package/dist/core/init.d.ts +0 -14
  29. package/dist/core/init.js +0 -117
  30. package/dist/core/init.js.map +0 -1
  31. package/dist/core/mcp.d.ts +0 -24
  32. package/dist/core/mcp.js +0 -323
  33. package/dist/core/mcp.js.map +0 -1
  34. package/dist/core/mem.d.ts +0 -21
  35. package/dist/core/mem.js +0 -337
  36. package/dist/core/mem.js.map +0 -1
  37. package/dist/core/migrate.d.ts +0 -21
  38. package/dist/core/migrate.js +0 -207
  39. package/dist/core/migrate.js.map +0 -1
  40. package/dist/core/paths.d.ts +0 -14
  41. package/dist/core/paths.js +0 -44
  42. package/dist/core/paths.js.map +0 -1
  43. package/dist/core/rules.d.ts +0 -22
  44. package/dist/core/rules.js +0 -262
  45. package/dist/core/rules.js.map +0 -1
  46. package/dist/core/snapshot.d.ts +0 -30
  47. package/dist/core/snapshot.js +0 -212
  48. package/dist/core/snapshot.js.map +0 -1
  49. package/dist/core/tasks.d.ts +0 -13
  50. package/dist/core/tasks.js +0 -180
  51. package/dist/core/tasks.js.map +0 -1
  52. package/dist/core/types.d.ts +0 -98
  53. package/dist/core/types.js +0 -2
  54. package/dist/core/types.js.map +0 -1
  55. package/dist/core/verify.d.ts +0 -8
  56. package/dist/core/verify.js +0 -66
  57. package/dist/core/verify.js.map +0 -1
  58. package/dist/index.d.ts +0 -15
  59. package/dist/index.js +0 -16
  60. package/dist/index.js.map +0 -1
  61. package/dist/templates/assets.d.ts +0 -11
  62. package/dist/templates/assets.js +0 -179
  63. package/dist/templates/assets.js.map +0 -1
  64. package/dist/version.d.ts +0 -1
  65. package/dist/version.js +0 -2
  66. package/dist/version.js.map +0 -1
package/ARCHITECTURE.md CHANGED
@@ -1,34 +1,32 @@
1
1
  # Architecture
2
2
 
3
- This document explains how Keel is laid out, what file formats it owns, and why certain features were left out.
3
+ Keel is a single pure-Rust executable (`keel`) that serves both the CLI and the stdio MCP server from one codebase.
4
4
 
5
5
  ## Design choices
6
6
 
7
- Keel assumes the coding tool you already use (Claude Code, Codex, Cursor, OpenCode, etc.) handles planning, file search, and sub-agent execution on its own. Trying to override that with vendor-specific hooks or custom sub-agent topologies creates maintenance churn every time a host changes its API and often fights native parallelism and prompt caching.
7
+ Keel assumes your coding tool (Claude Code, Codex, Cursor, OpenCode, Antigravity) already handles planning, code search, and sub-agent scheduling well. Keel stays strictly in the repository contract, local memory, and verification layer:
8
8
 
9
- Because of that, Keel intentionally avoids:
10
-
11
- - Custom sub-agent definitions or dispatch rules.
12
- - Vendor-specific `PreToolUse` / `UserPromptSubmit` hooks.
13
- - Python helper scripts inside user repositories (the CLI is Node.js >= 20; the optional native MCP server is Rust).
14
- - Built-in LLM API dependencies inside the CLI.
15
- - Requiring a task folder for small edits.
16
-
17
- Everything Keel does lives in plain files under `.keel/`, a short managed block in `AGENTS.md`, five skill files in `.agents/skills/`, and stateless read/write commands.
9
+ - No custom sub-agent definitions or dispatch rules.
10
+ - No vendor `PreToolUse` / `UserPromptSubmit` hooks.
11
+ - No Python or Node.js runtime required to run `keel` (the npm package `@pdxxxx/keel` is a zero-dependency launcher that downloads the SHA-256 verified Rust binary from GitHub Releases).
12
+ - No built-in LLM API calls.
13
+ - No task directory required for small edits.
18
14
 
19
15
  ## Code layout
20
16
 
21
- - `src/core/`: core logic (`init`, `config`, `rules`, `glob`, `git`, `tasks`, `verify`, `hotspots`, `mem`, `migrate`, `ablate`, `snapshot`, `mcp`).
22
- - `src/cli.ts` & `bin/keel.js`: CLI wrapper over `src/core/`.
23
- - `src/templates/assets.ts`: templates written by `keel init`.
24
- - `crates/keel-mcp/`: standalone Rust implementation of the stdio MCP server. Tested against the Node implementation via `crates/keel-mcp/tests/parity.mjs`.
17
+ - `Cargo.toml`, `src/` — single Rust crate producing `keel`:
18
+ - `main.rs` / `cli.rs` — CLI parser (`-C/--root`, `--json`, clean single-line `stderr` diagnostics)
19
+ - `mcp.rs` & `mcp_root.rs` — stdio JSON-RPC 2.0 MCP server (`2024-11-05`, 13 tools, per-call `root`, `initialize` `rootUri`/`workspaceFolders`, homeless-cwd write guard, `--lock-root`)
20
+ - `init.rs` & `doctor.rs` — non-destructive `init`, template-only `update`, strict config & marker `doctor`
21
+ - `rules.rs`, `tasks.rs`, `verify.rs`, `hotspots.rs`, `mem.rs`, `migrate.rs`, `ablate.rs`, `snapshot.rs`, `config.rs`, `git.rs`, `paths.rs`
22
+ - `tests/` — real child-process CLI (`tests/cli.rs`) and stdio MCP (`tests/stdio.rs`) integration suites.
23
+ - `npm/` — zero-dependency npm wrapper (`npm/install.js`, `npm/bin/keel.js`, `npm/test.mjs`).
24
+ - `docs/` — standalone VitePress documentation site deployed to GitHub Pages.
25
25
 
26
26
  ## On-disk formats
27
27
 
28
28
  ### Rules (`.keel/rules/**/*.md`)
29
29
 
30
- Rule files use YAML frontmatter followed by Markdown:
31
-
32
30
  ```markdown
33
31
  ---
34
32
  id: auth-token-rotation
@@ -38,25 +36,20 @@ paths:
38
36
  - src/auth/**
39
37
  ---
40
38
 
41
- Concurrent tab refreshes previously caused false-positive token revocation...
39
+ Explain why this invariant exists.
42
40
  ```
43
41
 
44
- - `severity` is one of `invariant`, `guideline`, or `adr` (defaults to `guideline`).
45
- - `paths` is a list of POSIX globs (`*`, `**`, `**/`, `?`). If omitted or empty, the rule is treated as global.
46
- - Frontmatter must start with `---` on line 1 and close with a standalone `---` line.
47
- - `.keel/rules/index.md` is ignored by `list` and `check` unless it declares an explicit `id` in frontmatter.
48
-
49
- `keel rules match` returns only the metadata index (`id`, `file`, `summary`, `severity`, `paths`, `global`) so an agent can open only the files that actually apply. `keel rules check --stale` additionally flags path globs matching zero repo files, rules longer than 80 lines, and repositories with more than 5 global rules (`--strict` fails on warnings).
42
+ - `severity`: `invariant`, `guideline`, or `adr` (defaults to `guideline`).
43
+ - `paths`: POSIX globs (`*`, `**`, `**/`, `?`). Empty or omitted means global.
44
+ - Frontmatter starts with `---` on line 1 and closes only on a standalone `---` line (LF, CRLF, or EOF).
45
+ - `keel rules check --stale` warns on dead path globs, rules over 80 lines, and more than 5 global rules (`--strict` fails on warnings).
50
46
 
51
47
  ### Tasks (`.keel/tasks/<YYYY-MM-DD>-<slug>/`)
52
48
 
53
- Each task folder holds:
54
-
55
- - `meta.json`: `id`, `title`, `status` (`open` or `done`), `createdAt`, `updatedAt`.
56
- - `spec.md`: a single Markdown file for goals, non-goals, acceptance criteria, and decisions.
57
- - `research/`: optional directory for notes that should survive chat compaction.
58
-
59
- `keel task archive <id>` sets status to `done` and moves the folder into `.keel/tasks/archive/<id>/`. Both TS and Rust implementations reject task IDs containing `..` or absolute paths.
49
+ - `meta.json`: `id`, `title`, `status` (`open` | `done`), `createdAt`, `updatedAt`.
50
+ - `spec.md`: single living document for goals, non-goals, acceptance criteria, and decisions.
51
+ - `research/`: optional persisted notes.
52
+ - Archived tasks live under `.keel/tasks/archive/<id>/`. Task IDs with `..` or absolute paths are rejected.
60
53
 
61
54
  ### Verification gates (`.keel/config.yaml`)
62
55
 
@@ -68,34 +61,46 @@ verify:
68
61
  command: pnpm --filter api test
69
62
  paths:
70
63
  - packages/api/**
71
- - name: typecheck
72
- command: pnpm typecheck
64
+ timeoutMs: 120000
65
+ maxOutputChars: 16000
73
66
  memory:
74
67
  sources: []
75
68
  ```
76
69
 
77
- `keel verify` runs gates sequentially in the configured order, captures stdout/stderr, exit code, and elapsed milliseconds, and exits non-zero if any gate fails. When `--git`, `--staged`, or `--base <ref>` is passed (or `git: true` over MCP) without explicit `--gate` names, only global gates (no `paths`) and gates whose `paths` match changed files are executed; skipped gate names are reported in `skipped`.
70
+ - `timeoutMs` defaults to `120000` (`0` disables timeout). Timed-out gates terminate their process tree and report `exitCode: 124` with `timedOut: true`.
71
+ - `maxOutputChars` defaults to `16000` (`0` disables truncation). Oversized logs keep the tail (preserving error summaries) with a truncation header.
72
+ - Invalid or unknown keys in `.keel/config.yaml` are caught by `keel doctor` and fail closed before gates run.
78
73
 
79
- ### Hotspots (`src/core/hotspots.ts`)
74
+ ### Memory (`src/mem.rs`)
80
75
 
81
- `keel hotspots` reads recent commits from `git log`, skips deleted files, and ranks existing paths by `fixTouches * 3 + touches` so brownfield repos can prioritize which areas need rules or tests first.
76
+ Streaming, read-only scan across seven sources:
82
77
 
83
- ### Memory (`src/core/mem.ts`, `crates/keel-mcp/src/mem.rs`)
84
-
85
- Read-only scan across:
86
-
87
- - `keel`: `.keel/tasks/` and `.keel/rules/` Markdown files.
78
+ - `keel`: `.keel/tasks/` and `.keel/rules/` Markdown files
88
79
  - `claude`: `~/.claude/projects/**/*.jsonl`
89
80
  - `codex`: `~/.codex/sessions/**/*.jsonl`
90
81
  - `opencode`: `~/.local/share/opencode/**/*.jsonl`
91
- - `custom`: directories listed in `.keel/config.yaml` (`memory.sources`) and the `KEEL_MEM_DIRS` environment variable.
82
+ - `antigravity`: `~/.gemini/antigravity/brain/*/.system_generated/logs/transcript.jsonl`
83
+ - `gemini`: `~/.gemini/tmp/*/chats/*.json`
84
+ - `custom`: directories in `.keel/config.yaml` (`memory.sources`) and `KEEL_MEM_DIRS`
85
+
86
+ Supports `--scope project | all`: `project` restricts results to sessions matching the active repository path; `all` searches everything while boosting current-project matches.
87
+
88
+ ### External SHA-256 snapshots (`src/snapshot.rs`)
89
+
90
+ `keel ablate` (`~/.keel-ablate/<repo-hash>/`) and `keel migrate cleanup` (`~/.keel-migrate/<repo-hash>/`) share one transaction-safe snapshot engine:
92
91
 
93
- Malformed JSONL lines and unreadable directories are skipped silently. Search splits the query on whitespace, scores each turn by term coverage plus capped occurrence count, and returns top hits with short snippets.
92
+ 1. Rejects symlinks anywhere along workspace or backup paths.
93
+ 2. Writes and SHA-256 verifies every backup file before mutating the repository.
94
+ 3. Strips managed blocks in `AGENTS.md` / `CLAUDE.md` and Trellis hooks in JSON settings without disturbing unrelated user content.
95
+ 4. Verifies every path against post-operation hashes before restoring (refusing conflicts unless `--force` is passed).
94
96
 
95
- ### Snapshots, ablation, and migration (`src/core/snapshot.ts`, `ablate.ts`, `migrate.ts`)
97
+ ### Multi-repo MCP root resolution (`src/mcp_root.rs`)
96
98
 
97
- `keel ablate` and `keel migrate cleanup` share the same external SHA-256 snapshot engine (`~/.keel-ablate/<repo-hash>/` and `~/.keel-migrate/<repo-hash>/`). Every target file is backed up and hash-verified before mutating the working tree, and `restore` / `migrate rollback` verify all paths for post-operation conflicts before writing anything back (unless `--force` is passed). Managed blocks in `AGENTS.md` are stripped without disturbing surrounding user text.
99
+ Per-call precedence (highest to lowest):
98
100
 
99
- ### MCP server (`src/core/mcp.ts`, `crates/keel-mcp/`)
101
+ 1. `arguments.root` (accepted on all 13 tools; resolves upward `.keel/` -> `.git/` -> given dir)
102
+ 2. Startup `--root <path>`
103
+ 3. `initialize` `params.rootUri` or `params.workspaceFolders[0].uri` (when `--root` was omitted)
104
+ 4. Process `cwd` upward discovery
100
105
 
101
- Newline-delimited JSON-RPC 2.0 over stdio (`protocolVersion: "2024-11-05"`). Supports `initialize`, `notifications/*` (no response), `ping`, `tools/list`, and `tools/call`. All logs and diagnostics go to `stderr`; `stdout` carries protocol frames only.
106
+ When no explicit root is provided and `cwd` has neither `.keel/` nor `.git/`, mutating and verification tools (`keel_task_create`, `keel_task_update`, `keel_rules_add`, `keel_verify`) refuse to run instead of writing into a homeless aggregator directory. Pass `--root <dir> --lock-root` to restrict all calls within one canonical directory tree.
package/CHANGELOG.md CHANGED
@@ -1,22 +1,27 @@
1
1
  # Changelog
2
2
 
3
- ## 1.1.0 - 2026-11-24
3
+ ## 2.0.0 - 2026-11-24
4
4
 
5
- Brownfield (1->N) and migration release.
5
+ Pure Rust single-binary release (`keel`).
6
6
 
7
- - **Incremental verification**: added optional `paths` globs on `verify.gates` plus `keel verify --git / --staged / --base <ref>` (and `git: true` on MCP `keel_verify` in both Node and Rust).
8
- - **Rule staleness & hygiene checks**: added `keel rules check --stale` / `--strict` (and `stale: true` on MCP `keel_rules_check`) to flag dead path globs, rules over 80 lines, and excess global rules while preserving the 1.0.0 default output.
9
- - **Git bugfix hotspots**: added `keel hotspots` to rank existing files by recent churn and bugfix commits.
10
- - **One-shot migration tools**: added `keel migrate scan / plan / cleanup / rollback` backed by shared external SHA-256 snapshots, plus the `keel-migrate` standard skill installed by `keel init`.
7
+ ### Architecture & Packaging
8
+ - Consolidated the entire CLI and MCP server into a single pure-Rust binary (`keel`, ~3.6 MiB); removed the duplicate TypeScript core, standalone `keel-mcp` crate, and cross-runtime parity harness.
9
+ - Replaced `@pdxxxx/keel` on npm with a zero-dependency thin launcher (~10 KB packed) that downloads and SHA-256 verifies the matching GitHub Release binary on install.
10
+ - Updated CI and Release workflows for five native binary targets (`linux-x86_64`, `linux-aarch64`, `macos-arm64`, `macos-x86_64`, `windows-x86_64.exe`), uploading GitHub Release assets and `SHA256SUMS.txt` before publishing to npm via OIDC Trusted Publishing.
11
11
 
12
- ## 1.0.0 - 2026-11-24
12
+ ### New Commands & Reliability Fixes
13
+ - **`keel update`**: safely refreshes managed templates (`AGENTS.md` block, `.keel/rules/index.md`, `.agents/skills/keel-*`) without touching `.keel/config.yaml`, user rules, or tasks. `keel init --force` no longer overwrites user `config.yaml` unless `--reset-config` is passed.
14
+ - **`keel doctor`**: validates `.keel/config.yaml` strictly (catching typos, bad types, duplicate gate names), `AGENTS.md` marker integrity, `git` availability, and stale rules.
15
+ - **Global `-C, --root <PATH>` & `--json`**: supported consistently across CLI commands with clean single-line `stderr` error reporting.
16
+ - **Multi-repo MCP & 13 tools**: all 13 MCP tools (`keel_rules_*`, `keel_task_*`, `keel_verify`, `keel_hotspots`, `keel_mem_*`) accept highest-priority per-call `root`, support `initialize` `rootUri`/`workspaceFolders`, enforce homeless-directory write protection, and support `--lock-root`.
17
+ - **Verification safety**: added `timeoutMs` (default 120s, process-tree termination) and `maxOutputChars` (default 16,000, tail-preserving truncation) to `verify.gates`.
18
+ - **Memory & Git improvements**: added `--scope project | all` filtering and current-project score boosting, read-only `antigravity` and `gemini` transcript adapters, `keel_mem_show`, and nested monorepo git-path alignment.
19
+ - **Migration coverage**: expanded `keel migrate` to detect and safely clean Trellis leftovers in `.agents/skills/trellis-*`, `.codex/`, `.cursor/hooks*`, `.gemini/settings.json`, and `CLAUDE.md`.
20
+
21
+ ## 1.1.0 - 2026-11-24
22
+
23
+ - Added incremental `verify.gates[].paths` + `keel verify --git / --staged / --base`, `keel rules check --stale / --strict`, `keel hotspots`, and `keel migrate scan / plan / cleanup / rollback`.
13
24
 
14
- Initial release.
25
+ ## 1.0.0 - 2026-11-24
15
26
 
16
- - `keel init`: creates `.keel/`, auto-detects project verification scripts, writes a managed block into `AGENTS.md`, and installs four skill files (`keel-plan`, `keel-verify`, `keel-distill`, `keel-mem`).
17
- - `keel rules`: `list`, `match` (path globs plus `--git`, `--staged`, `--base`), `add`, and `check`.
18
- - `keel task`: `create`, `list`, `show`, `done`, `reopen`, and `archive`.
19
- - `keel verify`: runs configured commands from `.keel/config.yaml` with `--gate`, `--fail-fast`, and `--json`.
20
- - `keel mem`: `sources`, `sessions`, `search`, and `show` across `.keel/` files and local Claude Code, Codex, OpenCode, and custom JSONL transcripts.
21
- - `keel ablate` / `keel restore`: SHA-256 verified temporary removal and restoration of Keel files with conflict checks.
22
- - `keel mcp` & `crates/keel-mcp`: stdio MCP server in both Node.js and Rust, verified against each other with `crates/keel-mcp/tests/parity.mjs`.
27
+ - Initial release (`init`, `rules`, `task`, `verify`, `mem`, `ablate` / `restore`, `mcp`).
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 pdxxxx
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pdxxxx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -10,14 +10,13 @@
10
10
  <a href="https://www.npmjs.com/package/@pdxxxx/keel"><img src="https://img.shields.io/npm/v/%40pdxxxx%2Fkeel?style=flat-square&color=cb3837" alt="npm version" /></a>
11
11
  <a href="https://github.com/pdxxxx/keel/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/pdxxxx/keel/ci.yml?style=flat-square&label=CI" alt="CI" /></a>
12
12
  <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-2563eb?style=flat-square" alt="MIT License" /></a>
13
- <img src="https://img.shields.io/badge/node-%3E%3D20-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node >= 20" />
14
13
  <img src="https://img.shields.io/badge/rust-1.85%2B-dea584?style=flat-square&logo=rust&logoColor=black" alt="Rust 1.85+" />
15
14
  </p>
16
15
 
17
16
  <p>
17
+ <a href="https://pdxxxx.github.io/keel/">Docs</a> ·
18
18
  <a href="./README_CN.md">简体中文</a> ·
19
19
  <a href="./ARCHITECTURE.md">Architecture</a> ·
20
- <a href="./crates/keel-mcp/README.md">Rust MCP</a> ·
21
20
  <a href="./CHANGELOG.md">Changelog</a>
22
21
  </p>
23
22
 
@@ -25,18 +24,27 @@
25
24
 
26
25
  ---
27
26
 
28
- Keel stores project-specific rules, optional task specs, and check commands in plain files under `.keel/`, and searches local transcripts across Claude Code, Codex, OpenCode, and custom directories.
27
+ Keel is a single Rust binary (~3.6 MiB) that stores project rules, optional task specs, and check commands under `.keel/`, searches local session logs across seven tools, and exposes 13 tools over stdio MCP.
29
28
 
30
- It does not manage sub-agents, install editor hooks, or lock you into a specific coding tool. Use it from the CLI or attach it over stdio MCP.
29
+ It does not manage sub-agents, install editor hooks, or tie you to a specific coding tool.
31
30
 
32
- ## Quick Start
33
-
34
- Requires **Node.js >= 20**.
31
+ ## Install
35
32
 
36
33
  ```sh
34
+ # Recommended: installs the prebuilt native binary verified with SHA-256
37
35
  npm install -g @pdxxxx/keel@latest
38
36
  ```
39
37
 
38
+ Or build directly from source with Rust 1.85+:
39
+
40
+ ```sh
41
+ cargo install --git https://github.com/pdxxxx/keel --locked
42
+ ```
43
+
44
+ Prebuilt binaries for Linux (`x86_64`, `aarch64`), macOS (`arm64`, `x86_64`), and Windows (`x86_64`) are also attached to [GitHub Releases](https://github.com/pdxxxx/keel/releases).
45
+
46
+ ## Quick Start
47
+
40
48
  ```sh
41
49
  # 1. Initialize .keel/, AGENTS.md block, and standard .agents/skills/
42
50
  keel init
@@ -50,89 +58,80 @@ keel rules add auth-rotation \
50
58
  keel rules match --git
51
59
 
52
60
  # 4. Search past sessions and .keel/ docs
53
- keel mem search "refresh token"
61
+ keel mem search "refresh token" --scope project
54
62
 
55
- # 5. Run checks matching your current git diff (or drop --git for all gates)
63
+ # 5. Run checks matching your current git diff (drop --git for all gates)
56
64
  keel verify --git
57
65
  ```
58
66
 
59
67
  ## Existing Repos & Migration
60
68
 
61
- On a mature codebase, start with checks and git history rather than writing broad style docs:
62
-
63
69
  ```sh
64
- keel hotspots # find frequently fixed files worth adding rules for
65
- keel rules check --stale # spot dead path globs or bloated rules
66
- keel migrate scan # inventory Trellis, .cursorrules, CLAUDE.md, etc.
67
- keel migrate plan # list hook conflicts, candidate gates, and rule sources
68
- keel migrate cleanup --dry-run # preview safe removal (backed up; undo with `keel migrate rollback`)
70
+ keel hotspots # rank existing files by recent bugfix churn
71
+ keel doctor # check config.yaml, AGENTS.md markers, git, and stale rules
72
+ keel update # refresh AGENTS.md block & skills without touching config.yaml
73
+ keel migrate scan # inventory Trellis, .cursorrules, CLAUDE.md, etc.
74
+ keel migrate cleanup --dry-run # preview safe removal (backed up; undo with `keel migrate rollback`)
69
75
  ```
70
76
 
71
- Pair `keel migrate` with the bundled `keel-migrate` skill to distill only non-obvious traps into `.keel/rules/`.
72
-
73
77
  ## Commands
74
78
 
75
- Every command supports `--json`.
79
+ Global flags: `-C, --root <PATH>` and `--json`.
76
80
 
77
81
  | Command | Description |
78
82
  | --- | --- |
79
- | `keel init` | Creates `.keel/`, detects project scripts (`typecheck`, `lint`, `test`), updates `AGENTS.md`, and installs `.agents/skills/`. |
83
+ | `keel init` | Creates `.keel/`, detects project scripts, updates `AGENTS.md`, installs 5 skills (never overwrites `config.yaml` unless `--reset-config`). |
84
+ | `keel update` | Safely refreshes managed templates (`AGENTS.md` block, `rules/index.md`, `keel-*` skills) without touching user config, rules, or tasks. |
85
+ | `keel doctor` | Validates `.keel/config.yaml` strictly, checks `AGENTS.md` markers, `git`, and stale rules. |
80
86
  | `keel rules` | `list`, `match [paths...] [--git \| --staged \| --base <ref>]`, `add <id>`, `check [--stale \| --strict]`. |
81
87
  | `keel task` | `create`, `list`, `show`, `done`, `reopen`, `archive` — optional single-file `spec.md` per task. |
82
- | `keel verify` | Runs gates in `.keel/config.yaml` (`--gate`, `--git`, `--staged`, `--base <ref>`, `--fail-fast`). |
88
+ | `keel verify` | Runs gates in `.keel/config.yaml` (`--gate`, `--git`, `--staged`, `--base <ref>`, `--fail-fast`) with timeout and output-cap protection. |
83
89
  | `keel hotspots` | Ranks existing files by recent churn and bugfix commits (`--commits`, `--limit`). |
84
- | `keel mem` | `sources`, `sessions`, `search <query>`, `show <id>` across local AI transcripts and `.keel/`. |
85
- | `keel migrate` | `scan`, `plan`, `cleanup [--dry-run]`, `rollback` for moving off older AI setups safely. |
86
- | `keel ablate` / `restore` | Temporarily removes Keel files into a SHA-256 verified snapshot for A/B testing, then restores them cleanly. |
87
- | `keel mcp` | Starts the built-in stdio MCP server. |
90
+ | `keel mem` | `sources`, `sessions`, `search`, `show` (`--scope project \| all`) across `.keel/`, Claude Code, Codex, OpenCode, Antigravity, Gemini, and custom dirs. |
91
+ | `keel migrate` | `scan`, `plan`, `cleanup [--dry-run]`, `rollback` backed by SHA-256 external snapshots. |
92
+ | `keel ablate` / `restore` | Temporarily removes Keel surfaces for A/B benchmarking and restores byte-for-byte. |
93
+ | `keel mcp` | Starts the stdio MCP server (13 tools, multi-repo per-call `root`, optional `--lock-root`). |
88
94
 
89
95
  ## MCP Server
90
96
 
91
- Two compatible stdio implementations are included: Node.js (`keel mcp`) and a standalone Rust binary (`crates/keel-mcp`, ~2 MiB, no Node runtime needed).
97
+ A single `keel mcp` process can serve multiple repositories safely (including behind MCP hubs/aggregators). Every tool accepts an optional `root` argument as highest priority.
92
98
 
93
- **Node.js**
99
+ **Codex CLI (global)**
94
100
 
95
- ```json
96
- {
97
- "mcpServers": {
98
- "keel": {
99
- "command": "keel",
100
- "args": ["mcp"]
101
- }
102
- }
103
- }
101
+ ```sh
102
+ codex mcp add keel -- keel mcp
104
103
  ```
105
104
 
106
- **Native Rust** (`cargo build --release --locked --manifest-path crates/keel-mcp/Cargo.toml`)
105
+ **Standard `mcpServers` JSON** (Claude Code, Cursor, OpenCode, Antigravity)
107
106
 
108
107
  ```json
109
108
  {
110
109
  "mcpServers": {
111
110
  "keel": {
112
- "command": "/path/to/keel/crates/keel-mcp/target/release/keel-mcp",
113
- "args": ["--root", "/path/to/your-project"]
111
+ "command": "keel",
112
+ "args": ["mcp"]
114
113
  }
115
114
  }
116
115
  }
117
116
  ```
118
117
 
118
+ Pass `--root <path> --lock-root` if you want to pin an instance to a single repository.
119
+
119
120
  <details>
120
- <summary>Exposed MCP tools (9)</summary>
121
+ <summary>Exposed MCP tools (13)</summary>
121
122
 
122
- - `keel_rules_list` · `keel_rules_match` · `keel_rules_check` (`stale?: boolean`)
123
- - `keel_task_list` · `keel_task_create` · `keel_task_show`
124
- - `keel_verify` (`gates?: string[]`, `git?: boolean`, `failFast?: boolean`)
125
- - `keel_mem_search` · `keel_mem_sessions`
123
+ - `keel_rules_list` · `keel_rules_match` · `keel_rules_add` · `keel_rules_check`
124
+ - `keel_task_list` · `keel_task_create` · `keel_task_show` · `keel_task_update`
125
+ - `keel_verify` · `keel_hotspots`
126
+ - `keel_mem_search` · `keel_mem_sessions` · `keel_mem_show`
126
127
 
127
128
  </details>
128
129
 
129
- See [crates/keel-mcp/README.md](./crates/keel-mcp/README.md) for Windows examples and parity checks.
130
-
131
130
  ## Repository Layout
132
131
 
133
132
  ```text
134
133
  .keel/
135
- config.yaml # verify gates (optional paths globs) and extra memory dirs
134
+ config.yaml # verify gates (paths, timeoutMs, maxOutputChars) & memory sources
136
135
  rules/ # path-scoped markdown rules (YAML frontmatter)
137
136
  tasks/ # optional task specs (meta.json + spec.md)
138
137
  AGENTS.md # managed block (<!-- KEEL:START --> ... <!-- KEEL:END -->)
package/README_CN.md CHANGED
@@ -10,14 +10,13 @@
10
10
  <a href="https://www.npmjs.com/package/@pdxxxx/keel"><img src="https://img.shields.io/npm/v/%40pdxxxx%2Fkeel?style=flat-square&color=cb3837" alt="npm version" /></a>
11
11
  <a href="https://github.com/pdxxxx/keel/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/pdxxxx/keel/ci.yml?style=flat-square&label=CI" alt="CI" /></a>
12
12
  <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-2563eb?style=flat-square" alt="MIT License" /></a>
13
- <img src="https://img.shields.io/badge/node-%3E%3D20-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node >= 20" />
14
13
  <img src="https://img.shields.io/badge/rust-1.85%2B-dea584?style=flat-square&logo=rust&logoColor=black" alt="Rust 1.85+" />
15
14
  </p>
16
15
 
17
16
  <p>
17
+ <a href="https://pdxxxx.github.io/keel/zh/">官网文档</a> ·
18
18
  <a href="./README.md">English</a> ·
19
19
  <a href="./ARCHITECTURE.md">Architecture</a> ·
20
- <a href="./crates/keel-mcp/README.md">Rust MCP</a> ·
21
20
  <a href="./CHANGELOG.md">Changelog</a>
22
21
  </p>
23
22
 
@@ -25,18 +24,27 @@
25
24
 
26
25
  ---
27
26
 
28
- Keel 把项目规则、可选任务文档和校验命令以纯文本形式存在 `.keel/` 下,并支持跨 Claude Code、Codex、OpenCode 与自定义目录检索本地历史会话。
27
+ Keel 是一个单文件纯 Rust 可执行程序(约 3.6 MiB),把项目规则、可选任务文档和校验命令以纯文本存在 `.keel/` 下,跨 7 类本地数据源检索历史会话,并通过 stdio MCP 暴露 13 个工具。
29
28
 
30
- 它不接管子 Agent 调度,不往编辑器里装私有 Hook,也不绑定特定 AI 工具。直接用命令行,或者通过 stdio 接 MCP 都可以。
29
+ 它不接管子 Agent 调度,不往编辑器里装私有 Hook,也不绑定特定 AI 工具。
31
30
 
32
- ## 快速开始
33
-
34
- 需要 **Node.js >= 20**。
31
+ ## 安装
35
32
 
36
33
  ```sh
34
+ # 推荐:自动下载对应平台预编译二进制并校验 SHA-256
37
35
  npm install -g @pdxxxx/keel@latest
38
36
  ```
39
37
 
38
+ 或使用 Rust 1.85+ 从源码直接安装:
39
+
40
+ ```sh
41
+ cargo install --git https://github.com/pdxxxx/keel --locked
42
+ ```
43
+
44
+ Linux(`x86_64`、`aarch64`)、macOS(`arm64`、`x86_64`)与 Windows(`x86_64`)预编译单文件也可从 [GitHub Releases](https://github.com/pdxxxx/keel/releases) 直接下载。
45
+
46
+ ## 快速开始
47
+
40
48
  ```sh
41
49
  # 1. 初始化 .keel/、AGENTS.md 托管块与标准 .agents/skills/
42
50
  keel init
@@ -46,93 +54,84 @@ keel rules add auth-rotation \
46
54
  --summary "Rotate refresh tokens atomically" \
47
55
  --paths "src/auth/**"
48
56
 
49
- # 3. 查找当前 git diff 命中的规则
57
+ # 3. 查找命中当前 git diff 的规则
50
58
  keel rules match --git
51
59
 
52
- # 4. 检索历史会话和 .keel/ 文档
53
- keel mem search "refresh token"
60
+ # 4. 检索当前项目相关的历史会话和 .keel/ 文档
61
+ keel mem search "refresh token" --scope project
54
62
 
55
63
  # 5. 只运行命中当前变更的检查门禁(去掉 --git 跑全量)
56
64
  keel verify --git
57
65
  ```
58
66
 
59
- ## 老仓库接入与迁移
60
-
61
- 在已有代码库里,先从门禁和 Git 历史热点入手,不用一上来写大篇幅规范:
67
+ ## 老仓库接入、升级与迁移
62
68
 
63
69
  ```sh
64
- keel hotspots # 找出高频修复文件,优先给暗坑补规则
65
- keel rules check --stale # 检查失效路径 glob 与过长/过多全局规则
66
- keel migrate scan # 盘点 Trellis、.cursorrules、CLAUDE.md 等旧配置
67
- keel migrate plan # 列出冲突 Hook、候选门禁与待提纯规则源
68
- keel migrate cleanup --dry-run # 预览安全清理(清理前自动备份,可 `keel migrate rollback` 回滚)
70
+ keel hotspots # 找出高频修复文件,优先给暗坑补规则
71
+ keel doctor # 检查 config.yaml 字段错误、AGENTS.md 标记、git 与失效规则
72
+ keel update # 安全刷新 AGENTS.md 块与内置 skills,不动你的 config.yaml
73
+ keel migrate scan # 盘点 Trellis、.cursorrules、CLAUDE.md 等旧配置
74
+ keel migrate cleanup --dry-run # 预览安全清理(自动备份,可 `keel migrate rollback` 回滚)
69
75
  ```
70
76
 
71
- 配合内置的 `keel-migrate` skill,可让 AI 将旧框架规范按 10:1 提纯进 `.keel/rules/`。
72
-
73
77
  ## 命令一览
74
78
 
75
- 所有命令均支持 `--json`。
79
+ 全局选项:`-C, --root <PATH>` 与 `--json`。
76
80
 
77
81
  | 命令 | 说明 |
78
82
  | --- | --- |
79
- | `keel init` | 创建 `.keel/`、自动识别常见检查脚本(`typecheck` / `lint` / `test`)、更新 `AGENTS.md` 并写入 `.agents/skills/`。 |
83
+ | `keel init` | 创建 `.keel/`、自动探测校验脚本、更新 `AGENTS.md` 并安装 5 个标准 skills(除非显式 `--reset-config`,绝不覆盖已有 `config.yaml`)。 |
84
+ | `keel update` | 安全刷新托管模板(`AGENTS.md` 块、`rules/index.md`、`keel-*` skills),不碰用户配置、规则和任务。 |
85
+ | `keel doctor` | 严格校验 `.keel/config.yaml` 字段与类型、检查 `AGENTS.md` 标记、`git` 及过期规则。 |
80
86
  | `keel rules` | `list`、`match [paths...] [--git \| --staged \| --base <ref>]`、`add <id>`、`check [--stale \| --strict]`。 |
81
87
  | `keel task` | `create`、`list`、`show`、`done`、`reopen`、`archive`,按需用单个 `spec.md` 记录复杂任务。 |
82
- | `keel verify` | 运行 `.keel/config.yaml` 中的检查门禁(支持 `--gate`、`--git`、`--staged`、`--base <ref>`、`--fail-fast`)。 |
83
- | `keel hotspots` | 按近期改动与 bugfix 频率列出高风险文件(`--commits`、`--limit`)。 |
84
- | `keel mem` | `sources`、`sessions`、`search <query>`、`show <id>`,检索本地 AI 会话与 `.keel/` 文档。 |
85
- | `keel migrate` | `scan`、`plan`、`cleanup [--dry-run]`、`rollback`,安全迁移旧 AI 框架配置。 |
86
- | `keel ablate` / `restore` | 将 Keel 相关文件临时移入带 SHA-256 校验的外部快照以做对比测试,随后无损恢复。 |
87
- | `keel mcp` | 启动内置 stdio MCP 服务。 |
88
+ | `keel verify` | 运行 `.keel/config.yaml` 中的门禁(支持 `--gate`、`--git`、`--staged`、`--base <ref>`、`--fail-fast`),自带超时强杀与输出截断。 |
89
+ | `keel hotspots` | 按近期改动与 bugfix 频率列出高风险现存文件(`--commits`、`--limit`)。 |
90
+ | `keel mem` | `sources`、`sessions`、`search`、`show`(支持 `--scope project \| all`),跨 `.keel/`、Claude Code、Codex、OpenCode、Antigravity、Gemini 与自定义目录流式检索。 |
91
+ | `keel migrate` | `scan`、`plan`、`cleanup [--dry-run]`、`rollback`,由外部 SHA-256 快照保护。 |
92
+ | `keel ablate` / `restore` | 临时移出 Keel 文件做 A/B 对比,随后逐字节无损恢复。 |
93
+ | `keel mcp` | 启动 stdio MCP 服务(13 个工具,支持按次 `root` 切换多仓库与 `--lock-root`)。 |
88
94
 
89
95
  ## MCP 接入
90
96
 
91
- 仓库同时提供两套协议完全一致的 stdio MCP 实现:Node.js 版(`keel mcp`)和独立 Rust 二进制版(`crates/keel-mcp`,约 2 MiB,运行不依赖 Node)。
97
+ 单个常驻 `keel mcp` 进程即可安全服务多个仓库(完美适配 MCP 聚合服务)。全部 13 个工具均支持最高优先级可选参数 `root`。
92
98
 
93
- **Node.js 版**
99
+ **Codex CLI 全局安装**
94
100
 
95
- ```json
96
- {
97
- "mcpServers": {
98
- "keel": {
99
- "command": "keel",
100
- "args": ["mcp"]
101
- }
102
- }
103
- }
101
+ ```sh
102
+ codex mcp add keel -- keel mcp
104
103
  ```
105
104
 
106
- **原生 Rust 版**(`cargo build --release --locked --manifest-path crates/keel-mcp/Cargo.toml`)
105
+ **通用 `mcpServers` JSON**(Claude Code / Cursor / OpenCode / Antigravity)
107
106
 
108
107
  ```json
109
108
  {
110
109
  "mcpServers": {
111
110
  "keel": {
112
- "command": "/path/to/keel/crates/keel-mcp/target/release/keel-mcp",
113
- "args": ["--root", "/path/to/your-project"]
111
+ "command": "keel",
112
+ "args": ["mcp"]
114
113
  }
115
114
  }
116
115
  }
117
116
  ```
118
117
 
118
+ 如需强制锁死在单个仓库目录,传入 `--root <path> --lock-root`。
119
+
119
120
  <details>
120
- <summary>暴露的 MCP 工具(9 个)</summary>
121
+ <summary>暴露的 MCP 工具(13 个)</summary>
121
122
 
122
- - `keel_rules_list` · `keel_rules_match` · `keel_rules_check`(支持 `stale?: boolean`)
123
- - `keel_task_list` · `keel_task_create` · `keel_task_show`
124
- - `keel_verify`(支持 `gates?: string[]`、`git?: boolean`、`failFast?: boolean`)
125
- - `keel_mem_search` · `keel_mem_sessions`
123
+ - `keel_rules_list` · `keel_rules_match` · `keel_rules_add` · `keel_rules_check`
124
+ - `keel_task_list` · `keel_task_create` · `keel_task_show` · `keel_task_update`
125
+ - `keel_verify` · `keel_hotspots`
126
+ - `keel_mem_search` · `keel_mem_sessions` · `keel_mem_show`
126
127
 
127
128
  </details>
128
129
 
129
- Windows 配置示例与双端对照测试见 [crates/keel-mcp/README.md](./crates/keel-mcp/README.md)。
130
-
131
130
  ## 仓库目录结构
132
131
 
133
132
  ```text
134
133
  .keel/
135
- config.yaml # 校验门禁(支持按 paths 增量触发)与额外记忆目录
134
+ config.yaml # 校验门禁(支持 paths、timeoutMs、maxOutputChars)与额外记忆目录
136
135
  rules/ # 带 YAML frontmatter 的按路径规则
137
136
  tasks/ # 可选任务目录(meta.json + spec.md)
138
137
  AGENTS.md # 托管块(<!-- KEEL:START --> ... <!-- KEEL:END -->)
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
3
+ import { constants } from 'node:os';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const native = process.platform === 'win32' ? 'keel.exe' : 'keel';
7
+ const binary = process.env.KEEL_BINARY || fileURLToPath(new URL(`../native/${native}`, import.meta.url));
8
+ const child = spawn(binary, process.argv.slice(2), { stdio: 'inherit' });
9
+ const handlers = new Map();
10
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
11
+ const forward = () => child.kill(signal);
12
+ handlers.set(signal, forward);
13
+ process.on(signal, forward);
14
+ }
15
+ child.once('error', error => {
16
+ console.error(`keel: Cannot start ${binary}: ${error.message}. Run npm rebuild @pdxxxx/keel to download again, or cargo install --git https://github.com/pdxxxx/keel.`);
17
+ process.exitCode = 1;
18
+ });
19
+ child.once('close', (code, signal) => {
20
+ for (const [name, handler] of handlers) process.off(name, handler);
21
+ if (signal) {
22
+ process.exitCode = 128 + (constants.signals[signal] || 0);
23
+ if (process.platform !== 'win32') process.kill(process.pid, signal);
24
+ } else if (!process.exitCode) process.exitCode = code ?? 1;
25
+ });