Download src/core/dedupe.ts from hongcoding/agentlens: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/src/core/dedupe.ts
- Command line
-
hf download hf://datasets/hongcoding/agentlens/src/core/dedupe.ts
-
curl -L -o dedupe.ts https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/src/core/dedupe.ts
655 Bytes
| import type { Rule } from "./types.js"; | |
| /** | |
| * Collapse rules with identical normalized content, keeping the first. | |
| * Needed because some agents expose more than one rule source (e.g. DSH reads | |
| * both the project AGENTS.md and the global bot-team state file), and writing | |
| * every duplicate back would grow the file on each migration. | |
| */ | |
| export function dedupeRules(rules: Rule[]): Rule[] { | |
| const seen = new Set<string>(); | |
| const out: Rule[] = []; | |
| for (const rule of rules) { | |
| const key = rule.content.replace(/\s+/g, " ").trim(); | |
| if (key.length === 0 || seen.has(key)) continue; | |
| seen.add(key); | |
| out.push(rule); | |
| } | |
| return out; | |
| } | |