@@ -69,6 +69,29 @@ describe("loadCustomCommands", () => {
6969 expect(result.get("search")?.description).toBe("local");
7070 expect(result.get("search")?.source).toBe("local");
7171 });
72+
73+ test("loads context: fork from frontmatter", () => {
74+ writeCmd(
75+ dir,
76+ "deploy",
77+ "---\ndescription: Deploy\ncontext: fork\n---\n\nDeploy it",
78+ );
79+ expect(loadCustomCommands(dir).get("deploy")?.context).toBe("fork");
80+ });
81+
82+ test("context is undefined when not specified", () => {
83+ writeCmd(dir, "plain", "---\ndescription: Plain\n---\n\nDo it");
84+ expect(loadCustomCommands(dir).get("plain")?.context).toBeUndefined();
85+ });
86+
87+ test("loads subtask: true from frontmatter", () => {
88+ writeCmd(
89+ dir,
90+ "analyze",
91+ "---\ndescription: Analyze\nsubtask: true\n---\n\nAnalyze it",
92+ );
93+ expect(loadCustomCommands(dir).get("analyze")?.subtask).toBe(true);
94+ });
7295 });
7396
7497 // ─── expandTemplate ───────────────────────────────────────────────────────────
@@ -147,3 +170,50 @@ describe("expandTemplate", () => {
147170 expect(out).toBe("plain text");
148171 });
149172 });
173+
174+// ─── @file reference expansion ───────────────────────────────────────────────
175+
176+describe("expandTemplate @file references", () => {
177+ let dir: string;
178+
179+ beforeEach(() => {
180+ dir = mkdtempSync(join(tmpdir(), "mc-fileref-test-"));
181+ });
182+
183+ afterEach(() => {
184+ rmSync(dir, { recursive: true, force: true });
185+ });
186+
187+ test("replaces @file with code-fenced content", async () => {
188+ writeFileSync(join(dir, "hello.txt"), "world");
189+ const out = await expandTemplate("see @hello.txt for details", "", dir);
190+ expect(out).toBe("see `hello.txt`:\n```\nworld\n``` for details");
191+ });
192+
193+ test("leaves @token unchanged when file does not exist", async () => {
194+ const out = await expandTemplate("@nonexistent.ts", "", dir);
195+ expect(out).toBe("@nonexistent.ts");
196+ });
197+
198+ test("handles nested path like @src/foo.ts", async () => {
199+ mkdirSync(join(dir, "src"), { recursive: true });
200+ writeFileSync(join(dir, "src", "foo.ts"), "export const x = 1;");
201+ const out = await expandTemplate("review @src/foo.ts please", "", dir);
202+ expect(out).toBe(
203+ "review `src/foo.ts`:\n```\nexport const x = 1;\n``` please",
204+ );
205+ });
206+
207+ test("non-file @tokens (e.g. email) are left intact", async () => {
208+ // no file named "user@example.com" or "example.com" exists in cwd
209+ const out = await expandTemplate("contact user@example.com", "", dir);
210+ expect(out).toBe("contact user@example.com");
211+ });
212+
213+ test("multiple @file refs in one template are all replaced", async () => {
214+ writeFileSync(join(dir, "a.md"), "AAA");
215+ writeFileSync(join(dir, "b.md"), "BBB");
216+ const out = await expandTemplate("@a.md and @b.md", "", dir);
217+ expect(out).toBe("`a.md`:\n```\nAAA\n``` and `b.md`:\n```\nBBB\n```");
218+ });
219+});