Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"permissions": {
"allow": [
"Bash(grep -rn \"显示工具\\\\|tool.*call.*show\\\\|showTool\\\\|displayTool\\\\|toolCallDisplay\\\\|ollamaStream\\\\|theme\\\\|outputMode\\\\|terminal.*render\" --include=*.ts /Users/bytedance/Documents/claude-code-source/src/utils/settings/)",
"Bash(grep -rn \"show\\\\|display\\\\|visible\\\\|verbose\\\\|render\" --include=*.ts /Users/bytedance/Documents/claude-code-source/src/utils/settings/types.ts)",
"Bash(grep -rn \"renderToolCall\\\\|toolCall.*card\\\\|toolCall.*block\\\\|ollama\" --include=*.ts /Users/bytedance/Documents/claude-code-source/src/ink/)",
"Bash(grep -rn \"ollamaStream\\\\|ollama.stream\\\\|showToolCall\\\\|toolCallVisible\\\\|minimalToolCall\\\\|simpleToolCall\\\\|compactTool\" --include=*.ts /Users/bytedance/Documents/claude-code-source/src/)",
"Bash(echo $CLAUDE_CODE_SIMPLE)",
"Bash(echo $CLAUDE_CODE_DISABLE_AUTO_MEMORY)",
"Bash(echo $ANTHROPIC_BASE_URL)",
"Bash(echo $OLLAMA_STREAM)",
"Bash(echo $TERM)",
"Bash(grep -rn \"ToolCall\\\\|toolCall\\\\|tool.*block\\\\|renderTool\\\\|ollama\" --include=*.ts /Users/bytedance/Documents/claude-code-source/src/ink/)",
"Bash(find /Users/bytedance/Documents/claude-code-source/src/ink -type f -name *.ts -o -name *.tsx)",
"Bash(grep -rn \"ollama\\\\|tool_call\\\\|tool_use\\\\|synthetic\\\\|simulate\" --include=*.ts --include=*.tsx /Users/bytedance/Documents/claude-code-source/src/)",
"Bash(find /Users/bytedance/Documents/claude-code-source/src/components -type f -name *.tsx -o -name *.ts)",
"Bash(find /Users/bytedance/Documents/claude-code-source/src -path */components/* -name *.tsx)",
"Bash(echo $COLORTERM)"
]
},
"env": {
"ENABLE_TOOL_SEARCH": "true"
}
}
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "bun",
"request": "launch",
"name": "Debug Claude Code",
"program": "${workspaceFolder}/src/entrypoints/cli.tsx",
"args": [],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"watchMode": true
},
{
"type": "bun",
"request": "attach",
"name": "Attach to Bun CLI",
"port": 9229,
"stopOnEntry": false
}
]
}
39 changes: 39 additions & 0 deletions src/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// {
// "version": "0.2.0",
// "configurations": [
// {
// "type": "bun",
// "request": "launch",
// "name": "Debug dev-cli",
// "program": "${workspaceFolder}/src/entrypoints/dev-cli.tsx",
// "cwd": "${workspaceFolder}",
// "stopOnEntry": false,
// "watchMode": false,
// "internalConsoleOptions": "neverOpen"
// },
// {
// "type": "bun",
// "request": "launch",
// "name": "Debug dev-mcp",
// "program": "${workspaceFolder}/src/entrypoints/dev-mcp.ts",
// "cwd": "${workspaceFolder}"
// }
// ]
// }


{
"version": "0.2.0",
"configurations": [
{
"type": "bun",
"request": "launch",
"name": "Debug Claude Code",
"program": "${workspaceFolder}/src/entrypoints/cli.tsx",
"args": [],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"watchMode": false
}
]
}
1 change: 1 addition & 0 deletions src/constants/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function getSimpleSystemSection(): string {

function getSimpleDoingTasksSection(): string {
const codeStyleSubitems = [
`Do not place root cause attributions dependent on assumptions in the main cause ranking to determine the likelihood of the assumptions.`,
`Don't add features, refactor code, or make "improvements" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.`,
`Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.`,
`Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is what the task actually requires—no speculative abstractions, but no half-finished implementations either. Three similar lines of code is better than a premature abstraction.`,
Expand Down
44 changes: 44 additions & 0 deletions src/middleware/extractOriginalUserInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Walks state.messages backwards and returns the text of the most recent
* *original* user message — i.e. one that is role='user' and NOT flagged as
* meta (system-injected recovery / hook / verification constraint messages).
*
* Used by the verification middleware so Stage 2 can decide "is this claim
* derivable from the user's actual question?" against the real user input,
* not against an internally-generated recovery prompt.
*/

import type { Message } from '../types/message.js'

export function extractOriginalUserInput(
messages: readonly Message[],
): string {
for (let i = messages.length - 1; i >= 0; i--) {
const m = messages[i]
if (m.type !== 'user') continue
// Skip anything the harness marked as meta (recovery prompts, hook
// blockers, our own verification constraint injection).
if ((m as unknown as { isMeta?: boolean }).isMeta) continue
const text = extractTextFromUserMessage(m)
if (text.trim().length > 0) return text
}
return ''
}

function extractTextFromUserMessage(m: Message): string {
const content = (m as unknown as { message?: { content?: unknown } })
.message?.content
if (!content) return ''
if (typeof content === 'string') return content
if (!Array.isArray(content)) return ''
const parts: string[] = []
for (const block of content as Array<
{ type: string; text?: string; content?: unknown }
>) {
if (block.type === 'text' && typeof block.text === 'string') {
parts.push(block.text)
}
// tool_result blocks may echo prior model text; ignore.
}
return parts.join('\n')
}
Loading