Skip to content

feat: Console 输出抽象层 — 替换 print() 为 Console 类 (Issue #31)#34

Merged
urika merged 1 commit into
mainfrom
fix/issue-31-console-class
May 30, 2026
Merged

feat: Console 输出抽象层 — 替换 print() 为 Console 类 (Issue #31)#34
urika merged 1 commit into
mainfrom
fix/issue-31-console-class

Conversation

@urika

@urika urika commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #31 Subtask 3

New: agent_go/console.py

Component Description
Console class Unified output with quiet/`verbose` modes
.success(msg) ✅ Success messages
.warning(msg) ⚠️ Warning messages
.error(msg) ❌ Error messages
.info(msg) Plain info (suppressed in quiet mode)
.debug(msg) Debug info (only in verbose mode)
.print(*args) Drop-in replacement for print()
.force(*args) Bypasses quiet mode (for interactive prompts)
.sep(char, width) Horizontal separator
.title(msg) Section title with decorative borders
.table(headers, rows) Formatted table output

CLI flags

  • --quiet / -q: suppress all non-error output
  • --verbose: show debug/diagnostic messages
  • --headless / --yes: auto-enables quiet mode

Migration status

File print() calls Status
cli.py 79 → cmd_run() migrated ✅ partial (other commands use print())
eval.py 76 ✅ fully migrated
config.py 2 ✅ fully migrated
pipeline.py 9 ✅ fully migrated
executor.py 2 ✅ fully migrated
workflow_gen.py 5 ✅ fully migrated
ui.py 70 ⏳ deferred (interactive prompts need force())

Verification

  • pytest tests/: 277 passed
  • All files compile clean

🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

新增:
- agent_go/console.py: Console 类(支持 quiet/verbose 模式)
  - 语义方法: success/warning/error/info/debug
  - 布局方法: sep/title/subtitle/table
  - 结构化输出: data/force(绕过 quiet 模式)
  - 模块级默认实例 + set/get_default_console 全局切换

CLI 集成:
- --quiet/-q 和 --verbose 标志(run + resume 子命令)
- cmd_run() 初始化 Console 并设为全局默认
- headless/--yes 模式自动启用 quiet

文件迁移(print → console.print):
- cli.py: cmd_run() 内的打印调用全部迁移
- eval.py: 76 个 print() → console.print()
- config.py/pipeline.py/executor.py/workflow_gen.py: 全部迁移

测试: 277 passed

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@urika urika merged commit cc50858 into main May 30, 2026
1 check failed
@urika urika deleted the fix/issue-31-console-class branch May 30, 2026 06:03
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.

[Code Quality] 代码清理三合一 — import 统一、未使用导入清理、输出抽象层

1 participant