@astrosheep/keiyaku 0.1.79 → 0.1.81

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.
Files changed (88) hide show
  1. package/README.md +87 -49
  2. package/build/.tsbuildinfo +1 -1
  3. package/build/agents/claude-agent-sdk-exec.js +248 -0
  4. package/build/agents/codex-cli-exec.js +33 -29
  5. package/build/agents/codex-sdk-exec.js +41 -33
  6. package/build/agents/gemini-cli-core-exec.js +499 -0
  7. package/build/agents/index.js +204 -50
  8. package/build/agents/opencode-exec.js +271 -110
  9. package/build/agents/opencode-sdk.js +238 -0
  10. package/build/agents/process-runner.js +27 -27
  11. package/build/agents/round-runner.js +14 -53
  12. package/build/agents/selector.js +15 -22
  13. package/build/agents/types.js +11 -4
  14. package/build/cli/index.js +926 -0
  15. package/build/cli/subagent-guard.js +19 -0
  16. package/build/config/architect-hints.js +371 -0
  17. package/build/config/config.js +2 -2
  18. package/build/config/env-keys.js +7 -15
  19. package/build/config/path-utils.js +11 -0
  20. package/build/config/render-template.js +0 -22
  21. package/build/config/schema.js +11 -35
  22. package/build/config/settings.js +166 -54
  23. package/build/flow-error.js +9 -61
  24. package/build/generated/version.js +1 -1
  25. package/build/git/commits.js +77 -0
  26. package/build/git/diff/filter.js +1 -1
  27. package/build/git/diff/parsers.js +1 -1
  28. package/build/git/diff/pathspec.js +4 -0
  29. package/build/git/diff/preview.js +2 -2
  30. package/build/git/diff/read.js +4 -4
  31. package/build/index.js +26 -71
  32. package/build/keiyaku.js +28 -20
  33. package/build/protocol/{summon-draft.js → bind-draft.js} +21 -26
  34. package/build/protocol/file-guards.js +3 -5
  35. package/build/protocol/ledger.js +374 -0
  36. package/build/protocol/markdown/index.js +1 -1
  37. package/build/protocol/response-history.js +67 -34
  38. package/build/protocol/status-previews.js +1 -71
  39. package/build/{mcp → responses}/response-style.js +2 -2
  40. package/build/{mcp → responses}/responses.js +91 -65
  41. package/build/{mcp → responses}/tool-errors.js +18 -8
  42. package/build/tools/amend/index.js +1 -1
  43. package/build/tools/amend/run.js +3 -8
  44. package/build/tools/bind/index.js +44 -0
  45. package/build/tools/bind/run.js +237 -0
  46. package/build/tools/create-handler.js +2 -2
  47. package/build/tools/help.js +4 -39
  48. package/build/tools/petition/claim-gates.js +16 -90
  49. package/build/tools/petition/claim.js +54 -41
  50. package/build/tools/petition/forfeit.js +11 -20
  51. package/build/tools/petition/index.js +1 -9
  52. package/build/tools/petition/run.js +1 -71
  53. package/build/tools/round/guidance.js +2 -22
  54. package/build/tools/round/prompt.js +58 -119
  55. package/build/tools/round/report.js +0 -6
  56. package/build/tools/round/worktree.js +2 -3
  57. package/build/tools/round-close/index.js +19 -0
  58. package/build/tools/round-close/run.js +98 -0
  59. package/build/tools/round-open/index.js +20 -0
  60. package/build/tools/round-open/run.js +77 -0
  61. package/build/tools/schema.js +28 -20
  62. package/build/tools/status/index.js +3 -8
  63. package/build/tools/status/read.js +23 -130
  64. package/build/tools/summon/index.js +20 -37
  65. package/build/tools/summon/persist.js +72 -0
  66. package/build/tools/summon/run.js +52 -217
  67. package/package.json +5 -3
  68. package/build/agents/failure-hints.js +0 -34
  69. package/build/agents/gemini-cli-exec.js +0 -57
  70. package/build/config/incremental-diff-mode.js +0 -4
  71. package/build/config/term-presets/constants.js +0 -13
  72. package/build/config/term-presets/default-preset.js +0 -182
  73. package/build/config/term-presets/hints.js +0 -15
  74. package/build/config/term-presets/resolver.js +0 -36
  75. package/build/git/diff/constants.js +0 -7
  76. package/build/mcp/server.js +0 -95
  77. package/build/mcp/startup-guard.js +0 -5
  78. package/build/protocol/trace.js +0 -374
  79. package/build/tools/ask/index.js +0 -26
  80. package/build/tools/ask/persist.js +0 -127
  81. package/build/tools/ask/run.js +0 -95
  82. package/build/tools/drive/index.js +0 -22
  83. package/build/tools/drive/run.js +0 -219
  84. package/build/tools/round/incremental-diff.js +0 -32
  85. package/build/tools/round/plan.js +0 -49
  86. package/build/tools/round/run.js +0 -153
  87. /package/build/{config/term-presets/types.js → protocol/bind-input.js} +0 -0
  88. /package/build/protocol/{summon-input.js → review.js} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Keiyaku
