@pdxxxx/keel 0.0.0-stage → 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.
@@ -0,0 +1,106 @@
1
+ # Architecture
2
+
3
+ Keel is a single pure-Rust executable (`keel`) that serves both the CLI and the stdio MCP server from one codebase.
4
+
5
+ ## Design choices
6
+
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
+
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.
14
+
15
+ ## Code layout
16
+
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
+
26
+ ## On-disk formats
27
+
28
+ ### Rules (`.keel/rules/**/*.md`)
29
+
30
+ ```markdown
31
+ ---
32
+ id: auth-token-rotation
33
+ summary: Rotate refresh tokens atomically
34
+ severity: invariant
35
+ paths:
36
+ - src/auth/**
37
+ ---
38
+
39
+ Explain why this invariant exists.
40
+ ```
41
+
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).
46
+
47
+ ### Tasks (`.keel/tasks/<YYYY-MM-DD>-<slug>/`)
48
+
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.
53
+
54
+ ### Verification gates (`.keel/config.yaml`)
55
+
56
+ ```yaml
57
+ version: 1
58
+ verify:
59
+ gates:
60
+ - name: api-test
61
+ command: pnpm --filter api test
62
+ paths:
63
+ - packages/api/**
64
+ timeoutMs: 120000
65
+ maxOutputChars: 16000
66
+ memory:
67
+ sources: []
68
+ ```
69
+
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.
73
+
74
+ ### Memory (`src/mem.rs`)
75
+
76
+ Streaming, read-only scan across seven sources:
77
+
78
+ - `keel`: `.keel/tasks/` and `.keel/rules/` Markdown files
79
+ - `claude`: `~/.claude/projects/**/*.jsonl`
80
+ - `codex`: `~/.codex/sessions/**/*.jsonl`
81
+ - `opencode`: `~/.local/share/opencode/**/*.jsonl`
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:
91
+
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).
96
+
97
+ ### Multi-repo MCP root resolution (`src/mcp_root.rs`)
98
+
99
+ Per-call precedence (highest to lowest):
100
+
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
105
+
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 ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0 - 2026-11-24
4
+
5
+ Pure Rust single-binary release (`keel`).
6
+
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
+
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`.
24
+
25
+ ## 1.0.0 - 2026-11-24
26
+
27
+ - Initial release (`init`, `rules`, `task`, `verify`, `mem`, `ablate` / `restore`, `mcp`).
package/LICENSE ADDED
@@ -0,0 +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.
package/README.md CHANGED
@@ -1,3 +1,143 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <img src="./assets/keel.png" width="84" height="84" alt="keel" />
4
+
5
+ # keel
6
+
7
+ **Repo rules, task specs, session memory, and verification gates for coding agents.**
8
+
9
+ <p>
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
+ <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
+ <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/rust-1.85%2B-dea584?style=flat-square&logo=rust&logoColor=black" alt="Rust 1.85+" />
14
+ </p>
15
+
16
+ <p>
17
+ <a href="https://pdxxxx.github.io/keel/">Docs</a> ·
18
+ <a href="./README_CN.md">简体中文</a> ·
19
+ <a href="./ARCHITECTURE.md">Architecture</a> ·
20
+ <a href="./CHANGELOG.md">Changelog</a>
21
+ </p>
22
+
23
+ </div>
24
+
25
+ ---
26
+
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.
28
+
29
+ It does not manage sub-agents, install editor hooks, or tie you to a specific coding tool.
30
+
31
+ ## Install
32
+
33
+ ```sh
34
+ # Recommended: installs the prebuilt native binary verified with SHA-256
35
+ npm install -g @pdxxxx/keel@latest
36
+ ```
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
+
48
+ ```sh
49
+ # 1. Initialize .keel/, AGENTS.md block, and standard .agents/skills/
50
+ keel init
51
+
52
+ # 2. Record a path-scoped rule
53
+ keel rules add auth-rotation \
54
+ --summary "Rotate refresh tokens atomically" \
55
+ --paths "src/auth/**"
56
+
57
+ # 3. Pull rules matching your current git diff
58
+ keel rules match --git
59
+
60
+ # 4. Search past sessions and .keel/ docs
61
+ keel mem search "refresh token" --scope project
62
+
63
+ # 5. Run checks matching your current git diff (drop --git for all gates)
64
+ keel verify --git
65
+ ```
66
+
67
+ ## Existing Repos & Migration
68
+
69
+ ```sh
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`)
75
+ ```
76
+
77
+ ## Commands
78
+
79
+ Global flags: `-C, --root <PATH>` and `--json`.
80
+
81
+ | Command | Description |
82
+ | --- | --- |
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. |
86
+ | `keel rules` | `list`, `match [paths...] [--git \| --staged \| --base <ref>]`, `add <id>`, `check [--stale \| --strict]`. |
87
+ | `keel task` | `create`, `list`, `show`, `done`, `reopen`, `archive` — optional single-file `spec.md` per task. |
88
+ | `keel verify` | Runs gates in `.keel/config.yaml` (`--gate`, `--git`, `--staged`, `--base <ref>`, `--fail-fast`) with timeout and output-cap protection. |
89
+ | `keel hotspots` | Ranks existing files by recent churn and bugfix commits (`--commits`, `--limit`). |
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`). |
94
+
95
+ ## MCP Server
96
+
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.
98
+
99
+ **Codex CLI (global)**
100
+
101
+ ```sh
102
+ codex mcp add keel -- keel mcp
103
+ ```
104
+
105
+ **Standard `mcpServers` JSON** (Claude Code, Cursor, OpenCode, Antigravity)
106
+
107
+ ```json
108
+ {
109
+ "mcpServers": {
110
+ "keel": {
111
+ "command": "keel",
112
+ "args": ["mcp"]
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ Pass `--root <path> --lock-root` if you want to pin an instance to a single repository.
119
+
120
+ <details>
121
+ <summary>Exposed MCP tools (13)</summary>
122
+
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`
127
+
128
+ </details>
129
+
130
+ ## Repository Layout
131
+
132
+ ```text
133
+ .keel/
134
+ config.yaml # verify gates (paths, timeoutMs, maxOutputChars) & memory sources
135
+ rules/ # path-scoped markdown rules (YAML frontmatter)
136
+ tasks/ # optional task specs (meta.json + spec.md)
137
+ AGENTS.md # managed block (<!-- KEEL:START --> ... <!-- KEEL:END -->)
138
+ .agents/skills/ # keel-plan, keel-verify, keel-distill, keel-mem, keel-migrate
139
+ ```
140
+
141
+ ## License
142
+
143
+ [MIT](./LICENSE)
package/README_CN.md ADDED
@@ -0,0 +1,143 @@
1
+ <div align="center">
2
+
3
+ <img src="./assets/keel.png" width="84" height="84" alt="keel" />
4
+
5
+ # keel
6
+
7
+ **面向 AI 编程的仓库规范、任务记录、会话检索与验证门禁工具。**
8
+
9
+ <p>
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
+ <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
+ <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/rust-1.85%2B-dea584?style=flat-square&logo=rust&logoColor=black" alt="Rust 1.85+" />
14
+ </p>
15
+
16
+ <p>
17
+ <a href="https://pdxxxx.github.io/keel/zh/">官网文档</a> ·
18
+ <a href="./README.md">English</a> ·
19
+ <a href="./ARCHITECTURE.md">Architecture</a> ·
20
+ <a href="./CHANGELOG.md">Changelog</a>
21
+ </p>
22
+
23
+ </div>
24
+
25
+ ---
26
+
27
+ Keel 是一个单文件纯 Rust 可执行程序(约 3.6 MiB),把项目规则、可选任务文档和校验命令以纯文本存在 `.keel/` 下,跨 7 类本地数据源检索历史会话,并通过 stdio MCP 暴露 13 个工具。
28
+
29
+ 它不接管子 Agent 调度,不往编辑器里装私有 Hook,也不绑定特定 AI 工具。
30
+
31
+ ## 安装
32
+
33
+ ```sh
34
+ # 推荐:自动下载对应平台预编译二进制并校验 SHA-256
35
+ npm install -g @pdxxxx/keel@latest
36
+ ```
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
+
48
+ ```sh
49
+ # 1. 初始化 .keel/、AGENTS.md 托管块与标准 .agents/skills/
50
+ keel init
51
+
52
+ # 2. 添加一条按路径生效的规则
53
+ keel rules add auth-rotation \
54
+ --summary "Rotate refresh tokens atomically" \
55
+ --paths "src/auth/**"
56
+
57
+ # 3. 查找命中当前 git diff 的规则
58
+ keel rules match --git
59
+
60
+ # 4. 检索当前项目相关的历史会话和 .keel/ 文档
61
+ keel mem search "refresh token" --scope project
62
+
63
+ # 5. 只运行命中当前变更的检查门禁(去掉 --git 跑全量)
64
+ keel verify --git
65
+ ```
66
+
67
+ ## 老仓库接入、升级与迁移
68
+
69
+ ```sh
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` 回滚)
75
+ ```
76
+
77
+ ## 命令一览
78
+
79
+ 全局选项:`-C, --root <PATH>` 与 `--json`。
80
+
81
+ | 命令 | 说明 |
82
+ | --- | --- |
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` 及过期规则。 |
86
+ | `keel rules` | `list`、`match [paths...] [--git \| --staged \| --base <ref>]`、`add <id>`、`check [--stale \| --strict]`。 |
87
+ | `keel task` | `create`、`list`、`show`、`done`、`reopen`、`archive`,按需用单个 `spec.md` 记录复杂任务。 |
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`)。 |
94
+
95
+ ## MCP 接入
96
+
97
+ 单个常驻 `keel mcp` 进程即可安全服务多个仓库(完美适配 MCP 聚合服务)。全部 13 个工具均支持最高优先级可选参数 `root`。
98
+
99
+ **Codex CLI 全局安装**
100
+
101
+ ```sh
102
+ codex mcp add keel -- keel mcp
103
+ ```
104
+
105
+ **通用 `mcpServers` JSON**(Claude Code / Cursor / OpenCode / Antigravity)
106
+
107
+ ```json
108
+ {
109
+ "mcpServers": {
110
+ "keel": {
111
+ "command": "keel",
112
+ "args": ["mcp"]
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ 如需强制锁死在单个仓库目录,传入 `--root <path> --lock-root`。
119
+
120
+ <details>
121
+ <summary>暴露的 MCP 工具(13 个)</summary>
122
+
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`
127
+
128
+ </details>
129
+
130
+ ## 仓库目录结构
131
+
132
+ ```text
133
+ .keel/
134
+ config.yaml # 校验门禁(支持 paths、timeoutMs、maxOutputChars)与额外记忆目录
135
+ rules/ # 带 YAML frontmatter 的按路径规则
136
+ tasks/ # 可选任务目录(meta.json + spec.md)
137
+ AGENTS.md # 托管块(<!-- KEEL:START --> ... <!-- KEEL:END -->)
138
+ .agents/skills/ # keel-plan, keel-verify, keel-distill, keel-mem, keel-migrate
139
+ ```
140
+
141
+ ## 开源协议
142
+
143
+ [MIT](./LICENSE)
@@ -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
+ });
package/npm/install.js ADDED
@@ -0,0 +1,55 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { createWriteStream } from 'node:fs';
3
+ import { chmod, mkdir, readFile, rename, rm } from 'node:fs/promises';
4
+ import { dirname, join } from 'node:path';
5
+ import { Readable, Transform } from 'node:stream';
6
+ import { pipeline } from 'node:stream/promises';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const assets = {
10
+ 'win32/x64': 'keel-windows-x86_64.exe',
11
+ 'darwin/arm64': 'keel-macos-arm64',
12
+ 'darwin/x64': 'keel-macos-x86_64',
13
+ 'linux/x64': 'keel-linux-x86_64',
14
+ 'linux/arm64': 'keel-linux-aarch64',
15
+ };
16
+
17
+ async function download(base, name) {
18
+ const url = new URL(name, base);
19
+ const response = await fetch(url, { signal: AbortSignal.timeout(120_000) });
20
+ if (!response.ok || !response.body) {
21
+ await response.body?.cancel();
22
+ throw new Error(`Download failed: ${url} (HTTP ${response.status})`);
23
+ }
24
+ return response;
25
+ }
26
+
27
+ async function install() {
28
+ if (process.env.KEEL_SKIP_DOWNLOAD === '1') return;
29
+ const platform = `${process.platform}/${process.arch}`;
30
+ const asset = assets[platform];
31
+ if (!asset) throw new Error(`No prebuilt binary for ${platform}; build Keel using cargo install --git https://github.com/pdxxxx/keel`);
32
+ const { version } = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
33
+ const base = (process.env.KEEL_DOWNLOAD_BASE_URL || `https://github.com/pdxxxx/keel/releases/download/v${version}`).replace(/\/*$/, '/');
34
+ const manifest = await (await download(base, 'SHA256SUMS.txt')).text();
35
+ const hashes = manifest.split(/\r?\n/).map(line => /^([\da-f]{64})[ \t]+\*?(\S+)$/i.exec(line)).filter(match => match?.[2] === asset);
36
+ if (hashes.length !== 1) throw new Error(`Expected exactly one SHA-256 checksum for ${asset}`);
37
+ const native = join(dirname(fileURLToPath(import.meta.url)), 'native');
38
+ const dest = join(native, process.platform === 'win32' ? 'keel.exe' : 'keel');
39
+ await mkdir(native, { recursive: true });
40
+ const tmp = join(native, `.${randomUUID()}.tmp`);
41
+ try {
42
+ const binary = await download(base, asset);
43
+ const hash = createHash('sha256');
44
+ const verify = new Transform({ transform(chunk, encoding, callback) { hash.update(chunk); callback(null, chunk); } });
45
+ await pipeline(Readable.fromWeb(binary.body), verify, createWriteStream(tmp, { flags: 'wx', mode: 0o600 }));
46
+ if (hash.digest('hex') !== hashes[0][1].toLowerCase()) throw new Error(`SHA-256 mismatch for ${asset}; refusing to install`);
47
+ if (process.platform !== 'win32') await chmod(tmp, 0o755);
48
+ await rename(tmp, dest);
49
+ } finally {
50
+ await rm(tmp, { force: true });
51
+ }
52
+ }
53
+
54
+ try { await install(); }
55
+ catch (error) { console.error(`keel: ${error.message}`); process.exitCode = 1; }
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@pdxxxx/keel",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0",
4
+ "description": "Repo rules, task specs, session memory, and verification gates for coding agents.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/pdxxxx/keel#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/pdxxxx/keel/issues"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/pdxxxx/keel.git"
14
+ },
15
+ "keywords": [
16
+ "ai",
17
+ "coding-agent",
18
+ "mcp",
19
+ "cli",
20
+ "agents-md",
21
+ "rules",
22
+ "memory",
23
+ "verification",
24
+ "keel"
25
+ ],
26
+ "engines": {
27
+ "node": ">=20.0.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "bin": {
33
+ "keel": "npm/bin/keel.js"
34
+ },
35
+ "files": [
36
+ "npm/bin",
37
+ "npm/install.js",
38
+ "README.md",
39
+ "README_CN.md",
40
+ "ARCHITECTURE.md",
41
+ "CHANGELOG.md",
42
+ "LICENSE"
43
+ ],
44
+ "scripts": {
45
+ "postinstall": "node npm/install.js",
46
+ "test:npm": "node --test npm/test.mjs"
47
+ }
48
+ }