@abelxiaoxing/cadence 1.8.4 → 2.0.1

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 (202) hide show
  1. package/README.md +324 -117
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/agents/design-explorer.md +14 -18
  4. package/agents/diagnosis-worker.md +14 -14
  5. package/agents/implementation-worker.md +16 -17
  6. package/config/workflow-task.example.json +7 -0
  7. package/docs/remote-access.md +60 -0
  8. package/docs/reuse-and-distribution.md +44 -0
  9. package/docs/service-management.md +108 -0
  10. package/licenses/bundled-web.txt +6245 -0
  11. package/licenses/pi-web-ui-MIT.txt +21 -0
  12. package/licenses/pi-web-ui-reuse.md +22 -0
  13. package/package.json +92 -20
  14. package/src/index.ts +21 -1802
  15. package/src/native-build.ts +6 -0
  16. package/src/native-client.ts +103 -0
  17. package/src/native-export.ts +58 -0
  18. package/src/native-history.ts +359 -0
  19. package/src/operator-cli.mjs +453 -1937
  20. package/src/plan-proposal.ts +87 -0
  21. package/src/sdk-worker.mjs +549 -0
  22. package/src/service/contracts/active.ts +82 -0
  23. package/src/service/contracts/budget.ts +148 -0
  24. package/src/service/contracts/build.ts +67 -0
  25. package/src/service/contracts/capture.ts +48 -0
  26. package/src/service/contracts/core.ts +33 -0
  27. package/src/service/contracts/current.ts +261 -0
  28. package/src/service/contracts/domain.ts +68 -0
  29. package/src/service/contracts/history.ts +2245 -0
  30. package/src/service/contracts/models.ts +139 -0
  31. package/src/service/coordination.ts +862 -0
  32. package/src/service/private-files.ts +204 -0
  33. package/src/service-cli.mjs +5592 -0
  34. package/src/service-client.ts +747 -0
  35. package/src/service-contract.ts +245 -0
  36. package/src/service-host.mjs +22382 -0
  37. package/src/service-http-client.ts +425 -0
  38. package/src/service-wire.ts +372 -0
  39. package/src/task-shell.ts +1045 -0
  40. package/src/task-store.ts +479 -0
  41. package/src/task-types.ts +184 -0
  42. package/src/verification-diagnostics.ts +29 -72
  43. package/src/worker-capture.mjs +1197 -0
  44. package/src/worker-public.mjs +1753 -0
  45. package/src/worker-redaction.mjs +608 -0
  46. package/src/worker-tools.mjs +202 -0
  47. package/web/dist/assets/KaTeX_AMS-Regular.ttf +0 -0
  48. package/web/dist/assets/KaTeX_AMS-Regular.woff +0 -0
  49. package/web/dist/assets/KaTeX_AMS-Regular.woff2 +0 -0
  50. package/web/dist/assets/KaTeX_Caligraphic-Bold.ttf +0 -0
  51. package/web/dist/assets/KaTeX_Caligraphic-Bold.woff +0 -0
  52. package/web/dist/assets/KaTeX_Caligraphic-Bold.woff2 +0 -0
  53. package/web/dist/assets/KaTeX_Caligraphic-Regular.ttf +0 -0
  54. package/web/dist/assets/KaTeX_Caligraphic-Regular.woff +0 -0
  55. package/web/dist/assets/KaTeX_Caligraphic-Regular.woff2 +0 -0
  56. package/web/dist/assets/KaTeX_Fraktur-Bold.ttf +0 -0
  57. package/web/dist/assets/KaTeX_Fraktur-Bold.woff +0 -0
  58. package/web/dist/assets/KaTeX_Fraktur-Bold.woff2 +0 -0
  59. package/web/dist/assets/KaTeX_Fraktur-Regular.ttf +0 -0
  60. package/web/dist/assets/KaTeX_Fraktur-Regular.woff +0 -0
  61. package/web/dist/assets/KaTeX_Fraktur-Regular.woff2 +0 -0
  62. package/web/dist/assets/KaTeX_Main-Bold.ttf +0 -0
  63. package/web/dist/assets/KaTeX_Main-Bold.woff +0 -0
  64. package/web/dist/assets/KaTeX_Main-Bold.woff2 +0 -0
  65. package/web/dist/assets/KaTeX_Main-BoldItalic.ttf +0 -0
  66. package/web/dist/assets/KaTeX_Main-BoldItalic.woff +0 -0
  67. package/web/dist/assets/KaTeX_Main-BoldItalic.woff2 +0 -0
  68. package/web/dist/assets/KaTeX_Main-Italic.ttf +0 -0
  69. package/web/dist/assets/KaTeX_Main-Italic.woff +0 -0
  70. package/web/dist/assets/KaTeX_Main-Italic.woff2 +0 -0
  71. package/web/dist/assets/KaTeX_Main-Regular.ttf +0 -0
  72. package/web/dist/assets/KaTeX_Main-Regular.woff +0 -0
  73. package/web/dist/assets/KaTeX_Main-Regular.woff2 +0 -0
  74. package/web/dist/assets/KaTeX_Math-BoldItalic.ttf +0 -0
  75. package/web/dist/assets/KaTeX_Math-BoldItalic.woff +0 -0
  76. package/web/dist/assets/KaTeX_Math-BoldItalic.woff2 +0 -0
  77. package/web/dist/assets/KaTeX_Math-Italic.ttf +0 -0
  78. package/web/dist/assets/KaTeX_Math-Italic.woff +0 -0
  79. package/web/dist/assets/KaTeX_Math-Italic.woff2 +0 -0
  80. package/web/dist/assets/KaTeX_SansSerif-Bold.ttf +0 -0
  81. package/web/dist/assets/KaTeX_SansSerif-Bold.woff +0 -0
  82. package/web/dist/assets/KaTeX_SansSerif-Bold.woff2 +0 -0
  83. package/web/dist/assets/KaTeX_SansSerif-Italic.ttf +0 -0
  84. package/web/dist/assets/KaTeX_SansSerif-Italic.woff +0 -0
  85. package/web/dist/assets/KaTeX_SansSerif-Italic.woff2 +0 -0
  86. package/web/dist/assets/KaTeX_SansSerif-Regular.ttf +0 -0
  87. package/web/dist/assets/KaTeX_SansSerif-Regular.woff +0 -0
  88. package/web/dist/assets/KaTeX_SansSerif-Regular.woff2 +0 -0
  89. package/web/dist/assets/KaTeX_Script-Regular.ttf +0 -0
  90. package/web/dist/assets/KaTeX_Script-Regular.woff +0 -0
  91. package/web/dist/assets/KaTeX_Script-Regular.woff2 +0 -0
  92. package/web/dist/assets/KaTeX_Size1-Regular.ttf +0 -0
  93. package/web/dist/assets/KaTeX_Size1-Regular.woff +0 -0
  94. package/web/dist/assets/KaTeX_Size1-Regular.woff2 +0 -0
  95. package/web/dist/assets/KaTeX_Size2-Regular.ttf +0 -0
  96. package/web/dist/assets/KaTeX_Size2-Regular.woff +0 -0
  97. package/web/dist/assets/KaTeX_Size2-Regular.woff2 +0 -0
  98. package/web/dist/assets/KaTeX_Size3-Regular.ttf +0 -0
  99. package/web/dist/assets/KaTeX_Size3-Regular.woff +0 -0
  100. package/web/dist/assets/KaTeX_Size3-Regular.woff2 +0 -0
  101. package/web/dist/assets/KaTeX_Size4-Regular.ttf +0 -0
  102. package/web/dist/assets/KaTeX_Size4-Regular.woff +0 -0
  103. package/web/dist/assets/KaTeX_Size4-Regular.woff2 +0 -0
  104. package/web/dist/assets/KaTeX_Typewriter-Regular.ttf +0 -0
  105. package/web/dist/assets/KaTeX_Typewriter-Regular.woff +0 -0
  106. package/web/dist/assets/KaTeX_Typewriter-Regular.woff2 +0 -0
  107. package/web/dist/assets/cadence.css +2 -0
  108. package/web/dist/assets/cadence.js +7 -0
  109. package/web/dist/assets/markdown.js +296 -0
  110. package/web/dist/assets/react.js +9 -0
  111. package/web/dist/assets/rolldown-runtime.js +1 -0
  112. package/web/dist/assets/timeline-client.js +41 -0
  113. package/web/dist/assets/vis-timeline.css +1274 -0
  114. package/web/dist/assets/vis-timeline.js +32 -0
  115. package/web/dist/index.html +18 -0
  116. package/web/dist/manifest.json +505 -0
  117. package/config/plan-draft.example.json +0 -125
  118. package/config/plan-draft.multiple-tasks.example.json +0 -375
  119. package/config/plan-draft.quick.example.json +0 -78
  120. package/prompts/abel-design.md +0 -382
  121. package/prompts/abel-diagnose.md +0 -71
  122. package/prompts/abel-implement.md +0 -284
  123. package/prompts/abel-init.md +0 -52
  124. package/src/activation.ts +0 -44
  125. package/src/activity-contracts.ts +0 -82
  126. package/src/agent-registry.ts +0 -53
  127. package/src/apply-transaction.ts +0 -1437
  128. package/src/artifact-store.ts +0 -213
  129. package/src/build-windows-job.mjs +0 -95
  130. package/src/candidate-artifact.ts +0 -143
  131. package/src/candidate-context.ts +0 -289
  132. package/src/candidate-patch.ts +0 -271
  133. package/src/candidate-workspace.ts +0 -80
  134. package/src/canonical.ts +0 -16
  135. package/src/change-contract-schema.ts +0 -191
  136. package/src/change-contract.ts +0 -324
  137. package/src/change-verification.ts +0 -1617
  138. package/src/contracts.ts +0 -2466
  139. package/src/control-contracts.ts +0 -382
  140. package/src/delivery-compiler.ts +0 -1805
  141. package/src/delivery-revision.ts +0 -42
  142. package/src/design-control.ts +0 -1299
  143. package/src/design-diagnostics.ts +0 -181
  144. package/src/design-journal.ts +0 -1773
  145. package/src/directory-sync.ts +0 -36
  146. package/src/durable-contracts.ts +0 -227
  147. package/src/durable-workflow.ts +0 -822
  148. package/src/evidence-draft.ts +0 -122
  149. package/src/execution-profile.ts +0 -64
  150. package/src/execution-retention.ts +0 -77
  151. package/src/file-snapshot.ts +0 -163
  152. package/src/implement-continuation.ts +0 -559
  153. package/src/implement-graph.ts +0 -690
  154. package/src/implement-plan.ts +0 -72
  155. package/src/install-config.d.mts +0 -6
  156. package/src/isolation-backend.ts +0 -353
  157. package/src/model-source.ts +0 -22
  158. package/src/openspec-cli.ts +0 -494
  159. package/src/operator-cli-entry.mjs +0 -24
  160. package/src/operator-tools.ts +0 -309
  161. package/src/package-candidate-process.ts +0 -206
  162. package/src/package-candidate.ts +0 -24
  163. package/src/package-delivery.ts +0 -486
  164. package/src/package-state.ts +0 -320
  165. package/src/package-verification.ts +0 -635
  166. package/src/package-workflow.ts +0 -305
  167. package/src/packet-runtime.ts +0 -459
  168. package/src/phase-execution.ts +0 -2163
  169. package/src/pi-adapter.ts +0 -19
  170. package/src/plan-draft-summary.ts +0 -527
  171. package/src/plan-draft.ts +0 -502
  172. package/src/remove-path.ts +0 -32
  173. package/src/run-state.ts +0 -420
  174. package/src/run-store.ts +0 -1179
  175. package/src/safe-path.ts +0 -77
  176. package/src/scoped-grep-worker.mjs +0 -23
  177. package/src/scoped-tools.ts +0 -775
  178. package/src/single-task-draft.ts +0 -142
  179. package/src/sqlite-schema.ts +0 -171
  180. package/src/state-root.ts +0 -215
  181. package/src/storage-schema.ts +0 -360
  182. package/src/subagent-activity.ts +0 -1417
  183. package/src/subagent-process.ts +0 -476
  184. package/src/task-ledger.ts +0 -1338
  185. package/src/transport-budget.ts +0 -50
  186. package/src/verification-capability.ts +0 -1191
  187. package/src/verification-environment-io.ts +0 -389
  188. package/src/verification-environment.ts +0 -162
  189. package/src/verification-identity.ts +0 -77
  190. package/src/verification-scan.ts +0 -64
  191. package/src/windows-job-backend.ts +0 -419
  192. package/src/windows-job.c +0 -149
  193. package/src/workflow-engine.ts +0 -28
  194. package/src/workflow-policy.ts +0 -1670
  195. package/src/workflow-recovery-policy.ts +0 -97
  196. package/src/workflow-scheduling.ts +0 -105
  197. package/src/workflow-state-machine.ts +0 -4341
  198. package/src/workflow-status.ts +0 -576
  199. package/src/workspace-io-entry.mjs +0 -76
  200. package/src/workspace-io-worker.mjs +0 -1312
  201. package/src/workspace-io.ts +0 -89
  202. package/src/workspace-store.ts +0 -634
