@astrosheep/keiyaku 4.6.28 → 4.6.30

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 (73) hide show
  1. package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
  2. package/build/plugins/claude/skills/keiyaku/SKILL.md +24 -24
  3. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +43 -165
  4. package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +58 -228
  5. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +45 -56
  6. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +43 -184
  7. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +39 -88
  8. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +54 -114
  9. package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
  10. package/build/plugins/codex/skills/keiyaku/SKILL.md +24 -24
  11. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +43 -165
  12. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +58 -228
  13. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +45 -56
  14. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +43 -184
  15. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +39 -88
  16. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +54 -114
  17. package/build/plugins/opencode/package.json +1 -1
  18. package/build/plugins/opencode/skills/keiyaku/SKILL.md +24 -24
  19. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +43 -165
  20. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +58 -228
  21. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +45 -56
  22. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +43 -184
  23. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +39 -88
  24. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +54 -114
  25. package/build/plugins/pi/README.md +10 -0
  26. package/build/plugins/pi/akuma-tools.ts +2 -2
  27. package/build/plugins/pi/keiyaku.ts +73 -1
  28. package/build/skills/keiyaku/SKILL.md +24 -24
  29. package/build/skills/keiyaku-akuma/SKILL.md +43 -165
  30. package/build/skills/keiyaku-akuma/references/automation.md +58 -228
  31. package/build/skills/keiyaku-babysit/SKILL.md +45 -56
  32. package/build/skills/keiyaku-bind/SKILL.md +43 -184
  33. package/build/skills/keiyaku-debt/SKILL.md +39 -88
  34. package/build/skills/keiyaku-workflow/SKILL.md +54 -114
  35. package/build/src/akuma/akuma-owner.js +5 -4
  36. package/build/src/akuma/akuma.d.ts +2 -0
  37. package/build/src/akuma/akuma.js +17 -5
  38. package/build/src/akuma/identity.d.ts +4 -0
  39. package/build/src/akuma/identity.js +7 -0
  40. package/build/src/akuma/projection.d.ts +7 -1
  41. package/build/src/akuma/projection.js +6 -1
  42. package/build/src/cli/commands/akuma-grammar.js +4 -4
  43. package/build/src/cli/render/akuma-activity.js +40 -9
  44. package/build/src/cli/render/akuma.js +1 -1
  45. package/build/src/cli/render/kanshi-akuma.d.ts +3 -2
  46. package/build/src/cli/render/kanshi-akuma.js +1 -1
  47. package/build/src/cli/render/kanshi.js +19 -5
  48. package/build/src/contract-worktree.js +19 -4
  49. package/build/src/git/observe.d.ts +2 -1
  50. package/build/src/git/observe.js +29 -20
  51. package/build/src/index.d.ts +2 -1
  52. package/build/src/index.js +1 -1
  53. package/build/src/kanshi/counts.d.ts +15 -0
  54. package/build/src/kanshi/counts.js +66 -0
  55. package/build/src/kanshi/index.d.ts +2 -0
  56. package/build/src/kanshi/index.js +1 -0
  57. package/build/src/kanshi/read.js +1 -1
  58. package/build/src/library/selection.d.ts +6 -1
  59. package/build/src/library/selection.js +5 -3
  60. package/build/src/protocol/read/status.d.ts +2 -2
  61. package/build/src/protocol/read/status.js +8 -6
  62. package/build/src/runtime/proc/windows-launch.exe +0 -0
  63. package/package.json +2 -2
  64. package/plugins/pi/README.md +10 -0
  65. package/plugins/pi/akuma-tools.ts +2 -2
  66. package/plugins/pi/keiyaku.ts +73 -1
  67. package/skills/keiyaku/SKILL.md +24 -24
  68. package/skills/keiyaku-akuma/SKILL.md +43 -165
  69. package/skills/keiyaku-akuma/references/automation.md +58 -228
  70. package/skills/keiyaku-babysit/SKILL.md +45 -56
  71. package/skills/keiyaku-bind/SKILL.md +43 -184
  72. package/skills/keiyaku-debt/SKILL.md +39 -88
  73. package/skills/keiyaku-workflow/SKILL.md +54 -114
