@mikenguyen69/harness 0.1.0-beta.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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +43 -0
  3. package/dist/build-identity.json +1 -0
  4. package/dist/cancellation.js +138 -0
  5. package/dist/cli.js +47 -0
  6. package/dist/dispatch.js +70 -0
  7. package/dist/help.js +47 -0
  8. package/dist/internal/agent/adapter/conformance.js +53 -0
  9. package/dist/internal/agent/adapter/hook.js +113 -0
  10. package/dist/internal/agent/adapter/install.js +30 -0
  11. package/dist/internal/agent/adapter/scope.js +55 -0
  12. package/dist/internal/agent/adapter/session.js +63 -0
  13. package/dist/internal/agent/adapter/settings.js +51 -0
  14. package/dist/internal/agent/cli.js +79 -0
  15. package/dist/internal/agent/evals/index.js +111 -0
  16. package/dist/internal/agent/index.js +15 -0
  17. package/dist/internal/agent/ledger-read.js +27 -0
  18. package/dist/internal/agent/routing/cli.js +104 -0
  19. package/dist/internal/agent/routing/index.js +123 -0
  20. package/dist/internal/agent/telemetry/index.js +97 -0
  21. package/dist/internal/orchestration/activity/index.js +111 -0
  22. package/dist/internal/orchestration/analyze/index.js +237 -0
  23. package/dist/internal/orchestration/cli.js +475 -0
  24. package/dist/internal/orchestration/config/index.js +66 -0
  25. package/dist/internal/orchestration/doctor/index.js +202 -0
  26. package/dist/internal/orchestration/forge/index.js +121 -0
  27. package/dist/internal/orchestration/git/index.js +181 -0
  28. package/dist/internal/orchestration/harness/cli.js +378 -0
  29. package/dist/internal/orchestration/harness/index.js +186 -0
  30. package/dist/internal/orchestration/harness/shim.js +182 -0
  31. package/dist/internal/orchestration/index.js +29 -0
  32. package/dist/internal/orchestration/loop/index.js +1107 -0
  33. package/dist/internal/orchestration/prompts/index.js +199 -0
  34. package/dist/internal/orchestration/report/index.js +125 -0
  35. package/dist/internal/orchestration/routes/index.js +85 -0
  36. package/dist/internal/orchestration/run/index.js +221 -0
  37. package/dist/internal/orchestration/runner/index.js +90 -0
  38. package/dist/internal/orchestration/runners/claude/index.js +246 -0
  39. package/dist/internal/orchestration/runners/claude/sdk.js +198 -0
  40. package/dist/internal/orchestration/runners/claude/wiring.js +98 -0
  41. package/dist/internal/orchestration/runners/codex/exec.js +114 -0
  42. package/dist/internal/orchestration/runners/codex/index.js +72 -0
  43. package/dist/internal/orchestration/runners/conformance/index.js +169 -0
  44. package/dist/internal/orchestration/runners/cursor/exec.js +531 -0
  45. package/dist/internal/orchestration/runners/cursor/index.js +184 -0
  46. package/dist/internal/orchestration/runners/stub/index.js +168 -0
  47. package/dist/internal/orchestration/runners/telemetry.js +36 -0
  48. package/dist/internal/orchestration/runstate/index.js +213 -0
  49. package/dist/internal/orchestration/runstate/publish.js +115 -0
  50. package/dist/internal/orchestration/worktree/index.js +89 -0
  51. package/dist/internal/system/adapters/index.js +19 -0
  52. package/dist/internal/system/agentops/index.js +16 -0
  53. package/dist/internal/system/agentops/scope.js +67 -0
  54. package/dist/internal/system/assets.js +45 -0
  55. package/dist/internal/system/board/cli.js +56 -0
  56. package/dist/internal/system/board/index.js +276 -0
  57. package/dist/internal/system/board/live.js +277 -0
  58. package/dist/internal/system/calibration/cli.js +45 -0
  59. package/dist/internal/system/calibration/index.js +141 -0
  60. package/dist/internal/system/cli.js +174 -0
  61. package/dist/internal/system/corpus/replay.js +79 -0
  62. package/dist/internal/system/digest/cli.js +23 -0
  63. package/dist/internal/system/digest/index.js +145 -0
  64. package/dist/internal/system/doors/classify.js +94 -0
  65. package/dist/internal/system/doors/cli.js +184 -0
  66. package/dist/internal/system/doors/index.js +249 -0
  67. package/dist/internal/system/doors/metrics.js +47 -0
  68. package/dist/internal/system/escapes/cli.js +45 -0
  69. package/dist/internal/system/escapes/index.js +81 -0
  70. package/dist/internal/system/explore/cli.js +77 -0
  71. package/dist/internal/system/explore/index.js +91 -0
  72. package/dist/internal/system/gates/cli.js +43 -0
  73. package/dist/internal/system/gates/detectors.js +55 -0
  74. package/dist/internal/system/gates/pre.js +51 -0
  75. package/dist/internal/system/hub/cli.js +51 -0
  76. package/dist/internal/system/hub/index.js +146 -0
  77. package/dist/internal/system/init/index.js +83 -0
  78. package/dist/internal/system/ledger/cli.js +54 -0
  79. package/dist/internal/system/ledger/index.js +176 -0
  80. package/dist/internal/system/manifest/index.js +207 -0
  81. package/dist/internal/system/provenance/index.js +13 -0
  82. package/dist/internal/system/report/index.js +15 -0
  83. package/dist/internal/system/runner/index.js +74 -0
  84. package/dist/internal/system/runstatus/cli.js +86 -0
  85. package/dist/internal/system/runstatus/index.js +168 -0
  86. package/dist/internal/system/sequencer/briefing.js +75 -0
  87. package/dist/internal/system/sequencer/cli.js +170 -0
  88. package/dist/internal/system/sequencer/index.js +156 -0
  89. package/dist/internal/system/spec/cli.js +110 -0
  90. package/dist/internal/system/spec/index.js +212 -0
  91. package/dist/internal/system/spec/materialize.js +111 -0
  92. package/dist/internal/system/spec/openspec-parse.js +83 -0
  93. package/dist/internal/system/spec/project.js +208 -0
  94. package/dist/internal/system/substrate/index.js +14 -0
  95. package/dist/internal/system/system/index.js +159 -0
  96. package/dist/internal/system/units/index.js +87 -0
  97. package/dist/internal/system/verify/cli.js +103 -0
  98. package/dist/internal/system/verify/declined-reasons.js +61 -0
  99. package/dist/internal/system/verify/index.js +188 -0
  100. package/dist/internal/system/verify/signing.js +79 -0
  101. package/dist/paths.js +50 -0
  102. package/dist/routes.js +93 -0
  103. package/dist/version.js +30 -0
  104. package/dist/win32-process-group.js +360 -0
  105. package/package.json +41 -0
  106. package/profiles/python/bindings.toml +59 -0
  107. package/profiles/terraform/bindings.toml +66 -0
  108. package/profiles/typescript/bindings.toml +64 -0
  109. package/profiles/typescript/smoke/README.md +8 -0
  110. package/schema/baseline.schema.json +26 -0
  111. package/schema/decision-classes.yaml +45 -0
  112. package/schema/envelope.schema.json +186 -0
  113. package/schema/ledger-event.schema.json +235 -0
  114. package/schema/manifest.schema.json +119 -0
  115. package/schema/routes.schema.json +55 -0
  116. package/schema/run-status.schema.json +162 -0
  117. package/schema/session-event.schema.json +74 -0
  118. package/schema/spec.schema.json +114 -0
  119. package/schema/system.schema.json +142 -0
  120. package/templates/ci/verify.yml +23 -0
  121. package/templates/target-kit/README.md +78 -0
  122. package/templates/target-kit/component.toml +20 -0
  123. package/templates/target-kit/orchestration.json +9 -0
  124. package/templates/target-kit/profiles/target/bindings.toml +6 -0
  125. package/templates/target-kit/routes.toml +5 -0
  126. package/templates/target-kit/specs/first-unit.yaml +11 -0
  127. package/templates/target-kit/system.toml +7 -0
