@astrosheep/keiyaku 2.9.5 → 2.9.7

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 (75) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/agents/harness/outcome.js +20 -4
  3. package/build/agents/harness/projection.js +8 -7
  4. package/build/agents/harness/router.js +2 -1
  5. package/build/agents/providers/claude-agent-sdk/adapter.js +13 -1
  6. package/build/agents/providers/claude-agent-sdk/registration.js +2 -1
  7. package/build/agents/providers/codex-app-server/adapter.js +11 -10
  8. package/build/agents/providers/codex-app-server/registration.js +2 -1
  9. package/build/agents/providers/opencode-sdk/adapter.js +7 -0
  10. package/build/agents/providers/opencode-sdk/registration.js +2 -1
  11. package/build/agents/providers/pi/adapter.js +10 -0
  12. package/build/agents/providers/pi/registration.js +3 -1
  13. package/build/cli/commands/contract/bind/handler.js +10 -4
  14. package/build/cli/commands/contract/bind/meta.js +6 -6
  15. package/build/cli/commands/contract/petition/handler.js +16 -3
  16. package/build/cli/commands/contract/petition/meta.js +4 -4
  17. package/build/cli/commands/metadata.js +3 -2
  18. package/build/cli/commands/projection/tell/handler.js +10 -2
  19. package/build/cli/commands/projection/tell/meta.js +3 -3
  20. package/build/cli/commands/task/catalog.js +2 -0
  21. package/build/cli/commands/task/log/handler.js +12 -0
  22. package/build/cli/commands/task/log/meta.js +8 -0
  23. package/build/cli/completion.js +9 -2
  24. package/build/cli/flags.js +11 -2
  25. package/build/cli/index.js +10 -6
  26. package/build/cli/parse-flags.js +6 -0
  27. package/build/cli/parse-metadata.js +1 -1
  28. package/build/cli/render/errors.js +18 -1
  29. package/build/cli/render/format.js +5 -2
  30. package/build/cli/render/line-width.js +33 -0
  31. package/build/cli/render/path-prefix-compaction.js +88 -0
  32. package/build/cli/render/petition.js +4 -0
  33. package/build/cli/render/projection-activity.js +93 -20
  34. package/build/cli/render/shared.js +34 -12
  35. package/build/cli/render/success-response.js +2 -0
  36. package/build/cli/render/tool-presentation.js +3 -3
  37. package/build/cli/render/wait.js +68 -48
  38. package/build/cli/subagent-guard.js +3 -0
  39. package/build/cli/types.js +1 -1
  40. package/build/core/audit/candidate.js +48 -0
  41. package/build/core/audit/coordinates.js +180 -0
  42. package/build/core/audit/evidence.js +158 -0
  43. package/build/core/audit/facade.js +42 -0
  44. package/build/core/audit/readiness.js +4 -0
  45. package/build/core/audit/report.js +38 -0
  46. package/build/core/audit.js +1 -650
  47. package/build/core/bind.js +111 -6
  48. package/build/core/draft.js +1 -1
  49. package/build/core/projection/generation/database.js +21 -2
  50. package/build/core/projection/generation/model.js +24 -3
  51. package/build/core/projection/generation/projection-generation-continuation.js +75 -10
  52. package/build/core/projection/generation/projection-generation-execution.js +4 -3
  53. package/build/core/projection/generation/projection-generation-runner.js +96 -53
  54. package/build/core/projection/generation/projection-generation-runtime.js +19 -0
  55. package/build/core/projection/generation/store.js +9 -0
  56. package/build/core/projection/generation/transitions.js +105 -3
  57. package/build/core/projection/index.js +2 -2
  58. package/build/core/projection/projection-core.js +1 -1
  59. package/build/core/projection/projection-kill.js +31 -0
  60. package/build/core/projection/projection-life-protocol.js +10 -0
  61. package/build/core/projection/projection-wait.js +53 -15
  62. package/build/core/projection/projection-wake.js +35 -3
  63. package/build/core/projection/tell/database.js +18 -0
  64. package/build/core/projection/tell/model.js +1 -0
  65. package/build/core/projection/tell/store.js +102 -55
  66. package/build/core/registry.js +82 -69
  67. package/build/core/scope.js +9 -9
  68. package/build/core/task/index.js +2 -2
  69. package/build/core/task/query.js +65 -23
  70. package/build/core/task/task-contract.js +18 -0
  71. package/build/core/task/task-git-store.js +50 -0
  72. package/build/generated/version.js +2 -2
  73. package/package.json +1 -1
  74. package/skills/keiyaku-akuma/SKILL.md +10 -0
  75. package/skills/keiyaku-workflow/SKILL.md +82 -7
