@astrosheep/keiyaku 4.5.8 → 4.5.9

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 (79) hide show
  1. package/README.md +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +2 -2
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +15 -15
  4. package/build/src/akuma/akuma.d.ts +24 -4
  5. package/build/src/akuma/archetype.js +1 -1
  6. package/build/src/akuma/body.d.ts +2 -1
  7. package/build/src/akuma/body.js +7 -2
  8. package/build/src/akuma/call-request.js +1 -1
  9. package/build/src/akuma/heart/facts.d.ts +10 -0
  10. package/build/src/akuma/heart/facts.js +11 -0
  11. package/build/src/akuma/heart/index.d.ts +3 -2
  12. package/build/src/akuma/heart/index.js +4 -1
  13. package/build/src/akuma/projection.d.ts +63 -12
  14. package/build/src/akuma/projection.js +5 -11
  15. package/build/src/akuma/provider.js +8 -1
  16. package/build/src/akuma/providers/claude/events.d.ts +2 -2
  17. package/build/src/akuma/providers/claude/events.js +16 -3
  18. package/build/src/akuma/providers/codex-app-server/events.d.ts +2 -2
  19. package/build/src/akuma/providers/codex-app-server/events.js +25 -4
  20. package/build/src/akuma/providers/pi/index.js +55 -69
  21. package/build/src/akuma/request-lifecycle.d.ts +1 -1
  22. package/build/src/akuma/request-lifecycle.js +3 -1
  23. package/build/src/akuma/request-serve.d.ts +1 -1
  24. package/build/src/akuma/request-serve.js +4 -4
  25. package/build/src/akuma/turn-drive.js +8 -2
  26. package/build/src/body/amend.js +18 -19
  27. package/build/src/cli/commands/akuma.js +2 -2
  28. package/build/src/cli/commands/contract-invoke.js +27 -22
  29. package/build/src/cli/commands/contract.d.ts +6 -10
  30. package/build/src/cli/commands/contract.js +29 -11
  31. package/build/src/cli/commands/install.d.ts +1 -0
  32. package/build/src/cli/commands/install.js +2 -1
  33. package/build/src/cli/parse.js +23 -9
  34. package/build/src/cli/render/akuma-activity.d.ts +1 -1
  35. package/build/src/cli/render/akuma-activity.js +4 -3
  36. package/build/src/cli/render/akuma.js +1 -1
  37. package/build/src/cli/render/catalog.js +1 -1
  38. package/build/src/cli/render/contract.js +13 -0
  39. package/build/src/cli/render/kanshi-akuma.js +26 -5
  40. package/build/src/cli/render/kanshi.js +26 -3
  41. package/build/src/cli/render/terminal.d.ts +4 -1
  42. package/build/src/cli/render/terminal.js +12 -1
  43. package/build/src/cli/runtime.js +1 -1
  44. package/build/src/git/nuke.js +3 -3
  45. package/build/src/git/process.js +7 -4
  46. package/build/src/git/read-observation.js +1 -1
  47. package/build/src/git/reconcile.d.ts +2 -1
  48. package/build/src/git/reconcile.js +6 -0
  49. package/build/src/git/ref-migration.d.ts +22 -0
  50. package/build/src/git/ref-migration.js +55 -0
  51. package/build/src/git/repository.d.ts +4 -4
  52. package/build/src/git/repository.js +8 -8
  53. package/build/src/library/audit.d.ts +13 -5
  54. package/build/src/library/audit.js +9 -21
  55. package/build/src/library/composition.d.ts +41 -27
  56. package/build/src/library/composition.js +3 -3
  57. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +17 -11
  58. package/build/src/library/contract-forwarding-reconciliation-result.js +11 -2
  59. package/build/src/library/contract-forwarding-result.d.ts +1628 -3887
  60. package/build/src/library/contract-forwarding-result.js +1 -1
  61. package/build/src/library/contract-forwarding.d.ts +12 -13
  62. package/build/src/library/contract-forwarding.js +17 -28
  63. package/build/src/library/contract-handle.d.ts +3 -1
  64. package/build/src/library/contract-handle.js +23 -22
  65. package/build/src/library/contract-operations.d.ts +61 -893
  66. package/build/src/library/contract-operations.js +2 -3
  67. package/build/src/library/contract-types.d.ts +7 -3
  68. package/build/src/library/contract.d.ts +12 -4
  69. package/build/src/library/contract.js +21 -6
  70. package/build/src/library/fleet-result.d.ts +138 -12
  71. package/build/src/library/fleet-result.js +2 -0
  72. package/build/src/library/input.d.ts +1 -1
  73. package/build/src/library/input.js +7 -1
  74. package/build/src/library/keiyaku.d.ts +44 -27
  75. package/build/src/library/keiyaku.js +6 -1
  76. package/build/src/runtime/proc/run.d.ts +1 -0
  77. package/build/src/runtime/proc/run.js +25 -5
  78. package/build/src/runtime/proc/windows-launch.exe +0 -0
  79. package/package.json +1 -1
