@isaacriehm/cairn-core 0.1.0 → 0.1.4

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 (64) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/ground/schemas.d.ts +2 -2
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.js +12 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/join/index.d.ts +6 -1
  7. package/dist/join/index.js +1 -1
  8. package/dist/join/index.js.map +1 -1
  9. package/dist/mcp/schemas.d.ts +4 -4
  10. package/package.json +4 -4
  11. package/dist/init/daemon-autostart.d.ts +0 -16
  12. package/dist/init/daemon-autostart.js +0 -95
  13. package/dist/init/daemon-autostart.js.map +0 -1
  14. package/dist/init/mapper-legacy.d.ts +0 -148
  15. package/dist/init/mapper-legacy.js +0 -238
  16. package/dist/init/mapper-legacy.js.map +0 -1
  17. package/dist/init/secrets.d.ts +0 -18
  18. package/dist/init/secrets.js +0 -76
  19. package/dist/init/secrets.js.map +0 -1
  20. package/dist/init/setup-runners.d.ts +0 -15
  21. package/dist/init/setup-runners.js +0 -143
  22. package/dist/init/setup-runners.js.map +0 -1
  23. package/dist/mirror/clone.d.ts +0 -6
  24. package/dist/mirror/clone.js +0 -48
  25. package/dist/mirror/clone.js.map +0 -1
  26. package/dist/mirror/dirty-overlap.d.ts +0 -13
  27. package/dist/mirror/dirty-overlap.js +0 -42
  28. package/dist/mirror/dirty-overlap.js.map +0 -1
  29. package/dist/mirror/index.d.ts +0 -7
  30. package/dist/mirror/index.js +0 -7
  31. package/dist/mirror/index.js.map +0 -1
  32. package/dist/mirror/paths.d.ts +0 -18
  33. package/dist/mirror/paths.js +0 -45
  34. package/dist/mirror/paths.js.map +0 -1
  35. package/dist/mirror/push.d.ts +0 -9
  36. package/dist/mirror/push.js +0 -27
  37. package/dist/mirror/push.js.map +0 -1
  38. package/dist/mirror/state.d.ts +0 -4
  39. package/dist/mirror/state.js +0 -36
  40. package/dist/mirror/state.js.map +0 -1
  41. package/dist/mirror/sync.d.ts +0 -9
  42. package/dist/mirror/sync.js +0 -33
  43. package/dist/mirror/sync.js.map +0 -1
  44. package/dist/mirror/types.d.ts +0 -77
  45. package/dist/mirror/types.js +0 -2
  46. package/dist/mirror/types.js.map +0 -1
  47. package/dist/tier0/ollama.d.ts +0 -22
  48. package/dist/tier0/ollama.js +0 -63
  49. package/dist/tier0/ollama.js.map +0 -1
  50. package/dist/voice/index.d.ts +0 -4
  51. package/dist/voice/index.js +0 -4
  52. package/dist/voice/index.js.map +0 -1
  53. package/dist/voice/model.d.ts +0 -23
  54. package/dist/voice/model.js +0 -46
  55. package/dist/voice/model.js.map +0 -1
  56. package/dist/voice/pipe.d.ts +0 -9
  57. package/dist/voice/pipe.js +0 -47
  58. package/dist/voice/pipe.js.map +0 -1
  59. package/dist/voice/transcribe.d.ts +0 -3
  60. package/dist/voice/transcribe.js +0 -43
  61. package/dist/voice/transcribe.js.map +0 -1
  62. package/dist/voice/types.d.ts +0 -26
  63. package/dist/voice/types.js +0 -9
  64. package/dist/voice/types.js.map +0 -1
