@abelxiaoxing/cadence 1.3.0 → 1.4.0

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 (45) hide show
  1. package/README.md +115 -10
  2. package/package.json +5 -3
  3. package/prompts/abel-design.md +71 -17
  4. package/prompts/abel-diagnose.md +10 -1
  5. package/prompts/abel-implement.md +118 -20
  6. package/prompts/abel-init.md +9 -2
  7. package/src/apply-transaction.ts +16 -14
  8. package/src/artifact-store.ts +17 -0
  9. package/src/candidate-patch.ts +2 -1
  10. package/src/canonical.ts +16 -0
  11. package/src/change-contract.ts +268 -0
  12. package/src/child-session.ts +4 -3
  13. package/src/contracts.ts +141 -33
  14. package/src/control-contracts.ts +51 -1
  15. package/src/delivery-compiler.ts +148 -31
  16. package/src/design-control.ts +69 -11
  17. package/src/design-journal.ts +216 -72
  18. package/src/durable-workflow.ts +4385 -0
  19. package/src/implement-graph.ts +11 -16
  20. package/src/index.ts +380 -981
  21. package/src/isolation-backend.ts +84 -23
  22. package/src/package-delivery.ts +486 -0
  23. package/src/package-verification.ts +509 -0
  24. package/src/route-policy.ts +1 -11
  25. package/src/run-state.ts +4 -16
  26. package/src/run-store.ts +5 -144
  27. package/src/scoped-grep-worker.mjs +23 -0
  28. package/src/scoped-tools.ts +312 -116
  29. package/src/sqlite-schema.ts +171 -0
  30. package/src/storage-schema.ts +352 -0
  31. package/src/subagent-activity.ts +14 -1
  32. package/src/submit-tool.ts +20 -2
  33. package/src/task-ledger.ts +14 -55
  34. package/src/verification-capability.ts +298 -102
  35. package/src/verification-environment.ts +213 -0
  36. package/src/verification-identity.ts +77 -0
  37. package/src/worker-broker.ts +97 -34
  38. package/src/workflow-engine.ts +28 -8285
  39. package/src/workflow-policy.ts +1427 -0
  40. package/src/workflow-state-machine.ts +4478 -0
  41. package/src/workspace-io-entry.mjs +58 -0
  42. package/src/workspace-io-worker.mjs +984 -0
  43. package/src/workspace-io.ts +84 -0
  44. package/src/workspace-store.ts +125 -19
  45. package/skills/abel-workflow/SKILL.md +0 -205
@@ -0,0 +1,58 @@
1
+ import { parentPort, workerData } from "node:worker_threads";
2
+ import { ArtifactStore } from "./artifact-store.ts";
3
+ import { verificationEnvironmentDigest } from "./verification-identity.ts";
4
+ import { WorkspaceStore } from "./workspace-store.ts";
5
+
6
+ const controller = new AbortController();
7
+ const flag = new Int32Array(workerData.cancelled);
8
+ parentPort.on("message", () => controller.abort(new Error("cancelled")));
9
+ const checkCancelled = () => {
10
+ if (Atomics.load(flag, 0)) throw new Error("cancelled");
11
+ };
12
+ try {
13
+ if (workerData.operation === "verificationIdentity") {
14
+ const result = verificationEnvironmentDigest(
15
+ workerData.args[0],
16
+ checkCancelled,
17
+ );
18
+ parentPort.postMessage({ ok: true, result, files: 0, bytes: 0 });
19
+ } else {
20
+ const artifacts = new ArtifactStore(workerData.artifactRoot);
21
+ const store = new WorkspaceStore(workerData.root, artifacts, {
22
+ checkCancelled,
23
+ });
24
+ let result;
25
+ let revision;
26
+ checkCancelled();
27
+ if (workerData.operation === "captureBaseline") {
28
+ revision = await store.captureBaselineWithGit(
29
+ workerData.args[0],
30
+ controller.signal,
31
+ );
32
+ result = revision;
33
+ } else if (workerData.operation === "materialize") {
34
+ revision = store.getRevision(workerData.args[0]);
35
+ store.materialize(workerData.args[0], workerData.args[1]);
36
+ } else {
37
+ throw new Error("workspace-io-operation-invalid");
38
+ }
39
+ const files = Object.values(revision.entries).filter(
40
+ (entry) => entry.kind === "file",
41
+ );
42
+ parentPort.postMessage({
43
+ ok: true,
44
+ result,
45
+ files: files.length,
46
+ bytes: files.reduce((sum, entry) => sum + entry.bytes, 0),
47
+ });
48
+ }
49
+ } catch (error) {
50
+ parentPort.postMessage({
51
+ ok: false,
52
+ error: error instanceof Error ? error.message : "workspace-io-failed",
53
+ files: 0,
54
+ bytes: 0,
55
+ });
56
+ } finally {
57
+ parentPort.close();
58
+ }