surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
* Revert "agents-md: the truncated-read tests laid out as the formatter lays them" * Revert "fix(agents-md): retain instructions after truncated reads" * Revert "diff: the shared diff arguments' doc says what --no-color pins" * Revert "fix(diff): preserve hunks when Git forces colored output"
| Mmods/agents-md/hooks/register.ts |
| Mmods/agents-md/tests/register.test.ts |
| Mmods/diff/hooks/git/argv/diff-leading-args.ts |
| Mmods/diff/tests/git/fetch-diff.test.ts |
| @@ -223,14 +223,7 @@ | ||
| 223 | 223 | ...Files.filesOf(claude), |
| 224 | 224 | ]).filter(file => !sent.has(file.path)) |
| 225 | 225 | const attached = fresh.filter(file => !Frames.isFileAt(file, read)) |
| 226 | - const output = result.result | |
| 227 | - const isPartialText = | |
| 228 | - output?.type === 'text' && | |
| 229 | - (output.file.truncatedByTokenCap || | |
| 230 | - output.file.startLine !== 1 || | |
| 231 | - output.file.numLines < output.file.totalLines) | |
| 232 | - const isWholeRead = | |
| 233 | - e.offset === undefined && e.limit === undefined && !isPartialText | |
| 226 | + const isWholeRead = e.offset === undefined && e.limit === undefined | |
| 234 | 227 | |
| 235 | 228 | for (const file of fresh) { |
| 236 | 229 | const isSent = |
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { describe, expect, mock, test, tier } from 'claude-code/testing' | |
| 1 | +import { describe, expect, test, tier } from 'claude-code/testing' | |
| 2 | 2 | |
| 3 | 3 | import Hooks from '../hooks' |
| 4 | 4 | import Fixtures from './fixtures' |
| @@ -84,79 +84,6 @@ | ||
| 84 | 84 | ).toEqual({ blocks: BLOCKS, instructionFiles: [] }) |
| 85 | 85 | }) |
| 86 | 86 | |
| 87 | - for (const [name, args, file, attaches] of [ | |
| 88 | - [ | |
| 89 | - 'an auto-paginated read', | |
| 90 | - {}, | |
| 91 | - { content: '# head\nfollow', truncatedByTokenCap: true }, | |
| 92 | - true, | |
| 93 | - ], | |
| 94 | - ['an incomplete line range', {}, { content: '# head', numLines: 1 }, true], | |
| 95 | - ['a complete read', {}, {}, false], | |
| 96 | - [ | |
| 97 | - 'an explicit limit', | |
| 98 | - { limit: 1 }, | |
| 99 | - { content: '# head', numLines: 1 }, | |
| 100 | - true, | |
| 101 | - ], | |
| 102 | - [ | |
| 103 | - 'an explicit offset', | |
| 104 | - { offset: 2 }, | |
| 105 | - { content: 'follow the tail rule', numLines: 1, startLine: 2 }, | |
| 106 | - true, | |
| 107 | - ], | |
| 108 | - ['an unstructured result', {}, undefined, false], | |
| 109 | - ] as const) { | |
| 110 | - test(`a nested AGENTS.md after ${name}`, async ($, on) => { | |
| 111 | - const dir = `${Fixtures.SESSION.cwd}/nested` | |
| 112 | - const path = `${dir}/AGENTS.md` | |
| 113 | - const content = '# head\nfollow the tail rule' | |
| 114 | - const started = Fixtures.projectOf( | |
| 115 | - on, | |
| 116 | - [Fixtures.ancestorOf(dir, 'AGENTS.md', content)], | |
| 117 | - [], | |
| 118 | - ) | |
| 119 | - | |
| 120 | - mock.env(on, {}) | |
| 121 | - on('session.cwd', () => ({ value: Fixtures.SESSION.cwd })) | |
| 122 | - on('tool.call', ($, e) => ({ | |
| 123 | - result: | |
| 124 | - e.tool === 'Read' && file !== undefined | |
| 125 | - ? { | |
| 126 | - type: 'text', | |
| 127 | - file: Object.assign( | |
| 128 | - { | |
| 129 | - filePath: e.file_path, | |
| 130 | - content, | |
| 131 | - numLines: 2, | |
| 132 | - startLine: 1, | |
| 133 | - totalLines: 2, | |
| 134 | - }, | |
| 135 | - file, | |
| 136 | - ), | |
| 137 | - } | |
| 138 | - : 'read', | |
| 139 | - })) | |
| 140 | - | |
| 141 | - const direct = await $.tool.call({ | |
| 142 | - tool: 'Read', | |
| 143 | - file_path: path, | |
| 144 | - ...args, | |
| 145 | - }) | |
| 146 | - const source = { tool: 'Read', file_path: `${dir}/source.ts` } as const | |
| 147 | - const after = await $.tool.call(source) | |
| 148 | - const repeated = await $.tool.call(source) | |
| 149 | - | |
| 150 | - expect(direct.context).toBeUndefined() | |
| 151 | - expect(after.context).toEqual( | |
| 152 | - attaches ? [`Contents of ${path}:\n\n${content}`] : undefined, | |
| 153 | - ) | |
| 154 | - expect(repeated.context).toBeUndefined() | |
| 155 | - | |
| 156 | - await started.clock.settle() | |
| 157 | - }) | |
| 158 | - } | |
| 159 | - | |
| 160 | 87 | test( |
| 161 | 88 | 'the start sends the mode row alone: no walk, no toast', |
| 162 | 89 | { plugins: [Fixtures.RECORDING] }, |
| @@ -4,9 +4,7 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * Root-relative paths whatever `diff.relative` says, non-ASCII paths as |
| 6 | 6 | * their own bytes, no optional locks, no child `git status` in a dirty |
| 7 | - * submodule, no external diff or textconv driver even on a stats pass, and | |
| 8 | - * no color escapes whatever `color.ui` or `color.diff` says, so a hunk | |
| 9 | - * header parses where either is set to `always`. | |
| 7 | + * submodule, and no external diff or textconv driver even on a stats pass. | |
| 10 | 8 | */ |
| 11 | 9 | export const DIFF_LEADING_ARGS = [ |
| 12 | 10 | '--no-optional-locks', |
| @@ -15,7 +13,6 @@ | ||
| 15 | 13 | '-c', |
| 16 | 14 | 'core.quotePath=false', |
| 17 | 15 | 'diff', |
| 18 | - '--no-color', | |
| 19 | 16 | '--no-ext-diff', |
| 20 | 17 | '--no-textconv', |
| 21 | 18 | '--ignore-submodules=dirty', |
| @@ -148,42 +148,6 @@ | ||
| 148 | 148 | ).toBe(true) |
| 149 | 149 | }) |
| 150 | 150 | |
| 151 | - test("forced git colors do not hide a changed file's hunks", async () => { | |
| 152 | - const deps = depsOf({ | |
| 153 | - 'HEAD --shortstat': Fixtures.ok( | |
| 154 | - ' 1 file changed, 1 insertion(+), 1 deletion(-)', | |
| 155 | - ), | |
| 156 | - 'HEAD --numstat': Fixtures.ok('1\t1\ta.ts\0'), | |
| 157 | - 'ls-files': Fixtures.ok(), | |
| 158 | - }) | |
| 159 | - | |
| 160 | - const git = Fixtures.scriptedGitOf({ | |
| 161 | - '--no-color': Fixtures.ok('@@ -1 +1 @@\n-old\n+new\n'), | |
| 162 | - diff: Fixtures.ok( | |
| 163 | - '\x1b[36m@@ -1 +1 @@\x1b[m\n\x1b[31m-old\x1b[m\n' + | |
| 164 | - '\x1b[32m+\x1b[m\x1b[32mnew\x1b[m\n', | |
| 165 | - ), | |
| 166 | - }) | |
| 167 | - | |
| 168 | - const outcome = await Git.fetchDiff(deps, 'uncommitted') | |
| 169 | - const data = outcome.kind === 'data' ? outcome.data : null | |
| 170 | - const [row] = data?.files ?? [] | |
| 171 | - | |
| 172 | - expect(data?.stats).toEqual({ | |
| 173 | - filesCount: 1, | |
| 174 | - linesAdded: 1, | |
| 175 | - linesRemoved: 1, | |
| 176 | - }) | |
| 177 | - | |
| 178 | - expect( | |
| 179 | - data && row ? await Git.fetchFileHunks(git.run, data, row) : null, | |
| 180 | - ).toEqual({ | |
| 181 | - hunks: [{ oldStart: 1, newStart: 1, lines: ['-old', '+new'] }], | |
| 182 | - isTruncated: false, | |
| 183 | - isLarge: false, | |
| 184 | - }) | |
| 185 | - }) | |
| 186 | - | |
| 187 | 151 | test('uncommitted mode drops pre-session untracked files', async () => { |
| 188 | 152 | const outcome = await Git.fetchDiff( |
| 189 | 153 | depsOf( |