@harness-engineering/core 0.5.0 → 0.7.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.
package/dist/index.js CHANGED
@@ -37,7 +37,6 @@ __export(index_exports, {
37
37
  DEFAULT_STATE: () => DEFAULT_STATE,
38
38
  EntropyAnalyzer: () => EntropyAnalyzer,
39
39
  EntropyConfigSchema: () => EntropyConfigSchema,
40
- Err: () => Err,
41
40
  FailureEntrySchema: () => FailureEntrySchema,
42
41
  FileSink: () => FileSink,
43
42
  GateConfigSchema: () => GateConfigSchema,
@@ -47,7 +46,6 @@ __export(index_exports, {
47
46
  NoOpExecutor: () => NoOpExecutor,
48
47
  NoOpSink: () => NoOpSink,
49
48
  NoOpTelemetryAdapter: () => NoOpTelemetryAdapter,
50
- Ok: () => Ok,
51
49
  PatternConfigSchema: () => PatternConfigSchema,
52
50
  REQUIRED_SECTIONS: () => REQUIRED_SECTIONS,
53
51
  TypeScriptParser: () => TypeScriptParser,
@@ -58,9 +56,7 @@ __export(index_exports, {
58
56
  applyFixes: () => applyFixes,
59
57
  archiveFailures: () => archiveFailures,
60
58
  buildDependencyGraph: () => buildDependencyGraph,
61
- buildReachabilityMap: () => buildReachabilityMap,
62
59
  buildSnapshot: () => buildSnapshot,
63
- checkConfigPattern: () => checkConfigPattern,
64
60
  checkDocCoverage: () => checkDocCoverage,
65
61
  configureFeedback: () => configureFeedback,
66
62
  contextBudget: () => contextBudget,
@@ -79,28 +75,23 @@ __export(index_exports, {
79
75
  executeWorkflow: () => executeWorkflow,
80
76
  extractMarkdownLinks: () => extractMarkdownLinks,
81
77
  extractSections: () => extractSections,
82
- findPossibleMatches: () => findPossibleMatches,
83
78
  generateAgentsMap: () => generateAgentsMap,
84
79
  generateSuggestions: () => generateSuggestions,
85
80
  getActionEmitter: () => getActionEmitter,
86
81
  getFeedbackConfig: () => getFeedbackConfig,
87
82
  getPhaseCategories: () => getPhaseCategories,
88
- isErr: () => isErr,
89
- isOk: () => isOk,
90
- levenshteinDistance: () => levenshteinDistance,
91
83
  loadFailures: () => loadFailures,
92
84
  loadHandoff: () => loadHandoff,
93
85
  loadRelevantLearnings: () => loadRelevantLearnings,
94
86
  loadState: () => loadState,
95
87
  logAgentAction: () => logAgentAction,
96
88
  parseDiff: () => parseDiff,
97
- parseDocumentationFile: () => parseDocumentationFile,
98
89
  previewFix: () => previewFix,
99
90
  requestMultiplePeerReviews: () => requestMultiplePeerReviews,
100
91
  requestPeerReview: () => requestPeerReview,
101
92
  resetFeedbackConfig: () => resetFeedbackConfig,
102
- resolveEntryPoints: () => resolveEntryPoints,
103
93
  resolveFileToLayer: () => resolveFileToLayer,
94
+ runCIChecks: () => runCIChecks,
104
95
  runMechanicalGate: () => runMechanicalGate,
105
96
  runMultiTurnPipeline: () => runMultiTurnPipeline,
106
97
  runPipeline: () => runPipeline,
@@ -119,22 +110,6 @@ __export(index_exports, {
119
110
  module.exports = __toCommonJS(index_exports);
120
111
  __reExport(index_exports, require("@harness-engineering/types"), module.exports);
121
112
 
122
- // src/shared/result.ts
123
- var Ok = (value) => ({
124
- ok: true,
125
- value
126
- });
127
- function isOk(result) {
128
- return result.ok === true;
129
- }
130
- var Err = (error) => ({
131
- ok: false,
132
- error
133
- });
134
- function isErr(result) {
135
- return result.ok === false;
136
- }
137
-
138
113
  // src/shared/errors.ts
139
114
  function createError(code, message, details = {}, suggestions = []) {
140
115
  return { code, message, details, suggestions };
@@ -143,26 +118,29 @@ function createEntropyError(code, message, details = {}, suggestions = []) {
143
118
  return { code, message, details, suggestions };
144
119
  }
145
120
 
121
+ // src/shared/result.ts
122
+ var import_types = require("@harness-engineering/types");
123
+
146
124
  // src/shared/fs-utils.ts
147
125
  var import_fs = require("fs");
148
126
  var import_util = require("util");
149
127
  var import_glob = require("glob");
150
128
  var accessAsync = (0, import_util.promisify)(import_fs.access);
151
129
  var readFileAsync = (0, import_util.promisify)(import_fs.readFile);
152
- async function fileExists(path2) {
130
+ async function fileExists(path3) {
153
131
  try {
154
- await accessAsync(path2, import_fs.constants.F_OK);
132
+ await accessAsync(path3, import_fs.constants.F_OK);
155
133
  return true;
156
134
  } catch {
157
135
  return false;
158
136
  }
159
137
  }
160
- async function readFileContent(path2) {
138
+ async function readFileContent(path3) {
161
139
  try {
162
- const content = await readFileAsync(path2, "utf-8");
163
- return Ok(content);
140
+ const content = await readFileAsync(path3, "utf-8");
141
+ return (0, import_types.Ok)(content);
164
142
  } catch (error) {
165
- return Err(error);
143
+ return (0, import_types.Err)(error);
166
144
  }
167
145
  }
168
146
  async function findFiles(pattern, cwd = process.cwd()) {
@@ -192,14 +170,14 @@ async function validateFileStructure(projectPath, conventions) {
192
170
  unexpected,
193
171
  conformance
194
172
  };
195
- return Ok(validation);
173
+ return (0, import_types.Ok)(validation);
196
174
  }
197
175
 
198
176
  // src/validation/config.ts
199
177
  function validateConfig(data, schema) {
200
178
  const result = schema.safeParse(data);
201
179
  if (result.success) {
202
- return Ok(result.data);
180
+ return (0, import_types.Ok)(result.data);
203
181
  }
204
182
  const zodErrors = result.error;
205
183
  const firstError = zodErrors.errors[0];
@@ -207,15 +185,15 @@ function validateConfig(data, schema) {
207
185
  let message = "Configuration validation failed";
208
186
  const suggestions = [];
209
187
  if (firstError) {
210
- const path2 = firstError.path.join(".");
211
- const pathDisplay = path2 ? ` at "${path2}"` : "";
188
+ const path3 = firstError.path.join(".");
189
+ const pathDisplay = path3 ? ` at "${path3}"` : "";
212
190
  if (firstError.code === "invalid_type") {
213
191
  const received = firstError.received;
214
192
  const expected = firstError.expected;
215
193
  if (received === "undefined") {
216
194
  code = "MISSING_FIELD";
217
195
  message = `Missing required field${pathDisplay}: ${firstError.message}`;
218
- suggestions.push(`Field "${path2}" is required and must be of type "${expected}"`);
196
+ suggestions.push(`Field "${path3}" is required and must be of type "${expected}"`);
219
197
  } else {
220
198
  code = "INVALID_TYPE";
221
199
  message = `Invalid type${pathDisplay}: ${firstError.message}`;
@@ -235,7 +213,7 @@ function validateConfig(data, schema) {
235
213
  },
236
214
  suggestions
237
215
  );
238
- return Err(error);
216
+ return (0, import_types.Err)(error);
239
217
  }
240
218
 
241
219
  // src/validation/commit-message.ts
@@ -261,12 +239,12 @@ function validateCommitMessage(message, format = "conventional") {
261
239
  { message },
262
240
  ["Provide a valid commit message"]
263
241
  );
264
- return Err(error);
242
+ return (0, import_types.Err)(error);
265
243
  }
266
244
  if (format === "conventional" || format === "angular") {
267
245
  return validateConventionalCommit(message);
268
246
  }
269
- return Ok({
247
+ return (0, import_types.Ok)({
270
248
  valid: true,
271
249
  breaking: false,
272
250
  issues: []
@@ -282,7 +260,7 @@ function validateConventionalCommit(message) {
282
260
  { message },
283
261
  ["Provide a commit message with at least a header line"]
284
262
  );
285
- return Err(error);
263
+ return (0, import_types.Err)(error);
286
264
  }
287
265
  const match = headerLine.match(CONVENTIONAL_PATTERN);
288
266
  if (!match) {
@@ -296,7 +274,7 @@ function validateConventionalCommit(message) {
296
274
  "Example: feat(core): add new feature"
297
275
  ]
298
276
  );
299
- return Err(error);
277
+ return (0, import_types.Err)(error);
300
278
  }
301
279
  const type = match[1];
302
280
  const scope = match[3];
@@ -327,7 +305,7 @@ function validateConventionalCommit(message) {
327
305
  { message, issues, type, scope },
328
306
  ["Review and fix the validation issues above"]
329
307
  );
330
- return Err(error);
308
+ return (0, import_types.Err)(error);
331
309
  }
332
310
  const result = {
333
311
  valid: true,
@@ -336,7 +314,7 @@ function validateConventionalCommit(message) {
336
314
  breaking: hasBreakingChange,
337
315
  issues: []
338
316
  };
339
- return Ok(result);
317
+ return (0, import_types.Ok)(result);
340
318
  }
341
319
 
342
320
  // src/context/types.ts
@@ -428,27 +406,27 @@ function extractSections(content) {
428
406
  return result;
429
407
  });
430
408
  }
431
- function isExternalLink(path2) {
432
- return path2.startsWith("http://") || path2.startsWith("https://") || path2.startsWith("#") || path2.startsWith("mailto:");
409
+ function isExternalLink(path3) {
410
+ return path3.startsWith("http://") || path3.startsWith("https://") || path3.startsWith("#") || path3.startsWith("mailto:");
433
411
  }
434
412
  function resolveLinkPath(linkPath, baseDir) {
435
413
  return linkPath.startsWith(".") ? (0, import_path.join)(baseDir, linkPath) : linkPath;
436
414
  }
437
- async function validateAgentsMap(path2 = "./AGENTS.md") {
438
- const contentResult = await readFileContent(path2);
415
+ async function validateAgentsMap(path3 = "./AGENTS.md") {
416
+ const contentResult = await readFileContent(path3);
439
417
  if (!contentResult.ok) {
440
- return Err(
418
+ return (0, import_types.Err)(
441
419
  createError(
442
420
  "PARSE_ERROR",
443
421
  `Failed to read AGENTS.md: ${contentResult.error.message}`,
444
- { path: path2 },
422
+ { path: path3 },
445
423
  ["Ensure the file exists", "Check file permissions"]
446
424
  )
447
425
  );
448
426
  }
449
427
  const content = contentResult.value;
450
428
  const sections = extractSections(content);
451
- const baseDir = (0, import_path.dirname)(path2);
429
+ const baseDir = (0, import_path.dirname)(path3);
452
430
  const sectionTitles = sections.map((s) => s.title);
453
431
  const missingSections = REQUIRED_SECTIONS.filter(
454
432
  (required) => !sectionTitles.some((title) => title.toLowerCase().includes(required.toLowerCase()))
@@ -478,7 +456,7 @@ async function validateAgentsMap(path2 = "./AGENTS.md") {
478
456
  );
479
457
  }
480
458
  const valid = missingSections.length === 0 && brokenLinks.length === 0;
481
- return Ok({
459
+ return (0, import_types.Ok)({
482
460
  valid,
483
461
  sections,
484
462
  totalLinks: allLinks.length,
@@ -555,7 +533,7 @@ async function checkDocCoverage(domain, options = {}) {
555
533
  }
556
534
  const total = documented.length + undocumented.length;
557
535
  const coveragePercentage = total > 0 ? Math.round(documented.length / total * 100) : 100;
558
- return Ok({
536
+ return (0, import_types.Ok)({
559
537
  domain,
560
538
  documented,
561
539
  undocumented,
@@ -563,7 +541,7 @@ async function checkDocCoverage(domain, options = {}) {
563
541
  gaps
564
542
  });
565
543
  } catch (error) {
566
- return Err(
544
+ return (0, import_types.Err)(
567
545
  createError(
568
546
  "PARSE_ERROR",
569
547
  `Failed to analyze documentation coverage: ${error.message}`,
@@ -576,8 +554,8 @@ async function checkDocCoverage(domain, options = {}) {
576
554
 
577
555
  // src/context/knowledge-map.ts
578
556
  var import_path3 = require("path");
579
- function suggestFix(path2, existingFiles) {
580
- const targetName = (0, import_path3.basename)(path2).toLowerCase();
557
+ function suggestFix(path3, existingFiles) {
558
+ const targetName = (0, import_path3.basename)(path3).toLowerCase();
581
559
  const similar = existingFiles.find((file) => {
582
560
  const fileName = (0, import_path3.basename)(file).toLowerCase();
583
561
  return fileName.includes(targetName) || targetName.includes(fileName);
@@ -585,13 +563,13 @@ function suggestFix(path2, existingFiles) {
585
563
  if (similar) {
586
564
  return `Did you mean "${similar}"?`;
587
565
  }
588
- return `Create the file "${path2}" or remove the link`;
566
+ return `Create the file "${path3}" or remove the link`;
589
567
  }
590
568
  async function validateKnowledgeMap(rootDir = process.cwd()) {
591
569
  const agentsPath = (0, import_path3.join)(rootDir, "AGENTS.md");
592
570
  const agentsResult = await validateAgentsMap(agentsPath);
593
571
  if (!agentsResult.ok) {
594
- return Err(agentsResult.error);
572
+ return (0, import_types.Err)(agentsResult.error);
595
573
  }
596
574
  const {
597
575
  sections,
@@ -615,7 +593,7 @@ async function validateKnowledgeMap(rootDir = process.cwd()) {
615
593
  });
616
594
  const validLinks = agentsTotalLinks - brokenLinks.length;
617
595
  const integrity = agentsTotalLinks > 0 ? Math.round(validLinks / agentsTotalLinks * 100) : 100;
618
- return Ok({
596
+ return (0, import_types.Ok)({
619
597
  totalLinks: agentsTotalLinks,
620
598
  brokenLinks,
621
599
  validLinks,
@@ -724,9 +702,9 @@ async function generateAgentsMap(config) {
724
702
  "> Document your development workflow: branching strategy, testing commands, deployment process."
725
703
  );
726
704
  lines.push("");
727
- return Ok(lines.join("\n"));
705
+ return (0, import_types.Ok)(lines.join("\n"));
728
706
  } catch (error) {
729
- return Err(
707
+ return (0, import_types.Err)(
730
708
  createError(
731
709
  "PARSE_ERROR",
732
710
  `Failed to generate AGENTS.md: ${error.message}`,
@@ -901,7 +879,7 @@ async function buildDependencyGraph(files, parser) {
901
879
  }
902
880
  }
903
881
  }
904
- return Ok({ nodes, edges });
882
+ return (0, import_types.Ok)({ nodes, edges });
905
883
  }
906
884
  function checkLayerViolations(graph, layers, rootDir) {
907
885
  const violations = [];
@@ -931,7 +909,7 @@ async function validateDependencies(config) {
931
909
  const healthResult = await parser.health();
932
910
  if (!healthResult.ok || !healthResult.value.available) {
933
911
  if (fallbackBehavior === "skip") {
934
- return Ok({
912
+ return (0, import_types.Ok)({
935
913
  valid: true,
936
914
  violations: [],
937
915
  graph: { nodes: [], edges: [] },
@@ -941,7 +919,7 @@ async function validateDependencies(config) {
941
919
  }
942
920
  if (fallbackBehavior === "warn") {
943
921
  console.warn(`Parser ${parser.name} unavailable, skipping validation`);
944
- return Ok({
922
+ return (0, import_types.Ok)({
945
923
  valid: true,
946
924
  violations: [],
947
925
  graph: { nodes: [], edges: [] },
@@ -949,7 +927,7 @@ async function validateDependencies(config) {
949
927
  reason: "Parser unavailable"
950
928
  });
951
929
  }
952
- return Err(
930
+ return (0, import_types.Err)(
953
931
  createError(
954
932
  "PARSER_UNAVAILABLE",
955
933
  `Parser ${parser.name} is not available`,
@@ -968,10 +946,10 @@ async function validateDependencies(config) {
968
946
  const uniqueFiles = [...new Set(allFiles)];
969
947
  const graphResult = await buildDependencyGraph(uniqueFiles, parser);
970
948
  if (!graphResult.ok) {
971
- return Err(graphResult.error);
949
+ return (0, import_types.Err)(graphResult.error);
972
950
  }
973
951
  const violations = checkLayerViolations(graphResult.value, layers, rootDir);
974
- return Ok({
952
+ return (0, import_types.Ok)({
975
953
  valid: violations.length === 0,
976
954
  violations,
977
955
  graph: graphResult.value
@@ -1055,7 +1033,7 @@ function detectCircularDeps(graph) {
1055
1033
  };
1056
1034
  });
1057
1035
  const largestCycle = cycles.reduce((max, c) => Math.max(max, c.size), 0);
1058
- return Ok({
1036
+ return (0, import_types.Ok)({
1059
1037
  hasCycles: cycles.length > 0,
1060
1038
  cycles,
1061
1039
  largestCycle
@@ -1077,13 +1055,13 @@ function createBoundaryValidator(schema, name) {
1077
1055
  parse(input) {
1078
1056
  const result = schema.safeParse(input);
1079
1057
  if (result.success) {
1080
- return Ok(result.data);
1058
+ return (0, import_types.Ok)(result.data);
1081
1059
  }
1082
1060
  const suggestions = result.error.issues.map((issue) => {
1083
- const path2 = issue.path.join(".");
1084
- return path2 ? `${path2}: ${issue.message}` : issue.message;
1061
+ const path3 = issue.path.join(".");
1062
+ return path3 ? `${path3}: ${issue.message}` : issue.message;
1085
1063
  });
1086
- return Err(
1064
+ return (0, import_types.Err)(
1087
1065
  createError(
1088
1066
  "BOUNDARY_ERROR",
1089
1067
  `Boundary validation failed for ${name}`,
@@ -1098,7 +1076,7 @@ function createBoundaryValidator(schema, name) {
1098
1076
  },
1099
1077
  validate(input) {
1100
1078
  const result = schema.safeParse(input);
1101
- return Ok(result.success);
1079
+ return (0, import_types.Ok)(result.success);
1102
1080
  }
1103
1081
  };
1104
1082
  }
@@ -1119,7 +1097,7 @@ function validateBoundaries(boundaries, data) {
1119
1097
  });
1120
1098
  }
1121
1099
  }
1122
- return Ok({
1100
+ return (0, import_types.Ok)({
1123
1101
  valid: violations.length === 0,
1124
1102
  violations
1125
1103
  });
@@ -1150,11 +1128,11 @@ function walk(node, visitor) {
1150
1128
  var TypeScriptParser = class {
1151
1129
  name = "typescript";
1152
1130
  extensions = [".ts", ".tsx", ".mts", ".cts"];
1153
- async parseFile(path2) {
1154
- const contentResult = await readFileContent(path2);
1131
+ async parseFile(path3) {
1132
+ const contentResult = await readFileContent(path3);
1155
1133
  if (!contentResult.ok) {
1156
- return Err(
1157
- createParseError("NOT_FOUND", `File not found: ${path2}`, { path: path2 }, [
1134
+ return (0, import_types.Err)(
1135
+ createParseError("NOT_FOUND", `File not found: ${path3}`, { path: path3 }, [
1158
1136
  "Check that the file exists",
1159
1137
  "Verify the path is correct"
1160
1138
  ])
@@ -1164,18 +1142,18 @@ var TypeScriptParser = class {
1164
1142
  const ast = (0, import_typescript_estree.parse)(contentResult.value, {
1165
1143
  loc: true,
1166
1144
  range: true,
1167
- jsx: path2.endsWith(".tsx"),
1145
+ jsx: path3.endsWith(".tsx"),
1168
1146
  errorOnUnknownASTType: false
1169
1147
  });
1170
- return Ok({
1148
+ return (0, import_types.Ok)({
1171
1149
  type: "Program",
1172
1150
  body: ast,
1173
1151
  language: "typescript"
1174
1152
  });
1175
1153
  } catch (e) {
1176
1154
  const error = e;
1177
- return Err(
1178
- createParseError("SYNTAX_ERROR", `Failed to parse ${path2}: ${error.message}`, { path: path2 }, [
1155
+ return (0, import_types.Err)(
1156
+ createParseError("SYNTAX_ERROR", `Failed to parse ${path3}: ${error.message}`, { path: path3 }, [
1179
1157
  "Check for syntax errors in the file",
1180
1158
  "Ensure valid TypeScript syntax"
1181
1159
  ])
@@ -1228,7 +1206,7 @@ var TypeScriptParser = class {
1228
1206
  }
1229
1207
  }
1230
1208
  });
1231
- return Ok(imports);
1209
+ return (0, import_types.Ok)(imports);
1232
1210
  }
1233
1211
  extractExports(ast) {
1234
1212
  const exports2 = [];
@@ -1333,10 +1311,10 @@ var TypeScriptParser = class {
1333
1311
  });
1334
1312
  }
1335
1313
  });
1336
- return Ok(exports2);
1314
+ return (0, import_types.Ok)(exports2);
1337
1315
  }
1338
1316
  async health() {
1339
- return Ok({ available: true, version: "7.0.0" });
1317
+ return (0, import_types.Ok)({ available: true, version: "7.0.0" });
1340
1318
  }
1341
1319
  };
1342
1320
 
@@ -1346,7 +1324,7 @@ var import_minimatch2 = require("minimatch");
1346
1324
  async function resolveEntryPoints(rootDir, explicitEntries) {
1347
1325
  if (explicitEntries && explicitEntries.length > 0) {
1348
1326
  const resolved = explicitEntries.map((e) => (0, import_path6.resolve)(rootDir, e));
1349
- return Ok(resolved);
1327
+ return (0, import_types.Ok)(resolved);
1350
1328
  }
1351
1329
  const pkgPath = (0, import_path6.join)(rootDir, "package.json");
1352
1330
  if (await fileExists(pkgPath)) {
@@ -1384,7 +1362,7 @@ async function resolveEntryPoints(rootDir, explicitEntries) {
1384
1362
  }
1385
1363
  }
1386
1364
  if (entries.length > 0) {
1387
- return Ok(entries);
1365
+ return (0, import_types.Ok)(entries);
1388
1366
  }
1389
1367
  } catch {
1390
1368
  }
@@ -1394,10 +1372,10 @@ async function resolveEntryPoints(rootDir, explicitEntries) {
1394
1372
  for (const conv of conventions) {
1395
1373
  const convPath = (0, import_path6.join)(rootDir, conv);
1396
1374
  if (await fileExists(convPath)) {
1397
- return Ok([convPath]);
1375
+ return (0, import_types.Ok)([convPath]);
1398
1376
  }
1399
1377
  }
1400
- return Err(
1378
+ return (0, import_types.Err)(
1401
1379
  createEntropyError(
1402
1380
  "ENTRY_POINT_NOT_FOUND",
1403
1381
  "Could not resolve entry points",
@@ -1459,22 +1437,22 @@ function extractInlineRefs(content) {
1459
1437
  }
1460
1438
  return refs;
1461
1439
  }
1462
- async function parseDocumentationFile(path2) {
1463
- const contentResult = await readFileContent(path2);
1440
+ async function parseDocumentationFile(path3) {
1441
+ const contentResult = await readFileContent(path3);
1464
1442
  if (!contentResult.ok) {
1465
- return Err(
1443
+ return (0, import_types.Err)(
1466
1444
  createEntropyError(
1467
1445
  "PARSE_ERROR",
1468
- `Failed to read documentation file: ${path2}`,
1469
- { file: path2 },
1446
+ `Failed to read documentation file: ${path3}`,
1447
+ { file: path3 },
1470
1448
  ["Check that the file exists"]
1471
1449
  )
1472
1450
  );
1473
1451
  }
1474
1452
  const content = contentResult.value;
1475
- const type = path2.endsWith(".md") ? "markdown" : "text";
1476
- return Ok({
1477
- path: path2,
1453
+ const type = path3.endsWith(".md") ? "markdown" : "text";
1454
+ return (0, import_types.Ok)({
1455
+ path: path3,
1478
1456
  type,
1479
1457
  content,
1480
1458
  codeBlocks: extractCodeBlocks(content),
@@ -1590,7 +1568,7 @@ async function buildSnapshot(config) {
1590
1568
  const rootDir = (0, import_path6.resolve)(config.rootDir);
1591
1569
  const entryPointsResult = await resolveEntryPoints(rootDir, config.entryPoints);
1592
1570
  if (!entryPointsResult.ok) {
1593
- return Err(entryPointsResult.error);
1571
+ return (0, import_types.Err)(entryPointsResult.error);
1594
1572
  }
1595
1573
  const includePatterns = config.include || ["**/*.ts", "**/*.tsx"];
1596
1574
  const excludePatterns = config.exclude || [
@@ -1644,7 +1622,7 @@ async function buildSnapshot(config) {
1644
1622
  const exportMap = buildExportMap(files);
1645
1623
  const codeReferences = extractAllCodeReferences(docs);
1646
1624
  const buildTime = Date.now() - startTime;
1647
- return Ok({
1625
+ return (0, import_types.Ok)({
1648
1626
  files,
1649
1627
  dependencyGraph,
1650
1628
  exportMap,
@@ -1795,7 +1773,7 @@ async function detectDocDrift(snapshot, config) {
1795
1773
  const exampleDrifts = drifts.filter((d) => d.type === "example-code").length;
1796
1774
  const structureDrifts = drifts.filter((d) => d.type === "structure").length;
1797
1775
  const severity = drifts.length === 0 ? "none" : drifts.length <= 3 ? "low" : drifts.length <= 10 ? "medium" : "high";
1798
- return Ok({
1776
+ return (0, import_types.Ok)({
1799
1777
  drifts,
1800
1778
  stats: {
1801
1779
  docsScanned: snapshot.docs.length,
@@ -2047,7 +2025,7 @@ async function detectDeadCode(snapshot) {
2047
2025
  estimatedDeadLines
2048
2026
  }
2049
2027
  };
2050
- return Ok(report);
2028
+ return (0, import_types.Ok)(report);
2051
2029
  }
2052
2030
 
2053
2031
  // src/entropy/detectors/patterns.ts
@@ -2204,7 +2182,7 @@ async function detectPatternViolations(snapshot, config) {
2204
2182
  const warningCount = violations.filter((v) => v.severity === "warning").length;
2205
2183
  const totalChecks = snapshot.files.length * patterns.length;
2206
2184
  const passRate = totalChecks > 0 ? (totalChecks - violations.length) / totalChecks : 1;
2207
- return Ok({
2185
+ return (0, import_types.Ok)({
2208
2186
  violations,
2209
2187
  stats: {
2210
2188
  filesChecked: snapshot.files.length,
@@ -2352,7 +2330,7 @@ var EntropyAnalyzer = class {
2352
2330
  const startTime = Date.now();
2353
2331
  const snapshotResult = await buildSnapshot(this.config);
2354
2332
  if (!snapshotResult.ok) {
2355
- return Err(snapshotResult.error);
2333
+ return (0, import_types.Err)(snapshotResult.error);
2356
2334
  }
2357
2335
  this.snapshot = snapshotResult.value;
2358
2336
  let driftReport;
@@ -2417,7 +2395,7 @@ var EntropyAnalyzer = class {
2417
2395
  report.patterns = patternReport;
2418
2396
  }
2419
2397
  this.report = report;
2420
- return Ok(report);
2398
+ return (0, import_types.Ok)(report);
2421
2399
  }
2422
2400
  /**
2423
2401
  * Get the built snapshot (must call analyze first)
@@ -2459,7 +2437,7 @@ var EntropyAnalyzer = class {
2459
2437
  */
2460
2438
  async ensureSnapshot() {
2461
2439
  if (this.snapshot) {
2462
- return Ok(this.snapshot);
2440
+ return (0, import_types.Ok)(this.snapshot);
2463
2441
  }
2464
2442
  return this.buildSnapshot();
2465
2443
  }
@@ -2469,7 +2447,7 @@ var EntropyAnalyzer = class {
2469
2447
  async detectDrift(config) {
2470
2448
  const snapshotResult = await this.ensureSnapshot();
2471
2449
  if (!snapshotResult.ok) {
2472
- return Err(snapshotResult.error);
2450
+ return (0, import_types.Err)(snapshotResult.error);
2473
2451
  }
2474
2452
  return detectDocDrift(snapshotResult.value, config || {});
2475
2453
  }
@@ -2479,7 +2457,7 @@ var EntropyAnalyzer = class {
2479
2457
  async detectDeadCode() {
2480
2458
  const snapshotResult = await this.ensureSnapshot();
2481
2459
  if (!snapshotResult.ok) {
2482
- return Err(snapshotResult.error);
2460
+ return (0, import_types.Err)(snapshotResult.error);
2483
2461
  }
2484
2462
  return detectDeadCode(snapshotResult.value);
2485
2463
  }
@@ -2489,7 +2467,7 @@ var EntropyAnalyzer = class {
2489
2467
  async detectPatterns(config) {
2490
2468
  const snapshotResult = await this.ensureSnapshot();
2491
2469
  if (!snapshotResult.ok) {
2492
- return Err(snapshotResult.error);
2470
+ return (0, import_types.Err)(snapshotResult.error);
2493
2471
  }
2494
2472
  return detectPatternViolations(snapshotResult.value, config);
2495
2473
  }
@@ -2564,9 +2542,9 @@ async function createBackup(filePath, backupDir) {
2564
2542
  try {
2565
2543
  await mkdir2((0, import_path10.dirname)(backupPath), { recursive: true });
2566
2544
  await copyFile2(filePath, backupPath);
2567
- return Ok(backupPath);
2545
+ return (0, import_types.Ok)(backupPath);
2568
2546
  } catch (e) {
2569
- return Err(
2547
+ return (0, import_types.Err)(
2570
2548
  createEntropyError(
2571
2549
  "BACKUP_FAILED",
2572
2550
  `Failed to create backup: ${filePath}`,
@@ -2578,7 +2556,7 @@ async function createBackup(filePath, backupDir) {
2578
2556
  }
2579
2557
  async function applySingleFix(fix, config) {
2580
2558
  if (config.dryRun) {
2581
- return Ok(fix);
2559
+ return (0, import_types.Ok)(fix);
2582
2560
  }
2583
2561
  try {
2584
2562
  switch (fix.action) {
@@ -2586,7 +2564,7 @@ async function applySingleFix(fix, config) {
2586
2564
  if (config.createBackup && config.backupDir) {
2587
2565
  const backupResult = await createBackup(fix.file, config.backupDir);
2588
2566
  if (!backupResult.ok) {
2589
- return Err({ fix, error: backupResult.error.message });
2567
+ return (0, import_types.Err)({ fix, error: backupResult.error.message });
2590
2568
  }
2591
2569
  }
2592
2570
  await unlink2(fix.file);
@@ -2615,9 +2593,9 @@ async function applySingleFix(fix, config) {
2615
2593
  }
2616
2594
  break;
2617
2595
  }
2618
- return Ok(fix);
2596
+ return (0, import_types.Ok)(fix);
2619
2597
  } catch (e) {
2620
- return Err({ fix, error: e.message });
2598
+ return (0, import_types.Err)({ fix, error: e.message });
2621
2599
  }
2622
2600
  }
2623
2601
  async function applyFixes(fixes, config) {
@@ -2648,7 +2626,7 @@ async function applyFixes(fixes, config) {
2648
2626
  errors.push(result.error);
2649
2627
  }
2650
2628
  }
2651
- return Ok({
2629
+ return (0, import_types.Ok)({
2652
2630
  applied,
2653
2631
  skipped,
2654
2632
  errors,
@@ -2757,7 +2735,7 @@ function validatePatternConfig(config) {
2757
2735
  const result = PatternConfigSchema.safeParse(config);
2758
2736
  if (!result.success) {
2759
2737
  const issues = result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
2760
- return Err(
2738
+ return (0, import_types.Err)(
2761
2739
  createEntropyError(
2762
2740
  "CONFIG_VALIDATION_ERROR",
2763
2741
  `Invalid pattern config: ${issues}`,
@@ -2766,23 +2744,23 @@ function validatePatternConfig(config) {
2766
2744
  )
2767
2745
  );
2768
2746
  }
2769
- return Ok(result.data);
2747
+ return (0, import_types.Ok)(result.data);
2770
2748
  }
2771
2749
 
2772
2750
  // src/feedback/telemetry/noop.ts
2773
2751
  var NoOpTelemetryAdapter = class {
2774
2752
  name = "noop";
2775
2753
  async health() {
2776
- return Ok({ available: true, message: "NoOp adapter - no real telemetry" });
2754
+ return (0, import_types.Ok)({ available: true, message: "NoOp adapter - no real telemetry" });
2777
2755
  }
2778
2756
  async getMetrics() {
2779
- return Ok([]);
2757
+ return (0, import_types.Ok)([]);
2780
2758
  }
2781
2759
  async getTraces() {
2782
- return Ok([]);
2760
+ return (0, import_types.Ok)([]);
2783
2761
  }
2784
2762
  async getLogs() {
2785
- return Ok([]);
2763
+ return (0, import_types.Ok)([]);
2786
2764
  }
2787
2765
  };
2788
2766
 
@@ -2803,7 +2781,7 @@ var NoOpExecutor = class {
2803
2781
  name = "noop";
2804
2782
  processes = /* @__PURE__ */ new Map();
2805
2783
  async health() {
2806
- return Ok({ available: true, message: "NoOp executor - no real agent spawning" });
2784
+ return (0, import_types.Ok)({ available: true, message: "NoOp executor - no real agent spawning" });
2807
2785
  }
2808
2786
  async spawn(config) {
2809
2787
  const id = generateId();
@@ -2814,31 +2792,31 @@ var NoOpExecutor = class {
2814
2792
  config
2815
2793
  };
2816
2794
  this.processes.set(id, process2);
2817
- return Ok(process2);
2795
+ return (0, import_types.Ok)(process2);
2818
2796
  }
2819
2797
  async status(processId) {
2820
2798
  const process2 = this.processes.get(processId);
2821
2799
  if (!process2) {
2822
- return Err({
2800
+ return (0, import_types.Err)({
2823
2801
  code: "AGENT_SPAWN_ERROR",
2824
2802
  message: "Process not found",
2825
2803
  details: { agentId: processId },
2826
2804
  suggestions: ["Check if the process ID is correct"]
2827
2805
  });
2828
2806
  }
2829
- return Ok(process2);
2807
+ return (0, import_types.Ok)(process2);
2830
2808
  }
2831
2809
  async wait(processId) {
2832
2810
  const process2 = this.processes.get(processId);
2833
2811
  if (!process2) {
2834
- return Err({
2812
+ return (0, import_types.Err)({
2835
2813
  code: "AGENT_SPAWN_ERROR",
2836
2814
  message: "Process not found",
2837
2815
  details: { agentId: processId },
2838
2816
  suggestions: ["Check if the process ID is correct"]
2839
2817
  });
2840
2818
  }
2841
- return Ok({
2819
+ return (0, import_types.Ok)({
2842
2820
  agentId: processId,
2843
2821
  agentType: process2.config.type,
2844
2822
  approved: true,
@@ -2850,7 +2828,7 @@ var NoOpExecutor = class {
2850
2828
  }
2851
2829
  async kill(processId) {
2852
2830
  this.processes.delete(processId);
2853
- return Ok(void 0);
2831
+ return (0, import_types.Ok)(void 0);
2854
2832
  }
2855
2833
  };
2856
2834
 
@@ -2868,7 +2846,7 @@ var ConsoleSink = class {
2868
2846
  async write(action) {
2869
2847
  const output = this.options.format === "json" ? JSON.stringify(action) : this.formatPretty(action);
2870
2848
  console.log(output);
2871
- return Ok(void 0);
2849
+ return (0, import_types.Ok)(void 0);
2872
2850
  }
2873
2851
  formatPretty(action) {
2874
2852
  const status = action.status === "completed" ? "\u2713" : action.status === "failed" ? "\u2717" : "\u2192";
@@ -2909,7 +2887,7 @@ function resetFeedbackConfig() {
2909
2887
  function parseDiff(diff) {
2910
2888
  try {
2911
2889
  if (!diff.trim()) {
2912
- return Ok({ diff, files: [] });
2890
+ return (0, import_types.Ok)({ diff, files: [] });
2913
2891
  }
2914
2892
  const files = [];
2915
2893
  const newFileRegex = /new file mode/;
@@ -2939,9 +2917,9 @@ function parseDiff(diff) {
2939
2917
  deletions
2940
2918
  });
2941
2919
  }
2942
- return Ok({ diff, files });
2920
+ return (0, import_types.Ok)({ diff, files });
2943
2921
  } catch (error) {
2944
- return Err({
2922
+ return (0, import_types.Err)({
2945
2923
  code: "DIFF_PARSE_ERROR",
2946
2924
  message: "Failed to parse git diff",
2947
2925
  details: { reason: String(error) },
@@ -2951,7 +2929,7 @@ function parseDiff(diff) {
2951
2929
  }
2952
2930
  async function analyzeDiff(changes, options) {
2953
2931
  if (!options?.enabled) {
2954
- return Ok([]);
2932
+ return (0, import_types.Ok)([]);
2955
2933
  }
2956
2934
  const items = [];
2957
2935
  let itemId = 0;
@@ -3023,7 +3001,7 @@ async function analyzeDiff(changes, options) {
3023
3001
  }
3024
3002
  }
3025
3003
  }
3026
- return Ok(items);
3004
+ return (0, import_types.Ok)(items);
3027
3005
  }
3028
3006
 
3029
3007
  // src/feedback/review/checklist.ts
@@ -3144,7 +3122,7 @@ var ChecklistBuilder = class {
3144
3122
  },
3145
3123
  duration: Date.now() - startTime
3146
3124
  };
3147
- return Ok(checklist);
3125
+ return (0, import_types.Ok)(checklist);
3148
3126
  }
3149
3127
  };
3150
3128
 
@@ -3235,7 +3213,7 @@ async function logAgentAction(action) {
3235
3213
  await sink.write(fullAction);
3236
3214
  }
3237
3215
  }
3238
- return Ok(fullAction);
3216
+ return (0, import_types.Ok)(fullAction);
3239
3217
  }
3240
3218
  function trackAction(type, context) {
3241
3219
  const startTime = Date.now();
@@ -3278,7 +3256,7 @@ async function requestPeerReview(agentType, context, options) {
3278
3256
  const config = getFeedbackConfig();
3279
3257
  const executor = config.executor;
3280
3258
  if (!executor) {
3281
- return Err({
3259
+ return (0, import_types.Err)({
3282
3260
  code: "AGENT_SPAWN_ERROR",
3283
3261
  message: "No agent executor configured",
3284
3262
  details: {},
@@ -3331,7 +3309,7 @@ async function requestPeerReview(agentType, context, options) {
3331
3309
  summary: `Agent spawned: ${spawnResult.value.id}`,
3332
3310
  data: { processId: spawnResult.value.id }
3333
3311
  });
3334
- return Ok({
3312
+ return (0, import_types.Ok)({
3335
3313
  agentId: spawnResult.value.id,
3336
3314
  agentType,
3337
3315
  approved: false,
@@ -3346,7 +3324,7 @@ async function requestPeerReview(agentType, context, options) {
3346
3324
  code: "AGENT_SPAWN_ERROR",
3347
3325
  message: String(error)
3348
3326
  });
3349
- return Err({
3327
+ return (0, import_types.Err)({
3350
3328
  code: "AGENT_SPAWN_ERROR",
3351
3329
  message: "Failed to request peer review",
3352
3330
  details: { reason: String(error) },
@@ -3356,7 +3334,7 @@ async function requestPeerReview(agentType, context, options) {
3356
3334
  }
3357
3335
  async function requestMultiplePeerReviews(requests) {
3358
3336
  if (requests.length === 0) {
3359
- return Ok([]);
3337
+ return (0, import_types.Ok)([]);
3360
3338
  }
3361
3339
  const results = await Promise.all(
3362
3340
  requests.map(
@@ -3365,9 +3343,9 @@ async function requestMultiplePeerReviews(requests) {
3365
3343
  );
3366
3344
  const firstError = results.find((r) => !r.ok);
3367
3345
  if (firstError && !firstError.ok) {
3368
- return Err(firstError.error);
3346
+ return (0, import_types.Err)(firstError.error);
3369
3347
  }
3370
- return Ok(results.map((r) => r.value));
3348
+ return (0, import_types.Ok)(results.map((r) => r.value));
3371
3349
  }
3372
3350
 
3373
3351
  // src/feedback/logging/file-sink.ts
@@ -3409,9 +3387,9 @@ var FileSink = class {
3409
3387
  if (this.buffer.length >= (this.options.bufferSize ?? 1)) {
3410
3388
  return this.flush();
3411
3389
  }
3412
- return Ok(void 0);
3390
+ return (0, import_types.Ok)(void 0);
3413
3391
  } catch (error) {
3414
- return Err({
3392
+ return (0, import_types.Err)({
3415
3393
  code: "SINK_ERROR",
3416
3394
  message: "Failed to write action to file",
3417
3395
  details: { reason: String(error) },
@@ -3421,7 +3399,7 @@ var FileSink = class {
3421
3399
  }
3422
3400
  async flush() {
3423
3401
  if (this.buffer.length === 0) {
3424
- return Ok(void 0);
3402
+ return (0, import_types.Ok)(void 0);
3425
3403
  }
3426
3404
  try {
3427
3405
  this.ensureDirectory();
@@ -3432,9 +3410,9 @@ var FileSink = class {
3432
3410
  } else {
3433
3411
  (0, import_fs2.appendFileSync)(this.filePath, content);
3434
3412
  }
3435
- return Ok(void 0);
3413
+ return (0, import_types.Ok)(void 0);
3436
3414
  } catch (error) {
3437
- return Err({
3415
+ return (0, import_types.Err)({
3438
3416
  code: "SINK_ERROR",
3439
3417
  message: "Failed to flush actions to file",
3440
3418
  details: { reason: String(error) },
@@ -3454,7 +3432,7 @@ var FileSink = class {
3454
3432
  var NoOpSink = class {
3455
3433
  name = "noop";
3456
3434
  async write() {
3457
- return Ok(void 0);
3435
+ return (0, import_types.Ok)(void 0);
3458
3436
  }
3459
3437
  };
3460
3438
 
@@ -3552,18 +3530,18 @@ var GATE_CONFIG_FILE = "gate.json";
3552
3530
  async function loadState(projectPath) {
3553
3531
  const statePath = path.join(projectPath, HARNESS_DIR, STATE_FILE);
3554
3532
  if (!fs2.existsSync(statePath)) {
3555
- return Ok({ ...DEFAULT_STATE });
3533
+ return (0, import_types.Ok)({ ...DEFAULT_STATE });
3556
3534
  }
3557
3535
  try {
3558
3536
  const raw = fs2.readFileSync(statePath, "utf-8");
3559
3537
  const parsed = JSON.parse(raw);
3560
3538
  const result = HarnessStateSchema.safeParse(parsed);
3561
3539
  if (!result.success) {
3562
- return Err(new Error(`Invalid state file ${statePath}: ${result.error.message}`));
3540
+ return (0, import_types.Err)(new Error(`Invalid state file ${statePath}: ${result.error.message}`));
3563
3541
  }
3564
- return Ok(result.data);
3542
+ return (0, import_types.Ok)(result.data);
3565
3543
  } catch (error) {
3566
- return Err(
3544
+ return (0, import_types.Err)(
3567
3545
  new Error(
3568
3546
  `Failed to load state from ${statePath}: ${error instanceof Error ? error.message : String(error)}`
3569
3547
  )
@@ -3576,9 +3554,9 @@ async function saveState(projectPath, state) {
3576
3554
  try {
3577
3555
  fs2.mkdirSync(harnessDir, { recursive: true });
3578
3556
  fs2.writeFileSync(statePath, JSON.stringify(state, null, 2));
3579
- return Ok(void 0);
3557
+ return (0, import_types.Ok)(void 0);
3580
3558
  } catch (error) {
3581
- return Err(
3559
+ return (0, import_types.Err)(
3582
3560
  new Error(`Failed to save state: ${error instanceof Error ? error.message : String(error)}`)
3583
3561
  );
3584
3562
  }
@@ -3609,9 +3587,9 @@ ${entry}`);
3609
3587
  } else {
3610
3588
  fs2.appendFileSync(learningsPath, entry);
3611
3589
  }
3612
- return Ok(void 0);
3590
+ return (0, import_types.Ok)(void 0);
3613
3591
  } catch (error) {
3614
- return Err(
3592
+ return (0, import_types.Err)(
3615
3593
  new Error(
3616
3594
  `Failed to append learning: ${error instanceof Error ? error.message : String(error)}`
3617
3595
  )
@@ -3621,7 +3599,7 @@ ${entry}`);
3621
3599
  async function loadRelevantLearnings(projectPath, skillName) {
3622
3600
  const learningsPath = path.join(projectPath, HARNESS_DIR, LEARNINGS_FILE);
3623
3601
  if (!fs2.existsSync(learningsPath)) {
3624
- return Ok([]);
3602
+ return (0, import_types.Ok)([]);
3625
3603
  }
3626
3604
  try {
3627
3605
  const content = fs2.readFileSync(learningsPath, "utf-8");
@@ -3645,12 +3623,12 @@ async function loadRelevantLearnings(projectPath, skillName) {
3645
3623
  entries.push(currentBlock.join("\n"));
3646
3624
  }
3647
3625
  if (!skillName) {
3648
- return Ok(entries);
3626
+ return (0, import_types.Ok)(entries);
3649
3627
  }
3650
3628
  const filtered = entries.filter((entry) => entry.includes(`[skill:${skillName}]`));
3651
- return Ok(filtered);
3629
+ return (0, import_types.Ok)(filtered);
3652
3630
  } catch (error) {
3653
- return Err(
3631
+ return (0, import_types.Err)(
3654
3632
  new Error(
3655
3633
  `Failed to load learnings: ${error instanceof Error ? error.message : String(error)}`
3656
3634
  )
@@ -3673,9 +3651,9 @@ ${entry}`);
3673
3651
  } else {
3674
3652
  fs2.appendFileSync(failuresPath, entry);
3675
3653
  }
3676
- return Ok(void 0);
3654
+ return (0, import_types.Ok)(void 0);
3677
3655
  } catch (error) {
3678
- return Err(
3656
+ return (0, import_types.Err)(
3679
3657
  new Error(
3680
3658
  `Failed to append failure: ${error instanceof Error ? error.message : String(error)}`
3681
3659
  )
@@ -3685,7 +3663,7 @@ ${entry}`);
3685
3663
  async function loadFailures(projectPath) {
3686
3664
  const failuresPath = path.join(projectPath, HARNESS_DIR, FAILURES_FILE);
3687
3665
  if (!fs2.existsSync(failuresPath)) {
3688
- return Ok([]);
3666
+ return (0, import_types.Ok)([]);
3689
3667
  }
3690
3668
  try {
3691
3669
  const content = fs2.readFileSync(failuresPath, "utf-8");
@@ -3701,9 +3679,9 @@ async function loadFailures(projectPath) {
3701
3679
  });
3702
3680
  }
3703
3681
  }
3704
- return Ok(entries);
3682
+ return (0, import_types.Ok)(entries);
3705
3683
  } catch (error) {
3706
- return Err(
3684
+ return (0, import_types.Err)(
3707
3685
  new Error(
3708
3686
  `Failed to load failures: ${error instanceof Error ? error.message : String(error)}`
3709
3687
  )
@@ -3714,7 +3692,7 @@ async function archiveFailures(projectPath) {
3714
3692
  const harnessDir = path.join(projectPath, HARNESS_DIR);
3715
3693
  const failuresPath = path.join(harnessDir, FAILURES_FILE);
3716
3694
  if (!fs2.existsSync(failuresPath)) {
3717
- return Ok(void 0);
3695
+ return (0, import_types.Ok)(void 0);
3718
3696
  }
3719
3697
  try {
3720
3698
  const archiveDir = path.join(harnessDir, "archive");
@@ -3727,9 +3705,9 @@ async function archiveFailures(projectPath) {
3727
3705
  counter++;
3728
3706
  }
3729
3707
  fs2.renameSync(failuresPath, path.join(archiveDir, archiveName));
3730
- return Ok(void 0);
3708
+ return (0, import_types.Ok)(void 0);
3731
3709
  } catch (error) {
3732
- return Err(
3710
+ return (0, import_types.Err)(
3733
3711
  new Error(
3734
3712
  `Failed to archive failures: ${error instanceof Error ? error.message : String(error)}`
3735
3713
  )
@@ -3742,9 +3720,9 @@ async function saveHandoff(projectPath, handoff) {
3742
3720
  try {
3743
3721
  fs2.mkdirSync(harnessDir, { recursive: true });
3744
3722
  fs2.writeFileSync(handoffPath, JSON.stringify(handoff, null, 2));
3745
- return Ok(void 0);
3723
+ return (0, import_types.Ok)(void 0);
3746
3724
  } catch (error) {
3747
- return Err(
3725
+ return (0, import_types.Err)(
3748
3726
  new Error(`Failed to save handoff: ${error instanceof Error ? error.message : String(error)}`)
3749
3727
  );
3750
3728
  }
@@ -3752,18 +3730,18 @@ async function saveHandoff(projectPath, handoff) {
3752
3730
  async function loadHandoff(projectPath) {
3753
3731
  const handoffPath = path.join(projectPath, HARNESS_DIR, HANDOFF_FILE);
3754
3732
  if (!fs2.existsSync(handoffPath)) {
3755
- return Ok(null);
3733
+ return (0, import_types.Ok)(null);
3756
3734
  }
3757
3735
  try {
3758
3736
  const raw = fs2.readFileSync(handoffPath, "utf-8");
3759
3737
  const parsed = JSON.parse(raw);
3760
3738
  const result = HandoffSchema.safeParse(parsed);
3761
3739
  if (!result.success) {
3762
- return Err(new Error(`Invalid handoff file: ${result.error.message}`));
3740
+ return (0, import_types.Err)(new Error(`Invalid handoff file: ${result.error.message}`));
3763
3741
  }
3764
- return Ok(result.data);
3742
+ return (0, import_types.Ok)(result.data);
3765
3743
  } catch (error) {
3766
- return Err(
3744
+ return (0, import_types.Err)(
3767
3745
  new Error(`Failed to load handoff: ${error instanceof Error ? error.message : String(error)}`)
3768
3746
  );
3769
3747
  }
@@ -3824,12 +3802,12 @@ async function runMechanicalGate(projectPath) {
3824
3802
  });
3825
3803
  }
3826
3804
  }
3827
- return Ok({
3805
+ return (0, import_types.Ok)({
3828
3806
  passed: results.length === 0 || results.every((r) => r.passed),
3829
3807
  checks: results
3830
3808
  });
3831
3809
  } catch (error) {
3832
- return Err(
3810
+ return (0, import_types.Err)(
3833
3811
  new Error(
3834
3812
  `Failed to run mechanical gate: ${error instanceof Error ? error.message : String(error)}`
3835
3813
  )
@@ -3985,8 +3963,183 @@ async function runMultiTurnPipeline(initialContext, turnExecutor, options) {
3985
3963
  };
3986
3964
  }
3987
3965
 
3966
+ // src/ci/check-orchestrator.ts
3967
+ var path2 = __toESM(require("path"));
3968
+ var ALL_CHECKS = ["validate", "deps", "docs", "entropy", "phase-gate"];
3969
+ async function runSingleCheck(name, projectRoot, config) {
3970
+ const start = Date.now();
3971
+ const issues = [];
3972
+ try {
3973
+ switch (name) {
3974
+ case "validate": {
3975
+ const agentsPath = path2.join(projectRoot, config.agentsMapPath ?? "AGENTS.md");
3976
+ const result = await validateAgentsMap(agentsPath);
3977
+ if (!result.ok) {
3978
+ issues.push({ severity: "error", message: result.error.message });
3979
+ } else if (!result.value.valid) {
3980
+ if (result.value.errors) {
3981
+ for (const err of result.value.errors) {
3982
+ issues.push({ severity: "error", message: err.message });
3983
+ }
3984
+ }
3985
+ for (const section of result.value.missingSections) {
3986
+ issues.push({ severity: "warning", message: `Missing section: ${section}` });
3987
+ }
3988
+ for (const link of result.value.brokenLinks) {
3989
+ issues.push({
3990
+ severity: "warning",
3991
+ message: `Broken link: ${link.text} \u2192 ${link.path}`,
3992
+ file: link.path
3993
+ });
3994
+ }
3995
+ }
3996
+ break;
3997
+ }
3998
+ case "deps": {
3999
+ const layers = config.layers;
4000
+ if (layers && layers.length > 0) {
4001
+ const parser = new TypeScriptParser();
4002
+ const result = await validateDependencies({
4003
+ layers,
4004
+ rootDir: projectRoot,
4005
+ parser
4006
+ });
4007
+ if (!result.ok) {
4008
+ issues.push({ severity: "error", message: result.error.message });
4009
+ } else if (result.value.violations.length > 0) {
4010
+ for (const v of result.value.violations) {
4011
+ issues.push({
4012
+ severity: "error",
4013
+ message: `${v.reason}: ${v.file} imports ${v.imports} (${v.fromLayer} \u2192 ${v.toLayer})`,
4014
+ file: v.file,
4015
+ line: v.line
4016
+ });
4017
+ }
4018
+ }
4019
+ }
4020
+ break;
4021
+ }
4022
+ case "docs": {
4023
+ const docsDir = path2.join(projectRoot, config.docsDir ?? "docs");
4024
+ const result = await checkDocCoverage("project", { docsDir });
4025
+ if (!result.ok) {
4026
+ issues.push({ severity: "warning", message: result.error.message });
4027
+ } else if (result.value.gaps.length > 0) {
4028
+ for (const gap of result.value.gaps) {
4029
+ issues.push({
4030
+ severity: "warning",
4031
+ message: `Undocumented: ${gap.file} (suggested: ${gap.suggestedSection})`,
4032
+ file: gap.file
4033
+ });
4034
+ }
4035
+ }
4036
+ break;
4037
+ }
4038
+ case "entropy": {
4039
+ const analyzer = new EntropyAnalyzer({
4040
+ rootDir: projectRoot,
4041
+ analyze: { drift: true, deadCode: true, patterns: false }
4042
+ });
4043
+ const result = await analyzer.analyze();
4044
+ if (!result.ok) {
4045
+ issues.push({ severity: "warning", message: result.error.message });
4046
+ } else {
4047
+ const report = result.value;
4048
+ if (report.drift) {
4049
+ for (const drift of report.drift.drifts) {
4050
+ issues.push({
4051
+ severity: "warning",
4052
+ message: `Doc drift (${drift.type}): ${drift.details}`,
4053
+ file: drift.docFile,
4054
+ line: drift.line
4055
+ });
4056
+ }
4057
+ }
4058
+ if (report.deadCode) {
4059
+ for (const dead of report.deadCode.deadExports) {
4060
+ issues.push({
4061
+ severity: "warning",
4062
+ message: `Dead export: ${dead.name}`,
4063
+ file: dead.file,
4064
+ line: dead.line
4065
+ });
4066
+ }
4067
+ }
4068
+ }
4069
+ break;
4070
+ }
4071
+ case "phase-gate": {
4072
+ const phaseGates = config.phaseGates;
4073
+ if (!phaseGates?.enabled) {
4074
+ break;
4075
+ }
4076
+ issues.push({
4077
+ severity: "warning",
4078
+ message: "Phase gate is enabled but requires CLI context. Run `harness check-phase-gate` separately for full validation."
4079
+ });
4080
+ break;
4081
+ }
4082
+ }
4083
+ } catch (error) {
4084
+ issues.push({
4085
+ severity: "error",
4086
+ message: `Check '${name}' threw: ${error instanceof Error ? error.message : String(error)}`
4087
+ });
4088
+ }
4089
+ const hasErrors = issues.some((i) => i.severity === "error");
4090
+ const hasWarnings = issues.some((i) => i.severity === "warning");
4091
+ const status = hasErrors ? "fail" : hasWarnings ? "warn" : "pass";
4092
+ return {
4093
+ name,
4094
+ status,
4095
+ issues,
4096
+ durationMs: Date.now() - start
4097
+ };
4098
+ }
4099
+ function buildSummary(checks) {
4100
+ return {
4101
+ total: checks.length,
4102
+ passed: checks.filter((c) => c.status === "pass").length,
4103
+ failed: checks.filter((c) => c.status === "fail").length,
4104
+ warnings: checks.filter((c) => c.status === "warn").length,
4105
+ skipped: checks.filter((c) => c.status === "skip").length
4106
+ };
4107
+ }
4108
+ function determineExitCode(summary, failOn = "error") {
4109
+ if (summary.failed > 0) return 1;
4110
+ if (failOn === "warning" && summary.warnings > 0) return 1;
4111
+ return 0;
4112
+ }
4113
+ async function runCIChecks(input) {
4114
+ const { projectRoot, config, skip = [], failOn = "error" } = input;
4115
+ try {
4116
+ const checks = [];
4117
+ for (const name of ALL_CHECKS) {
4118
+ if (skip.includes(name)) {
4119
+ checks.push({ name, status: "skip", issues: [], durationMs: 0 });
4120
+ } else {
4121
+ const result = await runSingleCheck(name, projectRoot, config);
4122
+ checks.push(result);
4123
+ }
4124
+ }
4125
+ const summary = buildSummary(checks);
4126
+ const exitCode = determineExitCode(summary, failOn);
4127
+ const report = {
4128
+ version: 1,
4129
+ project: config.name ?? "unknown",
4130
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
4131
+ checks,
4132
+ summary,
4133
+ exitCode
4134
+ };
4135
+ return (0, import_types.Ok)(report);
4136
+ } catch (error) {
4137
+ return (0, import_types.Err)(error instanceof Error ? error : new Error(String(error)));
4138
+ }
4139
+ }
4140
+
3988
4141
  // src/index.ts
3989
- var VERSION = "0.5.0";
4142
+ var VERSION = "0.6.0";
3990
4143
  // Annotate the CommonJS export names for ESM import in node:
3991
4144
  0 && (module.exports = {
3992
4145
  AgentActionEmitter,
@@ -3995,7 +4148,6 @@ var VERSION = "0.5.0";
3995
4148
  DEFAULT_STATE,
3996
4149
  EntropyAnalyzer,
3997
4150
  EntropyConfigSchema,
3998
- Err,
3999
4151
  FailureEntrySchema,
4000
4152
  FileSink,
4001
4153
  GateConfigSchema,
@@ -4005,7 +4157,6 @@ var VERSION = "0.5.0";
4005
4157
  NoOpExecutor,
4006
4158
  NoOpSink,
4007
4159
  NoOpTelemetryAdapter,
4008
- Ok,
4009
4160
  PatternConfigSchema,
4010
4161
  REQUIRED_SECTIONS,
4011
4162
  TypeScriptParser,
@@ -4016,9 +4167,7 @@ var VERSION = "0.5.0";
4016
4167
  applyFixes,
4017
4168
  archiveFailures,
4018
4169
  buildDependencyGraph,
4019
- buildReachabilityMap,
4020
4170
  buildSnapshot,
4021
- checkConfigPattern,
4022
4171
  checkDocCoverage,
4023
4172
  configureFeedback,
4024
4173
  contextBudget,
@@ -4037,28 +4186,23 @@ var VERSION = "0.5.0";
4037
4186
  executeWorkflow,
4038
4187
  extractMarkdownLinks,
4039
4188
  extractSections,
4040
- findPossibleMatches,
4041
4189
  generateAgentsMap,
4042
4190
  generateSuggestions,
4043
4191
  getActionEmitter,
4044
4192
  getFeedbackConfig,
4045
4193
  getPhaseCategories,
4046
- isErr,
4047
- isOk,
4048
- levenshteinDistance,
4049
4194
  loadFailures,
4050
4195
  loadHandoff,
4051
4196
  loadRelevantLearnings,
4052
4197
  loadState,
4053
4198
  logAgentAction,
4054
4199
  parseDiff,
4055
- parseDocumentationFile,
4056
4200
  previewFix,
4057
4201
  requestMultiplePeerReviews,
4058
4202
  requestPeerReview,
4059
4203
  resetFeedbackConfig,
4060
- resolveEntryPoints,
4061
4204
  resolveFileToLayer,
4205
+ runCIChecks,
4062
4206
  runMechanicalGate,
4063
4207
  runMultiTurnPipeline,
4064
4208
  runPipeline,