pi-fabric 0.76.0 → 0.76.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"system-guidance.d.ts","sourceRoot":"","sources":["../../src/core/system-guidance.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,GAAI,cAAc,OAAO,KAAG,MASzD,CAAC;AAEd,eAAO,MAAM,8BAA8B,GAAI,cAAc,OAAO,KAAG,MAGoQ,CAAC;AAG5U,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAQD,eAAO,MAAM,2BAA2B,GACtC,OAAO,aAAa,CAAC,yBAAyB,CAAC,EAC/C,eAAe,WAAW,CAAC,MAAM,CAAC,KACjC,MAAM,GAAG,SAyBX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,KAAK,GAAG,OAAO,GAAG,SAAS,KAAG,MAAM,GAAG,SAQjF,CAAC"}
1
+ {"version":3,"file":"system-guidance.d.ts","sourceRoot":"","sources":["../../src/core/system-guidance.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,6BAA6B,GAAI,cAAc,OAAO,KAAG,MASzD,CAAC;AAEd,eAAO,MAAM,8BAA8B,GAAI,cAAc,OAAO,KAAG,MAGoQ,CAAC;AAG5U,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAqCD,eAAO,MAAM,2BAA2B,GACtC,OAAO,aAAa,CAAC,yBAAyB,CAAC,EAC/C,eAAe,WAAW,CAAC,MAAM,CAAC,KACjC,MAAM,GAAG,SA8BX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,KAAK,GAAG,OAAO,GAAG,SAAS,KAAG,MAAM,GAAG,SAQjF,CAAC"}
package/dist/index.js CHANGED
@@ -1603,6 +1603,8 @@ ${sections.join("\n")}` : "";
1603
1603
  };
1604
1604
 
1605
1605
  // src/core/system-guidance.ts
1606
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
1607
+ import * as path4 from "node:path";
1606
1608
  var fabricExecutionKernelGuidance = (fullCodeMode) => [
1607
1609
  fullCodeMode ? "Pi Fabric full code mode: `fabric_exec` is the only way to call Pi core tools \u2014 use them as `pi.*` inside `code`." : "Pi Fabric is in orchestration-only mode. Pi core and registered extension tools stay on their native direct execution path; inside fabric_exec, `pi.*` and `extensions.*` are unavailable.",
1608
1610
  // Files the model has not opened (images in particular) must be read before
@@ -1611,13 +1613,38 @@ var fabricExecutionKernelGuidance = (fullCodeMode) => [
1611
1613
  `Read every file the user provides (images, screenshots, code, text) with the ${fullCodeMode ? "`pi.read`" : "`read`"} tool before responding \u2014 never assume its contents.`
1612
1614
  ].join(" ");
1613
1615
  var defaultFabricExecutionGuidance = (fullCodeMode) => fullCodeMode ? "Examples and returns: `pi.read('/x')`, `pi.grep('TODO','src')` / `pi.grep({pattern:'TODO', path:'src', ignoreCase:true, context:2})`, `pi.find({pattern:'*.ts', path:'src', limit:20})`, and `pi.ls('src')` return strings; `pi.bash({cmd:'ls'})`, `pi.edit({path:'/x', old:'a', new:'b'})`, and `pi.write({path:'/y', text:'z'})` return `{ok, output, details}` (read `.output`); failed core calls reject, including `bash` on an ordinary nonzero exit; pass `settle: true` to `pi.bash` to get `{ ok: false, exitCode, output, error }` instead. Timeout, cancellation, approval, and security failures still reject.\n`tools` is discovery + generic calls only (`providers`/`catalog`/`list`/`search`/`describe`/`call`/`models`). Call known MCP tools as `mcp.<sanitized_server>.<sanitized_tool>(args)`, captured tools as `extensions.<tool>(args)`, and stable providers as `memory.*`, `state.*`, `schema.*`, or `compact.*`. Use `tools.call({ref,args})` for computed refs. `pi` is the core tools; `\u03C0.<key>` reads named `strings` (not a tool)." : "Call known actions through `mcp.<sanitized_server>.<sanitized_tool>(args)`, `memory.*`, `state.*`, `schema.*`, `components.*`, `compact.*`, `agents.*`, or `mesh.*`; use `tools.catalog`/`search`/`describe`/`list` for discovery and `tools.call({ref,args})` for computed refs. Other surfaces are opt-in via user-loaded skills.";
1616
+ var manifestNameCache = /* @__PURE__ */ new Map();
1617
+ var packageNameFromManifest = (startPath) => {
1618
+ if (!startPath) return void 0;
1619
+ let directory = path4.dirname(path4.resolve(startPath));
1620
+ while (true) {
1621
+ if (manifestNameCache.has(directory)) return manifestNameCache.get(directory);
1622
+ const manifestPath = path4.join(directory, "package.json");
1623
+ let name;
1624
+ if (existsSync2(manifestPath)) {
1625
+ try {
1626
+ const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
1627
+ if (typeof manifest.name === "string" && manifest.name.trim()) name = manifest.name.trim();
1628
+ } catch {
1629
+ }
1630
+ }
1631
+ manifestNameCache.set(directory, name);
1632
+ if (name) return name;
1633
+ const parent = path4.dirname(directory);
1634
+ if (parent === directory) return void 0;
1635
+ directory = parent;
1636
+ }
1637
+ };
1614
1638
  var extensionToolRosterGuidance = (tools, coreToolNames) => {
1615
1639
  const extensionTools = tools.filter((tool) => !coreToolNames.has(tool.name));
1616
1640
  if (extensionTools.length === 0) return void 0;
1617
1641
  const namespaceLabel = (tool) => {
1618
1642
  const source = tool.sourceInfo?.source?.trim();
1619
- if (source) return source;
1620
- const parts = (tool.sourceInfo?.path ?? "").split(/[\\/]/).filter(Boolean);
1643
+ if (source?.startsWith("npm:")) return source.slice("npm:".length) || source;
1644
+ const manifestName = packageNameFromManifest(tool.sourceInfo?.path) ?? packageNameFromManifest(source && /[\\/]/.test(source) ? source : void 0);
1645
+ if (manifestName) return manifestName;
1646
+ if (source && !/[\\/]/.test(source)) return source;
1647
+ const parts = (tool.sourceInfo?.path ?? source ?? "").split(/[\\/]/).filter(Boolean);
1621
1648
  const base = parts.at(-1)?.trim() ?? "";
1622
1649
  if (/^index\./i.test(base)) return parts.at(-2)?.trim() || base;
1623
1650
  return base || "extensions";
@@ -1851,8 +1878,8 @@ var formatFailureProgress = (trace) => {
1851
1878
  );
1852
1879
  if (completed.length === 0) return void 0;
1853
1880
  const summaries = completed.slice(0, MAX_COMPLETED_CALLS).map((operation) => {
1854
- const path9 = operation.args.path;
1855
- return typeof path9 === "string" ? `${operation.ref}(${compactPath(path9)})` : operation.ref;
1881
+ const path10 = operation.args.path;
1882
+ return typeof path10 === "string" ? `${operation.ref}(${compactPath(path10)})` : operation.ref;
1856
1883
  });
1857
1884
  const omitted = completed.length - summaries.length;
1858
1885
  return [
@@ -2175,12 +2202,12 @@ var PartialResultObserver = class {
2175
2202
  // src/output-budget.ts
2176
2203
  import { mkdtemp, writeFile } from "node:fs/promises";
2177
2204
  import { tmpdir } from "node:os";
2178
- import path4 from "node:path";
2205
+ import path5 from "node:path";
2179
2206
  var MAX_FAILURE_MODEL_OUTPUT_CHARS = 2e4;
2180
2207
  var modelOutputBudget = (configuredMaxChars, success) => success ? configuredMaxChars : Math.min(configuredMaxChars, MAX_FAILURE_MODEL_OUTPUT_CHARS);
2181
2208
  var writeOutputArtifact = async (content) => {
2182
- const directory = await mkdtemp(path4.join(tmpdir(), "pi-fabric-output-"));
2183
- const artifactPath = path4.join(directory, "output.txt");
2209
+ const directory = await mkdtemp(path5.join(tmpdir(), "pi-fabric-output-"));
2210
+ const artifactPath = path5.join(directory, "output.txt");
2184
2211
  await writeFile(artifactPath, content, { encoding: "utf8", mode: 384 });
2185
2212
  return artifactPath;
2186
2213
  };
@@ -2923,7 +2950,7 @@ ${recoveryHint}` : ""}`,
2923
2950
 
2924
2951
  // src/fabric-state.ts
2925
2952
  import fs2 from "node:fs";
2926
- import path5 from "node:path";
2953
+ import path6 from "node:path";
2927
2954
  var FabricState = class {
2928
2955
  constructor(pi, capturedTools, options = {}) {
2929
2956
  this.pi = pi;
@@ -3059,10 +3086,10 @@ var FabricState = class {
3059
3086
  const sessionId = context.sessionManager.getSessionId();
3060
3087
  if (resolveFabricIdentity(sessionId).identity.kind !== "main") return false;
3061
3088
  const projectRoot = process.env.PI_FABRIC_PROJECT_ROOT ?? context.cwd;
3062
- const meshRoot = process.env.PI_FABRIC_MESH_ROOT ?? (this.config.mesh.root ? path5.resolve(projectRoot, this.config.mesh.root) : path5.join(projectRoot, ".pi", "fabric", "mesh"));
3063
- const actorRoot = this.config.mesh.actorScope === "session" ? path5.join(meshRoot, "actors", sessionId) : path5.join(meshRoot, "actors");
3089
+ const meshRoot = process.env.PI_FABRIC_MESH_ROOT ?? (this.config.mesh.root ? path6.resolve(projectRoot, this.config.mesh.root) : path6.join(projectRoot, ".pi", "fabric", "mesh"));
3090
+ const actorRoot = this.config.mesh.actorScope === "session" ? path6.join(meshRoot, "actors", sessionId) : path6.join(meshRoot, "actors");
3064
3091
  try {
3065
- const registry = JSON.parse(fs2.readFileSync(path5.join(actorRoot, "actors.json"), "utf8"));
3092
+ const registry = JSON.parse(fs2.readFileSync(path6.join(actorRoot, "actors.json"), "utf8"));
3066
3093
  if (typeof registry !== "object" || registry === null || Array.isArray(registry)) return false;
3067
3094
  const actors = registry.actors;
3068
3095
  return Array.isArray(actors) && actors.some((value) => {
@@ -3291,8 +3318,8 @@ var FabricState = class {
3291
3318
  };
3292
3319
 
3293
3320
  // src/host-compatibility.ts
3294
- import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
3295
- import path6 from "node:path";
3321
+ import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
3322
+ import path7 from "node:path";
3296
3323
  var MINIMUM_PI_HOST_VERSION = "0.80.6";
3297
3324
  var PI_HOST_PACKAGE_NAMES = /* @__PURE__ */ new Set([
3298
3325
  "@earendil-works/pi-coding-agent",
@@ -3323,22 +3350,22 @@ var detectPiHostVersion = (cliPath = process.argv[1]) => {
3323
3350
  if (!cliPath) return void 0;
3324
3351
  let directory;
3325
3352
  try {
3326
- directory = path6.dirname(realpathSync2(cliPath));
3353
+ directory = path7.dirname(realpathSync2(cliPath));
3327
3354
  } catch {
3328
3355
  return void 0;
3329
3356
  }
3330
3357
  while (true) {
3331
- const manifestPath = path6.join(directory, "package.json");
3332
- if (existsSync2(manifestPath)) {
3358
+ const manifestPath = path7.join(directory, "package.json");
3359
+ if (existsSync3(manifestPath)) {
3333
3360
  try {
3334
- const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
3361
+ const manifest = JSON.parse(readFileSync3(manifestPath, "utf8"));
3335
3362
  if (typeof manifest.name === "string" && PI_HOST_PACKAGE_NAMES.has(manifest.name) && typeof manifest.version === "string") {
3336
3363
  return manifest.version;
3337
3364
  }
3338
3365
  } catch {
3339
3366
  }
3340
3367
  }
3341
- const parent = path6.dirname(directory);
3368
+ const parent = path7.dirname(directory);
3342
3369
  if (parent === directory) return void 0;
3343
3370
  directory = parent;
3344
3371
  }
@@ -3351,7 +3378,7 @@ var piHostCompatibilityWarning = (version = detectPiHostVersion()) => {
3351
3378
  };
3352
3379
 
3353
3380
  // src/ui/controller.ts
3354
- import path7 from "node:path";
3381
+ import path8 from "node:path";
3355
3382
 
3356
3383
  // src/ui/snapshot.ts
3357
3384
  var MAX_UI_AGENTS = 240;
@@ -4063,7 +4090,7 @@ var FabricUiController = class {
4063
4090
  logFile: actor.worker.logFile
4064
4091
  };
4065
4092
  }
4066
- const retained = actor.lastRunId && actor.logDir ? path7.join(actor.logDir, actor.lastRunId, "events.jsonl") : void 0;
4093
+ const retained = actor.lastRunId && actor.logDir ? path8.join(actor.logDir, actor.lastRunId, "events.jsonl") : void 0;
4067
4094
  if (retained) return { id: actor.id, status: actor.status, logFile: retained };
4068
4095
  if (actor.sessionFile) {
4069
4096
  return { id: actor.id, status: actor.status, logFile: actor.sessionFile };
@@ -4182,16 +4209,16 @@ var FabricToolDisplayController = class {
4182
4209
  var REFRESH_CARDS_PER_TICK = 3;
4183
4210
 
4184
4211
  // src/index.ts
4185
- import { existsSync as existsSync3 } from "node:fs";
4186
- import path8 from "node:path";
4212
+ import { existsSync as existsSync4 } from "node:fs";
4213
+ import path9 from "node:path";
4187
4214
  import { fileURLToPath } from "node:url";
4188
- var FABRIC_EXTENSION_ENTRY_PATH = path8.resolve(fileURLToPath(import.meta.url));
4189
- var FABRIC_ENTRY_DIR = path8.dirname(FABRIC_EXTENSION_ENTRY_PATH);
4215
+ var FABRIC_EXTENSION_ENTRY_PATH = path9.resolve(fileURLToPath(import.meta.url));
4216
+ var FABRIC_ENTRY_DIR = path9.dirname(FABRIC_EXTENSION_ENTRY_PATH);
4190
4217
  var FABRIC_RUNTIME_PATHS = {
4191
4218
  extension: FABRIC_EXTENSION_ENTRY_PATH,
4192
- worker: path8.join(FABRIC_ENTRY_DIR, "worker.js"),
4193
- residentHost: path8.join(FABRIC_ENTRY_DIR, "residency", "launcher.js"),
4194
- skills: path8.resolve(FABRIC_ENTRY_DIR, "..", "skills")
4219
+ worker: path9.join(FABRIC_ENTRY_DIR, "worker.js"),
4220
+ residentHost: path9.join(FABRIC_ENTRY_DIR, "residency", "launcher.js"),
4221
+ skills: path9.resolve(FABRIC_ENTRY_DIR, "..", "skills")
4195
4222
  };
4196
4223
  var FABRIC_SKILLS_DIR = FABRIC_RUNTIME_PATHS.skills;
4197
4224
  var componentRegistrationFrom = (value) => {
@@ -4273,7 +4300,7 @@ async function piFabric(pi) {
4273
4300
  }
4274
4301
  );
4275
4302
  pi.on("resources_discover", async () => {
4276
- if (existsSync3(FABRIC_SKILLS_DIR)) return { skillPaths: [FABRIC_SKILLS_DIR] };
4303
+ if (existsSync4(FABRIC_SKILLS_DIR)) return { skillPaths: [FABRIC_SKILLS_DIR] };
4277
4304
  return {};
4278
4305
  });
4279
4306
  const fabricTool = createFabricExecTool(