Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(tests): follow multiline repository anchor bindings
MagicLizi9a0f60371a7f
diff --git a/scripts/__tests__/check-test-hygiene.test.mjs b/scripts/__tests__/check-test-hygiene.test.mjsindex 3dbdb4b083..15cc7c80f2 100644--- a/scripts/__tests__/check-test-hygiene.test.mjs+++ b/scripts/__tests__/check-test-hygiene.test.mjs@@ -315,6 +315,16 @@ test("scanTestSource counts only unjustified hits for each rule", () => {"const agentsRoot = resolve(__dirname, '..'); const source = readFileSync(resolve(agentsRoot, 'agents', 'index.ts'), 'utf8');",{ sourceReads: 1 },],+ [+ "multiline anchor bindings retain their complete initializer",+ "const agentsRoot = resolve(\n __dirname, '..',\n); const mainRoot = join(\n agentsRoot, 'main',\n); const source = readFileSync(resolve(mainRoot, 'index.ts'), 'utf8');",+ { sourceReads: 1 },+ ],+ [+ "semicolon-free fixture declarations do not absorb a later repository anchor",+ "const fixtureRoot = mkdtempSync(join(tmpdir(), 'fixture-'))\nconst agentsRoot = resolve(\n __dirname, '..',\n)\nconst source = readFileSync(resolve(fixtureRoot, 'index.ts'), 'utf8');",+ { sourceReads: 0 },+ ],["domain object pause is not a real wait", "const meter = { pause(ms) {} }; meter.pause(1_000);", { realWaits: 0 }],["domain object sleep is not a real wait", "const sleeper = { sleep(ms) {} }; sleeper.sleep(1_000);", { realWaits: 0 }],];diff --git a/scripts/check-test-hygiene.mjs b/scripts/check-test-hygiene.mjsindex 8b23702a1e..229b29d7fd 100644--- a/scripts/check-test-hygiene.mjs+++ b/scripts/check-test-hygiene.mjs@@ -768,21 +768,29 @@ const REPO_ANCHOR = /__dirname|import\.meta\.(?:url|dirname)|process\.cwd\s*\(\s* arbitrary expressions or cross module boundaries.*/function findRepoAnchorNames(code) {+ const ts = typescript ??= requireDesktop('typescript');+ const source = parseTestSource(ts, code);+ const declarations = [];+ const collect = node => {+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {+ declarations.push({ name: node.name.text, rhs: node.initializer.getText(source) });+ }+ ts.forEachChild(node, collect);+ };+ collect(source);const names = new Set();let changed = true;while (changed) {changed = false;- const declarations = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+)/g;- for (const match of code.matchAll(declarations)) {- const rhs = match[2];+ for (const { name, rhs } of declarations) {const identifiers = rhs.match(/\b[A-Za-z_$][\w$]*\b/g) ?? [];const pathFactory = /^\s*(?:new\s+)?(?:resolve|join|URL)\s*\(/.test(rhs);const directAnchor = /^\s*(?:__dirname|import\.meta\.(?:url|dirname)|process\.cwd\s*\(\s*\)|REPO_ROOT|repoRoot|desktopRoot)\b/.test(rhs);const alias = /^\s*[A-Za-z_$][\w$]*\s*$/.test(rhs);if ((directAnchor || pathFactory && (REPO_ANCHOR.test(rhs) || identifiers.some(identifier => names.has(identifier)))|| alias && identifiers.some(identifier => names.has(identifier)))- && !names.has(match[1])) {- names.add(match[1]);+ && !names.has(name)) {+ names.add(name);changed = true;}}