2
2
 
3
- MCP server. AI code changes run on an isolated branch. Tasks are written into the repo. Nothing closes without your sign-off.
3
+ CLI for contract-style coding work in git repositories. AI code changes run on an isolated branch. Tasks are written into the repo. Nothing closes without your sign-off.
4
4
 
5
5
  ```bash
6
6
  npm install -g @astrosheep/keiyaku
@@ -13,62 +13,49 @@ npm install -g @astrosheep/keiyaku
13
13
  Missing any of these? Don't come crying.
14
14
 
15
15
  - **Git repo.** Clean worktree. Dirty = refused.
16
- - **MCP client.** Claude Desktop, Claude Code, anything stdio.
17
- - **Subagent CLI.** [`claude`](https://docs.anthropic.com/en/docs/claude-code), [`gemini`](https://github.com/google-gemini/gemini-cli), or [`codex`](https://github.com/openai/codex). Installed. Logged in. Keiyaku doesn't run code itself — it delegates everything to a subprocess. No CLI = nothing happens.
18
-
19
- **Codex users, one extra step.** Codex clears env before spawning MCP servers. Add this to your `~/.codex/config.toml` or keiyaku won't know when it's running as a subagent:
20
-
21
- ```toml
22
- [mcp_servers.keiyaku]
23
- # ... rest of your config ...
24
- env_vars = ["KEIYAKU_DISABLE_SUBAGENT_SPAWN"]
25
- ```
16
+ - **Supported providers.** `codex-cli`, `codex-sdk`, `claude-agent-sdk`, `gemini-cli-core`, `opencode-sdk`. CLI-backed providers need their matching executable (`codex`, `gemini`, `opencode`). `claude-agent-sdk` uses the installed Agent SDK package and can optionally point at a `claude` executable override via `executable`.
26
17
 
27
18
  ---
28
19
 
29
20
  ## Setup
30
21
 
31
- Claude Desktop (`~/Library/Application Support/Claude/claude_desktop_config.json`):
32
-
33
- ```json
34
- {
35
- "mcpServers": {
36
- "keiyaku": {
37
- "command": "npx",
38
- "args": ["-y", "@astrosheep/keiyaku"]
39
- }
40
- }
41
- }
42
- ```
43
-
44
- Restart client. Open a git repo. Run `status`. Done.
22
+ Open a git repo. Run `keiyaku guide` and `keiyaku zako list`. Then use `keiyaku <command> --help` for exact command formats.
45
23
 
46
24
  ---
47
25
 
48
26
  ## Flow
49
27
 
50
28
  ```
51
- ask (anytime) | summon → [drive | ask]* → petition
29
+ bind round open → [summon | amend | delivery work] → delivery commits → round close → [round open | amend | petition]
52
30
  ```
53
31
 
54
32
  ---
55
33
 
56
34
  ## Tools
57
35
 
58
- **`ask`** — For questions. No branch, no contract. Use it freely.
36
+ **`summon`** — Calls in an agent to do scoped work. If a round is open, the round scope is injected. Add `--incognito` for a one-off run with no response history.
59
37
 
60
38
  ```
61
- Where's the retry logic? Run the unit tests for that file.
39
+ Implement the retry tests. Report touched files and verification.
40
+ ```
41
+
42
+ ---
43
+
44
+ **`zako list` / `zako show <name>`** — Inspect available helpers before choosing `summon --agent NAME`.
45
+
46
+ ```bash
47
+ keiyaku zako list
48
+ keiyaku zako show codex
62
49
  ```
63
50
 
64
51
  ---
65
52
 
66
- **`summon`** — Opens a branch, writes the contract. Repo must be clean.
53
+ **`bind`** — Opens a branch and writes `KEIYAKU.md`. Repo must be clean.
67
54
 
68
55
  Vague criteria = vague results. Write "make it better" and don't blame anyone but yourself.
69
56
 
70
57
  ```
71
- summon:
58
+ bind:
72
59
  title: "Retry logic for HTTP client"
73
60
  goal: "5xx failures retry up to 3 times with exponential backoff"
74
61
  criteria:
@@ -79,10 +66,28 @@ summon:
79
66
 
80
67
  ---
81
68
 
82
- **`drive`** — Next round. Review the diff, say what's wrong, run another round.
69
+ **`round open`** — Frame a delivery round before work starts.
83
70
 
84
71
  ```
85
- Backoff is 1.5x, should be 2x. Fix it, update the tests too.
72
+ # Retry backoff
73
+
74
+ ## Objective
75
+ Implement retries with exponential backoff.
76
+
77
+ ## Brief
78
+ Keep the public API unchanged. Commit the delivery work before closing the round.
79
+ ```
80
+
81
+ ---
82
+
83
+ **`round close`** — Record a completed round from git commits.
84
+
85
+ ```
86
+ ## Commits
87
+ - abc1234
88
+
89
+ ## Report
90
+ Retry tests pass and backoff is now 2x.
86
91
  ```
