@themoltnet/pi-extension 0.19.1 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -507,6 +507,10 @@ export declare interface PiTaskExecutionPlan {
507
507
  * inspection by applying VFS shadowing on top of the mounted path.
508
508
  */
509
509
  workspaceAttachment?: PiWorkspaceAttachmentPlan | null;
510
+ /**
511
+ * Optional seed content for a freshly created scratch workspace.
512
+ */
513
+ workspaceSeed?: PiWorkspaceSeedPlan | null;
510
514
  /**
511
515
  * Optional location for file-backed Pi session history. When omitted,
512
516
  * the executor keeps the conversation in memory for this attempt only.
@@ -522,6 +526,11 @@ declare interface PiWorkspaceAttachmentPlan {
522
526
  shadowWrites?: 'deny' | 'tmpfs';
523
527
  }
524
528
 
529
+ declare interface PiWorkspaceSeedPlan {
530
+ copyFromPath: string;
531
+ source: 'producer';
532
+ }
533
+
525
534
  export declare function resolveTaskWorktreePath(mainRepo: string, workspaceId: string): string;
526
535
 
527
536
  export declare interface ResumeCommand {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { execFileSync } from "node:child_process";
3
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
4
- import path, { join, relative } from "node:path";
3
+ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync } from "node:fs";
4
+ import path, { join, relative, sep } from "node:path";
5
5
  import { DefaultResourceLoader, SessionManager, createAgentSession, createBashTool, createBashToolDefinition, createEditTool, createEditToolDefinition, createReadTool, createReadToolDefinition, createSyntheticSourceInfo, createWriteTool, createWriteToolDefinition, defineTool, parseFrontmatter } from "@earendil-works/pi-coding-agent";
6
6
  import { createHash } from "node:crypto";
7
7
  import { readFile } from "node:fs/promises";
@@ -9632,7 +9632,8 @@ var PrReviewSubject = Type$1.Object({
9632
9632
  var PrReviewInput = Type$1.Object({
9633
9633
  subject: PrReviewSubject,
9634
9634
  taskPrompt: Type$1.Optional(Type$1.String({ minLength: 1 })),
9635
- successCriteria: SuccessCriteria
9635
+ successCriteria: SuccessCriteria,
9636
+ context: Type$1.Optional(TaskContext)
9636
9637
  }, {
9637
9638
  $id: "PrReviewInput",
9638
9639
  additionalProperties: false
@@ -10794,7 +10795,7 @@ function buildJudgeEvalAttemptUserPrompt(input, ctx) {
10794
10795
  "If the accepted attempt output lists `artifacts[].path`, treat those",
10795
10796
  "paths as relative to the current workspace root unless the output",
10796
10797
  "explicitly says otherwise.",
10797
- ctx.workspace.mode === "dedicated_worktree" ? `This attachment is a dedicated producer worktree${ctx.workspace.branch ? ` on branch \`${ctx.workspace.branch}\`` : ""}.` : ctx.workspace.mode === "scratch_mount" ? "This attachment is the producer scratch workspace mounted with shadow writes for safe inspection." : "This attachment is the producer shared workspace mounted with shadow writes for safe inspection.",
10798
+ ctx.workspace.mode === "dedicated_worktree" ? `This attachment is a dedicated producer worktree${ctx.workspace.branch ? ` on branch \`${ctx.workspace.branch}\`` : ""}.` : ctx.workspace.mode === "scratch_mount" ? "This workspace is a fresh judge-owned scratch copy of the producer workspace." : "This attachment is the producer shared workspace mounted with shadow writes for safe inspection.",
10798
10799
  ""
10799
10800
  ].join("\n") : "";
10800
10801
  return [
@@ -13303,7 +13304,7 @@ var require_transport = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13303
13304
  var { createRequire: createRequire$1 } = __require("module");
13304
13305
  var { existsSync: existsSync$1 } = __require("node:fs");
13305
13306
  var getCallers = require_caller();
13306
- var { join: join$1, isAbsolute, sep } = __require("node:path");
13307
+ var { join: join$1, isAbsolute, sep: sep$1 } = __require("node:path");
13307
13308
  var { fileURLToPath } = __require("node:url");
13308
13309
  var sleep = require_atomic_sleep();
13309
13310
  var onExit = require_on_exit_leak_free();
@@ -13471,7 +13472,7 @@ var require_transport = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13471
13472
  if (origin === "pino/file") return join$1(__dirname, "..", "file.js");
13472
13473
  let fixTarget;
13473
13474
  for (const filePath of callers) try {
13474
- fixTarget = createRequire$1(filePath === "node:repl" ? process.cwd() + sep : filePath).resolve(origin);
13475
+ fixTarget = createRequire$1(filePath === "node:repl" ? process.cwd() + sep$1 : filePath).resolve(origin);
13475
13476
  break;
13476
13477
  } catch (err) {
13477
13478
  continue;
@@ -15469,6 +15470,8 @@ function prepareTaskWorkspace(task, requestedMountPath, executionPlan) {
15469
15470
  });
15470
15471
  mkdirSync(scratchDir, { recursive: true });
15471
15472
  }
15473
+ const workspaceSeed = executionPlan?.workspaceSeed ?? null;
15474
+ if (workspaceSeed) copyDirectoryContents(workspaceSeed.copyFromPath, scratchDir);
15472
15475
  return {
15473
15476
  mountPath: scratchDir,
15474
15477
  cwdPath: scratchDir,
@@ -15590,6 +15593,68 @@ function gitRefExists(mainRepo, ref) {
15590
15593
  return false;
15591
15594
  }
15592
15595
  }
15596
+ function copyDirectoryContents(sourceDir, targetDir) {
15597
+ if (!existsSync(sourceDir)) throw new Error(`Workspace seed source is missing: ${sourceDir}`);
15598
+ if (existsSync(join(sourceDir, ".git"))) initializeScratchGitRepo(sourceDir, targetDir);
15599
+ const resolvedTargetDir = realpathSync(targetDir);
15600
+ for (const entry of readdirSync(sourceDir)) {
15601
+ const sourceEntry = join(sourceDir, entry);
15602
+ if (shouldSkipSeedEntry(sourceEntry, entry, resolvedTargetDir)) continue;
15603
+ cpSync(sourceEntry, join(targetDir, entry), { recursive: true });
15604
+ }
15605
+ }
15606
+ function initializeScratchGitRepo(sourceDir, targetDir) {
15607
+ execFileSync("git", [
15608
+ "-C",
15609
+ targetDir,
15610
+ "init"
15611
+ ], { stdio: "pipe" });
15612
+ let headCommit = null;
15613
+ try {
15614
+ headCommit = execFileSync("git", [
15615
+ "-C",
15616
+ sourceDir,
15617
+ "rev-parse",
15618
+ "HEAD"
15619
+ ], {
15620
+ encoding: "utf8",
15621
+ stdio: "pipe"
15622
+ }).trim();
15623
+ } catch {
15624
+ headCommit = null;
15625
+ }
15626
+ if (!headCommit) return;
15627
+ execFileSync("git", [
15628
+ "-C",
15629
+ targetDir,
15630
+ "remote",
15631
+ "add",
15632
+ "origin",
15633
+ sourceDir
15634
+ ], { stdio: "pipe" });
15635
+ execFileSync("git", [
15636
+ "-C",
15637
+ targetDir,
15638
+ "fetch",
15639
+ "--quiet",
15640
+ "--depth=1",
15641
+ "origin",
15642
+ headCommit
15643
+ ], { stdio: "pipe" });
15644
+ execFileSync("git", [
15645
+ "-C",
15646
+ targetDir,
15647
+ "checkout",
15648
+ "--quiet",
15649
+ "--detach",
15650
+ "FETCH_HEAD"
15651
+ ], { stdio: "pipe" });
15652
+ }
15653
+ function shouldSkipSeedEntry(sourceEntry, entryName, resolvedTargetDir) {
15654
+ if (entryName === ".git") return true;
15655
+ const resolvedSourceEntry = realpathSync(sourceEntry);
15656
+ return resolvedTargetDir === resolvedSourceEntry || resolvedTargetDir.startsWith(`${resolvedSourceEntry}${sep}`);
15657
+ }
15593
15658
  //#endregion
15594
15659
  //#region src/runtime/execute-pi-task.ts
15595
15660
  /**
@@ -15795,7 +15860,8 @@ async function executePiTask(claimedTask, reporter, opts) {
15795
15860
  workspace: {
15796
15861
  mode: activeWorkspace.mode,
15797
15862
  branch: activeWorkspace.branch,
15798
- attached: executionPlan?.workspaceAttachment !== void 0
15863
+ attached: executionPlan?.workspaceAttachment !== void 0 || executionPlan?.workspaceSeed?.source === "producer",
15864
+ source: executionPlan?.workspaceSeed?.source === "producer" ? "producer_copy" : executionPlan?.workspaceAttachment !== void 0 ? "producer_attachment" : void 0
15799
15865
  },
15800
15866
  extras: opts.promptExtras
15801
15867
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/pi-extension",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "type": "module",
5
5
  "description": "MoltNet pi extension — sandboxed tool execution in Gondolin VMs with MoltNet identity and persistent memory",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "@opentelemetry/api": "^1.9.0",
33
33
  "@sinclair/typebox": "^0.34.0",
34
34
  "@themoltnet/sdk": "0.103.0",
35
- "@themoltnet/agent-runtime": "0.18.0"
35
+ "@themoltnet/agent-runtime": "0.18.1"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@earendil-works/pi-coding-agent": ">=0.74.0",