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

推荐订阅源

博客园_首页
Vercel News
Vercel News
月光博客
月光博客
S
SegmentFault 最新的问题
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
小众软件
小众软件
WordPress大学
WordPress大学
G
Google Developers Blog
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
博客园 - 【当耐特】
I
InfoQ

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 message turn guardrails · opencl...
vincentkoc · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,7 +1,8 @@

1-

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

1+

import { spawnSync } from "node:child_process";

2+

import fs from "node:fs";

23

import path from "node:path";

34

import { fileURLToPath } from "node:url";

4-

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

5+

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

5667

const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");

78

@@ -69,20 +70,50 @@ const skippedExtensionScanDirs = new Set([

6970

]);

70717172

function readRepoFile(relativePath: string): string {

72-

return readFileSync(path.join(repoRoot, ...relativePath.split("/")), "utf8");

73+

return fs.readFileSync(path.join(repoRoot, ...relativePath.split("/")), "utf8");

74+

}

75+76+

function isScannableTsFile(relativePath: string): boolean {

77+

const parts = relativePath.split("/");

78+

return (

79+

!parts.some((part) => skippedExtensionScanDirs.has(part)) &&

80+

relativePath.endsWith(".ts") &&

81+

!relativePath.endsWith(".d.ts")

82+

);

83+

}

84+85+

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

86+

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

87+

cwd: repoRoot,

88+

encoding: "utf8",

89+

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

90+

});

91+

if (result.status !== 0) {

92+

return null;

93+

}

94+

return result.stdout

95+

.split("\n")

96+

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

97+

.filter((line) => line.length > 0 && isScannableTsFile(line))

98+

.toSorted();

7399

}

7410075101

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

102+

const gitFiles = listGitTsFiles(relativeDir);

103+

if (gitFiles) {

104+

return gitFiles;

105+

}

106+76107

const dir = path.join(repoRoot, ...relativeDir.split("/"));

77-

return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {

108+

return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {

78109

const relativePath = path.posix.join(relativeDir, entry.name);

79110

if (entry.isDirectory()) {

80111

if (skippedExtensionScanDirs.has(entry.name)) {

81112

return [];

82113

}

83114

return listTsFiles(relativePath);

84115

}

85-

if (!entry.isFile() || !entry.name.endsWith(".ts") || entry.name.endsWith(".d.ts")) {

116+

if (!entry.isFile() || !isScannableTsFile(relativePath)) {

86117

return [];

87118

}

88119

return [relativePath];

@@ -103,6 +134,20 @@ function collectReplyHistoryBindings(source: string): Set<string> {

103134

}

104135105136

describe("message turn migration guardrails", () => {

137+

it("lists plugin TypeScript files from git without walking extension roots", () => {

138+

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

139+

try {

140+

const files = listTsFiles("extensions");

141+142+

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

143+

expect(files.every((file) => file.startsWith("extensions/"))).toBe(true);

144+

expect(files.some((file) => file.endsWith(".d.ts"))).toBe(false);

145+

expect(readDir).not.toHaveBeenCalled();

146+

} finally {

147+

readDir.mockRestore();

148+

}

149+

});

150+106151

it("keeps migrated message paths off low-level reply-history helpers", () => {

107152

for (const file of migratedMessageTurnFiles) {

108153

const source = readRepoFile(file);