@@ -105,6 +105,29 @@ export async function locateTaskBoard(cwd, runGitProbe = defaultRunGit) {
105
105
  function taskDirectory(board) {
106
106
  return path.join(board.root, ".keiyaku", "tasks");
107
107
  }
108
+ const TASK_HISTORY_FORMAT = "%aI%x00%an%x00%s";
109
+ function taskHistoryPath(taskId) {
110
+ return `.keiyaku/tasks/${taskId}.md`;
111
+ }
112
+ function parseTaskHistory(output) {
113
+ const fields = output.split("\0");
114
+ if (fields.at(-1) !== "") {
115
+ throw new FlowError("INTERNAL_STATE", "task history returned an incomplete record");
116
+ }
117
+ fields.pop();
118
+ if (fields.length % 3 !== 0) {
119
+ throw new FlowError("INTERNAL_STATE", "task history returned an incomplete record");
120
+ }
121
+ const entries = [];
122
+ for (let index = 0; index < fields.length; index += 3) {
123
+ entries.push({
124
+ timestamp: fields[index],
125
+ actor: fields[index + 1],
126
+ subject: fields[index + 2],
127
+ });
128
+ }
129
+ return entries;
130
+ }
108
131
  function assertKeiyakuDirectory(board) {
109
132
  const keiyakuDirectory = path.join(board.root, ".keiyaku");
110
133
  const stat = lstatIfPresent(keiyakuDirectory);
@@ -201,6 +224,33 @@ export async function inspectTaskLock(cwd) {
201
224
  closeQuietly(database);
202
225
  }
203
226
  }
227
+ /** Read the current hub branch's task-specific Git history without acquiring the task lock. */
228
+ export async function readTaskHistory(cwd, taskId, deps = {}) {
229
+ if (!isTaskId(taskId)) {
230
+ throw new FlowError("INVALID_TARGET", `task history requires a canonical task id: ${taskId}`);
231
+ }
232
+ const board = await locateTaskBoard(cwd, deps.runGit);
233
+ if (board.mode !== "git") {
234
+ throw new FlowError("NOT_GIT_REPO", "task history is available only in a Git repository");
235
+ }
236
+ const result = await (deps.runGit ?? defaultRunGit)(board.root, [
237
+ "log",
238
+ "-z",
239
+ "--topo-order",
240
+ "--reverse",
241
+ `--format=${TASK_HISTORY_FORMAT}`,
242
+ "--",
243
+ taskHistoryPath(taskId),
244
+ ]);
245
+ if (result.error) {
246
+ throw new FlowError("INTERNAL_STATE", `cannot read task history: ${result.error.message}`, { cause: result.error });
247
+ }
248
+ if (result.status !== 0) {
249
+ const detail = result.stderr.trim() || `exit ${String(result.status)}`;
250
+ throw new FlowError("INTERNAL_STATE", `cannot read task history: ${detail}`);
251
+ }
252
+ return parseTaskHistory(result.stdout);
253
+ }
204
254
  export function atomicReplaceTaskFile(filePath, text, _deps) {
205
255
  const directory = path.dirname(filePath);
206
256
  fs.mkdirSync(directory, { recursive: true });
@@ -1,3 +1,3 @@
1
1
  // Generated into build output by scripts/build.mjs
2
- export const VERSION = "2.9.5";
3
- export const GIT_HASH = "ade1510";
2
+ export const VERSION = "2.9.7";
3
+ export const GIT_HASH = "e0169c3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/keiyaku",
3
- "version": "2.9.5",
3
+ "version": "2.9.7",
4
4
  "description": "CLI for running iterative keiyaku workflows with Codex subagents.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,6 +30,8 @@ keiyaku call NAME --detach "do the thing" # fire and forget; note the projec
30
30
  keiyaku call NAME - < prompt.md # long prompt: literal `-` reads stdin
31
31
  keiyaku wait <proj-id> # join a running one; prints its activity
32
32
  keiyaku wait <proj-id> --timeout 5m # peek for 5m; timeout = snapshot, not death
33
+ keiyaku wait <proj-a> <proj-b> --any # return when the first member finishes
34
+ keiyaku wait <proj-a> <proj-b> --all # return when every member finishes
33
35
  keiyaku tell <proj-id> [--wait DURATION] <BODY|-> # optionally tell, then bounded-join
34
36
  keiyaku revive rsp_XXXX "continue..." # new run continuing from a record
35
37
  keiyaku kill <proj-id> # stop it; record survives, revive still works
@@ -50,10 +52,18 @@ Use `keiyaku akuma view NAME` to inspect the resolved source and configuration.
50
52
  - Omit tell's bracketed `--wait DURATION` option for silent success: exit 0,
51
53
  zero output. Supply it to perform the ordinary bounded join after acceptance.
52
54
  Silence **is** the receipt — do not re-send. Effects show up in `wait`/`status`.
55
+ - `tell --interrupt` is intentionally destructive. On an active runner, silent
56
+ success means the tell and interrupt intent are durable; provider stop and
57
+ successor wake continue asynchronously under the same projection id. Idle or
58
+ terminal state uses ordinary tell plus wake and reports its typed wake error.
53
59
  - Body is required for `call`/`tell`. Literal `-` selects stdin; unselected
54
60
  piped bytes are ignored and cannot change an argv body.
55
61
  - A `--wait`/`--timeout` expiry prints a live snapshot and exits 0 — the run continues; rejoin with `wait` anytime.
56
62
  - `wait` is repeatable: on a finished run it shows the final transcript again.
63
+ - Supervise multiple projections with one plural `wait`. Choose `--any` to
64
+ handle the first terminal member and refill its lane; choose `--all` only for
65
+ final batch convergence. Keep foreground waits blocking; if bounded, use one
66
+ operationally meaningful timeout instead of repeated short-timeout polling.
57
67
 
58
68
  ## Occasional flags
59
69
 
@@ -22,6 +22,32 @@ Lifecycle:
22
22
  bound → active → petitioned → claimed | forfeited
23
23
  ```
24
24
 
25
+ ## Before Bind
26
+
27
+ `bind` begins implementation from a settled executable contract.
28
+
29
+ Before binding, complete the fact and decision work needed to state the delivery:
30
+
31
+ - reproduce or otherwise establish the motivating fact;
32
+ - read the registered authority and locate the current owning modules;
33
+ - settle inputs, outputs, state consequences, failure behavior, invariants, and
34
+ forbidden expansion;
35
+ - declare one coherent ownership region and account for known write overlap and
36
+ delivery dependencies;
37
+ - write checks that prove the critical success path, the highest-risk rejection,
38
+ and the relevant durability, concurrency, or recovery boundary.
39
+
40
+ Use tasks, fact scans, and bare read-only exploration while gathering evidence
41
+ and settling decisions. Task `ready` reports that its dependencies are
42
+ satisfied; the coordinator promotes it after establishing semantic contract
43
+ readiness. Bind when Objective, Scope, and Checks describe one complete
44
+ implementation journey and contain every product or architecture decision the
45
+ worker needs.
46
+
47
+ After bind, the worker implements and verifies that contract. `amend` records
48
+ new evidence or a change of intent that genuinely emerges during implementation
49
+ or review, then implementation continues from the updated contract.
50
+
25
51
  ## The default flow
26
52
 
27
53
  ```bash
@@ -51,8 +77,9 @@ EOF
51
77
  # The oath is required (OATH_MISSING otherwise) and checked for presence, not content.
52
78
  ```
53
79
 
54
- A task is optional planning, not a prerequisite. Bind directly for new work;
55
- use `--task` only when promoting existing tracked planning into this contract.
80
+ A task is optional planning, not a prerequisite. Bind settled new work directly;
81
+ use `--task` when promoting existing tracked planning after the same readiness
82
+ judgment.
56
83
 
57
84
  That's the whole small case: bind → worker dirty-tree handoff → host review/commit → petition.
58
85
 
@@ -62,11 +89,57 @@ contracts/worktrees; it does not replace `needs` or contract `--after` ordering.
62
89
 
63
90
  `audit` is read-only and never invokes an Akuma or settles the contract. Exit 0
64
91
  means it constructed the report, not that the candidate is acceptable. Use
65
- `--diff-budget BYTES` for bounded output and `--json` for complete typed facts.
92
+ `--diff-budget BYTES` when bounded diff evidence is useful.
66
93
 
67
94
  Commissioned workers never write Git metadata. The host alone reviews and
68
95
  commits accepted bytes before `arc`, `renew`, or `petition`.
69
96
 
97
+ Dispatch rule: every time a dispatcher sends a worker, whether through
98
+ `keiyaku call` or any other agent tool, the prompt must explicitly tell that
99
+ worker to read the worktree-root `.keiyaku/KEIYAKU.md` first and follow its
100
+ objective, scope, and checks. The file is the contract-body carrier; do not
101
+ copy its rendered body into a dispatch prompt.
102
+
103
+ ## Review findings
104
+
105
+ Review findings are evidence for diagnosis, not a queue of local patches. Before
106
+ changing code, classify each finding as a contract hole, missing invariant or
107
+ owner, execution slip, test gap, or provider/capability failure. A second
108
+ finding in the same transition, a race that crosses module owners, or a finding
109
+ that contradicts the contract is a root-cause signal: stop symptom patching,
110
+ record the governing invariant and ownership correction with `amend`, and
111
+ refactor the boundary before sending another tell or accepting another diff.
112
+
113
+ A default review dispatch is:
114
+
115
+ > First read the worktree-root `.keiyaku/KEIYAKU.md`. Review the candidate end
116
+ > to end against the contract and repository law. On every review round, treat
117
+ > the current candidate as a new complete implementation: reassess its overall
118
+ > coherence and regression risks rather than checking only whether prior
119
+ > findings were patched. Report material findings first. For each problem,
120
+ > explain the underlying cause and recommend a root-cause correction direction,
121
+ > not a patch-sized edit. If the evidence is insufficient, state what remains
122
+ > unknown. Do not modify files or Git metadata.
123
+
124
+ Add candidate-specific evidence only when it helps the reviewer judge coverage;
125
+ do not copy the contract body or seed an expected defect. Reviewer suggestions
126
+ inform the coordinator's judgment but do not amend the contract. The
127
+ coordinator owns the final diagnosis; a worker may implement a settled
128
+ correction but may not invent a new state machine or compatibility rule.
129
+
130
+ Do not claim a contract while related findings remain unresolved merely because
131
+ each individual test or patch passes. Re-run the focused interleaving or
132
+ boundary evidence and an independent review against the corrected ownership
133
+ model. Repeated tells that only add guards to the same disputed path are not
134
+ progress; if the contract cannot express the required invariant, amend or
135
+ forfeit and bind a coherent replacement.
136
+
137
+ After a worker fixes review findings, prefer telling the same review projection
138
+ to re-check those findings and the corrected candidate. Start a fresh reviewer
139
+ only when the earlier projection is unavailable or incompatible, its context is
140
+ no longer trustworthy, or a genuinely fresh independent perspective is useful.
141
+ This is an efficiency preference, not an acceptance gate.
142
+
70
143
  ## Mid-flight commands (use when needed, skip otherwise)
71
144
 
72
145
  ```bash
@@ -88,20 +161,22 @@ keiyaku log # this contract's history
88
161
  Clarify the owned documentation surface.
89
162
 
90
163
  ## Scope Append
91
- ```
164
+ ~~~
92
165
  docs/**
93
166
  !docs/generated/**
94
- ```
167
+ ~~~
95
168
  ````
96
169
 
97
170
  `Scope Append` appends ordered raw gitignore-subset lines in one column-zero
98
- backtick fence; `Scope Add` and Markdown bullets are rejected. A later
171
+ tilde fence; direct input also accepts a matching backtick fence. `Scope Add`
172
+ and Markdown bullets are rejected. A later
99
173
  `!pattern` can narrow earlier scope. Use `--append-scope PATTERN` when a
100
174
  lifecycle operation discovers one durable term.
101
175
 
102
176
  Gotchas:
103
177
  - `-C DIR` selects the effective working directory; repository discovery starts there.
104
- - Base drift blocks petition — if main moved, `renew` first; petition tells you.
178
+ - Base drift blocks ordinary petition. `petition --renew` runs the same renew
179
+ first and settles only after that renew succeeds; it never auto-opens an arc.
105
180
  - After an explicit `arc` seals, new loose commits need another `arc` before `renew`/`petition` accept them.
106
181
  - Not in the worktree? Address a contract with `--contract ADDR` (place, slug, or full id) or the `keiyaku @addr <verb>` prefix.
107
182