import test from "node:test"; import assert from "node:assert/strict"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import extension, { projectClaudeDirs } from "../claude-plugin-commands.ts"; test("native Markdown slash commands omit author comments before Pi sends them", async () => { const root = mkdtempSync(join(tmpdir(), "claude-plugin-commands-")); try { const prompts = join(root, ".pi", "prompts"); mkdirSync(prompts, { recursive: true }); writeFileSync(join(prompts, "comment-regression.md"), "---\ndescription: test\n---\n\n\nDo $ARGUMENTS.\n```html\n\n```\n"); const handlers: Array<(event: any, ctx: any) => Promise> = []; extension({ on(event: string, handler: any) { if (event === "input") handlers.push(handler); } } as any); let text = "/comment-regression topic"; for (const handler of handlers) { const result = await handler({ source: "interactive", text }, { cwd: root }); if (result.action === "transform") text = result.text; } assert.equal(text, "Do topic.\n```html\n\n```"); } finally { rmSync(root, { recursive: true, force: true }); } }); test("projectClaudeDirs widens discovery to profile projects while keeping cwd first and deduplicated", () => { const root = mkdtempSync(join(tmpdir(), "claude-plugin-commands-")); try { const current = join(root, "current"); const nestedCwd = join(current, "packages", "app"); const profiled = join(root, "profiled"); const currentClaude = join(current, ".claude"); const profiledClaude = join(profiled, ".claude"); mkdirSync(join(current, ".git"), { recursive: true }); mkdirSync(join(currentClaude, "commands"), { recursive: true }); mkdirSync(nestedCwd, { recursive: true }); mkdirSync(join(profiled, ".git"), { recursive: true }); mkdirSync(join(profiledClaude, "skills"), { recursive: true }); assert.deepEqual(projectClaudeDirs(nestedCwd, [profiled, current]), [currentClaude, profiledClaude]); } finally { rmSync(root, { recursive: true, force: true }); } });