@astrosheep/keiyaku 4.6.29 → 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 (50) 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 -167
  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 -167
  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 -167
  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/skills/keiyaku/SKILL.md +24 -24
  26. package/build/skills/keiyaku-akuma/SKILL.md +43 -167
  27. package/build/skills/keiyaku-akuma/references/automation.md +58 -228
  28. package/build/skills/keiyaku-babysit/SKILL.md +45 -56
  29. package/build/skills/keiyaku-bind/SKILL.md +43 -184
  30. package/build/skills/keiyaku-debt/SKILL.md +39 -88
  31. package/build/skills/keiyaku-workflow/SKILL.md +54 -114
  32. package/build/src/cli/render/akuma-activity.js +33 -1
  33. package/build/src/cli/render/kanshi-akuma.d.ts +3 -2
  34. package/build/src/cli/render/kanshi-akuma.js +1 -1
  35. package/build/src/cli/render/kanshi.js +19 -5
  36. package/build/src/contract-worktree.js +19 -4
  37. package/build/src/git/observe.d.ts +2 -1
  38. package/build/src/git/observe.js +29 -20
  39. package/build/src/kanshi/read.js +1 -1
  40. package/build/src/protocol/read/status.d.ts +2 -2
  41. package/build/src/protocol/read/status.js +8 -6
  42. package/build/src/runtime/proc/windows-launch.exe +0 -0
  43. package/package.json +1 -1
  44. package/skills/keiyaku/SKILL.md +24 -24
  45. package/skills/keiyaku-akuma/SKILL.md +43 -167
  46. package/skills/keiyaku-akuma/references/automation.md +58 -228
  47. package/skills/keiyaku-babysit/SKILL.md +45 -56
  48. package/skills/keiyaku-bind/SKILL.md +43 -184
  49. package/skills/keiyaku-debt/SKILL.md +39 -88
  50. package/skills/keiyaku-workflow/SKILL.md +54 -114
@@ -1,7 +1,7 @@
1
1
  import { abbreviateGitIds, afterWording, progressStrip, displayGitId, gateRequirementFacts, gitIdsInRow, lifecycleWord, mergeSummary, targetMovementFacts, } from "./contract-observation.js";
2
2
  import { DEFAULT_CLI_COLUMNS, emptyCatalogue, entityLines, elapsedMilliseconds, identityLine, plumbFacts, RECENT_TONE_MS, renderBoundedPayload, renderSectionBlock, safeText, tone, } from "./terminal.js";
3
- import { endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard } from "./kanshi-akuma.js";
4
- import { contractMark, debtDispositionMark } from "./marks.js";
3
+ import { akumaLabel, endpointFact, formatAge, NARROW_COLUMNS, renderAkuma, renderAkumaBoard } from "./kanshi-akuma.js";
4
+ import { akumaMark, contractMark, debtDispositionMark } from "./marks.js";
5
5
  import { dispositionText } from "./debt.js";
6
6
  const REVIEW_ATTENTION_MS = 15 * 60 * 1_000;
7
7
  const PENDING_ATTENTION_MS = 60 * 60 * 1_000;
@@ -87,6 +87,21 @@ function linkedAkumaSummary(row, akuma) {
87
87
  facts.push(`${row.roster.length - known.length} unavailable`);
88
88
  return facts.join(" · ");
89
89
  }
