779ca4872b
- Removed Prettier configuration files (.prettierignore and .prettierrc) and migrated formatting to Biome. - Updated Biome configuration from version 2.3.11 to 2.3.12 and changed arrowParentheses rule from 'always' to 'asNeeded'. - Pinned @biomejs/biome dependency to exact version 2.3.12 in package.json and bun.lock. - Applied consistent arrow function formatting across 489 files by removing unnecessary parentheses around single parameters. - Removed blank lines after comment blocks and reorganized imports for consistency across the codebase.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* Example extension with its own npm dependencies.
|
|
* Tests that jiti resolves modules from the extension's own node_modules.
|
|
*
|
|
* Requires: npm install in this directory
|
|
*/
|
|
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
import { Type } from "@sinclair/typebox";
|
|
import ms from "ms";
|
|
|
|
export default function (pi: ExtensionAPI) {
|
|
// Register a tool that uses ms
|
|
pi.registerTool({
|
|
name: "parse_duration",
|
|
label: "Parse Duration",
|
|
description: "Parse a human-readable duration string (e.g., '2 days', '1h', '5m') to milliseconds",
|
|
parameters: Type.Object({
|
|
duration: Type.String({ description: "Duration string like '2 days', '1h', '5m'" }),
|
|
}),
|
|
execute: async (_toolCallId, params) => {
|
|
const result = ms(params.duration as ms.StringValue);
|
|
if (result === undefined) {
|
|
return {
|
|
content: [{ type: "text", text: `Invalid duration: "${params.duration}"` }],
|
|
isError: true,
|
|
details: {},
|
|
};
|
|
}
|
|
return {
|
|
content: [{ type: "text", text: `${params.duration} = ${result} milliseconds` }],
|
|
details: {},
|
|
};
|
|
},
|
|
});
|
|
}
|