Commit Graph

642 Commits

Author SHA1 Message Date
fanghanjun 72fa992df8 feat(agent): 添加 write 工具,支持创建和覆盖写入文件
pi-agent 会话新增 write 工具,路径限制在 books/ 下,
自动创建父目录,safeBooksPath 防路径穿越。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun 038fd8d098 fix(studio): remove 50-model cap from test endpoint response
Services like PPIO (71 models) and SiliconFlow (111 models) were
truncated to 50. Return the full list.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun 2e7869000f fix(studio): probe returns knownModels when /models is unavailable
When discoveredModels is empty and probe succeeds, return the full
knownModels list (7 for MiniMax) instead of just the probed model.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun 59daff63ca fix(studio): probe uses service's own knownModels first, not global default
buildModelCandidates prioritized the global configModel (kimi-k2.5)
over service-specific models, causing MiniMax probe to try kimi-k2.5
on MiniMax's endpoint. Now uses knownModels[0] as preferredModel
for services that have them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun b787ab84d6 fix(studio): increase probe maxTokens to 248 for thinking models
maxTokens: 5 caused thinking models (MiniMax M2.7) to exhaust all
tokens on reasoning with no text output, failing the probe even
with a valid key.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun ac18cf0280 fix(studio): verify key via /test on page load, not just /models
Initial page load called GET /models which returns fallback models
without validating the key, showing false "已连接". Now calls
POST /test on mount to verify the key is actually valid.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun 03f499d459 fix(studio): validate API key before saving, not after
Previously handleSave persisted the key first, then validated.
Invalid keys were stored and shown as "connected". Now validates
via /test endpoint first — if validation fails, nothing is saved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun fa48c20812 fix(studio): short-circuit probe on 401/403 from /models
When /models returns 401 or 403, the API key is definitively invalid.
Previously the probe continued trying chat completions with fallback
models (MiniMax-M2.7 etc.), producing misleading error messages.
Now returns "API Key 无效" immediately.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun 763270c857 perf(studio): revert GET /models from full probe to simple API call
f942c84 changed GET /models to call probeServiceCapabilities which does
chat completion testing — causing zhipu to take 97s and minimax 47s.
GET /models only needs the model list, not a full API health check.
Reverted to simple /models fetch + pi-ai fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:55 -07:00
fanghanjun ae7fc4af9b perf(studio): skip API probe for services with knownModels
MiniMax GET /models took 47s because it tried the Anthropic endpoint
(no /models) and waited for timeout. Services with knownModels now
return the hardcoded list immediately, skipping the network call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:54 -07:00
fanghanjun 0d73427f33 docs(core): update system prompts with complete sub_agent param documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 04:57:54 -07:00
fanghanjun 86e8d0a6f8 fix(core): align architect/writer/auditor/reviser with pipeline params
- architect: pass full BookConfig (title, genre, platform, language,
  targetChapters, chapterWordCount, status, timestamps) instead of
  hardcoded stub
- writer: forward chapterWordCount to pipeline.writeNextChapter
- auditor: return per-issue severity/description and pass/fail status
  instead of bare issue count
- reviser: use explicit mode param instead of regex-based detection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 22:04:09 -07:00
fanghanjun 2ac2d6df77 feat(core): extend SubAgentParams with architect/writer/reviser/exporter fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 22:01:18 -07:00
fanghanjun c21e2995e2 docs: recreate CLAUDE.md with pi-agent tool design rules
Key additions:
- schema 即文档: TypeBox description directly informs the LLM
- Union+Literal for enums: model sees const constraints in JSON Schema
- No hardcoded pipeline params
- Return values must be actionable

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 21:57:00 -07:00
fanghanjun 7ce5a0465f docs: add sub_agent params alignment implementation plan (8 tasks)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 21:51:07 -07:00
fanghanjun 62f48a14e3 docs: add sub_agent params alignment design spec
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 21:47:06 -07:00
fanghanjun 17d1f9b967 feat(core): add chapterNumber param to sub_agent tool for auditor/reviser
Previously auditor and reviser always operated on the latest chapter.
Now the agent can pass an explicit chapterNumber so "重写第5章" targets
chapter 5 instead of always hitting the latest.