@@ -16,6 +16,16 @@ keiyaku install pi
16
16
  pi --extension ./plugins/pi/keiyaku.ts
17
17
  ```
18
18
 
19
+ ## Native status
20
+
21
+ Interactive Pi sessions show a compact status entry with the current World's
22
+ running Akuma, active Contracts, and open Debts across all namespaces. A zero
23
+ is an observed empty count; `-` means absent and `?` means unknown or failed.
24
+ The entry refreshes after each completed read (five seconds later) and when the
25
+ agent settles. It starts with the session and is removed on shutdown or reload;
26
+ non-terminal modes do not run the sampler. The `/keiyaku` overlay and native
27
+ tools are unchanged.
28
+
19
29
  ## Native tools
20
30
 
21
31
  All tools return the SDK result in `details`, `structuredContent`, and JSON
@@ -261,10 +261,10 @@ export function registerAkumaTools(pi: ExtensionAPI, exposure: "hidden" | "direc
261
261
  );
262
262
  register<ToolAddress<AkumaHistoryInput>>(
263
263
  "akuma_history",
264
- "Read retained execution history, the last answer, or one exact turn/n outcome. id cannot combine with paging or last. before/since are durable sequence cursors, not timestamps.",
264
+ "Read retained execution history, the last answer, one exact turn/n outcome, or one exact report/n. id cannot combine with paging or last. before/since are durable sequence cursors, not timestamps.",
265
265
  {
266
266
  akuma: selector,
267
- id: { type: "string", pattern: "^turn/[1-9][0-9]*$" },
267
+ id: { type: "string", pattern: "^(turn|report)/[1-9][0-9]*$" },
268
268
  before: { type: "integer", minimum: 1 },
269
269
  since: { type: "integer", minimum: 1 },
270
270
  limit,
@@ -1,4 +1,5 @@
1
1
  import type { ExtensionAPI, Theme } from "@earendil-works/pi-coding-agent";
2
+ import { kanshiCounts, NoGitWorldError, Repo, World } from "@astrosheep/keiyaku";
2
3
  import { registerAkumaTools } from "./akuma-tools.ts";
3
4
 
4
5
  type ExecResult = Readonly<{ stdout: string; stderr: string; code: number }>;
@@ -37,8 +38,79 @@ function overlay(lines: readonly string[], theme: Theme, done: () => void) {
37
38
  };
38
39
  }
39
40
 
40
- export default function keiyakuExtension(pi: ExtensionAPI): void {
41
+ type StatusReaders = { repo: typeof Repo.at; world: typeof World.resolve; counts: typeof kanshiCounts };
42
+
43
+ export default function keiyakuExtension(
44
+ pi: ExtensionAPI,
45
+ readers: StatusReaders = { repo: Repo.at, world: World.resolve, counts: kanshiCounts },
46
+ ): void {
41
47
  registerAkumaTools(pi);
48
+ let close: (() => void) | undefined;
49
+ let refresh: (() => void) | undefined;
50
+ pi.on("session_start", (_event, ctx) => {
51
+ close?.();
52
+ close = undefined;
53
+ refresh = undefined;
54
+ if (ctx.mode !== "tui") return;
55
+ const cwd = ctx.cwd;
56
+ const ui = ctx.ui;
57
+ let live = true;
58
+ let reading = false;
59
+ let pending = false;
60
+ let timer: ReturnType<typeof setTimeout> | undefined;
61
+ const unknown = "aku ? · kei ? · debt ?";
62
+ const show = (text: string | undefined): void => ui.setStatus("keiyaku", text);
63
+ const value = (section: { kind: "present"; value: number } | { kind: "absent" | "failed" }): string =>
64
+ section.kind === "present" ? String(section.value) : section.kind === "absent" ? "-" : "?";
65
+ const sample = async (): Promise<string> => {
66
+ let repo: Repo | undefined;
67
+ try {
68
+ repo = await readers.repo({ path: cwd });
69
+ } catch (error) {
70
+ if (!(error instanceof NoGitWorldError)) throw error;
71
+ }
72
+ const world = await readers.world(repo === undefined ? { cwd } : { cwd, repositoryRoot: repo.root });
73
+ const report = await readers.counts({ world: world.root, ...(repo === undefined ? {} : { repo }) });
74
+ return `aku ${value(report.akuma)} · kei ${value(report.contracts)} · debt ${value(report.debts)}`;
75
+ };
76
+ const request = (): void => {
77
+ if (!live) return;
78
+ if (timer !== undefined) clearTimeout(timer);
79
+ timer = undefined;
80
+ if (reading) {
81
+ pending = true;
82
+ return;
83
+ }
84
+ reading = true;
85
+ void sample().catch(() => unknown).then((text) => {
86
+ if (!live) return;
87
+ show(text);
88
+ reading = false;
89
+ if (pending) {
90
+ pending = false;
91
+ request();
92
+ } else {
93
+ timer = setTimeout(request, 5_000);
94
+ timer.unref();
95
+ }
96
+ });
97
+ };
98
+ close = () => {
99
+ if (!live) return;
100
+ live = false;
101
+ if (timer !== undefined) clearTimeout(timer);
102
+ show(undefined);
103
+ };
104
+ refresh = request;
105
+ show(unknown);
106
+ request();
107
+ });
108
+ pi.on("agent_settled", () => { refresh?.(); });
109
+ pi.on("session_shutdown", () => {
110
+ close?.();
111
+ close = undefined;
112
+ refresh = undefined;
113
+ });
42
114
  pi.registerCommand("keiyaku", {
43
115
  description: "Open the Kanshi world status",
44
116
  handler: async (_args, ctx) => {
@@ -1,36 +1,36 @@
1
1
  ---
2
2
  name: keiyaku
3
3
  description: >-
4
- Keiyaku is a CLI that records unresolved work, writes handoff terms for deliveries,
5
- and calls delegates. Use this skill when you need to figure out which
6
- Keiyaku skill or command to reach for.
4
+ Keiyaku records unresolved work, writes handoff terms for deliveries, and
5
+ calls delegates. Use this skill when deciding which Keiyaku concept or skill
6
+ to reach for.
7
7
  ---
8
8
 
9
9
  # Keiyaku
10
10
 
11
- ## Model
11
+ ## Three Independent Pillars
12
12
 
13
- Keiyaku has three independent pillars: **Debt** records unresolved work,
14
- **Contract** makes acceptance auditable, **Akuma** runs delegates. Use any one
15
- alone. Each Contract in flight has one holder who runs its loop: you by
16
- default, or one Aku you hand the whole loop to.
13
+ Keiyaku has three pillars that work alone or together:
17
14
 
18
- - Shaping and binding a Contract: `keiyaku-bind`
19
- - Holding a Contract to acceptance: `keiyaku-workflow`
20
- - Calling and steering Akumas: `keiyaku-akuma`
21
- - Recording unresolved work: `keiyaku-debt`
22
- - Watching many lanes at once: `keiyaku-babysit`
15
+ - **Debt (`keiyaku-debt`):** confirmed unresolved work and its dependencies.
16
+ Does **not** require a closed design — record a Debt as soon as a problem or
17
+ prerequisite is confirmed, even while the solution is still open.
18
+ - **Contract (`kei`):** one independently acceptable delivery whose objective,
19
+ design, and acceptance boundary are already closed, owned by **one and only
20
+ one holder** (you by default, or one Akuma handed the whole Contract loop). If
21
+ the design is not closed yet, investigate the codebase yourself or send an
22
+ Akuma to settle the approach before binding. Complex `kei`s divide their
23
+ execution into **Arcs** (chapters inside that one acceptance boundary).
24
+ - **Akuma (`keiyaku-akuma`):** delegated workers addressed by `@alias` or
25
+ `AkuId` across parallel lanes.
23
26
 
24
- ## Quick Start
27
+ ## Which Skill To Read
25
28
 
26
- ```bash
27
- keiyaku -C <repo> debt add "title"
28
- keiyaku -C <repo> bind [--debt <debt/...>] -
29
- keiyaku -C <repo> status
30
- keiyaku -C <repo> deliver [<contract>|@<contract>]
31
- keiyaku -C <repo> review [<contract>|@<contract>] --satisfied --summary "<evidence>"
32
- ```
29
+ - Recording or querying unresolved work and prerequisites: `keiyaku-debt`
30
+ - Splitting acceptance boundaries and authoring a Contract: `keiyaku-bind`
31
+ - Running a Contract's fulfillment loop (deliver, verify, review): `keiyaku-workflow`
32
+ - Calling, aliasing, steering, and waiting on Akumas: `keiyaku-akuma`
33
+ - Supervising multiple active Contracts and Akumas in parallel: `keiyaku-babysit`
33
34
 
34
- `-C <path>` sets the invocation directory and with it the World. `--repo <path>`
35
- only picks the Contract repository. `call --workdir <path>` only picks where the
36
- Akuma runs.
35
+ Get exact command or tool syntax from CLI `--help` or the exposed tool
36
+ descriptions.
@@ -8,168 +8,46 @@ description: >-
8
8
 
9
9
  # Keiyaku Akuma
10
10
 
11
- Use Akumas to delegate work to another worker. `call` creates a new Akuma;
12
- `tell` admits a Tell for an existing Akuma; `ask` admits one and observes its
13
- exact answer. Keep the complete AkuId, such as `aku/worker/1234abcd`, when you
14
- need to address the same worker later. An alias such as `@reviewer` is a
15
- shorter, world-local name.
16
-
17
- ## Call a new Akuma
18
-
19
- ```bash
20
- keiyaku call worker "Summarize the recent changes in src/cli"
21
- keiyaku call worker --alias @reviewer --wait 10m - < brief.md
22
- keiyaku call worker
23
- ```
24
-
25
- The prompt is optional for prompt-free birth. Otherwise it is the new Akuma's
26
- first prompt: give it as one argument, or use `-` to read stdin, never both.
27
- Calls are detached by default: they return the new identity after birth without
28
- waiting for the first answer. Use explicit `--wait <duration>` when this
29
- invocation should block while observing that initial work. `--wait` only bounds
30
- this command; it never stops the Akuma. Read `call --help` for flag syntax and
31
- defaults.
32
- To hand a Contract role to an Akuma, use the commissioning table in
33
- `keiyaku-workflow`.
34
-
35
- The selected Akuma name is a reusable worker configuration, not an individual.
36
- Calling it again creates an independent Akuma. Use different names for
37
- capabilities, not merely for parallelism.
38
-
39
- ## Commission Context
40
-
41
- `--contract` only records the association. It neither tells the Akuma about the
42
- Contract nor picks its worktree: pass `--workdir`, and put both in the prompt.
43
-
44
- ```bash
45
- keiyaku call worker --contract kei/add-rate-limit-a1b2 --workdir /path/to/worktree - <<'EOF'
46
- Contract: kei/add-rate-limit-a1b2
47
- Worktree: /path/to/worktree
48
- This Arc: implement the limiter and its tests
49
- EOF
50
- ```
51
-
52
- An Akuma can `keiyaku report` to you mid-turn without stopping. For long work,
53
- ask for it in the prompt (e.g. "report each milestone or blocker"); reports
54
- show up in its `history`.
55
-
56
- ### Verification brief
57
-
58
- When commissioning checks, name the appointed worktree, Contract, all declarations
59
- or current one-based index, and whether dirty capture is authorized:
60
-
61
- ```bash
62
- keiyaku -C <appointed-path> verify <kei/...>
63
- keiyaku -C <appointed-path> verify <kei/...> --index 2 --include-dirty
64
- ```
65
-
66
- Only explicit verify executes declarations. Deliver, review, preview, target
67
- refresh, and dependent completion consume current evidence only. Each check has
68
- independent clean scratch, setup, and cleanup: a required build belongs in that
69
- check's script or setup, never another fence. Evidence names the exact prospective
70
- integration and stable content-derived requirement; the index is only a current
71
- selector. Verify admits no delivery and can place only a previously delivered
72
- candidate whose prerequisites and every gate pass.
73
-
74
- Ask for every executed check's verdict, new or reused testimony admission,
75
- operational stops, retained diagnostic paths, and completion. Reused admission
76
- never means execution was skipped. Normal failure or timeout affects only that
77
- requirement and full verify continues; an operational stop admits no verdict for
78
- the affected check and preserves prior admissions. A selected success establishes
79
- no verdict for other requirements; the generic gate judgment decides whole-gate
80
- satisfaction. Verify runs in the invoking process with its native Git and
81
- process custody.
82
-
83
- ## Tell or ask an existing Akuma
84
-
85
- ```bash
86
- keiyaku tell @reviewer "The candidate moved; re-examine the worktree"
87
- keiyaku tell @reviewer --interrupt - < new-priority.md
88
- keiyaku ask @reviewer --wait 10m "What is your verdict?"
89
- keiyaku ask @reviewer --schema verdict.schema.json - < question.md
90
- ```
91
-
92
- `tell` queues the next instruction and returns without waiting for an answer.
93
- `ask` queues it and waits for that exact answer, bounded by `--wait`.
94
- `--interrupt` admits the Tell and asks current work to yield; the Tell remains
95
- admitted even if yielding cannot be confirmed. A deadline never withdraws it.
96
- Only `ask` takes `--schema`. Read `tell --help` and `ask --help` for syntax.
97
-
98
- ## Observe work
99
-
100
- ```bash
101
- keiyaku wait @deliverer @reviewer
102
- keiyaku wait --all --timeout 30m @deliverer @reviewer
103
- ```
104
-
105
- `wait` returns when any selected Akuma finishes (`--all`: every one). `--timeout`
106
- ends the wait, not the workers. An already finished Akuma counts immediately.
107
- Unlike `ask`, this observes existing work, not a newly submitted instruction.
108
-
109
- `keiyaku wait kei/...` instead waits for the named Contract's next journal
110
- change or terminal state, even without a dispatched Akuma. Each invocation
111
- starts at the current head; an already accepted or abandoned Contract counts
112
- immediately, without being reported as changed. Use `--all` to wait for every
113
- selected Contract, and do not mix Contract and Akuma selectors in one wait.
114
- `kill kei/...` still selects the associated Akumas.
115
-
116
- ## Inspect and retrieve results
117
-
118
- ```bash
119
- keiyaku whoami
120
- keiyaku status
121
- keiyaku status @reviewer
122
- keiyaku ls aku/
123
- keiyaku ls "aku/*/*"
124
- keiyaku ls --mine
125
- keiyaku history @reviewer --last
126
- keiyaku history @reviewer --id turn/3
127
- ```
128
-
129
- - `whoami`: who you are; for an Akuma, also who started its current turn.
130
- - `status [<aku>]`: the roster, or one Akuma's state and workdir.
131
- - `ls aku/`: callable names. `ls "aku/*/*"`: recent instances.
132
- `ls --mine`: Akumas you called, plus their descendants in this World.
133
- `--caller` selects another caller; see `ls --help`.
134
- - `history <aku> --last`: latest answer. `--id turn/N`: one exact turn's
135
- answer or failure diagnostic (ids are in `history <aku> --json`).
136
- Keep the complete AkuId if an alias may move.
137
-
138
- ## Retention
139
-
140
- Akumas idle for more than fifteen days may be cleaned up after a later
141
- successful `call` or `fork`. Running Akumas, alias targets, and Akumas
142
- dispatched to an open Contract are kept, and nothing is killed. Read-only
143
- commands and `tell`/`ask`/`wait` never trigger cleanup.
144
-
145
- ## Stop and branch
146
-
147
- ```bash
148
- keiyaku kill @reviewer
149
- keiyaku fork @reviewer --at turn/3
150
- ```
151
-
152
- `kill` stops current work without admitting a Tell, deleting the Akuma, or
153
- removing its history. `fork` creates a new Akuma from one exact retained
154
- answered history point; the source is unchanged, and providers that cannot
155
- fork report that refusal. See `kill --help` and `fork --help` for the
156
- complete grammar.
157
-
158
- ## JavaScript automation
159
-
160
- Use [Automation With The Akuma API](references/automation.md) for a
161
- job-specific JavaScript coordinator, structured answers, or multi-worker
162
- orchestration. The CLI is enough for one commission and its return. A
163
- prompt-free birth followed by one input-bound ask uses the same identity:
164
-
165
- ```ts
166
- import { Akuma, Akumas, World } from "@astrosheep/keiyaku";
167
-
168
- const root = await World.at(process.cwd());
169
- const called = await Akumas.of(root).call({ archetype: "worker" });
170
- const worker = Akuma.select(root, called.akuma);
171
- const result = await worker.ask("Inspect the change");
172
- console.log(result.observation);
173
- ```
174
-
175
- The automation guide covers schema-based answer handling and longer workflows.
11
+ Use Akumas to delegate implementation, review, verification, or parallel
12
+ research.
13
+
14
+ ## 1. Aliases And Operations (`call`, `tell`, `ask`, `wait`)
15
+
16
+ - **Give every worker an `@alias` at birth:** assign a role or lane alias when
17
+ calling an Akuma (`@deliverer`, `@reviewer`, `@scout`). Aliases make
18
+ `status`, `wait`, `tell`, `ask`, and `history` readable by role across
19
+ parallel lanes; keep the underlying `aku/<name>/<id>` only when reassigning
20
+ that `@alias` to a replacement worker. Calling an archetype name (`worker`,
21
+ `review-akuma`) always spawns a new instance — address the existing `@alias`
22
+ or `AkuId` with `tell`/`ask` to continue with the same worker.
23
+ - **Detached `call` + `wait` for real work:** launch workers detached, then
24
+ supervise them together with `wait` (wakes on any settlement by default, or
25
+ all; a wait deadline never kills workers). `wait` on `kei/...` waits for a
26
+ Contract's next journal change or terminal state.
27
+ - **`ask` for single-turn answers:** submits an instruction and waits for that
28
+ exact Turn's answer (optionally validated against a JSON schema).
29
+ - **`tell` vs. interrupting `tell`:** `tell` queues steering instructions
30
+ without blocking; request an interrupt only when the worker is on the wrong
31
+ track and should yield its current attempt first.
32
+
33
+ ## 2. Commissioning Context
34
+
35
+ - **Set both Contract association and working directory:** associating a
36
+ `kei/...` records Dispatch for `status`, but neither sets the working
37
+ directory nor injects Contract terms into the prompt. Point the working
38
+ directory at the appointed worktree and write the Contract ID, worktree path,
39
+ current Arc, and expected return in the prompt.
40
+ - **Request `report` on long tasks:** a worker can record mid-turn progress
41
+ reports without stopping; inspect them in `history`.
42
+
43
+ ## 3. Observing, Branching, And Automation
44
+
45
+ - **`status` and `history`:** `status` shows the World board or one Akuma's
46
+ live snapshot and file-change summary; `history` reads recent timeline
47
+ events, the latest answer, or one exact `turn/N` or `report/N` item.
48
+ - **`ls`, `fork`, and `kill`:** `ls` lists archetypes (`aku/`), recent
49
+ instances (`"aku/*/*"`), or your own call tree; `fork` branches a new Akuma
50
+ from an answered `turn/N`; `kill` stops active work while keeping history.
51
+ - **JavaScript orchestration:** for multi-agent tournaments, adversarial claim
52
+ checking, or custom concurrency control in code, read
53
+ [Automation With The Akuma API](references/automation.md).