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

推荐订阅源

D
Docker
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
博客园 - 聂微东
S
SegmentFault 最新的问题
量子位
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页

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
fix(test): avoid walking package boundary scans · opencla...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,6 +1,7 @@

1-

import { existsSync, readdirSync, readFileSync } from "node:fs";

1+

import { spawnSync } from "node:child_process";

2+

import fs from "node:fs";

23

import { relative, resolve } from "node:path";

3-

import { describe, expect, it } from "vitest";

4+

import { describe, expect, it, vi } from "vitest";

45

import {

56

collectExtensionsWithTsconfig,

67

collectOptInExtensionPackageBoundaries,

@@ -18,6 +19,7 @@ const EXTENSION_PACKAGE_BOUNDARY_PATHS_CONFIG =

1819

"extensions/tsconfig.package-boundary.paths.json" as const;

1920

const EXTENSION_PACKAGE_BOUNDARY_BASE_CONFIG =

2021

"extensions/tsconfig.package-boundary.base.json" as const;

22+

const trackedCodeFilesByRoot = new Map<string, readonly string[] | null>();

21232224

type TsConfigJson = {

2325

extends?: unknown;

@@ -71,13 +73,41 @@ const MEMORY_HOST_SDK_RUNTIME_ADAPTER_FILES = [

71737274

// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets assertions ascribe JSON file shape.

7375

function readJsonFile<T>(relativePath: string): T {

74-

return JSON.parse(readFileSync(resolve(REPO_ROOT, relativePath), "utf8")) as T;

76+

return JSON.parse(fs.readFileSync(resolve(REPO_ROOT, relativePath), "utf8")) as T;

77+

}

78+79+

function listTrackedCodeFiles(relativeDir: string): string[] | null {

80+

if (trackedCodeFilesByRoot.has(relativeDir)) {

81+

const files = trackedCodeFilesByRoot.get(relativeDir);

82+

return files ? [...files] : null;

83+

}

84+

const result = spawnSync("git", ["ls-files", "--", relativeDir], {

85+

cwd: REPO_ROOT,

86+

encoding: "utf8",

87+

stdio: ["ignore", "pipe", "ignore"],

88+

});

89+

if (result.status !== 0) {

90+

trackedCodeFilesByRoot.set(relativeDir, null);

91+

return null;

92+

}

93+

const files = result.stdout

94+

.split("\n")

95+

.map((line) => line.trim().replaceAll("\\", "/"))

96+

.filter((line) => line.length > 0 && /\.(?:[cm]?ts|tsx|mts|cts)$/u.test(line))

97+

.toSorted();

98+

trackedCodeFilesByRoot.set(relativeDir, files);

99+

return [...files];

75100

}

7610177102

function collectCodeFiles(relativeDir: string): string[] {

103+

const trackedFiles = listTrackedCodeFiles(relativeDir);

104+

if (trackedFiles) {

105+

return trackedFiles;

106+

}

107+78108

const dir = resolve(REPO_ROOT, relativeDir);

79109

const files: string[] = [];

80-

for (const entry of readdirSync(dir, { withFileTypes: true })) {

110+

for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {

81111

const nextPath = resolve(dir, entry.name);

82112

if (entry.isDirectory()) {

83113

files.push(...collectCodeFiles(relative(REPO_ROOT, nextPath).replaceAll("\\", "/")));

@@ -92,19 +122,33 @@ function collectCodeFiles(relativeDir: string): string[] {

9212293123

function collectCoreReferenceFiles(relativeDir: string): string[] {

94124

return collectCodeFiles(relativeDir).filter((file) => {

95-

const source = readFileSync(resolve(REPO_ROOT, file), "utf8");

125+

const source = fs.readFileSync(resolve(REPO_ROOT, file), "utf8");

96126

return source.includes("../../../../src/") || source.includes("../../../src/");

97127

});

98128

}

99129100130

function collectOpenClawRuntimeDirectImportFiles(relativeDir: string): string[] {

101131

return collectCodeFiles(relativeDir).filter((file) => {

102-

const source = readFileSync(resolve(REPO_ROOT, file), "utf8");

132+

const source = fs.readFileSync(resolve(REPO_ROOT, file), "utf8");

103133

return source.includes('"./openclaw-runtime.js"');

104134

});

105135

}

106136107137

describe("opt-in extension package boundaries", () => {

138+

it("lists package boundary code files from git without walking package roots", () => {

139+

const readDir = vi.spyOn(fs, "readdirSync");

140+

try {

141+

const memoryHostFiles = collectCodeFiles("packages/memory-host-sdk/src");

142+

const packageContractFiles = collectCodeFiles("packages/plugin-package-contract/src");

143+144+

expect(memoryHostFiles.length).toBeGreaterThan(0);

145+

expect(packageContractFiles.length).toBeGreaterThan(0);

146+

expect(readDir).not.toHaveBeenCalled();

147+

} finally {

148+

readDir.mockRestore();

149+

}

150+

});

151+108152

it("keeps path aliases in a dedicated shared config", () => {

109153

const pathsConfig = readJsonFile<TsConfigJson>(EXTENSION_PACKAGE_BOUNDARY_PATHS_CONFIG);

110154

expect(pathsConfig.extends).toBe("../tsconfig.json");

@@ -244,7 +288,7 @@ describe("opt-in extension package boundaries", () => {

244288

"./dist/src/plugin-sdk/text-runtime.d.ts",

245289

);

246290

expect(packageJson.exports?.["./zod"]?.types).toBe("./dist/src/plugin-sdk/zod.d.ts");

247-

expect(existsSync(resolve(REPO_ROOT, "packages/plugin-sdk/types/plugin-entry.d.ts"))).toBe(

291+

expect(fs.existsSync(resolve(REPO_ROOT, "packages/plugin-sdk/types/plugin-entry.d.ts"))).toBe(

248292

false,

249293

);

250294

});

@@ -265,7 +309,10 @@ describe("opt-in extension package boundaries", () => {

265309

if (!target) {

266310

throw new Error(`Missing memory-host-sdk export target for ${exportPath}`);

267311

}

268-

const source = readFileSync(resolve(REPO_ROOT, "packages/memory-host-sdk", target), "utf8");

312+

const source = fs.readFileSync(

313+

resolve(REPO_ROOT, "packages/memory-host-sdk", target),

314+

"utf8",

315+

);

269316

expect(source, target).not.toContain("src/memory-host-sdk/");

270317

}

271318