Forked from ceveyne/playbook
Forked from ceveyne/playbook
src / tools / read.ts
/**
* read — return the full content of a playbook document by filename.
*/
import { tool, type Tool, type ToolsProviderController } from "@lmstudio/sdk";
// @ts-ignore — zod/lib re-export chain breaks with NodeNext; runtime is fine
import { z } from "zod";
import type { IndexManager } from "../indexManager.js";
import { formatToolMetaBlock } from "../helpers/pluginMeta.js";
export function createReadTool(
_ctl: ToolsProviderController,
index: IndexManager
): Tool {
return tool({
name: "read",
description: `Read the full content of a playbook document — a note or a skill's SKILL.md.
Use this tool after recall has returned a relevant hit.
Use this tool when:
- recall returned one or more matching documents and you need the actual text
- The user asks you to quote or expand on something from the playbook
- A SKILL.md you already read links to a companion file (e.g. "tools/my-tool.md") and you need its content too
Returns:
- The complete Markdown source including YAML frontmatter (title/tags or name/description, timestamps)
- Full body text without any truncation
Examples:
- filename: "api-auth-notes.md" — returns a flat note
- filename: "pdf-report/SKILL.md" — returns a skill bundle's entry point
- filename: "pdf-report/tools/render_table.md" — returns a companion file linked from that SKILL.md
${formatToolMetaBlock()}`,
parameters: {
filename: z
.string()
.describe(
"The filename of the document to read (e.g. 'my-note.md' or 'my-skill/SKILL.md'). Use the filename returned by recall, or a relative path linked from a SKILL.md you already read."
),
},
implementation: async (args) => {
const filePath = index.resolveReadPath(args.filename);
if (!filePath) {
return `Error: File not found — "${args.filename}". Use recall to find available documents.`;
}
try {
return index.readSource(filePath);
} catch {
return `Error: File not found — "${args.filename}". Use recall to find available documents.`;
}
},
});
}
src / tools / read.ts
/**
* read — return the full content of a playbook document by filename.
*/
import { tool, type Tool, type ToolsProviderController } from "@lmstudio/sdk";
// @ts-ignore — zod/lib re-export chain breaks with NodeNext; runtime is fine
import { z } from "zod";
import type { IndexManager } from "../indexManager.js";
import { formatToolMetaBlock } from "../helpers/pluginMeta.js";
export function createReadTool(
_ctl: ToolsProviderController,
index: IndexManager
): Tool {
return tool({
name: "read",
description: `Read the full content of a playbook document — a note or a skill's SKILL.md.
Use this tool after recall has returned a relevant hit.
Use this tool when:
- recall returned one or more matching documents and you need the actual text
- The user asks you to quote or expand on something from the playbook
- A SKILL.md you already read links to a companion file (e.g. "tools/my-tool.md") and you need its content too
Returns:
- The complete Markdown source including YAML frontmatter (title/tags or name/description, timestamps)
- Full body text without any truncation
Examples:
- filename: "api-auth-notes.md" — returns a flat note
- filename: "pdf-report/SKILL.md" — returns a skill bundle's entry point
- filename: "pdf-report/tools/render_table.md" — returns a companion file linked from that SKILL.md
${formatToolMetaBlock()}`,
parameters: {
filename: z
.string()
.describe(
"The filename of the document to read (e.g. 'my-note.md' or 'my-skill/SKILL.md'). Use the filename returned by recall, or a relative path linked from a SKILL.md you already read."
),
},
implementation: async (args) => {
const filePath = index.resolveReadPath(args.filename);
if (!filePath) {
return `Error: File not found — "${args.filename}". Use recall to find available documents.`;
}
try {
return index.readSource(filePath);
} catch {
return `Error: File not found — "${args.filename}". Use recall to find available documents.`;
}
},
});
}