@@ -0,0 +1,182 @@
1
+ /**
2
+ * shim — the text-output adapter for `harness next` / `harness claim`, used
3
+ * until SH P7.4 (`--json` on both) lands. ISOLATED HERE ON PURPOSE: when the
4
+ * JSON flags ship, this file is deleted and `ShimHarness` is replaced by a
5
+ * straight JSON-parsing `CliHarness`. Nothing else in the loop imports it.
6
+ *
7
+ * Current text shapes it parses (from repos/system-harness/src/sequencer/cli.ts):
8
+ * `harness next` → `component#id\n` lines on stdout, `no ready units` on stderr
9
+ * `harness next --escalated` → same, `no escalated units` on stderr
10
+ * `harness claim <id> --session <s>` → `claimed <id> by <s> (seq N)\n`, exit 0/1
11
+ *
12
+ * The text carries no deps and no mode, so shimmed `next()` returns
13
+ * `deps: []` and `mode: "build"` for every unit — a known degradation. explore
14
+ * parking and dep ordering are only correct once P7.4 delivers structured data;
15
+ * the FakeHarness (which the M1 dry loop actually exercises) has both.
16
+ */
17
+ import { execFile } from "node:child_process";
18
+ import { promisify } from "node:util";
19
+ const run = promisify(execFile);
20
+ export class ShimHarness {
21
+ opts;
22
+ constructor(opts) {
23
+ this.opts = opts;
24
+ }
25
+ base() {
26
+ return this.opts.ledgerDir ? ["--ledger", this.opts.ledgerDir] : [];
27
+ }
28
+ async call(args) {
29
+ try {
30
+ const { stdout, stderr } = await run(this.opts.bin, args, {
31
+ cwd: this.opts.cwd,
32
+ });
33
+ return { code: 0, stdout, stderr };
34
+ }
35
+ catch (e) {
36
+ const err = e;
37
+ return {
38
+ code: typeof err.code === "number" ? err.code : 1,
39
+ stdout: err.stdout ?? "",
40
+ stderr: err.stderr ?? "",
41
+ };
42
+ }
43
+ }
44
+ parseLines(stdout) {
45
+ return stdout
46
+ .split("\n")
47
+ .map((l) => l.trim())
48
+ .filter(Boolean)
49
+ .map((line) => {
50
+ const hash = line.indexOf("#");
51
+ return hash >= 0
52
+ ? {
53
+ component: line.slice(0, hash),
54
+ id: line.slice(hash + 1),
55
+ deps: [],
56
+ mode: "build",
57
+ }
58
+ : { id: line, deps: [], mode: "build" };
59
+ });
60
+ }
61
+ async next(opts) {
62
+ const args = ["next", ...this.base()];
63
+ if (opts?.only)
64
+ args.push("--only", opts.only);
65
+ const { stdout } = await this.call(args);
66
+ return this.parseLines(stdout);
67
+ }
68
+ async escalated() {
69
+ const { stdout } = await this.call(["next", "--escalated", ...this.base()]);
70
+ return this.parseLines(stdout);
71
+ }
72
+ async units() {
73
+ // The current CLI has no structured status query, so the shim cannot feed
74
+ // the startup sweep. It returns `[]` — the sweep is a no-op behind the shim
75
+ // and only fully functional against the FakeHarness (dry loop) or a real
76
+ // status surface. Filling this is P7.4-adjacent system-harness work.
77
+ return [];
78
+ }
79
+ async claim(unitId, session) {
80
+ const { code } = await this.call([
81
+ "claim",
82
+ unitId,
83
+ "--session",
84
+ session,
85
+ ...this.base(),
86
+ ]);
87
+ if (code !== 0)
88
+ return null;
89
+ // The text `claim` returns no briefing body. Until P7.4, the caller must
90
+ // treat a shimmed claim as "took the unit" only; briefing fields are unknown
91
+ // and the loop cannot run a real dispatch off it. This is why M2 is blocked
92
+ // on P7.4, not on this shim.
93
+ return {
94
+ unitId,
95
+ intent: "(shim: briefing unavailable until harness claim --json — SH P7.4)",
96
+ acceptanceCriteria: [],
97
+ scope: [],
98
+ branch: `unit/${unitId}`,
99
+ mergeFacts: {},
100
+ };
101
+ }
102
+ async heartbeat(unitId, session) {
103
+ await this.call(["heartbeat", unitId, "--session", session, ...this.base()]);
104
+ }
105
+ async ledgerAppend(event) {
106
+ await this.call([
107
+ "ledger",
108
+ "append",
109
+ "--type",
110
+ event.type,
111
+ "--unit",
112
+ event.unitId,
113
+ ...(event.session ? ["--session", event.session] : []),
114
+ ...(event.body ? ["--body", JSON.stringify(event.body)] : []),
115
+ ...this.base(),
116
+ ]);
117
+ }
118
+ async verify(unitId) {
119
+ const { code, stdout, stderr } = await this.call([
120
+ "verify",
121
+ "--unit",
122
+ unitId,
123
+ ...this.base(),
124
+ ]);
125
+ if (code === 0)
126
+ return { status: "pass" };
127
+ if (code === 2)
128
+ return { status: "halt", evidence: stderr || stdout };
129
+ return { status: "fail", evidence: stderr || stdout };
130
+ }
131
+ async verifySystem(unitId, systemToml) {
132
+ const { code, stdout, stderr } = await this.call([
133
+ "verify",
134
+ "--unit",
135
+ unitId,
136
+ "--system",
137
+ systemToml,
138
+ ...this.base(),
139
+ ]);
140
+ if (code === 0)
141
+ return { status: "pass" };
142
+ if (code === 2)
143
+ return { status: "halt", evidence: stderr || stdout };
144
+ return { status: "fail", evidence: stderr || stdout };
145
+ }
146
+ async merge(unitId, landedSha, facts) {
147
+ const flags = [];
148
+ if (facts.door === "one-way")
149
+ flags.push("--one-way");
150
+ if (facts.door === "two-way")
151
+ flags.push("--two-way");
152
+ if (facts.addsDependency)
153
+ flags.push("--adds-dependency");
154
+ if (facts.schemaChange)
155
+ flags.push("--schema-change");
156
+ if (facts.security)
157
+ flags.push("--security");
158
+ if (facts.gateExternal)
159
+ flags.push("--gate-external");
160
+ if (facts.artifactProducerChange)
161
+ flags.push("--artifact-producer-change");
162
+ if (facts.mode)
163
+ flags.push("--mode", facts.mode);
164
+ const { code, stdout, stderr } = await this.call([
165
+ "merge",
166
+ unitId,
167
+ "--landed",
168
+ landedSha,
169
+ ...flags,
170
+ ...this.base(),
171
+ ]);
172
+ if (code === 0)
173
+ return { status: "merged", landedSha };
174
+ return {
175
+ status: "door-open",
176
+ doorId: `${unitId}#door`,
177
+ unblock: (stderr || stdout).trim() ||
178
+ `harness door approve ${unitId} --reason "<why>" --who <operator>`,
179
+ };
180
+ }
181
+ }
182
+ //# sourceMappingURL=shim.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @harness/orchestration — the execution loop.
3
+ *
4
+ * Public surface (v0): the loop primitives and their injectable fakes. The
5
+ * `orchestrate` CLI (./cli.ts) is the runnable entrypoint.
6
+ */
7
+ export * from "./harness/index.js";
8
+ export * from "./harness/cli.js";
9
+ export * from "./routes/index.js";
10
+ export * from "./runner/index.js";
11
+ export * from "./runstate/index.js";
12
+ export * from "./runstate/publish.js";
13
+ export * from "./loop/index.js";
14
+ export * from "./git/index.js";
15
+ export * from "./config/index.js";
16
+ export * from "./forge/index.js";
17
+ export * from "./run/index.js";
18
+ export * from "./worktree/index.js";
19
+ export * from "./report/index.js";
20
+ export * from "./prompts/index.js";
21
+ export * from "./runners/telemetry.js";
22
+ export * from "./runners/conformance/index.js";
23
+ export { ClaudeRunner } from "./runners/claude/index.js";
24
+ export { CodexRunner } from "./runners/codex/index.js";
25
+ export { CursorRunner } from "./runners/cursor/index.js";
26
+ export { runCodexExec, foldCodexStream, } from "./runners/codex/exec.js";
27
+ export { runCursorAgent, foldCursorOutput, } from "./runners/cursor/exec.js";
28
+ export { runClaudeSession, } from "./runners/claude/sdk.js";
29
+ //# sourceMappingURL=index.js.map