Commit graph

550 commits

Author SHA1 Message Date
NilsR0711
ae1bcc572d chore(pi-ai): regenerate model registry from upstream APIs (#3887)
* chore(pi-ai): regenerate model registry from upstream APIs

Regenerated models.generated.ts by running generate-models.ts against
live provider APIs. Last generated: 2026-04-09.

+48 models added, 19 removed across all providers.
Notable additions: z-ai/glm-5.1 via OpenRouter (closes #4069,
supersedes custom entry in #4055), zai-org/GLM-5.1, z-ai/glm-5v-turbo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(pi-ai): add structural and regression tests for models.generated.ts

- Regression #3582: pins qwen/qwen3.6-plus in openrouter
- Regression #4069: pins z-ai/glm-5.1 in openrouter
- Structural invariants across all 23 providers / all models
- Registry shape: exact provider list, model count lower bound
- Removed models guard: decommissioned models must stay absent
- Spot-checks for notable models added in this regeneration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 08:05:03 -04:00
NilsR0711
ddff956a91 feat(pi-ai): add Alibaba DashScope as standalone provider (#3891)
* feat(pi-ai): add Alibaba DashScope as standalone provider

Adds `alibaba-dashscope` for users with a regular DashScope API key,
separate from the existing `alibaba-coding-plan` free-tier provider.

- types.ts: register `alibaba-dashscope` as KnownProvider
- env-api-keys.ts: map to DASHSCOPE_API_KEY
- models.custom.ts: add qwen3-max, qwen3.5-plus, qwen3.5-flash,
  qwen3-coder-plus with international endpoint and real pricing
- model-resolver.ts: default model qwen3.5-plus
- key-manager.ts: add alibaba-coding-plan and alibaba-dashscope
  to PROVIDER_REGISTRY so /gsd keys add works for both

Co-Authored-By: Claude Code <noreply@anthropic.com>

* feat(pi-ai): add qwen3.6-plus to alibaba-dashscope provider

qwen3.6-plus is available on DashScope international endpoint.
Pricing: $0.5/M input, $3/M output (base tier, 0-256K tokens).
Supports thinking mode (reasoning: true).

Source: https://www.alibabacloud.com/help/en/model-studio/model-pricing

Co-Authored-By: Claude Code <noreply@anthropic.com>

* test(pi-ai): add tests for alibaba-dashscope provider and key-manager regression

- packages/pi-ai/src/models.test.ts: add describe block covering all 5
  alibaba-dashscope models (presence, base URL, API, provider field,
  context window, paid pricing, per-model reasoning/cost assertions,
  independence from alibaba-coding-plan, failure path for unknown model)
- src/resources/extensions/gsd/tests/key-manager.test.ts: add regression
  tests for #3891 — alibaba-coding-plan was missing from PROVIDER_REGISTRY,
  causing /gsd keys add alibaba-coding-plan to fail silently; also covers
  alibaba-dashscope registration, env var separation, and getAllKeyStatuses

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-04-13 08:04:39 -04:00
Rebecca Chernoff
110c01b8c6 fix: flush extension provider registrations before model resolution (#1923)
Extension-based providers like pi-claude-cli register their models
during extension loading, but registrations were queued and not flushed
until after model resolution ran. This caused findInitialModel() and
the startup model validation to see extension models as nonexistent,
permanently overwriting the user's saved model selection on every launch.

- Flush pendingProviderRegistrations in createAgentSession() before
  findInitialModel() so extension models are visible in the registry
- Move model validation to after createAgentSession() in both print
  and interactive code paths
- Load extensions before --list-models so extension models appear
2026-04-13 07:06:16 -04:00
mastertyko
510629c8cb fix(pi-tui): filter kitty keypad private-use input (#4026) 2026-04-13 06:51:12 -04:00
mastertyko
0df033dbac fix(pi-ai): filter unavailable github copilot models (#4031) 2026-04-13 06:46:27 -04:00
Jeremy McSpadden
3a529f7a95 Merge pull request #4100 from jeremymcs/claude/cleanup-mcp-stream-output-9uCeK
Improve MCP tool rendering with name parsing and compact args
2026-04-13 00:54:38 -05:00
Claude
2d1081f1cc fix: clean up MCP tool rendering in Claude Code CLI stream
Strip the `mcp__<server>__` prefix from tool_use blocks emitted by the
Claude Agent SDK so registered GSD extension renderers (gsd_plan_milestone,
gsd_task_complete, etc.) match instead of falling through to the generic
JSON-dump fallback. The original server name is preserved on the toolCall
block under `mcpServer` for downstream rendering.

Tighten the generic ToolExecutionComponent fallback for any remaining
prefixed names (third-party MCP servers): show a muted `server·tool`
title, render primitive args as compact `key=value` pairs, and truncate
output to 10 lines when collapsed.
2026-04-13 05:46:35 +00:00
github-actions[bot]
f188b94761 release: v2.72.0 2026-04-13 05:13:11 +00:00
Jeremy McSpadden
c189b2152e Merge pull request #4092 from jeremymcs/fix/openrouter-credit-retry
fix(auto): recover from OpenRouter affordability 402 errors
2026-04-12 23:04:58 -05:00
Jeremy
724464c7ae fix(auto): recover from OpenRouter credit affordability errors 2026-04-12 22:48:55 -05:00
Claude
8f58481875 fix(gsd): route quality gates through a per-turn registry
Every workflow turn that needed a quality gate either let it drop
silently or bulk-stamped it at closeout. Q8 was the worst case: seeded
as scope:"slice" by plan-slice, treated as a blocker for the
evaluating-gates phase by state.ts, then filtered out of the
gate-evaluate prompt via `if (!meta) continue;` and never closed by
complete-slice — a guaranteed auto-loop stall once slice gates were
enabled.

Introduce gate-registry.ts as the single source of truth for which
turn owns which gate (Q3/Q4 → gate-evaluate, Q5/Q6/Q7 → execute-task,
Q8 → complete-slice, MV01–MV04 → validate-milestone). Every layer of
the prompt system now consults it:

- state.ts derives pending counts by owner turn, not scope, so Q8
  never stalls evaluating-gates again.
- auto-prompts.ts builders call assertGateCoverage() and render a
  "Gates to Close" block from the registry instead of a hand-rolled
  GATE_QUESTIONS table.
- complete-slice and complete-task handlers saveGateResult for every
  gate they own, mapping gate id → params field so empty sections
  become `omitted` and populated sections become `pass`.
- milestone-validation-gates sources its MV id list from the registry.
- prompt-validation.ts adds validateSliceSummaryOutput /
  validateTaskSummaryOutput / validateMilestoneValidationOutput
  schema checks.
- gsd_save_gate_result accepts MV01–MV04 (via the registry keys) in
  the MCP server and bootstrap tool registration.

Tests: new gate-registry + prompt-system-gate-coverage +
complete-slice-gate-closure suites, plus a Q8 regression case in
gate-dispatch.test.ts. 161 related tests pass end-to-end.

https://claude.ai/code/session_019PT3EmrkMxr4TsgGGLSYK3
2026-04-12 21:13:16 -05:00
Claude
1be15758ec fix(mcp): thread abort signals, restore tool fidelity, and fix subpath imports
Audit-driven fixes across the two MCP server surfaces and the Claude Code
streaming adapter:

- src/mcp-server.ts: propagate `extra.signal` into `tool.execute` so MCP
  clients can actually cancel long-running Bash/WebFetch/grep calls, and
  route the remaining `/server` subpath import through `createRequire`
  for #3603 consistency.
- src/tests/mcp-createRequire.test.ts: extend regression coverage to the
  `/server` subpath.
- claude-code-cli/stream-adapter.ts: (a) classify aborts as `aborted`
  instead of the retry-eligible `stream_exhausted_without_result`,
  (b) merge final-turn toolCall blocks from the builder into the
  AssistantMessage via the new `mergePendingToolCalls` helper so a turn
  ending in `tool_use` stop_reason no longer drops its tool calls, and
  (c) resolve the SDK permission mode via `resolveClaudePermissionMode`
  (auto-mode → bypass, interactive → acceptEdits, env override).
- packages/mcp-server/src/server.ts: make `gsd_query` actually respect
  its `query` argument with known categories + forward-compatible
  fallback, and thread `extra.signal` into `gsd_execute` so an aborted
  RPC request cancels the newly-created session instead of leaking a
  background RpcClient process.
- stream-adapter test suite: add regression tests for abort
  classification, final-turn tool-call merging, and permission mode
  resolution.

Verified via: mcp-createRequire, stream-adapter (27), partial-builder,
mcp-server package (31), workflow-tools (13) — 83 tests green.

https://claude.ai/code/session_0174sYny3VvdwYTdCNTmY4Do
2026-04-12 20:04:47 -05:00
Claude
701ab18d81 fix(models): block unconfigured models from selection surfaces
Filter models whose provider has no working API key or OAuth out of
every user-facing selection path. Previously, stale defaults and scoped
sets could leak unconfigured models into /model, /gsd model, and auto
run — the user could "pick" a model that immediately threw on use.

- model-selector: filter scopedModels via isProviderRequestReady;
  default to "all" scope when no scoped model is ready.
- model-controller: same filter for getModelCandidates, so exact-match
  resolution from /model <term> can't return an unauth'd scoped model.
- model-resolver: gate findInitialModel step 3 on provider readiness so
  a stale saved default falls through to the available-models path.
- startup-model-validation: check configuredExists against getAvailable
  instead of getAll, so a configured-but-unauth default triggers the
  fallback picker and thinking-level reset.
- auto-start: validate resolveDefaultSessionModel against the live
  registry + auth before snapshotting, and warn when PREFERENCES.md
  names an unconfigured model.

https://claude.ai/code/session_015q6b23ap9Pyqdogzz2FXGh
2026-04-12 17:25:06 -05:00
Jeremy McSpadden
c3aa3a3bf0 Merge pull request #4067 from jeremymcs/fix/gsd-model-session-override 2026-04-12 12:50:12 -05:00
Jeremy McSpadden
17e3ef6a28 Merge pull request #4064 from mastertyko/fix/3402-full-oauth-login-url
fix(pi-coding-agent): show full OAuth login URLs
2026-04-12 12:26:25 -05:00
Jeremy
c96d01acb7 fix(model): require provider readiness for saved default selection 2026-04-12 12:24:49 -05:00
mastertyko
f15938ea4c fix(pi-coding-agent): show full OAuth login URLs 2026-04-12 18:45:28 +02:00
Jeremy McSpadden
564a71da37 Merge pull request #4053 from jeremymcs/fix/auto-session-credential-cooldown
fix(auto): survive transient 429 credential cooldown
2026-04-12 09:42:37 -05:00
Jeremy
4f2e90e1e8 test(auto): add tests for credential cooldown fix
- auth-storage.test.ts: 8 tests for getEarliestBackoffExpiry()
- sdk.test.ts: 12 tests for CredentialCooldownError class
- infra-errors-cooldown.test.ts: 35 tests for isTransientCooldownError(),
  getCooldownRetryAfterMs(), and exported constants

Required by CI lint (require-tests.sh) per CONTRIBUTING.md.

Closes #4052
2026-04-12 09:30:52 -05:00
Jeremy
d0afe018eb fix(auto): add structured cooldown error and bounded retry budget
Address Codex adversarial review findings:

- Replace string-matched cooldown detection with typed
  CredentialCooldownError (code: AUTH_COOLDOWN, retryAfterMs)
- Add MAX_COOLDOWN_RETRIES (5) cap so cooldown retries can't spin for
  hours on persistent quota exhaustion
- Auto-loop uses retryAfterMs from structured error when available,
  falls back to 35s default
- Export CredentialCooldownError from pi-coding-agent package
- Retain regex fallback for cross-process error propagation

Closes #4052
2026-04-12 09:16:05 -05:00
Jeremy
cd86e8a7d0 feat(tui): improve gsd overlays, shortcuts, and notification flows 2026-04-12 09:13:46 -05:00
Jeremy
1ae93e9822 fix(auto): survive transient 429 credential cooldown in auto sessions
getApiKey() retry loop (3 attempts, ~12s) couldn't outlast the 30s
rate-limit backoff window, causing cooldown errors to cascade through
the auto-loop and trigger a hard stop after 3 consecutive failures.

- Add AuthStorage.getEarliestBackoffExpiry() to expose when the next
  credential becomes available
- Update getApiKey() to sleep until backoff expiry (up to 60s) instead
  of fixed 2s/4s/6s delays
- Add isTransientCooldownError() detector in infra-errors.ts
- Auto-loop now waits 35s on cooldown errors without incrementing the
  consecutive error counter

Closes #4052
2026-04-12 09:04:41 -05:00
Jeremy McSpadden
b22f7baafb Merge pull request #4043 from mastertyko/fix/3783-minimax-bearer-auth
fix(pi-ai): use bearer auth for MiniMax Anthropic API
2026-04-12 09:03:11 -05:00
mastertyko
d2ed5a91a6 fix(pi-coding-agent): match renderable tools case-insensitively 2026-04-12 14:05:30 +02:00
mastertyko
739f6ca51c fix(pi-ai): use bearer auth for MiniMax Anthropic API 2026-04-12 14:02:07 +02:00
Jeremy
4b69e44a42 merge: resolve upstream/main conflicts for PR #3177 2026-04-11 22:59:58 -05:00
Jeremy McSpadden
56ee5616a5 Merge pull request #3984 from mastertyko/fix/3973-mcp-inline-db-open
fix(mcp-server): open the DB for inline workflow tools
2026-04-11 22:52:52 -05:00
github-actions[bot]
cf6f0613dd release: v2.71.0 2026-04-11 23:19:57 +00:00
Jeremy
b488961609 fix(tui): clear pinned output on message_end to prevent duplicate display
The pinned "Latest Output" zone was only cleared at agent_end, but during
flows with form elicitation (e.g. discuss-phase), there is a gap between
message_end and agent_end where the agent waits for user input. During this
gap, the same content was visible in both the chat history and the pinned
zone. Clear the pinned zone at message_end when the assistant message is
finalized in the chat container.
2026-04-11 17:41:50 -05:00
Jeremy
5531538e0d fix(tui): clear pinned latest output on turn completion 2026-04-11 16:58:48 -05:00
Git-Scram
1d1e47e78b fix(tui): restore pinned output above editor during tool execution
Restores the pinned assistant output zone that shows the latest narration
during tool execution. Adds markdown rendering, animated spinner, height
capping to prevent render flashing, and session rebuild support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 15:53:29 -04:00
Jeremy
2d531720f7 fix(tui): mask secure extension input values in interactive mode 2026-04-11 13:28:17 -05:00
Jeremy
bf4bcfadde fix(claude-code): harden MCP elicitation schema handling 2026-04-11 13:26:24 -05:00
Jeremy
1495e711e1 fix(claude-code): accept secure_env_collect MCP elicitation forms 2026-04-11 13:18:27 -05:00
Jeremy
74fee9ed48 fix(interactive): keep MCP tool output ordered and restore secure prompt fallback 2026-04-11 12:47:41 -05:00
Jeremy
ea506f66c8 feat(mcp-server): add secure_env_collect tool via MCP form elicitation
Exposes secure_env_collect as an MCP tool so any MCP client (Claude Code,
Cursor, etc.) can collect secrets through form-based input. Values are
written directly to .env/Vercel/Convex and never appear in LLM context —
only key names and applied/skipped status are returned.

- New env-writer.ts with writeEnvKey, detectDestination, checkExistingEnvKeys, applySecrets
- Uses server.server.elicitInput() to present form fields to the MCP client
- Pre-checks existing keys to skip already-set env vars
- Auto-detects destination from project files (vercel.json, convex/ dir)
- 27 tests covering utilities and tool integration

Closes #3975
2026-04-11 11:51:43 -05:00
Jeremy McSpadden
5d48038816 Merge pull request #3992 from jeremymcs/fix/mcp-output-stream-order
fix(interactive): preserve MCP tool output stream ordering
2026-04-11 11:46:23 -05:00
Jeremy
ba6c1f5d7e test(interactive): cover MCP tool output ordering in chat controller 2026-04-11 11:32:28 -05:00
Jeremy
58d729894e fix(interactive): preserve MCP tool output stream ordering 2026-04-11 11:26:08 -05:00
mastertyko
4ad2379dc5 fix(mcp-server): open the DB for inline workflow tools 2026-04-11 17:44:17 +02:00
github-actions[bot]
26696be2fa release: v2.70.1 2026-04-11 04:22:31 +00:00
Jeremy McSpadden
19cbb17683 Merge pull request #3961 from jeremymcs/fix/windows-portability-sweep
fix: harden Windows portability across runtime and tooling
2026-04-10 21:53:10 -05:00
Jeremy
61204ce771 fix(windows): harden portability across runtime and tooling 2026-04-10 20:33:18 -05:00
Jeremy McSpadden
9a7453fae8 Merge pull request #3957 from jeremymcs/fix/mcp-importLocalModule-paths
fix(mcp-server): importLocalModule resolves src/ paths from dist/ context
2026-04-10 19:54:00 -05:00
Jeremy McSpadden
37fa5168a9 Merge pull request #3956 from jeremymcs/fix/claude-code-structured-questions-fallback
[codex] fix Claude Code discuss structured-question fallback
2026-04-10 19:44:45 -05:00
Jeremy
67767c2527 test(mcp-server): add regression tests for importLocalModule candidate resolution
Extracts _buildImportCandidates() as a testable export and adds 5 tests
verifying src/<->dist/ path swapping and .ts extension fallback logic.

Refs #3954
2026-04-10 19:33:00 -05:00
Jeremy
d64056f833 fix claude code mcp elicitation bridge 2026-04-10 19:24:51 -05:00
Jeremy
ad8405c372 fix(mcp-server): importLocalModule resolves src/ paths from dist/ context
importLocalModule() resolved paths relative to import.meta.url. When
running from dist/, paths like ../../../src/.../foo.js pointed to source
where no .js files exist. Now tries src/<->dist/ swap and .ts fallback
so the same code works in both dev (tsx) and prod (compiled) contexts.

Also adds dist/ candidates to write-gate and workflow-executor lookups.

Fixes #3954
2026-04-10 19:22:52 -05:00
github-actions[bot]
4b671fba0f release: v2.70.0 2026-04-10 23:12:12 +00:00
Jeremy McSpadden
afe0574a23 Merge pull request #3953 from jeremymcs/fix/remove-anthropic-oauth 2026-04-10 17:52:59 -05:00