90
+ function linkedAkumaRows(row, akuma) {
91
+ const rows = akuma?.kind === "present" ? akuma.value.rows : [];
92
+ const byId = new Map(rows.map((item) => [item.id, item]));
93
+ return [
94
+ ...(row.rosterUnavailable === true ? [" akuma association unavailable"] : []),
95
+ ...row.roster.map((attached) => {
96
+ const observed = byId.get(attached.id);
97
+ const aliases = akumaLabel(attached, attached.aliasesUnavailable === true);
98
+ const identity = [attached.id, aliases].filter(Boolean).join(" ");
99
+ return observed === undefined
100
+ ? ` ! ${safeText(identity)} · unavailable`
101
+ : ` ${akumaMark(observed.life)} ${safeText(identity)} · ${observed.life}`;
102
+ }),
103
+ ];
104
+ }
90
105
  function semanticBlock(_name, facts, _context) {
91
106
  if (facts.length === 0)
92
107
  return [];
@@ -144,6 +159,7 @@ function renderSelectedContractRow(row, facts, context, abbreviations) {
144
159
  if (row.phase === "claimed" || row.phase === "abandoned") {
145
160
  const outcome = terminalFacts(row, context, abbreviations);
146
161
  lines.push(...outcome.map((fact) => (fact.startsWith(" ") ? fact : ` ${safeText(fact)}`)));
162
+ lines.push(...linkedAkumaRows(row, facts.akuma));
147
163
  return lines;
148
164
  }
149
165
  const deniedReview = row.gates.reports.find((gate) => gate.gate === "reviewed" && gate.current.kind === "attested" && gate.current.verdict === "unsatisfied");
@@ -161,9 +177,7 @@ function renderSelectedContractRow(row, facts, context, abbreviations) {
161
177
  }
162
178
  if (deniedReview?.current.kind === "attested" && deniedReview.current.summary !== undefined)
163
179
  lines.push(...payload("review ×", deniedReview.current.summary, context));
164
- const akuma = linkedAkumaSummary(row, facts.akuma);
165
- if (akuma !== undefined)
166
- lines.push(...semanticBlock("akuma", [akuma], context));
180
+ lines.push(...linkedAkumaRows(row, facts.akuma));
167
181
  if (row.worktreePath !== null)
168
182
  lines.push(...semanticBlock("worktree", [`worktree ${row.worktreePath}`], context));
169
183
  lines.push(...semanticBlock("alarms", liveAlarms(row, facts.debts), context));
@@ -56,16 +56,31 @@ async function repair(worktree, relativePath, bytes, tracked) {
56
56
  const path = join(worktree, relativePath);
57
57
  if (tracked.has(relativePath))
58
58
  throw new Error(`generated path is tracked by Git: ${path}`);
59
- const action = await repairDerivedFile(path, bytes);
60
- if (relativePath === ".keiyaku/KEIYAKU.md") {
59
+ if (relativePath !== ".keiyaku/KEIYAKU.md") {
60
+ return { kind: "contract-file", path, action: await repairDerivedFile(path, bytes) };
61
+ }
62
+ try {
63
+ const stat = await lstat(path).catch((error) => {
64
+ if (error.code === "ENOENT")
65
+ return undefined;
66
+ throw error;
67
+ });
68
+ if (stat?.isFile() && !stat.isSymbolicLink() && !(await readFile(path)).equals(Buffer.from(bytes))) {
69
+ await chmod(path, stat.mode | 0o200);
70
+ }
71
+ const action = await repairDerivedFile(path, bytes);
72
+ return { kind: "contract-file", path, action };
73
+ }
74
+ finally {
61
75
  try {
62
- await chmod(path, 0o444);
76
+ const stat = await lstat(path);
77
+ if (stat.isFile() && !stat.isSymbolicLink())
78
+ await chmod(path, 0o444);
63
79
  }
64
80
  catch {
65
81
  /* advisory protection only */
66
82
  }
67
83
  }
68
- return { kind: "contract-file", path, action };
69
84
  }
70
85
  async function isKeiyakuSeatLeaf(worktree, seat) {
71
86
  const sentinel = join(worktree, ".agents", "skills", seat, ".gitignore");
@@ -7,7 +7,8 @@ type TargetObservation = Readonly<{
7
7
  head: SnapshotId | null;
8
8
  drift: boolean;
9
9
  }>;
10
- export declare function observeDeliveryTargetAt(observation: GitReadObservation, state: ContractState): Promise<TargetObservation | null>;
10
+ /** Reuse exact target evidence only within this read, while judging each Contract's own drift. */
11
+ export declare function deliveryTargetObserver(observation: GitReadObservation): (state: ContractState) => Promise<TargetObservation | null>;
11
12
  type GitJournalRecord = Readonly<{
12
13
  entries: readonly JournalEntry[];
13
14
  state: ContractState | null;
@@ -1,29 +1,38 @@
1
1
  import { decodeJournal } from "../core/facts/codec.js";
2
2
  import { AuthorityCorruptionError } from "../core/facts/errors.js";
3
3
  import { foldJournal } from "../core/facts/fold.js";
4
- import { targetRef, targetRepository, resolveContractTarget } from "./target.js";
4
+ import { resolveContractTarget } from "./target.js";
5
5
  import { contractJournalPath, contractJournalPaths, mintContractHead, mintSnapshotId, } from "./identity.js";
6
- import { currentBranch, isKeiyakuOwnedRef, readRef } from "./repository.js";
6
+ import { currentBranch, isKeiyakuOwnedRef } from "./repository.js";
7
7
  import { GitPlumbingError, executeGit } from "./process.js";
8
8
  import { readBlobResults, readGitTreeSelection, withGitTargetedReadObservation, } from "./read-observation.js";
9
- export async function observeDeliveryTargetAt(observation, state) {
10
- const target = state.coordinates.target;
11
- if (target === undefined)
12
- return null;
13
- if (typeof target !== "string") {
14
- const resolved = await resolveContractTarget(observation.repository, target.contractId, target);
15
- if (resolved.kind === "refused")
16
- return { head: null, drift: true };
17
- }
18
- const value = typeof target === "string"
19
- ? await observation.resolveRef(target)
20
- : await readRef(targetRepository(observation.repository, target), targetRef(target));
21
- const head = value === null ? null : mintSnapshotId(value);
22
- const integration = state.currentIntegration;
23
- if (integration === null)
24
- return { head, drift: false };
25
- const expected = state.terminal?.kind === "claimed" ? integration.snapshot : integration.predecessor;
26
- return { head, drift: head !== expected };
9
+ /** Reuse exact target evidence only within this read, while judging each Contract's own drift. */
10
+ export function deliveryTargetObserver(observation) {
11
+ const targets = new Map();
12
+ return async (state) => {
13
+ const target = state.coordinates.target;
14
+ if (target === undefined)
15
+ return null;
16
+ const key = typeof target === "string" ? target : `${target.contractId}\0${target.worktree.id}\0${target.worktree.identity}`;
17
+ let pending = targets.get(key);
18
+ if (pending === undefined) {
19
+ pending = (async () => {
20
+ if (typeof target !== "string") {
21
+ const resolved = await resolveContractTarget(observation.repository, target.contractId, target);
22
+ return resolved.kind === "refused"
23
+ ? { head: null, unavailable: true }
24
+ : { head: resolved.head, unavailable: false };
25
+ }
26
+ const value = await observation.resolveRef(target);
27
+ return { head: value === null ? null : mintSnapshotId(value), unavailable: false };
28
+ })();
29
+ targets.set(key, pending);
30
+ }
31
+ const { head, unavailable } = await pending;
32
+ const integration = state.currentIntegration;
33
+ const expected = state.terminal?.kind === "claimed" ? integration?.snapshot : integration?.predecessor;
34
+ return { head, drift: unavailable || (integration !== null && head !== expected) };
35
+ };
27
36
  }
28
37
  const TARGET_COORDINATES_FORMAT = "%(refname)%00%(objectname)%00";
29
38
  export async function normalizeTargetBranch(repository, input) {
@@ -137,7 +137,7 @@ async function readContracts(observation, include, limit = WORLD_CONTRACT_ROWS)
137
137
  kind: "present",
138
138
  value: include === undefined
139
139
  ? await readContractCatalogue(observation, limit)
140
- : await readContractBoard(observation, include),
140
+ : await readContractBoard(observation, include, "selected"),
141
141
  };
142
142
  }
143
143
  catch (error) {
@@ -95,8 +95,8 @@ export type ContractObservation = Readonly<{
95
95
  }>;
96
96
  export declare function phaseAtFor(state: Pick<ContractState, "terminal" | "delivery">, bindAt: string): string;
97
97
  export declare function lastJournalAtFor(entries: readonly Pick<JournalEntry, "at">[]): string;
98
- /** Build the Contract board from one immutable git observation. */
99
- export declare function readContractBoard(observation: GitReadObservation, include?: ContractId): Promise<ContractBoard>;
98
+ /** Build the complete board by default; a selected detail read retains complete dependency evidence. */
99
+ export declare function readContractBoard(observation: GitReadObservation, include?: ContractId, detail?: "board" | "selected"): Promise<ContractBoard>;
100
100
  /** Observe a bounded recent active Contract catalogue from one immutable git observation. */
101
101
  export declare function readContractCatalogue(observation: GitReadObservation, limit: number): Promise<ContractCatalogue>;
102
102
  /**
@@ -1,4 +1,4 @@
1
- import { observeActiveContractWorld, observeContractsForAdmissionInObservationAt, observeDeliveryTargetAt, withContractReadObservationAt, } from "../../git/observe.js";
1
+ import { observeActiveContractWorld, observeContractsForAdmissionInObservationAt, deliveryTargetObserver, withContractReadObservationAt, } from "../../git/observe.js";
2
2
  import { decodeContractDocument } from "../../body/decode.js";
3
3
  import { observeTargetLag, observeWorkspace, readConflictHandoffs, conflictRecovery, worktreePath, } from "../../git/workspace.js";
4
4
  import { appointmentFor, readPlaceRegister } from "../../workspace-place.js";
@@ -145,20 +145,21 @@ async function hydrateRows(observation, states, endpoints, dependentStates = [])
145
145
  workspace: appointedWorkspace(observation.repository, register, value.state),
146
146
  }));
147
147
  const handoffs = await readConflictHandoffs(observation.repository, observation.readBlobs, selected.flatMap(({ workspace }) => (workspace === undefined ? [] : [workspace])));
148
+ const observeTarget = deliveryTargetObserver(observation);
148
149
  return await Promise.all(selected.map(async ({ state, bindAt, lastJournalAt, workspace }) => await rowFor({
149
150
  repository: observation.repository,
150
151
  state,
151
152
  bindAt,
152
153
  lastJournalAt,
153
- targetObservation: await observeDeliveryTargetAt(observation, state),
154
+ targetObservation: await observeTarget(state),
154
155
  workspace,
155
156
  handoff: handoffs.get(state.id),
156
157
  after: afterEdges(state, endpoints),
157
158
  dependents: reverseDependents(state.id, dependentStates),
158
159
  })));
159
160
  }
160
- /** Build the Contract board from one immutable git observation. */
161
- export async function readContractBoard(observation, include) {
161
+ /** Build the complete board by default; a selected detail read retains complete dependency evidence. */
162
+ export async function readContractBoard(observation, include, detail = "board") {
162
163
  const observedAt = new Date().toISOString();
163
164
  const observed = await observeActiveContractWorld(observation);
164
165
  const contracts = new Map(observed.contracts);
@@ -174,8 +175,9 @@ export async function readContractBoard(observation, include) {
174
175
  endpoints = new Map(await afterEndpointMap(observation, endpoints, record.state.terms.after));
175
176
  }
176
177
  }
177
- const selected = selectedContractStates(contracts);
178
- const rows = await hydrateRows(observation, selected, endpoints, selected);
178
+ const states = selectedContractStates(contracts);
179
+ const selected = detail === "selected" ? states.filter(({ state }) => state.id === include) : states;
180
+ const rows = await hydrateRows(observation, selected, endpoints, states);
179
181
  return {
180
182
  root: observation.repository.primaryWorktree,
181
183
  state: observed.snapshot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/keiyaku",
3
- "version": "4.6.29",
3
+ "version": "4.6.30",
4
4
  "workspaces": [
5
5
  "plugins/square",
6
6
  "plugins/paseo/forwarder"
@@ -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,170 +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
- keiyaku history @reviewer --id report/5
128
- ```
129
-
130
- - `whoami`: who you are; for an Akuma, also who started its current turn.
131
- - `status [<aku>]`: the roster, or one Akuma's state and workdir.
132
- - `ls aku/`: callable names. `ls "aku/*/*"`: recent instances.
133
- `ls --mine`: Akumas you called, plus their descendants in this World.
134
- `--caller` selects another caller; see `ls --help`.
135
- - `history <aku> --id report/N`: the exact retained report text, including during an open Turn.
136
- - `history <aku> --last`: latest answer. `--id turn/N`: one exact turn's
137
- answer or failure diagnostic (ids are in `history <aku> --json`).
138
- Keep the complete AkuId if an alias may move.
139
-
140
- ## Retention
141
-
142
- Akumas idle for more than fifteen days may be cleaned up after a later
143
- successful `call` or `fork`. Running Akumas, alias targets, and Akumas
144
- dispatched to an open Contract are kept, and nothing is killed. Read-only
145
- commands and `tell`/`ask`/`wait` never trigger cleanup.
146
-
147
- ## Stop and branch
148
-
149
- ```bash
150
- keiyaku kill @reviewer
151
- keiyaku fork @reviewer --at turn/3
152
- ```
153
-
154
- `kill` stops current work without admitting a Tell, deleting the Akuma, or
155
- removing its history. `fork` creates a new Akuma from one exact retained
156
- answered history point; the source is unchanged, and providers that cannot
157
- fork report that refusal. See `kill --help` and `fork --help` for the
158
- complete grammar.
159
-
160
- ## JavaScript automation
161
-
162
- Use [Automation With The Akuma API](references/automation.md) for a
163
- job-specific JavaScript coordinator, structured answers, or multi-worker
164
- orchestration. The CLI is enough for one commission and its return. A
165
- prompt-free birth followed by one input-bound ask uses the same identity:
166
-
167
- ```ts
168
- import { Akuma, Akumas, World } from "@astrosheep/keiyaku";
169
-
170
- const root = await World.at(process.cwd());
171
- const called = await Akumas.of(root).call({ archetype: "worker" });
172
- const worker = Akuma.select(root, called.akuma);
173
- const result = await worker.ask("Inspect the change");
174
- console.log(result.observation);
175
- ```
176
-
177
- 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).