Tool result refactor (return an object instead of a string)

This commit is contained in:
Alex Gleason committed 2025-12-08 15:13:34 -06:00
1 parent 9c86ced552
commit f7b2d754e9
40 files changed
+315 -276

No files matched your search

+6 -4
View File
@@ -1,5 +1,5 @@
import { z } from 'zod';
import type { Tool } from './Tool';
import type { Tool, ToolResult } from './Tool';
import type { JSRuntimeFS } from '../JSRuntime';
import { findSkill, readSkillContent } from '../plugins';
@@ -24,7 +24,7 @@ export class SkillTool implements Tool<SkillParams> {
this.projectPath = projectPath;
}
async execute(args: SkillParams): Promise<string> {
async execute(args: SkillParams): Promise<ToolResult> {
const { name } = args;
try {
@@ -38,7 +38,8 @@ export class SkillTool implements Tool<SkillParams> {
// Read and return the skill content
const content = await readSkillContent(this.fs, skill);
return `# Skill: ${skill.name}
return {
content: `# Skill: ${skill.name}
**Source**: ${skill.plugin === 'project' ? 'Project' : `Plugin: ${skill.plugin}`}
**Description**: ${skill.description}
@@ -46,7 +47,8 @@ export class SkillTool implements Tool<SkillParams> {
---
${content}`;
${content}`
};
} catch (error) {
if (error instanceof Error) {
throw error;