87
92
 
88
93
  ---
@@ -91,13 +96,13 @@ Backoff is 1.5x, should be 2x. Fix it, update the tests too.
91
96
 
92
97
  `CLAIM` = verified, all criteria pass. `FORFEIT` = abandon, throw everything away.
93
98
 
94
- Scores required (0–10). Oath required. The gates will actually reject you. Don't show up without checking.
99
+ Oath required unless you explicitly bypass gates. Configured verification and reviewer gates will reject weak claims.
95
100
 
96
101
  ---
97
102
 
98
103
  **`status`** — Current state and what's blocking you.
99
104
 
100
- **`help`** — Full reference.
105
+ **`keiyaku guide`** — Full reference.
101
106
 
102
107
  ---
103
108
 
@@ -106,9 +111,8 @@ Scores required (0–10). Oath required. The gates will actually reject you. Don
106
111
  | File | |
107
112
  |------|--|
108
113
  | `KEIYAKU.md` | Active contract |
109
- | `KEIYAKU_TRACE.md` | Per-round log |
110
- | `KEIYAKU.draft.md` | Recovery draft if summon fails |
111
- | `.keiyaku/response/*.md` | Per-round output |
114
+ | `.keiyaku/draft/*.md` | Recovery input if bind/stdin execution fails |
115
+ | `.keiyaku/response/*.md` | Tool response history |
112
116
 
113
117
  Don't want these tracked:
114
118
 
@@ -125,24 +129,58 @@ Don't want these tracked:
125
129
  keiyaku dump-env
126
130
  ```
127
131
 
132
+ Per-agent runtime settings live in `.keiyaku/settings.json` and use `provider` / `executable`:
133
+
134
+ ```json
135
+ {
136
+ "agents": {
137
+ "claude": {
138
+ "provider": "claude-agent-sdk",
139
+ "model": "claude-sonnet-4-5",
140
+ "executable": "claude",
141
+ "description": "Claude-side Zako for review and integration.",
142
+ "systemPromptFile": ".keiyaku/claude-system.md"
143
+ },
144
+ "codex": {
145
+ "provider": "codex-sdk",
146
+ "executable": "codex",
147
+ "description": "Default Codex-side Zako.",
148
+ "config": {
149
+ "developer_instructions": "Adapter-level instructions appended to Codex sessions."
150
+ }
151
+ },
152
+ "gemini": {
153
+ "provider": "gemini-cli-core",
154
+ "model": "gemini-2.5-pro",
155
+ "description": "Gemini-side Zako for preview and synthesis.",
156
+ "systemPromptFile": ".keiyaku/gemini-system.md"
157
+ }
158
+ },
159
+ "default": "codex",
160
+ "reviewer": "codex"
161
+ }
162
+ ```
163
+
164
+ Claude defaults:
165
+ - `settingSources: ["project"]`
166
+ - `permissionMode: "bypassPermissions"`
167
+ - `resumePath` resumes via persisted provider session metadata
168
+
169
+ Codex SDK notes:
170
+ - `config` is passed through to Codex. Use `developer_instructions` for adapter-level instructions.
171
+ - `model_instructions_file` is also accepted through `config`, but it replaces Codex built-in instructions.
172
+
173
+ Gemini notes:
174
+ - `systemPromptFile` is passed to Gemini CLI core as `GEMINI_SYSTEM_MD`, which replaces Gemini's base system prompt.
175
+
176
+ `keiyaku zako list` and `keiyaku zako ls` show each profile's description when present.
177
+
128
178
  | Variable | Default | |
129
179
  |----------|---------|--|
130
- | `KEIYAKU_MCP_TRANSPORT` | `stdio` | `stdio` or `streamable-http` |
131
- | `KEIYAKU_MCP_HTTP_PORT` | `3000` | HTTP port |
132
180
  | `KEIYAKU_SUBAGENT_EXEC_TIMEOUT_MS` | — | Execution timeout |
133
181
  | `KEIYAKU_SUBAGENT_EXEC_IDLE_TIMEOUT_MS` | — | Idle timeout |
134
- | `KEIYAKU_INCREMENTAL_DIFF_MODE` | `targeted` | `targeted` \| `stat` \| `unified` |
135
182
  | `KEIYAKU_FAKE_SUBAGENT` | `0` | `1` = test stub |
136
183
 
137
- HTTP transport:
138
-
139
- ```bash
140
- KEIYAKU_MCP_TRANSPORT=streamable-http \
141
- KEIYAKU_MCP_HTTP_HOST=127.0.0.1 \
142
- KEIYAKU_MCP_HTTP_PORT=3000 \
143
- npx -y @astrosheep/keiyaku
144
- ```
145
-
146
184
  ---
147
185
 
148
186
  MIT