refactor: migrated packages to internal utility modules and removed external dependencies
- Implemented in-house, zero-dependency utility modules in `pi-utils` covering DOM manipulation, markdown parsing, templating, browser automation helpers, and terminal buffers. - Migrated packages across the repository to consume the new internal utilities and `omptype` schema validators instead of external dependencies. - Removed multiple external runtime and development dependencies including Zod, Marked, LRU cache, Turndown, and Puppeteer browser packages.
This commit is contained in:
@@ -96,7 +96,7 @@ renderResult(result, { expanded, isPartial }, theme) {
|
||||
**Use `z.enum` for discriminated string tool args:**
|
||||
|
||||
```typescript
|
||||
const { z } = pi.zod;
|
||||
const z = pi.zod;
|
||||
|
||||
parameters: z.object({
|
||||
action: z.enum(["list", "add"]),
|
||||
|
||||
@@ -114,7 +114,7 @@ export default function (pi: ExtensionAPI) {
|
||||
**Use `z.enum` for discriminated string tool args:**
|
||||
|
||||
```typescript
|
||||
const { z } = pi.zod;
|
||||
const z = pi.zod;
|
||||
|
||||
parameters: z.object({
|
||||
action: z.enum(["list", "add"]),
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
/**
|
||||
* API Demo Extension
|
||||
*
|
||||
* Demonstrates using ExtensionAPI's logger, injected `pi.zod`, and pi module access.
|
||||
* These features are now exposed directly on the ExtensionAPI, matching
|
||||
* the CustomToolAPI interface.
|
||||
* Demonstrates using ExtensionAPI's logger, injected schema builder, and pi
|
||||
* module access.
|
||||
*/
|
||||
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const { z } = pi.zod;
|
||||
const z = pi.zod;
|
||||
|
||||
// Access the logger for debugging
|
||||
pi.logger.debug("API demo extension loaded");
|
||||
@@ -16,7 +15,7 @@ export default function (pi: ExtensionAPI) {
|
||||
pi.registerTool({
|
||||
name: "api_demo",
|
||||
label: "API Demo",
|
||||
description: "Demonstrates ExtensionAPI capabilities: logger, zod, and pi module access",
|
||||
description: "Demonstrates ExtensionAPI capabilities: logger, schema validation, and pi module access",
|
||||
parameters: z.object({
|
||||
message: z.string().describe("Test message"),
|
||||
logLevel: z.enum(["error", "warn", "debug"]).default("debug").describe("Log level to use"),
|
||||
@@ -48,7 +47,7 @@ export default function (pi: ExtensionAPI) {
|
||||
``,
|
||||
`Features demonstrated:`,
|
||||
`1. ✓ Logger access via pi.logger`,
|
||||
`2. ✓ Zod access via pi.zod`,
|
||||
`2. ✓ Schema builder access via pi.arktype`,
|
||||
`3. ✓ Pi module access via pi.pi`,
|
||||
``,
|
||||
`Context:`,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Tests that jiti can resolve npm modules correctly.
|
||||
*/
|
||||
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
||||
import chalk from "chalk";
|
||||
import chalk from "@oh-my-pi/pi-utils/chalk";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
// Log with colors using chalk
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* Hello Tool - Minimal custom tool example
|
||||
*
|
||||
* Demonstrates using ExtensionAPI's logger, injected `pi.zod`, and pi module access.
|
||||
* Demonstrates using ExtensionAPI's logger and injected schema builder.
|
||||
*/
|
||||
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const { z } = pi.zod;
|
||||
const z = pi.zod;
|
||||
|
||||
pi.registerTool({
|
||||
name: "hello",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const { z } = pi.zod;
|
||||
const z = pi.zod;
|
||||
|
||||
// Command entrypoint for reload.
|
||||
// Treat reload as terminal for this handler.
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
||||
import ms from "ms";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const { z } = pi.zod;
|
||||
const z = pi.zod;
|
||||
|
||||
// Register a tool that uses ms
|
||||
pi.registerTool({
|
||||
|
||||
@@ -41,7 +41,7 @@ console.log();
|
||||
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const { z } = pi.zod;
|
||||
const z = pi.zod;
|
||||
|
||||
pi.on("agent_start", async () => {
|
||||
console.log("[Extension] Agent starting");
|
||||
|
||||
Reference in New Issue
Block a user