Skip to content

Commit dec92bc

Browse files
authored
mods: revert two changes (agents-md truncated reads, diff forced colors) (#98018)
* 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"
1 parent 8364969 commit dec92bc

4 files changed

Lines changed: 3 additions & 122 deletions

File tree

‎mods/agents-md/hooks/register.ts‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,7 @@ export function register(on: On, options: PluginOptions): void {
223223
...Files.filesOf(claude),
224224
]).filter(file => !sent.has(file.path))
225225
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
234227

235228
for (const file of fresh) {
236229
const isSent =

‎mods/agents-md/tests/register.test.ts‎

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -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'
22

33
import Hooks from '../hooks'
44
import Fixtures from './fixtures'
@@ -84,79 +84,6 @@ describe('register', () => {
8484
).toEqual({ blocks: BLOCKS, instructionFiles: [] })
8585
})
8686

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-
16087
test(
16188
'the start sends the mode row alone: no walk, no toast',
16289
{ plugins: [Fixtures.RECORDING] },

‎mods/diff/hooks/git/argv/diff-leading-args.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
*
55
* Root-relative paths whatever `diff.relative` says, non-ASCII paths as
66
* 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.
108
*/
119
export const DIFF_LEADING_ARGS = [
1210
'--no-optional-locks',
@@ -15,7 +13,6 @@ export const DIFF_LEADING_ARGS = [
1513
'-c',
1614
'core.quotePath=false',
1715
'diff',
18-
'--no-color',
1916
'--no-ext-diff',
2017
'--no-textconv',
2118
'--ignore-submodules=dirty',

‎mods/diff/tests/git/fetch-diff.test.ts‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -148,42 +148,6 @@ describe('fetch-diff', () => {
148148
).toBe(true)
149149
})
150150

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-
187151
test('uncommitted mode drops pre-session untracked files', async () => {
188152
const outcome = await Git.fetchDiff(
189153
depsOf(

0 commit comments

Comments
 (0)