@@ -1,238 +0,0 @@
1
- /**
2
- * Legacy single-call mapper — extracted unchanged from the original mapper.ts.
3
- *
4
- * Used as a fallback when the chunked parallel path (`mapper-parallel.ts` +
5
- * `mapper-merge.ts`) cannot run — e.g., every per-module Sonnet call failed,
6
- * or the slicer detected zero modules and the orchestrator chose to skip the
7
- * parallel path entirely.
8
- *
9
- * This module deliberately preserves the original behavior: one Sonnet call
10
- * with a flat ~20k token repo summary. The acknowledged trade-off is degraded
11
- * proposals on monorepos (per `INIT_SPEC.md` §3 motivation), but it remains
12
- * the safest fallback because the rest of init has consumed `MapperOutput` for
13
- * months and we want zero downstream churn when we drop into legacy mode.
14
- */
15
- import { runClaude } from "../claude/index.js";
16
- import { logger } from "../logger.js";
17
- import { validateMapperOutput, } from "./mapper.js";
18
- const log = logger("init.mapper-legacy");
19
- export const LEGACY_OUTPUT_SCHEMA = {
20
- type: "object",
21
- additionalProperties: false,
22
- properties: {
23
- pilot_module: { type: "string" },
24
- domain_summary: { type: "string" },
25
- key_modules: {
26
- type: "array",
27
- items: {
28
- type: "object",
29
- additionalProperties: false,
30
- properties: {
31
- name: { type: "string" },
32
- path: { type: "string" },
33
- purpose: { type: "string" },
34
- },
35
- required: ["name", "path", "purpose"],
36
- },
37
- },
38
- route_handler_globs: { type: "array", items: { type: "string" } },
39
- dto_globs: { type: "array", items: { type: "string" } },
40
- generator_source_globs: { type: "array", items: { type: "string" } },
41
- high_stakes_globs: { type: "array", items: { type: "string" } },
42
- off_limits_globs: { type: "array", items: { type: "string" } },
43
- proposed_sensors: {
44
- type: "array",
45
- items: {
46
- type: "object",
47
- additionalProperties: false,
48
- properties: {
49
- id: { type: "string" },
50
- description: { type: "string" },
51
- applies_to_globs: {
52
- type: "array",
53
- items: { type: "string" },
54
- },
55
- },
56
- required: ["id", "description", "applies_to_globs"],
57
- },
58
- },
59
- notes: { type: "string" },
60
- scope_index: {
61
- type: "object",
62
- additionalProperties: false,
63
- properties: {
64
- files: {
65
- type: "object",
66
- additionalProperties: {
67
- type: "object",
68
- additionalProperties: false,
69
- properties: {
70
- decisions: { type: "array", items: { type: "string" } },
71
- invariants: { type: "array", items: { type: "string" } },
72
- unscoped: { type: "boolean" },
73
- },
74
- required: ["decisions", "invariants"],
75
- },
76
- },
77
- },
78
- required: ["files"],
79
- },
80
- },
81
- required: [
82
- "pilot_module",
83
- "domain_summary",
84
- "key_modules",
85
- "route_handler_globs",
86
- "dto_globs",
87
- "generator_source_globs",
88
- "high_stakes_globs",
89
- "off_limits_globs",
90
- "proposed_sensors",
91
- "notes",
92
- ],
93
- };
94
- export const LEGACY_SYSTEM_PROMPT = [
95
- "You are the INIT MAPPER for a code-agent harness adopting a new project.",
96
- "",
97
- "Your job: read a structural inventory of an unknown project (top-level dirs, package manifests, framework signals, file-extension breakdown, notable files and dirs) and produce a structured proposal that lets the harness run useful sensors against the project's diffs.",
98
- "",
99
- "You DO NOT execute code. You DO NOT modify files. You produce one JSON object.",
100
- "",
101
- "Required outputs:",
102
- "",
103
- "- `pilot_module` — a glob like `core/src/integrations/**` for the initial scope where the harness should focus, OR the literal `ALL` if the project is small enough to harness end-to-end on day one. Bias toward a focused module — operators add scope as confidence grows.",
104
- "- `domain_summary` — one paragraph (~80-200 words). What does this codebase appear to do? Inferred from package name, README contents (when in a manifest preview), top-level dirs, and manifest deps. State only what the inventory supports; if uncertain, say so.",
105
- "- `key_modules` — 3-8 modules the harness should know about. Each `{ name, path, purpose }`. `path` is a directory path that EXISTS in the inventory (no glob); `purpose` is one short sentence.",
106
- "- `route_handler_globs` — file glob patterns matching HTTP / CLI / RPC / route handlers. Examples: `core/src/**/*.controller.ts` (NestJS), `app/controllers/**/*.rb` (Rails), `apps/api/routes/**/*.py` (FastAPI), `internal/handlers/**/*.go`. EMPTY array if no handlers detected.",
107
- "- `dto_globs` — globs matching DTO / schema / form-input / request-validator definitions. Examples: `**/*.dto.ts`, `apps/api/schemas/**/*.py`, `core/src/**/zod.ts`, `app/forms/**/*.rb`.",
108
- "- `generator_source_globs` — globs whose changes mean a generator must re-run. Examples: `core/openapi.json`, `core/src/db/schema.ts` (Drizzle), `**/*.proto`, `prisma/schema.prisma`, `db/structure.sql`. EMPTY if no generators apparent.",
109
- "- `high_stakes_globs` — globs for high-risk surfaces (auth, billing, multi-tenant boundaries, payments, integrations storing tokens, telephony, anything where a regression leaks user data or charges money). Be conservative; over-flagging dilutes the gate. EMPTY if not clear.",
110
- "- `off_limits_globs` — globs the harness MUST NOT touch beyond the generic defaults already in place (`node_modules/**`, `dist/**`, `.git/**`, `.harness/**`, `.archive/**`, generated artifact dirs are already excluded). Add things like vendored third-party code, copied snapshots, large binary fixtures, anything under a directory the operator should not let an agent rewrite. EMPTY if nothing extra.",
111
- "- `proposed_sensors` — project-specific sensors beyond the generic harness Layer A/B/C/D. Each `{ id, description, applies_to_globs }`. Examples: `event-emit-coverage` (every emit() has a label), `migration-naming-convention`, `auth-guard-on-controllers`, `dto-discriminator-coverage`. EMPTY if nothing project-specific is obvious.",
112
- "- `notes` — anything notable that didn't fit a structured field — e.g., \"truncated at file cap; pilot scope conservative\", \"no test infra detected\", \"monorepo with pnpm-workspace; harness should adopt one package at a time\".",
113
- "- `scope_index` — forward map from repo-relative file paths to the decisions and invariants whose `scope_globs` apply, keyed by file. Shape: `{ files: { \"<repo-relative-path>\": { decisions: [\"DEC-NNNN\"], invariants: [\"V-NNNN\"], unscoped?: true } } }`. The user prompt provides a list of in-scope decisions + invariants when ground state already exists; classify which apply to each meaningful source file. Use `unscoped: true` for files that should never carry rules (lockfiles, generated, vendored, dotfile config) so the GC scope-coverage pass doesn't re-flag them. EMPTY `{ files: {} }` is acceptable on first-run adopters with no decisions yet.",
114
- "",
115
- "Rules:",
116
- "- Globs MUST start from repo root, no leading slash.",
117
- "- Use forward slashes only (`/`), never backslashes.",
118
- "- Use `**` for any-depth wildcards, `*` for single-segment.",
119
- "- Do not invent paths that aren't in the inventory.",
120
- "- Prefer EMPTY arrays over guessed entries. The harness propagates empty fields to operator review; guessed entries silently mislead and the operator may not catch them at adoption time.",
121
- "- Avoid overly-broad globs like `**/*.ts` for `route_handler_globs` — narrow to the controller / route directory.",
122
- "- For `pilot_module`: if the repo has a clear modular layout (packages/, apps/, services/, core/src/<feature>/), name one. If it's a flat single-app codebase, use the literal `ALL` and let the operator narrow later.",
123
- "- `key_modules.path` MUST appear in the inventory's notable directories or the file-count breakdown.",
124
- "- Return ONLY the JSON object. No prose, no preamble, no code fences.",
125
- ].join("\n");
126
- export function buildLegacyUserPrompt(args) {
127
- const d = args.detection;
128
- const s = args.summary;
129
- const parts = [];
130
- parts.push(`# Project inventory`);
131
- parts.push("");
132
- parts.push(`Project slug: ${d.project_slug}`);
133
- parts.push(`Origin URL: ${d.origin_url ?? "(none — local-only repo)"}`);
134
- parts.push(`Stack signatures (mechanical): ${d.stack_signatures.map((sig) => sig.kind).join(", ") || "(none)"}`);
135
- if (d.start_command !== null) {
136
- parts.push(`Start command (detected): ${[d.start_command.command, ...d.start_command.args].join(" ")}`);
137
- }
138
- if (d.proposed_sensors.length > 0) {
139
- parts.push("Generic stack-detected sensors already proposed:");
140
- for (const sensor of d.proposed_sensors) {
141
- parts.push(` - ${sensor.id} (${sensor.command} ${sensor.args.join(" ")}) — ${sensor.reason}`);
142
- }
143
- }
144
- parts.push("");
145
- parts.push(`## Repo summary`);
146
- parts.push(`Total files (after caps): ${s.total_files}`);
147
- parts.push(`Total dirs: ${s.total_dirs}`);
148
- parts.push(`Listing source: ${s.used_git_ls_files ? "git ls-files (gitignore-aware)" : "filesystem walk"}`);
149
- if (s.truncated_at_file_cap)
150
- parts.push(`(truncated at file cap)`);
151
- if (s.truncated_at_depth_cap)
152
- parts.push(`(truncated at depth cap — pilot scope should be conservative)`);
153
- parts.push("");
154
- parts.push(`## Top-level entries`);
155
- parts.push(s.top_level.length === 0 ? "(none)" : s.top_level.join(", "));
156
- parts.push("");
157
- parts.push(`## Files per top-level dir (top 30)`);
158
- for (const [dir, count] of Object.entries(s.by_top_dir)) {
159
- parts.push(` - ${dir}/ (${count} files)`);
160
- }
161
- parts.push("");
162
- parts.push(`## File extensions (top 25)`);
163
- for (const [ext, count] of Object.entries(s.by_extension)) {
164
- parts.push(` - ${ext} (${count})`);
165
- }
166
- parts.push("");
167
- if (s.notable_files.length > 0) {
168
- parts.push(`## Notable files`);
169
- for (const f of s.notable_files)
170
- parts.push(` - ${f}`);
171
- parts.push("");
172
- }
173
- if (s.notable_dir_paths.length > 0) {
174
- parts.push(`## Notable directories (matching framework conventions)`);
175
- for (const dir of s.notable_dir_paths.slice(0, 80))
176
- parts.push(` - ${dir}/`);
177
- parts.push("");
178
- }
179
- if (s.framework_signals.length > 0) {
180
- parts.push(`## Framework signals from manifests`);
181
- for (const f of s.framework_signals)
182
- parts.push(` - ${f}`);
183
- parts.push("");
184
- }
185
- if (s.package_manifests.length > 0) {
186
- parts.push(`## Package manifest previews (first 80 lines each)`);
187
- for (const m of s.package_manifests) {
188
- parts.push(`### ${m.path}`);
189
- parts.push("```");
190
- parts.push(m.preview);
191
- parts.push("```");
192
- parts.push("");
193
- }
194
- }
195
- parts.push(`Now produce the JSON object per the schema. No preamble.`);
196
- return parts.join("\n");
197
- }
198
- export async function runLegacyMapper(args) {
199
- const userPrompt = buildLegacyUserPrompt({
200
- detection: args.detection,
201
- summary: args.summary,
202
- });
203
- log.info({
204
- slug: args.detection.project_slug,
205
- total_files: args.summary.total_files,
206
- manifests: args.summary.package_manifests.length,
207
- truncated_file_cap: args.summary.truncated_at_file_cap,
208
- truncated_depth_cap: args.summary.truncated_at_depth_cap,
209
- }, "legacy mapper dispatch");
210
- const result = await runClaude({
211
- tier: "sonnet",
212
- prompt: userPrompt,
213
- system: LEGACY_SYSTEM_PROMPT,
214
- jsonSchema: LEGACY_OUTPUT_SCHEMA,
215
- timeoutMs: args.timeoutMs ?? 300_000,
216
- });
217
- const output = validateMapperOutput(result.parsed);
218
- return {
219
- output,
220
- tier: "sonnet",
221
- model: result.model,
222
- duration_ms: result.durationMs,
223
- path: "legacy",
224
- ...(result.usage !== undefined
225
- ? {
226
- usage: {
227
- ...(result.usage.input_tokens !== undefined
228
- ? { input_tokens: result.usage.input_tokens }
229
- : {}),
230
- ...(result.usage.output_tokens !== undefined
231
- ? { output_tokens: result.usage.output_tokens }
232
- : {}),
233
- },
234
- }
235
- : {}),
236
- };
237
- }
238
- //# sourceMappingURL=mapper-legacy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapper-legacy.js","sourceRoot":"","sources":["../../src/init/mapper-legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,oBAAoB,GAGrB,MAAM,aAAa,CAAC;AAIrB,MAAM,GAAG,GAA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AC,MAAM;QAChD,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB;QACtD,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,sBAAsB;KACzD,EACD,wBAAwB,CACzB,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;QAC7B,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,oBAAoB;QAC5B,UAAU,EAAE,oBAA8B;QAC1C,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,OAAO;KACrC,CAAC,CAAC;IACH,MAAM,MAAM,GAAiB,oBAAoB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjE,OAAO;QACL,MAAM;QACN,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,WAAW,EAAE,MAAM,CAAC,UAAU;QAC9B,IAAI,EAAE,QAAQ;QACd,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS;YAC5B,CAAC,CAAC;gBACE,KAAK,EAAE;oBACL,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,KAAK,SAAS;wBACzC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE;wBAC7C,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS;wBAC1C,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE;wBAC/C,CAAC,CAAC,EAAE,CAAC;iBACR;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Secrets file — `~/.local/harness/.env`.
3
- *
4
- * Operator-scoped (not project-scoped) so a single Discord bot powers
5
- * every adopted project. Init writes here; the CLI's dotenv loader reads
6
- * here first.
7
- *
8
- * Format = standard dotenv (KEY=VALUE per line, # comments). Existing
9
- * keys are preserved on append; only the named keys get rewritten.
10
- */
11
- export declare function harnessEnvPath(): string;
12
- export declare function readHarnessEnv(): Record<string, string>;
13
- /**
14
- * Merge `updates` into the on-disk env file, preserving every other key
15
- * + comments + ordering of unchanged lines. Created with mode 0600 since
16
- * it carries secrets.
17
- */
18
- export declare function upsertHarnessEnv(updates: Record<string, string>): string;
@@ -1,76 +0,0 @@
1
- /**
2
- * Secrets file — `~/.local/harness/.env`.
3
- *
4
- * Operator-scoped (not project-scoped) so a single Discord bot powers
5
- * every adopted project. Init writes here; the CLI's dotenv loader reads
6
- * here first.
7
- *
8
- * Format = standard dotenv (KEY=VALUE per line, # comments). Existing
9
- * keys are preserved on append; only the named keys get rewritten.
10
- */
11
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
12
- import { homedir } from "node:os";
13
- import { dirname, join } from "node:path";
14
- export function harnessEnvPath() {
15
- return join(homedir(), ".local", "harness", ".env");
16
- }
17
- export function readHarnessEnv() {
18
- const p = harnessEnvPath();
19
- if (!existsSync(p))
20
- return {};
21
- const raw = readFileSync(p, "utf8");
22
- return parseDotenv(raw);
23
- }
24
- /**
25
- * Merge `updates` into the on-disk env file, preserving every other key
26
- * + comments + ordering of unchanged lines. Created with mode 0600 since
27
- * it carries secrets.
28
- */
29
- export function upsertHarnessEnv(updates) {
30
- const p = harnessEnvPath();
31
- mkdirSync(dirname(p), { recursive: true });
32
- const existing = existsSync(p) ? readFileSync(p, "utf8") : "";
33
- const lines = existing.length === 0 ? [] : existing.split(/\r?\n/);
34
- const seen = new Set();
35
- const out = [];
36
- for (const line of lines) {
37
- const m = line.match(/^([A-Z_][A-Z0-9_]*)=/);
38
- if (m && m[1] !== undefined && updates[m[1]] !== undefined) {
39
- out.push(`${m[1]}=${updates[m[1]]}`);
40
- seen.add(m[1]);
41
- }
42
- else {
43
- out.push(line);
44
- }
45
- }
46
- for (const [k, v] of Object.entries(updates)) {
47
- if (!seen.has(k))
48
- out.push(`${k}=${v}`);
49
- }
50
- while (out.length > 0 && out[out.length - 1] === "")
51
- out.pop();
52
- const text = out.join("\n") + "\n";
53
- writeFileSync(p, text, { encoding: "utf8", mode: 0o600 });
54
- return p;
55
- }
56
- function parseDotenv(text) {
57
- const out = {};
58
- for (const line of text.split(/\r?\n/)) {
59
- if (line.length === 0 || line.startsWith("#"))
60
- continue;
61
- const eq = line.indexOf("=");
62
- if (eq <= 0)
63
- continue;
64
- const key = line.slice(0, eq).trim();
65
- let value = line.slice(eq + 1).trim();
66
- // Strip wrapping quotes — match dotenv behavior.
67
- if ((value.startsWith('"') && value.endsWith('"')) ||
68
- (value.startsWith("'") && value.endsWith("'"))) {
69
- value = value.slice(1, -1);
70
- }
71
- if (/^[A-Z_][A-Z0-9_]*$/.test(key))
72
- out[key] = value;
73
- }
74
- return out;
75
- }
76
- //# sourceMappingURL=secrets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/init/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;IAC3B,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED;;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YACD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Spawners for actually executing setup steps from `harness init`.
3
- *
4
- * Each function inherits stdio so the operator sees curl / pnpm / docker
5
- * progress live. Returns success/failure; the caller surfaces the result
6
- * in the wizard summary.
7
- */
8
- export interface RunResult {
9
- ok: boolean;
10
- exit_code: number | null;
11
- /** Optional human-readable note (skipped reason / failure summary). */
12
- note?: string;
13
- }
14
- export declare function downloadWhisperModel(): Promise<RunResult>;
15
- export declare function runHarnessSetupScript(script: "setup-whisper" | "setup-uat-browsers" | "setup-uat-sql" | "setup-uat-docker", extraArgs?: string[]): Promise<RunResult>;
@@ -1,143 +0,0 @@
1
- /**
2
- * Spawners for actually executing setup steps from `harness init`.
3
- *
4
- * Each function inherits stdio so the operator sees curl / pnpm / docker
5
- * progress live. Returns success/failure; the caller surfaces the result
6
- * in the wizard summary.
7
- */
8
- import { spawn } from "node:child_process";
9
- import { createWriteStream, existsSync, mkdirSync, statSync, unlinkSync } from "node:fs";
10
- import { dirname, join, resolve } from "node:path";
11
- import { fileURLToPath } from "node:url";
12
- import { homedir } from "node:os";
13
- import { startProgress } from "./visual.js";
14
- const HERE = dirname(fileURLToPath(import.meta.url));
15
- /** dist/init/setup-runners.js → walk up to package root. */
16
- const PKG_ROOT = resolve(HERE, "..", "..");
17
- const WHISPER_MODEL_DIR = join(homedir(), ".local", "harness", "models");
18
- const WHISPER_MODEL_FILE = "ggml-large-v3-turbo-q5_0.bin";
19
- const WHISPER_MODEL_URL = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3-turbo-q5_0.bin?download=true";
20
- export async function downloadWhisperModel() {
21
- mkdirSync(WHISPER_MODEL_DIR, { recursive: true });
22
- const out = join(WHISPER_MODEL_DIR, WHISPER_MODEL_FILE);
23
- if (existsSync(out)) {
24
- return { ok: true, exit_code: 0, note: "model already on disk" };
25
- }
26
- return downloadWithProgress({
27
- url: WHISPER_MODEL_URL,
28
- destPath: out,
29
- label: "Downloading whisper model",
30
- });
31
- }
32
- /**
33
- * Stream-download a URL to disk, showing a cli-progress bar with bytes +
34
- * transfer rate. Falls back to a single-line in-place update on non-TTY.
35
- *
36
- * Uses the global `fetch()` available in Node 22+. No new deps.
37
- */
38
- async function downloadWithProgress(opts) {
39
- let response;
40
- try {
41
- response = await fetch(opts.url);
42
- }
43
- catch (err) {
44
- return {
45
- ok: false,
46
- exit_code: null,
47
- note: `fetch failed — ${err instanceof Error ? err.message : String(err)}`,
48
- };
49
- }
50
- if (!response.ok) {
51
- return {
52
- ok: false,
53
- exit_code: response.status,
54
- note: `HTTP ${response.status} ${response.statusText}`,
55
- };
56
- }
57
- const lenHeader = response.headers.get("content-length");
58
- const total = lenHeader !== null && Number.isFinite(Number.parseInt(lenHeader, 10))
59
- ? Number.parseInt(lenHeader, 10)
60
- : 0;
61
- if (response.body === null) {
62
- return { ok: false, exit_code: null, note: "empty response body" };
63
- }
64
- const sink = createWriteStream(opts.destPath, { flags: "w" });
65
- const progress = startProgress({ label: opts.label, total: Math.max(total, 1) });
66
- let received = 0;
67
- const startedAt = Date.now();
68
- try {
69
- const reader = response.body.getReader();
70
- let last = 0;
71
- while (true) {
72
- const { value, done } = await reader.read();
73
- if (done)
74
- break;
75
- received += value.byteLength;
76
- sink.write(value);
77
- const now = Date.now();
78
- if (now - last > 80) {
79
- const elapsedSec = Math.max((now - startedAt) / 1000, 0.001);
80
- const speedMb = (received / elapsedSec / 1_048_576).toFixed(1);
81
- progress.set(received, { speedMb });
82
- last = now;
83
- }
84
- }
85
- sink.end();
86
- await new Promise((resolveP) => sink.on("close", () => resolveP()));
87
- progress.set(received, {
88
- speedMb: ((received / Math.max((Date.now() - startedAt) / 1000, 0.001) / 1_048_576).toFixed(1)),
89
- });
90
- progress.stop(true, `whisper model downloaded (${(received / 1_048_576).toFixed(0)}MB)`);
91
- return { ok: true, exit_code: 0 };
92
- }
93
- catch (err) {
94
- progress.stop(false, "download failed");
95
- try {
96
- sink.end();
97
- }
98
- catch {
99
- // ignore
100
- }
101
- try {
102
- if (existsSync(opts.destPath) && statSync(opts.destPath).size < (total || Infinity)) {
103
- unlinkSync(opts.destPath);
104
- }
105
- }
106
- catch {
107
- // ignore
108
- }
109
- return {
110
- ok: false,
111
- exit_code: null,
112
- note: err instanceof Error ? err.message : String(err),
113
- };
114
- }
115
- }
116
- export async function runHarnessSetupScript(script, extraArgs = []) {
117
- const scriptPath = join(PKG_ROOT, "scripts", `${script}.ts`);
118
- if (!existsSync(scriptPath)) {
119
- return {
120
- ok: false,
121
- exit_code: null,
122
- note: `script not found: ${scriptPath}`,
123
- };
124
- }
125
- // pnpm exec resolves tsx from the harness pkg's node_modules; we stay
126
- // in PKG_ROOT so workspace-style filtering doesn't matter.
127
- return runInherit("pnpm", ["exec", "tsx", scriptPath, ...extraArgs], PKG_ROOT);
128
- }
129
- function runInherit(command, args, cwd) {
130
- return new Promise((resolveP) => {
131
- const child = spawn(command, args, {
132
- stdio: "inherit",
133
- ...(cwd !== undefined ? { cwd } : {}),
134
- });
135
- child.on("error", (err) => {
136
- resolveP({ ok: false, exit_code: null, note: String(err) });
137
- });
138
- child.on("exit", (code) => {
139
- resolveP({ ok: code === 0, exit_code: code });
140
- });
141
- });
142
- }
143
- //# sourceMappingURL=setup-runners.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-runners.js","sourceRoot":"","sources":["../../src/init/setup-runners.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ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AAU,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,EAAE,EAAE,KAAK;YACT,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,qBAAqB,UAAU,EAAE;SACxC,CAAC;IACJ,CAAC;IACD,sEAAsE;IACtE,2DAA2D;IAC3D,OAAO,UAAU,CACf,MAAM,EACN,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,EACzC,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,OAAe,EACf,IAAc,EACd,GAAY;IAEZ,OAAO,IAAI,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YACjC,KAAK,EAAE,SAAS;YAChB,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,QAAQ,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,QAAQ,CAAC,EAAE,EAAE,EAAE,IAAI,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { CloneOptions, MirrorRecord } from "./types.js";
2
- /**
3
- * Idempotent: ensures the mirror exists for the given project. Records the
4
- * record if missing. Returns the (possibly-updated) record.
5
- */
6
- export declare function ensureMirror(opts: CloneOptions): Promise<MirrorRecord>;
@@ -1,48 +0,0 @@
1
- import { existsSync, mkdirSync } from "node:fs";
2
- import { dirname } from "node:path";
3
- import { simpleGit } from "simple-git";
4
- import { logger } from "../logger.js";
5
- import { mirrorPath, reposRoot } from "./paths.js";
6
- import { readMirrorRecord, writeMirrorRecord } from "./state.js";
7
- const log = logger("mirror.clone");
8
- /**
9
- * Idempotent: ensures the mirror exists for the given project. Records the
10
- * record if missing. Returns the (possibly-updated) record.
11
- */
12
- export async function ensureMirror(opts) {
13
- const { projectName, userTreePath, originUrl } = opts;
14
- const path = mirrorPath(projectName);
15
- const existing = readMirrorRecord(projectName);
16
- if (existing && existsSync(path)) {
17
- log.debug({ projectName, path }, "mirror already present");
18
- if (existing.originUrl !== originUrl || existing.userTreePath !== userTreePath) {
19
- throw new Error(`Mirror record for "${projectName}" exists with different origin/userTreePath.\n` +
20
- ` recorded: ${existing.originUrl} (tree ${existing.userTreePath})\n` +
21
- ` requested: ${originUrl} (tree ${userTreePath})\n` +
22
- "Refusing to overwrite. Resolve manually before re-running.");
23
- }
24
- return existing;
25
- }
26
- log.info({ projectName, originUrl, path }, "cloning mirror");
27
- mkdirSync(dirname(path), { recursive: true });
28
- mkdirSync(reposRoot(), { recursive: true });
29
- const git = simpleGit();
30
- await git.clone(originUrl, path);
31
- const repo = simpleGit(path);
32
- const branchSummary = await repo.branch();
33
- const defaultBranch = opts.defaultBranch ?? branchSummary.current;
34
- const record = {
35
- projectName,
36
- userTreePath,
37
- originUrl,
38
- defaultBranch,
39
- mirrorPath: path,
40
- lastSyncedAt: null,
41
- lastSha: null,
42
- createdAt: new Date().toISOString(),
43
- };
44
- writeMirrorRecord(record);
45
- log.info({ projectName, defaultBranch }, "mirror clone complete");
46
- return record;
47
- }
48
- //# sourceMappingURL=clone.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clone.js","sourceRoot":"","sources":["../../src/mirror/clone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS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AAE,CAAC,CAAC;IAC9C,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5C,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;IAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,OAAO,CAAC;IAElE,MAAM,MAAM,GAAiB;QAC3B,WAAW;QACX,YAAY;QACZ,SAAS;QACT,aAAa;QACb,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IACF,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,uBAAuB,CAAC,CAAC;IAClE,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,13 +0,0 @@
1
- import type { DirtyOverlapOptions, DirtyOverlapResult } from "./types.js";
2
- /**
3
- * `local_dirty_overlap` gate.
4
- *
5
- * Reads the user's working tree (NEVER writes) and reports any un-committed
6
- * files that overlap the dispatched run's target globs. If overlap is
7
- * non-empty, the orchestrator pauses the run and offers the operator
8
- * stash / cancel / wait via the active frontend adapter.
9
- *
10
- * Glob matching reuses `ground/glob.ts` so the matcher is the same one
11
- * `walkCanonical` and the GC sweeps use.
12
- */
13
- export declare function checkLocalDirtyOverlap(opts: DirtyOverlapOptions): Promise<DirtyOverlapResult>;
@@ -1,42 +0,0 @@
1
- import { simpleGit } from "simple-git";
2
- import { matchAnyGlob } from "../ground/glob.js";
3
- import { logger } from "../logger.js";
4
- import { requireMirrorRecord } from "./state.js";
5
- const log = logger("mirror.dirty-overlap");
6
- /**
7
- * `local_dirty_overlap` gate.
8
- *
9
- * Reads the user's working tree (NEVER writes) and reports any un-committed
10
- * files that overlap the dispatched run's target globs. If overlap is
11
- * non-empty, the orchestrator pauses the run and offers the operator
12
- * stash / cancel / wait via the active frontend adapter.
13
- *
14
- * Glob matching reuses `ground/glob.ts` so the matcher is the same one
15
- * `walkCanonical` and the GC sweeps use.
16
- */
17
- export async function checkLocalDirtyOverlap(opts) {
18
- const record = requireMirrorRecord(opts.projectName);
19
- const repo = simpleGit(record.userTreePath);
20
- const status = await repo.status();
21
- const dirtyFiles = [
22
- ...status.not_added,
23
- ...status.modified,
24
- ...status.created,
25
- ...status.deleted,
26
- ...status.renamed.map((r) => r.to),
27
- ...status.staged,
28
- ];
29
- const dedup = Array.from(new Set(dirtyFiles));
30
- const overlapping = dedup.filter((path) => matchAnyGlob(path, opts.targetGlobs));
31
- log.debug({
32
- projectName: opts.projectName,
33
- dirtyCount: dedup.length,
34
- overlapCount: overlapping.length,
35
- }, "dirty-overlap check");
36
- return {
37
- dirtyFiles: dedup,
38
- overlappingFiles: overlapping,
39
- overlap: overlapping.length > 0,
40
- };
41
- }
42
- //# sourceMappingURL=dirty-overlap.js.map