@christang/keel 5.1.2 → 5.2.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/README.md CHANGED
@@ -8,77 +8,64 @@
8
8
  ![Node](https://img.shields.io/badge/node-%3E%3D20.19.0-brightgreen.svg)
9
9
  ![Targets](https://img.shields.io/badge/targets-Claude%20Code%20%C2%B7%20Codex%20%C2%B7%20OpenCode-blue.svg)
10
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
- ```
11
+ ## What Keel is for
12
+
13
+ [OpenSpec](https://github.com/fission-ai/openspec) gives a project a spec-driven
14
+ workflow: proposal, design, specs, tasks, and an archive of what changed. Claude Code
15
+ (or Codex) gives you the agent that does the work. Keel sits between them and keeps the
16
+ agent on track while it works through an OpenSpec change.
17
+
18
+ Left alone, an agent tends to drift: it edits files the task never mentioned, loses the
19
+ thread after a context reset, or checks work off without proof. Keel adds a thin, checkable
20
+ layer that prevents that, and it does so by building on tools you already have instead of
21
+ replacing them.
22
+
23
+ What Keel adds:
24
+
25
+ - **Stateless continuity.** `keel context` recomputes the current task and next step from
26
+ OpenSpec and Git every session, so work survives `/clear`, compaction, and cold starts
27
+ without depending on chat memory.
28
+ - **Deterministic gates.** `keel gate task-start | task-complete | change-close` run local
29
+ structural checks and return `pass` / `fail` / `needs-review` with real exit codes. They
30
+ check that the task contract and evidence are present; they do not judge whether the design
31
+ is correct.
32
+ - **A write guard (Claude).** After `task-start`, a `PreToolUse` hook rejects any edit
33
+ outside the files the task declared it would touch.
34
+ - **Expectation alignment.** Before specs and tasks are finalized, Keel surfaces hidden
35
+ assumptions and asks about the ones that actually change behavior.
36
+
37
+ Keel leans on native capabilities rather than reinventing them. The spec workflow is plain
38
+ OpenSpec. The execution skills, the SessionStart continuity hook, and the write-guard hook
39
+ ship as an ordinary Claude Code / Codex plugin. `keel --init` writes only a small host
40
+ surface into your repo: an `AGENTS.md` bootstrap block, the OpenSpec schema, and the
41
+ `/opsx:*` command overlay.
59
42
 
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.
43
+ ## Requirements
63
44
 
64
- ---
45
+ Node.js `>=20.19.0` (the bundled OpenSpec CLI needs it).
65
46
 
66
- ## Requirements
47
+ ## Install
67
48
 
68
- - **Node.js `>=20.19.0`** (the bundled OpenSpec CLI requires it; older Node may hit
69
- `EBADENGINE`).
49
+ Two pieces: the `keel` CLI and the `keel` plugin.
70
50
 
71
- ---
51
+ **CLI** — one command (also installs the bundled OpenSpec CLI):
72
52
 
73
- ## Install
53
+ ```bash
54
+ npm install -g @christang/keel
55
+ keel --version
56
+ ```
74
57
 
75
- Keel has two installable pieces: the **`keel` CLI** (context, gates, guard, schema,
76
- install) and the **`keel` plugin** (execution skills + runtime hooks).
58
+ **Plugin** the execution skills and runtime hooks:
59
+
60
+ ```bash
61
+ claude plugin install keel@<marketplace> # Claude Code
62
+ codex plugin add keel@<marketplace> # Codex
63
+ ```
77
64
 
78
- ### 1. The `keel` CLI
65
+ <details>
66
+ <summary>Install the latest unreleased build from GitHub</summary>
79
67
 
80
- Pack from GitHub and install globally. This avoids conflicts during Git-dependency
81
- preparation and installs the bundled OpenSpec CLI.
68
+ Pack the current `main` and install the tarball (skips the npm registry):
82
69
 
83
70
  **Windows (PowerShell):**
84
71
 
@@ -99,97 +86,84 @@ npm pack github:TanglmChris/keel --pack-destination "$tmp_dir"
99
86
  npm install -g "$tmp_dir"/christang-keel-*.tgz
100
87
  rm -rf "$tmp_dir"
101
88
  ```
89
+ </details>
102
90
 
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)
91
+ ## Use
111
92
 
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:
93
+ In your project's root, set it up once:
125
94
 
126
95
  ```bash
127
96
  keel --init # default target: claude
128
- keel --init --target codex
129
- keel --init --target opencode
97
+ keel --init --target codex # or: opencode
130
98
  ```
131
99
 
132
- `keel --init` runs OpenSpec init/update and installs Keel's thin host surface. Then, every
133
- time you start or resume work:
100
+ `keel --init` runs OpenSpec init/update and writes Keel's host surface. Then, every time you
101
+ start or resume work:
134
102
 
135
103
  ```bash
136
- keel context # or: keel context --json
104
+ keel context # what to do now, recomputed from OpenSpec + Git
105
+ keel --doctor # check everything is wired up
137
106
  ```
138
107
 
139
- It returns `ready` / `ambiguous` / `blocked` / `idle` with the selection, next action, and a
140
- minimal read list. Check full readiness anytime:
108
+ Do the spec work through OpenSpec's commands (`/opsx:propose`, `/opsx:apply`, `/opsx:sync`,
109
+ `/opsx:archive`). Keel's gates run at the task boundaries. The whole loop:
141
110
 