- Added chapterNumber to SubAgentParams schema
- auditor: pipeline.auditDraft(bookId, chapterNumber)
- reviser: pipeline.reviseDraft(bookId, chapterNumber, mode)
- Updated system prompt to document the parameter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 21:35:22 -07:00
Ma db1df2b3bf chore(release): bump to v1.3.2 and update changelog v1.3.2 2026-04-16 10:41:16 +08:00
Ma ffa0872b5e fix(cli,core): align interact and minimax regressions 2026-04-16 10:41:16 +08:00
Ma dba462c651 fix(core,studio,cli): unify service routing through presets 2026-04-16 02:05:10 +08:00
Ma a4a8d4e765 feat(studio): extract safe chat and service polish from #192 2026-04-16 02:02:11 +08:00
Ma 866048bfc2 fix(core): let bootstrap studio projects fall back to env config 2026-04-15 23:18:39 +08:00
Ma be78d4b2fc fix(core): point minimax preset to anthropic endpoint 2026-04-15 22:31:51 +08:00
Ma 30a0a5dc35 test(core): align minimax resolver expectation with domestic endpoint 2026-04-15 22:16:45 +08:00
Ma 787217191c fix(core): finalize minimax preset after merge 2026-04-15 22:13:06 +08:00
Ma 9dbc517fb5 fix(core,cli): restore provider compatibility and windows studio launch 2026-04-15 22:11:36 +08:00
Ma 5f10f209b2 feat(core): use native transport for custom anthropic chat 2026-04-15 22:08:25 +08:00
Ma f942c84fbf feat(studio): auto-detect working provider transport settings 2026-04-15 22:08:25 +08:00
Ma 7ce9577ea7 feat(cli): auto-init Studio projects on first launch 2026-04-15 22:00:40 +08:00
fanghanjun 811e055894 chore(release): bump to v1.3.1 and update changelog
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v1.3.1
2026-04-15 04:48:11 -07:00
SttFang 4721364997 Merge pull request #187 from SttFang/fix/multi-service-baseurl-resolution
fix: multi-service baseUrl resolution and MiniMax support
2026-04-15 19:40:47 +08:00
fanghanjun 6ecaf3ab92 fix(studio): broadcast book:created after agent-driven book creation
When the agent creates a book via sub_agent architect, the sidebar
didn't refresh because book:created was only broadcast from the
POST /books/create endpoint. Now the agent endpoint also broadcasts
this event when architect completes successfully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:20:08 -07:00
fanghanjun ca05a3b207 test: add regression tests for multi-service baseUrl fixes
- service-presets: MiniMax baseUrl correctness, knownModels fallback
- service-resolver: preset baseUrl/api overrides pi-ai built-in values
- normalizeBaseUrl: custom service URL normalization (trailing slash, /v1 append)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:14:42 -07:00
fanghanjun 1cf5d3341d test(architect): 添加 current_state/pending_hooks fallback 回归测试
覆盖三种场景:仅缺 current_state、仅缺 pending_hooks、两者都缺。
确保 parseSections 使用默认模板而非抛错。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:14:18 -07:00
fanghanjun fe0da0bfda feat(core): improve agent system prompt with format rules and index management
- Add output format rules: no emoji, use bullet lists/tables for structured content
- Add chapter index management instructions so the agent can detect and fix
  index.json inconsistencies (missing chapters, rewrites) using its own tools

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:10:41 -07:00
fanghanjun 8d122876ae fix(studio): fix multi-service baseUrl resolution and custom URL normalization
- Test connection: remove slow chat completion, just validate via /models + fallback
- GET models: add pi-ai fallback when /models returns 404
- Agent fallback/probe: use empty baseUrl instead of config.llm.baseUrl to prevent
  default service URL leaking into other services (e.g. moonshot URL used for minimax)
- Custom service URLs auto-normalize: append /v1 if missing (save, test, resolve)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:00:46 -07:00
fanghanjun 5cada30289 fix(core): always use preset baseUrl/api in resolveServiceModel
pi-ai's built-in model objects may have different baseUrl (e.g. international
endpoint) or api format (e.g. anthropic-messages) than our configured presets.
Always construct our own model object using preset values, only inheriting
metadata (reasoning, cost, contextWindow) from pi-ai.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:00:38 -07:00
fanghanjun a2e24b74f1 fix(core): correct MiniMax baseUrl and add knownModels fallback
- baseUrl from api.minimax.chat to api.minimaxi.com (current OpenAI-compatible endpoint)
- Add knownModels for MiniMax (7 models) since it doesn't support GET /models
- listModelsForService prioritizes knownModels over dynamic /models call

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:00:28 -07:00
fanghanjun 5652cdebd4 fix: add --parallel to pnpm dev so all packages start concurrently
Without --parallel, tsc --watch in core blocks studio from starting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 04:00:22 -07:00
fanghanjun d93e22398d 修复建书bug
Architect LLM 生成基础设定时偶尔漏掉 current_state/pending_hooks section,
导致 parseSections 抛错、pipeline agent 反复重试建书。
改为缺失时使用默认空白模板,后续写章由 Settler 正常更新。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 03:50:59 -07:00
Ma b78e745054 Merge branch 'dev' v1.3.0 2026-04-15 17:24:53 +08:00
Ma 99e72949da test(release): relax studio pack timeout for CI 2026-04-15 17:24:44 +08:00
Ma 31bab8dc76 Merge branch 'dev' 2026-04-15 17:17:58 +08:00
Ma 2967653c6d chore(release): bump to v1.3.0 and update changelog 2026-04-15 17:17:49 +08:00
Ma e54f145a64 Merge branch 'dev' 2026-04-15 17:14:11 +08:00
Ma 1a018accf9 docs: announce Studio 2.0 and update default launch copy 2026-04-15 16:55:31 +08:00
Ma 7eb5363e33 Merge branch 'dev' 2026-04-15 16:50:54 +08:00
Ma a938318f21 fix(studio): rehydrate saved service keys in detail view 2026-04-15 16:46:10 +08:00
Ma 4d55dc76d1 feat(studio): improve service save flow and home navigation 2026-04-15 16:31:16 +08:00
Ma d33ce212e8 fix(studio): allow startup without default model in Studio mode 2026-04-15 16:13:10 +08:00