feat: tsconfig.json + npm run typecheck
- tsconfig.json simulates pi's ESM TypeScript runtime - Resolves peer deps from pi's global node_modules - 'type: module' added to package.json (correct — pi loads as ESM) - Fixes found by tsc: - buffer/writer.ts: correct Dirent import from node:fs - messages.ts: toolCall id/name may be undefined, default to empty string - Remaining warnings: pi event API names (session_switch etc.) not in types; these are guarded with try/catch at runtime — acceptable - npm run typecheck: tsc --noEmit
This commit is contained in:
parent
920f6d8fc3
commit
38cad794e2
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
|
import type { Dirent } from "node:fs";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import type { SeqNum } from "../sequence.js";
|
import type { SeqNum } from "../sequence.js";
|
||||||
|
|
@ -165,7 +166,7 @@ export async function cleanupIdleBuffers(
|
||||||
const maxIdleMs = cfg.idleDays * 24 * 60 * 60 * 1000;
|
const maxIdleMs = cfg.idleDays * 24 * 60 * 60 * 1000;
|
||||||
const deleted: string[] = [];
|
const deleted: string[] = [];
|
||||||
|
|
||||||
let entries: fs.Dirent[] = [];
|
let entries: Dirent[] = [];
|
||||||
try {
|
try {
|
||||||
entries = await fs.readdir(dir, { withFileTypes: true });
|
entries = await fs.readdir(dir, { withFileTypes: true });
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@ export function serializeMessage(
|
||||||
const toolCalls = (msg.content as RawContent[])
|
const toolCalls = (msg.content as RawContent[])
|
||||||
.filter((c) => c.type === "toolCall")
|
.filter((c) => c.type === "toolCall")
|
||||||
.map((c) => ({
|
.map((c) => ({
|
||||||
id: c.id,
|
id: c.id ?? "",
|
||||||
name: c.name,
|
name: c.name ?? "",
|
||||||
args: JSON.stringify(c.arguments, null, 2),
|
args: JSON.stringify(c.arguments, null, 2),
|
||||||
}));
|
}));
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^2.4.12",
|
"@biomejs/biome": "^2.4.12",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"husky": "^9.1.7"
|
"husky": "^9.1.7",
|
||||||
|
"typescript": "^6.0.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@earendil-works/pi-coding-agent": "*",
|
"@earendil-works/pi-coding-agent": "*",
|
||||||
|
|
@ -3970,6 +3971,20 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"node_modules/typescript": {
|
||||||
|
"version": "6.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
|
||||||
|
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"tsc": "bin/tsc",
|
||||||
|
"tsserver": "bin/tsserver"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/uint8array-extras": {
|
"node_modules/uint8array-extras": {
|
||||||
"version": "1.5.0",
|
"version": "1.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/uint8array-extras/-/uint8array-extras-1.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/uint8array-extras/-/uint8array-extras-1.5.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pi-remote-control",
|
"name": "pi-remote-control",
|
||||||
|
"type": "module",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Expose a running pi session over HTTP/WebSocket — view and interact from any browser on your network.",
|
"description": "Expose a running pi session over HTTP/WebSocket — view and interact from any browser on your network.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
@ -18,6 +19,7 @@
|
||||||
"lint": "biome check --write .",
|
"lint": "biome check --write .",
|
||||||
"lint:check": "biome check .",
|
"lint:check": "biome check .",
|
||||||
"prepare": "node .husky/install.mjs",
|
"prepare": "node .husky/install.mjs",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
"smoke": "node --test scripts/smoke/smoke.mjs",
|
"smoke": "node --test scripts/smoke/smoke.mjs",
|
||||||
"smoke:stream": "node --test scripts/smoke/stream.test.mjs",
|
"smoke:stream": "node --test scripts/smoke/stream.test.mjs",
|
||||||
"smoke:all": "node --test scripts/smoke/smoke.mjs scripts/smoke/stream.test.mjs"
|
"smoke:all": "node --test scripts/smoke/smoke.mjs scripts/smoke/stream.test.mjs"
|
||||||
|
|
@ -25,6 +27,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^2.4.12",
|
"@biomejs/biome": "^2.4.12",
|
||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"husky": "^9.1.7"
|
"husky": "^9.1.7",
|
||||||
|
"typescript": "^6.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
// Simulate pi's TypeScript runtime environment
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"lib": ["ES2022"],
|
||||||
|
|
||||||
|
// Type-check only, no emit — pi handles the actual transpilation
|
||||||
|
"noEmit": true,
|
||||||
|
"strict": true,
|
||||||
|
"exactOptionalPropertyTypes": false,
|
||||||
|
|
||||||
|
// Resolve peer deps from pi's global node_modules
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@earendil-works/pi-coding-agent": [
|
||||||
|
"../../../../../../usr/local/lib/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts"
|
||||||
|
],
|
||||||
|
"@earendil-works/pi-tui": [
|
||||||
|
"../../../../../../usr/local/lib/node_modules/@earendil-works/pi-tui/dist/index.d.ts"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"/usr/local/lib/node_modules/@types"
|
||||||
|
],
|
||||||
|
|
||||||
|
// Project uses .js extensions in imports (NodeNext convention)
|
||||||
|
"allowImportingTsExtensions": false,
|
||||||
|
|
||||||
|
// Relax some checks that are impractical without the real pi runtime
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"ignoreDeprecations": "6.0"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"extensions/remote-control/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"build"
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue