@h-rig/runtime 0.0.6-alpha.32 → 0.0.6-alpha.34

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.
@@ -288,62 +288,17 @@ function readBuildConfig() {
288
288
  }
289
289
  }
290
290
 
291
- // packages/runtime/src/control-plane/runtime/tooling/shell.ts
292
- import { tmpdir } from "os";
293
- import { basename, dirname as dirname2, resolve as resolve3 } from "path";
294
- var sharedNativeShellOutputDir = resolve3(tmpdir(), "rig-native");
295
- var sharedNativeShellOutputPath = resolve3(sharedNativeShellOutputDir, `rig-shell-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
296
- // packages/runtime/src/control-plane/runtime/tooling/file-tools.ts
297
- import { tmpdir as tmpdir2 } from "os";
298
- import { basename as basename2, dirname as dirname3, resolve as resolve4 } from "path";
299
- var sharedNativeToolsOutputDir = resolve4(tmpdir2(), "rig-native");
300
- var sharedNativeToolsOutputPath = resolve4(sharedNativeToolsOutputDir, `rig-tools-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
301
- // packages/runtime/src/control-plane/plugin-host-context.ts
302
- import { createPluginHost } from "@rig/core";
303
- import { loadConfig } from "@rig/core/load-config";
304
-
305
- // packages/runtime/src/control-plane/repos/registry.ts
306
- var MANAGED_REPOS = new Map;
307
-
308
- // packages/runtime/src/control-plane/native/scope-rules.ts
309
- var activeRules = null;
310
- function getScopeRules() {
311
- return activeRules;
312
- }
313
-
314
- // packages/runtime/src/control-plane/skill-materializer.ts
315
- import { loadSkill } from "@rig/skill-loader";
316
-
317
- // packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
318
- var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
319
-
320
- // packages/runtime/src/control-plane/native/task-state.ts
321
- import { existsSync as existsSync7, readFileSync as readFileSync5, readdirSync, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
322
- import { basename as basename4, resolve as resolve9 } from "path";
323
-
324
- // packages/runtime/src/control-plane/state-sync/types.ts
325
- var CANONICAL_TASK_LIFECYCLE_STATUSES = new Set([
326
- "draft",
327
- "open",
328
- "ready",
329
- "queued",
330
- "in_progress",
331
- "under_review",
332
- "blocked",
333
- "completed",
334
- "cancelled"
335
- ]);
336
291
  // packages/runtime/src/control-plane/native/git-native.ts
337
292
  import { chmodSync, copyFileSync, existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
338
- import { tmpdir as tmpdir3 } from "os";
339
- import { dirname as dirname4, isAbsolute, resolve as resolve5 } from "path";
293
+ import { tmpdir } from "os";
294
+ import { dirname as dirname2, isAbsolute, resolve as resolve3 } from "path";
340
295
  import { createHash } from "crypto";
341
- var sharedGitNativeOutputDir = resolve5(tmpdir3(), "rig-native");
342
- var sharedGitNativeOutputPath = resolve5(sharedGitNativeOutputDir, `rig-git-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
296
+ var sharedGitNativeOutputDir = resolve3(tmpdir(), "rig-native");
297
+ var sharedGitNativeOutputPath = resolve3(sharedGitNativeOutputDir, `rig-git-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
343
298
  var trackerCommandUsageProbe = "usage: rig-git fetch-ref <repo-path> <remote> <branch>";
344
299
  function temporaryGitBinaryOutputPath(outputPath) {
345
300
  const suffix = process.platform === "win32" ? ".exe" : "";
346
- return resolve5(dirname4(outputPath), `.rig-git-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}${suffix}`);
301
+ return resolve3(dirname2(outputPath), `.rig-git-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}${suffix}`);
347
302
  }
348
303
  function publishGitBinary(tempOutputPath, outputPath) {
349
304
  try {
@@ -361,27 +316,27 @@ function runtimeRigGitFileName() {
361
316
  return `rig-git${process.platform === "win32" ? ".exe" : ""}`;
362
317
  }
363
318
  function rigGitSourceCandidates() {
364
- const execDir = process.execPath?.trim() ? dirname4(process.execPath.trim()) : "";
319
+ const execDir = process.execPath?.trim() ? dirname2(process.execPath.trim()) : "";
365
320
  const cwd = process.cwd()?.trim() || "";
366
321
  const projectRoot = process.env.PROJECT_RIG_ROOT?.trim() || "";
367
322
  const hostProjectRoot = process.env.RIG_HOST_PROJECT_ROOT?.trim() || "";
368
- const moduleRelativeSource = resolve5(import.meta.dir, "../../../native/rig-git.zig");
323
+ const moduleRelativeSource = resolve3(import.meta.dir, "../../../native/rig-git.zig");
369
324
  return [...new Set([
370
325
  process.env.RIG_NATIVE_GIT_SOURCE?.trim() || "",
371
326
  moduleRelativeSource,
372
- projectRoot ? resolve5(projectRoot, "packages/runtime/native/rig-git.zig") : "",
373
- hostProjectRoot ? resolve5(hostProjectRoot, "packages/runtime/native/rig-git.zig") : "",
374
- cwd ? resolve5(cwd, "packages/runtime/native/rig-git.zig") : "",
375
- execDir ? resolve5(execDir, "..", "..", "packages/runtime/native/rig-git.zig") : "",
376
- execDir ? resolve5(execDir, "..", "native", "rig-git.zig") : ""
327
+ projectRoot ? resolve3(projectRoot, "packages/runtime/native/rig-git.zig") : "",
328
+ hostProjectRoot ? resolve3(hostProjectRoot, "packages/runtime/native/rig-git.zig") : "",
329
+ cwd ? resolve3(cwd, "packages/runtime/native/rig-git.zig") : "",
330
+ execDir ? resolve3(execDir, "..", "..", "packages/runtime/native/rig-git.zig") : "",
331
+ execDir ? resolve3(execDir, "..", "native", "rig-git.zig") : ""
377
332
  ].filter(Boolean))];
378
333
  }
379
334
  function nativePackageBinaryCandidates(fromDir, fileName) {
380
335
  const candidates = [];
381
- let cursor = resolve5(fromDir);
336
+ let cursor = resolve3(fromDir);
382
337
  for (let index = 0;index < 8; index += 1) {
383
- candidates.push(resolve5(cursor, "native", `${process.platform}-${process.arch}`, fileName), resolve5(cursor, "native", `${process.platform}-${process.arch}`, "bin", fileName), resolve5(cursor, "native", fileName), resolve5(cursor, "native", "bin", fileName));
384
- const parent = dirname4(cursor);
338
+ candidates.push(resolve3(cursor, "native", `${process.platform}-${process.arch}`, fileName), resolve3(cursor, "native", `${process.platform}-${process.arch}`, "bin", fileName), resolve3(cursor, "native", fileName), resolve3(cursor, "native", "bin", fileName));
339
+ const parent = dirname2(cursor);
385
340
  if (parent === cursor)
386
341
  break;
387
342
  cursor = parent;
@@ -389,15 +344,15 @@ function nativePackageBinaryCandidates(fromDir, fileName) {
389
344
  return candidates;
390
345
  }
391
346
  function rigGitBinaryCandidates() {
392
- const execDir = process.execPath?.trim() ? dirname4(process.execPath.trim()) : "";
347
+ const execDir = process.execPath?.trim() ? dirname2(process.execPath.trim()) : "";
393
348
  const fileName = runtimeRigGitFileName();
394
349
  const explicit = process.env.RIG_NATIVE_GIT_BIN?.trim() || "";
395
350
  return [...new Set([
396
351
  explicit,
397
352
  ...nativePackageBinaryCandidates(import.meta.dir, fileName),
398
- execDir ? resolve5(execDir, fileName) : "",
399
- execDir ? resolve5(execDir, "..", fileName) : "",
400
- execDir ? resolve5(execDir, "..", "bin", fileName) : "",
353
+ execDir ? resolve3(execDir, fileName) : "",
354
+ execDir ? resolve3(execDir, "..", fileName) : "",
355
+ execDir ? resolve3(execDir, "..", "bin", fileName) : "",
401
356
  sharedGitNativeOutputPath
402
357
  ].filter(Boolean))];
403
358
  }
@@ -473,7 +428,7 @@ function ensureRigGitBinaryPathSync(outputPath = preferredGitBinaryOutputPath())
473
428
  if (!zigBinary) {
474
429
  throw new Error("zig is required to build native Rig git tools.");
475
430
  }
476
- mkdirSync2(dirname4(outputPath), { recursive: true });
431
+ mkdirSync2(dirname2(outputPath), { recursive: true });
477
432
  const sourceDigest = sha256FileSync(sourcePath);
478
433
  const buildKey = JSON.stringify({
479
434
  version: 1,
@@ -498,7 +453,7 @@ function ensureRigGitBinaryPathSync(outputPath = preferredGitBinaryOutputPath())
498
453
  "ReleaseFast",
499
454
  `-femit-bin=${tempOutputPath}`
500
455
  ], {
501
- cwd: dirname4(sourcePath),
456
+ cwd: dirname2(sourcePath),
502
457
  stdout: "pipe",
503
458
  stderr: "pipe"
504
459
  });
@@ -622,8 +577,52 @@ function nativeFileHasChanges(repoPath, filePath) {
622
577
  return null;
623
578
  }
624
579
 
580
+ // packages/runtime/src/control-plane/runtime/tooling/shell.ts
581
+ import { tmpdir as tmpdir2 } from "os";
582
+ import { basename, dirname as dirname3, resolve as resolve4 } from "path";
583
+ var sharedNativeShellOutputDir = resolve4(tmpdir2(), "rig-native");
584
+ var sharedNativeShellOutputPath = resolve4(sharedNativeShellOutputDir, `rig-shell-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
585
+ // packages/runtime/src/control-plane/runtime/tooling/file-tools.ts
586
+ import { tmpdir as tmpdir3 } from "os";
587
+ import { basename as basename2, dirname as dirname4, resolve as resolve5 } from "path";
588
+ var sharedNativeToolsOutputDir = resolve5(tmpdir3(), "rig-native");
589
+ var sharedNativeToolsOutputPath = resolve5(sharedNativeToolsOutputDir, `rig-tools-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
590
+ // packages/runtime/src/control-plane/plugin-host-context.ts
591
+ import { createPluginHost } from "@rig/core";
592
+ import { loadConfig } from "@rig/core/load-config";
593
+
594
+ // packages/runtime/src/control-plane/repos/registry.ts
595
+ var MANAGED_REPOS = new Map;
596
+
597
+ // packages/runtime/src/control-plane/native/scope-rules.ts
598
+ var activeRules = null;
599
+ function getScopeRules() {
600
+ return activeRules;
601
+ }
602
+
603
+ // packages/runtime/src/control-plane/skill-materializer.ts
604
+ import { loadSkill } from "@rig/skill-loader";
605
+
606
+ // packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
607
+ var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
608
+
609
+ // packages/runtime/src/control-plane/native/task-state.ts
610
+ import { existsSync as existsSync7, readFileSync as readFileSync5, readdirSync, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
611
+ import { basename as basename4, resolve as resolve9 } from "path";
612
+
613
+ // packages/runtime/src/control-plane/state-sync/types.ts
614
+ var CANONICAL_TASK_LIFECYCLE_STATUSES = new Set([
615
+ "draft",
616
+ "open",
617
+ "ready",
618
+ "queued",
619
+ "in_progress",
620
+ "under_review",
621
+ "blocked",
622
+ "completed",
623
+ "cancelled"
624
+ ]);
625
625
  // packages/runtime/src/control-plane/native/utils.ts
626
- import { ptr as ptr2 } from "bun:ffi";
627
626
  import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
628
627
  import { resolve as resolve8 } from "path";
629
628
 
@@ -745,12 +744,6 @@ var sharedNativeRuntimeOutputDir = resolve7(tmpdir4(), "rig-native");
745
744
  var sharedNativeRuntimeOutputPath = resolve7(sharedNativeRuntimeOutputDir, `runtime-native-${process.platform}-${process.arch}.${suffix}`);
746
745
  var colocatedNativeRuntimeFileName = `runtime-native.${suffix}`;
747
746
  var nativeRuntimeLibrary = await loadNativeRuntimeLibrary();
748
- function requireNativeRuntimeLibrary(feature) {
749
- if (!nativeRuntimeLibrary) {
750
- throw new Error(`Native Zig runtime is required for ${feature}`);
751
- }
752
- return nativeRuntimeLibrary;
753
- }
754
747
  async function ensureNativeRuntimeLibraryPath(outputPath = sharedNativeRuntimeOutputPath, options = {}) {
755
748
  if (await buildNativeRuntimeLibrary(outputPath, options)) {
756
749
  return outputPath;
@@ -916,7 +909,6 @@ function tryDlopenNativeRuntimeLibrary(outputPath) {
916
909
  function resolveMonorepoRoot2(projectRoot) {
917
910
  return resolveMonorepoRoot(projectRoot);
918
911
  }
919
- var nativeScopeMatcher = null;
920
912
  var scopeRegexCache = new Map;
921
913
  function runCapture(command, cwd, env) {
922
914
  const result = Bun.spawnSync(command, {
@@ -977,63 +969,6 @@ function resolveHarnessPaths(projectRoot) {
977
969
  reviewProfilePath: resolve8(stateDir, "review-profile.json")
978
970
  };
979
971
  }
980
- function normalizeRelativeScopePath(inputPath) {
981
- let normalized = inputPath.replace(/^\.\//, "");
982
- const rules = getScopeRules();
983
- if (rules?.stripPrefixes) {
984
- for (const prefix of rules.stripPrefixes) {
985
- if (normalized.startsWith(prefix)) {
986
- normalized = normalized.slice(prefix.length);
987
- }
988
- }
989
- }
990
- return normalized;
991
- }
992
- function normalizePathToScope(projectRoot, monorepoRoot, inputPath) {
993
- let normalized = inputPath.replace(/^\.\//, "");
994
- if (normalized.startsWith(projectRoot + "/")) {
995
- normalized = normalized.slice(projectRoot.length + 1);
996
- }
997
- if (normalized.startsWith(monorepoRoot + "/")) {
998
- normalized = normalized.slice(monorepoRoot.length + 1);
999
- }
1000
- return normalizeRelativeScopePath(normalized);
1001
- }
1002
- function scopeMatches(path, scopes) {
1003
- const matcher = getNativeScopeMatcher();
1004
- const pathVariants = unique([path, normalizeRelativeScopePath(path)]);
1005
- for (const scope of scopes) {
1006
- const scopeVariants = unique([scope, normalizeRelativeScopePath(scope)]);
1007
- for (const candidatePath of pathVariants) {
1008
- for (const candidateScope of scopeVariants) {
1009
- if (candidatePath === candidateScope) {
1010
- return true;
1011
- }
1012
- if (matcher.match(candidateScope, candidatePath)) {
1013
- return true;
1014
- }
1015
- }
1016
- }
1017
- }
1018
- return false;
1019
- }
1020
- function getNativeScopeMatcher() {
1021
- if (nativeScopeMatcher) {
1022
- return nativeScopeMatcher;
1023
- }
1024
- nativeScopeMatcher = createNativeScopeMatcher();
1025
- return nativeScopeMatcher;
1026
- }
1027
- function createNativeScopeMatcher() {
1028
- const library = requireNativeRuntimeLibrary("scope matching");
1029
- return {
1030
- match: (pattern, path) => {
1031
- const patternBuffer = Buffer.from(`${pattern}\x00`);
1032
- const pathBuffer = Buffer.from(`${path}\x00`);
1033
- return library.symbols.rig_scope_match(Number(ptr2(patternBuffer)), Number(ptr2(pathBuffer))) !== 0;
1034
- }
1035
- };
1036
- }
1037
972
  // packages/runtime/src/control-plane/state-sync/reconcile.ts
1038
973
  var STALE_CLAIM_MS = 24 * 60 * 60 * 1000;
1039
974
  // packages/runtime/src/control-plane/native/task-state.ts
@@ -1415,12 +1350,6 @@ var BAKED_INFO_OUTPUT = BUILD_CONFIG.AGENT_INFO_OUTPUT ?? "";
1415
1350
  var BAKED_DEPS_OUTPUT = BUILD_CONFIG.AGENT_DEPS_OUTPUT ?? "";
1416
1351
  var BAKED_STATUS_OUTPUT = BUILD_CONFIG.AGENT_STATUS_OUTPUT ?? "";
1417
1352
  var REOPENABLE_TASK_STATUSES = new Set(["completed", "cancelled", "blocked"]);
1418
- function hasRuntimeWorkspace() {
1419
- return Boolean(process.env.RIG_TASK_WORKSPACE?.trim());
1420
- }
1421
- function readTaskConfigForInvocation(projectRoot) {
1422
- return hasRuntimeWorkspace() ? readTaskConfig(projectRoot) : readSourceTaskConfig(projectRoot);
1423
- }
1424
1353
  var GENERATED_TASK_ARTIFACT_FILES = new Set([
1425
1354
  "changed-files.txt",
1426
1355
  "decision-log.md",
@@ -1465,20 +1394,7 @@ function filterTaskChangedFiles(projectRoot, taskId, files, scoped) {
1465
1394
  if (!taskId) {
1466
1395
  return unique(uniqueFiles).sort();
1467
1396
  }
1468
- const filteredFiles = unique(uniqueFiles).filter((file) => !isGeneratedTaskChangePath(taskId, file));
1469
- if (!scoped) {
1470
- return filteredFiles.sort();
1471
- }
1472
- const paths = resolveHarnessPaths(projectRoot);
1473
- const monorepoRoot = resolveTaskMonorepoRoot(projectRoot);
1474
- const scopes = readTaskConfigForInvocation(projectRoot)[taskId]?.scope || [];
1475
- if (scopes.length === 0) {
1476
- return [];
1477
- }
1478
- return filteredFiles.filter((file) => {
1479
- const normalized = normalizePathToScope(projectRoot, monorepoRoot || paths.monorepoRoot, file);
1480
- return scopeMatches(file, scopes) || scopeMatches(normalized, scopes);
1481
- }).sort();
1397
+ return unique(uniqueFiles).filter((file) => !isGeneratedTaskChangePath(taskId, file)).sort();
1482
1398
  }
1483
1399
  function resolveTaskMonorepoRoot(projectRoot) {
1484
1400
  const runtimeWorkspace = loadRuntimeContextFromEnv()?.workspaceDir || process.env.RIG_TASK_WORKSPACE?.trim();
@@ -1529,6 +1445,17 @@ function resolveMonorepoBaseCommit(projectRoot, repo) {
1529
1445
  }
1530
1446
  function collectWorkingTreeFiles(projectRoot, repo, baseline) {
1531
1447
  const files = new Set;
1448
+ const nativeFiles = nativePendingFiles(repo);
1449
+ if (nativeFiles !== null) {
1450
+ for (const entry of nativeFiles) {
1451
+ const normalized = normalizeChangedFilePath(entry.path);
1452
+ if (!normalized || baseline.has(normalized)) {
1453
+ continue;
1454
+ }
1455
+ files.add(normalized);
1456
+ }
1457
+ return [...files].sort();
1458
+ }
1532
1459
  for (const args of [
1533
1460
  ["diff", "--name-only"],
1534
1461
  ["diff", "--cached", "--name-only"],
@@ -1660,7 +1587,7 @@ function shouldScopeGitCommit(args, hasTaskContext) {
1660
1587
  if (!hasTaskContext) {
1661
1588
  return false;
1662
1589
  }
1663
- return !args.includes("--all") && !args.includes("--unscoped");
1590
+ return args.includes("--scoped");
1664
1591
  }
1665
1592
  function gitStatus(projectRoot, taskId) {
1666
1593
  const monorepoRoot = resolveOptionalMonorepoRoot(projectRoot);