Skip to content

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.

TypeScript

mods: revert two changes (agents-md truncated reads, diff forced colors) (#98018)

Alice T'Poteatdec92bc87ab6
diff --git a/mods/agents-md/hooks/register.ts b/mods/agents-md/hooks/register.ts
index 73cc1327..40911d73 100644
--- a/mods/agents-md/hooks/register.ts
+++ b/mods/agents-md/hooks/register.ts
@@ -223,14 +223,7 @@ export function register(on: On, options: PluginOptions): void {
...Files.filesOf(claude),
]).filter(file => !sent.has(file.path))
const attached = fresh.filter(file => !Frames.isFileAt(file, read))
- const output = result.result
- const isPartialText =
- output?.type === 'text' &&
- (output.file.truncatedByTokenCap ||
- output.file.startLine !== 1 ||
- output.file.numLines < output.file.totalLines)
- const isWholeRead =
- e.offset === undefined && e.limit === undefined && !isPartialText
+ const isWholeRead = e.offset === undefined && e.limit === undefined
for (const file of fresh) {
const isSent =
diff --git a/mods/agents-md/tests/register.test.ts b/mods/agents-md/tests/register.test.ts
index 674106f1..970c98f4 100644
--- a/mods/agents-md/tests/register.test.ts
+++ b/mods/agents-md/tests/register.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, mock, test, tier } from 'claude-code/testing'
+import { describe, expect, test, tier } from 'claude-code/testing'
import Hooks from '../hooks'
import Fixtures from './fixtures'
@@ -84,79 +84,6 @@ describe('register', () => {
).toEqual({ blocks: BLOCKS, instructionFiles: [] })
})
- for (const [name, args, file, attaches] of [
- [
- 'an auto-paginated read',
- {},
- { content: '# head\nfollow', truncatedByTokenCap: true },
- true,
- ],
- ['an incomplete line range', {}, { content: '# head', numLines: 1 }, true],
- ['a complete read', {}, {}, false],
- [
- 'an explicit limit',
- { limit: 1 },
- { content: '# head', numLines: 1 },
- true,
- ],
- [
- 'an explicit offset',
- { offset: 2 },
- { content: 'follow the tail rule', numLines: 1, startLine: 2 },
- true,
- ],
- ['an unstructured result', {}, undefined, false],
- ] as const) {
- test(`a nested AGENTS.md after ${name}`, async ($, on) => {
- const dir = `${Fixtures.SESSION.cwd}/nested`
- const path = `${dir}/AGENTS.md`
- const content = '# head\nfollow the tail rule'
- const started = Fixtures.projectOf(
- on,
- [Fixtures.ancestorOf(dir, 'AGENTS.md', content)],
- [],
- )
-
- mock.env(on, {})
- on('session.cwd', () => ({ value: Fixtures.SESSION.cwd }))
- on('tool.call', ($, e) => ({
- result:
- e.tool === 'Read' && file !== undefined
- ? {
- type: 'text',
- file: Object.assign(
- {
- filePath: e.file_path,
- content,
- numLines: 2,
- startLine: 1,
- totalLines: 2,
- },
- file,
- ),
- }
- : 'read',
- }))
-
- const direct = await $.tool.call({
- tool: 'Read',
- file_path: path,
- ...args,
- })
- const source = { tool: 'Read', file_path: `${dir}/source.ts` } as const
- const after = await $.tool.call(source)
- const repeated = await $.tool.call(source)
-
- expect(direct.context).toBeUndefined()
- expect(after.context).toEqual(
- attaches ? [`Contents of ${path}:\n\n${content}`] : undefined,
- )
- expect(repeated.context).toBeUndefined()
-
- await started.clock.settle()
- })
- }
-
test(
'the start sends the mode row alone: no walk, no toast',
{ plugins: [Fixtures.RECORDING] },
diff --git a/mods/diff/hooks/git/argv/diff-leading-args.ts b/mods/diff/hooks/git/argv/diff-leading-args.ts
index e30db4f5..fe77659e 100644
--- a/mods/diff/hooks/git/argv/diff-leading-args.ts
+++ b/mods/diff/hooks/git/argv/diff-leading-args.ts
@@ -4,9 +4,7 @@
*
* Root-relative paths whatever `diff.relative` says, non-ASCII paths as
* their own bytes, no optional locks, no child `git status` in a dirty
- * submodule, no external diff or textconv driver even on a stats pass, and
- * no color escapes whatever `color.ui` or `color.diff` says, so a hunk
- * header parses where either is set to `always`.
+ * submodule, and no external diff or textconv driver even on a stats pass.
*/
export const DIFF_LEADING_ARGS = [
'--no-optional-locks',
@@ -15,7 +13,6 @@ export const DIFF_LEADING_ARGS = [
'-c',
'core.quotePath=false',
'diff',
- '--no-color',
'--no-ext-diff',
'--no-textconv',
'--ignore-submodules=dirty',
diff --git a/mods/diff/tests/git/fetch-diff.test.ts b/mods/diff/tests/git/fetch-diff.test.ts
index a52a530d..b9cb7bbe 100644
--- a/mods/diff/tests/git/fetch-diff.test.ts
+++ b/mods/diff/tests/git/fetch-diff.test.ts
@@ -148,42 +148,6 @@ describe('fetch-diff', () => {
).toBe(true)
})
- test("forced git colors do not hide a changed file's hunks", async () => {
- const deps = depsOf({
- 'HEAD --shortstat': Fixtures.ok(
- ' 1 file changed, 1 insertion(+), 1 deletion(-)',
- ),
- 'HEAD --numstat': Fixtures.ok('1\t1\ta.ts\0'),
- 'ls-files': Fixtures.ok(),
- })
-
- const git = Fixtures.scriptedGitOf({
- '--no-color': Fixtures.ok('@@ -1 +1 @@\n-old\n+new\n'),
- diff: Fixtures.ok(
- '\x1b[36m@@ -1 +1 @@\x1b[m\n\x1b[31m-old\x1b[m\n' +
- '\x1b[32m+\x1b[m\x1b[32mnew\x1b[m\n',
- ),
- })
-
- const outcome = await Git.fetchDiff(deps, 'uncommitted')
- const data = outcome.kind === 'data' ? outcome.data : null
- const [row] = data?.files ?? []
-
- expect(data?.stats).toEqual({
- filesCount: 1,
- linesAdded: 1,
- linesRemoved: 1,
- })
-
- expect(
- data && row ? await Git.fetchFileHunks(git.run, data, row) : null,
- ).toEqual({
- hunks: [{ oldStart: 1, newStart: 1, lines: ['-old', '+new'] }],
- isTruncated: false,
- isLarge: false,
- })
- })
-
test('uncommitted mode drops pre-session untracked files', async () => {
const outcome = await Git.fetchDiff(
depsOf(