@h-rig/runtime 0.0.6-alpha.28 → 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
@@ -300,6 +300,50 @@ function safeReadJson(path) {
300
300
  var MARKER_PLUGIN = "_rigPlugin", MARKER_HOOK_ID = "_rigHookId";
301
301
  var init_hook_materializer = () => {};
302
302
 
303
+ // packages/runtime/src/control-plane/skill-materializer.ts
304
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
305
+ import { resolve as resolve2 } from "path";
306
+ import { loadSkill } from "@rig/skill-loader";
307
+ function skillDirName(id) {
308
+ return id.replace(/[^a-zA-Z0-9._-]+/g, "-");
309
+ }
310
+ async function materializeSkills(projectRoot, entries) {
311
+ const skillsRoot = resolve2(projectRoot, ".pi", "skills");
312
+ if (existsSync3(skillsRoot)) {
313
+ for (const name of readdirSync(skillsRoot)) {
314
+ const dir = resolve2(skillsRoot, name);
315
+ if (existsSync3(resolve2(dir, MARKER_FILENAME))) {
316
+ rmSync(dir, { recursive: true, force: true });
317
+ }
318
+ }
319
+ }
320
+ const written = [];
321
+ for (const { pluginName, skill } of entries) {
322
+ const sourcePath = resolve2(projectRoot, skill.path);
323
+ if (!existsSync3(sourcePath)) {
324
+ console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${sourcePath} does not exist`);
325
+ continue;
326
+ }
327
+ let body;
328
+ try {
329
+ await loadSkill(sourcePath);
330
+ body = readFileSync2(sourcePath, "utf-8");
331
+ } catch (err) {
332
+ console.warn(`[plugin-host] skill "${skill.id}" from plugin "${pluginName}" not materialized: ${err instanceof Error ? err.message : err}`);
333
+ continue;
334
+ }
335
+ const dir = resolve2(skillsRoot, skillDirName(skill.id));
336
+ mkdirSync2(dir, { recursive: true });
337
+ writeFileSync2(resolve2(dir, "SKILL.md"), body, "utf-8");
338
+ writeFileSync2(resolve2(dir, MARKER_FILENAME), `${JSON.stringify({ plugin: pluginName, skillId: skill.id }, null, 2)}
339
+ `, "utf-8");
340
+ written.push({ id: skill.id, pluginName, directory: dir });
341
+ }
342
+ return written;
343
+ }
344
+ var MARKER_FILENAME = ".rig-plugin";
345
+ var init_skill_materializer = () => {};
346
+
303
347
  // packages/runtime/src/control-plane/plugin-host-context.ts
304
348
  var exports_plugin_host_context = {};
305
349
  __export(exports_plugin_host_context, {
@@ -342,6 +386,17 @@ async function buildPluginHostContext(projectRoot) {
342
386
  } catch (err) {
343
387
  console.warn(`[plugin-host] hook materialization failed: ${err instanceof Error ? err.message : err}`);
344
388
  }
389
+ try {
390
+ const skillEntries = config.plugins.flatMap((plugin) => (plugin.contributes?.skills ?? []).map((skill) => ({
391
+ pluginName: plugin.name,
392
+ skill
393
+ })));
394
+ if (skillEntries.length > 0) {
395
+ await materializeSkills(projectRoot, skillEntries);
396
+ }
397
+ } catch (err) {
398
+ console.warn(`[plugin-host] skill materialization failed: ${err instanceof Error ? err.message : err}`);
399
+ }
345
400
  return {
346
401
  config,
347
402
  pluginHost,
@@ -357,13 +412,14 @@ var init_plugin_host_context = __esm(() => {
357
412
  init_registry();
358
413
  init_runtime_registration();
359
414
  init_hook_materializer();
415
+ init_skill_materializer();
360
416
  });
361
417
 
362
418
  // packages/runtime/src/control-plane/materialize-task-config.ts
363
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
364
- import { dirname as dirname2, resolve as resolve2 } from "path";
419
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
420
+ import { dirname as dirname2, resolve as resolve3 } from "path";
365
421
  async function materializePluginHostTaskConfig(projectRoot) {
366
- const hasConfig = existsSync3(resolve2(projectRoot, "rig.config.ts")) || existsSync3(resolve2(projectRoot, "rig.config.json"));
422
+ const hasConfig = existsSync4(resolve3(projectRoot, "rig.config.ts")) || existsSync4(resolve3(projectRoot, "rig.config.json"));
367
423
  if (!hasConfig)
368
424
  return null;
369
425
  const { buildPluginHostContext: buildPluginHostContext2 } = await Promise.resolve().then(() => (init_plugin_host_context(), exports_plugin_host_context));
@@ -383,8 +439,8 @@ async function materializePluginHostTaskConfig(projectRoot) {
383
439
  const tasks = await source.list();
384
440
  if (tasks.length === 0)
385
441
  return null;
386
- const configPath = resolve2(projectRoot, ".rig", "task-config.json");
387
- const existing = existsSync3(configPath) ? safeJsonRead(configPath) : {};
442
+ const configPath = resolve3(projectRoot, ".rig", "task-config.json");
443
+ const existing = existsSync4(configPath) ? safeJsonRead(configPath) : {};
388
444
  const merged = { ...existing };
389
445
  let syncedCount = 0;
390
446
  for (const task of tasks) {
@@ -400,8 +456,8 @@ async function materializePluginHostTaskConfig(projectRoot) {
400
456
  merged[id] = synthesizeEntry(t, ctx.config.taskSource);
401
457
  syncedCount += 1;
402
458
  }
403
- mkdirSync2(dirname2(configPath), { recursive: true });
404
- writeFileSync2(configPath, `${JSON.stringify(merged, null, 2)}
459
+ mkdirSync3(dirname2(configPath), { recursive: true });
460
+ writeFileSync3(configPath, `${JSON.stringify(merged, null, 2)}
405
461
  `, "utf-8");
406
462
  return { configPath, syncedCount };
407
463
  }
@@ -442,7 +498,7 @@ function materializedTaskSource(taskSource) {
442
498
  }
443
499
  function safeJsonRead(path) {
444
500
  try {
445
- const parsed = JSON.parse(readFileSync2(path, "utf-8"));
501
+ const parsed = JSON.parse(readFileSync3(path, "utf-8"));
446
502
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
447
503
  } catch {
448
504
  return {};
@@ -311,6 +311,9 @@ function getScopeRules() {
311
311
  return activeRules;
312
312
  }
313
313
 
314
+ // packages/runtime/src/control-plane/skill-materializer.ts
315
+ import { loadSkill } from "@rig/skill-loader";
316
+
314
317
  // packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
315
318
  var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
316
319