mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 10:33:18 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
108
openclaw/test/vitest/vitest.pattern-file.ts
Normal file
108
openclaw/test/vitest/vitest.pattern-file.ts
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
function normalizeCliPattern(value: string): string {
|
||||
let normalized = value
|
||||
.trim()
|
||||
.replace(/^\.\/+/u, "")
|
||||
.replace(/\/+$/u, "");
|
||||
if (
|
||||
/^(?:src|test|extensions|ui|packages|apps)(?:\/|$)/u.test(normalized) &&
|
||||
!/[?*[\]{}]/u.test(normalized) &&
|
||||
!/\.(?:[cm]?[jt]sx?)$/u.test(normalized)
|
||||
) {
|
||||
normalized = `${normalized}/**/*.test.*`;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function looksLikeCliIncludePattern(value: string): boolean {
|
||||
const normalized = normalizeCliPattern(value);
|
||||
return (
|
||||
normalized.includes(".test.") ||
|
||||
normalized.includes(".e2e.") ||
|
||||
normalized.includes(".live.") ||
|
||||
/^(?:src|test|extensions|ui|packages|apps)(?:\/|$)/u.test(normalized)
|
||||
);
|
||||
}
|
||||
|
||||
export function loadPatternListFile(filePath: string, label: string): string[] {
|
||||
const parsed = JSON.parse(fs.readFileSync(filePath, "utf8")) as unknown;
|
||||
if (!Array.isArray(parsed)) {
|
||||
throw new TypeError(`${label} must point to a JSON array: ${filePath}`);
|
||||
}
|
||||
return parsed.filter((value): value is string => typeof value === "string" && value.length > 0);
|
||||
}
|
||||
|
||||
export function loadPatternListFromEnv(
|
||||
envKey: string,
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
): string[] | null {
|
||||
const filePath = env[envKey]?.trim();
|
||||
if (!filePath) {
|
||||
return null;
|
||||
}
|
||||
return loadPatternListFile(filePath, envKey);
|
||||
}
|
||||
|
||||
export function loadPatternListFromArgv(argv: string[] = process.argv): string[] | null {
|
||||
const optionValueFlags = new Set([
|
||||
"-c",
|
||||
"-r",
|
||||
"-t",
|
||||
"--config",
|
||||
"--dir",
|
||||
"--environment",
|
||||
"--exclude",
|
||||
"--maxWorkers",
|
||||
"--mode",
|
||||
"--outputFile",
|
||||
"--pool",
|
||||
"--project",
|
||||
"--reporter",
|
||||
"--root",
|
||||
"--shard",
|
||||
"--testNamePattern",
|
||||
]);
|
||||
const values: string[] = [];
|
||||
let skipNext = false;
|
||||
for (const value of argv.slice(2)) {
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
continue;
|
||||
}
|
||||
if (value === "run" || value === "watch" || value === "bench") {
|
||||
continue;
|
||||
}
|
||||
if (optionValueFlags.has(value)) {
|
||||
skipNext = true;
|
||||
continue;
|
||||
}
|
||||
if (value.startsWith("-")) {
|
||||
continue;
|
||||
}
|
||||
values.push(value);
|
||||
}
|
||||
|
||||
const patterns = values.filter(looksLikeCliIncludePattern).map(normalizeCliPattern);
|
||||
|
||||
return patterns.length > 0 ? [...new Set(patterns)] : null;
|
||||
}
|
||||
|
||||
export function narrowIncludePatternsForCli(
|
||||
includePatterns: string[],
|
||||
argv: string[] = process.argv,
|
||||
): string[] | null {
|
||||
const cliPatterns = loadPatternListFromArgv(argv);
|
||||
if (!cliPatterns) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const matched = cliPatterns.filter((value) =>
|
||||
includePatterns.some(
|
||||
(pattern) => path.matchesGlob(value, pattern) || path.matchesGlob(pattern, value),
|
||||
),
|
||||
);
|
||||
|
||||
return [...new Set(matched)];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue