Skip to content

fix: support macOS proxy routing and harden DeepSeek JSON generation - #9

Open
spark-star-open wants to merge 1 commit into
leiting-eric:mainfrom
spark-star-open:main
Open

fix: support macOS proxy routing and harden DeepSeek JSON generation#9
spark-star-open wants to merge 1 commit into
leiting-eric:mainfrom
spark-star-open:main

Conversation

@spark-star-open

Copy link
Copy Markdown

背景

我在 macOS 本地运行 DailyBrief 时遇到了两个问题:

  1. macOS 已开启系统代理,但 Node.js 和 curl 抓取流程没有继承代理配置,导致 Hugging Face、BBC、Guardian、Bloomberg 等多个来源连接超时。
  2. DeepSeek V4 偶尔返回空内容或截断的 JSON,导致 Generate today's report 阶段解析失败,整个 GitHub Actions 流程中断。

另外,本机没有安装 Claude CLI 时,原来的 shell: true 会导致提示词内容被 shell 当成命令执行,产生大量 command not found 日志。

修改内容

  • 新增统一的 TypeScript 启动器:
    • 优先使用 .env.local / 环境变量中的代理配置
    • macOS 下自动读取系统 HTTP(S) 代理
    • 使用 Node 的环境代理模式运行内置 fetch
  • 代理启用时,RSS 抓取自动通过 curl 执行
  • DeepSeek V4 请求启用:
    • non-thinking mode
    • JSON output mode
  • 检测空响应及 finish_reason=length 等不完整输出
  • 连续两次 JSON 输出损坏时,使用已完成的文章摘要生成可发布的降级日报
  • API 认证、配额和网络错误仍保持为显式失败,不会被降级逻辑掩盖
  • 缺少 Claude CLI 时提前给出明确配置错误
  • Unix 下不再通过 shell 执行 Claude CLI 参数

验证

  • npm test:10/10 tests passed
  • npm exec tsc -- --noEmit:passed
  • npm run sources:check:passed
  • npm run dry-run
    • 25 个来源全部成功
    • 共抓取 580 条文章
  • npm run daily
    • 共抓取 580 条文章
    • 82/82 条目标内容完成摘要
    • 21 个行情标的成功
    • DeepSeek trading commentary 和 digest 均成功
    • JSON、HTML 和 articles sidecar 均正常生成

兼容性

  • 未增加新的依赖
  • 显式设置的代理环境变量优先于 macOS 系统代理
  • 未配置代理时保持原有直连行为
  • 尚未在原仓库环境中验证 GitHub Pages 发布步骤

Constraint: macOS system proxy is not inherited automatically by terminal fetches
Confidence: high
Scope-risk: moderate
Tested: npm test; TypeScript check; sources check; dry-run fetched 580 articles
Not-tested: GitHub Pages publication
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.

1 participant