pi-fabric 0.86.0 → 0.87.0

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 (35) hide show
  1. package/README.md +2 -2
  2. package/dist/chunks/{chunk-PPIWZJ4M.js → chunk-7RPCSGQM.js} +1 -1
  3. package/dist/chunks/{chunk-Z3AEX7SQ.js → chunk-GRA2PF4H.js} +2 -1
  4. package/dist/core/kernel-skills.d.ts +10 -0
  5. package/dist/core/kernel-skills.d.ts.map +1 -0
  6. package/dist/core/skill-prompt.d.ts +1 -1
  7. package/dist/core/skill-prompt.d.ts.map +1 -1
  8. package/dist/core/system-guidance.d.ts.map +1 -1
  9. package/dist/fabric-runtime-state.js +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +64 -16
  12. package/dist/index.js.map +4 -4
  13. package/dist/runtime/cpython-child-source.d.ts.map +1 -1
  14. package/dist/runtime/cpython-runtime.d.ts.map +1 -1
  15. package/dist/runtime/cpython-runtime.js +101 -21
  16. package/dist/runtime/cpython-runtime.js.map +2 -2
  17. package/dist/ui/settings.js +1 -1
  18. package/docs/kernels.md +17 -0
  19. package/docs/skills.md +3 -2
  20. package/package.json +1 -1
  21. package/skills/fabric-advisor/SKILL.md +2 -0
  22. package/skills/fabric-ambient/SKILL.md +2 -0
  23. package/skills/fabric-council/SKILL.md +2 -0
  24. package/skills/fabric-exec/SKILL.md +8 -34
  25. package/skills/fabric-exec-python/SKILL.md +66 -0
  26. package/skills/fabric-fusion/SKILL.md +2 -0
  27. package/skills/fabric-guide/SKILL.md +2 -0
  28. package/skills/fabric-rlm/SKILL.md +2 -0
  29. package/skills/fabric-schema/SKILL.md +2 -0
  30. package/skills/fabric-spec/SKILL.md +2 -0
  31. package/skills/fabric-supervisor/SKILL.md +2 -0
  32. package/skills/fabric-swarm/SKILL.md +2 -0
  33. package/skills/fabric-workflow/SKILL.md +2 -0
  34. /package/dist/chunks/{chunk-PPIWZJ4M.js.map → chunk-7RPCSGQM.js.map} +0 -0
  35. /package/dist/chunks/{chunk-Z3AEX7SQ.js.map → chunk-GRA2PF4H.js.map} +0 -0
package/README.md CHANGED
@@ -102,7 +102,7 @@ pi -e /absolute/path/to/pi-fabric
102
102
 
103
103
  ## What you can ask for
104
104
 
105
- Pi loads advanced patterns after direct user invocation. Run `/skill:fabric-guide` for one recommendation, or invoke the exact `/skill:<name>` yourself. An ordinary coding task keeps Pi on the core `fabric-exec` path.
105
+ Pi loads advanced patterns after direct user invocation. Run `/skill:fabric-guide` for one recommendation, or invoke the exact `/skill:<name>` yourself. An ordinary coding task uses the kernel-matched execution reference (`fabric-exec` for TypeScript, `fabric-exec-python` for Python). The advanced workflows below currently require TypeScript.
106
106
 
107
107
  | You want | Run |
108
108
  | -------- | --- |
