@astrosheep/keiyaku 0.1.65 β 0.1.68
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 +109 -64
- package/build/.tsbuildinfo +1 -1
- package/build/agents/codex-exec.js +16 -8
- package/build/agents/selector.js +6 -4
- package/build/common/errors.js +4 -4
- package/build/config/env-keys.js +3 -3
- package/build/config/term-presets/default-preset.js +22 -20
- package/build/generated/version.js +1 -1
- package/build/handlers/start.js +6 -4
- package/build/types/tooling.js +2 -1
- package/build/utils/response-history.js +7 -1
- package/build/workflow/ask-execution.js +1 -0
- package/build/workflow/ask.js +5 -3
- package/build/workflow/keiyaku-draft.js +1 -1
- package/build/workflow/response-builders.js +11 -8
- package/build/workflow/start.js +60 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,105 +1,150 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Keiyaku
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Keiyaku is an MCP server that runs a contract-style workflow for AI-assisted coding in Git repos: isolate work on a dedicated `keiyaku/*` branch, iterate in rounds with review, then submit a final petition for judgment.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This README is for users of the tool (MCP clients). It intentionally does not document repo maintenance workflows.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Philosophy
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **Traceable Logic**: Every iteration is documented in `KEIYAKU_TRACE.md`. You can literally see the AI's "learning curve" (or mistakes).
|
|
11
|
-
- **Strict Guardrails**: No "Done" until you say so. No merging until the criteria are met.
|
|
12
|
-
- **Human-in-the-Loop**: Designed for humans who actually want to review the code before it hits production.
|
|
9
|
+
Keiyaku is opinionated on purpose:
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
- Isolation over βchat editsβ: work happens on a dedicated `keiyaku/*` branch so your base branch stays clean.
|
|
12
|
+
- Explicit contracts: the goal/rules/criteria live in `KEIYAKU.md` so βwhat are we doing?β is always answered by a file, not a scrolling chat.
|
|
13
|
+
- Review-driven iteration: you drive the rounds; the tool optimizes for diffs and verification, not vibes.
|
|
14
|
+
- Verdict-gated finish: the contract ends via `petition` (CLAIM/FORFEIT) so βdoneβ is an explicit decision with gates (oath + scores).
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
## When To Use Which Tool
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
- Use `ask` for investigation: summarize, locate relevant code, run tests/scripts, debug a failure. No branch required.
|
|
19
|
+
- Use `summon`/`drive` for non-trivial code changes that should be isolated and iterated.
|
|
20
|
+
- Use `petition` only when you believe the criteria are met (CLAIM) or when you want to discard the contract (FORFEIT).
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## How It Works
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Keiyaku formalizes a task into:
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
| **`drive`** | Iterate | Provide feedback based on the previous round's output. |
|
|
30
|
-
| **`ask`** | Reason | Pure read-only analysis session. No code changes, just brain power. |
|
|
31
|
-
| **`present`** | Finish | Finalize the task. Requires a quality check (the "Oath"). |
|
|
32
|
-
| **`help`** | Help | Show the current rules + preset usage guide. |
|
|
26
|
+
- A signed contract (`KEIYAKU.md`) that defines goal, rules, and verification criteria
|
|
27
|
+
- A round trace (`KEIYAKU_TRACE.md`) that records iterations
|
|
28
|
+
- A final petition (`petition`) that requests a CLAIM or FORFEIT verdict
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
Default workflow:
|
|
35
31
|
|
|
36
|
-
|
|
32
|
+
`ask` (anytime) | `summon` -> [`drive` | `ask`]* -> `petition`
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
Typical loop:
|
|
39
35
|
|
|
40
|
-
|
|
36
|
+
1. `summon`: provide `title`, `goal`, `criteria` (plus any rules/context). Repo must be clean.
|
|
37
|
+
2. Review the round output and repo diff.
|
|
38
|
+
3. `drive`: issue the next directive (fixes, refinements, tests, cleanup).
|
|
39
|
+
4. `ask`: optionally verify independently (tests, static checks, targeted inspection).
|
|
40
|
+
5. `petition`:
|
|
41
|
+
- `CLAIM` to request acceptance (requires oath + 0-10 scores).
|
|
42
|
+
- `FORFEIT` to abandon and discard the contract.
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
## Tools (Default Preset)
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
- **`pocket`**: `choose_you` β `command` β `capture` (Gotta code 'em all)
|
|
46
|
-
- **`mischief`**: `oi` β `neh` β `yoshi` (For those who like a little attitude)
|
|
46
|
+
Keiyaku registers the following MCP tools:
|
|
47
47
|
|
|
48
|
-
`
|
|
48
|
+
- `summon`: start a contract, create/enter a `keiyaku/*` branch, run round 1
|
|
49
|
+
- `drive`: run the next round (mutates the repo)
|
|
50
|
+
- `ask`: stateless delegation (analysis, running tests/scripts, debugging). No keiyaku branch required.
|
|
51
|
+
- `petition`: submit `CLAIM` or `FORFEIT` to close the contract (verdict-gated)
|
|
52
|
+
- `status`: read-only contract/protocol status and readiness hints
|
|
53
|
+
- `help`: usage guide and protocol notes
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
Term presets: currently only `default` is supported (`KEIYAKU_TERM_PRESET=default`).
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
- **Doesn't change**: core behavior (branching, protocol files, verdict rules).
|
|
57
|
+
## Install / Run
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
Global install:
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- `mischief`: `imp`, `minion`, `mastermind`
|
|
62
|
-
|
|
63
|
-
### Prevent nested subagents
|
|
64
|
-
|
|
65
|
-
Set `KEIYAKU_DISABLE_SUBAGENT_SPAWN=1` to block any subagent spawn attempts in the current process.
|
|
66
|
-
Keiyaku automatically injects this env var into spawned Codex/Gemini runs so they cannot recursively trigger another Keiyaku subagent run.
|
|
61
|
+
```bash
|
|
62
|
+
npm install -g @astrosheep/keiyaku
|
|
63
|
+
keiyaku --version
|
|
64
|
+
```
|
|
67
65
|
|
|
68
|
-
|
|
66
|
+
Via npx:
|
|
69
67
|
|
|
70
|
-
### 1. Install
|
|
71
68
|
```bash
|
|
72
|
-
|
|
69
|
+
npx -y @astrosheep/keiyaku --version
|
|
73
70
|
```
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
## MCP Setup
|
|
73
|
+
|
|
74
|
+
### Claude Desktop (stdio)
|
|
77
75
|
|
|
78
76
|
```json
|
|
79
77
|
{
|
|
80
78
|
"mcpServers": {
|
|
81
79
|
"keiyaku": {
|
|
82
80
|
"command": "npx",
|
|
83
|
-
"args": ["-y", "keiyaku"]
|
|
84
|
-
"env": {
|
|
85
|
-
"KEIYAKU_TERM_PRESET": "mischief"
|
|
86
|
-
}
|
|
81
|
+
"args": ["-y", "@astrosheep/keiyaku"]
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
```
|
|
91
86
|
|
|
92
|
-
|
|
87
|
+
### Streamable HTTP
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
KEIYAKU_MCP_TRANSPORT=streamable-http \
|
|
91
|
+
KEIYAKU_MCP_HTTP_HOST=127.0.0.1 \
|
|
92
|
+
KEIYAKU_MCP_HTTP_PORT=3000 \
|
|
93
|
+
npx -y @astrosheep/keiyaku
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Endpoint: `http://127.0.0.1:3000/mcp`
|
|
97
|
+
|
|
98
|
+
## What Gets Written To Your Repo
|
|
99
|
+
|
|
100
|
+
Keiyaku writes protocol artifacts into the target repository:
|
|
101
|
+
|
|
102
|
+
- `KEIYAKU.md`: the active contract (goal/rules/criteria)
|
|
103
|
+
- `KEIYAKU_TRACE.md`: round-by-round trace
|
|
104
|
+
- `KEIYAKU.draft.md`: optional recovery draft when start fails
|
|
105
|
+
- `.keiyaku/response/*.md`: persisted responses for `summon`, `drive`, and `ask`
|
|
106
|
+
- `.keiyaku/draft/*`: internal drafts (used for recovery and workflow safety)
|
|
107
|
+
|
|
108
|
+
If you do not want these tracked, add:
|
|
93
109
|
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
- `KEIYAKU_TRACE.md`: The history of every round, feedback, and result.
|
|
110
|
+
- `.keiyaku/draft/`
|
|
111
|
+
- `.keiyaku/response/`
|
|
97
112
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
to `.gitignore`.
|
|
114
|
+
|
|
115
|
+
## Key Environment Variables
|
|
116
|
+
|
|
117
|
+
Server / transport:
|
|
118
|
+
|
|
119
|
+
- `KEIYAKU_MCP_TRANSPORT`: `stdio` (default) or `streamable-http`
|
|
120
|
+
- `KEIYAKU_MCP_HTTP_HOST`: default `127.0.0.1`
|
|
121
|
+
- `KEIYAKU_MCP_HTTP_PORT`: default `3000`
|
|
122
|
+
|
|
123
|
+
Preset / naming:
|
|
124
|
+
|
|
125
|
+
- `KEIYAKU_TERM_PRESET`: only `default` is supported
|
|
126
|
+
- `KEIYAKU_SUBAGENT_NAME_OVERRIDE`: overrides the default subagent display name
|
|
127
|
+
|
|
128
|
+
Subagent execution:
|
|
129
|
+
|
|
130
|
+
- `KEIYAKU_DISABLE_SUBAGENT_SPAWN`: when `1`, blocks Keiyaku MCP server startup
|
|
131
|
+
- `KEIYAKU_FAKE_SUBAGENT`: `0` | `1` | `abort-wait` (stub subagent execution)
|
|
132
|
+
- `KEIYAKU_AGENT_[A|B|C]_PROVIDER`: `codex` | `gemini` | `opencode`
|
|
133
|
+
- `KEIYAKU_AGENT_[A|B|C]_MODEL`: optional model override for that profile
|
|
134
|
+
- `KEIYAKU_AGENT_[A|B|C]_REASONING_EFFORT`: `low` | `medium` | `high` (codex only)
|
|
135
|
+
- `KEIYAKU_AGENT_[A|B|C]_COMMAND`: program name override (single token)
|
|
136
|
+
|
|
137
|
+
Workflow:
|
|
138
|
+
|
|
139
|
+
- `KEIYAKU_INCREMENTAL_DIFF_MODE`: `targeted` (default) | `stat` | `unified`
|
|
140
|
+
- `KEIYAKU_CLOSE_OATH`: overrides the required petition oath template
|
|
141
|
+
|
|
142
|
+
Print the full env template with defaults:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
keiyaku dump-env
|
|
146
|
+
```
|
|
101
147
|
|
|
102
|
-
|
|
148
|
+
## License
|
|
103
149
|
|
|
104
|
-
|
|
105
|
-
"Keep your branches clean and your minions in line." β Mischief preset
|
|
150
|
+
MIT
|