@harness-engineering/core 0.5.0 → 0.6.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,27 +75,21 @@ __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,
104
94
  runMechanicalGate: () => runMechanicalGate,
105
95
  runMultiTurnPipeline: () => runMultiTurnPipeline,
@@ -119,22 +109,6 @@ __export(index_exports, {
119
109
  module.exports = __toCommonJS(index_exports);
120
110
  __reExport(index_exports, require("@harness-engineering/types"), module.exports);
121
111
 
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
112
  // src/shared/errors.ts
139
113
  function createError(code, message, details = {}, suggestions = []) {
140
114
  return { code, message, details, suggestions };
@@ -143,6 +117,9 @@ function createEntropyError(code, message, details = {}, suggestions = []) {
143
117
  return { code, message, details, suggestions };
144
118
  }
145
119
 
120
+ // src/shared/result.ts
121
+ var import_types = require("@harness-engineering/types");
122
+
146
123
  // src/shared/fs-utils.ts
147
124
  var import_fs = require("fs");
148
125
  var import_util = require("util");
@@ -160,9 +137,9 @@ async function fileExists(path2) {
160
137
  async function readFileContent(path2) {
161
138
  try {
162
139
  const content = await readFileAsync(path2, "utf-8");
163
- return Ok(content);
140
+ return (0, import_types.Ok)(content);
164
141
  } catch (error) {
165
- return Err(error);
142
+ return (0, import_types.Err)(error);
166
143
  }
167
144
  }
168
145
  async function findFiles(pattern, cwd = process.cwd()) {
@@ -192,14 +169,14 @@ async function validateFileStructure(projectPath, conventions) {
192
169
  unexpected,
193
170
  conformance
194
171
  };
195
- return Ok(validation);
172
+ return (0, import_types.Ok)(validation);
196
173
  }
197
174
 
198
175
  // src/validation/config.ts
199
176
  function validateConfig(data, schema) {
200
177
  const result = schema.safeParse(data);
201
178
  if (result.success) {
202
- return Ok(result.data);
179
+ return (0, import_types.Ok)(result.data);
203
180
  }
204
181
  const zodErrors = result.error;
205
182
  const firstError = zodErrors.errors[0];
@@ -235,7 +212,7 @@ function validateConfig(data, schema) {
235
212
  },
236
213
  suggestions
237
214
  );
238
- return Err(error);
215
+ return (0, import_types.Err)(error);
239
216
  }
240
217
 
241
218
  // src/validation/commit-message.ts
@@ -261,12 +238,12 @@ function validateCommitMessage(message, format = "conventional") {
261
238
  { message },
262
239
  ["Provide a valid commit message"]
263
240
  );
264
- return Err(error);
241
+ return (0, import_types.Err)(error);
265
242
  }
266
243
  if (format === "conventional" || format === "angular") {
267
244
  return validateConventionalCommit(message);
268
245
  }
269
- return Ok({
246
+ return (0, import_types.Ok)({
270
247
  valid: true,
271
248
  breaking: false,
272
249
  issues: []
@@ -282,7 +259,7 @@ function validateConventionalCommit(message) {
282
259
  { message },
283
260
  ["Provide a commit message with at least a header line"]
284
261
  );
285
- return Err(error);
262
+ return (0, import_types.Err)(error);
286
263
  }
287
264
  const match = headerLine.match(CONVENTIONAL_PATTERN);
288
265
  if (!match) {
@@ -296,7 +273,7 @@ function validateConventionalCommit(message) {
296
273
  "Example: feat(core): add new feature"
297
274
  ]
298
275
  );
299
- return Err(error);
276
+ return (0, import_types.Err)(error);
300
277
  }
301
278
  const type = match[1];
302
279
  const scope = match[3];
@@ -327,7 +304,7 @@ function validateConventionalCommit(message) {
327
304
  { message, issues, type, scope },
328
305
  ["Review and fix the validation issues above"]
329
306
  );
330
- return Err(error);
307
+ return (0, import_types.Err)(error);
331
308
  }
332
309
  const result = {
333
310
  valid: true,
@@ -336,7 +313,7 @@ function validateConventionalCommit(message) {
336
313
  breaking: hasBreakingChange,
337
314
  issues: []
338
315
  };
339
- return Ok(result);
316
+ return (0, import_types.Ok)(result);
340
317
  }
341
318
 
342
319
  // src/context/types.ts
@@ -437,7 +414,7 @@ function resolveLinkPath(linkPath, baseDir) {
437
414
  async function validateAgentsMap(path2 = "./AGENTS.md") {
438
415
  const contentResult = await readFileContent(path2);
439
416
  if (!contentResult.ok) {
440
- return Err(
417
+ return (0, import_types.Err)(
441
418
  createError(
442
419
  "PARSE_ERROR",
443
420
  `Failed to read AGENTS.md: ${contentResult.error.message}`,
@@ -478,7 +455,7 @@ async function validateAgentsMap(path2 = "./AGENTS.md") {
478
455
  );
479
456
  }
480
457
  const valid = missingSections.length === 0 && brokenLinks.length === 0;
481
- return Ok({
458
+ return (0, import_types.Ok)({
482
459
  valid,
483
460
  sections,
484
461
  totalLinks: allLinks.length,
@@ -555,7 +532,7 @@ async function checkDocCoverage(domain, options = {}) {
555
532
  }
556
533
  const total = documented.length + undocumented.length;
557
534
  const coveragePercentage = total > 0 ? Math.round(documented.length / total * 100) : 100;
558
- return Ok({
535
+ return (0, import_types.Ok)({
559
536
  domain,
560
537
  documented,
561
538
  undocumented,
@@ -563,7 +540,7 @@ async function checkDocCoverage(domain, options = {}) {
563
540
  gaps
564
541
  });
565
542
  } catch (error) {
566
- return Err(
543
+ return (0, import_types.Err)(
567
544
  createError(
568
545
  "PARSE_ERROR",
569
546
  `Failed to analyze documentation coverage: ${error.message}`,
@@ -591,7 +568,7 @@ async function validateKnowledgeMap(rootDir = process.cwd()) {
591
568
  const agentsPath = (0, import_path3.join)(rootDir, "AGENTS.md");
592
569
  const agentsResult = await validateAgentsMap(agentsPath);
593
570
  if (!agentsResult.ok) {
594
- return Err(agentsResult.error);
571
+ return (0, import_types.Err)(agentsResult.error);
595
572
  }
596
573
  const {
597
574
  sections,
@@ -615,7 +592,7 @@ async function validateKnowledgeMap(rootDir = process.cwd()) {
615
592
  });
616
593
  const validLinks = agentsTotalLinks - brokenLinks.length;
617
594
  const integrity = agentsTotalLinks > 0 ? Math.round(validLinks / agentsTotalLinks * 100) : 100;
618
- return Ok({
595
+ return (0, import_types.Ok)({
619
596
  totalLinks: agentsTotalLinks,
620
597
  brokenLinks,
621
598
  validLinks,
@@ -724,9 +701,9 @@ async function generateAgentsMap(config) {
724
701
  "> Document your development workflow: branching strategy, testing commands, deployment process."
725
702
  );
726
703
  lines.push("");
727
- return Ok(lines.join("\n"));
704
+ return (0, import_types.Ok)(lines.join("\n"));
728
705
  } catch (error) {
729
- return Err(
706
+ return (0, import_types.Err)(
730
707
  createError(
731
708
  "PARSE_ERROR",
732
709
  `Failed to generate AGENTS.md: ${error.message}`,
@@ -901,7 +878,7 @@ async function buildDependencyGraph(files, parser) {
901
878
  }
902
879
  }
903
880
  }
904
- return Ok({ nodes, edges });
881
+ return (0, import_types.Ok)({ nodes, edges });
905
882
  }
906
883
  function checkLayerViolations(graph, layers, rootDir) {
907
884
  const violations = [];
@@ -931,7 +908,7 @@ async function validateDependencies(config) {
931
908
  const healthResult = await parser.health();
932
909
  if (!healthResult.ok || !healthResult.value.available) {
933
910
  if (fallbackBehavior === "skip") {
934
- return Ok({
911
+ return (0, import_types.Ok)({
935
912
  valid: true,
936
913
  violations: [],
937
914
  graph: { nodes: [], edges: [] },
@@ -941,7 +918,7 @@ async function validateDependencies(config) {
941
918
  }
942
919
  if (fallbackBehavior === "warn") {
943
920
  console.warn(`Parser ${parser.name} unavailable, skipping validation`);
944
- return Ok({
921
+ return (0, import_types.Ok)({
945
922
  valid: true,
946
923
  violations: [],
947
924
  graph: { nodes: [], edges: [] },
@@ -949,7 +926,7 @@ async function validateDependencies(config) {
949
926
  reason: "Parser unavailable"
950
927
  });
951
928
  }
952
- return Err(
929
+ return (0, import_types.Err)(
953
930
  createError(
954
931
  "PARSER_UNAVAILABLE",
955
932
  `Parser ${parser.name} is not available`,
@@ -968,10 +945,10 @@ async function validateDependencies(config) {
968
945
  const uniqueFiles = [...new Set(allFiles)];
969
946
  const graphResult = await buildDependencyGraph(uniqueFiles, parser);
970
947
  if (!graphResult.ok) {
971
- return Err(graphResult.error);
948
+ return (0, import_types.Err)(graphResult.error);
972
949
  }
973
950
  const violations = checkLayerViolations(graphResult.value, layers, rootDir);
974
- return Ok({
951
+ return (0, import_types.Ok)({
975
952
  valid: violations.length === 0,
976
953
  violations,
977
954
  graph: graphResult.value
@@ -1055,7 +1032,7 @@ function detectCircularDeps(graph) {
1055
1032
  };
1056
1033
  });
1057
1034
  const largestCycle = cycles.reduce((max, c) => Math.max(max, c.size), 0);
1058
- return Ok({
1035
+ return (0, import_types.Ok)({
1059
1036
  hasCycles: cycles.length > 0,
1060
1037
  cycles,
1061
1038
  largestCycle
@@ -1077,13 +1054,13 @@ function createBoundaryValidator(schema, name) {
1077
1054
  parse(input) {
1078
1055
  const result = schema.safeParse(input);
1079
1056
  if (result.success) {
1080
- return Ok(result.data);
1057
+ return (0, import_types.Ok)(result.data);
1081
1058
  }
1082
1059
  const suggestions = result.error.issues.map((issue) => {
1083
1060
  const path2 = issue.path.join(".");
1084
1061
  return path2 ? `${path2}: ${issue.message}` : issue.message;
1085
1062
  });
1086
- return Err(
1063
+ return (0, import_types.Err)(
1087
1064
  createError(
1088
1065
  "BOUNDARY_ERROR",
1089
1066
  `Boundary validation failed for ${name}`,
@@ -1098,7 +1075,7 @@ function createBoundaryValidator(schema, name) {
1098
1075
  },
1099
1076
  validate(input) {
1100
1077
  const result = schema.safeParse(input);
1101
- return Ok(result.success);
1078
+ return (0, import_types.Ok)(result.success);
1102
1079
  }
1103
1080
  };
1104
1081
  }
@@ -1119,7 +1096,7 @@ function validateBoundaries(boundaries, data) {
1119
1096
  });
1120
1097
  }
1121
1098
  }
1122
- return Ok({
1099
+ return (0, import_types.Ok)({
1123
1100
  valid: violations.length === 0,
1124
1101
  violations
1125
1102
  });
@@ -1153,7 +1130,7 @@ var TypeScriptParser = class {
1153
1130
  async parseFile(path2) {
1154
1131
  const contentResult = await readFileContent(path2);
1155
1132
  if (!contentResult.ok) {
1156
- return Err(
1133
+ return (0, import_types.Err)(
1157
1134
  createParseError("NOT_FOUND", `File not found: ${path2}`, { path: path2 }, [
1158
1135
  "Check that the file exists",
1159
1136
  "Verify the path is correct"
@@ -1167,14 +1144,14 @@ var TypeScriptParser = class {
1167
1144
  jsx: path2.endsWith(".tsx"),
1168
1145
  errorOnUnknownASTType: false
1169
1146
  });
1170
- return Ok({
1147
+ return (0, import_types.Ok)({
1171
1148
  type: "Program",
1172
1149
  body: ast,
1173
1150
  language: "typescript"
1174
1151
  });
1175
1152
  } catch (e) {
1176
1153
  const error = e;
1177
- return Err(
1154
+ return (0, import_types.Err)(
1178
1155
  createParseError("SYNTAX_ERROR", `Failed to parse ${path2}: ${error.message}`, { path: path2 }, [
1179
1156
  "Check for syntax errors in the file",
1180
1157
  "Ensure valid TypeScript syntax"
@@ -1228,7 +1205,7 @@ var TypeScriptParser = class {
1228
1205
  }
1229
1206
  }
1230
1207
  });
1231
- return Ok(imports);
1208
+ return (0, import_types.Ok)(imports);
1232
1209
  }
1233
1210
  extractExports(ast) {
1234
1211
  const exports2 = [];
@@ -1333,10 +1310,10 @@ var TypeScriptParser = class {
1333
1310
  });
1334
1311
  }
1335
1312
  });
1336
- return Ok(exports2);
1313
+ return (0, import_types.Ok)(exports2);
1337
1314
  }
1338
1315
  async health() {
1339
- return Ok({ available: true, version: "7.0.0" });
1316
+ return (0, import_types.Ok)({ available: true, version: "7.0.0" });
1340
1317
  }
1341
1318
  };
1342
1319
 
@@ -1346,7 +1323,7 @@ var import_minimatch2 = require("minimatch");
1346
1323
  async function resolveEntryPoints(rootDir, explicitEntries) {
1347
1324
  if (explicitEntries && explicitEntries.length > 0) {
1348
1325
  const resolved = explicitEntries.map((e) => (0, import_path6.resolve)(rootDir, e));
1349
- return Ok(resolved);
1326
+ return (0, import_types.Ok)(resolved);
1350
1327
  }
1351
1328
  const pkgPath = (0, import_path6.join)(rootDir, "package.json");
1352
1329
  if (await fileExists(pkgPath)) {
@@ -1384,7 +1361,7 @@ async function resolveEntryPoints(rootDir, explicitEntries) {
1384
1361
  }
1385
1362
  }
1386
1363
  if (entries.length > 0) {
1387
- return Ok(entries);
1364
+ return (0, import_types.Ok)(entries);
1388
1365
  }
1389
1366
  } catch {
1390
1367
  }
@@ -1394,10 +1371,10 @@ async function resolveEntryPoints(rootDir, explicitEntries) {
1394
1371
  for (const conv of conventions) {
1395
1372
  const convPath = (0, import_path6.join)(rootDir, conv);
1396
1373
  if (await fileExists(convPath)) {
1397
- return Ok([convPath]);
1374
+ return (0, import_types.Ok)([convPath]);
1398
1375
  }
1399
1376
  }
1400
- return Err(
1377
+ return (0, import_types.Err)(
1401
1378
  createEntropyError(
1402
1379
  "ENTRY_POINT_NOT_FOUND",
1403
1380
  "Could not resolve entry points",
@@ -1462,7 +1439,7 @@ function extractInlineRefs(content) {
1462
1439
  async function parseDocumentationFile(path2) {
1463
1440
  const contentResult = await readFileContent(path2);
1464
1441
  if (!contentResult.ok) {
1465
- return Err(
1442
+ return (0, import_types.Err)(
1466
1443
  createEntropyError(
1467
1444
  "PARSE_ERROR",
1468
1445
  `Failed to read documentation file: ${path2}`,
@@ -1473,7 +1450,7 @@ async function parseDocumentationFile(path2) {
1473
1450
  }
1474
1451
  const content = contentResult.value;
1475
1452
  const type = path2.endsWith(".md") ? "markdown" : "text";
1476
- return Ok({
1453
+ return (0, import_types.Ok)({
1477
1454
  path: path2,
1478
1455
  type,
1479
1456
  content,
@@ -1590,7 +1567,7 @@ async function buildSnapshot(config) {
1590
1567
  const rootDir = (0, import_path6.resolve)(config.rootDir);
1591
1568
  const entryPointsResult = await resolveEntryPoints(rootDir, config.entryPoints);
1592
1569
  if (!entryPointsResult.ok) {
1593
- return Err(entryPointsResult.error);
1570
+ return (0, import_types.Err)(entryPointsResult.error);
1594
1571
  }
1595
1572
  const includePatterns = config.include || ["**/*.ts", "**/*.tsx"];
1596
1573
  const excludePatterns = config.exclude || [
@@ -1644,7 +1621,7 @@ async function buildSnapshot(config) {
1644
1621
  const exportMap = buildExportMap(files);
1645
1622
  const codeReferences = extractAllCodeReferences(docs);
1646
1623
  const buildTime = Date.now() - startTime;
1647
- return Ok({
1624
+ return (0, import_types.Ok)({
1648
1625
  files,
1649
1626
  dependencyGraph,
1650
1627
  exportMap,
@@ -1795,7 +1772,7 @@ async function detectDocDrift(snapshot, config) {
1795
1772
  const exampleDrifts = drifts.filter((d) => d.type === "example-code").length;
1796
1773
  const structureDrifts = drifts.filter((d) => d.type === "structure").length;
1797
1774
  const severity = drifts.length === 0 ? "none" : drifts.length <= 3 ? "low" : drifts.length <= 10 ? "medium" : "high";
1798
- return Ok({
1775
+ return (0, import_types.Ok)({
1799
1776
  drifts,
1800
1777
  stats: {
1801
1778
  docsScanned: snapshot.docs.length,
@@ -2047,7 +2024,7 @@ async function detectDeadCode(snapshot) {
2047
2024
  estimatedDeadLines
2048
2025
  }
2049
2026
  };
2050
- return Ok(report);
2027
+ return (0, import_types.Ok)(report);
2051
2028
  }
2052
2029
 
2053
2030
  // src/entropy/detectors/patterns.ts
@@ -2204,7 +2181,7 @@ async function detectPatternViolations(snapshot, config) {
2204
2181
  const warningCount = violations.filter((v) => v.severity === "warning").length;
2205
2182
  const totalChecks = snapshot.files.length * patterns.length;
2206
2183
  const passRate = totalChecks > 0 ? (totalChecks - violations.length) / totalChecks : 1;
2207
- return Ok({
2184
+ return (0, import_types.Ok)({
2208
2185
  violations,
2209
2186
  stats: {
2210
2187
  filesChecked: snapshot.files.length,
@@ -2352,7 +2329,7 @@ var EntropyAnalyzer = class {
2352
2329
  const startTime = Date.now();
2353
2330
  const snapshotResult = await buildSnapshot(this.config);
2354
2331
  if (!snapshotResult.ok) {
2355
- return Err(snapshotResult.error);
2332
+ return (0, import_types.Err)(snapshotResult.error);
2356
2333
  }
2357
2334
  this.snapshot = snapshotResult.value;
2358
2335
  let driftReport;
@@ -2417,7 +2394,7 @@ var EntropyAnalyzer = class {
2417
2394
  report.patterns = patternReport;
2418
2395
  }
2419
2396
  this.report = report;
2420
- return Ok(report);
2397
+ return (0, import_types.Ok)(report);
2421
2398
  }
2422
2399
  /**
2423
2400
  * Get the built snapshot (must call analyze first)
@@ -2459,7 +2436,7 @@ var EntropyAnalyzer = class {
2459
2436
  */
2460
2437
  async ensureSnapshot() {
2461
2438
  if (this.snapshot) {
2462
- return Ok(this.snapshot);
2439
+ return (0, import_types.Ok)(this.snapshot);
2463
2440
  }
2464
2441
  return this.buildSnapshot();
2465
2442
  }
@@ -2469,7 +2446,7 @@ var EntropyAnalyzer = class {
2469
2446
  async detectDrift(config) {
2470
2447
  const snapshotResult = await this.ensureSnapshot();
2471
2448
  if (!snapshotResult.ok) {
2472
- return Err(snapshotResult.error);
2449
+ return (0, import_types.Err)(snapshotResult.error);
2473
2450
  }
2474
2451
  return detectDocDrift(snapshotResult.value, config || {});
2475
2452
  }
@@ -2479,7 +2456,7 @@ var EntropyAnalyzer = class {
2479
2456
  async detectDeadCode() {
2480
2457
  const snapshotResult = await this.ensureSnapshot();
2481
2458
  if (!snapshotResult.ok) {
2482
- return Err(snapshotResult.error);
2459
+ return (0, import_types.Err)(snapshotResult.error);
2483
2460
  }
2484
2461
  return detectDeadCode(snapshotResult.value);
2485
2462
  }
@@ -2489,7 +2466,7 @@ var EntropyAnalyzer = class {
2489
2466
  async detectPatterns(config) {
2490
2467
  const snapshotResult = await this.ensureSnapshot();
2491
2468
  if (!snapshotResult.ok) {
2492
- return Err(snapshotResult.error);
2469
+ return (0, import_types.Err)(snapshotResult.error);
2493
2470
  }
2494
2471
  return detectPatternViolations(snapshotResult.value, config);
2495
2472
  }
@@ -2564,9 +2541,9 @@ async function createBackup(filePath, backupDir) {
2564
2541
  try {
2565
2542
  await mkdir2((0, import_path10.dirname)(backupPath), { recursive: true });
2566
2543
  await copyFile2(filePath, backupPath);
2567
- return Ok(backupPath);
2544
+ return (0, import_types.Ok)(backupPath);
2568
2545
  } catch (e) {
2569
- return Err(
2546
+ return (0, import_types.Err)(
2570
2547
  createEntropyError(
2571
2548
  "BACKUP_FAILED",
2572
2549
  `Failed to create backup: ${filePath}`,
@@ -2578,7 +2555,7 @@ async function createBackup(filePath, backupDir) {
2578
2555
  }
2579
2556
  async function applySingleFix(fix, config) {
2580
2557
  if (config.dryRun) {
2581
- return Ok(fix);
2558
+ return (0, import_types.Ok)(fix);
2582
2559
  }
2583
2560
  try {
2584
2561
  switch (fix.action) {
@@ -2586,7 +2563,7 @@ async function applySingleFix(fix, config) {
2586
2563
  if (config.createBackup && config.backupDir) {
2587
2564
  const backupResult = await createBackup(fix.file, config.backupDir);
2588
2565
  if (!backupResult.ok) {
2589
- return Err({ fix, error: backupResult.error.message });
2566
+ return (0, import_types.Err)({ fix, error: backupResult.error.message });
2590
2567
  }
2591
2568
  }
2592
2569
  await unlink2(fix.file);
@@ -2615,9 +2592,9 @@ async function applySingleFix(fix, config) {
2615
2592
  }
2616
2593
  break;
2617
2594
  }
2618
- return Ok(fix);
2595
+ return (0, import_types.Ok)(fix);
2619
2596
  } catch (e) {
2620
- return Err({ fix, error: e.message });
2597
+ return (0, import_types.Err)({ fix, error: e.message });
2621
2598
  }
2622
2599
  }
2623
2600
  async function applyFixes(fixes, config) {
@@ -2648,7 +2625,7 @@ async function applyFixes(fixes, config) {
2648
2625
  errors.push(result.error);
2649
2626
  }
2650
2627
  }
2651
- return Ok({
2628
+ return (0, import_types.Ok)({
2652
2629
  applied,
2653
2630
  skipped,
2654
2631
  errors,
@@ -2757,7 +2734,7 @@ function validatePatternConfig(config) {
2757
2734
  const result = PatternConfigSchema.safeParse(config);
2758
2735
  if (!result.success) {
2759
2736
  const issues = result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
2760
- return Err(
2737
+ return (0, import_types.Err)(
2761
2738
  createEntropyError(
2762
2739
  "CONFIG_VALIDATION_ERROR",
2763
2740
  `Invalid pattern config: ${issues}`,
@@ -2766,23 +2743,23 @@ function validatePatternConfig(config) {
2766
2743
  )
2767
2744
  );
2768
2745
  }
2769
- return Ok(result.data);
2746
+ return (0, import_types.Ok)(result.data);
2770
2747
  }
2771
2748
 
2772
2749
  // src/feedback/telemetry/noop.ts
2773
2750
  var NoOpTelemetryAdapter = class {
2774
2751
  name = "noop";
2775
2752
  async health() {
2776
- return Ok({ available: true, message: "NoOp adapter - no real telemetry" });
2753
+ return (0, import_types.Ok)({ available: true, message: "NoOp adapter - no real telemetry" });
2777
2754
  }
2778
2755
  async getMetrics() {
2779
- return Ok([]);
2756
+ return (0, import_types.Ok)([]);
2780
2757
  }
2781
2758
  async getTraces() {
2782
- return Ok([]);
2759
+ return (0, import_types.Ok)([]);
2783
2760
  }
2784
2761
  async getLogs() {
2785
- return Ok([]);
2762
+ return (0, import_types.Ok)([]);
2786
2763
  }
2787
2764
  };
2788
2765
 
@@ -2803,7 +2780,7 @@ var NoOpExecutor = class {
2803
2780
  name = "noop";
2804
2781
  processes = /* @__PURE__ */ new Map();
2805
2782
  async health() {
2806
- return Ok({ available: true, message: "NoOp executor - no real agent spawning" });
2783
+ return (0, import_types.Ok)({ available: true, message: "NoOp executor - no real agent spawning" });
2807
2784
  }
2808
2785
  async spawn(config) {
2809
2786
  const id = generateId();
@@ -2814,31 +2791,31 @@ var NoOpExecutor = class {
2814
2791
  config
2815
2792
  };
2816
2793
  this.processes.set(id, process2);
2817
- return Ok(process2);
2794
+ return (0, import_types.Ok)(process2);
2818
2795
  }
2819
2796
  async status(processId) {
2820
2797
  const process2 = this.processes.get(processId);
2821
2798
  if (!process2) {
2822
- return Err({
2799
+ return (0, import_types.Err)({
2823
2800
  code: "AGENT_SPAWN_ERROR",
2824
2801
  message: "Process not found",
2825
2802
  details: { agentId: processId },
2826
2803
  suggestions: ["Check if the process ID is correct"]
2827
2804
  });
2828
2805
  }
2829
- return Ok(process2);
2806
+ return (0, import_types.Ok)(process2);
2830
2807
  }
2831
2808
  async wait(processId) {
2832
2809
  const process2 = this.processes.get(processId);
2833
2810
  if (!process2) {
2834
- return Err({
2811
+ return (0, import_types.Err)({
2835
2812
  code: "AGENT_SPAWN_ERROR",
2836
2813
  message: "Process not found",
2837
2814
  details: { agentId: processId },
2838
2815
  suggestions: ["Check if the process ID is correct"]
2839
2816
  });
2840
2817
  }
2841
- return Ok({
2818
+ return (0, import_types.Ok)({
2842
2819
  agentId: processId,
2843
2820
  agentType: process2.config.type,
2844
2821
  approved: true,
@@ -2850,7 +2827,7 @@ var NoOpExecutor = class {
2850
2827
  }
2851
2828
  async kill(processId) {
2852
2829
  this.processes.delete(processId);
2853
- return Ok(void 0);
2830
+ return (0, import_types.Ok)(void 0);
2854
2831
  }
2855
2832
  };
2856
2833
 
@@ -2868,7 +2845,7 @@ var ConsoleSink = class {
2868
2845
  async write(action) {
2869
2846
  const output = this.options.format === "json" ? JSON.stringify(action) : this.formatPretty(action);
2870
2847
  console.log(output);
2871
- return Ok(void 0);
2848
+ return (0, import_types.Ok)(void 0);
2872
2849
  }
2873
2850
  formatPretty(action) {
2874
2851
  const status = action.status === "completed" ? "\u2713" : action.status === "failed" ? "\u2717" : "\u2192";
@@ -2909,7 +2886,7 @@ function resetFeedbackConfig() {
2909
2886
  function parseDiff(diff) {
2910
2887
  try {
2911
2888
  if (!diff.trim()) {
2912
- return Ok({ diff, files: [] });
2889
+ return (0, import_types.Ok)({ diff, files: [] });
2913
2890
  }
2914
2891
  const files = [];
2915
2892
  const newFileRegex = /new file mode/;
@@ -2939,9 +2916,9 @@ function parseDiff(diff) {
2939
2916
  deletions
2940
2917
  });
2941
2918
  }
2942
- return Ok({ diff, files });
2919
+ return (0, import_types.Ok)({ diff, files });
2943
2920
  } catch (error) {
2944
- return Err({
2921
+ return (0, import_types.Err)({
2945
2922
  code: "DIFF_PARSE_ERROR",
2946
2923
  message: "Failed to parse git diff",
2947
2924
  details: { reason: String(error) },
@@ -2951,7 +2928,7 @@ function parseDiff(diff) {
2951
2928
  }
2952
2929
  async function analyzeDiff(changes, options) {
2953
2930
  if (!options?.enabled) {
2954
- return Ok([]);
2931
+ return (0, import_types.Ok)([]);
2955
2932
  }
2956
2933
  const items = [];
2957
2934
  let itemId = 0;
@@ -3023,7 +3000,7 @@ async function analyzeDiff(changes, options) {
3023
3000
  }
3024
3001
  }
3025
3002
  }
3026
- return Ok(items);
3003
+ return (0, import_types.Ok)(items);
3027
3004
  }
3028
3005
 
3029
3006
  // src/feedback/review/checklist.ts
@@ -3144,7 +3121,7 @@ var ChecklistBuilder = class {
3144
3121
  },
3145
3122
  duration: Date.now() - startTime
3146
3123
  };
3147
- return Ok(checklist);
3124
+ return (0, import_types.Ok)(checklist);
3148
3125
  }
3149
3126
  };
3150
3127
 
@@ -3235,7 +3212,7 @@ async function logAgentAction(action) {
3235
3212
  await sink.write(fullAction);
3236
3213
  }
3237
3214
  }
3238
- return Ok(fullAction);
3215
+ return (0, import_types.Ok)(fullAction);
3239
3216
  }
3240
3217
  function trackAction(type, context) {
3241
3218
  const startTime = Date.now();
@@ -3278,7 +3255,7 @@ async function requestPeerReview(agentType, context, options) {
3278
3255
  const config = getFeedbackConfig();
3279
3256
  const executor = config.executor;
3280
3257
  if (!executor) {
3281
- return Err({
3258
+ return (0, import_types.Err)({
3282
3259
  code: "AGENT_SPAWN_ERROR",
3283
3260
  message: "No agent executor configured",
3284
3261
  details: {},
@@ -3331,7 +3308,7 @@ async function requestPeerReview(agentType, context, options) {
3331
3308
  summary: `Agent spawned: ${spawnResult.value.id}`,
3332
3309
  data: { processId: spawnResult.value.id }
3333
3310
  });
3334
- return Ok({
3311
+ return (0, import_types.Ok)({
3335
3312
  agentId: spawnResult.value.id,
3336
3313
  agentType,
3337
3314
  approved: false,
@@ -3346,7 +3323,7 @@ async function requestPeerReview(agentType, context, options) {
3346
3323
  code: "AGENT_SPAWN_ERROR",
3347
3324
  message: String(error)
3348
3325
  });
3349
- return Err({
3326
+ return (0, import_types.Err)({
3350
3327
  code: "AGENT_SPAWN_ERROR",
3351
3328
  message: "Failed to request peer review",
3352
3329
  details: { reason: String(error) },
@@ -3356,7 +3333,7 @@ async function requestPeerReview(agentType, context, options) {
3356
3333
  }
3357
3334
  async function requestMultiplePeerReviews(requests) {
3358
3335
  if (requests.length === 0) {
3359
- return Ok([]);
3336
+ return (0, import_types.Ok)([]);
3360
3337
  }
3361
3338
  const results = await Promise.all(
3362
3339
  requests.map(
@@ -3365,9 +3342,9 @@ async function requestMultiplePeerReviews(requests) {
3365
3342
  );
3366
3343
  const firstError = results.find((r) => !r.ok);
3367
3344
  if (firstError && !firstError.ok) {
3368
- return Err(firstError.error);
3345
+ return (0, import_types.Err)(firstError.error);
3369
3346
  }
3370
- return Ok(results.map((r) => r.value));
3347
+ return (0, import_types.Ok)(results.map((r) => r.value));
3371
3348
  }
3372
3349
 
3373
3350
  // src/feedback/logging/file-sink.ts
@@ -3409,9 +3386,9 @@ var FileSink = class {
3409
3386
  if (this.buffer.length >= (this.options.bufferSize ?? 1)) {
3410
3387
  return this.flush();
3411
3388
  }
3412
- return Ok(void 0);
3389
+ return (0, import_types.Ok)(void 0);
3413
3390
  } catch (error) {
3414
- return Err({
3391
+ return (0, import_types.Err)({
3415
3392
  code: "SINK_ERROR",
3416
3393
  message: "Failed to write action to file",
3417
3394
  details: { reason: String(error) },
@@ -3421,7 +3398,7 @@ var FileSink = class {
3421
3398
  }
3422
3399
  async flush() {
3423
3400
  if (this.buffer.length === 0) {
3424
- return Ok(void 0);
3401
+ return (0, import_types.Ok)(void 0);
3425
3402
  }
3426
3403
  try {
3427
3404
  this.ensureDirectory();
@@ -3432,9 +3409,9 @@ var FileSink = class {
3432
3409
  } else {
3433
3410
  (0, import_fs2.appendFileSync)(this.filePath, content);
3434
3411
  }
3435
- return Ok(void 0);
3412
+ return (0, import_types.Ok)(void 0);
3436
3413
  } catch (error) {
3437
- return Err({
3414
+ return (0, import_types.Err)({
3438
3415
  code: "SINK_ERROR",
3439
3416
  message: "Failed to flush actions to file",
3440
3417
  details: { reason: String(error) },
@@ -3454,7 +3431,7 @@ var FileSink = class {
3454
3431
  var NoOpSink = class {
3455
3432
  name = "noop";
3456
3433
  async write() {
3457
- return Ok(void 0);
3434
+ return (0, import_types.Ok)(void 0);
3458
3435
  }
3459
3436
  };
3460
3437
 
@@ -3552,18 +3529,18 @@ var GATE_CONFIG_FILE = "gate.json";
3552
3529
  async function loadState(projectPath) {
3553
3530
  const statePath = path.join(projectPath, HARNESS_DIR, STATE_FILE);
3554
3531
  if (!fs2.existsSync(statePath)) {
3555
- return Ok({ ...DEFAULT_STATE });
3532
+ return (0, import_types.Ok)({ ...DEFAULT_STATE });
3556
3533
  }
3557
3534
  try {
3558
3535
  const raw = fs2.readFileSync(statePath, "utf-8");
3559
3536
  const parsed = JSON.parse(raw);
3560
3537
  const result = HarnessStateSchema.safeParse(parsed);
3561
3538
  if (!result.success) {
3562
- return Err(new Error(`Invalid state file ${statePath}: ${result.error.message}`));
3539
+ return (0, import_types.Err)(new Error(`Invalid state file ${statePath}: ${result.error.message}`));
3563
3540
  }
3564
- return Ok(result.data);
3541
+ return (0, import_types.Ok)(result.data);
3565
3542
  } catch (error) {
3566
- return Err(
3543
+ return (0, import_types.Err)(
3567
3544
  new Error(
3568
3545
  `Failed to load state from ${statePath}: ${error instanceof Error ? error.message : String(error)}`
3569
3546
  )
@@ -3576,9 +3553,9 @@ async function saveState(projectPath, state) {
3576
3553
  try {
3577
3554
  fs2.mkdirSync(harnessDir, { recursive: true });
3578
3555
  fs2.writeFileSync(statePath, JSON.stringify(state, null, 2));
3579
- return Ok(void 0);
3556
+ return (0, import_types.Ok)(void 0);
3580
3557
  } catch (error) {
3581
- return Err(
3558
+ return (0, import_types.Err)(
3582
3559
  new Error(`Failed to save state: ${error instanceof Error ? error.message : String(error)}`)
3583
3560
  );
3584
3561
  }
@@ -3609,9 +3586,9 @@ ${entry}`);
3609
3586
  } else {
3610
3587
  fs2.appendFileSync(learningsPath, entry);
3611
3588
  }
3612
- return Ok(void 0);
3589
+ return (0, import_types.Ok)(void 0);
3613
3590
  } catch (error) {
3614
- return Err(
3591
+ return (0, import_types.Err)(
3615
3592
  new Error(
3616
3593
  `Failed to append learning: ${error instanceof Error ? error.message : String(error)}`
3617
3594
  )
@@ -3621,7 +3598,7 @@ ${entry}`);
3621
3598
  async function loadRelevantLearnings(projectPath, skillName) {
3622
3599
  const learningsPath = path.join(projectPath, HARNESS_DIR, LEARNINGS_FILE);
3623
3600
  if (!fs2.existsSync(learningsPath)) {
3624
- return Ok([]);
3601
+ return (0, import_types.Ok)([]);
3625
3602
  }
3626
3603
  try {
3627
3604
  const content = fs2.readFileSync(learningsPath, "utf-8");
@@ -3645,12 +3622,12 @@ async function loadRelevantLearnings(projectPath, skillName) {
3645
3622
  entries.push(currentBlock.join("\n"));
3646
3623
  }
3647
3624
  if (!skillName) {
3648
- return Ok(entries);
3625
+ return (0, import_types.Ok)(entries);
3649
3626
  }
3650
3627
  const filtered = entries.filter((entry) => entry.includes(`[skill:${skillName}]`));
3651
- return Ok(filtered);
3628
+ return (0, import_types.Ok)(filtered);
3652
3629
  } catch (error) {
3653
- return Err(
3630
+ return (0, import_types.Err)(
3654
3631
  new Error(
3655
3632
  `Failed to load learnings: ${error instanceof Error ? error.message : String(error)}`
3656
3633
  )
@@ -3673,9 +3650,9 @@ ${entry}`);
3673
3650
  } else {
3674
3651
  fs2.appendFileSync(failuresPath, entry);
3675
3652
  }
3676
- return Ok(void 0);
3653
+ return (0, import_types.Ok)(void 0);
3677
3654
  } catch (error) {
3678
- return Err(
3655
+ return (0, import_types.Err)(
3679
3656
  new Error(
3680
3657
  `Failed to append failure: ${error instanceof Error ? error.message : String(error)}`
3681
3658
  )
@@ -3685,7 +3662,7 @@ ${entry}`);
3685
3662
  async function loadFailures(projectPath) {
3686
3663
  const failuresPath = path.join(projectPath, HARNESS_DIR, FAILURES_FILE);
3687
3664
  if (!fs2.existsSync(failuresPath)) {
3688
- return Ok([]);
3665
+ return (0, import_types.Ok)([]);
3689
3666
  }
3690
3667
  try {
3691
3668
  const content = fs2.readFileSync(failuresPath, "utf-8");
@@ -3701,9 +3678,9 @@ async function loadFailures(projectPath) {
3701
3678
  });
3702
3679
  }
3703
3680
  }
3704
- return Ok(entries);
3681
+ return (0, import_types.Ok)(entries);
3705
3682
  } catch (error) {
3706
- return Err(
3683
+ return (0, import_types.Err)(
3707
3684
  new Error(
3708
3685
  `Failed to load failures: ${error instanceof Error ? error.message : String(error)}`
3709
3686
  )
@@ -3714,7 +3691,7 @@ async function archiveFailures(projectPath) {
3714
3691
  const harnessDir = path.join(projectPath, HARNESS_DIR);
3715
3692
  const failuresPath = path.join(harnessDir, FAILURES_FILE);
3716
3693
  if (!fs2.existsSync(failuresPath)) {
3717
- return Ok(void 0);
3694
+ return (0, import_types.Ok)(void 0);
3718
3695
  }
3719
3696
  try {
3720
3697
  const archiveDir = path.join(harnessDir, "archive");
@@ -3727,9 +3704,9 @@ async function archiveFailures(projectPath) {
3727
3704
  counter++;
3728
3705
  }
3729
3706
  fs2.renameSync(failuresPath, path.join(archiveDir, archiveName));
3730
- return Ok(void 0);
3707
+ return (0, import_types.Ok)(void 0);
3731
3708
  } catch (error) {
3732
- return Err(
3709
+ return (0, import_types.Err)(
3733
3710
  new Error(
3734
3711
  `Failed to archive failures: ${error instanceof Error ? error.message : String(error)}`
3735
3712
  )
@@ -3742,9 +3719,9 @@ async function saveHandoff(projectPath, handoff) {
3742
3719
  try {
3743
3720
  fs2.mkdirSync(harnessDir, { recursive: true });
3744
3721
  fs2.writeFileSync(handoffPath, JSON.stringify(handoff, null, 2));
3745
- return Ok(void 0);
3722
+ return (0, import_types.Ok)(void 0);
3746
3723
  } catch (error) {
3747
- return Err(
3724
+ return (0, import_types.Err)(
3748
3725
  new Error(`Failed to save handoff: ${error instanceof Error ? error.message : String(error)}`)
3749
3726
  );
3750
3727
  }
@@ -3752,18 +3729,18 @@ async function saveHandoff(projectPath, handoff) {
3752
3729
  async function loadHandoff(projectPath) {
3753
3730
  const handoffPath = path.join(projectPath, HARNESS_DIR, HANDOFF_FILE);
3754
3731
  if (!fs2.existsSync(handoffPath)) {
3755
- return Ok(null);
3732
+ return (0, import_types.Ok)(null);
3756
3733
  }
3757
3734
  try {
3758
3735
  const raw = fs2.readFileSync(handoffPath, "utf-8");
3759
3736
  const parsed = JSON.parse(raw);
3760
3737
  const result = HandoffSchema.safeParse(parsed);
3761
3738
  if (!result.success) {
3762
- return Err(new Error(`Invalid handoff file: ${result.error.message}`));
3739
+ return (0, import_types.Err)(new Error(`Invalid handoff file: ${result.error.message}`));
3763
3740
  }
3764
- return Ok(result.data);
3741
+ return (0, import_types.Ok)(result.data);
3765
3742
  } catch (error) {
3766
- return Err(
3743
+ return (0, import_types.Err)(
3767
3744
  new Error(`Failed to load handoff: ${error instanceof Error ? error.message : String(error)}`)
3768
3745
  );
3769
3746
  }
@@ -3824,12 +3801,12 @@ async function runMechanicalGate(projectPath) {
3824
3801
  });
3825
3802
  }
3826
3803
  }
3827
- return Ok({
3804
+ return (0, import_types.Ok)({
3828
3805
  passed: results.length === 0 || results.every((r) => r.passed),
3829
3806
  checks: results
3830
3807
  });
3831
3808
  } catch (error) {
3832
- return Err(
3809
+ return (0, import_types.Err)(
3833
3810
  new Error(
3834
3811
  `Failed to run mechanical gate: ${error instanceof Error ? error.message : String(error)}`
3835
3812
  )
@@ -3986,7 +3963,7 @@ async function runMultiTurnPipeline(initialContext, turnExecutor, options) {
3986
3963
  }
3987
3964
 
3988
3965
  // src/index.ts
3989
- var VERSION = "0.5.0";
3966
+ var VERSION = "0.6.0";
3990
3967
  // Annotate the CommonJS export names for ESM import in node:
3991
3968
  0 && (module.exports = {
3992
3969
  AgentActionEmitter,
@@ -3995,7 +3972,6 @@ var VERSION = "0.5.0";
3995
3972
  DEFAULT_STATE,
3996
3973
  EntropyAnalyzer,
3997
3974
  EntropyConfigSchema,
3998
- Err,
3999
3975
  FailureEntrySchema,
4000
3976
  FileSink,
4001
3977
  GateConfigSchema,
@@ -4005,7 +3981,6 @@ var VERSION = "0.5.0";
4005
3981
  NoOpExecutor,
4006
3982
  NoOpSink,
4007
3983
  NoOpTelemetryAdapter,
4008
- Ok,
4009
3984
  PatternConfigSchema,
4010
3985
  REQUIRED_SECTIONS,
4011
3986
  TypeScriptParser,
@@ -4016,9 +3991,7 @@ var VERSION = "0.5.0";
4016
3991
  applyFixes,
4017
3992
  archiveFailures,
4018
3993
  buildDependencyGraph,
4019
- buildReachabilityMap,
4020
3994
  buildSnapshot,
4021
- checkConfigPattern,
4022
3995
  checkDocCoverage,
4023
3996
  configureFeedback,
4024
3997
  contextBudget,
@@ -4037,27 +4010,21 @@ var VERSION = "0.5.0";
4037
4010
  executeWorkflow,
4038
4011
  extractMarkdownLinks,
4039
4012
  extractSections,
4040
- findPossibleMatches,
4041
4013
  generateAgentsMap,
4042
4014
  generateSuggestions,
4043
4015
  getActionEmitter,
4044
4016
  getFeedbackConfig,
4045
4017
  getPhaseCategories,
4046
- isErr,
4047
- isOk,
4048
- levenshteinDistance,
4049
4018
  loadFailures,
4050
4019
  loadHandoff,
4051
4020
  loadRelevantLearnings,
4052
4021
  loadState,
4053
4022
  logAgentAction,
4054
4023
  parseDiff,
4055
- parseDocumentationFile,
4056
4024
  previewFix,
4057
4025
  requestMultiplePeerReviews,
4058
4026
  requestPeerReview,
4059
4027
  resetFeedbackConfig,
4060
- resolveEntryPoints,
4061
4028
  resolveFileToLayer,
4062
4029
  runMechanicalGate,
4063
4030
  runMultiTurnPipeline,