@themoltnet/pi-extension 0.19.0 → 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 [
@@ -11102,6 +11103,29 @@ function buildRenderPackUserPrompt(input, ctx) {
11102
11103
  "- Do NOT write diary entries unless a genuine incident occurs",
11103
11104
  " (rendering failure, invariant violation).",
11104
11105
  "",
11106
+ "## Fidelity Discipline",
11107
+ "",
11108
+ "These rules apply when you are producing the markdown yourself rather",
11109
+ "than relying on a deterministic `server:*` renderer.",
11110
+ "",
11111
+ "1. Preserve hedges and qualifiers verbatim.",
11112
+ " Source phrases like \"typically\", \"roughly\", \"about half\",",
11113
+ " \"in this codebase\", \"for this speaker\", and \"on most slides\"",
11114
+ " are load-bearing. Keep them. Do not turn a partial observation",
11115
+ " into a universal claim by stripping the hedge.",
11116
+ "2. Signal list truncation explicitly.",
11117
+ " If a source entry enumerates examples and you shorten the list,",
11118
+ " say so with markers like `e.g.`, `among others`, or",
11119
+ " `[truncated - see source for full list]`. Do not silently drop",
11120
+ " items from an enumeration in a way that looks lossless.",
11121
+ "3. Calibrate against fidelity scoring.",
11122
+ " A paraphrased rendered pack will be audited claim-by-claim for",
11123
+ " drift on quotes, numbers, file paths, hedges, polarity, and list",
11124
+ " completeness. Optimize for \"no detectable drift across a",
11125
+ " claim-by-claim audit\", not \"shorter at any cost\". When compressing, prefer",
11126
+ " tightening prose around a quote rather than altering the quote,",
11127
+ " and prefer summarising a list over silently truncating it.",
11128
+ "",
11105
11129
  buildSelfVerificationBlock(ctx.taskId),
11106
11130
  buildFinalOutputBlock({
11107
11131
  taskType: "render_pack",
@@ -13280,7 +13304,7 @@ var require_transport = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13280
13304
  var { createRequire: createRequire$1 } = __require("module");
13281
13305
  var { existsSync: existsSync$1 } = __require("node:fs");
13282
13306
  var getCallers = require_caller();
13283
- var { join: join$1, isAbsolute, sep } = __require("node:path");
13307
+ var { join: join$1, isAbsolute, sep: sep$1 } = __require("node:path");
13284
13308
  var { fileURLToPath } = __require("node:url");
13285
13309
  var sleep = require_atomic_sleep();
13286
13310
  var onExit = require_on_exit_leak_free();
@@ -13448,7 +13472,7 @@ var require_transport = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13448
13472
  if (origin === "pino/file") return join$1(__dirname, "..", "file.js");
13449
13473
  let fixTarget;
13450
13474
  for (const filePath of callers) try {
13451
- 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);
13452
13476
  break;
13453
13477
  } catch (err) {
13454
13478
  continue;
@@ -15446,6 +15470,8 @@ function prepareTaskWorkspace(task, requestedMountPath, executionPlan) {
15446
15470
  });
15447
15471
  mkdirSync(scratchDir, { recursive: true });
15448
15472
  }
15473
+ const workspaceSeed = executionPlan?.workspaceSeed ?? null;
15474
+ if (workspaceSeed) copyDirectoryContents(workspaceSeed.copyFromPath, scratchDir);
15449
15475
  return {
15450
15476
  mountPath: scratchDir,
15451
15477
  cwdPath: scratchDir,
@@ -15567,6 +15593,68 @@ function gitRefExists(mainRepo, ref) {
15567
15593
  return false;
15568
15594
  }
15569
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
+ }
15570
15658
  //#endregion
15571
15659
  //#region src/runtime/execute-pi-task.ts
15572
15660
  /**
@@ -15772,7 +15860,8 @@ async function executePiTask(claimedTask, reporter, opts) {
15772
15860
  workspace: {
15773
15861
  mode: activeWorkspace.mode,
15774
15862
  branch: activeWorkspace.branch,
15775
- 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
15776
15865
  },
15777
15866
  extras: opts.promptExtras
15778
15867
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/pi-extension",
3
- "version": "0.19.0",
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",
@@ -31,8 +31,8 @@
31
31
  "@earendil-works/gondolin": "^0.9.1",
32
32
  "@opentelemetry/api": "^1.9.0",
33
33
  "@sinclair/typebox": "^0.34.0",
34
- "@themoltnet/agent-runtime": "0.17.0",
35
- "@themoltnet/sdk": "0.103.0"
34
+ "@themoltnet/sdk": "0.103.0",
35
+ "@themoltnet/agent-runtime": "0.18.1"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@earendil-works/pi-coding-agent": ">=0.74.0",