@h-rig/runtime 0.0.6-alpha.3 → 0.0.6-alpha.31
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/bin/rig-agent-dispatch.js +1165 -785
- package/dist/bin/rig-agent.js +458 -389
- package/dist/src/control-plane/agent-wrapper.js +1191 -504
- package/dist/src/control-plane/authority-files.js +12 -6
- package/dist/src/control-plane/harness-main.js +2186 -1786
- package/dist/src/control-plane/hooks/completion-verification.js +2084 -1019
- package/dist/src/control-plane/hooks/inject-context.js +193 -139
- package/dist/src/control-plane/hooks/submodule-branch.js +603 -545
- package/dist/src/control-plane/hooks/task-runtime-start.js +603 -545
- package/dist/src/control-plane/materialize-task-config.js +64 -8
- package/dist/src/control-plane/native/git-ops.js +90 -64
- package/dist/src/control-plane/native/harness-cli.js +1989 -682
- package/dist/src/control-plane/native/pr-automation.js +1657 -54
- package/dist/src/control-plane/native/pr-review-gate.js +1455 -0
- package/dist/src/control-plane/native/repo-ops.js +3 -0
- package/dist/src/control-plane/native/run-ops.js +39 -13
- package/dist/src/control-plane/native/task-ops.js +1819 -527
- package/dist/src/control-plane/native/validator.js +163 -109
- package/dist/src/control-plane/native/verifier.js +1616 -323
- package/dist/src/control-plane/native/workspace-ops.js +12 -6
- package/dist/src/control-plane/pi-sessiond/bin.js +793 -0
- package/dist/src/control-plane/pi-sessiond/client.js +41 -0
- package/dist/src/control-plane/pi-sessiond/event-hub.js +59 -0
- package/dist/src/control-plane/pi-sessiond/extension-ui-context.js +198 -0
- package/dist/src/control-plane/pi-sessiond/launcher.js +173 -0
- package/dist/src/control-plane/pi-sessiond/server.js +802 -0
- package/dist/src/control-plane/pi-sessiond/session-service.js +540 -0
- package/dist/src/control-plane/pi-sessiond/types.js +1 -0
- package/dist/src/control-plane/plugin-host-context.js +54 -0
- package/dist/src/control-plane/runtime/image/fingerprint-sidecar.js +3 -0
- package/dist/src/control-plane/runtime/image/index.js +3 -0
- package/dist/src/control-plane/runtime/image-fingerprint-sidecar.js +3 -0
- package/dist/src/control-plane/runtime/image.js +3 -0
- package/dist/src/control-plane/runtime/index.js +517 -722
- package/dist/src/control-plane/runtime/isolation/home.js +28 -6
- package/dist/src/control-plane/runtime/isolation/index.js +541 -461
- package/dist/src/control-plane/runtime/isolation/runner.js +28 -6
- package/dist/src/control-plane/runtime/isolation/shared.js +9 -6
- package/dist/src/control-plane/runtime/isolation.js +541 -461
- package/dist/src/control-plane/runtime/plugin-mode.js +3 -27
- package/dist/src/control-plane/runtime/queue.js +458 -385
- package/dist/src/control-plane/runtime/snapshot/task-run.js +3 -0
- package/dist/src/control-plane/runtime/task-run-snapshot.js +3 -0
- package/dist/src/control-plane/skill-materializer.js +46 -0
- package/dist/src/control-plane/tasks/source-aware-task-config-source.js +14 -2
- package/dist/src/control-plane/tasks/source-lifecycle.js +86 -32
- package/dist/src/index.js +27 -298
- package/dist/src/layout.js +12 -7
- package/dist/src/local-server.js +20 -14
- package/native/darwin-arm64/rig-git +0 -0
- package/native/darwin-arm64/rig-git.build-manifest.json +1 -1
- package/native/darwin-arm64/rig-shell +0 -0
- package/native/darwin-arm64/rig-shell.build-manifest.json +1 -1
- package/native/darwin-arm64/rig-tools +0 -0
- package/native/darwin-arm64/rig-tools.build-manifest.json +1 -1
- package/native/darwin-arm64/runtime-native.dylib +0 -0
- package/package.json +8 -6
- package/dist/src/control-plane/runtime/plugins.js +0 -1131
- package/dist/src/plugins.js +0 -329
|
@@ -598,6 +598,9 @@ import { loadConfig } from "@rig/core/load-config";
|
|
|
598
598
|
// packages/runtime/src/control-plane/repos/registry.ts
|
|
599
599
|
var MANAGED_REPOS = new Map;
|
|
600
600
|
|
|
601
|
+
// packages/runtime/src/control-plane/skill-materializer.ts
|
|
602
|
+
import { loadSkill } from "@rig/skill-loader";
|
|
603
|
+
|
|
601
604
|
// packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
|
|
602
605
|
var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
|
|
603
606
|
|
|
@@ -598,6 +598,9 @@ import { loadConfig } from "@rig/core/load-config";
|
|
|
598
598
|
// packages/runtime/src/control-plane/repos/registry.ts
|
|
599
599
|
var MANAGED_REPOS = new Map;
|
|
600
600
|
|
|
601
|
+
// packages/runtime/src/control-plane/skill-materializer.ts
|
|
602
|
+
import { loadSkill } from "@rig/skill-loader";
|
|
603
|
+
|
|
601
604
|
// packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
|
|
602
605
|
var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
|
|
603
606
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/runtime/src/control-plane/skill-materializer.ts
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "fs";
|
|
4
|
+
import { resolve } from "path";
|
|
5
|
+
import { loadSkill } from "@rig/skill-loader";
|
|
6
|
+
var MARKER_FILENAME = ".rig-plugin";
|
|
7
|
+
function skillDirName(id) {
|
|
8
|
+
return id.replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
9
|
+
}
|
|
10
|
+
async function materializeSkills(projectRoot, entries) {
|
|
11
|
+
const skillsRoot = resolve(projectRoot, ".pi", "skills");
|
|
12
|
+
if (existsSync(skillsRoot)) {
|
|
13
|
+
for (const name of readdirSync(skillsRoot)) {
|
|
14
|
+
const dir = resolve(skillsRoot, name);
|
|
15
|
+
if (existsSync(resolve(dir, MARKER_FILENAME))) {
|
|
16
|
+
rmSync(dir, { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const written = [];
|
|
21
|
+
for (const { pluginName, skill } of entries) {
|
|
22
|
+
const sourcePath = resolve(projectRoot, skill.path);
|
|
23
|
+
if (!existsSync(sourcePath)) {
|
|
24
|
+
console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${sourcePath} does not exist`);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
let body;
|
|
28
|
+
try {
|
|
29
|
+
await loadSkill(sourcePath);
|
|
30
|
+
body = readFileSync(sourcePath, "utf-8");
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${err instanceof Error ? err.message : err}`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const dir = resolve(skillsRoot, skillDirName(skill.id));
|
|
36
|
+
mkdirSync(dir, { recursive: true });
|
|
37
|
+
writeFileSync(resolve(dir, "SKILL.md"), body, "utf-8");
|
|
38
|
+
writeFileSync(resolve(dir, MARKER_FILENAME), `${JSON.stringify({ plugin: pluginName, skillId: skill.id }, null, 2)}
|
|
39
|
+
`, "utf-8");
|
|
40
|
+
written.push({ id: skill.id, pluginName, directory: dir });
|
|
41
|
+
}
|
|
42
|
+
return written;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
materializeSkills
|
|
46
|
+
};
|
|
@@ -198,6 +198,17 @@ async function readSourceAwareTaskStatus(projectRoot, taskId, options = {}) {
|
|
|
198
198
|
return null;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
+
function updateGithubIssueTaskBySourceIssueId(sourceIssueId, taskId, update, options = {}) {
|
|
202
|
+
const parsed = sourceIssueId?.trim().match(/^([^/]+)\/([^#]+)#(\d+)$/);
|
|
203
|
+
if (!parsed || parsed[3] !== taskId) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
applyGithubIssueUpdate(options.ghBinary ?? "gh", options.spawn ?? spawnSync, parsed[3], {
|
|
207
|
+
sourceIssueId: sourceIssueId.trim(),
|
|
208
|
+
taskSource: { kind: "github-issues", owner: parsed[1], repo: parsed[2] }
|
|
209
|
+
}, update);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
201
212
|
function updateSourceAwareTaskConfigTask(projectRoot, taskId, update, options = {}) {
|
|
202
213
|
const configPath = options.configPath ?? resolve2(projectRoot, ".rig", "task-config.json");
|
|
203
214
|
const rawEntry = readRawTaskEntry(configPath, taskId);
|
|
@@ -553,8 +564,8 @@ function ensureStatusLabel(bin, repo, spawnFn, label) {
|
|
|
553
564
|
}
|
|
554
565
|
}
|
|
555
566
|
function selectedGitHubEnv() {
|
|
556
|
-
const token = process.env.RIG_GITHUB_SELECTED_TOKEN?.trim()
|
|
557
|
-
return { GH_TOKEN: token, GITHUB_TOKEN: token };
|
|
567
|
+
const token = process.env.RIG_GITHUB_SELECTED_TOKEN?.trim() || process.env.RIG_GITHUB_TOKEN?.trim() || "";
|
|
568
|
+
return { GH_TOKEN: token, GITHUB_TOKEN: token, RIG_GITHUB_TOKEN: token };
|
|
558
569
|
}
|
|
559
570
|
function ghSpawnOptions() {
|
|
560
571
|
return { encoding: "utf-8", env: { ...process.env, ...selectedGitHubEnv() } };
|
|
@@ -605,6 +616,7 @@ function isPlainRecord2(candidate) {
|
|
|
605
616
|
}
|
|
606
617
|
export {
|
|
607
618
|
updateSourceAwareTaskConfigTask,
|
|
619
|
+
updateGithubIssueTaskBySourceIssueId,
|
|
608
620
|
readSourceAwareTaskStatus,
|
|
609
621
|
readMaterializedTaskMetadata,
|
|
610
622
|
createSourceAwareTaskConfigRecordReader
|
|
@@ -283,6 +283,49 @@ function safeReadJson(path) {
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
// packages/runtime/src/control-plane/skill-materializer.ts
|
|
287
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
288
|
+
import { resolve as resolve2 } from "path";
|
|
289
|
+
import { loadSkill } from "@rig/skill-loader";
|
|
290
|
+
var MARKER_FILENAME = ".rig-plugin";
|
|
291
|
+
function skillDirName(id) {
|
|
292
|
+
return id.replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
293
|
+
}
|
|
294
|
+
async function materializeSkills(projectRoot, entries) {
|
|
295
|
+
const skillsRoot = resolve2(projectRoot, ".pi", "skills");
|
|
296
|
+
if (existsSync3(skillsRoot)) {
|
|
297
|
+
for (const name of readdirSync(skillsRoot)) {
|
|
298
|
+
const dir = resolve2(skillsRoot, name);
|
|
299
|
+
if (existsSync3(resolve2(dir, MARKER_FILENAME))) {
|
|
300
|
+
rmSync(dir, { recursive: true, force: true });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const written = [];
|
|
305
|
+
for (const { pluginName, skill } of entries) {
|
|
306
|
+
const sourcePath = resolve2(projectRoot, skill.path);
|
|
307
|
+
if (!existsSync3(sourcePath)) {
|
|
308
|
+
console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${sourcePath} does not exist`);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
let body;
|
|
312
|
+
try {
|
|
313
|
+
await loadSkill(sourcePath);
|
|
314
|
+
body = readFileSync2(sourcePath, "utf-8");
|
|
315
|
+
} catch (err) {
|
|
316
|
+
console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${err instanceof Error ? err.message : err}`);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const dir = resolve2(skillsRoot, skillDirName(skill.id));
|
|
320
|
+
mkdirSync2(dir, { recursive: true });
|
|
321
|
+
writeFileSync2(resolve2(dir, "SKILL.md"), body, "utf-8");
|
|
322
|
+
writeFileSync2(resolve2(dir, MARKER_FILENAME), `${JSON.stringify({ plugin: pluginName, skillId: skill.id }, null, 2)}
|
|
323
|
+
`, "utf-8");
|
|
324
|
+
written.push({ id: skill.id, pluginName, directory: dir });
|
|
325
|
+
}
|
|
326
|
+
return written;
|
|
327
|
+
}
|
|
328
|
+
|
|
286
329
|
// packages/runtime/src/control-plane/plugin-host-context.ts
|
|
287
330
|
async function buildPluginHostContext(projectRoot) {
|
|
288
331
|
let config;
|
|
@@ -319,6 +362,17 @@ async function buildPluginHostContext(projectRoot) {
|
|
|
319
362
|
} catch (err) {
|
|
320
363
|
console.warn(`[plugin-host] hook materialization failed: ${err instanceof Error ? err.message : err}`);
|
|
321
364
|
}
|
|
365
|
+
try {
|
|
366
|
+
const skillEntries = config.plugins.flatMap((plugin) => (plugin.contributes?.skills ?? []).map((skill) => ({
|
|
367
|
+
pluginName: plugin.name,
|
|
368
|
+
skill
|
|
369
|
+
})));
|
|
370
|
+
if (skillEntries.length > 0) {
|
|
371
|
+
await materializeSkills(projectRoot, skillEntries);
|
|
372
|
+
}
|
|
373
|
+
} catch (err) {
|
|
374
|
+
console.warn(`[plugin-host] skill materialization failed: ${err instanceof Error ? err.message : err}`);
|
|
375
|
+
}
|
|
322
376
|
return {
|
|
323
377
|
config,
|
|
324
378
|
pluginHost,
|
|
@@ -332,12 +386,12 @@ async function buildPluginHostContext(projectRoot) {
|
|
|
332
386
|
|
|
333
387
|
// packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
|
|
334
388
|
import { spawnSync } from "child_process";
|
|
335
|
-
import { existsSync as
|
|
336
|
-
import { basename, join as join2, resolve as
|
|
389
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync, writeFileSync as writeFileSync3 } from "fs";
|
|
390
|
+
import { basename, join as join2, resolve as resolve4 } from "path";
|
|
337
391
|
|
|
338
392
|
// packages/runtime/src/control-plane/tasks/legacy-task-config-source.ts
|
|
339
|
-
import { existsSync as
|
|
340
|
-
import { resolve as
|
|
393
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
394
|
+
import { resolve as resolve3 } from "path";
|
|
341
395
|
|
|
342
396
|
// packages/runtime/src/control-plane/tasks/task-record-reader.ts
|
|
343
397
|
async function findTaskById(reader, id) {
|
|
@@ -360,7 +414,7 @@ class LegacyTaskConfigReadError extends Error {
|
|
|
360
414
|
}
|
|
361
415
|
}
|
|
362
416
|
function createLegacyTaskConfigRecordReader(projectRoot, options = {}) {
|
|
363
|
-
const configPath = options.configPath ??
|
|
417
|
+
const configPath = options.configPath ?? resolve3(projectRoot, ".rig", "task-config.json");
|
|
364
418
|
const reader = {
|
|
365
419
|
async listTasks() {
|
|
366
420
|
return readLegacyTaskRecords(projectRoot, configPath);
|
|
@@ -371,8 +425,8 @@ function createLegacyTaskConfigRecordReader(projectRoot, options = {}) {
|
|
|
371
425
|
};
|
|
372
426
|
return reader;
|
|
373
427
|
}
|
|
374
|
-
function readLegacyTaskRecords(projectRoot, configPath =
|
|
375
|
-
if (!
|
|
428
|
+
function readLegacyTaskRecords(projectRoot, configPath = resolve3(projectRoot, ".rig", "task-config.json")) {
|
|
429
|
+
if (!existsSync4(configPath)) {
|
|
376
430
|
return [];
|
|
377
431
|
}
|
|
378
432
|
const rawConfig = readLegacyTaskConfigJson(projectRoot, configPath);
|
|
@@ -380,7 +434,7 @@ function readLegacyTaskRecords(projectRoot, configPath = resolve2(projectRoot, "
|
|
|
380
434
|
}
|
|
381
435
|
function readLegacyTaskConfigJson(projectRoot, configPath) {
|
|
382
436
|
try {
|
|
383
|
-
const parsed = JSON.parse(
|
|
437
|
+
const parsed = JSON.parse(readFileSync3(configPath, "utf8"));
|
|
384
438
|
if (isPlainRecord(parsed)) {
|
|
385
439
|
return parsed;
|
|
386
440
|
}
|
|
@@ -464,7 +518,7 @@ function isPlainRecord(candidate) {
|
|
|
464
518
|
var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
|
|
465
519
|
var FILE_TASK_PATTERN = /\.(task\.)?json$/;
|
|
466
520
|
function createSourceAwareTaskConfigRecordReader(projectRoot, options = {}) {
|
|
467
|
-
const configPath = options.configPath ??
|
|
521
|
+
const configPath = options.configPath ?? resolve4(projectRoot, ".rig", "task-config.json");
|
|
468
522
|
const legacy = createLegacyTaskConfigRecordReader(projectRoot, { configPath });
|
|
469
523
|
const spawnFn = options.spawn ?? spawnSync;
|
|
470
524
|
const ghBinary = options.ghBinary ?? "gh";
|
|
@@ -530,7 +584,7 @@ async function readSourceAwareTaskStatus(projectRoot, taskId, options = {}) {
|
|
|
530
584
|
}
|
|
531
585
|
}
|
|
532
586
|
function updateSourceAwareTaskConfigTask(projectRoot, taskId, update, options = {}) {
|
|
533
|
-
const configPath = options.configPath ??
|
|
587
|
+
const configPath = options.configPath ?? resolve4(projectRoot, ".rig", "task-config.json");
|
|
534
588
|
const rawEntry = readRawTaskEntry(configPath, taskId);
|
|
535
589
|
if (!rawEntry) {
|
|
536
590
|
const configuredFilesPath = readConfiguredFilesTaskSourcePath(projectRoot);
|
|
@@ -583,10 +637,10 @@ function readMaterializedTaskMetadata(entry) {
|
|
|
583
637
|
return metadata;
|
|
584
638
|
}
|
|
585
639
|
function readConfiguredFilesTaskSourcePath(projectRoot) {
|
|
586
|
-
const jsonPath =
|
|
587
|
-
if (
|
|
640
|
+
const jsonPath = resolve4(projectRoot, "rig.config.json");
|
|
641
|
+
if (existsSync5(jsonPath)) {
|
|
588
642
|
try {
|
|
589
|
-
const parsed = JSON.parse(
|
|
643
|
+
const parsed = JSON.parse(readFileSync4(jsonPath, "utf8"));
|
|
590
644
|
if (isPlainRecord2(parsed) && isPlainRecord2(parsed.taskSource)) {
|
|
591
645
|
const source = parsed.taskSource;
|
|
592
646
|
return source.kind === "files" && typeof source.path === "string" ? source.path : null;
|
|
@@ -595,12 +649,12 @@ function readConfiguredFilesTaskSourcePath(projectRoot) {
|
|
|
595
649
|
return null;
|
|
596
650
|
}
|
|
597
651
|
}
|
|
598
|
-
const tsPath =
|
|
599
|
-
if (!
|
|
652
|
+
const tsPath = resolve4(projectRoot, "rig.config.ts");
|
|
653
|
+
if (!existsSync5(tsPath)) {
|
|
600
654
|
return null;
|
|
601
655
|
}
|
|
602
656
|
try {
|
|
603
|
-
const source =
|
|
657
|
+
const source = readFileSync4(tsPath, "utf8");
|
|
604
658
|
const taskSourceBlock = source.match(/taskSource\s*:\s*\{[\s\S]*?\}/m)?.[0] ?? "";
|
|
605
659
|
const kind = taskSourceBlock.match(/kind\s*:\s*["']([^"']+)["']/)?.[1];
|
|
606
660
|
if (kind !== "files") {
|
|
@@ -620,10 +674,10 @@ function readRawTaskEntry(configPath, taskId) {
|
|
|
620
674
|
return isPlainRecord2(entry) ? entry : null;
|
|
621
675
|
}
|
|
622
676
|
function readRawTaskConfig(configPath) {
|
|
623
|
-
if (!
|
|
677
|
+
if (!existsSync5(configPath)) {
|
|
624
678
|
return null;
|
|
625
679
|
}
|
|
626
|
-
const parsed = JSON.parse(
|
|
680
|
+
const parsed = JSON.parse(readFileSync4(configPath, "utf8"));
|
|
627
681
|
return isPlainRecord2(parsed) ? parsed : null;
|
|
628
682
|
}
|
|
629
683
|
function stripLegacyTaskConfigMetadata2(raw) {
|
|
@@ -640,16 +694,16 @@ function writeLegacyTaskStatus(configPath, taskId, status) {
|
|
|
640
694
|
return;
|
|
641
695
|
}
|
|
642
696
|
entry.status = status;
|
|
643
|
-
|
|
697
|
+
writeFileSync3(configPath, `${JSON.stringify(rawConfig, null, 2)}
|
|
644
698
|
`, "utf8");
|
|
645
699
|
}
|
|
646
700
|
function updateFileBackedTask(projectRoot, sourcePath, taskId, update) {
|
|
647
|
-
const directory =
|
|
701
|
+
const directory = resolve4(projectRoot, sourcePath);
|
|
648
702
|
const file = findFileBackedTaskFile(directory, taskId);
|
|
649
703
|
if (!file) {
|
|
650
704
|
return false;
|
|
651
705
|
}
|
|
652
|
-
const raw = JSON.parse(
|
|
706
|
+
const raw = JSON.parse(readFileSync4(file, "utf8"));
|
|
653
707
|
if (!isPlainRecord2(raw)) {
|
|
654
708
|
return false;
|
|
655
709
|
}
|
|
@@ -666,17 +720,17 @@ function updateFileBackedTask(projectRoot, sourcePath, taskId, update) {
|
|
|
666
720
|
{ body: update.comment, createdAt: new Date().toISOString(), source: "rig" }
|
|
667
721
|
];
|
|
668
722
|
}
|
|
669
|
-
|
|
723
|
+
writeFileSync3(file, `${JSON.stringify(raw, null, 2)}
|
|
670
724
|
`, "utf8");
|
|
671
725
|
return true;
|
|
672
726
|
}
|
|
673
727
|
function listFileBackedTasks(projectRoot, sourcePath) {
|
|
674
|
-
const directory =
|
|
675
|
-
if (!
|
|
728
|
+
const directory = resolve4(projectRoot, sourcePath);
|
|
729
|
+
if (!existsSync5(directory)) {
|
|
676
730
|
return [];
|
|
677
731
|
}
|
|
678
732
|
const tasks = [];
|
|
679
|
-
for (const name of
|
|
733
|
+
for (const name of readdirSync2(directory)) {
|
|
680
734
|
if (!FILE_TASK_PATTERN.test(name))
|
|
681
735
|
continue;
|
|
682
736
|
const inferredId = basename(name).replace(FILE_TASK_PATTERN, "");
|
|
@@ -687,11 +741,11 @@ function listFileBackedTasks(projectRoot, sourcePath) {
|
|
|
687
741
|
return tasks;
|
|
688
742
|
}
|
|
689
743
|
function readFileBackedTask(projectRoot, sourcePath, taskId, rawEntry) {
|
|
690
|
-
const file = findFileBackedTaskFile(
|
|
744
|
+
const file = findFileBackedTaskFile(resolve4(projectRoot, sourcePath), taskId);
|
|
691
745
|
if (!file) {
|
|
692
746
|
return null;
|
|
693
747
|
}
|
|
694
|
-
const raw = JSON.parse(
|
|
748
|
+
const raw = JSON.parse(readFileSync4(file, "utf8"));
|
|
695
749
|
if (!isPlainRecord2(raw)) {
|
|
696
750
|
return null;
|
|
697
751
|
}
|
|
@@ -704,17 +758,17 @@ function readFileBackedTask(projectRoot, sourcePath, taskId, rawEntry) {
|
|
|
704
758
|
};
|
|
705
759
|
}
|
|
706
760
|
function findFileBackedTaskFile(directory, taskId) {
|
|
707
|
-
if (!
|
|
761
|
+
if (!existsSync5(directory)) {
|
|
708
762
|
return null;
|
|
709
763
|
}
|
|
710
|
-
for (const name of
|
|
764
|
+
for (const name of readdirSync2(directory)) {
|
|
711
765
|
if (!FILE_TASK_PATTERN.test(name))
|
|
712
766
|
continue;
|
|
713
767
|
const file = join2(directory, name);
|
|
714
768
|
try {
|
|
715
769
|
if (!statSync(file).isFile())
|
|
716
770
|
continue;
|
|
717
|
-
const raw = JSON.parse(
|
|
771
|
+
const raw = JSON.parse(readFileSync4(file, "utf8"));
|
|
718
772
|
const inferredId = basename(file).replace(FILE_TASK_PATTERN, "");
|
|
719
773
|
const id = isPlainRecord2(raw) && typeof raw.id === "string" ? raw.id : inferredId;
|
|
720
774
|
if (id === taskId) {
|
|
@@ -884,8 +938,8 @@ function ensureStatusLabel(bin, repo, spawnFn, label) {
|
|
|
884
938
|
}
|
|
885
939
|
}
|
|
886
940
|
function selectedGitHubEnv() {
|
|
887
|
-
const token = process.env.RIG_GITHUB_SELECTED_TOKEN?.trim()
|
|
888
|
-
return { GH_TOKEN: token, GITHUB_TOKEN: token };
|
|
941
|
+
const token = process.env.RIG_GITHUB_SELECTED_TOKEN?.trim() || process.env.RIG_GITHUB_TOKEN?.trim() || "";
|
|
942
|
+
return { GH_TOKEN: token, GITHUB_TOKEN: token, RIG_GITHUB_TOKEN: token };
|
|
889
943
|
}
|
|
890
944
|
function ghSpawnOptions() {
|
|
891
945
|
return { encoding: "utf-8", env: { ...process.env, ...selectedGitHubEnv() } };
|