142
- ```bash
143
- keel --doctor
111
+ ```
112
+ keel --init → keel context → /opsx:apply (pick one task)
113
+ → task-start (+ write guard) → implement & verify
114
+ → task-complete → /opsx:sync · /opsx:archive
144
115
  ```
145
116
 
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
117
+ ### Full vs Lite
156
118
 
157
- ---
119
+ Use **Full mode** (the OpenSpec flow above) for new features, interface or protocol changes,
120
+ cross-module work, or anything over ~3 files / 100 lines. Use **Lite mode** for local fixes,
121
+ small scripts, docs, or tests with no interface change and locally provable impact; Lite does
122
+ not write OpenSpec state.
158
123
 
159
- ## Targets
124
+ ## How the agent uses these
160
125
 
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` |
126
+ You rarely type the commands below. The point of Keel is that the discipline runs itself:
127
+ `keel --init` installs it into the agent's own workflow, and the agent reaches for each
128
+ command at the right moment. Three things make that happen.
166
129
 
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`.
130
+ - **The protocol.** `keel --init` writes a bootstrap block into your repo's `AGENTS.md`
131
+ (imported by `CLAUDE.md` on Claude). It states the rules the agent follows: open every
132
+ session with `keel context`, pass the gates at task boundaries, and stay inside the task's
133
+ declared write scope. That is how the agent knows *when* to run what.
134
+ - **The skills.** The `keel-*` execution skills and the `/opsx:*` command overlays walk the
135
+ agent through align → apply → review → complete, invoking the gates at each step.
136
+ - **The hooks.** A SessionStart hook runs the continuity projection the moment a session
137
+ opens; a PreToolUse hook enforces the write guard on every edit. Neither needs prompting.
170
138
 
171
- ---
139
+ So in day-to-day use you run two commands: `keel --init` once, and `keel --doctor` when you
140
+ want to check the wiring. Everything below is the vocabulary the agent uses on your behalf.
172
141
 
173
- ## Full vs Lite mode
142
+ ## Domain lenses
174
143
 
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.
144
+ Keel's core is pure process; it ships no domain knowledge of its own. Domain guidance lives in
145
+ **lenses** you author under `keel/lenses/*.md` in your repo. Each lens is self-describing: it
146
+ opens with an `Applies when:` line stating the signals that trigger it (file extensions, artifact
147
+ shapes) and carries an `Execution and review checks` section. When a change's artifacts or Touch
148
+ match a lens, the alignment, test, debug, and review skills load only that one lens — and nothing
149
+ when none match. Keel stays domain-agnostic; the knowledge is yours to own and edit.
179
150
 
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.
151
+ Three lenses ship as opt-in templates (`web`, `hardware`, `hardware-dsl`) under `assets/lenses/`.
152
+ They are never installed automatically:
183
153
 
184
- ---
154
+ ```bash
155
+ keel lenses list # shipped templates + lenses installed in keel/lenses/
156
+ keel lenses add web # copy the web template into keel/lenses/web.md, then edit it
157
+ keel lenses add web --force # overwrite an existing lens
158
+ ```
185
159
 
186
- ## Core commands
160
+ ## Commands
187
161
 
188
162
  ```bash
189
163
  # Continuity — recompute what to do (stateless)
190
164
  keel context [--json] [--change <c> --task <t>]
191
165
 
192
- # Deterministic gates (schemaVersion 1 → pass | fail | needs-review)
166
+ # Deterministic gates → pass | fail | needs-review
193
167
  keel gate task-start --change <c> --task <t> --json
194
168
  keel gate task-complete --change <c> --task <t> [--base <git-ref>] --json
195
169
  keel gate change-close --change <c> --action sync|archive --json
@@ -199,52 +173,34 @@ keel guard start --change <c> --task <t> --json
199
173
  keel guard status --json
200
174
  keel guard clear --json
201
175
 
176
+ # Domain lenses — user-authored guidance in keel/lenses/
177
+ keel lenses list
178
+ keel lenses add <name> [--force]
179
+
202
180
  # Install / maintenance
203
- keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
181
+ keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
204
182
  keel --update [--dry-run]
205
183
  keel --version | --help
206
184
  ```
207
185
 
208
- Exit codes: `0` pass · `3` deterministic policy failure · `4` missing semantic review · `1`
209
- input/parse failure.
186
+ Exit codes: `0` pass · `3` policy failure · `4` missing semantic review · `1` input error.
210
187
 
211
- ---
188
+ Targets are probed, not assumed by name: unverified runtime behavior is reported as `manual`,
189
+ not `enforced`. Pick one target per repo and use it for every `--install` / `--check` /
190
+ `--doctor` / `--uninstall`.
212
191
 
213
192
  ## Development
214
193
 
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:
194
+ No build step. `src/skills/` is the single source of truth for portable skills; the
195
+ distribution copies under `plugins/keel/skills/` must stay byte-identical (enforced by
196
+ validation).
218
197
 
219
198
  ```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
199
+ npm test # baseline + all scenarios in parallel
200
+ node scripts/bump_version.js <patch|minor|major> # bump every version pin at once
225
201
  ```
226
202
 
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
203
  ## License
249
204
 
250
- [MIT](LICENSE) © 2026 TanglmChris
205
+ [MIT](LICENSE) © 2026 TanglmChris. See the **[中文完整手册](README.zh-CN.md)** for the full
206
+ command and workflow reference.