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:
can1357
2026-08-05 13:39:09 +02:00
parent 1e492d6ff9
commit e9888367d1
284 changed files with 14662 additions and 2477 deletions
+12 -14
View File
@@ -31,6 +31,7 @@
import * as path from "node:path";
import { parseArgs } from "node:util";
import { type } from "@oh-my-pi/omptype";
import {
type Api,
AuthStorage,
@@ -43,7 +44,6 @@ import {
} from "@oh-my-pi/pi-ai";
import { type GeneratedProvider, getBundledModel } from "@oh-my-pi/pi-catalog/models";
import { getAgentDbPath } from "@oh-my-pi/pi-utils";
import { z } from "zod/v4";
import {
type ChangelogDocument,
changelogPaths,
@@ -151,15 +151,13 @@ interface RewrittenSection {
items: string[];
}
const REWRITE_RESPONSE = z.object({
sections: z
.array(
z.object({
category: z.enum(["Breaking Changes", "Added", "Changed", "Fixed", "Removed"]),
items: z.array(z.string()),
}),
)
.default([]),
const REWRITE_RESPONSE = type({
sections: type({
category: "'Breaking Changes' | 'Added' | 'Changed' | 'Fixed' | 'Removed'",
items: "string[]",
})
.array()
.default(() => []),
});
const REWRITE_PARAMETERS = {
@@ -198,11 +196,11 @@ const REWRITE_TOOL: Tool = {
};
function validateRewrite(args: Record<string, unknown>): RewrittenSection[] {
const parsed = REWRITE_RESPONSE.safeParse(args);
if (!parsed.success) {
throw new Error(`invalid tool arguments: ${parsed.error.issues.map(issue => issue.message).join("; ")}`);
const parsed = REWRITE_RESPONSE(args);
if (parsed instanceof type.errors) {
throw new Error(`invalid tool arguments: ${parsed.summary}`);
}
return parsed.data.sections
return parsed.sections
.map(sec => ({
category: sec.category,
items: sec.items.map(item => item.trim()).filter(Boolean),