Skip to content

log:增加log打印#91

Closed
shrakin wants to merge 3 commits intoclaude-code-best:mainfrom
shrakin:Develop
Closed

log:增加log打印#91
shrakin wants to merge 3 commits intoclaude-code-best:mainfrom
shrakin:Develop

Conversation

@shrakin
Copy link
Copy Markdown

@shrakin shrakin commented Apr 3, 2026

Summary by CodeRabbit

  • Chores

    • Version bumped to 2026.4.3-restored; package marked private and license field added.
    • Added a new dev-debug script to aid debugging.
  • Documentation

    • Expanded CLI, build/dev, feature-flag, architecture, and testing docs.
    • Added a new projects-collection guide listing community projects and blogs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

Package metadata updated (version, private, license, new dev-debug script). Added extensive debug logging in the Claude API service and AgentTool to emit request, tool-use, streaming, and agent-execution details. Several documentation files were added or expanded (CLAUDE.md, docs/projects-collection.md).

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Version -> 2026.4.3-restored, private: true, license: "SEE LICENSE IN LICENSE.md", added dev-debug script and referenced by dev:inspect.
API Debug Logging
src/services/api/claude.ts
Added detailed debug logs for constructed requests (model/max_tokens, system/messages or truncated prompt), tool counts and summaries, streaming tool_use/server_tool_use events, and message_delta response summaries (stop reason, usage, newMessages). No control-flow changes.
Agent Tool Logging
src/tools/AgentTool/AgentTool.tsx
Inserted extensive logForDebugging calls capturing invocation params, teammate spawn/resolution, selected agent definition metadata, remote/async launch details, and finalize stats (tokens, tool usage, duration). No API/signature changes.
Documentation & Guides
CLAUDE.md, docs/projects-collection.md
Added/expanded CLI commands, feature defaults, architecture sections (Bridge/Daemon/Remote), testing counts, and a new projects collection doc. Documentation-only changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • KonghaYao

Poem

🐰 I hopped through code with careful paws,

logging tokens, prompts, and cause.
A version stamped and docs anew,
private package, license true.
Debug trails bright — a rabbit's applause! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'log:增加log打印' (log: add log printing) accurately describes the primary changes in the changeset, which focus on adding debugging and logging statements across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/services/api/claude.ts`:
- Around line 2260-2263: The code unconditionally logs full assistant response
content by calling logForDebugging(`[API_RESPONSE_CONTENT]
${jsonStringify(newMessages)}`), which bypasses the CLAUDE_CODE_LOG_FULL_PROMPT
gating used for request logging; modify the block that logs API response content
so it only logs the full jsonStringify(newMessages) when the
CLAUDE_CODE_LOG_FULL_PROMPT flag (or equivalent debug check used in
src/utils/debug.ts) is set, otherwise log a redacted/summary version (e.g.,
count or truncated text) — update the lines around logForDebugging, newMessages
and jsonStringify usage to mirror the request-logging pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7ee03950-3a92-4db3-8f01-e3b2badb1d33

📥 Commits

Reviewing files that changed from the base of the PR and between 4a9e918 and 1e4d426.

📒 Files selected for processing (3)
  • package.json
  • src/services/api/claude.ts
  • src/tools/AgentTool/AgentTool.tsx

Comment on lines +2260 to +2263
// 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)}`)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Consider gating full response content logging with CLAUDE_CODE_LOG_FULL_PROMPT.

Line 2263 logs the entire newMessages array via jsonStringify, which contains assistant message content. This is inconsistent with the request logging (lines 1790-1796) where full content requires CLAUDE_CODE_LOG_FULL_PROMPT to be set.

From the context in src/utils/debug.ts:173-186, ant users always have debug logs written (for /share and bug reports), meaning this full response content would be logged unconditionally for internal users.

🛡️ 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
Verify each finding against the current code and only fix it if needed.

In `@src/services/api/claude.ts` around lines 2260 - 2263, The code
unconditionally logs full assistant response content by calling
logForDebugging(`[API_RESPONSE_CONTENT] ${jsonStringify(newMessages)}`), which
bypasses the CLAUDE_CODE_LOG_FULL_PROMPT gating used for request logging; modify
the block that logs API response content so it only logs the full
jsonStringify(newMessages) when the CLAUDE_CODE_LOG_FULL_PROMPT flag (or
equivalent debug check used in src/utils/debug.ts) is set, otherwise log a
redacted/summary version (e.g., count or truncated text) — update the lines
around logForDebugging, newMessages and jsonStringify usage to mirror the
request-logging pattern.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CLAUDE.md (1)

1-179: ⚠️ Potential issue | 🟠 Major

Inconsistency: PR title indicates code changes, but only documentation is modified.

The PR title is "log:增加log打印" (add log printing) and the AI summary mentions "Added extensive debug logging in the Claude API service and AgentTool," but the only file in this diff is CLAUDE.md, which is pure documentation.

