@pdxxxx/keel 0.0.0-stage → 1.1.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.
- package/ARCHITECTURE.md +101 -0
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +143 -2
- package/README_CN.md +144 -0
- package/bin/keel.js +4 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +569 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/ablate.d.ts +11 -0
- package/dist/core/ablate.js +54 -0
- package/dist/core/ablate.js.map +1 -0
- package/dist/core/config.d.ts +3 -0
- package/dist/core/config.js +60 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/git.d.ts +9 -0
- package/dist/core/git.js +48 -0
- package/dist/core/git.js.map +1 -0
- package/dist/core/glob.d.ts +8 -0
- package/dist/core/glob.js +61 -0
- package/dist/core/glob.js.map +1 -0
- package/dist/core/hotspots.d.ts +11 -0
- package/dist/core/hotspots.js +49 -0
- package/dist/core/hotspots.js.map +1 -0
- package/dist/core/init.d.ts +14 -0
- package/dist/core/init.js +117 -0
- package/dist/core/init.js.map +1 -0
- package/dist/core/mcp.d.ts +24 -0
- package/dist/core/mcp.js +323 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/core/mem.d.ts +21 -0
- package/dist/core/mem.js +337 -0
- package/dist/core/mem.js.map +1 -0
- package/dist/core/migrate.d.ts +21 -0
- package/dist/core/migrate.js +207 -0
- package/dist/core/migrate.js.map +1 -0
- package/dist/core/paths.d.ts +14 -0
- package/dist/core/paths.js +44 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/rules.d.ts +22 -0
- package/dist/core/rules.js +262 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/snapshot.d.ts +30 -0
- package/dist/core/snapshot.js +212 -0
- package/dist/core/snapshot.js.map +1 -0
- package/dist/core/tasks.d.ts +13 -0
- package/dist/core/tasks.js +180 -0
- package/dist/core/tasks.js.map +1 -0
- package/dist/core/types.d.ts +98 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/verify.d.ts +8 -0
- package/dist/core/verify.js +66 -0
- package/dist/core/verify.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/assets.d.ts +11 -0
- package/dist/templates/assets.js +179 -0
- package/dist/templates/assets.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +67 -4
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
This document explains how Keel is laid out, what file formats it owns, and why certain features were left out.
|
|
4
|
+
|
|
5
|
+
## Design choices
|
|
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.
|
|
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.
|
|
18
|
+
|
|
19
|
+
## Code layout
|
|
20
|
+
|
|
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`.
|
|
25
|
+
|
|
26
|
+
## On-disk formats
|
|
27
|
+
|
|
28
|
+
### Rules (`.keel/rules/**/*.md`)
|
|
29
|
+
|
|
30
|
+
Rule files use YAML frontmatter followed by Markdown:
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
---
|
|
34
|
+
id: auth-token-rotation
|
|
35
|
+
summary: Rotate refresh tokens atomically
|
|
36
|
+
severity: invariant
|
|
37
|
+
paths:
|
|
38
|
+
- src/auth/**
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
Concurrent tab refreshes previously caused false-positive token revocation...
|
|
42
|
+
```
|
|
43
|
+
|
|
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).
|
|
50
|
+
|
|
51
|
+
### Tasks (`.keel/tasks/<YYYY-MM-DD>-<slug>/`)
|
|
52
|
+
|
|
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.
|
|
60
|
+
|
|
61
|
+
### Verification gates (`.keel/config.yaml`)
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
version: 1
|
|
65
|
+
verify:
|
|
66
|
+
gates:
|
|
67
|
+
- name: api-test
|
|
68
|
+
command: pnpm --filter api test
|
|
69
|
+
paths:
|
|
70
|
+
- packages/api/**
|
|
71
|
+
- name: typecheck
|
|
72
|
+
command: pnpm typecheck
|
|
73
|
+
memory:
|
|
74
|
+
sources: []
|
|
75
|
+
```
|
|
76
|
+
|
|
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`.
|
|
78
|
+
|
|
79
|
+
### Hotspots (`src/core/hotspots.ts`)
|
|
80
|
+
|
|
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.
|
|
82
|
+
|
|
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.
|
|
88
|
+
- `claude`: `~/.claude/projects/**/*.jsonl`
|
|
89
|
+
- `codex`: `~/.codex/sessions/**/*.jsonl`
|
|
90
|
+
- `opencode`: `~/.local/share/opencode/**/*.jsonl`
|
|
91
|
+
- `custom`: directories listed in `.keel/config.yaml` (`memory.sources`) and the `KEEL_MEM_DIRS` environment variable.
|
|
92
|
+
|
|
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.
|
|
94
|
+
|
|
95
|
+
### Snapshots, ablation, and migration (`src/core/snapshot.ts`, `ablate.ts`, `migrate.ts`)
|
|
96
|
+
|
|
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.
|
|
98
|
+
|
|
99
|
+
### MCP server (`src/core/mcp.ts`, `crates/keel-mcp/`)
|
|
100
|
+
|
|
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.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.1.0 - 2026-11-24
|
|
4
|
+
|
|
5
|
+
Brownfield (1->N) and migration release.
|
|
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`.
|
|
11
|
+
|
|
12
|
+
## 1.0.0 - 2026-11-24
|
|
13
|
+
|
|
14
|
+
Initial release.
|
|
15
|
+
|
|
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`.
|
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,144 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
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/node-%3E%3D20-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node >= 20" />
|
|
14
|
+
<img src="https://img.shields.io/badge/rust-1.85%2B-dea584?style=flat-square&logo=rust&logoColor=black" alt="Rust 1.85+" />
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p>
|
|
18
|
+
<a href="./README_CN.md">简体中文</a> ·
|
|
19
|
+
<a href="./ARCHITECTURE.md">Architecture</a> ·
|
|
20
|
+
<a href="./crates/keel-mcp/README.md">Rust MCP</a> ·
|
|
21
|
+
<a href="./CHANGELOG.md">Changelog</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
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.
|
|
29
|
+
|
|
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.
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
Requires **Node.js >= 20**.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install -g @pdxxxx/keel@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
# 1. Initialize .keel/, AGENTS.md block, and standard .agents/skills/
|
|
42
|
+
keel init
|
|
43
|
+
|
|
44
|
+
# 2. Record a path-scoped rule
|
|
45
|
+
keel rules add auth-rotation \
|
|
46
|
+
--summary "Rotate refresh tokens atomically" \
|
|
47
|
+
--paths "src/auth/**"
|
|
48
|
+
|
|
49
|
+
# 3. Pull rules matching your current git diff
|
|
50
|
+
keel rules match --git
|
|
51
|
+
|
|
52
|
+
# 4. Search past sessions and .keel/ docs
|
|
53
|
+
keel mem search "refresh token"
|
|
54
|
+
|
|
55
|
+
# 5. Run checks matching your current git diff (or drop --git for all gates)
|
|
56
|
+
keel verify --git
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Existing Repos & Migration
|
|
60
|
+
|
|
61
|
+
On a mature codebase, start with checks and git history rather than writing broad style docs:
|
|
62
|
+
|
|
63
|
+
```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`)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Pair `keel migrate` with the bundled `keel-migrate` skill to distill only non-obvious traps into `.keel/rules/`.
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
Every command supports `--json`.
|
|
76
|
+
|
|
77
|
+
| Command | Description |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `keel init` | Creates `.keel/`, detects project scripts (`typecheck`, `lint`, `test`), updates `AGENTS.md`, and installs `.agents/skills/`. |
|
|
80
|
+
| `keel rules` | `list`, `match [paths...] [--git \| --staged \| --base <ref>]`, `add <id>`, `check [--stale \| --strict]`. |
|
|
81
|
+
| `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`). |
|
|
83
|
+
| `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. |
|
|
88
|
+
|
|
89
|
+
## MCP Server
|
|
90
|
+
|
|
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).
|
|
92
|
+
|
|
93
|
+
**Node.js**
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"mcpServers": {
|
|
98
|
+
"keel": {
|
|
99
|
+
"command": "keel",
|
|
100
|
+
"args": ["mcp"]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Native Rust** (`cargo build --release --locked --manifest-path crates/keel-mcp/Cargo.toml`)
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"mcpServers": {
|
|
111
|
+
"keel": {
|
|
112
|
+
"command": "/path/to/keel/crates/keel-mcp/target/release/keel-mcp",
|
|
113
|
+
"args": ["--root", "/path/to/your-project"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
<details>
|
|
120
|
+
<summary>Exposed MCP tools (9)</summary>
|
|
121
|
+
|
|
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`
|
|
126
|
+
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
See [crates/keel-mcp/README.md](./crates/keel-mcp/README.md) for Windows examples and parity checks.
|
|
130
|
+
|
|
131
|
+
## Repository Layout
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
.keel/
|
|
135
|
+
config.yaml # verify gates (optional paths globs) and extra memory dirs
|
|
136
|
+
rules/ # path-scoped markdown rules (YAML frontmatter)
|
|
137
|
+
tasks/ # optional task specs (meta.json + spec.md)
|
|
138
|
+
AGENTS.md # managed block (<!-- KEEL:START --> ... <!-- KEEL:END -->)
|
|
139
|
+
.agents/skills/ # keel-plan, keel-verify, keel-distill, keel-mem, keel-migrate
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
[MIT](./LICENSE)
|
package/README_CN.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
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/node-%3E%3D20-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node >= 20" />
|
|
14
|
+
<img src="https://img.shields.io/badge/rust-1.85%2B-dea584?style=flat-square&logo=rust&logoColor=black" alt="Rust 1.85+" />
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p>
|
|
18
|
+
<a href="./README.md">English</a> ·
|
|
19
|
+
<a href="./ARCHITECTURE.md">Architecture</a> ·
|
|
20
|
+
<a href="./crates/keel-mcp/README.md">Rust MCP</a> ·
|
|
21
|
+
<a href="./CHANGELOG.md">Changelog</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
Keel 把项目规则、可选任务文档和校验命令以纯文本形式存在 `.keel/` 下,并支持跨 Claude Code、Codex、OpenCode 与自定义目录检索本地历史会话。
|
|
29
|
+
|
|
30
|
+
它不接管子 Agent 调度,不往编辑器里装私有 Hook,也不绑定特定 AI 工具。直接用命令行,或者通过 stdio 接 MCP 都可以。
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
33
|
+
|
|
34
|
+
需要 **Node.js >= 20**。
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install -g @pdxxxx/keel@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
# 1. 初始化 .keel/、AGENTS.md 托管块与标准 .agents/skills/
|
|
42
|
+
keel init
|
|
43
|
+
|
|
44
|
+
# 2. 添加一条按路径生效的规则
|
|
45
|
+
keel rules add auth-rotation \
|
|
46
|
+
--summary "Rotate refresh tokens atomically" \
|
|
47
|
+
--paths "src/auth/**"
|
|
48
|
+
|
|
49
|
+
# 3. 查找当前 git diff 命中的规则
|
|
50
|
+
keel rules match --git
|
|
51
|
+
|
|
52
|
+
# 4. 检索历史会话和 .keel/ 文档
|
|
53
|
+
keel mem search "refresh token"
|
|
54
|
+
|
|
55
|
+
# 5. 只运行命中当前变更的检查门禁(去掉 --git 跑全量)
|
|
56
|
+
keel verify --git
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 老仓库接入与迁移
|
|
60
|
+
|
|
61
|
+
在已有代码库里,先从门禁和 Git 历史热点入手,不用一上来写大篇幅规范:
|
|
62
|
+
|
|
63
|
+
```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` 回滚)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
配合内置的 `keel-migrate` skill,可让 AI 将旧框架规范按 10:1 提纯进 `.keel/rules/`。
|
|
72
|
+
|
|
73
|
+
## 命令一览
|
|
74
|
+
|
|
75
|
+
所有命令均支持 `--json`。
|
|
76
|
+
|
|
77
|
+
| 命令 | 说明 |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `keel init` | 创建 `.keel/`、自动识别常见检查脚本(`typecheck` / `lint` / `test`)、更新 `AGENTS.md` 并写入 `.agents/skills/`。 |
|
|
80
|
+
| `keel rules` | `list`、`match [paths...] [--git \| --staged \| --base <ref>]`、`add <id>`、`check [--stale \| --strict]`。 |
|
|
81
|
+
| `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
|
+
|
|
89
|
+
## MCP 接入
|
|
90
|
+
|
|
91
|
+
仓库同时提供两套协议完全一致的 stdio MCP 实现:Node.js 版(`keel mcp`)和独立 Rust 二进制版(`crates/keel-mcp`,约 2 MiB,运行不依赖 Node)。
|
|
92
|
+
|
|
93
|
+
**Node.js 版**
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"mcpServers": {
|
|
98
|
+
"keel": {
|
|
99
|
+
"command": "keel",
|
|
100
|
+
"args": ["mcp"]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**原生 Rust 版**(`cargo build --release --locked --manifest-path crates/keel-mcp/Cargo.toml`)
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"mcpServers": {
|
|
111
|
+
"keel": {
|
|
112
|
+
"command": "/path/to/keel/crates/keel-mcp/target/release/keel-mcp",
|
|
113
|
+
"args": ["--root", "/path/to/your-project"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
<details>
|
|
120
|
+
<summary>暴露的 MCP 工具(9 个)</summary>
|
|
121
|
+
|
|
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`
|
|
126
|
+
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
Windows 配置示例与双端对照测试见 [crates/keel-mcp/README.md](./crates/keel-mcp/README.md)。
|
|
130
|
+
|
|
131
|
+
## 仓库目录结构
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
.keel/
|
|
135
|
+
config.yaml # 校验门禁(支持按 paths 增量触发)与额外记忆目录
|
|
136
|
+
rules/ # 带 YAML frontmatter 的按路径规则
|
|
137
|
+
tasks/ # 可选任务目录(meta.json + spec.md)
|
|
138
|
+
AGENTS.md # 托管块(<!-- KEEL:START --> ... <!-- KEEL:END -->)
|
|
139
|
+
.agents/skills/ # keel-plan, keel-verify, keel-distill, keel-mem, keel-migrate
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 开源协议
|
|
143
|
+
|
|
144
|
+
[MIT](./LICENSE)
|
package/bin/keel.js
ADDED
package/dist/cli.d.ts
ADDED