Repository navigation
log:增加log打印 #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log:增加log打印 #91
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # 社区项目 & Blog 合集 | ||
|
|
||
| > 每日更新,欢迎自荐! | ||
|
|
||
| ## 工具 & 应用 | ||
|
|
||
| | 项目 | 描述 | 作者 | | ||
| |------|------|------| | ||
| | [4qtask.vercel.app](https://4qtask.vercel.app/) | 免费四象限时间管理工具 | @kevinhuky | | ||
| | [kaying.studio](https://kaying.studio/) | 个人 AI 工具箱 | @kayingai | | ||
| | [supsub.ai](https://supsub.ai/) | 高效阅读工具 | @hidumou | | ||
| | [x-video-download.net](https://x-video-download.net/) | 视频下载工具 | @syakadou | | ||
| | [1openapi.com](https://1openapi.com/) | API 中转站 | @thinker007 | | ||
| | [claw-z.com](https://claw-z.com/) | 一键部署 OpenClaw AI Agent(场景驱动、全面管理) | @uhhc | | ||
| | [gemini-watermark-remover.net](https://gemini-watermark-remover.net/) | Gemini 水印移除工具 | @syakadou | | ||
|
|
||
| ## GitHub 开源项目 | ||
|
|
||
| | 项目 | 描述 | 作者 | | ||
| |------|------|------| | ||
| | [VersperClaw](https://github.com/versperai/VersperClaw) | 全自动科研流 | @versperai | | ||
| | [claude-reviews-claude](https://github.com/openedclaude/claude-reviews-claude) | 原汤化原食——Claude 如何看待眼中的老己 | @openedclaude | | ||
| | [agentica](https://github.com/shibing624/agentica) | 自研 Agent 框架,借鉴 claude-code 多 Agent 处理 | @shibing624 | | ||
| | [macman](https://github.com/tonngw/macman) | Mac 从 0 到 1 保姆级配置教程 | @tonngw | | ||
| | [SuperSpec](https://github.com/asasugar/SuperSpec) | SDD / Spec-Driven Development | @asasugar | | ||
| | [adnify](https://github.com/adnaan-worker/adnify) | 高颜值高定制化 AI 编辑器 | @adnaan-worker | | ||
| | [another-rule-engine](https://github.com/eatmoreduck/another-rule-engine) | 基于 Groovy 的开源多功能决策引擎 | @eatmoreduck | | ||
| | [creative_master](https://github.com/chatabc/creative_master) | AI 驱动的创意灵感管理工具 | @chatabc | | ||
| | [RapidDoc](https://github.com/RapidAI/RapidDoc) | Office 文件解析工具转 Markdown(支持 PDF/Image/Word/PPT/Excel) | @hzkitt | | ||
|
|
||
| ## Blog | ||
|
|
||
| | 链接 | 作者 | | ||
| |------|------| | ||
| | [blog.xiaohuangyu.space](https://blog.xiaohuangyu.space/) | @eatmoreduck | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1784,6 +1784,27 @@ async function* queryModel( | |
| const params = paramsFromContext(context) | ||
| captureAPIRequest(params, options.querySource) // Capture for bug reports | ||
|
|
||
| // Log the full API request to debug log file | ||
| logForDebugging(`[API_REQUEST] model=${params.model} max_tokens=${params.max_tokens}`) | ||
| // Set CLAUDE_CODE_LOG_FULL_PROMPT=1 to log full system prompt and messages | ||
| if (isEnvTruthy(process.env.CLAUDE_CODE_LOG_FULL_PROMPT)) { | ||
| logForDebugging(`[API_REQUEST_SYSTEM_FULL] ${jsonStringify(params.system)}`) | ||
| logForDebugging(`[API_REQUEST_MESSAGES_FULL] ${jsonStringify(params.messages)}`) | ||
| } else { | ||
| logForDebugging(`[API_REQUEST_SYSTEM] ${jsonStringify(params.system).slice(0, 5000)}...`) | ||
| logForDebugging(`[API_REQUEST_MESSAGES] count=${params.messages.length}`) | ||
| } | ||
| logForDebugging(`[API_REQUEST_TOOLS] count=${params.tools?.length ?? 0}`) | ||
| if (params.tools && params.tools.length > 0) { | ||
| for (const tool of params.tools) { | ||
| if ('name' in tool) { | ||
| logForDebugging(`[API_REQUEST_TOOL] name=${tool.name}`) | ||
| } else if ('type' in tool) { | ||
| logForDebugging(`[API_REQUEST_TOOL] type=${tool.type}`) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| maxOutputTokens = params.max_tokens | ||
|
|
||
| // Fire immediately before the fetch is dispatched. .withResponse() below | ||
|
|
@@ -1986,12 +2007,14 @@ async function* queryModel( | |
| ...part.content_block, | ||
| input: '', | ||
| } | ||
| logForDebugging(`[TOOL_USE] name=${part.content_block.name} id=${part.content_block.id}`) | ||
| break | ||
| case 'server_tool_use': | ||
| contentBlocks[part.index] = { | ||
| ...part.content_block, | ||
| input: '' as unknown as { [key: string]: unknown }, | ||
| } | ||
| logForDebugging(`[MCP_TOOL_USE] name=${part.content_block.name} id=${part.content_block.id}`) | ||
| if ((part.content_block.name as string) === 'advisor') { | ||
| isAdvisorInProgress = true | ||
| logForDebugging(`[AdvisorTool] Advisor tool called`) | ||
|
|
@@ -2234,6 +2257,11 @@ async function* queryModel( | |
| lastMsg.message.stop_reason = stopReason | ||
| } | ||
|
|
||
| // Log the API response summary | ||
| logForDebugging(`[API_RESPONSE] stop_reason=${stopReason} usage=${jsonStringify(usage)}`) | ||
| logForDebugging(`[API_RESPONSE_MESSAGES] count=${newMessages.length}`) | ||
| logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`) | ||
|
Comment on lines
+2260
to
+2263
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider gating full response content logging with Line 2263 logs the entire From the context in 🛡️ Suggested fix to align with request logging pattern // Log the API response summary
logForDebugging(`[API_RESPONSE] stop_reason=${stopReason} usage=${jsonStringify(usage)}`)
logForDebugging(`[API_RESPONSE_MESSAGES] count=${newMessages.length}`)
- logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`)
+ if (isEnvTruthy(process.env.CLAUDE_CODE_LOG_FULL_PROMPT)) {
+ logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`)
+ }🤖 Prompt for AI Agents |
||
|
|
||
| // Update cost | ||
| const costUSDForPart = calculateUSDCost(resolvedModel, usage as unknown as BetaUsage) | ||
| costUSD += addToTotalSessionCost( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete documentation of cli.tsx fast paths.
The documented priority list is missing a fast path that exists in the actual code. According to the relevant code snippet from
src/entrypoints/cli.tsx, there is a templates/environment-runner/self-hosted-runner fast path (lines 196-223) that executes between theps/logs/attach/kill/--bgpath and the--tmux + --worktreepath, but it's not mentioned in this documentation.📝 Suggested addition
Add the missing fast path to the list:
- `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS) + - `templates` / `environment-runner` / `self-hosted-runner` — feature-gated paths - `--tmux` + `--worktree` 组合Based on relevant code snippet from
src/entrypoints/cli.tsx:196-223.📝 Committable suggestion
🤖 Prompt for AI Agents