惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
C
Check Point Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
Vercel News
Vercel News
腾讯CDC
GbyAI
GbyAI
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
H
Help Net Security
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor: share package cleanup helpers · openclaw/opencl...
steipete · 2026-05-03 · via Recent Commits to openclaw:main

@@ -19,16 +19,9 @@ import {

1919

writeFileSync,

2020

} from "node:fs";

2121

import { homedir, tmpdir } from "node:os";

22-

import {

23-

basename,

24-

dirname,

25-

isAbsolute,

26-

join,

27-

posix,

28-

relative,

29-

resolve as pathResolve,

30-

} from "node:path";

22+

import { basename, dirname, isAbsolute, join, relative, resolve as pathResolve } from "node:path";

3123

import { fileURLToPath, pathToFileURL } from "node:url";

24+

import { expandPackageDistImportClosure } from "./lib/package-dist-imports.mjs";

32253326

const __dirname = dirname(fileURLToPath(import.meta.url));

3427

const DEFAULT_PACKAGE_ROOT = join(__dirname, "..");

@@ -400,145 +393,6 @@ export function pruneLegacyPluginRuntimeDepsState(params = {}) {

400393

return removed;

401394

}

402395403-

const JS_DIST_FILE_RE = /^dist\/.*\.(?:cjs|js|mjs)$/u;

404-405-

function stripSpecifierSuffix(value) {

406-

return value.replace(/[?#].*$/u, "");

407-

}

408-409-

function resolveDistImportPath(importerPath, specifier) {

410-

if (!specifier.startsWith(".")) {

411-

return null;

412-

}

413-

const stripped = stripSpecifierSuffix(specifier);

414-

if (!stripped) {

415-

return null;

416-

}

417-

return posix.normalize(posix.join(posix.dirname(importerPath), stripped));

418-

}

419-420-

function findStatementStart(source, index) {

421-

return (

422-

Math.max(

423-

source.lastIndexOf(";", index),

424-

source.lastIndexOf("{", index),

425-

source.lastIndexOf("}", index),

426-

source.lastIndexOf("\n", index),

427-

source.lastIndexOf("\r", index),

428-

) + 1

429-

);

430-

}

431-432-

function isImportSpecifierContext(source, index) {

433-

const dynamicPrefix = source.slice(Math.max(0, index - 32), index);

434-

if (/\bimport\s*\(\s*$/u.test(dynamicPrefix)) {

435-

return true;

436-

}

437-

const statementPrefix = source.slice(findStatementStart(source, index), index).trimStart();

438-

return (

439-

/^(?:import|export)\b[\s\S]*\bfrom\s*$/u.test(statementPrefix) ||

440-

/^import\s*$/u.test(statementPrefix)

441-

);

442-

}

443-444-

function collectImportSpecifiers(source) {

445-

const specifiers = [];

446-

let inBlockComment = false;

447-

let inLineComment = false;

448-

for (let index = 0; index < source.length; index += 1) {

449-

if (inBlockComment) {

450-

if (source[index] === "*" && source[index + 1] === "/") {

451-

inBlockComment = false;

452-

index += 1;

453-

}

454-

continue;

455-

}

456-

if (inLineComment) {

457-

if (source[index] === "\n" || source[index] === "\r") {

458-

inLineComment = false;

459-

}

460-

continue;

461-

}

462-

if (source[index] === "/" && source[index + 1] === "*") {

463-

inBlockComment = true;

464-

index += 1;

465-

continue;

466-

}

467-

if (source[index] === "/" && source[index + 1] === "/") {

468-

inLineComment = true;

469-

index += 1;

470-

continue;

471-

}

472-473-

const quote = source[index];

474-

if (quote !== '"' && quote !== "'") {

475-

continue;

476-

}

477-478-

let cursor = index + 1;

479-

let value = "";

480-

while (cursor < source.length) {

481-

const char = source[cursor];

482-

if (char === "\\") {

483-

value += source.slice(cursor, cursor + 2);

484-

cursor += 2;

485-

continue;

486-

}

487-

if (char === quote) {

488-

break;

489-

}

490-

value += char;

491-

cursor += 1;

492-

}

493-

if (cursor >= source.length) {

494-

break;

495-

}

496-497-

if (value.startsWith(".") && isImportSpecifierContext(source, index)) {

498-

specifiers.push(value);

499-

}

500-

index = cursor;

501-

}

502-

return specifiers;

503-

}

504-505-

function expandInstalledDistImportClosure(params) {

506-

const files = [...new Set(params.files)];

507-

const fileSet = new Set(files);

508-

const expectedSet = new Set(params.seedFiles);

509-

let changed = true;

510-511-

while (changed) {

512-

changed = false;

513-

for (const importerPath of [...expectedSet]

514-

.filter((file) => fileSet.has(file))

515-

.toSorted((left, right) => left.localeCompare(right))) {

516-

if (!JS_DIST_FILE_RE.test(importerPath) || importerPath.includes("/node_modules/")) {

517-

continue;

518-

}

519-

let source;

520-

try {

521-

source = params.readText(importerPath);

522-

} catch (error) {

523-

if (error?.code === "ENOENT") {

524-

continue;

525-

}

526-

throw error;

527-

}

528-

for (const specifier of collectImportSpecifiers(source)) {

529-

const importedPath = resolveDistImportPath(importerPath, specifier);

530-

if (!importedPath || !fileSet.has(importedPath) || expectedSet.has(importedPath)) {

531-

continue;

532-

}

533-

expectedSet.add(importedPath);

534-

changed = true;

535-

}

536-

}

537-

}

538-539-

return [...expectedSet].toSorted((left, right) => left.localeCompare(right));

540-

}

541-542396

export function pruneInstalledPackageDist(params = {}) {

543397

const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;

544398

const removeFile = params.unlinkSync ?? unlinkSync;

@@ -569,11 +423,18 @@ export function pruneInstalledPackageDist(params = {}) {

569423

const installedFiles = listInstalledDistFiles(params);

570424

const readFile = params.readFileSync ?? readFileSync;

571425

expectedFiles = new Set(

572-

expandInstalledDistImportClosure({

426+

expandPackageDistImportClosure({

573427

files: installedFiles,

574428

seedFiles: [...expectedFiles],

575429

readText(relativePath) {

576-

return readFile(join(packageRoot, relativePath), "utf8");

430+

try {

431+

return readFile(join(packageRoot, relativePath), "utf8");

432+

} catch (error) {

433+

if (error?.code === "ENOENT") {

434+

return "";

435+

}

436+

throw error;

437+

}

577438

},

578439

}),

579440

);