@@ -470,7 +470,7 @@ export const auditReportSchema = z
470
470
  .optional(),
471
471
  })
472
472
  .strict()
473
- .transform(({ delivery, ...report }) => delivery === undefined ? report : { ...report, delivery });
473
+ .transform(({ delivery, ...report }) => (delivery === undefined ? report : { ...report, delivery }));
474
474
  const mutationResultSchema = (value) => z
475
475
  .object({
476
476
  facts: z.array(journalFactSchema),
@@ -1,19 +1,18 @@
1
- import { type ContractId } from "../core/facts/types.js";
1
+ import type { ActorId, ContractId } from "../core/facts/types.js";
2
2
  import { type IntegrationConflictMaterialized } from "../protocol/deliver.js";
3
3
  import type { RepositoryScope } from "../protocol/operations.js";
4
- import { type AuditInput } from "./audit.js";
4
+ import { type AuditComposition } from "./audit.js";
5
5
  import type { AuditReport } from "../protocol/audit.js";
6
6
  import type { WorktreeHooks } from "./configuration.js";
7
7
  import type { DeliveryValue } from "./delivery.js";
8
- import { actorOption } from "./input.js";
9
8
  import { type MutationResult } from "./mutation.js";
10
- import { type Review } from "./contract-forwarding-result.js";
9
+ import type { Review } from "./contract-forwarding-result.js";
11
10
  export type { Review } from "./contract-forwarding-result.js";
12
11
  import { Repo } from "./repo.js";
13
12
  export type DeliveryExecutionInput = Readonly<{
14
13
  scope: RepositoryScope;
15
14
  contractId: ContractId;
16
- actor?: ReturnType<typeof actorOption>["actor"];
15
+ actor?: ActorId;
17
16
  message?: string;
18
17
  requireBranchesToBeUpToDate: boolean;
19
18
  includeDirty: boolean;
@@ -25,7 +24,7 @@ export type AttestationVerdict = "satisfied" | "unsatisfied";
25
24
  export type ReviewExecutionInput = Readonly<{
26
25
  scope: RepositoryScope;
27
26
  contractId: ContractId;
28
- actor?: ReturnType<typeof actorOption>["actor"];
27
+ actor?: ActorId;
29
28
  verdict: AttestationVerdict;
30
29
  summary?: string;
31
30
  hooks: WorktreeHooks;
@@ -34,8 +33,8 @@ export declare function executeLocalDelivery(input: DeliveryExecutionInput): Pro
34
33
  export declare function executeLocalReview(input: ReviewExecutionInput): Promise<MutationResult<Review>>;
35
34
  export declare function executeForwardedDeliver(input: Readonly<{
36
35
  repo: Repo;
37
- contractId: string;
38
- requester: string;
36
+ contractId: ContractId;
37
+ requester: ActorId;
39
38
  message?: string;
40
39
  includeDirty: boolean;
41
40
  materializeConflict: boolean;
@@ -48,8 +47,8 @@ export declare function executeForwardedDeliver(input: Readonly<{
48
47
  }>>;
49
48
  export declare function executeForwardedReview(input: Readonly<{
50
49
  repo: Repo;
51
- contractId: string;
52
- requester: string;
50
+ contractId: ContractId;
51
+ requester: ActorId;
53
52
  verdict: AttestationVerdict;
54
53
  summary?: string;
55
54
  hooks: Parameters<typeof executeLocalReview>[0]["hooks"];
@@ -59,12 +58,12 @@ export declare function executeForwardedReview(input: Readonly<{
59
58
  }>>;
60
59
  export declare function executeForwardedAudit(input: Readonly<{
61
60
  repo: Repo;
62
- contractId: string;
63
- requester: string;
61
+ contractId: ContractId;
62
+ requester: ActorId;
64
63
  includeDirty: boolean;
65
64
  showDiff: boolean;
66
65
  requireBranchesToBeUpToDate: boolean;
67
- hooks: AuditInput["hooks"];
66
+ hooks: NonNullable<AuditComposition["hooks"]>;
68
67
  signal?: AbortSignal;
69
68
  }>): Promise<Readonly<{
70
69
  result: MutationResult<AuditReport>;
@@ -1,14 +1,12 @@
1
1
  import { decodeContractDocument } from "../body/decode.js";
2
- import { contractId } from "../core/facts/types.js";
3
2
  import { withGitDecodeChannel } from "../git/read-observation.js";
4
3
  import { deliverOperation } from "../protocol/deliver.js";
5
4
  import { reviewOperation } from "../protocol/review.js";
6
5
  import { auditContract } from "./audit.js";
7
6
  import { continueAcceptedCompletion } from "./continuation.js";
8
- import { actorOption, documentDerivation, invalidInput, optionalNonblank } from "./input.js";
7
+ import { documentDerivation } from "./input.js";
9
8
  import { completionInput, completeMutation } from "./mutation.js";
10
9
  import { requireAccepted } from "./refusal.js";
11
- import { auditReportSchema, auditResultSchema, deliveryResultSchema, reviewResultSchema, } from "./contract-forwarding-result.js";
12
10
  import { scopeForRepo } from "./repo.js";
13
11
  function derivedDocument(state) {
14
12
  return documentDerivation(decodeContractDocument(state.terms.document.bytes), state.terms.gates, state.id);
@@ -65,14 +63,11 @@ export async function executeLocalReview(input) {
65
63
  });
66
64
  }
67
65
  export async function executeForwardedDeliver(input) {
68
- const id = contractId(input.contractId);
69
- const actor = actorOption(input.requester).actor;
70
- const message = optionalNonblank(input.message, "deliver message");
71
66
  const result = await executeLocalDelivery({
72
67
  scope: scopeForRepo(input.repo),
73
- contractId: id,
74
- ...(actor === undefined ? {} : { actor }),
75
- ...(message === undefined ? {} : { message }),
68
+ contractId: input.contractId,
69
+ actor: input.requester,
70
+ ...(input.message === undefined ? {} : { message: input.message }),
76
71
  requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
77
72
  includeDirty: input.includeDirty,
78
73
  materializeConflict: input.materializeConflict,
@@ -80,46 +75,40 @@ export async function executeForwardedDeliver(input) {
80
75
  hooks: input.hooks,
81
76
  });
82
77
  if (!("facts" in result))
83
- return { result: deliveryResultSchema.parse(result) };
78
+ return { result };
84
79
  const delivery = result.facts.find((fact) => fact.kind === "deliver");
85
80
  if (delivery === undefined)
86
81
  throw new Error("accepted delivery is missing its journal fact");
87
- return { result: deliveryResultSchema.parse(result), deliveryFactId: delivery.entry };
82
+ return { result, deliveryFactId: delivery.entry };
88
83
  }
89
84
  export async function executeForwardedReview(input) {
90
- const id = contractId(input.contractId);
91
- const actor = actorOption(input.requester).actor;
92
- if (input.verdict !== "satisfied" && input.verdict !== "unsatisfied") {
93
- invalidInput("verdict must be satisfied or unsatisfied");
94
- }
95
- const summary = optionalNonblank(input.summary, "review summary");
96
85
  const result = await executeLocalReview({
97
86
  scope: scopeForRepo(input.repo),
98
- contractId: id,
99
- ...(actor === undefined ? {} : { actor }),
87
+ contractId: input.contractId,
88
+ actor: input.requester,
100
89
  verdict: input.verdict,
101
- ...(summary === undefined ? {} : { summary }),
90
+ ...(input.summary === undefined ? {} : { summary: input.summary }),
102
91
  hooks: input.hooks,
103
92
  });
104
93
  const review = result.facts.find((fact) => fact.kind === "attestation");
105
94
  if (review === undefined)
106
95
  throw new Error("accepted review is missing its journal fact");
107
- return { result: reviewResultSchema.parse(result), reviewFactId: review.entry };
96
+ return { result, reviewFactId: review.entry };
108
97
  }
109
98
  export async function executeForwardedAudit(input) {
110
- const id = contractId(input.contractId);
111
- const actor = actorOption(input.requester).actor;
112
99
  const result = await auditContract({
113
100
  scope: scopeForRepo(input.repo),
114
- contractId: id,
101
+ contractId: input.contractId,
115
102
  input: {
116
- ...(actor === undefined ? {} : { actor }),
117
103
  includeDirty: input.includeDirty,
118
104
  showDiff: input.showDiff,
119
- requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
120
- ...(input.hooks === undefined ? {} : { hooks: input.hooks }),
121
105
  ...(input.signal === undefined ? {} : { signal: input.signal }),
122
106
  },
107
+ composition: {
108
+ actor: input.requester,
109
+ hooks: input.hooks,
110
+ requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
111
+ },
123
112
  });
124
- return { result: auditResultSchema.parse(result), auditReport: auditReportSchema.parse(result.value) };
113
+ return { result, auditReport: result.value };
125
114
  }
@@ -9,12 +9,14 @@ import { Delivery } from "./delivery.js";
9
9
  import { type MutationResult } from "./mutation.js";
10
10
  import type { AbandonInput, AmendInput, AmendResult, ArcInput, DeliverInput, ReconcileReport, ReviewInput, ContractHistory } from "./contract-types.js";
11
11
  import { type Review as OperationReview } from "./contract-operations.js";
12
+ import type { LocalContractCompositionCapture } from "./contract.js";
12
13
  type Review = OperationReview;
13
14
  export declare class KeiyakuHandle {
14
15
  private readonly id;
15
16
  private readonly scope;
16
17
  private readonly execution;
17
- constructor(id: ContractId, scope: RepositoryScope, execution?: ExecutionContext);
18
+ private readonly composition;
19
+ constructor(id: ContractId, scope: RepositoryScope, execution: ExecutionContext | undefined, composition: LocalContractCompositionCapture);
18
20
  state(): Promise<ContractState>;
19
21
  history(): Promise<ContractHistory>;
20
22
  guidance(): Promise<string>;
@@ -28,10 +28,12 @@ export class KeiyakuHandle {
28
28
  id;
29
29
  scope;
30
30
  execution;
31
- constructor(id, scope, execution = localExecutionContext()) {
31
+ composition;
32
+ constructor(id, scope, execution = localExecutionContext(), composition) {
32
33
  this.id = id;
33
34
  this.scope = scope;
34
35
  this.execution = execution;
36
+ this.composition = composition;
35
37
  KEIYAKU_SEATS.set(this, { id, scope });
36
38
  }
37
39
  async state() {
@@ -147,26 +149,25 @@ export class KeiyakuHandle {
147
149
  };
148
150
  }
149
151
  async deliver(input) {
150
- const values = input === undefined ? undefined : requireInput(input, "deliver input");
151
- const hooks = worktreeHooksOption(values?.hooks);
152
+ const values = input === undefined
153
+ ? undefined
154
+ : requireInput(input, "deliver input", ["message", "includeDirty", "materializeConflict", "signal"]);
152
155
  const message = optionalNonblank(values?.message, "deliver message");
153
- const requireBranchesToBeUpToDate = optionalBoolean(values?.requireBranchesToBeUpToDate, "requireBranchesToBeUpToDate") ?? false;
154
156
  const includeDirty = optionalBoolean(values?.includeDirty, "includeDirty") ?? false;
155
157
  const materializeConflict = optionalBoolean(values?.materializeConflict, "materializeConflict") ?? false;
156
- const actor = actorOption(values?.actor);
157
158
  const signal = optionalSignal(values?.signal);
158
159
  const channel = executionChannel(this.execution);
159
160
  const result = channel.kind === "local"
160
161
  ? await executeLocalDelivery({
161
162
  scope: this.scope,
162
163
  contractId: this.id,
163
- ...actor,
164
+ ...(this.composition.actor === undefined ? {} : { actor: this.composition.actor }),
164
165
  ...(message === undefined ? {} : { message }),
165
- requireBranchesToBeUpToDate,
166
+ requireBranchesToBeUpToDate: this.composition.requireBranchesToBeUpToDate,
166
167
  includeDirty,
167
168
  materializeConflict,
168
169
  ...(signal === undefined ? {} : { signal }),
169
- hooks,
170
+ hooks: this.composition.hooks,
170
171
  })
171
172
  : await requestForwardedContractLive({
172
173
  directory: channel.directory,
@@ -184,14 +185,12 @@ export class KeiyakuHandle {
184
185
  return "facts" in result ? { ...result, value: this.deliveryHandle(result.value) } : result;
185
186
  }
186
187
  async review(input) {
187
- const values = requireInput(input, "review input");
188
- const hooks = worktreeHooksOption(values.hooks);
188
+ const values = requireInput(input, "review input", ["verdict", "summary"]);
189
189
  const verdict = values.verdict;
190
190
  if (verdict !== "satisfied" && verdict !== "unsatisfied") {
191
191
  return invalidInput("verdict must be satisfied or unsatisfied");
192
192
  }
193
193
  const summary = optionalNonblank(values.summary, "review summary");
194
- const actor = actorOption(values.actor);
195
194
  const channel = executionChannel(this.execution);
196
195
  if (channel.kind === "body-request") {
197
196
  return await requestForwardedContractLive({
@@ -209,10 +208,10 @@ export class KeiyakuHandle {
209
208
  return await executeLocalReview({
210
209
  scope: this.scope,
211
210
  contractId: this.id,
212
- ...actor,
211
+ ...(this.composition.actor === undefined ? {} : { actor: this.composition.actor }),
213
212
  verdict,
214
213
  ...(summary === undefined ? {} : { summary }),
215
- hooks,
214
+ hooks: this.composition.hooks,
216
215
  });
217
216
  }
218
217
  async abandon(input) {
@@ -258,15 +257,17 @@ export class KeiyakuHandle {
258
257
  });
259
258
  }
260
259
  async audit(input) {
260
+ const values = input === undefined ? undefined : requireInput(input, "audit input", ["includeDirty", "showDiff", "signal"]);
261
+ const includeDirty = optionalBoolean(values?.includeDirty, "includeDirty") ?? false;
262
+ const showDiff = optionalBoolean(values?.showDiff, "showDiff") ?? false;
263
+ const signal = optionalSignal(values?.signal);
264
+ const auditInput = {
265
+ includeDirty,
266
+ showDiff,
267
+ ...(signal === undefined ? {} : { signal }),
268
+ };
261
269
  const channel = executionChannel(this.execution);
262
270
  if (channel.kind === "body-request") {
263
- const values = input === undefined ? undefined : requireInput(input, "audit input");
264
- worktreeHooksOption(values?.hooks);
265
- actorOption(values?.actor);
266
- const includeDirty = optionalBoolean(values?.includeDirty, "includeDirty") ?? false;
267
- const showDiff = optionalBoolean(values?.showDiff, "showDiff") ?? false;
268
- const requireBranchesToBeUpToDate = optionalBoolean(values?.requireBranchesToBeUpToDate, "requireBranchesToBeUpToDate") ?? false;
269
- const signal = optionalSignal(values?.signal);
270
271
  return await requestForwardedContractLive({
271
272
  directory: channel.directory,
272
273
  action: "contract.audit",
@@ -276,7 +277,6 @@ export class KeiyakuHandle {
276
277
  contractId: this.id,
277
278
  includeDirty,
278
279
  showDiff,
279
- requireBranchesToBeUpToDate,
280
280
  },
281
281
  ...(signal === undefined ? {} : { signal }),
282
282
  });
@@ -284,7 +284,8 @@ export class KeiyakuHandle {
284
284
  return auditContract({
285
285
  scope: this.scope,
286
286
  contractId: this.id,
287
- ...(input === undefined ? {} : { input }),
287
+ input: auditInput,
288
+ composition: this.composition,
288
289
  });
289
290
  }
290
291
  async reconcile(input) {