@@ -118,7 +118,7 @@ Pi loads advanced patterns after direct user invocation. Run `/skill:fabric-guid
118
118
  | A durable team coordinating through versioned tasks | `/skill:fabric-swarm Coordinate this migration across owned task partitions.` |
119
119
  | Evidence-gated edits with postconditions | `/skill:fabric-schema Make this parser change only if focused tests stay green.` |
120
120
 
121
- The foundation is the `fabric-exec` reference skill: the model loads it before its first `fabric_exec` call and again when a call errors on argument shape.
121
+ Execution references stay progressive: the model loads the selected kernel's skill after argument-shape errors or when exact advanced contracts are needed. Skills can declare `metadata.fabric-kernel` for runtime selection; see [kernel-specific skills](docs/kernels.md#kernel-specific-skills-and-guidance).
122
122
 
123
123
  ## Agent conversations
124
124
 
@@ -398,4 +398,4 @@ var FabricState = class {
398
398
  export {
399
399
  FabricState
400
400
  };
401
- //# sourceMappingURL=chunk-PPIWZJ4M.js.map
401
+ //# sourceMappingURL=chunk-7RPCSGQM.js.map
@@ -568,7 +568,8 @@ export {
568
568
  settleInPlacePrewalk,
569
569
  runFabricHandoffAtBoundary,
570
570
  formatSkillsForPrompt,
571
+ parseSkillBlock,
571
572
  expandSkillDirMarkersInSkillBlock,
572
573
  expandSkillDirMarkersForRead
573
574
  };
574
- //# sourceMappingURL=chunk-Z3AEX7SQ.js.map
575
+ //# sourceMappingURL=chunk-GRA2PF4H.js.map
@@ -0,0 +1,10 @@
1
+ import type { Skill } from "@earendil-works/pi-coding-agent";
2
+ import type { FabricKernel } from "../runtime/kernel.js";
3
+ export declare class KernelSkills {
4
+ private readonly cache;
5
+ private declaration;
6
+ select(skills: readonly Skill[], kernel: FabricKernel): Skill[];
7
+ private compatible;
8
+ filterInvocation(text: string, kernel: FabricKernel): string;
9
+ }
10
+ //# sourceMappingURL=kernel-skills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel-skills.d.ts","sourceRoot":"","sources":["../../src/core/kernel-skills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6D;IAEnF,OAAO,CAAC,WAAW;IA0BnB,MAAM,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE;IAI/D,OAAO,CAAC,UAAU;IAKlB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM;CAK7D"}
@@ -1,3 +1,3 @@
1
1
  import type { Skill } from "@earendil-works/pi-coding-agent";
2
- export declare const restoreSkillsForFullCodePrompt: (systemPrompt: string, skills: readonly Skill[]) => string;
2
+ export declare const restoreSkillsForFullCodePrompt: (systemPrompt: string, skills: readonly Skill[], fullCodeMode?: boolean) => string;
3
3
  //# sourceMappingURL=skill-prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skill-prompt.d.ts","sourceRoot":"","sources":["../../src/core/skill-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAW7D,eAAO,MAAM,8BAA8B,GACzC,cAAc,MAAM,EACpB,QAAQ,SAAS,KAAK,EAAE,KACvB,MAiBF,CAAC"}
1
+ {"version":3,"file":"skill-prompt.d.ts","sourceRoot":"","sources":["../../src/core/skill-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAW7D,eAAO,MAAM,8BAA8B,GACzC,cAAc,MAAM,EACpB,QAAQ,SAAS,KAAK,EAAE,EACxB,sBAAmB,KAClB,MAkBF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"system-guidance.d.ts","sourceRoot":"","sources":["../../src/core/system-guidance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,eAAO,MAAM,6BAA6B,GAAI,cAAc,OAAO,EAAE,SAAQ,YAA2B,EAAE,gBAAe,SAAS,GAAG,OAAiB,KAAG,MAY5I,CAAC;AAEd,eAAO,MAAM,8BAA8B,GAAI,cAAc,OAAO,EAAE,SAAQ,YAA2B,EAAE,gBAAe,SAAS,GAAG,OAAiB,KAAG,MAOiL,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"}
1
+ {"version":3,"file":"system-guidance.d.ts","sourceRoot":"","sources":["../../src/core/system-guidance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,eAAO,MAAM,6BAA6B,GAAI,cAAc,OAAO,EAAE,SAAQ,YAA2B,EAAE,gBAAe,SAAS,GAAG,OAAiB,KAAG,MAa5I,CAAC;AAEd,eAAO,MAAM,8BAA8B,GAAI,cAAc,OAAO,EAAE,SAAQ,YAA2B,EAAE,gBAAe,SAAS,GAAG,OAAiB,KAAG,MAOiL,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"}
@@ -21,7 +21,7 @@ import {
21
21
  claimFabricHandoff,
22
22
  expandSkillDirMarkersForRead,
23
23
  runFabricHandoffAtBoundary
24
- } from "./chunks/chunk-Z3AEX7SQ.js";
24
+ } from "./chunks/chunk-GRA2PF4H.js";
25
25
  import {
26
26
  ApprovalController,
27
27
  FABRIC_COMPONENT_PROVIDER_NAMES,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,iCAAiC,CAAC;AA4JzC,wBAA8B,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkvBtE;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,iCAAiC,CAAC;AA6JzC,wBAA8B,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqvBtE;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  FabricState
3
- } from "./chunks/chunk-PPIWZJ4M.js";
3
+ } from "./chunks/chunk-7RPCSGQM.js";
4
4
  import {
5
5
  arcItemStyled,
6
6
  captureFabricAgentPreviews,
@@ -57,10 +57,11 @@ import {
57
57
  filterPrewalkContinuationMessages,
58
58
  formatSkillsForPrompt,
59
59
  hasPrewalkArmedPrompt,
60
+ parseSkillBlock,
60
61
  prewalkArmedPrompt,
61
62
  settleInPlacePrewalk,
62
63
  withTrajectoryRearmDirective
63
- } from "./chunks/chunk-Z3AEX7SQ.js";
64
+ } from "./chunks/chunk-GRA2PF4H.js";
64
65
  import {
65
66
  ApprovalController,
66
67
  CapturedToolCatalog,
@@ -1967,6 +1968,7 @@ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:f
1967
1968
  import * as path4 from "node:path";
1968
1969
  var fabricExecutionKernelGuidance = (fullCodeMode, kernel = "typescript", pythonRuntime = "monty") => [
1969
1970
  kernel === "python" ? `Configured fabric_exec kernel: Python (${pythonRuntime === "monty" ? "Monty sandboxed subset" : "CPython"}). Write Python only in \`code\`: top-level await/return, dicts, True/False/None, and asyncio.gather. There is no per-call language switch.` : "Configured fabric_exec kernel: TypeScript. Write TypeScript only in `code`; top-level await and return are supported.",