Either the actual code changes are missing from this review, or the PR title/description is incorrect.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` around lines 1 - 179, The PR title/AI summary claim code changes
("log:增加log打印", "Added extensive debug logging in the Claude API service and
AgentTool") but the diff only contains CLAUDE.md (documentation); fix by either
updating the PR title/description to accurately reflect that only CLAUDE.md was
changed or by adding the missing code changes (e.g., the logging modifications
referenced in the summary) to the repo; reference the PR title string and the AI
summary phrase so you can locate and correct the mismatch, and ensure any
intended code edits touch the actual modules mentioned (e.g.,
src/services/api/claude.ts and src/tools/AgentTool/*) if you opt to include the
logging changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CLAUDE.md`:
- Around line 63-73: Update the CLI fast-path list in CLAUDE.md to include the
missing templates/environment-runner/self-hosted-runner fast path that exists in
src/entrypoints/cli.tsx (the block around the
templates/environment-runner/self-hosted-runner check that runs after the
ps/logs/attach/kill/--bg feature-gated BG_SESSIONS branch and before the --tmux
+ --worktree branch); add a single bullet describing that fast path in the
priority order so the documentation matches the actual control flow.

---

Outside diff comments:
In `@CLAUDE.md`:
- Around line 1-179: The PR title/AI summary claim code changes ("log:增加log打印",
"Added extensive debug logging in the Claude API service and AgentTool") but the
diff only contains CLAUDE.md (documentation); fix by either updating the PR
title/description to accurately reflect that only CLAUDE.md was changed or by
adding the missing code changes (e.g., the logging modifications referenced in
the summary) to the repo; reference the PR title string and the AI summary
phrase so you can locate and correct the mismatch, and ensure any intended code
edits touch the actual modules mentioned (e.g., src/services/api/claude.ts and
src/tools/AgentTool/*) if you opt to include the logging changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e06e5565-31ee-4c4c-bdd7-a7b75c0812fd

📥 Commits

Reviewing files that changed from the base of the PR and between 1e4d426 and 5d5f3dc.

📒 Files selected for processing (2)
  • CLAUDE.md
  • docs/projects-collection.md
✅ Files skipped from review due to trivial changes (1)
  • docs/projects-collection.md

Comment on lines +63 to +73
1. **`src/entrypoints/cli.tsx`** — True entrypoint。`main()` 函数按优先级处理多条快速路径:
- `--version` / `-v` — 零模块加载
- `--dump-system-prompt` — feature-gated (DUMP_SYSTEM_PROMPT)
- `--claude-in-chrome-mcp` / `--chrome-native-host`
- `--daemon-worker=<kind>` — feature-gated (DAEMON)
- `remote-control` / `rc` / `bridge` — feature-gated (BRIDGE_MODE)
- `daemon` — feature-gated (DAEMON)
- `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS)
- `--tmux` + `--worktree` 组合
- 默认路径:加载 `main.tsx` 启动完整 CLI
2. **`src/main.tsx`** (~4680 行) — Commander.js CLI definition。注册大量 subcommands:`mcp` (serve/add/remove/list...)、`server`、`ssh`、`open`、`auth`、`plugin`、`agents`、`auto-mode`、`doctor`、`update` 等。主 `.action()` 处理器负责权限、MCP、会话恢复、REPL/Headless 模式分发。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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 the ps/logs/attach/kill/--bg path and the --tmux + --worktree path, 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
1. **`src/entrypoints/cli.tsx`** — True entrypoint。`main()` 函数按优先级处理多条快速路径:
- `--version` / `-v` — 零模块加载
- `--dump-system-prompt` — feature-gated (DUMP_SYSTEM_PROMPT)
- `--claude-in-chrome-mcp` / `--chrome-native-host`
- `--daemon-worker=<kind>` — feature-gated (DAEMON)
- `remote-control` / `rc` / `bridge` — feature-gated (BRIDGE_MODE)
- `daemon` — feature-gated (DAEMON)
- `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS)
- `--tmux` + `--worktree` 组合
- 默认路径:加载 `main.tsx` 启动完整 CLI
2. **`src/main.tsx`** (~4680 行) — Commander.js CLI definition。注册大量 subcommands:`mcp` (serve/add/remove/list...)、`server``ssh``open``auth``plugin``agents``auto-mode``doctor``update` 等。主 `.action()` 处理器负责权限、MCP、会话恢复、REPL/Headless 模式分发。
1. **`src/entrypoints/cli.tsx`** — True entrypoint。`main()` 函数按优先级处理多条快速路径:
- `--version` / `-v` — 零模块加载
- `--dump-system-prompt` — feature-gated (DUMP_SYSTEM_PROMPT)
- `--claude-in-chrome-mcp` / `--chrome-native-host`
- `--daemon-worker=<kind>` — feature-gated (DAEMON)
- `remote-control` / `rc` / `bridge` — feature-gated (BRIDGE_MODE)
- `daemon` — feature-gated (DAEMON)
- `ps` / `logs` / `attach` / `kill` / `--bg` — feature-gated (BG_SESSIONS)
- `templates` / `environment-runner` / `self-hosted-runner` — feature-gated paths
- `--tmux` + `--worktree` 组合
- 默认路径:加载 `main.tsx` 启动完整 CLI
2. **`src/main.tsx`** (~4680 行) — Commander.js CLI definition。注册大量 subcommands:`mcp` (serve/add/remove/list...)、`server``ssh``open``auth``plugin``agents``auto-mode``doctor``update` 等。主 `.action()` 处理器负责权限、MCP、会话恢复、REPL/Headless 模式分发。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` around lines 63 - 73, Update the CLI fast-path list in CLAUDE.md
to include the missing templates/environment-runner/self-hosted-runner fast path
that exists in src/entrypoints/cli.tsx (the block around the
templates/environment-runner/self-hosted-runner check that runs after the
ps/logs/attach/kill/--bg feature-gated BG_SESSIONS branch and before the --tmux
+ --worktree branch); add a single bullet describing that fast path in the
priority order so the documentation matches the actual control flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants