Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(pi): 同名 skill 里直接项排在嵌套命名空间前
Zhang Yunjind1214b719492
diff --git a/packages/maker-core/src/agents/pi/__tests__/customization-scanner.test.ts b/packages/maker-core/src/agents/pi/__tests__/customization-scanner.test.tsindex 3a0c8f699d..4b16d95826 100644--- a/packages/maker-core/src/agents/pi/__tests__/customization-scanner.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/customization-scanner.test.ts@@ -123,6 +123,23 @@ describe('scanPiCustomizations', () => {expect(items.every((item) => item.workingDir === path.resolve(cwd))).toBe(true);});+ it('prefers a top-level skill over a nested namespace skill with the same name', async () => {+ // `.agents/skills/foo` 与 `.agents/skills/bar/foo` 同名很常见。按目录名排序时+ // `bar` 在前,嵌套项会被下游 mergeCommands(保留靠前者)选中,面板显示嵌套项的+ // 描述与详情路径,共享投影 / 远程扫描 / `/learn` 却选直接项。+ const root = tempRoot();+ const repo = path.join(root, 'repo');+ mkdirSync(path.join(repo, '.git'), { recursive: true });+ const direct = writeSkill(repo, path.join('.agents', 'skills'), 'foo');+ writeSkill(repo, path.join('.agents', 'skills', 'bar'), 'foo');++ const result = await scanPiCustomizations({ workingDirs: [repo] });+ const foos = projectItems(result).filter((item) => item.name === 'foo');++ expect(foos.length).toBeGreaterThanOrEqual(2);+ expect(canonical(foos[0]!.absolutePath)).toBe(canonical(direct));+ });+it('stops ancestor discovery at a nested repository root', async () => {const root = tempRoot();const outer = path.join(root, 'outer');diff --git a/packages/maker-core/src/agents/pi/customization-scanner.ts b/packages/maker-core/src/agents/pi/customization-scanner.tsindex ae0fd12133..7f6515183a 100644--- a/packages/maker-core/src/agents/pi/customization-scanner.ts+++ b/packages/maker-core/src/agents/pi/customization-scanner.ts@@ -130,6 +130,12 @@ export async function scanPiCustomizations(opts: ListCustomizationsOptions): Proresult.items.sort((a, b) => {if (a.scope !== b.scope) return a.scope.localeCompare(b.scope);if (a.name !== b.name) return a.name.localeCompare(b.name);+ // 同名时直接项优先:`<root>/<skill>` 比 `<root>/<namespace>/<skill>` 浅,下游+ // mergeCommands 保留名单里靠前的那条。按路径字典序排会把命名空间(bar/foo)排在+ // 前面,面板就显示嵌套项的描述与详情路径,而共享投影 / 远程扫描 / `/learn` 选直接项。+ const depth = (value: string) => value.split(/[\\/]/).length;+ const depthDiff = depth(a.absolutePath) - depth(b.absolutePath);+ if (depthDiff !== 0) return depthDiff;return a.absolutePath.localeCompare(b.absolutePath);});return result;