pi-cache-optimizer 2.8.24 → 2.8.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cache-optimizer",
3
- "version": "2.8.24",
3
+ "version": "2.8.25",
4
4
  "description": "Improve Pi prompt/KV cache hit rates with stable prompts, OpenAI-compatible cache keys, proxy compat warnings, and footer cache stats.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -19,15 +19,21 @@ export function escapeXml(value: string): string {
19
19
  .replace(/'/g, "'");
20
20
  }
21
21
 
22
- /** The tool Pi tells the model to load skill files with: `read` when selected, otherwise `bash`; undefined when neither. */
23
- export type SkillFileReadTool = "read" | "bash";
24
-
25
- export function skillFileReadTool(opts: Pick<BuildSystemPromptOptions, "selectedTools">): SkillFileReadTool | undefined {
26
- const tools = opts.selectedTools ?? ["read", "bash", "edit", "write"];
27
- return (["read", "bash"] as const).find((tool) => tools.includes(tool));
22
+ /**
23
+ * The tool Pi tells the model to load skill files with: the first declared of `read`/`bash`;
24
+ * `indirect` when they are selected but hidden (reachable only through another tool); undefined when neither.
25
+ */
26
+ export type SkillFileReadTool = "read" | "bash" | "indirect";
27
+
28
+ export function skillFileReadTool(opts: Pick<BuildSystemPromptOptions, "selectedTools" | "hiddenTools">): SkillFileReadTool | undefined {
29
+ const selected = opts.selectedTools ?? ["read", "bash", "edit", "write"];
30
+ const hidden = opts.hiddenTools ?? [];
31
+ const readers = ["read", "bash"] as const;
32
+ return readers.find((tool) => selected.includes(tool) && !hidden.includes(tool)) ??
33
+ (readers.some((tool) => selected.includes(tool)) ? "indirect" : undefined);
28
34
  }
29
35
 
30
- /** Byte-for-byte copy of Pi's formatter (contract-tested against the installed Pi for both tool wordings). */
36
+ /** Byte-for-byte copy of Pi's formatter (contract-tested against the installed Pi for every tool wording). */
31
37
  export function formatSkillsForPrompt(skills: NonNullable<BuildSystemPromptOptions["skills"]>, fileReadTool: SkillFileReadTool = "read"): string {
32
38
  const visibleSkills = skills.filter((skill) => !skill.disableModelInvocation);
33
39
  if (visibleSkills.length === 0) return "";
@@ -36,7 +42,9 @@ export function formatSkillsForPrompt(skills: NonNullable<BuildSystemPromptOptio
36
42
  "\n\nThe following skills provide specialized instructions for specific tasks.",
37
43
  fileReadTool === "read"
38
44
  ? "Use the read tool to load a skill's file when the task matches its description."
39
- : "Use bash to load a skill's file when the task matches its description.",
45
+ : fileReadTool === "bash"
46
+ ? "Use bash to load a skill's file when the task matches its description."
47
+ : "Load a skill's file when the task matches its description.",
40
48
  "When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.",
41
49
  "",
42
50
  "<available_skills>",