chore(node-sdk): audit plugins shared

Add plugins/common.ts for the helpers and size limits copied across plugin files; managed-transaction compares snapshots in one place; guard template imported directly.

Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
This commit is contained in:
雷电芽衣 committed 2026-09-02 21:23:57 -04:00
1 parent 07f32a48d7
commit b7f14ba34b
9 files changed
+55 -87

No files matched your search

+1 -14
View File
@@ -1,8 +1,7 @@
import { constants } from 'node:fs';
import fsp from 'node:fs/promises';
import type { FileHandle } from 'node:fs/promises';
const MAX_SOURCE_BYTES = 2 * 1024 * 1024;
import { asError, errorMessage, hasCode, MAX_SOURCE_BYTES } from './common.js';
export interface FileSnapshot {
readonly contents: string;
@@ -11,18 +10,6 @@ export interface FileSnapshot {
readonly mode: number;
}
function asError(error: unknown): Error {
return error instanceof Error ? error : new Error(String(error));
}
function errorMessage(error: unknown): string {
return error instanceof Error ? error.message : String(error);
}
function hasCode(error: unknown, code: string): boolean {
return typeof error === 'object' && error !== null && 'code' in error && error.code === code;
}
export async function readPhysicalFile(
filePath: string,
label: string,