@@ -1,305 +0,0 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- import path from "node:path";
3
- import type { WorkflowActivityUpdate } from "./activity-contracts.ts";
4
- import { loadAgentDefinitions } from "./agent-registry.ts";
5
- import type {
6
- DesignEvidenceResult,
7
- StructuredVerificationContract,
8
- } from "./contracts.ts";
9
- import { validateControlCommand } from "./control-contracts.ts";
10
- import { DesignController } from "./design-control.ts";
11
- import { executionProfile } from "./execution-profile.ts";
12
- import type { PackageContext } from "./model-source.ts";
13
- import { inspectOpenSpecDelivery } from "./openspec-cli.ts";
14
- import { proposePackageCandidate } from "./package-candidate.ts";
15
- import { packageDeliverySource } from "./package-delivery.ts";
16
- import { acquirePackageState } from "./package-state.ts";
17
- import {
18
- changeVerificationResult,
19
- executePackageVerification,
20
- phaseVerificationResult,
21
- } from "./package-verification.ts";
22
- import { resolveStateRoot } from "./state-root.ts";
23
- import { VerificationFeedback } from "./verification-diagnostics.ts";
24
- import { captureVerificationEnvironmentIdentity } from "./verification-environment.ts";
25
- import { coalesceVerificationScans } from "./verification-scan.ts";
26
- import { openDurableWorkflowEngine } from "./workflow-engine.ts";
27
- export interface PackageWorkflowService {
28
- execute(
29
- command: unknown,
30
- context?: PackageContext,
31
- signal?: AbortSignal,
32
- onActivity?: (event: WorkflowActivityUpdate) => void,
33
- ): Promise<Record<string, unknown>>;
34
- executeDesign(request: unknown): Promise<Record<string, unknown>>;
35
- executeAmendment(
36
- change: string,
37
- batchId: string,
38
- request: unknown,
39
- ): Promise<Record<string, unknown>>;
40
- assertDesignRun(runId: string): void;
41
- recordDesignEvidence(input: {
42
- runId: string;
43
- evidence: DesignEvidenceResult;
44
- }): unknown;
45
- close(): void | Promise<void>;
46
- }
47
-
48
- function affectedVerification(
49
- task: Parameters<
50
- Parameters<typeof openDurableWorkflowEngine>[0]["proposeCandidate"]
51
- >[0]["task"],
52
- ): StructuredVerificationContract {
53
- if (task.affectedVerification) {
54
- return structuredClone(task.affectedVerification);
55
- }
56
- const finalPhase = task.phases.refactor ?? task.phases.green;
57
- const verification = structuredClone(finalPhase.verification);
58
- const affected = [...new Set(task.impactClosure.affectedSuite)].sort();
59
- if (affected.length === 0) return verification;
60
- if (verification.kind === "vitest") {
61
- return { ...verification, testFiles: affected };
62
- }
63
- if (verification.kind === "steps") {
64
- return {
65
- ...verification,
66
- steps: verification.steps.map((step) =>
67
- step.kind === "vitest" ? { ...step, testFiles: affected } : step,
68
- ),
69
- };
70
- }
71
- return verification;
72
- }
73
-
74
- export function openPackageWorkflowService(
75
- initialContext: PackageContext,
76
- ): PackageWorkflowService {
77
- const state = acquirePackageState(
78
- resolveStateRoot({
79
- consumerRoot: path.resolve(initialContext.cwd),
80
- xdgStateHome: process.env.XDG_STATE_HOME,
81
- }),
82
- );
83
- try {
84
- const service = openPreparedPackageWorkflowService(initialContext);
85
- const notice = (result: Record<string, unknown>) =>
86
- state.notice ? { ...result, packageStateReset: state.notice } : result;
87
- return {
88
- ...service,
89
- async execute(...args) {
90
- return notice(await service.execute(...args));
91
- },
92
- async executeDesign(...args) {
93
- return notice(await service.executeDesign(...args));
94
- },
95
- async executeAmendment(...args) {
96
- return notice(await service.executeAmendment(...args));
97
- },
98
- async close() {
99
- // Never release ownership while an executor or storage connection may survive.
100
- await service.close();
101
- state.close();
102
- },
103
- };
104
- } catch (error) {
105
- state.close();
106
- throw error;
107
- }
108
- }
109
-
110
- function openPreparedPackageWorkflowService(
111
- initialContext: PackageContext,
112
- ): PackageWorkflowService {
113
- const consumerRoot = path.resolve(initialContext.cwd);
114
- const stateRoot = resolveStateRoot({
115
- consumerRoot,
116
- xdgStateHome: process.env.XDG_STATE_HOME,
117
- });
118
- const contexts = new AsyncLocalStorage<PackageContext>();
119
- const feedback = new AsyncLocalStorage<VerificationFeedback>();
120
- const verify: typeof executePackageVerification = async (input) => {
121
- const result = await executePackageVerification(input);
122
- feedback.getStore()?.observe(result);
123
- return result;
124
- };
125
- const design = DesignController.open({
126
- consumerRoot,
127
- stateRoot,
128
- inspectOpenSpec: inspectOpenSpecDelivery,
129
- });
130
- try {
131
- const implementationAgent = loadAgentDefinitions().find(
132
- (agent) => agent.role === "implementation-worker",
133
- );
134
- if (!implementationAgent) {
135
- throw new Error("implementation-worker-agent-unavailable");
136
- }
137
- const hostLimit = (name: string, fallback: number): number => {
138
- const value =
139
- process.env[name] === undefined ? fallback : Number(process.env[name]);
140
- if (!Number.isSafeInteger(value) || value < 1)
141
- throw new Error("verification-host-limit-invalid");
142
- return value;
143
- };
144
- const maxReportBytes = hostLimit(
145
- "ABEL_VERIFICATION_MAX_REPORT_BYTES",
146
- 64 * 1024 * 1024,
147
- );
148
- const workHardLimit = hostLimit("ABEL_WORK_MAX_UNITS", 512);
149
- const engine = openDurableWorkflowEngine({
150
- workHardLimit,
151
- awaitPostApplySettlement: true,
152
- verificationPolicy: `report-file-v5:${JSON.stringify(executionProfile())}`,
153
- verificationEnvironment: coalesceVerificationScans(
154
- (plan: import("./implement-plan.ts").ImplementPlan, signal) =>
155
- captureVerificationEnvironmentIdentity(
156
- consumerRoot,
157
- [
158
- ...plan.tasks.flatMap((task) => [
159
- ...Object.values(task.phases).map(
160
- (phase) => phase.verification,
161
- ),
162
- task.affectedVerification,
163
- ...(task.baselineVerification
164
- ? [task.baselineVerification]
165
- : []),
166
- task.repairVerification,
167
- ]),
168
- plan.verification.baseline.fullSuite,
169
- plan.verification.change.fullSuite,
170
- plan.verification.change.postApply,
171
- ...(plan.verification.agentsCheckpoint.verification
172
- ? [plan.verification.agentsCheckpoint.verification]
173
- : []),
174
- ],
175
- signal,
176
- ),
177
- ),
178
- consumerRoot,
179
- stateRoot,
180
- deliverySource: packageDeliverySource(consumerRoot, {
181
- verifyGateProof: (input) => design.verifyGateProof(input),
182
- verifyFinalizedDelivery: (input) =>
183
- design.verifyFinalizedDelivery(input),
184
- }),
185
- proposeCandidate: (input) =>
186
- proposePackageCandidate(
187
- input,
188
- contexts.getStore(),
189
- implementationAgent,
190
- feedback.getStore()?.current(),
191
- ),
192
- verifyPhase: async (input) =>
193
- phaseVerificationResult(
194
- await verify({
195
- maxReportBytes,
196
- executionWritePaths: input.executionWritePaths,
197
- root: input.root,
198
- dependencyOwner: consumerRoot,
199
- executionOwnerRoot: stateRoot.rootDir,
200
- verification: input.verification,
201
- signal: input.signal,
202
- }),
203
- ),
204
- verifyChange: async (input) => {
205
- const verifications = input.verification
206
- ? [input.verification]
207
- : input.plan.tasks.map((task) => affectedVerification(task));
208
- let failure: ReturnType<typeof changeVerificationResult> | undefined;
209
- for (const verification of verifications) {
210
- const result = await verify({
211
- maxReportBytes,
212
- executionWritePaths: input.plan.tasks.flatMap((task) =>
213
- Object.values(task.phases).flatMap((phase) => [
214
- ...phase.write,
215
- ...phase.delete,
216
- ]),
217
- ),
218
- root: input.root,
219
- dependencyOwner: consumerRoot,
220
- executionOwnerRoot: stateRoot.rootDir,
221
- verification,
222
- signal: input.signal,
223
- });
224
- const observed = changeVerificationResult(result);
225
- if (!observed.ok) {
226
- if (observed.kind !== "verification") return observed;
227
- if (failure && !failure.ok && failure.kind === "verification") {
228
- failure.failureIdentities = [
229
- ...new Set([
230
- ...(failure.failureIdentities ?? []),
231
- ...(observed.failureIdentities ?? []),
232
- ]),
233
- ];
234
- failure.attributionReliable =
235
- failure.attributionReliable !== false &&
236
- observed.attributionReliable !== false;
237
- } else failure = observed;
238
- }
239
- }
240
- if (failure) return failure;
241
- return {
242
- ok: true,
243
- exitCode: 0,
244
- classification: "expected-green",
245
- };
246
- },
247
- });
248
- return {
249
- async execute(
250
- command: unknown,
251
- context = initialContext,
252
- signal,
253
- onActivity,
254
- ) {
255
- const validation = validateControlCommand(command);
256
- if (!validation.ok) {
257
- const error = new Error(validation.code);
258
- error.name = "ControlCommandError";
259
- throw error;
260
- }
261
- return feedback.run(new VerificationFeedback(), () =>
262
- contexts.run(context, async () => {
263
- const outcome = await engine.execute(
264
- validation.value,
265
- signal,
266
- onActivity,
267
- );
268
- return {
269
- ...outcome,
270
- workerExecution: {
271
- mode: "inherited-pi-model",
272
- migration:
273
- "routes.json and endpoint routing were removed; configure the current model in Pi.",
274
- },
275
- verificationDiagnostics: feedback.getStore()?.current() ?? [],
276
- };
277
- }),
278
- );
279
- },
280
- executeDesign(request: unknown) {
281
- return design.execute(request);
282
- },
283
- executeAmendment(change: string, batchId: string, request: unknown) {
284
- return engine.amend(change, batchId, request, (assertAuthority) =>
285
- design.executeWithAuthority(request, assertAuthority),
286
- );
287
- },
288
- assertDesignRun(runId: string) {
289
- design.assertDesignRun(runId);
290
- },
291
- recordDesignEvidence(input) {
292
- return design.recordEvidence(input);
293
- },
294
- async close() {
295
- contexts.disable();
296
- await engine.close();
297
- feedback.disable();
298
- design.close();
299
- },
300
- };
301
- } catch (error) {
302
- design.close();
303
- throw error;
304
- }
305
- }