From 7f5eae338596d404357445a4f0f6b6e9de3eeadd Mon Sep 17 00:00:00 2001 From: Furkan Date: Sun, 8 Nov 2026 11:10:56 +0300 Subject: [PATCH 1/4] Model Copilot on what Copilot CLI loads; skip a CLAUDE.md over 4 MiB - Copilot follows Copilot CLI 1.0.107 as observed with scripts/observe.mjs (62 of 62 checks) instead of the legacy VS Code Local harness: GEMINI.md with AGENTS.md and CLAUDE.md, nested copies on demand, @imports in AGENTS.md and CLAUDE.md, .claude/rules without paths and instructions without applyTo every turn, no .claude/CLAUDE.md or CLAUDE.local.md - A root CLAUDE.md over 4 MiB counts as not loaded for Claude Code, with the reason as a finding - observe.mjs checks Copilot CLI (project codes, its skills_loaded event, --trust-folder), records each answer, and --keep keeps the fixtures --- CHANGELOG.md | 10 +++++ README.md | 2 +- docs/how-it-counts.md | 29 +++++++------ scripts/observe.mjs | 93 ++++++++++++++++++++++++++++++++++++---- src/core/classify.ts | 12 ++++-- src/core/tools.ts | 54 ++++++++++++----------- src/core/user.ts | 2 - test/agents.test.ts | 13 ++++++ test/classify.test.ts | 56 ++++++++++++++++++------ test/fix.test.ts | 19 ++++---- test/user.test.ts | 5 ++- test/vscode-view.test.ts | 12 ++++-- 12 files changed, 226 insertions(+), 81 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22fc797..e9cd95a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## Unreleased + +- GitHub Copilot is modelled on what Copilot CLI 1.0.107 loads, checked with `scripts/observe.mjs` (62 of 62 checks), instead of the legacy VS Code Local harness. VS Code's Copilot harness shares that runtime. Counts change: + - `GEMINI.md` is read with `AGENTS.md` and `CLAUDE.md`, and nested copies of all three load when Copilot works in their folder. + - `@imports` in `AGENTS.md` and `CLAUDE.md` are followed. + - `.claude/rules` without `paths` and instructions files without `applyTo` or with `applyTo: **` load every turn. + - `.claude/CLAUDE.md` and `CLAUDE.local.md` are not read. +- A root `CLAUDE.md` over 4 MiB counts as not loaded for Claude Code, which skips it, and the finding says so. +- `scripts/observe.mjs` checks Copilot CLI too, and `--keep` keeps the fixtures for a closer look. + ## 0.9.0 (2026-11-06) - Claude Code's rules were also checked against Claude Code 2.1.296 itself. In three setups, the model reported all 41 checks as turntax counts them. `scripts/observe.mjs` runs the check, and [docs/how-it-counts.md](docs/how-it-counts.md) has the results. diff --git a/README.md b/README.md index 41b3420..8d8fa56 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Each agent's documented loading rules decide what is sent on every turn, what lo | Devin Local / Devin CLI | `AGENTS.md`, `AGENTS.local.md`, `AGENT.md`, `.windsurfrules`, `CLAUDE.md` at every level, `.devin/rules/`, `.windsurf/rules/`, `.cursor/rules/`, skills | | Factory Droid | `AGENTS.md` / `CLAUDE.md` (also in `.factory`, `.agents`, `.agent`), `DESIGN.md`, `.factory/skills`, `.agents/skills`, `.factory/droids` | | Gemini CLI | `GEMINI.md`, skills in `.agents` and `.gemini` | -| GitHub Copilot | `.github/copilot-instructions.md`, `.github/instructions/`, `AGENTS.md`, `CLAUDE.md`, `.claude/rules`, skills in `.github`, `.claude`, `.agents` (VS Code Local harness defaults) | +| GitHub Copilot | `.github/copilot-instructions.md`, `.github/instructions/`, `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.claude/rules`, skills in `.github`, `.claude`, `.agents` (as Copilot CLI loads them) | | Goose | `.goosehints`, `AGENTS.md`, `@`-included files, skills in `.agents`, `.goose`, `.claude` | | Google Jules | root `AGENTS.md` | | JetBrains Junie | `.junie/AGENTS.md`, or `AGENTS.md` with `.junie/rules/`, or `.junie/guidelines`; skills in `.junie`, `.agents` | diff --git a/docs/how-it-counts.md b/docs/how-it-counts.md index f735347..bb10f4b 100644 --- a/docs/how-it-counts.md +++ b/docs/how-it-counts.md @@ -22,6 +22,8 @@ The rules come from the vendors' docs. [`scripts/observe.mjs`](../scripts/observ | Agent | Version | Date | Result | | --- | --- | --- | --- | | Claude Code | 2.1.296 | 2026-11-06 | 41 of 41 checks as turntax expects, in three setups | +| Claude Code | 2.1.296 | 2026-11-08 | 39 of 41: the description of a command was missing twice (see below) | +| GitHub Copilot CLI | 1.0.107 | 2026-11-08 | 62 of 62 in two setups, twice, after turntax took up what the CLI loads | | OpenAI Codex | | | not run yet | In Claude Code, started at the root of the repository: @@ -31,7 +33,11 @@ In Claude Code, started at the root of the repository: After Claude reads a file in a subfolder, that folder's `CLAUDE.md` and a rule with `paths` for it load too. With `AGENTS.md` and no `CLAUDE.md`, `AGENTS.md` loads. -To run the check yourself, install and sign in to the agents, then run `npm run build` and `node scripts/observe.mjs`. Each setup is one short prompt on your own account. +On 2026-11-08 Claude Code listed the command by name with no description. Its skill listing is capped at 1% of the context window, and past that it drops the descriptions of the least-used entries; the account used for the run had many plugin skills. turntax counts every description and does not apply that cap. + +Copilot CLI did not list what its instructions say when asked, so each Copilot fixture file gives it a project code to repeat, and the skills it lists are read from the CLI's own `session.skills_loaded` event. The first run disagreed with turntax's model of the VS Code Local harness in 14 of 31 checks at the root; turntax now models what the CLI loads, described under [GitHub Copilot](#github-copilot). Copilot CLI loads repository instructions only in a folder you trust; the script passes `--trust-folder`. + +To run the check yourself, install and sign in to the agents, then run `npm run build` and `node scripts/observe.mjs` (`--agents claude-code,copilot,codex` picks some, `--keep` keeps the fixtures). Each setup is one short prompt on your own account. ## Claude Code @@ -97,24 +103,23 @@ Which skill folder wins on a name clash is not documented; `.agents`, `.cursor`, Sources: VS Code [custom instructions](https://code.visualstudio.com/docs/agent-customization/custom-instructions), [settings](https://code.visualstudio.com/docs/agents/reference/ai-settings) and [skills](https://code.visualstudio.com/docs/agent-customization/agent-skills); GitHub [repository instructions](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions/add-repository-instructions), [Copilot CLI instructions](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-custom-instructions), [support by surface](https://docs.github.com/en/copilot/reference/custom-instructions-support) and [skills](https://docs.github.com/en/copilot/concepts/agents/about-agent-skills) -Copilot surfaces read different files. turntax models the defaults of VS Code's Local harness (the `chat.useAgentsMdFile`, `chat.useClaudeMdFile` and `chat.useNestedAgentsMdFiles` settings are documented for Local harness sessions): +Copilot surfaces read different files. turntax models Copilot CLI 1.0.107 as observed on 2026-11-08 (see [Checked against the agents](#checked-against-the-agents)). VS Code's Copilot harness shares the Copilot CLI runtime ([agent harnesses](https://code.visualstudio.com/docs/agents/concepts/agent-harnesses)), so it is assumed to read the same files. | File | Mode | | --- | --- | -| `.github/copilot-instructions.md` | always | -| `.github/instructions/**/*.instructions.md` | `applyTo` on-demand; `description` only: description always, body on-demand; neither: manual | -| `AGENTS.md` at the root | always (`chat.useAgentsMdFile`, on by default) | -| `CLAUDE.md`, `.claude/CLAUDE.md`, `CLAUDE.local.md` at the root | always (`chat.useClaudeMdFile`, on by default), together with `AGENTS.md` | -| `.claude/rules/**/*.md` | on-demand: `paths`, which defaults to `**` | -| `AGENTS.md` or `CLAUDE.md` in a subdirectory | ignored (nested `AGENTS.md` needs `chat.useNestedAgentsMdFiles`, off by default) | +| `.github/copilot-instructions.md` | always; `@imports` in it are not followed | +| `.github/instructions/**/*.instructions.md` | always without `applyTo` or with `applyTo: **`; other `applyTo` on-demand | +| `AGENTS.md`, `CLAUDE.md` and `GEMINI.md` at the root | always, all together; `@imports` in `AGENTS.md` and `CLAUDE.md` are followed (at least six hops were) | +| `AGENTS.md`, `CLAUDE.md` or `GEMINI.md` in a subdirectory | on-demand, when Copilot works on a file there | +| `.claude/rules/**/*.md` | always without `paths`; on-demand with `paths` | +| `.claude/CLAUDE.md`, `CLAUDE.local.md` | ignored | | `.github/skills/*/SKILL.md`, `.claude/skills/*/SKILL.md`, `.agents/skills/*/SKILL.md` | description always; body on-demand; `disable-model-invocation: true` manual; same-name skills in two folders are both counted | -Treating a description-only instructions file's description as always in context is an inference; VS Code says the agent decides from it. VS Code does not expand `@imports`. Other surfaces: +The docs say less than this, and in places differ: Copilot CLI's page also lists `.claude/CLAUDE.md` and imports in `copilot-instructions.md`, which the CLI did not read when observed, and no page says that an instructions file without `applyTo` loads every turn. Other surfaces: -- Copilot CLI reads `AGENTS.md`, `CLAUDE.md`, `.claude/CLAUDE.md` and `GEMINI.md` from the repository root, the working directory, the folders between and the folders of files it works on, combines them all, and expands `@path` references in `copilot-instructions.md`, `AGENTS.md` and `CLAUDE.md`. +- The legacy VS Code Local harness reads `CLAUDE.md`, `.claude/CLAUDE.md` and `CLAUDE.local.md` at the root, `.claude/rules` on demand, nested `AGENTS.md` only with `chat.useNestedAgentsMdFiles` (off by default), and no `GEMINI.md`. It also reads `~/.claude/CLAUDE.md` and `~/.claude/rules`, which are not counted. - Copilot cloud agent uses the nearest `AGENTS.md`, or a single root `CLAUDE.md` or `GEMINI.md` instead. -- VS Code's Copilot harness shares the Copilot CLI runtime ([agent harnesses](https://code.visualstudio.com/docs/agents/concepts/agent-harnesses)), so it is assumed to read what the CLI reads, `GEMINI.md` included. `GEMINI.md` is not counted for Copilot, because the Local harness modelled here does not document it. -- Copilot code review also reads `REVIEW.md` and uses only skills in `.github/skills`. +- Copilot code review also reads `REVIEW.md`. ## Windsurf Cascade diff --git a/scripts/observe.mjs b/scripts/observe.mjs index edefd0f..b2d2352 100644 --- a/scripts/observe.mjs +++ b/scripts/observe.mjs @@ -4,13 +4,13 @@ * is asked, without tools, which markers are in its context, and the answer is compared with what turntax says the * agent loads. Needs the agents installed and signed in; each run is a short prompt on your own account. * - * npm run build && node scripts/observe.mjs [--agents claude-code,codex] [--out results.json] + * npm run build && node scripts/observe.mjs [--agents claude-code,copilot,codex] [--out results.json] [--keep] */ import { spawnSync } from 'node:child_process'; import { randomBytes } from 'node:crypto'; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; -import { dirname, join } from 'node:path'; +import { dirname, join, resolve } from 'node:path'; import { parseArgs } from 'node:util'; const { classify } = await import('../dist/core/classify.js'); @@ -21,6 +21,11 @@ const ASK = [ 'Output every distinct string that starts with CANARY- exactly as written, one per line, and nothing else. If there is none, output NONE.', ].join(' '); const ASK_AFTER_READ = `Use your file reading tool once to read pkg/note.txt. Then, with no other tool use, output every distinct string that starts with CANARY- that is now in your context, exactly as written, one per line, and nothing else.`; +// Copilot will not list what its instructions contain, but it follows them: each file gives a project code to repeat. +const ASK_CODES = 'Without using any tools, list every project code you were given, one per line, and nothing else. If you were given none, output NONE.'; +const ASK_CODES_AFTER_READ = + 'Use your file reading tool once to read pkg/note.ts. Then, with no other tool use, list every project code you were given, including any that came with that file, one per line, and nothing else.'; +const pc = (name) => `Project code: ${m(name)}. When the user asks for the project codes, reply with every project code you were given.\n`; /** Marker token -> marker name. Each marker gets its own random part, so an agent cannot guess one from another. */ const MARKERS = new Map(); @@ -67,6 +72,7 @@ const SCENARIOS = [ title: 'Claude Code, after reading a file in pkg/', sameFilesAs: 'claude-start', ask: ASK_AFTER_READ, + readsFile: true, // turntax: pkg/CLAUDE.md and a rule with paths: pkg/** load once Claude reads a file there. expect: (start) => [...start, 'CC-NESTED', 'CC-RULE-SCOPED'], }, @@ -76,6 +82,53 @@ const SCENARIOS = [ title: 'Claude Code, AGENTS.md and no CLAUDE.md', files: { 'AGENTS.md': `${m('CC-AGENTS-ONLY')}\n` }, }, + { + id: 'copilot-start', + tool: 'copilot', + title: 'Copilot CLI, started at the root', + ask: ASK_CODES, + files: { + '.github/copilot-instructions.md': `${pc('CP-REPO-INSTRUCTIONS')}\n@docs/from-copilot.md\n`, + 'docs/from-copilot.md': pc('CP-IMPORT-FROM-COPILOT'), + '.github/instructions/all.instructions.md': `---\napplyTo: "**"\n---\n${pc('CP-INSTRUCTIONS-ALL')}`, + '.github/instructions/ts.instructions.md': `---\napplyTo: "**/*.ts"\n---\n${pc('CP-INSTRUCTIONS-TS')}`, + '.github/instructions/sub/deep.instructions.md': `---\napplyTo: "**"\n---\n${pc('CP-INSTRUCTIONS-DEEP')}`, + '.github/instructions/plain.instructions.md': pc('CP-INSTRUCTIONS-PLAIN'), + 'AGENTS.md': `${pc('CP-AGENTS')}\n@docs/i1.md\n`, + 'docs/i1.md': `${pc('CP-IMPORT-1')}\n@i2.md\n`, + 'docs/i2.md': `${pc('CP-IMPORT-2')}\n@i3.md\n`, + 'docs/i3.md': `${pc('CP-IMPORT-3')}\n@i4.md\n`, + 'docs/i4.md': `${pc('CP-IMPORT-4')}\n@i5.md\n`, + 'docs/i5.md': `${pc('CP-IMPORT-5')}\n@i6.md\n`, + 'docs/i6.md': pc('CP-IMPORT-6'), + 'CLAUDE.md': `${pc('CP-CLAUDE')}\n@docs/from-claude.md\n`, + 'docs/from-claude.md': pc('CP-IMPORT-FROM-CLAUDE'), + '.claude/CLAUDE.md': pc('CP-DOTCLAUDE'), + 'CLAUDE.local.md': pc('CP-LOCAL'), + 'GEMINI.md': pc('CP-GEMINI'), + '.claude/rules/always.md': pc('CP-CLAUDE-RULE'), + '.claude/rules/scoped.md': `---\npaths:\n - "pkg/**"\n---\n${pc('CP-CLAUDE-RULE-SCOPED')}`, + 'pkg/AGENTS.md': pc('CP-NESTED-AGENTS'), + 'pkg/CLAUDE.md': pc('CP-NESTED-CLAUDE'), + 'pkg/GEMINI.md': pc('CP-NESTED-GEMINI'), + 'pkg/note.ts': '// A note.\n', + 'pkg/.github/skills/nested-skill/SKILL.md': `---\nname: nested-skill\ndescription: Use for ${m('CP-SKILL-NESTED-DESC')} tasks only.\n---\n${pc('CP-SKILL-NESTED-BODY')}`, + '.github/skills/gh-skill/SKILL.md': `---\nname: gh-skill\ndescription: Use for ${m('CP-SKILL-GITHUB-DESC')} tasks only.\n---\n${pc('CP-SKILL-GITHUB-BODY')}`, + '.claude/skills/cl-skill/SKILL.md': `---\nname: cl-skill\ndescription: Use for ${m('CP-SKILL-CLAUDE-DESC')} tasks only.\n---\n${pc('CP-SKILL-CLAUDE-BODY')}`, + '.agents/skills/ag-skill/SKILL.md': `---\nname: ag-skill\ndescription: Use for ${m('CP-SKILL-AGENTS-DESC')} tasks only.\n---\n${pc('CP-SKILL-AGENTS-BODY')}`, + }, + }, + { + id: 'copilot-after-read', + tool: 'copilot', + title: 'Copilot CLI, after reading a .ts file in pkg/', + sameFilesAs: 'copilot-start', + ask: ASK_CODES_AFTER_READ, + readsFile: true, + // turntax: the applyTo **/*.ts instructions, the rule with paths: pkg/** and pkg/'s AGENTS.md, CLAUDE.md and GEMINI.md + // load once Copilot works on pkg/note.ts. + expect: (start) => [...start, 'CP-INSTRUCTIONS-TS', 'CP-CLAUDE-RULE-SCOPED', 'CP-NESTED-AGENTS', 'CP-NESTED-CLAUDE', 'CP-NESTED-GEMINI'], + }, { id: 'codex-start', tool: 'codex', @@ -153,6 +206,22 @@ function ask(tool, cwd, prompt, toolsAllowed) { if (out.is_error || r.status !== 0) throw new Error(`claude: ${out.result ?? `exited with ${r.status}`}`); return { text: String(out.result ?? ''), usedTools: out.num_turns > (toolsAllowed ? 2 : 1) }; } + if (tool === 'copilot') { + // --trust-folder: in an untrusted folder Copilot CLI loads no repository instructions at all. + const args = ['--no-ask-user', '--trust-folder', '--output-format', 'json', ...(toolsAllowed ? ['--allow-all-tools'] : [])]; + const r = run('copilot', args, cwd, prompt); + const events = r.stdout.split('\n').filter((l) => l.startsWith('{')).map((l) => JSON.parse(l)); + const messages = events.filter((e) => e.type === 'assistant.message').map((e) => String(e.data?.content ?? '')); + const result = events.find((e) => e.type === 'model.call_final_result'); + if (r.status !== 0 || !messages.length || result?.data?.result !== 'success') + throw new Error(`copilot exited with ${r.status} and no answer: ${r.stderr.trim().slice(0, 300)}`); + // A skill the agent loads on its own (one of your personal skills) adds no file of the fixture; a fixture skill's + // body would show up as a marker anyway. + const toolCalls = events.filter((e) => e.type.startsWith('tool.execution_start') && e.data?.toolName !== 'skill').length; + // Skill descriptions are not project codes; the CLI's own record of the skills it listed says which ones the agent got. + const skills = events.filter((e) => e.type === 'session.skills_loaded').at(-1)?.data?.skills ?? []; + return { text: messages.join('\n'), usedTools: toolCalls > (toolsAllowed ? 1 : 0), skillFiles: skills.filter((k) => k.enabled).map((k) => k.path) }; + } const r = run('codex', ['exec', '--json', '--skip-git-repo-check', '--ephemeral', '-s', 'read-only', '-'], cwd, prompt); const events = r.stdout.split('\n').filter((l) => l.startsWith('{')).map((l) => JSON.parse(l)); const failed = events.find((e) => e.type === 'turn.failed' || e.type === 'error'); @@ -168,12 +237,12 @@ function ask(tool, cwd, prompt, toolsAllowed) { } function version(tool) { - const r = run(tool === 'claude-code' ? 'claude' : 'codex', ['--version'], process.cwd()); + const r = run({ 'claude-code': 'claude', codex: 'codex', copilot: 'copilot' }[tool], ['--version'], process.cwd()); return r.stdout.trim().split('\n')[0]; } -const { values } = parseArgs({ options: { agents: { type: 'string' }, out: { type: 'string' } } }); -const agents = values.agents ? values.agents.split(',') : ['claude-code', 'codex']; +const { values } = parseArgs({ options: { agents: { type: 'string' }, out: { type: 'string' }, keep: { type: 'boolean' } } }); +const agents = values.agents ? values.agents.split(',') : ['claude-code', 'copilot', 'codex']; const base = mkdtempSync(join(tmpdir(), 'turntax-observe-')); const results = []; const byId = new Map(); @@ -185,17 +254,23 @@ try { if (!source) write(dir, files); const start = expectedAtStart(s.tool, files); const expected = s.expect ? s.expect(start).sort() : start; - const answer = ask(s.tool, join(dir, s.cwd ?? ''), s.ask ?? ASK, Boolean(s.ask)); - const observed = markersIn(answer.text); + const answer = ask(s.tool, join(dir, s.cwd ?? ''), s.ask ?? ASK, Boolean(s.readsFile)); + const listed = new Set((answer.skillFiles ?? []).map((p) => resolve(p).toLowerCase())); + const skillMarkers = Object.entries(files) + .filter(([path]) => listed.has(resolve(dir, path).toLowerCase())) + .flatMap(([, text]) => markersIn(/^description:.*$/m.exec(text)?.[0] ?? '')); + const observed = [...new Set([...markersIn(answer.text), ...skillMarkers])].sort(); const all = markersIn(Object.values(files).join('\n')); const rows = all.map((name) => ({ name, expected: expected.includes(name), observed: observed.includes(name) })); byId.set(s.id, { files, dir }); - results.push({ id: s.id, tool: s.tool, title: s.title, usedTools: answer.usedTools, rows }); + results.push({ id: s.id, tool: s.tool, title: s.title, usedTools: answer.usedTools, answer: answer.text, rows }); const misses = rows.filter((r) => r.expected !== r.observed); process.stderr.write(`${s.id}: ${misses.length ? `${misses.length} mismatch(es)` : 'as expected'}${answer.usedTools ? ' (the agent used a tool; rerun)' : ''}\n`); } } finally { - rmSync(base, { recursive: true, force: true }); + if (values.keep) process.stderr.write(`Fixtures kept in ${base} +`); + else rmSync(base, { recursive: true, force: true }); } const report = { diff --git a/src/core/classify.ts b/src/core/classify.ts index 467aad9..0b40448 100644 --- a/src/core/classify.ts +++ b/src/core/classify.ts @@ -185,9 +185,10 @@ function applyHierarchical( files: RepoFile[], byPath: Map, ): LoadedUnit[] { - // A skill or subagent file of the tool (Devin's agents//AGENT.md) is not also an instruction file for it. - const ownSkill = (path: string) => tool.rules.some((r) => r.kind === 'skill' && r.pattern.test(path)); - const matches = files.filter((f) => rule.names.includes(basename(f.path)) && !ownSkill(f.path)); + // A skill or subagent file of the tool (Devin's agents//AGENT.md), or a file another rule says the tool does + // not read (Copilot's .claude/CLAUDE.md), is not also an instruction file for it. + const claimed = (path: string) => tool.rules.some((r) => (r.kind === 'skill' || r.kind === 'ignored') && r.pattern.test(path)); + const matches = files.filter((f) => rule.names.includes(basename(f.path)) && !claimed(f.path)); if (!matches.length) return []; let conditionFails: string | null = null; @@ -220,6 +221,11 @@ function applyHierarchical( } const level = levelOf(f.path, rule.sameLevelDirs); const isRoot = level === ''; + if (isRoot && rule.skipOverBytes && new TextEncoder().encode(f.text).length > rule.skipOverBytes) { + const problem = `${tool.name} skips a ${basename(f.path)} over ${rule.skipOverBytes / 1024 / 1024} MiB at launch and loads none of it.`; + out.push(unit(tool.id, f.path, 'ignored', problem, f.text, { problem })); + continue; + } // Claude reads a subdirectory AGENTS.md only when that directory has no CLAUDE.md of its own. if ( rule.condition === 'claude-reads-agents-md' && diff --git a/src/core/tools.ts b/src/core/tools.ts index b4944f4..6a6707f 100644 --- a/src/core/tools.ts +++ b/src/core/tools.ts @@ -46,6 +46,8 @@ export type FileRule = globMentions?: boolean; /** Bytes read before the tool stops (content beyond is dropped). */ maxBytes?: number; + /** A root file over this many bytes is skipped whole (Claude Code's 4 MiB). */ + skipOverBytes?: number; /** Only read when the condition holds for the repository. */ condition?: 'claude-reads-agents-md'; note?: string; @@ -212,6 +214,7 @@ export const TOOLS: ToolSpec[] = [ nestedTrigger: 'when Claude reads or edits a file in', stripHtmlComments: true, importDepth: 4, + skipOverBytes: 4 * 1024 * 1024, }, { kind: 'hierarchical', @@ -448,57 +451,58 @@ export const TOOLS: ToolSpec[] = [ 'https://docs.github.com/en/copilot/reference/custom-instructions-support', 'https://docs.github.com/en/copilot/concepts/customizations/agent-skills', ], - checkedAt: '2026-11-06', - // Modelled on the VS Code Local harness with default settings; the Copilot harness, Copilot CLI and cloud agent differ (see notes). + checkedAt: '2026-11-08', + // Modelled on Copilot CLI 1.0.107 as observed with scripts/observe.mjs on 2026-11-08; VS Code's Copilot harness + // shares that runtime. The legacy VS Code Local harness differs (see notes). rules: [ + // Copilot CLI does not follow @imports in this file (observed), and a root-file rule follows none. { kind: 'root-file', path: '.github/copilot-instructions.md' }, { kind: 'frontmatter', pattern: /^\.github\/instructions\/.+\.instructions\.md$/, rootPrefixes: ['.github/instructions/'], decide: (fm) => { - if (has(fm, 'applyTo')) return { mode: 'on-demand', trigger: `applyTo: ${str(fm.applyTo)}` }; - if (has(fm, 'description')) - return { - mode: 'on-demand', - trigger: 'agent decides from description (VS Code)', - descriptionOnly: true, - note: 'Description assumed to be in context so the agent can decide (inferred, not documented).', - }; - return { mode: 'manual', trigger: 'attached manually' }; + const applyTo = str(fm.applyTo).trim(); + if (!applyTo) return { mode: 'always', trigger: 'no applyTo', note: 'Loaded every turn in Copilot CLI (observed); the docs do not say.' }; + if (/^\*\*(\/\*)?$/.test(applyTo)) return { mode: 'always', trigger: `applyTo: ${applyTo}` }; + return { mode: 'on-demand', trigger: `applyTo: ${applyTo}` }; }, }, { - // Claude rules: `paths` replaces applyTo and defaults to **. kind: 'frontmatter', pattern: /^\.claude\/rules\/.+\.md$/, rootPrefixes: ['.claude/rules/'], - decide: (fm) => ({ mode: 'on-demand', trigger: has(fm, 'paths') ? `paths: ${str(fm.paths)}` : 'paths: ** (default)' }), + decide: (fm) => + has(fm, 'paths') ? { mode: 'on-demand', trigger: `paths: ${str(fm.paths)}` } : { mode: 'always', trigger: 'rule without paths' }, + }, + { + kind: 'ignored', + pattern: /^(?:\.claude\/CLAUDE\.md|CLAUDE\.local\.md)$/, + reason: 'Copilot CLI reads CLAUDE.md at the root, not .claude/CLAUDE.md or CLAUDE.local.md (observed).', }, { kind: 'hierarchical', - names: ['AGENTS.md'], - nested: 'ignored', - nestedTrigger: 'The VS Code Local harness reads nested AGENTS.md only with chat.useNestedAgentsMdFiles, which is off by default.', + names: ['AGENTS.md', 'CLAUDE.md'], + nested: 'on-demand', + nestedTrigger: 'when Copilot works on a file in', + // At least six hops were followed when observed; the limit is not documented. + importDepth: 6, }, { - // chat.useClaudeMdFile (on by default): CLAUDE.md as always-on instructions, together with AGENTS.md. kind: 'hierarchical', - names: ['CLAUDE.md', 'CLAUDE.local.md'], - sameLevelDirs: ['.claude'], - nested: 'ignored', - nestedTrigger: 'The VS Code Local harness reads CLAUDE.md only at the workspace root.', + names: ['GEMINI.md'], + nested: 'on-demand', + nestedTrigger: 'when Copilot works on a file in', }, ...skillFolders(['.github', '.claude', '.agents'], { hideFlag: 'disable-model-invocation', bodyTrigger: 'when Copilot loads the skill' }), ], limits: [], notes: [ - 'Modelled on the VS Code Local harness with its default settings (chat.useAgentsMdFile and chat.useClaudeMdFile on, chat.useNestedAgentsMdFiles off; VS Code documents these settings for the Local harness only); VS Code does not expand @imports.', - "The Copilot harness in VS Code shares a runtime with Copilot CLI and is assumed to read the same files. Copilot CLI reads AGENTS.md, CLAUDE.md, .claude/CLAUDE.md and GEMINI.md together from the repository root, the working directory and the folders between, plus nested copies in the folders of files it works on, and expands @path references in copilot-instructions.md, AGENTS.md and CLAUDE.md. GEMINI.md is read only there, so it is not counted.", + "Modelled on Copilot CLI 1.0.107 as observed on 2026-11-08 with scripts/observe.mjs: the root AGENTS.md, CLAUDE.md and GEMINI.md load together, nested copies load when Copilot works on a file there, and .claude/CLAUDE.md and CLAUDE.local.md are not read. VS Code's Copilot harness shares the Copilot CLI runtime and is assumed to read the same files.", + 'The VS Code Local harness, now a legacy option, reads differently: CLAUDE.md, CLAUDE.local.md and .claude/CLAUDE.md at the root, .claude/rules on demand, no nested AGENTS.md by default (chat.useNestedAgentsMdFiles) and no GEMINI.md.', 'Copilot cloud agent uses the nearest AGENTS.md, or a single root CLAUDE.md or GEMINI.md instead.', 'Copilot code review also reads REVIEW.md.', - 'VS Code now calls the Local harness a legacy editor harness and recommends the Copilot harness. That harness discovers nested AGENTS.md along the paths it works with, and its reference table does not list CLAUDE.md or .claude/rules. turntax still models the Local harness.', - 'Copilot CLI also reads ~/.copilot/copilot-instructions.md, ~/.copilot/instructions/**/*.instructions.md and folders in COPILOT_CUSTOM_INSTRUCTIONS_DIRS; these are not counted.', + 'User-level ~/.claude/CLAUDE.md and ~/.claude/rules are read by the legacy VS Code Local harness and are not counted. Copilot CLI also reads ~/.copilot/copilot-instructions.md, ~/.copilot/instructions/**/*.instructions.md and folders in COPILOT_CUSTOM_INSTRUCTIONS_DIRS; these are not counted.', 'Same-name skills in different folders are not merged (VS Code shows both); both are counted.', ], }, diff --git a/src/core/user.ts b/src/core/user.ts index 7c5a1f6..f136279 100644 --- a/src/core/user.ts +++ b/src/core/user.ts @@ -55,8 +55,6 @@ export const USER_FILES: UserFileRule[] = [ { tool: 'copilot', pattern: /^\.copilot\/instructions\/.+\.instructions\.md$/, as: moved('.copilot/instructions/', '.github/instructions/'), source: VSCODE_INSTRUCTIONS }, { tool: 'copilot', pattern: skills('.copilot'), as: moved('.copilot/skills/', '.github/skills/'), source: VSCODE_SKILLS }, { tool: 'copilot', pattern: skills('.agents|.claude'), as: same, source: VSCODE_SKILLS }, - { tool: 'copilot', pattern: /^\.claude\/CLAUDE\.md$/, as: same, source: VSCODE_INSTRUCTIONS }, - { tool: 'copilot', pattern: /^\.claude\/rules\/.+\.md$/, as: same, source: 'https://code.visualstudio.com/docs/agents/reference/ai-settings' }, // Read through its own rule (6,000-character limit), not as .windsurfrules. { tool: 'windsurf', pattern: /^\.codeium\/windsurf\/memories\/global_rules\.md$/, as: same, source: 'https://docs.devin.ai/desktop/cascade/memories' }, { tool: 'windsurf', pattern: skills('.codeium/windsurf'), as: moved('.codeium/windsurf/skills/', '.windsurf/skills/'), source: WINDSURF_SKILLS }, diff --git a/test/agents.test.ts b/test/agents.test.ts index 98a61f1..83a1589 100644 --- a/test/agents.test.ts +++ b/test/agents.test.ts @@ -386,6 +386,19 @@ describe('Claude Code size limits', () => { for (const p of ['~/.claude/CLAUDE.md', '~/.claude/rules/big.md']) expect(limit.pattern.test(p), p).toBe(false); }); + it('counts a root CLAUDE.md over 4 MiB as not loaded, with the reason as a finding', () => { + const big = 'word '.repeat(4 * 1024 * 1024 / 5 + 1); + const files = [ + { path: 'CLAUDE.md', text: big }, + { path: 'pkg/CLAUDE.md', text: big }, + ]; + const units = classify(files, ['claude-code']); + expect(units.find((u) => u.path === 'CLAUDE.md')).toMatchObject({ mode: 'ignored', problem: 'Claude Code skips a CLAUDE.md over 4 MiB at launch and loads none of it.' }); + // Only files read at launch are skipped; a nested file is cut at 40,000 characters instead. + expect(units.find((u) => u.path === 'pkg/CLAUDE.md')!.mode).toBe('on-demand'); + expect(classify([{ path: 'CLAUDE.md', text: 'word '.repeat(1000) }], ['claude-code'])[0]!.mode).toBe('always'); + }); + it('limits a CLAUDE.md read at launch to 4 MiB, and no nested file', () => { // Tokenising a 4 MiB file is too slow for a test, so the limit entry is checked directly. const limit = getTool('claude-code').limits.find((l) => l.unit === 'bytes')!; diff --git a/test/classify.test.ts b/test/classify.test.ts index d8932ce..b1ab9c3 100644 --- a/test/classify.test.ts +++ b/test/classify.test.ts @@ -296,19 +296,50 @@ describe('Copilot', () => { expect(api.mode).toBe('on-demand'); expect(api.trigger).toBe('applyTo: packages/api/**'); }); - it('reads CLAUDE.md together with AGENTS.md at the root, as the VS Code Local harness does by default', () => { + it('reads AGENTS.md, CLAUDE.md and GEMINI.md together at the root and nested copies on demand, as Copilot CLI does', () => { expect(find(units, 'copilot', 'AGENTS.md')!.mode).toBe('always'); expect(find(units, 'copilot', 'CLAUDE.md')!.mode).toBe('always'); - // Only Copilot CLI and the Copilot harness read GEMINI.md; it is described in a note, not modelled. - expect(find(units, 'copilot', 'GEMINI.md')).toBeUndefined(); - expect(getTool('copilot').notes.join(' ')).toMatch(/GEMINI\.md is read only there/); - // The Local harness reads neither nested CLAUDE.md nor (by default) nested AGENTS.md. - expect(find(units, 'copilot', 'packages/api/CLAUDE.md')!.mode).toBe('ignored'); - const nested = classify([{ path: 'AGENTS.md', text: 'Root.' }, { path: 'pkg/AGENTS.md', text: 'Nested.' }], ['copilot']); - expect(find(nested, 'copilot', 'pkg/AGENTS.md')!.trigger).toMatch(/chat\.useNestedAgentsMdFiles/); + expect(find(units, 'copilot', 'GEMINI.md')!.mode).toBe('always'); + expect(find(units, 'copilot', 'packages/api/CLAUDE.md')).toMatchObject({ mode: 'on-demand', trigger: 'when Copilot works on a file in packages/api/' }); + const nested = classify( + [ + { path: 'AGENTS.md', text: 'Root.' }, + { path: 'pkg/AGENTS.md', text: 'Nested.' }, + { path: 'pkg/GEMINI.md', text: 'Nested.' }, + ], + ['copilot'], + ); + expect(find(nested, 'copilot', 'pkg/AGENTS.md')!.mode).toBe('on-demand'); + expect(find(nested, 'copilot', 'pkg/GEMINI.md')!.mode).toBe('on-demand'); + }); + + it('follows @imports in AGENTS.md and CLAUDE.md but not in copilot-instructions.md', () => { + const u = classify( + [ + { path: 'AGENTS.md', text: 'Root.\n@docs/a.md' }, + { path: 'docs/a.md', text: 'Imported.' }, + { path: '.github/copilot-instructions.md', text: 'Repo.\n@docs/b.md' }, + { path: 'docs/b.md', text: 'Not imported.' }, + ], + ['copilot'], + ); + expect(find(u, 'copilot', 'docs/a.md')!.mode).toBe('always'); + expect(find(u, 'copilot', 'docs/b.md')).toBeUndefined(); + }); + + it('loads instructions without applyTo or with applyTo ** every turn', () => { + const u = classify( + [ + { path: '.github/instructions/plain.instructions.md', text: 'Plain.' }, + { path: '.github/instructions/all.instructions.md', text: '---\napplyTo: "**"\n---\nAll.' }, + { path: '.github/instructions/sub/deep.instructions.md', text: '---\napplyTo: "**/*"\n---\nDeep.' }, + ], + ['copilot'], + ); + for (const p of ['plain', 'all', 'sub/deep']) expect(find(u, 'copilot', `.github/instructions/${p}.instructions.md`)!.mode, p).toBe('always'); }); - it('reads .claude/CLAUDE.md and CLAUDE.local.md, and .claude/rules on demand with paths defaulting to **', () => { + it('does not read .claude/CLAUDE.md or CLAUDE.local.md, and reads .claude/rules every turn without paths', () => { const u = classify( [ { path: '.claude/CLAUDE.md', text: 'Team.' }, @@ -318,9 +349,10 @@ describe('Copilot', () => { ], ['copilot'], ); - expect(find(u, 'copilot', '.claude/CLAUDE.md')!.mode).toBe('always'); - expect(find(u, 'copilot', 'CLAUDE.local.md')!.mode).toBe('always'); - expect(find(u, 'copilot', '.claude/rules/all.md')).toMatchObject({ mode: 'on-demand', trigger: 'paths: ** (default)' }); + expect(find(u, 'copilot', '.claude/CLAUDE.md')!.mode).toBe('ignored'); + expect(find(u, 'copilot', 'CLAUDE.local.md')!.mode).toBe('ignored'); + expect(u.filter((x) => x.path === '.claude/CLAUDE.md')).toHaveLength(1); + expect(find(u, 'copilot', '.claude/rules/all.md')).toMatchObject({ mode: 'always', trigger: 'rule without paths' }); expect(find(u, 'copilot', '.claude/rules/ts.md')).toMatchObject({ mode: 'on-demand', trigger: 'paths: src/**/*.ts' }); }); diff --git a/test/fix.test.ts b/test/fix.test.ts index 65bb5e6..8a44e3b 100644 --- a/test/fix.test.ts +++ b/test/fix.test.ts @@ -43,17 +43,15 @@ const after = (plan: ReturnType, path: string) => plan.changes const files = await loadFixture('mixed'); -// Copilot in VS Code reads the root CLAUDE.md but no nested instruction file, so the API section can move only -// for the other agents. -const MIXED_TOOLS = TOOL_IDS.filter((t) => t !== 'copilot'); +// Every agent that reads the root CLAUDE.md also reads packages/api/CLAUDE.md, so the API section can move. +const MIXED_TOOLS = TOOL_IDS; describe('planFixes on the mixed fixture', () => { const plan = planFixes(files, { exists: existsIn(fixture('mixed')), tools: MIXED_TOOLS }); - it('keeps the API section where it is for every agent, since Copilot would lose it', () => { + it('moves the API section for every agent, since Copilot also reads the nested CLAUDE.md', () => { const all = planFixes(files, { exists: existsIn(fixture('mixed')) }); - expect(all.fixes.map((f) => f.kind)).toEqual(['misconfigured']); - expect(all.skipped.find((s) => s.kind === 'scopable-section')!.reason).toMatch(/packages\/api\/CLAUDE\.md \(GitHub Copilot would lose context\)/); + expect(all.fixes.map((f) => f.kind)).toEqual(['misconfigured', 'scopable-section']); }); it('renames a .md rule in .cursor/rules to .mdc', () => { @@ -65,7 +63,7 @@ describe('planFixes on the mixed fixture', () => { it('moves the API section into the nested CLAUDE.md that Claude Code and Cursor read there', () => { const fix = plan.fixes.find((f) => f.kind === 'scopable-section')!; expect(fix.paths).toEqual(['CLAUDE.md', 'packages/api/CLAUDE.md']); - expect(fix.message).toMatch(/Not kept for GitHub Copilot \(outside --tools\)\.$/); + expect(fix.message).not.toMatch(/Not kept for/); expect(fix.savingTokens).toBeGreaterThan(100); expect(after(plan, 'CLAUDE.md')).not.toContain('## API package'); // A Windows checkout may have CRLF fixtures; the fix keeps each file's line endings. @@ -439,13 +437,12 @@ describe('scopable sections', () => { const message = planFixes(files, { exists, tools: ['codex', 'cursor', 'claude-code'] }).fixes[0]!.message; expect(message).toMatch(/ Not kept for [^.]*\bZed\b[^.]* \(outside --tools\)\.$/); expect(message).toMatch(/Not kept for [^.]*JetBrains Junie/); - // Agents that read the nested AGENTS.md as well are not named; VS Code Copilot reads no nested AGENTS.md by default. - expect(message).not.toMatch(/Not kept for [^.]*(OpenAI Codex|Cursor|Claude Code)/); - expect(message).toMatch(/Not kept for [^.]*GitHub Copilot/); + // Agents that read the nested AGENTS.md as well are not named. + expect(message).not.toMatch(/Not kept for [^.]*(OpenAI Codex|Cursor|Claude Code|GitHub Copilot)/); const all = planFixes(files, { exists, tools: ['codex', 'cursor', 'claude-code', 'zed', 'junie'] }); expect(all.fixes).toEqual([]); const other = planFixes([{ path: 'CLAUDE.md', text: `# Rules\n\n${API_SECTION}` }], { exists, tools: ['claude-code', 'cursor'] }); - expect(other.fixes[0]!.message).toMatch(/Not kept for GitHub Copilot, Zed, OpenCode, Kilo Code \(outside --tools\)\.$/); + expect(other.fixes[0]!.message).toMatch(/Not kept for Zed, OpenCode, Kilo Code \(outside --tools\)\.$/); }); it('does not count a move as a saving for agents that load nested files every turn', () => { diff --git a/test/user.test.ts b/test/user.test.ts index 9710606..12d73dc 100644 --- a/test/user.test.ts +++ b/test/user.test.ts @@ -24,8 +24,9 @@ describe('user-level files', () => { it('classifies each file only for its own agent', () => { const units = classifyUser(home.files); const who = (path: string) => units.filter((u) => u.path === path && u.mode === 'always').map((u) => u.tool); - // VS Code Copilot reads ~/.claude/CLAUDE.md; OpenCode falls back to it because there is no ~/.config/opencode/AGENTS.md. - expect(who('~/.claude/CLAUDE.md')).toEqual(['claude-code', 'copilot', 'opencode', 'devin']); + // OpenCode falls back to it because there is no ~/.config/opencode/AGENTS.md. Copilot reads it only in the legacy + // VS Code Local harness, which is not modelled. + expect(who('~/.claude/CLAUDE.md')).toEqual(['claude-code', 'opencode', 'devin']); expect(who('~/.claude/rules/style.md')).toEqual(['claude-code']); expect(who('~/.codex/AGENTS.md')).toEqual(['codex']); expect(who('~/.gemini/GEMINI.md')).toEqual(['gemini-cli']); diff --git a/test/vscode-view.test.ts b/test/vscode-view.test.ts index 3c804e9..8ecafb5 100644 --- a/test/vscode-view.test.ts +++ b/test/vscode-view.test.ts @@ -141,8 +141,12 @@ describe('VS Code fix preview', () => { it('plans the fixes as the MCP fix_preview does and summarises them', async () => { const plan = await planWorkspaceFixes(fixture('mixed')); - expect(plan.changes.map((c) => [c.renamedFrom, c.path])).toEqual([['.cursor/rules/wrong.md', '.cursor/rules/wrong.mdc']]); - expect(fixSummary(plan)).toBe('1 safe fix'); + expect(plan.changes.map((c) => [c.renamedFrom, c.path])).toEqual([ + ['.cursor/rules/wrong.md', '.cursor/rules/wrong.mdc'], + [undefined, 'CLAUDE.md'], + [undefined, 'packages/api/CLAUDE.md'], + ]); + expect(fixSummary(plan)).toMatch(/^2 safe fixes \(saves ~\d+ o200k tokens\/turn\)$/); const scoped = await planWorkspaceFixes(materialize('mixed', { 'turntax.config.json': JSON.stringify({ tools: ['claude-code', 'cursor'] }) })); expect(scoped.fixes.length).toBeGreaterThan(plan.fixes.length); }); @@ -189,7 +193,7 @@ describe('VS Code CodeLens', () => { 'Counts are o200k_base estimates, made offline.', ].join('\n'), }); - expect(lens('packages/api/CLAUDE.md')?.title).toBe('turntax: on demand in 6 agents · not read by 1'); + expect(lens('packages/api/CLAUDE.md')?.title).toBe('turntax: on demand in 7 agents'); expect(lens('.cursor/rules/wrong.md')?.title).toBe('turntax: when referenced in 1 agent · not read by 1'); }); @@ -199,7 +203,7 @@ describe('VS Code CodeLens', () => { const [always, onDemand] = skill.tooltip.split('\n'); expect(always).toMatch(/^Every turn: Warp \(26 tokens, description\); Claude Code, Cursor, [^;]+ \(14 tokens, description\)$/); expect(onDemand).toMatch(/^On demand: Claude Code, [^;]*Warp[^;]* \(22 tokens, body\)$/); - expect(lens('docs/extra.md')?.tooltip.split('\n')[0]).toBe('Every turn: Claude Code (42 tokens, imported by CLAUDE.md)'); + expect(lens('docs/extra.md')?.tooltip.split('\n')[0]).toBe('Every turn: Claude Code, GitHub Copilot (42 tokens, imported by CLAUDE.md)'); const rows = [ row('codex', 'ignored', 5), From 7c4a9517ba47645f53d2eab9ea40737864f0e125 Mon Sep 17 00:00:00 2001 From: Furkan Date: Sun, 8 Nov 2026 11:21:13 +0300 Subject: [PATCH 2/4] Fix review findings in the Copilot model and the 4 MiB skip - Copilot user-level skills come from ~/.agents/skills only, as Copilot CLI lists them; docs and notes say which user files count - Copilot's hierarchical rule excludes .claude/CLAUDE.md itself instead of every agent's ignored rules claiming files - Instructions with a description and no applyTo keep description-only loading; that case was not observed - The 4 MiB skip measures the file as it is on disk, CRLF included - Import discovery follows as many levels as the deepest agent (six for Copilot) - observe.mjs records the skills Copilot listed; docs hedge the cause of Claude Code's 39 of 41 --- CHANGELOG.md | 2 ++ docs/how-it-counts.md | 13 ++++++------- scripts/observe.mjs | 2 +- src/core/classify.ts | 13 ++++++++----- src/core/files.ts | 8 ++++++-- src/core/tools.ts | 8 +++++++- src/core/user.ts | 4 ++-- test/agents.test.ts | 15 +++++++++++++++ test/classify.test.ts | 12 ++++++++++++ 9 files changed, 59 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9cd95a..175c021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - `@imports` in `AGENTS.md` and `CLAUDE.md` are followed. - `.claude/rules` without `paths` and instructions files without `applyTo` or with `applyTo: **` load every turn. - `.claude/CLAUDE.md` and `CLAUDE.local.md` are not read. + - With `--include-user`, `~/.claude/CLAUDE.md`, `~/.claude/rules` and `~/.claude/skills` no longer count for Copilot; `~/.copilot` and `~/.agents/skills` still do. + - An instructions file with a `description` and no `applyTo` keeps its description always and its body on demand; that case was not observed. - A root `CLAUDE.md` over 4 MiB counts as not loaded for Claude Code, which skips it, and the finding says so. - `scripts/observe.mjs` checks Copilot CLI too, and `--keep` keeps the fixtures for a closer look. diff --git a/docs/how-it-counts.md b/docs/how-it-counts.md index bb10f4b..3b49a86 100644 --- a/docs/how-it-counts.md +++ b/docs/how-it-counts.md @@ -13,7 +13,7 @@ Rule folders inside a subdirectory (for example `packages/api/.claude/rules/` or When an agent reads two skills with the same name at the same level, for example `.agents/skills/deploy/` and `.claude/skills/deploy/` (often symlinked copies), only the one from the folder that takes precedence is counted; the other is ignored with "same skill name as ...". A skill's name is its `name` frontmatter, else its folder name. The order is the agent's documented precedence; where its docs are silent, the order shown below is an assumption. Agents that list both copies (OpenAI Codex, GitHub Copilot, Devin Local / Devin CLI, and Warp, which also lists each skill's path) count both. -The rules below live in [`src/core/tools.ts`](../src/core/tools.ts). Each entry cites the page it came from; all were checked on 2026-11-06, except Windsurf Cascade (see its entry). +The rules below live in [`src/core/tools.ts`](../src/core/tools.ts). Each entry cites the page it came from; all were checked on 2026-11-06, Copilot on 2026-11-08, except Windsurf Cascade (see its entry). ## Checked against the agents @@ -22,7 +22,7 @@ The rules come from the vendors' docs. [`scripts/observe.mjs`](../scripts/observ | Agent | Version | Date | Result | | --- | --- | --- | --- | | Claude Code | 2.1.296 | 2026-11-06 | 41 of 41 checks as turntax expects, in three setups | -| Claude Code | 2.1.296 | 2026-11-08 | 39 of 41: the description of a command was missing twice (see below) | +| Claude Code | 2.1.296 | 2026-11-08 | 39 of 41: in both setups that list it, a command's description was missing (see below) | | GitHub Copilot CLI | 1.0.107 | 2026-11-08 | 62 of 62 in two setups, twice, after turntax took up what the CLI loads | | OpenAI Codex | | | not run yet | @@ -33,7 +33,7 @@ In Claude Code, started at the root of the repository: After Claude reads a file in a subfolder, that folder's `CLAUDE.md` and a rule with `paths` for it load too. With `AGENTS.md` and no `CLAUDE.md`, `AGENTS.md` loads. -On 2026-11-08 Claude Code listed the command by name with no description. Its skill listing is capped at 1% of the context window, and past that it drops the descriptions of the least-used entries; the account used for the run had many plugin skills. turntax counts every description and does not apply that cap. +On 2026-11-08 Claude Code listed the command by name with no description, in every run that day. The likely cause, not confirmed: its skill listing is capped at 1% of the context window, and past that it drops the descriptions of the least-used entries, and the account used for the run had many plugin skills. A small fixture with only that command and one skill listed both descriptions. turntax counts every description and does not apply that cap. Copilot CLI did not list what its instructions say when asked, so each Copilot fixture file gives it a project code to repeat, and the skills it lists are read from the CLI's own `session.skills_loaded` event. The first run disagreed with turntax's model of the VS Code Local harness in 14 of 31 checks at the root; turntax now models what the CLI loads, described under [GitHub Copilot](#github-copilot). Copilot CLI loads repository instructions only in a folder you trust; the script passes `--trust-folder`. @@ -108,16 +108,16 @@ Copilot surfaces read different files. turntax models Copilot CLI 1.0.107 as obs | File | Mode | | --- | --- | | `.github/copilot-instructions.md` | always; `@imports` in it are not followed | -| `.github/instructions/**/*.instructions.md` | always without `applyTo` or with `applyTo: **`; other `applyTo` on-demand | +| `.github/instructions/**/*.instructions.md` | always with no front matter or `applyTo: **` (`**/*` is assumed the same); other `applyTo` on-demand; `description` and no `applyTo`: description always, body on-demand | | `AGENTS.md`, `CLAUDE.md` and `GEMINI.md` at the root | always, all together; `@imports` in `AGENTS.md` and `CLAUDE.md` are followed (at least six hops were) | | `AGENTS.md`, `CLAUDE.md` or `GEMINI.md` in a subdirectory | on-demand, when Copilot works on a file there | | `.claude/rules/**/*.md` | always without `paths`; on-demand with `paths` | | `.claude/CLAUDE.md`, `CLAUDE.local.md` | ignored | | `.github/skills/*/SKILL.md`, `.claude/skills/*/SKILL.md`, `.agents/skills/*/SKILL.md` | description always; body on-demand; `disable-model-invocation: true` manual; same-name skills in two folders are both counted | -The docs say less than this, and in places differ: Copilot CLI's page also lists `.claude/CLAUDE.md` and imports in `copilot-instructions.md`, which the CLI did not read when observed, and no page says that an instructions file without `applyTo` loads every turn. Other surfaces: +The docs say less than this, and in places differ: Copilot CLI's page also lists `.claude/CLAUDE.md` and imports in `copilot-instructions.md`, which the CLI did not read when observed, and no page says that an instructions file without front matter loads every turn. VS Code's docs say the agent decides from a `description`; files with one and no `applyTo` were not observed and are counted that way. Other surfaces: -- The legacy VS Code Local harness reads `CLAUDE.md`, `.claude/CLAUDE.md` and `CLAUDE.local.md` at the root, `.claude/rules` on demand, nested `AGENTS.md` only with `chat.useNestedAgentsMdFiles` (off by default), and no `GEMINI.md`. It also reads `~/.claude/CLAUDE.md` and `~/.claude/rules`, which are not counted. +- The legacy VS Code Local harness reads `CLAUDE.md`, `.claude/CLAUDE.md` and `CLAUDE.local.md` at the root, `.claude/rules` on demand, nested `AGENTS.md` only with `chat.useNestedAgentsMdFiles` (off by default), and no `GEMINI.md`. It also reads `~/.claude/CLAUDE.md`, `~/.claude/rules` and `~/.claude/skills`, which are not counted for Copilot. - Copilot cloud agent uses the nearest `AGENTS.md`, or a single root `CLAUDE.md` or `GEMINI.md` instead. - Copilot code review also reads `REVIEW.md`. @@ -365,7 +365,6 @@ With `--include-user`, files in the home directory are classified by the same ru | `~/.gemini/GEMINI.md`, `~/.gemini/skills/` | Gemini CLI ([GEMINI.md](https://geminicli.com/docs/cli/gemini-md/), [skills](https://geminicli.com/docs/cli/skills/)) | root `GEMINI.md`, `.gemini/skills` | | `~/.cursor/skills/`, `~/.claude/skills/`, `~/.codex/skills/` | Cursor ([skills](https://cursor.com/docs/skills)) | the same folders | | `~/.copilot/copilot-instructions.md`, `~/.copilot/instructions/**/*.instructions.md`, `~/.copilot/skills/` | GitHub Copilot ([instructions](https://code.visualstudio.com/docs/agent-customization/custom-instructions), [skills](https://code.visualstudio.com/docs/agent-customization/agent-skills)) | `.github/copilot-instructions.md`, `.github/instructions/`, `.github/skills` | -| `~/.claude/CLAUDE.md`, `~/.claude/rules/`, `~/.claude/skills/` | GitHub Copilot in VS Code ([instructions](https://code.visualstudio.com/docs/agent-customization/custom-instructions), [settings](https://code.visualstudio.com/docs/agents/reference/ai-settings)) | the same paths | | `~/.codeium/windsurf/memories/global_rules.md` | Windsurf Cascade ([rules](https://docs.devin.ai/desktop/cascade/memories)) | always loaded; limited to 6,000 characters | | `~/.codeium/windsurf/skills/`, `~/.config/devin/skills/` | Windsurf Cascade ([skills](https://docs.devin.ai/desktop/cascade/skills)) | `.windsurf/skills`, `.devin/skills` | | `~/Documents/Cline/Rules/`, `~/Cline/Rules/`, `~/.cline/rules/` | Cline ([rules](https://docs.cline.bot/customization/cline-rules)) | `.clinerules/` | diff --git a/scripts/observe.mjs b/scripts/observe.mjs index b2d2352..1932faf 100644 --- a/scripts/observe.mjs +++ b/scripts/observe.mjs @@ -263,7 +263,7 @@ try { const all = markersIn(Object.values(files).join('\n')); const rows = all.map((name) => ({ name, expected: expected.includes(name), observed: observed.includes(name) })); byId.set(s.id, { files, dir }); - results.push({ id: s.id, tool: s.tool, title: s.title, usedTools: answer.usedTools, answer: answer.text, rows }); + results.push({ id: s.id, tool: s.tool, title: s.title, usedTools: answer.usedTools, answer: answer.text, ...(answer.skillFiles ? { skillsListed: answer.skillFiles } : {}), rows }); const misses = rows.filter((r) => r.expected !== r.observed); process.stderr.write(`${s.id}: ${misses.length ? `${misses.length} mismatch(es)` : 'as expected'}${answer.usedTools ? ' (the agent used a tool; rerun)' : ''}\n`); } diff --git a/src/core/classify.ts b/src/core/classify.ts index 0b40448..a9db80c 100644 --- a/src/core/classify.ts +++ b/src/core/classify.ts @@ -4,9 +4,13 @@ import { TOOLS, type FileRule, type Frontmatter, type ToolSpec } from './tools.j import type { LoadMode, LoadedUnit, RepoFile, ToolId } from './types.js'; /** Works out which files each tool loads, when, and with what text. */ +const RAW_BYTES = new WeakMap(); + export function classify(input: RepoFile[], toolIds?: ToolId[]): LoadedUnit[] { // Same text on every platform: a CRLF checkout must not count or compare differently. const files = input.map((f) => ({ path: f.path, text: f.text.replace(/\r\n/g, '\n') })); + // Sizes as on disk, CRLF included: a tool applies its size limits to the file it reads. + files.forEach((f, i) => RAW_BYTES.set(f, new TextEncoder().encode(input[i]!.text).length)); const byPath = new Map(files.map((f) => [f.path, f])); const tools = toolIds ? TOOLS.filter((t) => toolIds.includes(t.id)) : TOOLS; const units: LoadedUnit[] = []; @@ -185,10 +189,9 @@ function applyHierarchical( files: RepoFile[], byPath: Map, ): LoadedUnit[] { - // A skill or subagent file of the tool (Devin's agents//AGENT.md), or a file another rule says the tool does - // not read (Copilot's .claude/CLAUDE.md), is not also an instruction file for it. - const claimed = (path: string) => tool.rules.some((r) => (r.kind === 'skill' || r.kind === 'ignored') && r.pattern.test(path)); - const matches = files.filter((f) => rule.names.includes(basename(f.path)) && !claimed(f.path)); + // A skill or subagent file of the tool (Devin's agents//AGENT.md) is not also an instruction file for it. + const ownSkill = (path: string) => tool.rules.some((r) => r.kind === 'skill' && r.pattern.test(path)); + const matches = files.filter((f) => rule.names.includes(basename(f.path)) && !ownSkill(f.path) && !rule.exclude?.test(f.path)); if (!matches.length) return []; let conditionFails: string | null = null; @@ -221,7 +224,7 @@ function applyHierarchical( } const level = levelOf(f.path, rule.sameLevelDirs); const isRoot = level === ''; - if (isRoot && rule.skipOverBytes && new TextEncoder().encode(f.text).length > rule.skipOverBytes) { + if (isRoot && rule.skipOverBytes && (RAW_BYTES.get(f) ?? new TextEncoder().encode(f.text).length) > rule.skipOverBytes) { const problem = `${tool.name} skips a ${basename(f.path)} over ${rule.skipOverBytes / 1024 / 1024} MiB at launch and loads none of it.`; out.push(unit(tool.id, f.path, 'ignored', problem, f.text, { problem })); continue; diff --git a/src/core/files.ts b/src/core/files.ts index 7e8a325..f4c1fef 100644 --- a/src/core/files.ts +++ b/src/core/files.ts @@ -27,6 +27,9 @@ export const SKIP_DIRS = new Set([ '.cache', ]); +/** The deepest @import chain any agent follows (Copilot's six hops), at least five; discovery reads that far. */ +const IMPORT_LEVELS = Math.max(5, ...TOOLS.flatMap((t) => t.rules.map((r) => (r.kind === 'hierarchical' ? (r.importDepth ?? 0) : 0)))); + /** `.md` files in `.cursor/rules`, which Cursor ignores; `--fix` renames them to `.mdc`. */ export const CURSOR_MD_RULE = /(^|\/)\.cursor\/rules\/.+\.md$/; @@ -118,7 +121,8 @@ function references(f: RepoFile, paths: string[]): string[] { } /** - * Adds in-repo files reached through @imports or config read lists (up to five levels) to `found`. + * Adds in-repo files reached through @imports or config read lists to `found`, as deep as the deepest import chain any + * agent follows. * `paths` lists the repository's files, for glob mentions in the files found first (Amp follows mentions one level). */ export async function addImports( @@ -128,7 +132,7 @@ export async function addImports( ): Promise { const all = [...paths]; let queue = [...found.values()]; - for (let depth = 0; depth < 5 && queue.length; depth++) { + for (let depth = 0; depth < IMPORT_LEVELS && queue.length; depth++) { const next: RepoFile[] = []; for (const f of queue) { for (const rel of references(f, depth === 0 ? all : [])) { diff --git a/src/core/tools.ts b/src/core/tools.ts index 6a6707f..1592693 100644 --- a/src/core/tools.ts +++ b/src/core/tools.ts @@ -48,6 +48,8 @@ export type FileRule = maxBytes?: number; /** A root file over this many bytes is skipped whole (Claude Code's 4 MiB). */ skipOverBytes?: number; + /** Paths with a matching name that the tool does not read this way (Copilot's .claude/CLAUDE.md). */ + exclude?: RegExp; /** Only read when the condition holds for the repository. */ condition?: 'claude-reads-agents-md'; note?: string; @@ -463,6 +465,8 @@ export const TOOLS: ToolSpec[] = [ rootPrefixes: ['.github/instructions/'], decide: (fm) => { const applyTo = str(fm.applyTo).trim(); + if (!applyTo && has(fm, 'description')) + return { mode: 'on-demand', trigger: 'agent decides from description', descriptionOnly: true, note: 'Not observed; VS Code says the agent decides from the description.' }; if (!applyTo) return { mode: 'always', trigger: 'no applyTo', note: 'Loaded every turn in Copilot CLI (observed); the docs do not say.' }; if (/^\*\*(\/\*)?$/.test(applyTo)) return { mode: 'always', trigger: `applyTo: ${applyTo}` }; return { mode: 'on-demand', trigger: `applyTo: ${applyTo}` }; @@ -483,6 +487,8 @@ export const TOOLS: ToolSpec[] = [ { kind: 'hierarchical', names: ['AGENTS.md', 'CLAUDE.md'], + // Reported by the ignored rule above. + exclude: /^\.claude\/CLAUDE\.md$/, nested: 'on-demand', nestedTrigger: 'when Copilot works on a file in', // At least six hops were followed when observed; the limit is not documented. @@ -502,7 +508,7 @@ export const TOOLS: ToolSpec[] = [ 'The VS Code Local harness, now a legacy option, reads differently: CLAUDE.md, CLAUDE.local.md and .claude/CLAUDE.md at the root, .claude/rules on demand, no nested AGENTS.md by default (chat.useNestedAgentsMdFiles) and no GEMINI.md.', 'Copilot cloud agent uses the nearest AGENTS.md, or a single root CLAUDE.md or GEMINI.md instead.', 'Copilot code review also reads REVIEW.md.', - 'User-level ~/.claude/CLAUDE.md and ~/.claude/rules are read by the legacy VS Code Local harness and are not counted. Copilot CLI also reads ~/.copilot/copilot-instructions.md, ~/.copilot/instructions/**/*.instructions.md and folders in COPILOT_CUSTOM_INSTRUCTIONS_DIRS; these are not counted.', + 'With --include-user, ~/.copilot/copilot-instructions.md, ~/.copilot/instructions, ~/.copilot/skills and ~/.agents/skills are counted. ~/.claude/CLAUDE.md, ~/.claude/rules and ~/.claude/skills, read by the legacy VS Code Local harness, and folders in COPILOT_CUSTOM_INSTRUCTIONS_DIRS are not.', 'Same-name skills in different folders are not merged (VS Code shows both); both are counted.', ], }, diff --git a/src/core/user.ts b/src/core/user.ts index f136279..77113cd 100644 --- a/src/core/user.ts +++ b/src/core/user.ts @@ -50,11 +50,11 @@ export const USER_FILES: UserFileRule[] = [ { tool: 'gemini-cli', pattern: /^\.gemini\/GEMINI\.md$/, as: () => 'GEMINI.md', source: 'https://geminicli.com/docs/cli/gemini-md/' }, { tool: 'gemini-cli', pattern: skills('.agents|.gemini'), as: same, source: GEMINI_SKILLS }, { tool: 'cursor', pattern: skills('.agents|.cursor|.claude|.codex', RECURSIVE), as: same, source: CURSOR_SKILLS }, - // VS Code: personal Copilot instructions and skills, plus the Claude files it reads by default. + // Personal Copilot instructions and skills. Copilot CLI lists ~/.agents/skills but not ~/.claude/skills (observed). { tool: 'copilot', pattern: /^\.copilot\/copilot-instructions\.md$/, as: () => '.github/copilot-instructions.md', source: VSCODE_INSTRUCTIONS }, { tool: 'copilot', pattern: /^\.copilot\/instructions\/.+\.instructions\.md$/, as: moved('.copilot/instructions/', '.github/instructions/'), source: VSCODE_INSTRUCTIONS }, { tool: 'copilot', pattern: skills('.copilot'), as: moved('.copilot/skills/', '.github/skills/'), source: VSCODE_SKILLS }, - { tool: 'copilot', pattern: skills('.agents|.claude'), as: same, source: VSCODE_SKILLS }, + { tool: 'copilot', pattern: skills('.agents'), as: same, source: VSCODE_SKILLS }, // Read through its own rule (6,000-character limit), not as .windsurfrules. { tool: 'windsurf', pattern: /^\.codeium\/windsurf\/memories\/global_rules\.md$/, as: same, source: 'https://docs.devin.ai/desktop/cascade/memories' }, { tool: 'windsurf', pattern: skills('.codeium/windsurf'), as: moved('.codeium/windsurf/skills/', '.windsurf/skills/'), source: WINDSURF_SKILLS }, diff --git a/test/agents.test.ts b/test/agents.test.ts index 83a1589..7abfdc4 100644 --- a/test/agents.test.ts +++ b/test/agents.test.ts @@ -399,6 +399,21 @@ describe('Claude Code size limits', () => { expect(classify([{ path: 'CLAUDE.md', text: 'word '.repeat(1000) }], ['claude-code'])[0]!.mode).toBe('always'); }); + it('measures the 4 MiB on the file as it is on disk, CRLF included', () => { + // Under 4 MiB once \r\n becomes \n, over it as checked out with CRLF. + const text = Array.from({ length: 65078 }, () => 'x'.repeat(63)).join('\r\n'); + expect(classify([{ path: 'CLAUDE.md', text }], ['claude-code'])[0]!.mode).toBe('ignored'); + }); + + it('discovers an @import chain as deep as Copilot follows it', async () => { + const texts: Record = { 'docs/i6.md': 'Six.' }; + for (let i = 1; i <= 5; i++) texts[`docs/i${i}.md`] = `Hop ${i}.\n@i${i + 1}.md`; + const found = new Map([['AGENTS.md', { path: 'AGENTS.md', text: 'Root.\n@docs/i1.md' }]]); + await addImports(found, (p) => texts[p] ?? null, Object.keys(texts)); + expect(found.has('docs/i6.md')).toBe(true); + expect(find(classify([...found.values()], ['copilot']), 'copilot', 'docs/i6.md')!.mode).toBe('always'); + }); + it('limits a CLAUDE.md read at launch to 4 MiB, and no nested file', () => { // Tokenising a 4 MiB file is too slow for a test, so the limit entry is checked directly. const limit = getTool('claude-code').limits.find((l) => l.unit === 'bytes')!; diff --git a/test/classify.test.ts b/test/classify.test.ts index b1ab9c3..5e4811e 100644 --- a/test/classify.test.ts +++ b/test/classify.test.ts @@ -339,6 +339,18 @@ describe('Copilot', () => { for (const p of ['plain', 'all', 'sub/deep']) expect(find(u, 'copilot', `.github/instructions/${p}.instructions.md`)!.mode, p).toBe('always'); }); + it('keeps the description of an instructions file with a description and no applyTo always, and its body on demand', () => { + const u = classify([{ path: '.github/instructions/review.instructions.md', text: '---\ndescription: Code review rules\n---\nReview carefully.' }], ['copilot']); + expect(find(u, 'copilot', '.github/instructions/review.instructions.md', 'description')!.mode).toBe('always'); + expect(find(u, 'copilot', '.github/instructions/review.instructions.md', 'body')!.mode).toBe('on-demand'); + }); + + it('leaves the other agents alone where a file of theirs sits in a folder they ignore', () => { + // Only Copilot excludes .claude/CLAUDE.md from its hierarchical rule; Cursor still reads an AGENTS.md anywhere. + const u = classify([{ path: '.cursor/rules/AGENTS.md', text: 'Odd place.' }], ['cursor']); + expect(u.find((x) => x.path === '.cursor/rules/AGENTS.md' && x.part === 'full')!.mode).toBe('on-demand'); + }); + it('does not read .claude/CLAUDE.md or CLAUDE.local.md, and reads .claude/rules every turn without paths', () => { const u = classify( [ From 278f08221c1ce3c30645b700bd69cdd3a211b1e7 Mon Sep 17 00:00:00 2001 From: Furkan Date: Sun, 8 Nov 2026 11:23:46 +0300 Subject: [PATCH 3/4] Release 0.10.0 and VS Code extension 0.5.0; minor review notes --- .claude-plugin/marketplace.json | 2 +- .pre-commit-hooks.yaml | 2 +- CHANGELOG.md | 4 ++-- README.md | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- plugins/turntax/.claude-plugin/plugin.json | 4 ++-- plugins/turntax/README.md | 2 +- plugins/turntax/package.json | 2 +- server.json | 4 ++-- src/core/classify.ts | 4 ++-- src/core/tools.ts | 2 +- test/user.test.ts | 6 ++++++ vscode/CHANGELOG.md | 4 ++++ vscode/package-lock.json | 4 ++-- vscode/package.json | 2 +- 16 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 17f4534..27bea37 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,7 +10,7 @@ "name": "turntax", "source": "./plugins/turntax", "description": "Measure the per-turn token cost of AI coding-agent instruction files and MCP servers, and preview safe fixes.", - "version": "0.9.0", + "version": "0.10.0", "category": "development" } ] diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 68592df..7fc323e 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -3,7 +3,7 @@ - id: turntax name: turntax description: Fail when an agent's instruction files go over a per-turn token budget (--max-tokens, or maxTokens in turntax.config.json). - entry: npx --yes turntax@0.9.0 + entry: npx --yes turntax@0.10.0 language: system pass_filenames: false always_run: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 175c021..4ad6028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,11 @@ # Changelog -## Unreleased +## 0.10.0 (2026-11-08) - GitHub Copilot is modelled on what Copilot CLI 1.0.107 loads, checked with `scripts/observe.mjs` (62 of 62 checks), instead of the legacy VS Code Local harness. VS Code's Copilot harness shares that runtime. Counts change: - `GEMINI.md` is read with `AGENTS.md` and `CLAUDE.md`, and nested copies of all three load when Copilot works in their folder. - `@imports` in `AGENTS.md` and `CLAUDE.md` are followed. - - `.claude/rules` without `paths` and instructions files without `applyTo` or with `applyTo: **` load every turn. + - `.claude/rules` without `paths`, instructions files with no front matter (observed) and with `applyTo: **` or `**/*` load every turn. - `.claude/CLAUDE.md` and `CLAUDE.local.md` are not read. - With `--include-user`, `~/.claude/CLAUDE.md`, `~/.claude/rules` and `~/.claude/skills` no longer count for Copilot; `~/.copilot` and `~/.agents/skills` still do. - An instructions file with a `description` and no `applyTo` keeps its description always and its body on demand; that case was not observed. diff --git a/README.md b/README.md index 8d8fa56..1f68cec 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: TorutDev/turntax@v0.9.0 + - uses: TorutDev/turntax@v0.10.0 with: max-increase: 500 # optional: fail when an agent grows by more than 500 tokens per turn # max-tokens: 8000 # optional: absolute budget @@ -232,7 +232,7 @@ The repository is also a [pre-commit](https://pre-commit.com) hook, which fails ```yaml repos: - repo: https://github.com/TorutDev/turntax - rev: v0.9.0 + rev: v0.10.0 hooks: - id: turntax args: [--max-tokens, '8000'] diff --git a/package-lock.json b/package-lock.json index 5bfffb0..c7d2594 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "turntax", - "version": "0.9.0", + "version": "0.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "turntax", - "version": "0.9.0", + "version": "0.10.0", "license": "MIT", "dependencies": { "gpt-tokenizer": "4.1.0" diff --git a/package.json b/package.json index f1ef776..9b93da3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "turntax", - "version": "0.9.0", + "version": "0.10.0", "description": "Measure the per-turn token cost of AI coding-agent instruction files (AGENTS.md, CLAUDE.md, Cursor, Copilot, Cline, Roo, Kiro, Windsurf and more) for every agent that reads them.", "mcpName": "io.github.TorutDev/turntax", "license": "MIT", diff --git a/plugins/turntax/.claude-plugin/plugin.json b/plugins/turntax/.claude-plugin/plugin.json index 3ab677c..6e393e6 100644 --- a/plugins/turntax/.claude-plugin/plugin.json +++ b/plugins/turntax/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "turntax", - "version": "0.9.0", + "version": "0.10.0", "description": "Measure the per-turn token cost of AI coding-agent instruction files (AGENTS.md, CLAUDE.md, Cursor rules and more) and MCP servers, and preview safe fixes.", "author": { "name": "TORUT LTD", @@ -15,7 +15,7 @@ "mcpServers": { "turntax": { "command": "npx", - "args": ["-y", "turntax@0.9.0", "mcp"] + "args": ["-y", "turntax@0.10.0", "mcp"] } } } diff --git a/plugins/turntax/README.md b/plugins/turntax/README.md index 8c7f4c8..4e8ca1e 100644 --- a/plugins/turntax/README.md +++ b/plugins/turntax/README.md @@ -9,7 +9,7 @@ Measures how many tokens your agent instruction files (CLAUDE.md, `.claude/rules ## What it runs and sends -The server runs `npx -y turntax@0.9.0 mcp` on your machine. npx downloads the `turntax` package from npm on first use. `package.json` and `package-lock.json` in this folder pin the same version and its one dependency, with integrity hashes. The tools read instruction files and MCP configs in the folder you audit. They do not start the MCP servers they find, do not call any vendor API, and send nothing over the network. +The server runs `npx -y turntax@0.10.0 mcp` on your machine. npx downloads the `turntax` package from npm on first use. `package.json` and `package-lock.json` in this folder pin the same version and its one dependency, with integrity hashes. The tools read instruction files and MCP configs in the folder you audit. They do not start the MCP servers they find, do not call any vendor API, and send nothing over the network. ## Install diff --git a/plugins/turntax/package.json b/plugins/turntax/package.json index 925021b..928ccfe 100644 --- a/plugins/turntax/package.json +++ b/plugins/turntax/package.json @@ -4,6 +4,6 @@ "description": "Pins the turntax package that this plugin's MCP server runs (npx -y turntax@ mcp).", "license": "MIT", "dependencies": { - "turntax": "0.9.0" + "turntax": "0.10.0" } } diff --git a/server.json b/server.json index 9150a7a..ae12560 100644 --- a/server.json +++ b/server.json @@ -8,12 +8,12 @@ "source": "github" }, "websiteUrl": "https://torutdev.github.io/turntax/", - "version": "0.9.0", + "version": "0.10.0", "packages": [ { "registryType": "npm", "identifier": "turntax", - "version": "0.9.0", + "version": "0.10.0", "runtimeHint": "npx", "packageArguments": [ { diff --git a/src/core/classify.ts b/src/core/classify.ts index a9db80c..2c127d3 100644 --- a/src/core/classify.ts +++ b/src/core/classify.ts @@ -3,13 +3,13 @@ import { basename, configList, dirname, findImports, firstParagraph, parseFrontm import { TOOLS, type FileRule, type Frontmatter, type ToolSpec } from './tools.js'; import type { LoadMode, LoadedUnit, RepoFile, ToolId } from './types.js'; -/** Works out which files each tool loads, when, and with what text. */ +/** Each normalized file's size as on disk, CRLF included: a tool applies its size limits to the file it reads. */ const RAW_BYTES = new WeakMap(); +/** Works out which files each tool loads, when, and with what text. */ export function classify(input: RepoFile[], toolIds?: ToolId[]): LoadedUnit[] { // Same text on every platform: a CRLF checkout must not count or compare differently. const files = input.map((f) => ({ path: f.path, text: f.text.replace(/\r\n/g, '\n') })); - // Sizes as on disk, CRLF included: a tool applies its size limits to the file it reads. files.forEach((f, i) => RAW_BYTES.set(f, new TextEncoder().encode(input[i]!.text).length)); const byPath = new Map(files.map((f) => [f.path, f])); const tools = toolIds ? TOOLS.filter((t) => toolIds.includes(t.id)) : TOOLS; diff --git a/src/core/tools.ts b/src/core/tools.ts index 1592693..ba411c9 100644 --- a/src/core/tools.ts +++ b/src/core/tools.ts @@ -467,7 +467,7 @@ export const TOOLS: ToolSpec[] = [ const applyTo = str(fm.applyTo).trim(); if (!applyTo && has(fm, 'description')) return { mode: 'on-demand', trigger: 'agent decides from description', descriptionOnly: true, note: 'Not observed; VS Code says the agent decides from the description.' }; - if (!applyTo) return { mode: 'always', trigger: 'no applyTo', note: 'Loaded every turn in Copilot CLI (observed); the docs do not say.' }; + if (!applyTo) return { mode: 'always', trigger: 'no applyTo', note: 'A file with no front matter loaded every turn in Copilot CLI (observed); the docs do not say.' }; if (/^\*\*(\/\*)?$/.test(applyTo)) return { mode: 'always', trigger: `applyTo: ${applyTo}` }; return { mode: 'on-demand', trigger: `applyTo: ${applyTo}` }; }, diff --git a/test/user.test.ts b/test/user.test.ts index 12d73dc..6369e20 100644 --- a/test/user.test.ts +++ b/test/user.test.ts @@ -28,6 +28,12 @@ describe('user-level files', () => { // VS Code Local harness, which is not modelled. expect(who('~/.claude/CLAUDE.md')).toEqual(['claude-code', 'opencode', 'devin']); expect(who('~/.claude/rules/style.md')).toEqual(['claude-code']); + // Copilot CLI lists personal skills from ~/.agents/skills, not ~/.claude/skills. + const skill = (path: string) => ({ path, text: '---\nname: s\ndescription: A skill.\n---\nBody.' }); + const copilotSkills = (path: string) => + classifyUser([skill(path)]).filter((u) => u.tool === 'copilot' && u.part === 'description').map((u) => u.mode); + expect(copilotSkills('~/.claude/skills/s/SKILL.md')).toEqual([]); + expect(copilotSkills('~/.agents/skills/s/SKILL.md')).toEqual(['always']); expect(who('~/.codex/AGENTS.md')).toEqual(['codex']); expect(who('~/.gemini/GEMINI.md')).toEqual(['gemini-cli']); // Amp reads both of its user files. diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md index 3b2da7a..d039fc6 100644 --- a/vscode/CHANGELOG.md +++ b/vscode/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.5.0 + +- The engine of turntax 0.10.0: GitHub Copilot is counted as Copilot CLI loads instruction files (checked against Copilot CLI 1.0.107), which VS Code's Copilot harness shares, and a root `CLAUDE.md` over 4 MiB counts as skipped by Claude Code. + ## 0.4.0 - The engine of turntax 0.9.0: loading rules re-checked against every agent's docs on 2026-11-06 (Augment Code reads `AGENTS.md` instead of a `CLAUDE.md` in the same folder, Devin's custom subagents are counted, Claude Code size limits), and duplicate findings and fixes leave table rows alone. diff --git a/vscode/package-lock.json b/vscode/package-lock.json index 830f8b1..5e2a90f 100644 --- a/vscode/package-lock.json +++ b/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "turntax", - "version": "0.4.0", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "turntax", - "version": "0.4.0", + "version": "0.5.0", "license": "MIT", "devDependencies": { "@types/node": "20.19.43", diff --git a/vscode/package.json b/vscode/package.json index 4a8866d..933d4f7 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -2,7 +2,7 @@ "name": "turntax", "displayName": "turntax", "description": "Per-turn token cost of AI coding-agent instruction files (AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, skills) in the status bar, with findings and safe fixes.", - "version": "0.4.0", + "version": "0.5.0", "publisher": "torut", "icon": "icon.png", "license": "MIT", From 6b15108f2625b44800aee2a1df0d3a9f4a8296a7 Mon Sep 17 00:00:00 2001 From: Furkan Date: Sun, 8 Nov 2026 11:31:06 +0300 Subject: [PATCH 4/4] Plugin lock pins the published turntax 0.10.0 --- plugins/turntax/package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/turntax/package-lock.json b/plugins/turntax/package-lock.json index 15dbf11..81acc27 100644 --- a/plugins/turntax/package-lock.json +++ b/plugins/turntax/package-lock.json @@ -7,7 +7,7 @@ "name": "turntax-claude-plugin", "license": "MIT", "dependencies": { - "turntax": "0.9.0" + "turntax": "0.10.0" } }, "node_modules/gpt-tokenizer": { @@ -17,9 +17,9 @@ "license": "MIT" }, "node_modules/turntax": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/turntax/-/turntax-0.9.0.tgz", - "integrity": "sha512-IDblMK16utuUItWtKJtuM588fTED4SIyeHLYO6zXVDuvNuOTW3KFAhxwr+FL09oEeArh3KPU1wh5JXiNsTgYWA==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/turntax/-/turntax-0.10.0.tgz", + "integrity": "sha512-yXsjHFkObcXw6RvqkiW93YtCs5YwRJQfGSCXF3W44+sSFAXCBmHANh83PX56G5UlZXT0jQTDM5AQAF989tmy0A==", "license": "MIT", "dependencies": { "gpt-tokenizer": "4.1.0"