1971
+ "The configured kernel is exclusive for Fabric orchestration, including when skills or earlier messages show another language. Do not invoke another interpreter through shell tools or native subprocesses merely to run Fabric orchestration in a different language. Project builds, tests, and explicitly requested interpreter work remain legitimate shell commands.",
1970
1972
  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.",
1971
1973
  // Files the model has not opened (images in particular) must be read before
1972
1974
  // use; this line rides the turn-stable kernel guidance so provider prefix
@@ -2037,23 +2039,66 @@ var SKILL_SECTION_HEADING = "The following skills provide specialized instructio
2037
2039
  var PI_SKILL_LOAD_INSTRUCTION = "Use the read tool to load a skill's file when the task matches its description.";
2038
2040
  var FABRIC_SKILL_LOAD_INSTRUCTION = "Use `pi.read` inside `fabric_exec` to load a skill's file when the task matches its description.";
2039
2041
  var CWD_MARKER = "\nCurrent working directory:";
2040
- var restoreSkillsForFullCodePrompt = (systemPrompt, skills) => {
2042
+ var restoreSkillsForFullCodePrompt = (systemPrompt, skills, fullCodeMode = true) => {
2041
2043
  const section = formatSkillsForPrompt([...skills]).replace(
2042
2044
  PI_SKILL_LOAD_INSTRUCTION,
2043
- FABRIC_SKILL_LOAD_INSTRUCTION
2045
+ fullCodeMode ? FABRIC_SKILL_LOAD_INSTRUCTION : PI_SKILL_LOAD_INSTRUCTION
2044
2046
  );
2045
- if (!section) return systemPrompt;
2046
- if (systemPrompt.includes(SKILL_SECTION_HEADING)) {
2047
- return systemPrompt.replace(
2048
- PI_SKILL_LOAD_INSTRUCTION,
2049
- FABRIC_SKILL_LOAD_INSTRUCTION
2050
- );
2047
+ const start = systemPrompt.indexOf(SKILL_SECTION_HEADING);
2048
+ const end = start < 0 ? -1 : systemPrompt.indexOf("</available_skills>", start);
2049
+ if (start >= 0 && end >= 0) {
2050
+ return systemPrompt.slice(0, start) + section.trimStart() + systemPrompt.slice(end + "</available_skills>".length);
2051
2051
  }
2052
+ if (!section) return systemPrompt;
2052
2053
  const cwdIndex = systemPrompt.lastIndexOf(CWD_MARKER);
2053
2054
  if (cwdIndex < 0) return `${systemPrompt}${section}`;
2054
2055
  return `${systemPrompt.slice(0, cwdIndex)}${section}${systemPrompt.slice(cwdIndex)}`;
2055
2056
  };
2056
2057
 
2058
+ // src/core/kernel-skills.ts
2059
+ import { readFileSync as readFileSync3, statSync } from "node:fs";
2060
+ import { parse } from "yaml";
2061
+ var KernelSkills = class {
2062
+ cache = /* @__PURE__ */ new Map();
2063
+ declaration(filePath) {
2064
+ try {
2065
+ const stat = statSync(filePath);
2066
+ const stamp = `${stat.ino}:${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`;
2067
+ const cached = this.cache.get(filePath);
2068
+ if (cached?.stamp === stamp) return cached.kernel;
2069
+ const text = readFileSync3(filePath, "utf8");
2070
+ const frontmatter = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text)?.[1];
2071
+ let kernel = "shared";
2072
+ if (frontmatter) {
2073
+ try {
2074
+ const value = parse(frontmatter)?.metadata?.["fabric-kernel"];
2075
+ kernel = value === void 0 ? "shared" : value === "typescript" || value === "python" ? value : "invalid";
2076
+ } catch {
2077
+ kernel = "invalid";
2078
+ }
2079
+ }
2080
+ this.cache.set(filePath, { stamp, kernel });
2081
+ return kernel;
2082
+ } catch {
2083
+ return this.cache.get(filePath)?.kernel ?? "shared";
2084
+ }
2085
+ }
2086
+ select(skills, kernel) {
2087
+ return skills.filter((skill) => this.compatible(skill.filePath, kernel));
2088
+ }
2089
+ compatible(filePath, kernel) {
2090
+ const declared = this.declaration(filePath);
2091
+ return declared === "shared" || declared === kernel;
2092
+ }
2093
+ filterInvocation(text, kernel) {
2094
+ const block = parseSkillBlock(text);
2095
+ if (!block || this.compatible(block.location, kernel)) return text;
2096
+ return `Skill ${block.name} is unavailable for the configured ${kernel} kernel. Do not execute its instructions or switch interpreters to run it. Use a compatible skill or the current kernel's host APIs.${block.userMessage ? `
2097
+
2098
+ ${block.userMessage}` : ""}`;
2099
+ }
2100
+ };
2101
+
2057
2102
  // src/core/proxy-contract.ts
2058
2103
  var PROXY_CONTRACT_CUSTOM_TYPE = "pi-fabric-proxy";
2059
2104
  var FABRIC_EXEC_TOOL = "fabric_exec";
@@ -3510,7 +3555,7 @@ var classifyToolResult = (input) => {
3510
3555
  };
3511
3556
 
3512
3557
  // src/host-compatibility.ts
3513
- import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
3558
+ import { existsSync as existsSync3, readFileSync as readFileSync4, realpathSync as realpathSync2 } from "node:fs";
3514
3559
  import path6 from "node:path";
3515
3560
  var MINIMUM_PI_HOST_VERSION = "0.80.6";
3516
3561
  var PI_HOST_PACKAGE_NAMES = /* @__PURE__ */ new Set([
@@ -3550,7 +3595,7 @@ var detectPiHostVersion = (cliPath = process.argv[1]) => {
3550
3595
  const manifestPath = path6.join(directory, "package.json");
3551
3596
  if (existsSync3(manifestPath)) {
3552
3597
  try {
3553
- const manifest = JSON.parse(readFileSync3(manifestPath, "utf8"));
3598
+ const manifest = JSON.parse(readFileSync4(manifestPath, "utf8"));
3554
3599
  if (typeof manifest.name === "string" && PI_HOST_PACKAGE_NAMES.has(manifest.name) && typeof manifest.version === "string") {
3555
3600
  return manifest.version;
3556
3601
  }
@@ -4796,6 +4841,7 @@ async function piFabric(pi) {
4796
4841
  );
4797
4842
  }
4798
4843
  );
4844
+ const kernelSkills = new KernelSkills();
4799
4845
  pi.on("resources_discover", async () => {
4800
4846
  if (existsSync4(FABRIC_SKILLS_DIR)) return { skillPaths: [FABRIC_SKILLS_DIR] };
4801
4847
  return {};
@@ -5176,11 +5222,13 @@ async function piFabric(pi) {
5176
5222
  event.messages,
5177
5223
  (continuationId) => state.initialized && state.prewalk.acceptContinuation(sessionId, continuationId)
5178
5224
  );
5225
+ const kernel = (state.bootstrapped ? state.config : DEFAULT_FABRIC_CONFIG).executor.kernel;
5226
+ const filterSkill = (text) => pi.getActiveTools().includes("fabric_exec") ? kernelSkills.filterInvocation(text, kernel) : text;
5179
5227
  let changed = continuation.changed;
5180
5228
  const messages = continuation.messages.map((message) => {
5181
5229
  if (message.role !== "user") return message;
5182
5230
  if (typeof message.content === "string") {
5183
- const content2 = expandSkillDirMarkersInSkillBlock(message.content);
5231
+ const content2 = expandSkillDirMarkersInSkillBlock(filterSkill(message.content));
5184
5232
  if (content2 === message.content) return message;
5185
5233
  changed = true;
5186
5234
  return { ...message, content: content2 };
@@ -5188,7 +5236,7 @@ async function piFabric(pi) {
5188
5236
  let messageChanged = false;
5189
5237
  const content = message.content.map((part) => {
5190
5238
  if (part.type !== "text") return part;
5191
- const text = expandSkillDirMarkersInSkillBlock(part.text);
5239
+ const text = expandSkillDirMarkersInSkillBlock(filterSkill(part.text));
5192
5240
  if (text === part.text) return part;
5193
5241
  changed = true;
5194
5242
  messageChanged = true;
@@ -5204,9 +5252,9 @@ async function piFabric(pi) {
5204
5252
  const schemaMode = config.schema.mode;
5205
5253
  const effectiveFullCodeMode = fullCodeMode || schemaMode === "enforce";
5206
5254
  if (!pi.getActiveTools().includes("fabric_exec")) return;
5207
- const skills = event.systemPromptOptions.skills ?? [];
5255
+ const skills = kernelSkills.select(event.systemPromptOptions.skills ?? [], config.executor.kernel);
5208
5256
  const captureSnapshot = state.bootstrapped ? capturePolicy() : void 0;
5209
- const systemPrompt = effectiveFullCodeMode ? restoreSkillsForFullCodePrompt(event.systemPrompt, skills) : event.systemPrompt;
5257
+ const systemPrompt = restoreSkillsForFullCodePrompt(event.systemPrompt, skills, effectiveFullCodeMode);
5210
5258
  const skillReferenceGuidance = effectiveFullCodeMode ? buildSkillReferenceGuidance(event.prompt, skills) : void 0;
5211
5259
  const currentModel = context.model ? `${context.model.provider}/${context.model.id}` : void 0;
5212
5260
  const resolvedGuidance = resolveFabricModelGuidance(state.modelGuidance(), {