@christang/keel 5.1.1
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/LICENSE +21 -0
- package/README.md +250 -0
- package/README.zh-CN.md +295 -0
- package/assets/bootstrap/AGENTS.md +9 -0
- package/assets/openspec/schemas/keel-spec-driven/schema.yaml +166 -0
- package/assets/openspec/schemas/keel-spec-driven/templates/design.md +52 -0
- package/assets/openspec/schemas/keel-spec-driven/templates/proposal.md +21 -0
- package/assets/openspec/schemas/keel-spec-driven/templates/spec.md +8 -0
- package/assets/openspec/schemas/keel-spec-driven/templates/tasks.md +68 -0
- package/bin/keel.js +1490 -0
- package/package.json +35 -0
- package/plugins/keel/.claude-plugin/plugin.json +17 -0
- package/plugins/keel/.codex-plugin/plugin.json +29 -0
- package/plugins/keel/agents/keel-single-task-goal-claude.md +16 -0
- package/plugins/keel/agents/keel-single-task-goal-codex.md +16 -0
- package/plugins/keel/hooks/hooks.json +30 -0
- package/plugins/keel/scripts/pretooluse-guard.js +156 -0
- package/plugins/keel/scripts/session-start.js +182 -0
- package/plugins/keel/skills/keel-align-expectations/SKILL.md +53 -0
- package/plugins/keel/skills/keel-align-expectations/references/hardware-dsl.md +21 -0
- package/plugins/keel/skills/keel-align-expectations/references/hardware.md +21 -0
- package/plugins/keel/skills/keel-align-expectations/references/web.md +21 -0
- package/plugins/keel/skills/keel-debug-failure/SKILL.md +41 -0
- package/plugins/keel/skills/keel-handoff/SKILL.md +45 -0
- package/plugins/keel/skills/keel-review-checklist/SKILL.md +73 -0
- package/plugins/keel/skills/keel-run-single-task-goal/SKILL.md +68 -0
- package/plugins/keel/skills/keel-tdd-or-test-first/SKILL.md +45 -0
- package/scripts/install_to_repo.py +1122 -0
- package/scripts/run_python.js +63 -0
- package/scripts/validate_plugin.py +9869 -0
- package/src/core/capabilities.js +291 -0
- package/src/core/context.js +514 -0
- package/src/core/gates.js +643 -0
- package/src/core/goal.js +230 -0
- package/src/core/guard.js +295 -0
- package/src/core/helper.js +319 -0
- package/src/core/projection.js +195 -0
- package/src/core/task-contract.js +736 -0
- package/src/core/tasksview.js +123 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TanglmChris
|
|
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
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Keel
|
|
2
|
+
|
|
3
|
+
**English** | [中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
> OpenSpec execution discipline for AI coding agents — Claude Code, Codex, and OpenCode.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
Keel wraps [OpenSpec](https://github.com/fission-ai/openspec) with a thin, deterministic
|
|
12
|
+
execution layer so a coding agent **plans, implements, verifies, reviews, and hands off**
|
|
13
|
+
work inside stable, checkable boundaries — instead of drifting mid-task or losing the
|
|
14
|
+
thread between sessions.
|
|
15
|
+
|
|
16
|
+
Keel is **stateless by design**: every session recomputes what to do from your OpenSpec
|
|
17
|
+
artifacts and Git, never from hidden chat memory, transcripts, or a saved "current task."
|
|
18
|
+
That makes an agent's work resumable, auditable, and safe to hand between runtimes.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Why Keel
|
|
23
|
+
|
|
24
|
+
- **Deterministic gates, not vibes.** `keel gate task-start | task-complete | change-close`
|
|
25
|
+
run local, model-free structural checks and return `pass` / `fail` / `needs-review` with
|
|
26
|
+
real exit codes. They never claim to judge whether your design is *correct* — only whether
|
|
27
|
+
the contract and evidence are present.
|
|
28
|
+
- **A real write guard (Claude).** A passing `task-start` drops a one-shot manifest, and a
|
|
29
|
+
`PreToolUse` hook then *deterministically rejects* any `Edit`/`Write` outside the task's
|
|
30
|
+
declared `Touch` scope — turning "please stay in scope" from a hope into enforcement.
|
|
31
|
+
- **Stateless continuity.** `keel context` reconstructs the selected task, next action, and
|
|
32
|
+
minimal read list from OpenSpec + Git every time. Survives compaction, `/clear`, and cold
|
|
33
|
+
starts. `keel/HANDOFF.md` exists only as an optional, validated override.
|
|
34
|
+
- **Expectation alignment before code.** `keel-align-expectations` aligns hidden assumptions
|
|
35
|
+
*before* specs and tasks finalize — a risk-triggered deep path asks one material decision at
|
|
36
|
+
a time and writes accepted answers back into OpenSpec.
|
|
37
|
+
- **Single-task goal execution.** Authorize the agent to autonomously drive *exactly one*
|
|
38
|
+
OpenSpec task — with a fingerprinted capsule, a hard stop boundary, and no hidden scheduler
|
|
39
|
+
picking the next task for you.
|
|
40
|
+
- **One discipline, three runtimes.** The same protocol runs on Claude Code, Codex, and
|
|
41
|
+
OpenCode; execution skills and hooks ship as a native plugin.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## How it works
|
|
46
|
+
|
|
47
|
+
```mermaid
|
|
48
|
+
flowchart LR
|
|
49
|
+
A[keel --init] --> B[keel context]
|
|
50
|
+
B --> C[proposal / design / specs / tasks]
|
|
51
|
+
C --> D[keel-align-expectations]
|
|
52
|
+
D --> E[/opsx:apply → pick one task/]
|
|
53
|
+
E --> F[task-start<br/>+ write guard]
|
|
54
|
+
F --> G[implement · test-first · verify]
|
|
55
|
+
G --> H[keel-review-checklist]
|
|
56
|
+
H --> I[task-complete]
|
|
57
|
+
I --> J[/opsx:sync · /opsx:archive/]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
OpenSpec owns the durable artifacts (proposal, design, specs, tasks, archive). Keel owns the
|
|
61
|
+
*execution discipline* around them: mode routing, the task capsule contract, deterministic
|
|
62
|
+
gates, the write guard, continuity, review, and handoff hygiene.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Requirements
|
|
67
|
+
|
|
68
|
+
- **Node.js `>=20.19.0`** (the bundled OpenSpec CLI requires it; older Node may hit
|
|
69
|
+
`EBADENGINE`).
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
Keel has two installable pieces: the **`keel` CLI** (context, gates, guard, schema,
|
|
76
|
+
install) and the **`keel` plugin** (execution skills + runtime hooks).
|
|
77
|
+
|
|
78
|
+
### 1. The `keel` CLI
|
|
79
|
+
|
|
80
|
+
Pack from GitHub and install globally. This avoids conflicts during Git-dependency
|
|
81
|
+
preparation and installs the bundled OpenSpec CLI.
|
|
82
|
+
|
|
83
|
+
**Windows (PowerShell):**
|
|
84
|
+
|
|
85
|
+
```powershell
|
|
86
|
+
$tmp = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
|
|
87
|
+
New-Item -ItemType Directory -Path $tmp | Out-Null
|
|
88
|
+
npm pack github:TanglmChris/keel --pack-destination $tmp
|
|
89
|
+
$pkg = Get-ChildItem $tmp -Filter "christang-keel-*.tgz" | Select-Object -First 1
|
|
90
|
+
npm install -g $pkg.FullName
|
|
91
|
+
Remove-Item -Recurse -Force $tmp
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Linux / macOS:**
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
tmp_dir="$(mktemp -d)"
|
|
98
|
+
npm pack github:TanglmChris/keel --pack-destination "$tmp_dir"
|
|
99
|
+
npm install -g "$tmp_dir"/christang-keel-*.tgz
|
|
100
|
+
rm -rf "$tmp_dir"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Verify, and self-update later with `keel --update`:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
keel --version
|
|
107
|
+
keel --update # re-pack + reinstall the global CLI
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 2. The `keel` plugin (skills + hooks)
|
|
111
|
+
|
|
112
|
+
Execution skills (`keel-*`) and the runtime hooks (SessionStart continuity, the PreToolUse
|
|
113
|
+
write guard) ship as a native plugin — they are **not** copied into your repo by `keel --init`:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
claude plugin install keel@<marketplace> # Claude Code
|
|
117
|
+
codex plugin add keel@<marketplace> # Codex
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Quick start
|
|
123
|
+
|
|
124
|
+
From your target project's root:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
keel --init # default target: claude
|
|
128
|
+
keel --init --target codex
|
|
129
|
+
keel --init --target opencode
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`keel --init` runs OpenSpec init/update and installs Keel's thin host surface. Then, every
|
|
133
|
+
time you start or resume work:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
keel context # or: keel context --json
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
It returns `ready` / `ambiguous` / `blocked` / `idle` with the selection, next action, and a
|
|
140
|
+
minimal read list. Check full readiness anytime:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
keel --doctor
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### What `--init` writes
|
|
147
|
+
|
|
148
|
+
`keel --init` / `--install` keeps a **thin host surface** — it does not copy skills or hooks
|
|
149
|
+
(those come from the plugin):
|
|
150
|
+
|
|
151
|
+
- `AGENTS.md` — Keel bootstrap block (all targets)
|
|
152
|
+
- `CLAUDE.md` — `@AGENTS.md` import block (Claude target)
|
|
153
|
+
- `openspec/config.yaml` — sets `schema: keel-spec-driven`
|
|
154
|
+
- `openspec/schemas/keel-spec-driven/` — the Keel-hardened OpenSpec schema
|
|
155
|
+
- plus the OpenSpec command surface (`/opsx:*`) with the Keel authoring/apply/archive overlay
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Targets
|
|
160
|
+
|
|
161
|
+
| Target | Init command | Command surface |
|
|
162
|
+
| --- | --- | --- |
|
|
163
|
+
| Claude Code | `keel --init` | `.claude/commands/opsx/*.md` + plugin hooks (SessionStart, PreToolUse guard) |
|
|
164
|
+
| Codex | `keel --init --target codex` | global `CODEX_HOME/prompts/opsx-*.md` |
|
|
165
|
+
| OpenCode | `keel --init --target opencode` | project-local `.opencode/commands/opsx-*.md` |
|
|
166
|
+
|
|
167
|
+
Pick one target per repo and use it for every subsequent `--install` / `--check` / `--doctor`
|
|
168
|
+
/ `--uninstall`. Capabilities are **probed, not assumed by target name** — unverified runtime
|
|
169
|
+
behavior is reported as `manual`, not `enforced`.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Full vs Lite mode
|
|
174
|
+
|
|
175
|
+
**Full mode** — for new features, external interface changes, cross-module work, changes over
|
|
176
|
+
3 files / 100 lines, architecture or protocol/state-machine decisions, or any hardware work
|
|
177
|
+
touching signals, reset, CDC, or security boundaries. Full mode uses OpenSpec for
|
|
178
|
+
proposal → design → specs → tasks → archive.
|
|
179
|
+
|
|
180
|
+
**Lite mode** — local fixes, small scripts, docs, or test additions only: no interface change,
|
|
181
|
+
no new dependency, no new design decision, locally provable impact. Lite does not write
|
|
182
|
+
OpenSpec state by default.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Core commands
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Continuity — recompute what to do (stateless)
|
|
190
|
+
keel context [--json] [--change <c> --task <t>]
|
|
191
|
+
|
|
192
|
+
# Deterministic gates (schemaVersion 1 → pass | fail | needs-review)
|
|
193
|
+
keel gate task-start --change <c> --task <t> --json
|
|
194
|
+
keel gate task-complete --change <c> --task <t> [--base <git-ref>] --json
|
|
195
|
+
keel gate change-close --change <c> --action sync|archive --json
|
|
196
|
+
|
|
197
|
+
# Write guard (Claude target)
|
|
198
|
+
keel guard start --change <c> --task <t> --json
|
|
199
|
+
keel guard status --json
|
|
200
|
+
keel guard clear --json
|
|
201
|
+
|
|
202
|
+
# Install / maintenance
|
|
203
|
+
keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
|
|
204
|
+
keel --update [--dry-run]
|
|
205
|
+
keel --version | --help
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Exit codes: `0` pass · `3` deterministic policy failure · `4` missing semantic review · `1`
|
|
209
|
+
input/parse failure.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
No build step. `src/skills/` is the single source of truth for portable skills; distribution
|
|
216
|
+
copies under `plugins/keel/skills/` must stay byte-identical (enforced by validation). After
|
|
217
|
+
editing, sync copies and run:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npm run validate # baseline validation
|
|
221
|
+
npm test # baseline + all scenarios in parallel (~25s)
|
|
222
|
+
|
|
223
|
+
# single scenario
|
|
224
|
+
node scripts/run_python.js scripts/validate_plugin.py --scenario core-gates
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Repository layout
|
|
228
|
+
|
|
229
|
+
```text
|
|
230
|
+
bin/keel.js # cross-platform keel CLI
|
|
231
|
+
src/core/ # stateless Keel Core (context, gates, guard, goal, helper, projection)
|
|
232
|
+
src/skills/ # canonical portable skills (+ keel-align-expectations/references)
|
|
233
|
+
plugins/keel/ # native plugin (.claude-plugin / .codex-plugin, hooks, skills)
|
|
234
|
+
assets/bootstrap/AGENTS.md # canonical managed bootstrap block
|
|
235
|
+
assets/openspec/ # OpenSpec schema assets
|
|
236
|
+
scripts/ # install_to_repo.py, validate_plugin.py, run_python.js
|
|
237
|
+
openspec/ # this repo's own OpenSpec workspace
|
|
238
|
+
keel/ # project-local Keel state (CHANGELOG, archive)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Documentation
|
|
244
|
+
|
|
245
|
+
- **[中文完整手册 (Chinese full manual)](README.zh-CN.md)** — exhaustive command and workflow reference.
|
|
246
|
+
- **[keel/CHANGELOG.md](keel/CHANGELOG.md)** — version history.
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
[MIT](LICENSE) © 2026 TanglmChris
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Keel
|
|
2
|
+
|
|
3
|
+
[English](README.md) | **中文**
|
|
4
|
+
|
|
5
|
+
> 面向 AI 编码 agent 的 OpenSpec 执行纪律 —— Claude Code、Codex、OpenCode 通用。
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
Keel 在 [OpenSpec](https://github.com/fission-ai/openspec) 之上加一层轻量、确定性的执行纪律,
|
|
12
|
+
让编码 agent 在**稳定、可校验的边界**内完成「判断 → 设计 → 执行 → review → 交接」,
|
|
13
|
+
而不是中途跑偏或在会话之间丢失上下文。
|
|
14
|
+
|
|
15
|
+
Keel **无状态**:每次会话都从你的 OpenSpec artifacts 和 Git 重新推导「现在该做什么」,
|
|
16
|
+
绝不依赖隐藏的对话记忆、transcript 或某个存下来的「当前任务」。这让 agent 的工作可恢复、
|
|
17
|
+
可审计,并且能安全地在不同 runtime 之间交接。
|
|
18
|
+
|
|
19
|
+
> 这是完整中文手册。速览请看英文 [README](README.md)。
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 为什么用 Keel
|
|
24
|
+
|
|
25
|
+
- **确定性门禁,而不是凭感觉。** `keel gate task-start | task-complete | change-close`
|
|
26
|
+
做本地、无模型的结构检查,返回 `pass` / `fail` / `needs-review` 和真实退出码。它们从不声称
|
|
27
|
+
判断你的设计是否*正确*——只判断契约与证据是否齐备。
|
|
28
|
+
- **真正的写入守卫(Claude)。** 通过的 `task-start` 会落下一次性 manifest,插件的 `PreToolUse`
|
|
29
|
+
hook 随后**确定性拒绝**任何超出任务声明 `Touch` 范围的 `Edit`/`Write`——把「请别越界」从
|
|
30
|
+
祈祷变成执法。
|
|
31
|
+
- **无状态连续性。** `keel context` 每次都从 OpenSpec + Git 重建选中任务、下一步动作和最小读取
|
|
32
|
+
列表。能扛住 compaction、`/clear` 和冷启动。`keel/HANDOFF.md` 只作为可选的、经校验的覆盖存在。
|
|
33
|
+
- **写代码前先对齐预期。** `keel-align-expectations` 在 specs/tasks 定稿*之前*对齐隐性假设——
|
|
34
|
+
风险触发的 deep path 一次只问一个材料性决策,并把接受的答案写回 OpenSpec。
|
|
35
|
+
- **单任务原生目标执行。** 授权 agent 自动执行**恰好一个** OpenSpec task——带指纹化 capsule、
|
|
36
|
+
硬停边界,没有隐藏调度器替你选下一个任务。
|
|
37
|
+
- **一套纪律,三个 runtime。** 同一协议在 Claude Code、Codex、OpenCode 上运行;执行技能与 hook
|
|
38
|
+
以原生插件分发。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 工作流程
|
|
43
|
+
|
|
44
|
+
```mermaid
|
|
45
|
+
flowchart LR
|
|
46
|
+
A[keel --init] --> B[keel context]
|
|
47
|
+
B --> C[proposal / design / specs / tasks]
|
|
48
|
+
C --> D[keel-align-expectations]
|
|
49
|
+
D --> E[/opsx:apply → 选一个 task/]
|
|
50
|
+
E --> F[task-start<br/>+ 写入守卫]
|
|
51
|
+
F --> G[实现 · 测试先行 · 验证]
|
|
52
|
+
G --> H[keel-review-checklist]
|
|
53
|
+
H --> I[task-complete]
|
|
54
|
+
I --> J[/opsx:sync · /opsx:archive/]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
OpenSpec 拥有持久 artifacts(proposal、design、specs、tasks、archive);Keel 拥有它们周围的
|
|
58
|
+
*执行纪律*:模式路由、任务 capsule 契约、确定性门禁、写入守卫、连续性、review 和交接卫生。
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 环境要求
|
|
63
|
+
|
|
64
|
+
- **Node.js `>=20.19.0`**(内置的 OpenSpec CLI 要求此版本;更低版本可能触发 `EBADENGINE`)。
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 安装
|
|
69
|
+
|
|
70
|
+
Keel 有两个可安装部分:**`keel` CLI**(context、gates、guard、schema、安装)和
|
|
71
|
+
**`keel` 插件**(执行技能 + 运行时 hook)。
|
|
72
|
+
|
|
73
|
+
### 1. `keel` CLI
|
|
74
|
+
|
|
75
|
+
从 GitHub 打包后全局安装,避免与已有全局旧包在 Git 依赖准备阶段冲突,并会一并装上 OpenSpec CLI。
|
|
76
|
+
|
|
77
|
+
**Windows(PowerShell):**
|
|
78
|
+
|
|
79
|
+
```powershell
|
|
80
|
+
$tmp = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
|
|
81
|
+
New-Item -ItemType Directory -Path $tmp | Out-Null
|
|
82
|
+
npm pack github:TanglmChris/keel --pack-destination $tmp
|
|
83
|
+
$pkg = Get-ChildItem $tmp -Filter "christang-keel-*.tgz" | Select-Object -First 1
|
|
84
|
+
npm install -g $pkg.FullName
|
|
85
|
+
Remove-Item -Recurse -Force $tmp
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Linux / macOS:**
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
tmp_dir="$(mktemp -d)"
|
|
92
|
+
npm pack github:TanglmChris/keel --pack-destination "$tmp_dir"
|
|
93
|
+
npm install -g "$tmp_dir"/christang-keel-*.tgz
|
|
94
|
+
rm -rf "$tmp_dir"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
验证版本,之后可用 `keel --update` 自更新:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
keel --version
|
|
101
|
+
keel --update # 重新打包 + 重装全局 CLI
|
|
102
|
+
keel --update --dry-run # 先看将执行的 npm 命令
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. `keel` 插件(技能 + hook)
|
|
106
|
+
|
|
107
|
+
执行技能(`keel-*`)和运行时 hook(SessionStart 连续性、PreToolUse 写入守卫)以原生插件分发,
|
|
108
|
+
**不会**被 `keel --init` 复制进你的 repo:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
claude plugin install keel@<marketplace> # Claude Code
|
|
112
|
+
codex plugin add keel@<marketplace> # Codex
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 快速开始
|
|
118
|
+
|
|
119
|
+
在目标项目根目录:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
keel --init # 默认 target:claude
|
|
123
|
+
keel --init --target codex
|
|
124
|
+
keel --init --target opencode
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`keel --init` 会运行 OpenSpec 初始化/更新并安装 Keel 的精简宿主面。之后每次开始或恢复工作:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
keel context # 或 keel context --json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
它返回 `ready` / `ambiguous` / `blocked` / `idle`,附带 selection、下一动作和最小读取列表。
|
|
134
|
+
随时检查完整就绪状态:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
keel --doctor
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### `--init` 会写入什么
|
|
141
|
+
|
|
142
|
+
`keel --init` / `--install` 只保留**精简宿主面**——不复制技能或 hook(那些来自插件):
|
|
143
|
+
|
|
144
|
+
- `AGENTS.md` —— Keel bootstrap 块(所有 target)
|
|
145
|
+
- `CLAUDE.md` —— `@AGENTS.md` import 块(Claude target)
|
|
146
|
+
- `openspec/config.yaml` —— 设置 `schema: keel-spec-driven`
|
|
147
|
+
- `openspec/schemas/keel-spec-driven/` —— Keel 强化过的 OpenSpec schema
|
|
148
|
+
- 以及 OpenSpec 生成并叠加 Keel overlay 的 `/opsx:*` 命令面
|
|
149
|
+
|
|
150
|
+
若目标 repo 里存在旧版打包的 `keel-*` skill、`keel-adapter.js` 或 `keel-gate` hook,
|
|
151
|
+
`--install` 会迁移它们:与旧打包字节一致的副本被移除并提示改由原生插件提供,用户改过的副本
|
|
152
|
+
原样保留并给出手动迁移警告。
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 目标(Targets)
|
|
157
|
+
|
|
158
|
+
| target | 初始化命令 | 命令面 |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| Claude Code | `keel --init` | `.claude/commands/opsx/*.md` + 插件 hook(SessionStart、PreToolUse 守卫) |
|
|
161
|
+
| Codex | `keel --init --target codex` | 全局 `CODEX_HOME/prompts/opsx-*.md` |
|
|
162
|
+
| OpenCode | `keel --init --target opencode` | 项目内 `.opencode/commands/opsx-*.md` |
|
|
163
|
+
|
|
164
|
+
一个 repo 通常固定一个 target,后续 `--install` / `--check` / `--doctor` / `--uninstall` 都用它。
|
|
165
|
+
能力**按可观察证据探测,不按 target 名字假定**——无法验证的运行时行为报告为 `manual`,而非 `enforced`。
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Full / Lite 模式
|
|
170
|
+
|
|
171
|
+
**Full 模式**——新功能、对外接口变更、跨模块、改动超过 3 文件 / 100 行、架构或协议/状态机决策,
|
|
172
|
+
或任何触及信号、reset、CDC、安全边界的硬件工作。Full 模式用 OpenSpec 走
|
|
173
|
+
proposal → design → specs → tasks → archive。
|
|
174
|
+
|
|
175
|
+
被接受的原生 `plan mode` 产物只是会话态:其中影响 scope、Acceptance、完成定义或执行边界的决策,
|
|
176
|
+
必须在进入实现前固化到 `proposal/design/specs/tasks`;session plan 永远不是执行权威(review
|
|
177
|
+
checklist 会检查这条通道)。
|
|
178
|
+
|
|
179
|
+
**Lite 模式**——仅限局部小改:单点修复、小脚本、文档或补测试,不改对外接口、不加依赖、不引入新
|
|
180
|
+
设计决策、影响面可局部证明。Lite 默认不写 OpenSpec 状态。
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 核心命令
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# 连续性 —— 无状态地重算「现在该做什么」
|
|
188
|
+
keel context [--json] [--change <c> --task <t>]
|
|
189
|
+
|
|
190
|
+
# 确定性门禁(schemaVersion 1 → pass | fail | needs-review)
|
|
191
|
+
keel gate task-start --change <c> --task <t> --json
|
|
192
|
+
keel gate task-complete --change <c> --task <t> [--base <git-ref>] --json
|
|
193
|
+
keel gate change-close --change <c> --action sync|archive --json
|
|
194
|
+
|
|
195
|
+
# 写入守卫(Claude target)
|
|
196
|
+
keel guard start --change <c> --task <t> --json
|
|
197
|
+
keel guard status --json
|
|
198
|
+
keel guard clear --json
|
|
199
|
+
|
|
200
|
+
# 一次性原生投影(视图,永不是权威)
|
|
201
|
+
keel project --target claude --event resume --change <c> --task <t> --json
|
|
202
|
+
keel project tasks [repo] --target claude [--change <c>] [--json]
|
|
203
|
+
keel project --target codex --event compaction --json
|
|
204
|
+
|
|
205
|
+
# 安装 / 维护
|
|
206
|
+
keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
|
|
207
|
+
keel --update [--dry-run]
|
|
208
|
+
keel --version | --help
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
退出码:`0` 通过 · `3` 确定性策略失败 · `4` 缺少语义 review · `1` 输入/解析故障。
|
|
212
|
+
|
|
213
|
+
### 写入守卫(Claude target)
|
|
214
|
+
|
|
215
|
+
Touch 是唯一写权限来源。通过的 `keel gate task-start` 默认写入一次性守卫 manifest
|
|
216
|
+
(`keel guard start` 显式激活、`keel guard clear` 停止执法、`--no-guard` 退出默认激活)。
|
|
217
|
+
守卫激活期间,插件的 `PreToolUse` hook 确定性拒绝 Touch 之外的文件编辑,并带出精确路径与恢复命令:
|
|
218
|
+
|
|
219
|
+
- manifest 记录 change/task、capsule 指纹、规范化 Touch 和权威文件哈希,存于 `guard.json`;
|
|
220
|
+
失败即关闭(fail-closed):损坏、哈希漂移、指纹不匹配或 task 已勾选时一律拒绝。
|
|
221
|
+
- 守卫只覆盖文件编辑工具;`Bash` 等间接写入仍属纪律约束,仓库外的临时/scratch 路径直接放行。
|
|
222
|
+
|
|
223
|
+
### 一次性原生投影
|
|
224
|
+
|
|
225
|
+
`keel project` 从当前 OpenSpec task 编译一次性视图(objective、Acceptance、Stop 边界、Read、Touch、
|
|
226
|
+
evidence contract),永远只是投影、不是权威,也不勾选复选框:
|
|
227
|
+
|
|
228
|
+
- `keel project tasks --target claude` 把选中 change 的 tasks.md 编译成只读清单视图,由当前 agent
|
|
229
|
+
自行决定是否手动镜像到宿主任务 UI;只读、不落盘、无同步循环。
|
|
230
|
+
- compaction 后手动重注入:`keel project --target codex --event compaction --json`。
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## 对齐与纪律
|
|
235
|
+
|
|
236
|
+
- **`keel-align-expectations`**:SPEC 前的隐性知识风险用 risk-triggered deep alignment(一次一个
|
|
237
|
+
决策、给推荐答案),而不是对所有 Full change 强制问卷;先查仓库事实再问用户,接受的结论写回
|
|
238
|
+
proposal/design/specs/tasks。v5 已退役旧的 grill 问答技能,深度对齐统一由该技能承担。
|
|
239
|
+
- **执行/review 阶段的领域引用**:web / hardware / hardware-dsl 三个 reference 各带一节
|
|
240
|
+
`Execution and review checks`;当变更 artifacts 或 Touch 扩展名显示对应领域信号时,
|
|
241
|
+
`keel-tdd-or-test-first`、`keel-debug-failure`、`keel-review-checklist` 会按需查阅——仍然只
|
|
242
|
+
加载匹配的那一个。
|
|
243
|
+
- **Dedicated Skill Policy**:新增或实质扩展专门技能时,先研究 first-party 或其他 authoritative source
|
|
244
|
+
并记录 provenance/license 影响;用真实的 `should-trigger` 与近邻 `should-not-trigger`
|
|
245
|
+
提示验证 description,并至少通过一个 real task 验证程序性行为;以 `src/skills/<name>/SKILL.md`
|
|
246
|
+
为唯一 portable 权威,target metadata 只是 additive adapter,discovery 与激活仍由 target-native
|
|
247
|
+
runtime 负责。
|
|
248
|
+
|
|
249
|
+
`/opsx:sync`、`/opsx:archive` 的完成门禁由确定性的 `keel gate change-close` 加
|
|
250
|
+
`keel-review-checklist` 承担,不再由运行时 hook 执行(该门禁在所有 target 上能力为 `manual`)。
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 开发与校验
|
|
255
|
+
|
|
256
|
+
无构建步骤。`src/skills/` 是可移植技能的唯一维护源;`plugins/keel/skills/` 等分发副本必须与源
|
|
257
|
+
字节一致(由校验强制)。修改后同步副本,然后运行:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
npm run validate # baseline 校验
|
|
261
|
+
npm test # baseline + 全部场景并行(约 25s)
|
|
262
|
+
|
|
263
|
+
# 单场景调试
|
|
264
|
+
node scripts/run_python.js scripts/validate_plugin.py --scenario core-gates
|
|
265
|
+
node scripts/run_python.js scripts/validate_plugin.py --all --jobs 4
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
`npm test` 是一条 `validate_plugin.py --all` 调用:先跑 baseline,再按内置 scenario registry
|
|
269
|
+
并行跑全部场景(`--jobs N` 控制并发,默认 CPU 数),fail-loud 而非 fail-fast。新增场景只需写
|
|
270
|
+
`validate_<name>_scenario()` 并加入 registry。
|
|
271
|
+
|
|
272
|
+
### 目录结构
|
|
273
|
+
|
|
274
|
+
```text
|
|
275
|
+
bin/keel.js # 跨平台 keel CLI
|
|
276
|
+
src/core/ # 无状态 Keel Core(context、gates、guard、goal、helper、projection)
|
|
277
|
+
src/skills/ # 可移植技能的唯一维护源(含 keel-align-expectations/references)
|
|
278
|
+
plugins/keel/ # 原生插件(.claude-plugin / .codex-plugin、hooks、skills)
|
|
279
|
+
assets/bootstrap/AGENTS.md # managed bootstrap 块的唯一权威源
|
|
280
|
+
assets/openspec/ # OpenSpec schema 资产
|
|
281
|
+
scripts/ # install_to_repo.py、validate_plugin.py、run_python.js
|
|
282
|
+
openspec/ # 本仓库自身的 OpenSpec 工作区
|
|
283
|
+
keel/ # 项目本地 Keel 状态(CHANGELOG、archive)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 文档
|
|
289
|
+
|
|
290
|
+
- **[English README](README.md)** —— 速览与安装。
|
|
291
|
+
- **[keel/CHANGELOG.md](keel/CHANGELOG.md)** —— 版本历史。
|
|
292
|
+
|
|
293
|
+
## License
|
|
294
|
+
|
|
295
|
+
[MIT](LICENSE) © 2026 TanglmChris
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<!-- keel:start version=5.1.1 -->
|
|
2
|
+
## Keel Bootstrap
|
|
3
|
+
|
|
4
|
+
- Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
|
|
5
|
+
- Obey the selected task capsule: `keel gate task-start` before implementing, record its fingerprint in the task Evidence `Contract` line, and pass `keel gate task-complete` before checking complete. Touch is the write boundary; on Claude a passing `task-start` guards it by default (`--no-guard`/`keel guard clear` opt out).
|
|
6
|
+
- One current agent owns writes; helpers return read-only report/evidence only. No commit, sync, or archive without explicit authorization.
|
|
7
|
+
- Native plugin projections (SessionStart context) are disposable views, never authority; without the plugin or hook, run the commands manually.
|
|
8
|
+
- Keel skills and hooks come from the `keel` native plugin (`codex plugin add` / `claude plugin install`); `keel --init` owns only the OpenSpec schema, overlays, and this bootstrap.
|
|
9
|
+
<!-- keel:end -->
|