@h-rig/runtime 0.0.6-alpha.27 → 0.0.6-alpha.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/bin/rig-agent-dispatch.js +552 -483
  2. package/dist/bin/rig-agent.js +418 -364
  3. package/dist/src/control-plane/agent-wrapper.js +557 -488
  4. package/dist/src/control-plane/harness-main.js +559 -1418
  5. package/dist/src/control-plane/hooks/completion-verification.js +451 -808
  6. package/dist/src/control-plane/hooks/inject-context.js +191 -137
  7. package/dist/src/control-plane/hooks/submodule-branch.js +596 -542
  8. package/dist/src/control-plane/hooks/task-runtime-start.js +596 -542
  9. package/dist/src/control-plane/materialize-task-config.js +64 -8
  10. package/dist/src/control-plane/native/git-ops.js +3 -0
  11. package/dist/src/control-plane/native/harness-cli.js +544 -496
  12. package/dist/src/control-plane/native/repo-ops.js +3 -0
  13. package/dist/src/control-plane/native/run-ops.js +3 -0
  14. package/dist/src/control-plane/native/task-ops.js +418 -370
  15. package/dist/src/control-plane/native/validator.js +161 -107
  16. package/dist/src/control-plane/native/verifier.js +217 -169
  17. package/dist/src/control-plane/pi-sessiond/launcher.js +12 -2
  18. package/dist/src/control-plane/plugin-host-context.js +54 -0
  19. package/dist/src/control-plane/runtime/image/fingerprint-sidecar.js +3 -0
  20. package/dist/src/control-plane/runtime/image/index.js +3 -0
  21. package/dist/src/control-plane/runtime/image-fingerprint-sidecar.js +3 -0
  22. package/dist/src/control-plane/runtime/image.js +3 -0
  23. package/dist/src/control-plane/runtime/index.js +487 -718
  24. package/dist/src/control-plane/runtime/isolation/index.js +511 -457
  25. package/dist/src/control-plane/runtime/isolation.js +511 -457
  26. package/dist/src/control-plane/runtime/plugin-mode.js +3 -27
  27. package/dist/src/control-plane/runtime/queue.js +428 -381
  28. package/dist/src/control-plane/runtime/snapshot/task-run.js +3 -0
  29. package/dist/src/control-plane/runtime/task-run-snapshot.js +3 -0
  30. package/dist/src/control-plane/skill-materializer.js +46 -0
  31. package/dist/src/control-plane/tasks/source-lifecycle.js +84 -30
  32. package/dist/src/index.js +0 -278
  33. package/native/darwin-arm64/rig-shell +0 -0
  34. package/native/darwin-arm64/rig-shell.build-manifest.json +1 -1
  35. package/native/darwin-arm64/rig-tools +0 -0
  36. package/native/darwin-arm64/rig-tools.build-manifest.json +1 -1
  37. package/package.json +8 -7
  38. package/dist/src/control-plane/runtime/plugins.js +0 -1131
  39. package/dist/src/plugins.js +0 -329
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // packages/runtime/src/control-plane/native/verifier.ts
3
- import { existsSync as existsSync11, mkdirSync as mkdirSync5, writeFileSync as writeFileSync6 } from "fs";
4
- import { resolve as resolve13 } from "path";
3
+ import { existsSync as existsSync12, mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
4
+ import { resolve as resolve14 } from "path";
5
5
 
6
6
  // packages/runtime/src/control-plane/runtime/baked-secrets.ts
7
7
  var BAKED_RUNTIME_SECRETS = {
@@ -47,8 +47,8 @@ function resolveRuntimeSecrets(env, baked = BAKED_RUNTIME_SECRETS) {
47
47
  }
48
48
 
49
49
  // packages/runtime/src/control-plane/native/git-ops.ts
50
- import { existsSync as existsSync10, lstatSync, mkdirSync as mkdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
51
- import { dirname as dirname8, isAbsolute as isAbsolute2, resolve as resolve12 } from "path";
50
+ import { existsSync as existsSync11, lstatSync, mkdirSync as mkdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
51
+ import { dirname as dirname8, isAbsolute as isAbsolute2, resolve as resolve13 } from "path";
52
52
 
53
53
  // packages/runtime/src/control-plane/runtime/context.ts
54
54
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -539,6 +539,49 @@ function safeReadJson(path) {
539
539
  }
540
540
  }
541
541
 
542
+ // packages/runtime/src/control-plane/skill-materializer.ts
543
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, readdirSync, rmSync, writeFileSync as writeFileSync3 } from "fs";
544
+ import { resolve as resolve5 } from "path";
545
+ import { loadSkill } from "@rig/skill-loader";
546
+ var MARKER_FILENAME = ".rig-plugin";
547
+ function skillDirName(id) {
548
+ return id.replace(/[^a-zA-Z0-9._-]+/g, "-");
549
+ }
550
+ async function materializeSkills(projectRoot, entries) {
551
+ const skillsRoot = resolve5(projectRoot, ".pi", "skills");
552
+ if (existsSync4(skillsRoot)) {
553
+ for (const name of readdirSync(skillsRoot)) {
554
+ const dir = resolve5(skillsRoot, name);
555
+ if (existsSync4(resolve5(dir, MARKER_FILENAME))) {
556
+ rmSync(dir, { recursive: true, force: true });
557
+ }
558
+ }
559
+ }
560
+ const written = [];
561
+ for (const { pluginName, skill } of entries) {
562
+ const sourcePath = resolve5(projectRoot, skill.path);
563
+ if (!existsSync4(sourcePath)) {
564
+ console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${sourcePath} does not exist`);
565
+ continue;
566
+ }
567
+ let body;
568
+ try {
569
+ await loadSkill(sourcePath);
570
+ body = readFileSync3(sourcePath, "utf-8");
571
+ } catch (err) {
572
+ console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${err instanceof Error ? err.message : err}`);
573
+ continue;
574
+ }
575
+ const dir = resolve5(skillsRoot, skillDirName(skill.id));
576
+ mkdirSync3(dir, { recursive: true });
577
+ writeFileSync3(resolve5(dir, "SKILL.md"), body, "utf-8");
578
+ writeFileSync3(resolve5(dir, MARKER_FILENAME), `${JSON.stringify({ plugin: pluginName, skillId: skill.id }, null, 2)}
579
+ `, "utf-8");
580
+ written.push({ id: skill.id, pluginName, directory: dir });
581
+ }
582
+ return written;
583
+ }
584
+
542
585
  // packages/runtime/src/control-plane/plugin-host-context.ts
543
586
  async function buildPluginHostContext(projectRoot) {
544
587
  let config;
@@ -575,6 +618,17 @@ async function buildPluginHostContext(projectRoot) {
575
618
  } catch (err) {
576
619
  console.warn(`[plugin-host] hook materialization failed: ${err instanceof Error ? err.message : err}`);
577
620
  }
621
+ try {
622
+ const skillEntries = config.plugins.flatMap((plugin) => (plugin.contributes?.skills ?? []).map((skill) => ({
623
+ pluginName: plugin.name,
624
+ skill
625
+ })));
626
+ if (skillEntries.length > 0) {
627
+ await materializeSkills(projectRoot, skillEntries);
628
+ }
629
+ } catch (err) {
630
+ console.warn(`[plugin-host] skill materialization failed: ${err instanceof Error ? err.message : err}`);
631
+ }
578
632
  return {
579
633
  config,
580
634
  pluginHost,
@@ -588,12 +642,12 @@ async function buildPluginHostContext(projectRoot) {
588
642
 
589
643
  // packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
590
644
  import { spawnSync } from "child_process";
591
- import { existsSync as existsSync5, readFileSync as readFileSync4, readdirSync, statSync, writeFileSync as writeFileSync3 } from "fs";
592
- import { basename as basename3, join as join2, resolve as resolve6 } from "path";
645
+ import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync2, statSync, writeFileSync as writeFileSync4 } from "fs";
646
+ import { basename as basename3, join as join2, resolve as resolve7 } from "path";
593
647
 
594
648
  // packages/runtime/src/control-plane/tasks/legacy-task-config-source.ts
595
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
596
- import { resolve as resolve5 } from "path";
649
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
650
+ import { resolve as resolve6 } from "path";
597
651
 
598
652
  // packages/runtime/src/control-plane/tasks/task-record-reader.ts
599
653
  async function findTaskById(reader, id) {
@@ -616,7 +670,7 @@ class LegacyTaskConfigReadError extends Error {
616
670
  }
617
671
  }
618
672
  function createLegacyTaskConfigRecordReader(projectRoot, options = {}) {
619
- const configPath = options.configPath ?? resolve5(projectRoot, ".rig", "task-config.json");
673
+ const configPath = options.configPath ?? resolve6(projectRoot, ".rig", "task-config.json");
620
674
  const reader = {
621
675
  async listTasks() {
622
676
  return readLegacyTaskRecords(projectRoot, configPath);
@@ -627,8 +681,8 @@ function createLegacyTaskConfigRecordReader(projectRoot, options = {}) {
627
681
  };
628
682
  return reader;
629
683
  }
630
- function readLegacyTaskRecords(projectRoot, configPath = resolve5(projectRoot, ".rig", "task-config.json")) {
631
- if (!existsSync4(configPath)) {
684
+ function readLegacyTaskRecords(projectRoot, configPath = resolve6(projectRoot, ".rig", "task-config.json")) {
685
+ if (!existsSync5(configPath)) {
632
686
  return [];
633
687
  }
634
688
  const rawConfig = readLegacyTaskConfigJson(projectRoot, configPath);
@@ -636,7 +690,7 @@ function readLegacyTaskRecords(projectRoot, configPath = resolve5(projectRoot, "
636
690
  }
637
691
  function readLegacyTaskConfigJson(projectRoot, configPath) {
638
692
  try {
639
- const parsed = JSON.parse(readFileSync3(configPath, "utf8"));
693
+ const parsed = JSON.parse(readFileSync4(configPath, "utf8"));
640
694
  if (isPlainRecord(parsed)) {
641
695
  return parsed;
642
696
  }
@@ -720,7 +774,7 @@ function isPlainRecord(candidate) {
720
774
  var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
721
775
  var FILE_TASK_PATTERN = /\.(task\.)?json$/;
722
776
  function createSourceAwareTaskConfigRecordReader(projectRoot, options = {}) {
723
- const configPath = options.configPath ?? resolve6(projectRoot, ".rig", "task-config.json");
777
+ const configPath = options.configPath ?? resolve7(projectRoot, ".rig", "task-config.json");
724
778
  const legacy = createLegacyTaskConfigRecordReader(projectRoot, { configPath });
725
779
  const spawnFn = options.spawn ?? spawnSync;
726
780
  const ghBinary = options.ghBinary ?? "gh";
@@ -803,10 +857,10 @@ function readMaterializedTaskMetadata(entry) {
803
857
  return metadata;
804
858
  }
805
859
  function readConfiguredFilesTaskSourcePath(projectRoot) {
806
- const jsonPath = resolve6(projectRoot, "rig.config.json");
807
- if (existsSync5(jsonPath)) {
860
+ const jsonPath = resolve7(projectRoot, "rig.config.json");
861
+ if (existsSync6(jsonPath)) {
808
862
  try {
809
- const parsed = JSON.parse(readFileSync4(jsonPath, "utf8"));
863
+ const parsed = JSON.parse(readFileSync5(jsonPath, "utf8"));
810
864
  if (isPlainRecord2(parsed) && isPlainRecord2(parsed.taskSource)) {
811
865
  const source = parsed.taskSource;
812
866
  return source.kind === "files" && typeof source.path === "string" ? source.path : null;
@@ -815,12 +869,12 @@ function readConfiguredFilesTaskSourcePath(projectRoot) {
815
869
  return null;
816
870
  }
817
871
  }
818
- const tsPath = resolve6(projectRoot, "rig.config.ts");
819
- if (!existsSync5(tsPath)) {
872
+ const tsPath = resolve7(projectRoot, "rig.config.ts");
873
+ if (!existsSync6(tsPath)) {
820
874
  return null;
821
875
  }
822
876
  try {
823
- const source = readFileSync4(tsPath, "utf8");
877
+ const source = readFileSync5(tsPath, "utf8");
824
878
  const taskSourceBlock = source.match(/taskSource\s*:\s*\{[\s\S]*?\}/m)?.[0] ?? "";
825
879
  const kind = taskSourceBlock.match(/kind\s*:\s*["']([^"']+)["']/)?.[1];
826
880
  if (kind !== "files") {
@@ -840,10 +894,10 @@ function readRawTaskEntry(configPath, taskId) {
840
894
  return isPlainRecord2(entry) ? entry : null;
841
895
  }
842
896
  function readRawTaskConfig(configPath) {
843
- if (!existsSync5(configPath)) {
897
+ if (!existsSync6(configPath)) {
844
898
  return null;
845
899
  }
846
- const parsed = JSON.parse(readFileSync4(configPath, "utf8"));
900
+ const parsed = JSON.parse(readFileSync5(configPath, "utf8"));
847
901
  return isPlainRecord2(parsed) ? parsed : null;
848
902
  }
849
903
  function stripLegacyTaskConfigMetadata2(raw) {
@@ -851,12 +905,12 @@ function stripLegacyTaskConfigMetadata2(raw) {
851
905
  return tasks;
852
906
  }
853
907
  function listFileBackedTasks(projectRoot, sourcePath) {
854
- const directory = resolve6(projectRoot, sourcePath);
855
- if (!existsSync5(directory)) {
908
+ const directory = resolve7(projectRoot, sourcePath);
909
+ if (!existsSync6(directory)) {
856
910
  return [];
857
911
  }
858
912
  const tasks = [];
859
- for (const name of readdirSync(directory)) {
913
+ for (const name of readdirSync2(directory)) {
860
914
  if (!FILE_TASK_PATTERN.test(name))
861
915
  continue;
862
916
  const inferredId = basename3(name).replace(FILE_TASK_PATTERN, "");
@@ -867,11 +921,11 @@ function listFileBackedTasks(projectRoot, sourcePath) {
867
921
  return tasks;
868
922
  }
869
923
  function readFileBackedTask(projectRoot, sourcePath, taskId, rawEntry) {
870
- const file = findFileBackedTaskFile(resolve6(projectRoot, sourcePath), taskId);
924
+ const file = findFileBackedTaskFile(resolve7(projectRoot, sourcePath), taskId);
871
925
  if (!file) {
872
926
  return null;
873
927
  }
874
- const raw = JSON.parse(readFileSync4(file, "utf8"));
928
+ const raw = JSON.parse(readFileSync5(file, "utf8"));
875
929
  if (!isPlainRecord2(raw)) {
876
930
  return null;
877
931
  }
@@ -884,17 +938,17 @@ function readFileBackedTask(projectRoot, sourcePath, taskId, rawEntry) {
884
938
  };
885
939
  }
886
940
  function findFileBackedTaskFile(directory, taskId) {
887
- if (!existsSync5(directory)) {
941
+ if (!existsSync6(directory)) {
888
942
  return null;
889
943
  }
890
- for (const name of readdirSync(directory)) {
944
+ for (const name of readdirSync2(directory)) {
891
945
  if (!FILE_TASK_PATTERN.test(name))
892
946
  continue;
893
947
  const file = join2(directory, name);
894
948
  try {
895
949
  if (!statSync(file).isFile())
896
950
  continue;
897
- const raw = JSON.parse(readFileSync4(file, "utf8"));
951
+ const raw = JSON.parse(readFileSync5(file, "utf8"));
898
952
  const inferredId = basename3(file).replace(FILE_TASK_PATTERN, "");
899
953
  const id = isPlainRecord2(raw) && typeof raw.id === "string" ? raw.id : inferredId;
900
954
  if (id === taskId) {
@@ -1054,8 +1108,8 @@ async function readConfiguredTaskSourceTask(projectRoot, taskId) {
1054
1108
  }
1055
1109
 
1056
1110
  // packages/runtime/src/control-plane/native/task-state.ts
1057
- import { existsSync as existsSync9, readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as statSync3, writeFileSync as writeFileSync4 } from "fs";
1058
- import { basename as basename5, resolve as resolve11 } from "path";
1111
+ import { existsSync as existsSync10, readFileSync as readFileSync7, readdirSync as readdirSync3, statSync as statSync3, writeFileSync as writeFileSync5 } from "fs";
1112
+ import { basename as basename5, resolve as resolve12 } from "path";
1059
1113
 
1060
1114
  // packages/runtime/src/control-plane/state-sync/types.ts
1061
1115
  var CANONICAL_TASK_LIFECYCLE_STATUSES = new Set([
@@ -1071,40 +1125,40 @@ var CANONICAL_TASK_LIFECYCLE_STATUSES = new Set([
1071
1125
  ]);
1072
1126
  // packages/runtime/src/control-plane/native/git-native.ts
1073
1127
  import { tmpdir as tmpdir3 } from "os";
1074
- import { dirname as dirname5, isAbsolute, resolve as resolve7 } from "path";
1075
- var sharedGitNativeOutputDir = resolve7(tmpdir3(), "rig-native");
1076
- var sharedGitNativeOutputPath = resolve7(sharedGitNativeOutputDir, `rig-git-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
1128
+ import { dirname as dirname5, isAbsolute, resolve as resolve8 } from "path";
1129
+ var sharedGitNativeOutputDir = resolve8(tmpdir3(), "rig-native");
1130
+ var sharedGitNativeOutputPath = resolve8(sharedGitNativeOutputDir, `rig-git-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
1077
1131
 
1078
1132
  // packages/runtime/src/control-plane/native/utils.ts
1079
- import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
1080
- import { resolve as resolve10 } from "path";
1133
+ import { existsSync as existsSync9, readFileSync as readFileSync6 } from "fs";
1134
+ import { resolve as resolve11 } from "path";
1081
1135
 
1082
1136
  // packages/runtime/src/layout.ts
1083
- import { existsSync as existsSync6 } from "fs";
1084
- import { basename as basename4, dirname as dirname6, resolve as resolve8 } from "path";
1137
+ import { existsSync as existsSync7 } from "fs";
1138
+ import { basename as basename4, dirname as dirname6, resolve as resolve9 } from "path";
1085
1139
  var RIG_DEFINITION_DIRNAME = "rig";
1086
1140
  var RIG_ARTIFACTS_DIRNAME = "artifacts";
1087
1141
  function resolveMonorepoRoot(projectRoot) {
1088
- const normalizedProjectRoot = resolve8(projectRoot);
1142
+ const normalizedProjectRoot = resolve9(projectRoot);
1089
1143
  const explicit = process.env.MONOREPO_ROOT?.trim();
1090
1144
  if (explicit) {
1091
- const explicitRoot = resolve8(explicit);
1145
+ const explicitRoot = resolve9(explicit);
1092
1146
  const explicitParent = dirname6(explicitRoot);
1093
1147
  if (basename4(explicitParent) === ".worktrees") {
1094
1148
  const owner = dirname6(explicitParent);
1095
- const ownerHasGit = existsSync6(resolve8(owner, ".git"));
1096
- const ownerHasTaskConfig = existsSync6(resolve8(owner, ".rig", "task-config.json"));
1097
- const ownerHasRigConfig = existsSync6(resolve8(owner, "rig.config.ts"));
1149
+ const ownerHasGit = existsSync7(resolve9(owner, ".git"));
1150
+ const ownerHasTaskConfig = existsSync7(resolve9(owner, ".rig", "task-config.json"));
1151
+ const ownerHasRigConfig = existsSync7(resolve9(owner, "rig.config.ts"));
1098
1152
  if (ownerHasGit && (ownerHasTaskConfig || ownerHasRigConfig)) {
1099
1153
  return owner;
1100
1154
  }
1101
1155
  throw new Error(`MONOREPO_ROOT points to worktree ${explicitRoot}, but the owner checkout is incomplete at ${owner}.`);
1102
1156
  }
1103
- if (!existsSync6(resolve8(explicitRoot, ".git"))) {
1157
+ if (!existsSync7(resolve9(explicitRoot, ".git"))) {
1104
1158
  throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but no git checkout was found there.`);
1105
1159
  }
1106
- const hasTaskConfig = existsSync6(resolve8(explicitRoot, ".rig", "task-config.json"));
1107
- const hasRigConfig = existsSync6(resolve8(explicitRoot, "rig.config.ts"));
1160
+ const hasTaskConfig = existsSync7(resolve9(explicitRoot, ".rig", "task-config.json"));
1161
+ const hasRigConfig = existsSync7(resolve9(explicitRoot, "rig.config.ts"));
1108
1162
  if (!hasTaskConfig && !hasRigConfig) {
1109
1163
  throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but neither .rig/task-config.json nor rig.config.ts exists there.`);
1110
1164
  }
@@ -1113,9 +1167,9 @@ function resolveMonorepoRoot(projectRoot) {
1113
1167
  const projectParent = dirname6(normalizedProjectRoot);
1114
1168
  if (basename4(projectParent) === ".worktrees") {
1115
1169
  const worktreeOwner = dirname6(projectParent);
1116
- const ownerHasGit = existsSync6(resolve8(worktreeOwner, ".git"));
1117
- const ownerHasTaskConfig = existsSync6(resolve8(worktreeOwner, ".rig", "task-config.json"));
1118
- const ownerHasRigConfig = existsSync6(resolve8(worktreeOwner, "rig.config.ts"));
1170
+ const ownerHasGit = existsSync7(resolve9(worktreeOwner, ".git"));
1171
+ const ownerHasTaskConfig = existsSync7(resolve9(worktreeOwner, ".rig", "task-config.json"));
1172
+ const ownerHasRigConfig = existsSync7(resolve9(worktreeOwner, "rig.config.ts"));
1119
1173
  if (ownerHasGit && (ownerHasTaskConfig || ownerHasRigConfig)) {
1120
1174
  return worktreeOwner;
1121
1175
  }
@@ -1123,28 +1177,28 @@ function resolveMonorepoRoot(projectRoot) {
1123
1177
  return normalizedProjectRoot;
1124
1178
  }
1125
1179
  function resolveRuntimeWorkspaceLayout(workspaceDir) {
1126
- const root = resolve8(workspaceDir);
1127
- const rigRoot = resolve8(root, ".rig");
1128
- const logsDir = resolve8(rigRoot, "logs");
1129
- const stateDir = resolve8(rigRoot, "state");
1130
- const runtimeDir = resolve8(rigRoot, "runtime");
1131
- const binDir = resolve8(rigRoot, "bin");
1180
+ const root = resolve9(workspaceDir);
1181
+ const rigRoot = resolve9(root, ".rig");
1182
+ const logsDir = resolve9(rigRoot, "logs");
1183
+ const stateDir = resolve9(rigRoot, "state");
1184
+ const runtimeDir = resolve9(rigRoot, "runtime");
1185
+ const binDir = resolve9(rigRoot, "bin");
1132
1186
  return {
1133
1187
  workspaceDir: root,
1134
1188
  rigRoot,
1135
1189
  stateDir,
1136
1190
  logsDir,
1137
- artifactsRoot: resolve8(root, RIG_ARTIFACTS_DIRNAME),
1191
+ artifactsRoot: resolve9(root, RIG_ARTIFACTS_DIRNAME),
1138
1192
  runtimeDir,
1139
- homeDir: resolve8(rigRoot, "home"),
1140
- tmpDir: resolve8(rigRoot, "tmp"),
1141
- cacheDir: resolve8(rigRoot, "cache"),
1142
- sessionDir: resolve8(rigRoot, "session"),
1193
+ homeDir: resolve9(rigRoot, "home"),
1194
+ tmpDir: resolve9(rigRoot, "tmp"),
1195
+ cacheDir: resolve9(rigRoot, "cache"),
1196
+ sessionDir: resolve9(rigRoot, "session"),
1143
1197
  binDir,
1144
- distDir: resolve8(rigRoot, "dist"),
1145
- pluginBinDir: resolve8(binDir, "plugins"),
1146
- contextPath: resolve8(rigRoot, "runtime-context.json"),
1147
- controlPlaneEventsFile: resolve8(logsDir, "control-plane.events.jsonl")
1198
+ distDir: resolve9(rigRoot, "dist"),
1199
+ pluginBinDir: resolve9(binDir, "plugins"),
1200
+ contextPath: resolve9(rigRoot, "runtime-context.json"),
1201
+ controlPlaneEventsFile: resolve9(logsDir, "control-plane.events.jsonl")
1148
1202
  };
1149
1203
  }
1150
1204
  function resolveActiveRuntimeWorkspaceRoot(monorepoRoot) {
@@ -1152,14 +1206,14 @@ function resolveActiveRuntimeWorkspaceRoot(monorepoRoot) {
1152
1206
  if (!explicit) {
1153
1207
  throw new Error("No active runtime workspace. Set RIG_TASK_WORKSPACE or provision a task runtime first.");
1154
1208
  }
1155
- return resolve8(explicit);
1209
+ return resolve9(explicit);
1156
1210
  }
1157
1211
  function resolveRigLayout(projectRoot) {
1158
1212
  const monorepoRoot = resolveMonorepoRoot(projectRoot);
1159
- const definitionRoot = resolve8(projectRoot, RIG_DEFINITION_DIRNAME);
1213
+ const definitionRoot = resolve9(projectRoot, RIG_DEFINITION_DIRNAME);
1160
1214
  const runtimeWorkspaceRoot = resolveActiveRuntimeWorkspaceRoot(monorepoRoot);
1161
1215
  const runtimeLayout = resolveRuntimeWorkspaceLayout(runtimeWorkspaceRoot);
1162
- const policyDir = resolve8(definitionRoot, "policy");
1216
+ const policyDir = resolve9(definitionRoot, "policy");
1163
1217
  return {
1164
1218
  projectRoot,
1165
1219
  monorepoRoot,
@@ -1167,48 +1221,48 @@ function resolveRigLayout(projectRoot) {
1167
1221
  runtimeWorkspaceRoot,
1168
1222
  stateRoot: runtimeLayout.rigRoot,
1169
1223
  artifactsRoot: runtimeLayout.artifactsRoot,
1170
- configPath: resolve8(definitionRoot, "config.sh"),
1171
- taskConfigPath: resolve8(runtimeWorkspaceRoot, ".rig", "task-config.json"),
1224
+ configPath: resolve9(definitionRoot, "config.sh"),
1225
+ taskConfigPath: resolve9(runtimeWorkspaceRoot, ".rig", "task-config.json"),
1172
1226
  policyDir,
1173
- policyFile: resolve8(policyDir, "policy.json"),
1174
- pluginsDir: resolve8(definitionRoot, "plugins"),
1175
- hooksDir: resolve8(definitionRoot, "hooks"),
1176
- toolsDir: resolve8(definitionRoot, "tools"),
1177
- templatesDir: resolve8(definitionRoot, "templates"),
1178
- validationDir: resolve8(definitionRoot, "validation"),
1227
+ policyFile: resolve9(policyDir, "policy.json"),
1228
+ pluginsDir: resolve9(definitionRoot, "plugins"),
1229
+ hooksDir: resolve9(definitionRoot, "hooks"),
1230
+ toolsDir: resolve9(definitionRoot, "tools"),
1231
+ templatesDir: resolve9(definitionRoot, "templates"),
1232
+ validationDir: resolve9(definitionRoot, "validation"),
1179
1233
  stateDir: runtimeLayout.stateDir,
1180
1234
  logsDir: runtimeLayout.logsDir,
1181
- notificationsDir: resolve8(definitionRoot, "notifications"),
1235
+ notificationsDir: resolve9(definitionRoot, "notifications"),
1182
1236
  runtimeDir: runtimeLayout.runtimeDir,
1183
1237
  distDir: runtimeLayout.distDir,
1184
1238
  binDir: runtimeLayout.binDir,
1185
1239
  pluginBinDir: runtimeLayout.pluginBinDir,
1186
- keybindingsPath: resolve8(definitionRoot, "keybindings.json"),
1240
+ keybindingsPath: resolve9(definitionRoot, "keybindings.json"),
1187
1241
  controlPlaneEventsFile: runtimeLayout.controlPlaneEventsFile
1188
1242
  };
1189
1243
  }
1190
1244
 
1191
1245
  // packages/runtime/src/control-plane/native/runtime-native.ts
1192
1246
  import { dlopen, ptr, suffix, toBuffer } from "bun:ffi";
1193
- import { copyFileSync, existsSync as existsSync7, mkdirSync as mkdirSync3, renameSync, rmSync, statSync as statSync2 } from "fs";
1247
+ import { copyFileSync, existsSync as existsSync8, mkdirSync as mkdirSync4, renameSync, rmSync as rmSync2, statSync as statSync2 } from "fs";
1194
1248
  import { tmpdir as tmpdir4 } from "os";
1195
- import { dirname as dirname7, resolve as resolve9 } from "path";
1196
- var sharedNativeRuntimeOutputDir = resolve9(tmpdir4(), "rig-native");
1197
- var sharedNativeRuntimeOutputPath = resolve9(sharedNativeRuntimeOutputDir, `runtime-native-${process.platform}-${process.arch}.${suffix}`);
1249
+ import { dirname as dirname7, resolve as resolve10 } from "path";
1250
+ var sharedNativeRuntimeOutputDir = resolve10(tmpdir4(), "rig-native");
1251
+ var sharedNativeRuntimeOutputPath = resolve10(sharedNativeRuntimeOutputDir, `runtime-native-${process.platform}-${process.arch}.${suffix}`);
1198
1252
  var colocatedNativeRuntimeFileName = `runtime-native.${suffix}`;
1199
1253
  var nativeRuntimeLibrary = await loadNativeRuntimeLibrary();
1200
1254
  async function ensureNativeRuntimeLibraryPath(outputPath = sharedNativeRuntimeOutputPath, options = {}) {
1201
1255
  if (await buildNativeRuntimeLibrary(outputPath, options)) {
1202
1256
  return outputPath;
1203
1257
  }
1204
- return !options.force && existsSync7(outputPath) ? outputPath : null;
1258
+ return !options.force && existsSync8(outputPath) ? outputPath : null;
1205
1259
  }
1206
1260
  async function loadNativeRuntimeLibrary() {
1207
1261
  if (process.env.RIG_DISABLE_ZIG_NATIVE === "1") {
1208
1262
  return null;
1209
1263
  }
1210
1264
  for (const candidate of nativeRuntimeLibraryCandidates()) {
1211
- if (!candidate || !existsSync7(candidate)) {
1265
+ if (!candidate || !existsSync8(candidate)) {
1212
1266
  continue;
1213
1267
  }
1214
1268
  const loaded = tryDlopenNativeRuntimeLibrary(candidate);
@@ -1224,10 +1278,10 @@ async function loadNativeRuntimeLibrary() {
1224
1278
  }
1225
1279
  function nativePackageLibraryCandidates(fromDir, names) {
1226
1280
  const candidates = [];
1227
- let cursor = resolve9(fromDir);
1281
+ let cursor = resolve10(fromDir);
1228
1282
  for (let index = 0;index < 8; index += 1) {
1229
1283
  for (const name of names) {
1230
- candidates.push(resolve9(cursor, "native", `${process.platform}-${process.arch}`, name), resolve9(cursor, "native", `${process.platform}-${process.arch}`, "lib", name), resolve9(cursor, "native", name), resolve9(cursor, "native", "lib", name));
1284
+ candidates.push(resolve10(cursor, "native", `${process.platform}-${process.arch}`, name), resolve10(cursor, "native", `${process.platform}-${process.arch}`, "lib", name), resolve10(cursor, "native", name), resolve10(cursor, "native", "lib", name));
1231
1285
  }
1232
1286
  const parent = dirname7(cursor);
1233
1287
  if (parent === cursor)
@@ -1243,22 +1297,22 @@ function nativeRuntimeLibraryCandidates() {
1243
1297
  return [...new Set([
1244
1298
  explicit,
1245
1299
  ...nativePackageLibraryCandidates(import.meta.dir, [colocatedNativeRuntimeFileName, platformSpecific]),
1246
- execDir ? resolve9(execDir, colocatedNativeRuntimeFileName) : "",
1247
- execDir ? resolve9(execDir, platformSpecific) : "",
1248
- execDir ? resolve9(execDir, "..", colocatedNativeRuntimeFileName) : "",
1249
- execDir ? resolve9(execDir, "..", platformSpecific) : "",
1250
- execDir ? resolve9(execDir, "lib", colocatedNativeRuntimeFileName) : "",
1251
- execDir ? resolve9(execDir, "..", "lib", colocatedNativeRuntimeFileName) : "",
1300
+ execDir ? resolve10(execDir, colocatedNativeRuntimeFileName) : "",
1301
+ execDir ? resolve10(execDir, platformSpecific) : "",
1302
+ execDir ? resolve10(execDir, "..", colocatedNativeRuntimeFileName) : "",
1303
+ execDir ? resolve10(execDir, "..", platformSpecific) : "",
1304
+ execDir ? resolve10(execDir, "lib", colocatedNativeRuntimeFileName) : "",
1305
+ execDir ? resolve10(execDir, "..", "lib", colocatedNativeRuntimeFileName) : "",
1252
1306
  sharedNativeRuntimeOutputPath
1253
1307
  ].filter(Boolean))];
1254
1308
  }
1255
1309
  function resolveNativeRuntimeSourcePath() {
1256
1310
  const explicit = process.env.RIG_NATIVE_RUNTIME_SOURCE?.trim();
1257
- if (explicit && existsSync7(explicit)) {
1311
+ if (explicit && existsSync8(explicit)) {
1258
1312
  return explicit;
1259
1313
  }
1260
- const bundled = resolve9(import.meta.dir, "../../../native/snapshot.zig");
1261
- return existsSync7(bundled) ? bundled : null;
1314
+ const bundled = resolve10(import.meta.dir, "../../../native/snapshot.zig");
1315
+ return existsSync8(bundled) ? bundled : null;
1262
1316
  }
1263
1317
  async function buildNativeRuntimeLibrary(outputPath, options = {}) {
1264
1318
  if (process.env.RIG_DISABLE_ZIG_NATIVE === "1") {
@@ -1271,8 +1325,8 @@ async function buildNativeRuntimeLibrary(outputPath, options = {}) {
1271
1325
  }
1272
1326
  const tempOutputPath = `${outputPath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
1273
1327
  try {
1274
- mkdirSync3(dirname7(outputPath), { recursive: true });
1275
- const needsBuild = options.force === true || !existsSync7(outputPath) || statSync2(sourcePath).mtimeMs > statSync2(outputPath).mtimeMs;
1328
+ mkdirSync4(dirname7(outputPath), { recursive: true });
1329
+ const needsBuild = options.force === true || !existsSync8(outputPath) || statSync2(sourcePath).mtimeMs > statSync2(outputPath).mtimeMs;
1276
1330
  if (!needsBuild) {
1277
1331
  return true;
1278
1332
  }
@@ -1290,14 +1344,14 @@ async function buildNativeRuntimeLibrary(outputPath, options = {}) {
1290
1344
  stderr: "pipe"
1291
1345
  });
1292
1346
  const exitCode = await build.exited;
1293
- if (exitCode !== 0 || !existsSync7(tempOutputPath)) {
1294
- rmSync(tempOutputPath, { force: true });
1347
+ if (exitCode !== 0 || !existsSync8(tempOutputPath)) {
1348
+ rmSync2(tempOutputPath, { force: true });
1295
1349
  return false;
1296
1350
  }
1297
1351
  renameSync(tempOutputPath, outputPath);
1298
1352
  return true;
1299
1353
  } catch {
1300
- rmSync(tempOutputPath, { force: true });
1354
+ rmSync2(tempOutputPath, { force: true });
1301
1355
  return false;
1302
1356
  }
1303
1357
  }
@@ -1377,11 +1431,11 @@ function runCapture(command, cwd, env) {
1377
1431
  };
1378
1432
  }
1379
1433
  function readJsonFile(path, fallback) {
1380
- if (!existsSync8(path)) {
1434
+ if (!existsSync9(path)) {
1381
1435
  return fallback;
1382
1436
  }
1383
1437
  try {
1384
- return JSON.parse(readFileSync5(path, "utf-8"));
1438
+ return JSON.parse(readFileSync6(path, "utf-8"));
1385
1439
  } catch {
1386
1440
  return fallback;
1387
1441
  }
@@ -1392,31 +1446,31 @@ function nowIso() {
1392
1446
  function resolveHarnessPaths(projectRoot) {
1393
1447
  const hasRuntimeWorkspace = Boolean(process.env.RIG_TASK_WORKSPACE?.trim());
1394
1448
  const monorepoRoot = resolveMonorepoRoot2(projectRoot);
1395
- const harnessRoot = resolve10(projectRoot, "rig");
1396
- const stateRoot = resolve10(projectRoot, ".rig");
1449
+ const harnessRoot = resolve11(projectRoot, "rig");
1450
+ const stateRoot = resolve11(projectRoot, ".rig");
1397
1451
  const layout = hasRuntimeWorkspace ? resolveRigLayout(projectRoot) : null;
1398
- const stateDir = layout?.stateDir ?? resolve10(stateRoot, "state");
1399
- const logsDir = layout?.logsDir ?? resolve10(stateRoot, "logs");
1400
- const artifactsDir = layout?.artifactsRoot ?? resolve10(monorepoRoot, "artifacts");
1401
- const taskConfigPath = layout?.taskConfigPath ?? resolve10(monorepoRoot, ".rig", "task-config.json");
1402
- const binDir = layout?.binDir ?? resolve10(stateRoot, "bin");
1452
+ const stateDir = layout?.stateDir ?? resolve11(stateRoot, "state");
1453
+ const logsDir = layout?.logsDir ?? resolve11(stateRoot, "logs");
1454
+ const artifactsDir = layout?.artifactsRoot ?? resolve11(monorepoRoot, "artifacts");
1455
+ const taskConfigPath = layout?.taskConfigPath ?? resolve11(monorepoRoot, ".rig", "task-config.json");
1456
+ const binDir = layout?.binDir ?? resolve11(stateRoot, "bin");
1403
1457
  return {
1404
1458
  harnessRoot,
1405
1459
  stateDir: process.env.RIG_STATE_DIR || stateDir,
1406
1460
  artifactsDir,
1407
1461
  logsDir: process.env.RIG_LOGS_DIR || logsDir,
1408
1462
  binDir,
1409
- hooksDir: resolve10(harnessRoot, "hooks"),
1410
- validationDir: resolve10(harnessRoot, "validation"),
1463
+ hooksDir: resolve11(harnessRoot, "hooks"),
1464
+ validationDir: resolve11(harnessRoot, "validation"),
1411
1465
  taskConfigPath,
1412
- sessionPath: process.env.RIG_SESSION_FILE || resolve10(stateRoot, "session", "session.json"),
1466
+ sessionPath: process.env.RIG_SESSION_FILE || resolve11(stateRoot, "session", "session.json"),
1413
1467
  monorepoRoot,
1414
- tsApiTestsDir: process.env.TS_API_TESTS_DIR || resolve10(monorepoRoot, "TSAPITests"),
1415
- taskRepoCommitsPath: resolve10(stateDir, "task-repo-commits.json"),
1416
- baseRepoPinsPath: resolve10(stateDir, "base-repo-pins.json"),
1417
- failedApproachesPath: resolve10(stateDir, "failed_approaches.md"),
1418
- agentProfilePath: resolve10(stateDir, "agent-profile.json"),
1419
- reviewProfilePath: resolve10(stateDir, "review-profile.json")
1468
+ tsApiTestsDir: process.env.TS_API_TESTS_DIR || resolve11(monorepoRoot, "TSAPITests"),
1469
+ taskRepoCommitsPath: resolve11(stateDir, "task-repo-commits.json"),
1470
+ baseRepoPinsPath: resolve11(stateDir, "base-repo-pins.json"),
1471
+ failedApproachesPath: resolve11(stateDir, "failed_approaches.md"),
1472
+ agentProfilePath: resolve11(stateDir, "agent-profile.json"),
1473
+ reviewProfilePath: resolve11(stateDir, "review-profile.json")
1420
1474
  };
1421
1475
  }
1422
1476
  // packages/runtime/src/control-plane/state-sync/reconcile.ts
@@ -1471,25 +1525,25 @@ function lookupTask(projectRoot, input) {
1471
1525
  function artifactDirForId(projectRoot, id) {
1472
1526
  const workspaceDir = process.env.RIG_TASK_WORKSPACE?.trim();
1473
1527
  if (workspaceDir) {
1474
- const worktreeArtifacts = resolve11(workspaceDir, "artifacts", id);
1475
- if (existsSync9(worktreeArtifacts) || existsSync9(resolve11(workspaceDir, "artifacts"))) {
1528
+ const worktreeArtifacts = resolve12(workspaceDir, "artifacts", id);
1529
+ if (existsSync10(worktreeArtifacts) || existsSync10(resolve12(workspaceDir, "artifacts"))) {
1476
1530
  return worktreeArtifacts;
1477
1531
  }
1478
1532
  }
1479
1533
  try {
1480
1534
  const paths = resolveHarnessPaths(projectRoot);
1481
- return resolve11(paths.artifactsDir, id);
1535
+ return resolve12(paths.artifactsDir, id);
1482
1536
  } catch {
1483
- return resolve11(resolveMonorepoRoot2(projectRoot), "artifacts", id);
1537
+ return resolve12(resolveMonorepoRoot2(projectRoot), "artifacts", id);
1484
1538
  }
1485
1539
  }
1486
1540
  function resolveTaskConfigPath(projectRoot) {
1487
1541
  const paths = resolveHarnessPaths(projectRoot);
1488
- if (existsSync9(paths.taskConfigPath)) {
1542
+ if (existsSync10(paths.taskConfigPath)) {
1489
1543
  return paths.taskConfigPath;
1490
1544
  }
1491
1545
  for (const candidate of sourceTaskConfigCandidates(projectRoot)) {
1492
- if (existsSync9(candidate)) {
1546
+ if (existsSync10(candidate)) {
1493
1547
  return candidate;
1494
1548
  }
1495
1549
  }
@@ -1497,7 +1551,7 @@ function resolveTaskConfigPath(projectRoot) {
1497
1551
  }
1498
1552
  function findSourceTaskConfigPath(projectRoot) {
1499
1553
  for (const candidate of sourceTaskConfigCandidates(projectRoot)) {
1500
- if (existsSync9(candidate)) {
1554
+ if (existsSync10(candidate)) {
1501
1555
  return candidate;
1502
1556
  }
1503
1557
  }
@@ -1510,7 +1564,7 @@ function readAndSyncSourceTaskConfig(projectRoot) {
1510
1564
  const synced = synchronizeTaskConfigWithTracker(projectRoot, raw);
1511
1565
  if (sourcePath && synced.updated) {
1512
1566
  try {
1513
- writeFileSync4(sourcePath, `${JSON.stringify(synced.config, null, 2)}
1567
+ writeFileSync5(sourcePath, `${JSON.stringify(synced.config, null, 2)}
1514
1568
  `, "utf-8");
1515
1569
  } catch {}
1516
1570
  }
@@ -1562,12 +1616,12 @@ function shouldRefreshAutoSyncedTaskConfigEntry(entry) {
1562
1616
  return !candidate.role;
1563
1617
  }
1564
1618
  function readSourceIssueRecords(projectRoot) {
1565
- const issuesPath = resolve11(resolveMonorepoRoot2(projectRoot), ".beads", "issues.jsonl");
1566
- if (!existsSync9(issuesPath)) {
1619
+ const issuesPath = resolve12(resolveMonorepoRoot2(projectRoot), ".beads", "issues.jsonl");
1620
+ if (!existsSync10(issuesPath)) {
1567
1621
  return [];
1568
1622
  }
1569
1623
  const records = [];
1570
- for (const line of readFileSync6(issuesPath, "utf-8").split(/\r?\n/)) {
1624
+ for (const line of readFileSync7(issuesPath, "utf-8").split(/\r?\n/)) {
1571
1625
  const trimmed = line.trim();
1572
1626
  if (!trimmed) {
1573
1627
  continue;
@@ -1623,19 +1677,19 @@ function readConfiguredFileTaskConfig(projectRoot) {
1623
1677
  if (!sourcePath) {
1624
1678
  return {};
1625
1679
  }
1626
- const directory = resolve11(projectRoot, sourcePath);
1627
- if (!existsSync9(directory)) {
1680
+ const directory = resolve12(projectRoot, sourcePath);
1681
+ if (!existsSync10(directory)) {
1628
1682
  return {};
1629
1683
  }
1630
1684
  const config = {};
1631
- for (const name of readdirSync2(directory)) {
1685
+ for (const name of readdirSync3(directory)) {
1632
1686
  if (!FILE_TASK_PATTERN2.test(name))
1633
1687
  continue;
1634
- const file = resolve11(directory, name);
1688
+ const file = resolve12(directory, name);
1635
1689
  try {
1636
1690
  if (!statSync3(file).isFile())
1637
1691
  continue;
1638
- const raw = JSON.parse(readFileSync6(file, "utf8"));
1692
+ const raw = JSON.parse(readFileSync7(file, "utf8"));
1639
1693
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
1640
1694
  continue;
1641
1695
  const record = raw;
@@ -1677,10 +1731,10 @@ function firstStringList2(...candidates) {
1677
1731
  return [];
1678
1732
  }
1679
1733
  function readConfiguredFilesTaskSourcePath2(projectRoot) {
1680
- const jsonPath = resolve11(projectRoot, "rig.config.json");
1681
- if (existsSync9(jsonPath)) {
1734
+ const jsonPath = resolve12(projectRoot, "rig.config.json");
1735
+ if (existsSync10(jsonPath)) {
1682
1736
  try {
1683
- const parsed = JSON.parse(readFileSync6(jsonPath, "utf8"));
1737
+ const parsed = JSON.parse(readFileSync7(jsonPath, "utf8"));
1684
1738
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
1685
1739
  const taskSource = parsed.taskSource;
1686
1740
  if (taskSource && typeof taskSource === "object" && !Array.isArray(taskSource)) {
@@ -1692,12 +1746,12 @@ function readConfiguredFilesTaskSourcePath2(projectRoot) {
1692
1746
  return null;
1693
1747
  }
1694
1748
  }
1695
- const tsPath = resolve11(projectRoot, "rig.config.ts");
1696
- if (!existsSync9(tsPath)) {
1749
+ const tsPath = resolve12(projectRoot, "rig.config.ts");
1750
+ if (!existsSync10(tsPath)) {
1697
1751
  return null;
1698
1752
  }
1699
1753
  try {
1700
- const source = readFileSync6(tsPath, "utf8");
1754
+ const source = readFileSync7(tsPath, "utf8");
1701
1755
  const taskSourceBlock = source.match(/taskSource\s*:\s*\{[\s\S]*?\}/m)?.[0] ?? "";
1702
1756
  const kind = taskSourceBlock.match(/kind\s*:\s*["']([^"']+)["']/)?.[1];
1703
1757
  if (kind !== "files") {
@@ -1711,9 +1765,9 @@ function readConfiguredFilesTaskSourcePath2(projectRoot) {
1711
1765
  function sourceTaskConfigCandidates(projectRoot) {
1712
1766
  const runtimeContext = loadRuntimeContextFromEnv();
1713
1767
  return [
1714
- runtimeContext?.monorepoMainRoot ? resolve11(runtimeContext.monorepoMainRoot, ".rig", "task-config.json") : "",
1715
- process.env.MONOREPO_MAIN_ROOT?.trim() ? resolve11(process.env.MONOREPO_MAIN_ROOT.trim(), ".rig", "task-config.json") : "",
1716
- resolve11(resolveMonorepoRoot2(projectRoot), ".rig", "task-config.json")
1768
+ runtimeContext?.monorepoMainRoot ? resolve12(runtimeContext.monorepoMainRoot, ".rig", "task-config.json") : "",
1769
+ process.env.MONOREPO_MAIN_ROOT?.trim() ? resolve12(process.env.MONOREPO_MAIN_ROOT.trim(), ".rig", "task-config.json") : "",
1770
+ resolve12(resolveMonorepoRoot2(projectRoot), ".rig", "task-config.json")
1717
1771
  ].filter(Boolean);
1718
1772
  }
1719
1773
 
@@ -3011,12 +3065,12 @@ var TASK_ARTIFACT_STAGE_FALLBACK = new Set([
3011
3065
  "validation-summary.json"
3012
3066
  ]);
3013
3067
  function readPrMetadata(projectRoot, taskId) {
3014
- const path = resolve12(artifactDirForId(projectRoot, taskId), "pr-state.json");
3015
- if (!existsSync10(path)) {
3068
+ const path = resolve13(artifactDirForId(projectRoot, taskId), "pr-state.json");
3069
+ if (!existsSync11(path)) {
3016
3070
  return [];
3017
3071
  }
3018
3072
  try {
3019
- const parsed = JSON.parse(readFileSync7(path, "utf-8"));
3073
+ const parsed = JSON.parse(readFileSync8(path, "utf-8"));
3020
3074
  if (!parsed || typeof parsed !== "object") {
3021
3075
  return [];
3022
3076
  }
@@ -3042,11 +3096,11 @@ async function verifyTask(options) {
3042
3096
  const taskId = options.taskId;
3043
3097
  const normalizedTaskId = lookupTask(options.projectRoot, taskId);
3044
3098
  const artifactDir = artifactDirForId(options.projectRoot, taskId);
3045
- mkdirSync5(artifactDir, { recursive: true });
3046
- const validationSummaryPath = resolve13(artifactDir, "validation-summary.json");
3047
- const reviewFeedbackPath = resolve13(artifactDir, "review-feedback.md");
3048
- const reviewStatePath = resolve13(artifactDir, "review-state.json");
3049
- const greptileRawPath = resolve13(artifactDir, "review-greptile-raw.json");
3099
+ mkdirSync6(artifactDir, { recursive: true });
3100
+ const validationSummaryPath = resolve14(artifactDir, "validation-summary.json");
3101
+ const reviewFeedbackPath = resolve14(artifactDir, "review-feedback.md");
3102
+ const reviewStatePath = resolve14(artifactDir, "review-state.json");
3103
+ const greptileRawPath = resolve14(artifactDir, "review-greptile-raw.json");
3050
3104
  const prStates = readPrMetadata(options.projectRoot, taskId);
3051
3105
  const prState = prStates[0] || null;
3052
3106
  const localReasons = [];
@@ -3058,7 +3112,7 @@ async function verifyTask(options) {
3058
3112
  if (!normalizedTaskId && !await hasConfiguredSourceTask(options.projectRoot, taskId)) {
3059
3113
  localReasons.push(`[Task Config] Unknown task id '${taskId}' in task-config or configured task source.`);
3060
3114
  }
3061
- if (!existsSync11(validationSummaryPath)) {
3115
+ if (!existsSync12(validationSummaryPath)) {
3062
3116
  localReasons.push(`[Artifact Quality] validation-summary.json not found at ${validationSummaryPath}.`);
3063
3117
  } else {
3064
3118
  const summary = await parseValidationSummary(validationSummaryPath);
@@ -3067,13 +3121,13 @@ async function verifyTask(options) {
3067
3121
  }
3068
3122
  }
3069
3123
  for (const file of ["task-result.json", "decision-log.md", "next-actions.md", "changed-files.txt"]) {
3070
- const requiredPath = resolve13(artifactDir, file);
3071
- if (!existsSync11(requiredPath)) {
3124
+ const requiredPath = resolve14(artifactDir, file);
3125
+ if (!existsSync12(requiredPath)) {
3072
3126
  localReasons.push(`[Artifact Quality] Missing required artifact file: ${requiredPath}`);
3073
3127
  }
3074
3128
  }
3075
- const taskResultPath = resolve13(artifactDir, "task-result.json");
3076
- if (existsSync11(taskResultPath)) {
3129
+ const taskResultPath = resolve14(artifactDir, "task-result.json");
3130
+ if (existsSync12(taskResultPath)) {
3077
3131
  const taskResult = await readJsonFile2(taskResultPath);
3078
3132
  const artifactStatus = typeof taskResult?.status === "string" ? taskResult.status.trim().toLowerCase() : "";
3079
3133
  if (artifactStatus === "partial") {
@@ -3086,8 +3140,8 @@ async function verifyTask(options) {
3086
3140
  localReasons.push("[Artifact Quality] task-result.json next actions indicate remaining implementation scope.");
3087
3141
  }
3088
3142
  }
3089
- const nextActionsPath = resolve13(artifactDir, "next-actions.md");
3090
- if (existsSync11(nextActionsPath)) {
3143
+ const nextActionsPath = resolve14(artifactDir, "next-actions.md");
3144
+ if (existsSync12(nextActionsPath)) {
3091
3145
  const nextActionsContent = await Bun.file(nextActionsPath).text();
3092
3146
  if (nextActionsContent.includes("TODO: Replace this scaffold") || nextActionsContent.includes("bd-<downstream-task-id>")) {
3093
3147
  localReasons.push("[Artifact Quality] next-actions.md still contains scaffold placeholder text. Replace with real recommendations.");
@@ -3100,12 +3154,6 @@ async function verifyTask(options) {
3100
3154
  if (sourceCloseoutIssueId) {
3101
3155
  localReasons.push(...evaluateGithubSourceIssuePrCloseout(options.projectRoot, prStates, sourceCloseoutIssueId));
3102
3156
  }
3103
- const pluginResults = await options.plugins.runValidators(taskId);
3104
- for (const result of pluginResults) {
3105
- if (!result.passed) {
3106
- localReasons.push(`[Plugin Validator] ${result.id}: ${result.summary}`);
3107
- }
3108
- }
3109
3157
  const reviewMode = await loadReviewMode(paths.reviewProfilePath, process.env.AI_REVIEW_MODE || "advisory");
3110
3158
  const reviewProvider = await loadReviewProvider(paths.reviewProfilePath, process.env.AI_REVIEW_PROVIDER || "greptile");
3111
3159
  if (!options.skipAiReview && localReasons.length === 0 && reviewProvider === "greptile" && reviewMode !== "off") {
@@ -3124,7 +3172,7 @@ async function verifyTask(options) {
3124
3172
  aiReasons.push(`[AI Review] Required mode needs a completed Greptile approval; current verdict is ${ai.verdict}.`);
3125
3173
  }
3126
3174
  if (persistArtifacts && ai.rawResponse) {
3127
- writeFileSync6(greptileRawPath, `${ai.rawResponse}
3175
+ writeFileSync7(greptileRawPath, `${ai.rawResponse}
3128
3176
  `, "utf-8");
3129
3177
  }
3130
3178
  } else if (!options.skipAiReview && reviewMode === "off") {
@@ -3463,7 +3511,7 @@ function isAcceptedValidationSummary(summary) {
3463
3511
  return summary.status === "skipped" && summary.total === 0 && summary.failed === 0;
3464
3512
  }
3465
3513
  async function loadReviewMode(reviewProfilePath, fallback) {
3466
- const parsed = existsSync11(reviewProfilePath) ? await readJsonFile2(reviewProfilePath) : null;
3514
+ const parsed = existsSync12(reviewProfilePath) ? await readJsonFile2(reviewProfilePath) : null;
3467
3515
  const mode = parsed?.mode;
3468
3516
  if (mode === "off" || mode === "advisory" || mode === "required") {
3469
3517
  return mode;
@@ -3474,7 +3522,7 @@ async function loadReviewMode(reviewProfilePath, fallback) {
3474
3522
  return "advisory";
3475
3523
  }
3476
3524
  async function loadReviewProvider(reviewProfilePath, fallback) {
3477
- const parsed = existsSync11(reviewProfilePath) ? await readJsonFile2(reviewProfilePath) : null;
3525
+ const parsed = existsSync12(reviewProfilePath) ? await readJsonFile2(reviewProfilePath) : null;
3478
3526
  const provider = parsed?.provider;
3479
3527
  if (typeof provider === "string" && provider.trim().length > 0) {
3480
3528
  return provider;
@@ -3633,7 +3681,7 @@ function writeFeedbackFile(options) {
3633
3681
  if (options.aiRawFeedback) {
3634
3682
  lines.push("## Raw Reviewer Feedback", "", "```text", options.aiRawFeedback, "```", "");
3635
3683
  }
3636
- writeFileSync6(options.output, `${lines.join(`
3684
+ writeFileSync7(options.output, `${lines.join(`
3637
3685
  `)}
3638
3686
  `, "utf-8");
3639
3687
  }
@@ -3650,7 +3698,7 @@ function writeReviewStateFile(options) {
3650
3698
  ai_warnings: options.aiWarnings,
3651
3699
  updated_at: nowIso()
3652
3700
  };
3653
- writeFileSync6(options.output, `${JSON.stringify(payload, null, 2)}
3701
+ writeFileSync7(options.output, `${JSON.stringify(payload, null, 2)}
3654
3702
  `, "utf-8");
3655
3703
  }
3656
3704
  async function runGreptileReviewForPr(options) {
@@ -4440,7 +4488,7 @@ function filterActionableGithubGreptileThreads(threads) {
4440
4488
  }
4441
4489
  function resolvePrRepoRoot(projectRoot, prState) {
4442
4490
  const runtimeWorkspace = process.env.RIG_TASK_WORKSPACE?.trim();
4443
- if (prState.target === "monorepo" && runtimeWorkspace && existsSync11(resolve13(runtimeWorkspace, ".git"))) {
4491
+ if (prState.target === "monorepo" && runtimeWorkspace && existsSync12(resolve14(runtimeWorkspace, ".git"))) {
4444
4492
  return runtimeWorkspace;
4445
4493
  }
4446
4494
  const paths = resolveHarnessPaths(projectRoot);