Download tests/migrator.test.ts from hongcoding/agentlens: direct link, hf CLI and curl.
- Browser
- Download file 2.93 kB
-
https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/tests/migrator.test.ts
- Command line
-
hf download hf://datasets/hongcoding/agentlens/tests/migrator.test.ts
-
curl -L -o migrator.test.ts https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/tests/migrator.test.ts
2.93 kB
| import { describe, it, expect } from "vitest"; | |
| import { generateConfig, outputFileFor } from "../src/migrator/generate.js"; | |
| import type { Rule } from "../src/core/types.js"; | |
| const sampleRules: Rule[] = [ | |
| { | |
| id: "r1", | |
| category: "style", | |
| content: "Use TypeScript strict mode", | |
| scope: "project", | |
| source: { agent: "claude", file: "CLAUDE.md" }, | |
| status: "active", | |
| }, | |
| { | |
| id: "r2", | |
| category: "constraint", | |
| content: "Never commit secrets to the repository", | |
| scope: "project", | |
| source: { agent: "claude", file: "CLAUDE.md" }, | |
| status: "active", | |
| }, | |
| { | |
| id: "r3", | |
| category: "tooling", | |
| content: "Use pnpm as package manager", | |
| scope: "project", | |
| source: { agent: "claude", file: "CLAUDE.md" }, | |
| status: "active", | |
| }, | |
| ]; | |
| describe("generateConfig", () => { | |
| it("generates Claude format with markdown structure", () => { | |
| const output = generateConfig(sampleRules, "claude"); | |
| expect(output).toContain("# Project Rules"); | |
| expect(output).toContain("## Code Style"); | |
| expect(output).toContain("- Use TypeScript strict mode"); | |
| expect(output).toContain("## Constraints"); | |
| expect(output).toContain("- Never commit secrets to the repository"); | |
| expect(output).toContain("## Tools & Dependencies"); | |
| }); | |
| it("generates Cursor .mdc format with frontmatter", () => { | |
| const output = generateConfig(sampleRules, "cursor"); | |
| expect(output).toContain("---"); | |
| expect(output).toContain("description: Migrated rules"); | |
| expect(output).toContain("globs:"); | |
| expect(output).toContain("- Use TypeScript strict mode"); | |
| expect(output).toContain("- Never commit secrets to the repository"); | |
| }); | |
| it("generates Codex AGENTS.md format", () => { | |
| const output = generateConfig(sampleRules, "codex"); | |
| expect(output).toContain("# Agent Instructions"); | |
| expect(output).toContain("## Code Style"); | |
| expect(output).toContain("- Use pnpm as package manager"); | |
| }); | |
| it("generates Windsurf plain markdown", () => { | |
| const output = generateConfig(sampleRules, "windsurf"); | |
| expect(output).toContain("# Project Rules"); | |
| expect(output).toContain("- Never commit secrets to the repository"); | |
| }); | |
| it("generates Copilot instructions format", () => { | |
| const output = generateConfig(sampleRules, "copilot"); | |
| expect(output).toContain("# Project Rules"); | |
| expect(output).toContain("- Use TypeScript strict mode"); | |
| }); | |
| }); | |
| describe("outputFileFor", () => { | |
| it("returns correct file paths for each agent", () => { | |
| expect(outputFileFor("claude")).toBe("CLAUDE.md"); | |
| expect(outputFileFor("cursor")).toBe(".cursor/rules/agentlens.mdc"); | |
| expect(outputFileFor("codex")).toBe("AGENTS.md"); | |
| expect(outputFileFor("windsurf")).toBe(".windsurfrules"); | |
| expect(outputFileFor("copilot")).toBe(".github/copilot-instructions.md"); | |
| expect(outputFileFor("generic")).toBe("agentlens-rules.md"); | |
| }); | |
| }); | |