// Package reverse_think is the Go-native realization of the // ~/.claude/skills/reverse-think/ markdown skill: it sends a // reverse-thinking prompt to an Anthropic-compatible endpoint (MiniMax // by default) and returns a typed counterfactual.Deliverable. // // # Why a Go package, not a shell wrapper // // The markdown skill at ~/.claude/skills/reverse-think/SKILL.md is // invoked manually by Claude (this dev) before non-trivial design // decisions. Production agents (Flyto running in platform/) cannot read // markdown skills -- they need a callable Go function whose return // value plugs into staging.Record / hooks.HookResult / evolve.LogReplayer. // Same prompt template, same JSON schema, but typed at the seams. // // # API key handling // // The package does NOT read MINIMAX_TOKEN_PLAN_KEY from the environment. // Callers must inject Client.APIKey explicitly. Rationale: core stays // environment-agnostic; platform / CLI / TUI each surface their own // secret loading (e.g. platform layer reads env once at boot, the // markdown skill reads core/.env via shell). Hard-coding env lookup // here couples core to one secret-management style and breaks SDK use // where callers want to pass a key from a vault, KMS, or test fixture. // // # max_tokens default // // Default is 8000. Per SKILL.md, the Anthropic-compatible MiniMax // endpoint shares this budget between thinking and text output: setting // it to 3000 once produced an empty text response (thinking consumed // the entire pool). Token cost is free under the project's plan; calls // per 5h is the only quota and is effectively unreachable. Do not // shrink for "cost" reasons -- shrink only when the question is so // simple that long thinking is wasteful, and even then favour an // in-prompt instruction over reducing the pool. // // # 反向思维 skill 的 Go 化实现 // // 把 ~/.claude/skills/reverse-think/ 的 markdown skill 兑现为 Go 函数: // 向 Anthropic 兼容端点 (默认 MiniMax) 发反向思维 prompt, 返回 typed // counterfactual.Deliverable. // // 为什么做成 Go 包不做 shell wrapper: // markdown skill 给 Claude (这个 dev) 在非平凡设计决策前手动调; 生产 Agent // (Flyto 跑在 platform/) 读不了 markdown -- 需要可调 Go 函数, 返回值能直接 // 喂 staging.Record / hooks.HookResult / evolve.LogReplayer. 同 prompt 模板, // 同 JSON schema, 但接口处类型化. // // API key 处理: 本包不读 MINIMAX_TOKEN_PLAN_KEY 环境变量, 调用方显式注入 // Client.APIKey. 理由: core 与环境解耦; platform / CLI / TUI 各自决定密钥 // 加载方式. 在本包硬编码 env 读取会把 core 绑定到一种 secret 管理风格, // 破坏 SDK 用法 (从 vault / KMS / test fixture 传 key). // // max_tokens 默认 8000: 见 SKILL.md, Anthropic 兼容端点这个预算是 thinking + // text 共享池, 设 3000 实测过 thinking 用完导致 text 空响应. token 计费按 // 项目 plan 免费, 唯一限额是 calls/5h 实际碰不到. 不要为 "省钱" 缩, 只在 // 问题极简 thinking 浪费时缩, 即便如此也优选 prompt 内指令限 thinking 而非 // 减小 pool. // // # Reference files // // client.go -- Client + Run (HTTP roundtrip, JSON parse, Validate) // template.go -- Chinese prompt renderer (SKILL.md template aligned) // client_test.go -- httptest-backed roundtrip cases (no real MiniMax) package reverse_think