Commit graph

3479 commits

Author SHA1 Message Date
drkthng
d9a3aabf75 fix(async-jobs): suppress stale follow-up for jobs consumed by await_job (#3787) (#3788)
The queueMicrotask() deferral in deliverResult() only prevented duplicate
follow-ups when a job completed *while* await_job was blocked in Promise.race().
For jobs that completed before await_job was called (common in multi-turn
interactive sessions), the microtask had already fired and queued the follow-up
message before suppressFollowUp could run.

Fix: replace queueMicrotask with setTimeout(0), storing the timer handle on
the job object. suppressFollowUp() (new method on AsyncJobManager) cancels
that timer and marks awaited = true atomically, handling both the within-turn
and cross-turn cases.

await-tool.ts now calls manager.suppressFollowUp(id) instead of directly
setting j.awaited = true, which gives it the cancellable timer path.

Adds a regression test specifically for the cross-turn case.
2026-04-13 08:10:09 -04:00
drkthng
a460463371 docs: add change management guide for mid-project reshuffling (#3792)
Covers 10 real-world scenarios users face after milestones are underway:
- Quick fixes and captures during auto-mode
- Steering a running slice
- Inserting new milestones before planned ones
- Parking/unparking milestones to reorder execution
- Dedicated bugfix milestones
- Handling bugs in completed slices
- Course-correcting a milestone that went wrong

Adds navigation entry under Features in docs.json.
2026-04-13 08:09:29 -04:00
mastertyko
eb499116d4 fix(gsd): rebuild STATE.md after unit completion (#3876) 2026-04-13 08:08:34 -04:00
mastertyko
a5b46eaca3 fix(gsd): let doctor heal dispatch fixable warnings (#3875) 2026-04-13 08:08:18 -04:00
mastertyko
daef91f7b8 fix(gsd): preserve experimental preferences in merges (#3847) 2026-04-13 08:07:54 -04:00
mastertyko
b13c980ecc fix(gsd): heal legacy task arrays and evidence rows (#4027) 2026-04-13 08:07:26 -04:00
mastertyko
1d8e7c95ff fix(gsd): unlock depth verification outside guided flow (#4058) 2026-04-13 08:07:07 -04:00
mastertyko
65ba0fc30b fix(gsd): preserve paused auto badge after provider pause (#4062) 2026-04-13 08:05:59 -04:00
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
Luan Neves Barroso
00c6442e1a fix(ollama): add cloud auth support and resolve real context window via /api/show (#4017)
- Add OLLAMA_API_KEY Bearer token auth to all Ollama HTTP client requests
  (fetchWithTimeout, pullModel, chat) via getAuthHeaders/withAuth helpers.
  Local Ollama ignores the Authorization header; cloud endpoints require it.

- Fix isRunning() probe for cloud endpoints: use /api/tags instead of root /
  since cloud hosts may not serve the root endpoint.

- Resolve real context window for unknown models via /api/show model_info
  ({arch}.context_length) instead of defaulting to 8192. Priority chain:
  known table > /api/show > estimate from parameter_size > 8192.

- Use dependency injection for discoverModels() to allow test mocking
  without ESM named export issues.

- Pick up OLLAMA_API_KEY in provider registration (apiKey field).

Closes #3544

Co-authored-by: luannevesb <luannevesb@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 08:03:57 -04:00
Eric Chan
843b72e7c1 docs(i18n): add Simplified Chinese user docs (#4105) 2026-04-13 07:57:41 -04:00
Tom Boucher
2c75425916 chore: require linked issue in PR template (#4112)
Adds a prominent "Linked issue" section at the top of the PR template
with a required acknowledgement checkbox. PRs that leave the issue
number blank or uncheck the box signal they haven't read the contribution
guidelines and will be closed.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 07:56:19 -04:00
Jeremy McSpadden
ab03677567 fix(security): activate auth middleware and harden shutdown/update routes (#4023)
The Next.js auth middleware (proxy.ts) was never wired in — it exported
`proxy` from a file named proxy.ts, but Next.js requires a `middleware`
export from middleware.ts. The middleware-manifest.json was empty,
leaving all 42 API routes accessible without authentication.

Fixes:
- Rename web/proxy.ts → web/middleware.ts, export `middleware` not `proxy`
- Add defense-in-depth auth-guard to /api/shutdown and /api/update routes
- Remove shell: true from update-service spawn (command injection surface)
- Update contract tests to verify middleware file name and export

Closes #4014

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 07:52:43 -04:00
mastertyko
b7ad8bf31a fix(gsd): normalize workingDirectory prompt paths (#4057) 2026-04-13 07:50:52 -04:00
Jeremy McSpadden
5cc343305d Merge pull request #4110 from jeremymcs/fix/4099-mcp-tool-approval
fix(claude-code): stop 'This command requires approval' on GSD workflow MCP tools (#4099)
2026-04-13 06:43:00 -05:00
Jeremy McSpadden
eb7256b818 Merge pull request #4111 from jeremymcs/fix/cli-validate-model-duplicate
fix(cli): resolve duplicate validateConfiguredModel import breaking all CI on main
2026-04-13 06:40:42 -05:00
Jeremy
b92fdc7b6f fix(claude-code): pre-authorize workflow MCP tools so interactive acceptEdits mode stops blocking GSD commands
Since 2.72.0 the interactive permission default is acceptEdits, which
auto-approves built-in Edit/Write/Bash but leaves the SDK permission
gate up for MCP tools. Without a canUseTool handler, every
mcp__gsd-workflow__* call surfaces as "This command requires approval"
and blocks GSD actions (#4099).

Add allowedTools entries (mcp__<server>__*) for each registered workflow
MCP server in buildSdkOptions so they run unattended while the rest of
the acceptEdits safety gate stays intact. Env-overridden server names
are handled by deriving the glob list from the built mcpServers keys.

Fixes #4099
2026-04-13 06:34:59 -05:00
Jeremy
d4bddfadf5 test(cli): regression test for pi-migration.getPiDefaultModelAndProvider export
Asserts that getPiDefaultModelAndProvider and migratePiCredentials remain
callable top-level exports from src/pi-migration.ts. If either is ever
renamed or unexported, this test fails before the root `tsc` build breaks
every CI job on main — the same class of regression introduced by
110c01b8c.
2026-04-13 06:32:47 -05:00
Jeremy
a8123ab558 fix(cli): resolve duplicate validateConfiguredModel and missing getPiDefaultModelAndProvider import
Commit 110c01b8c added an inline `validateConfiguredModel` function in
`src/cli.ts` while leaving the prior import from
`./startup-model-validation.js` in place, producing TS2440 (import
declaration conflicts with local declaration). The same commit added a
call to `getPiDefaultModelAndProvider()` without importing it, producing
TS2304 (cannot find name). Both errors block `npm run build` and every
CI job on main.

Drop the stale import and add `getPiDefaultModelAndProvider` to the
existing `./pi-migration.js` import where the symbol is actually
exported. The local `validateConfiguredModel` function (lines 139-174)
becomes the sole definition in scope. `./startup-model-validation.js`
is still consumed by its dedicated test files so the module stays.
2026-04-13 06:30:21 -05:00
Alan Alwakeel
c1bc53452b feat(gsd): add layered depth enforcement to discuss.md (#4079)
Organize discussion question rounds into four layers (Scope →
Architecture → Error States → Quality Bar) with user-confirmed
gates between each. Prevents silent advancement and ensures
systematic depth coverage.

Each gate pauses for user confirmation. Users can skip forward
at any gate. Adjustments are reflected back before advancing.
Work-type adaptation shapes question depth per layer.

Prompt-only change — no TypeScript modifications.
Builds on #3977 (multi-round question structure).
2026-04-13 07:29:38 -04:00
zoumo
8dab974863 fix: update GSD runtime ignore patterns for team mode (#2824)
* fix: update GSD runtime ignore patterns for team mode

Add missing runtime files to gitignore patterns across codebase and docs:
- .gsd/completed-units*.json (wildcard for archived per-milestone files)
- .gsd/state-manifest.json (workflow state manifest)
- .gsd/gsd.db* (SQLite database and WAL sidecars)
- .gsd/journal/ (daily-rotated event journal)
- .gsd/doctor-history.jsonl (diagnostic check history)
- .gsd/event-log.jsonl (workflow event log)

Updated files:
- gitignore.ts: GSD_RUNTIME_PATTERNS
- git-service.ts: RUNTIME_EXCLUSION_PATHS
- worktree-manager.ts: SKIP_PATHS, SKIP_EXACT, SKIP_PREFIXES
- doctor-runtime-checks.ts: criticalPatterns
- tests/git-service.test.ts: test expectations
- docs: README.md, working-in-teams.mdx

* docs: add comments noting gitignore.ts as canonical source of truth

Address code review feedback about maintenance risk of having multiple
sources of truth for ignore patterns. Add clear comments in all files
that reference GSD_RUNTIME_PATTERNS to indicate gitignore.ts is the
canonical source that must stay synchronized.
2026-04-13 07:13:51 -04:00
deseltrus
ff36c117dd fix(gsd): prevent double frontmatter in task SUMMARY.md from projection re-render (#2818)
renderSummaryContent() in workflow-projections.ts wraps full_summary_md
(already a complete markdown doc with frontmatter) inside a second generated
frontmatter/heading envelope. This produces double frontmatter, double H1
headings, and duplicate Deviations/Known Issues sections.

The fix checks whether full_summary_md exists and starts with frontmatter
delimiters. If so, it is used as the entire output. The fallback synthesis
from individual DB columns only runs when full_summary_md is absent or
lacks frontmatter.

Adds 3 regression tests to projection-regression.test.ts.
2026-04-13 07:13:48 -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
416be1e169 fix(gsd): reset db-open attempted flag on close (#4024) 2026-04-13 06:51:59 -04:00
mastertyko
92ac0e3a7d fix(gsd): unblock mixed-dependency zero-dep slices (#4025) 2026-04-13 06:51:34 -04:00
mastertyko
510629c8cb fix(pi-tui): filter kitty keypad private-use input (#4026) 2026-04-13 06:51:12 -04:00
mastertyko
7a7683488f fix(gsd): disable db mmap on darwin (#4029) 2026-04-13 06:48:49 -04:00
mastertyko
df4e8245df fix(gsd): reject empty roadmap stubs as milestone plans (#4063) 2026-04-13 06:47:53 -04:00
deseltrus
ff42dccb58 fix: persist defaultProvider when user selects Claude Code CLI in onboarding (#4104)
The claude-cli onboarding path stored the auth sentinel for claude-code
but did not update defaultProvider in settings.json. Users who had an
existing Anthropic API key were left on the "anthropic" provider because
the startup migration in cli.ts correctly skips direct-key holders.

Write defaultProvider = "claude-code" to settings.json in the claude-cli
branch so the provider switch takes effect immediately.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 06:46:58 -04:00
mastertyko
0df033dbac fix(pi-ai): filter unavailable github copilot models (#4031) 2026-04-13 06:46:27 -04:00
Jeremy McSpadden
754979e7a6 Merge pull request #4103 from jeremymcs/fix/4102-claude-code-transcript-fabrication
fix(claude-code): stop prompt context from fabricating [User]/[Assistant] turns
2026-04-13 01:33:43 -05:00
Jeremy
ad2211b218 fix(claude-code): wrap prompt history in XML tags to stop transcript fabrication
Closes #4102.

buildPromptFromContext previously serialized multi-turn history using
literal [User] / [Assistant] / [System] bracket labels. Those tokens
are the exact pattern the anti-fabrication rule in system.md and
discuss.md forbids — the model saw its own input framed as a bracket-
labeled transcript and mirrored the format in its output, inventing
both sides of the conversation during /gsd discuss turns.

Replace the bracket labels with XML-tag structure:
  - <conversation_history> wraps the whole turn sequence
  - <user_message> / <assistant_message> per turn
  - <prior_system_context> for the system prompt (renamed from
    <system_prompt> to avoid overlap with Claude Code's reserved
    <system-reminder> convention)

Prepend a directive telling the model to respond only to the final
user message and not emit the XML tags in its own response. Keep
system.md and discuss.md in sync by documenting that prior context
is delivered in those tags.

Add regression tests asserting:
  - no literal [User]/[Assistant]/[System] substrings in the prompt
  - history wrapped in <conversation_history> with per-turn tags
  - directive leads the prompt
  - empty-history edge cases still render correctly
2026-04-13 01:23:47 -05: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
c8e5414812 Merge pull request #4095 from jeremymcs/fix/ci-integration-tests-build-prereqs
fix(ci): build artifacts in integration-tests job
2026-04-12 23:55:30 -05:00
Jeremy
6dfcb6a049 fix(ci): build artifacts in integration-tests job
PR #4093 split build and integration-tests into parallel CI jobs but the new
integration-tests job only ran `npm ci`, leaving tests without the compiled
artifacts they spawn at runtime. That caused 8 failures on main (run 24325713845):

- e2e-headless, e2e-smoke, pack-install — throw "dist/loader.js not found"
- 4 web-session-parity / web-live-state tests — "session manager module not
  found; checked=packages/pi-coding-agent/dist/core/session-manager.js"
- web-mode-onboarding — "sh: 1: next: not found" when the test shells
  `npm run build:web-host` at runtime (web/node_modules/.bin/next absent)

Add `npm --prefix web ci` and `npm run build` to the integration-tests job
before `test:integration`, matching what the build job already does. Using
`needs: build` + artifact sharing would serialize the two jobs and undo the
parallelism PR #4093 was buying, so the build is duplicated intentionally.
2026-04-12 23:47:03 -05:00
Jeremy McSpadden
b0fa373d2b Merge pull request #4093 from jeremymcs/perf/parallel-integration-tests
perf(ci): run integration tests in parallel with build
2026-04-12 23:30:07 -05:00
Jeremy
852ddf3bdd perf(ci): run integration tests in parallel with build
Split integration tests into a separate job that runs concurrently with
the build+unit test job. Integration tests run from TypeScript source
(no build artifact dependency), so they can start immediately after
detect-changes without waiting for compilation.
2026-04-12 23:18:08 -05: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 McSpadden
94b3e8c59a Merge pull request #4090 from jeremymcs/perf/nextjs-build-cache
perf(ci): cache Next.js build artifacts with Blacksmith
2026-04-12 22:51:25 -05:00
Jeremy
724464c7ae fix(auto): recover from OpenRouter credit affordability errors 2026-04-12 22:48:55 -05:00
Jeremy
bdcf2c5c24 perf(ci): cache Next.js build artifacts with Blacksmith cache
Add useblacksmith/cache@v5 to persist web/.next/cache across CI runs,
eliminating redundant Webpack recompilation of unchanged pages. Applied
to ci.yml build job and pipeline.yml dev-publish/prod-release jobs.
2026-04-12 22:38:30 -05:00
Jeremy McSpadden
cac4f8ac37 Merge pull request #4087 from jeremymcs/feat/add-specialist-agents
feat(agents): add 8 specialist subagents, slim pro agents, add GSD phase guard
2026-04-12 22:11:43 -05:00
Jeremy
0c19ca88f2 feat(agents): add GSD phase guard to prevent subagent/phase conflicts
When GSD auto-mode is running a planning phase, the planner subagent
could bypass GSD's state machine and artifact system. This adds a
shared state module and conflict check to block agents that overlap
with the active GSD phase.

- Add shared/gsd-phase-state.ts for cross-extension phase coordination
- Add conflicts_with frontmatter field to agent definitions
- Block conflicting agents with clear error directing to GSD workflow
- Tag planner agent with conflicts_with for plan/research phases
- 10 new tests for phase state and conflict parsing
2026-04-12 21:56:52 -05:00
Jeremy
66f0d45a8c feat(agents): add 8 specialist subagents and slim pro agents
Add focused, token-efficient specialist agents:
- reviewer: structured code review with severity ratings
- debugger: hypothesis-driven bug investigation
- tester: test writing, fixing, and coverage gap analysis
- refactorer: safe code transformations (extract, inline, rename)
- security: OWASP security audit and secrets detection
- planner: architecture/implementation planning (no code output)
- git-ops: conflict resolution, rebase strategy, PR prep
- doc-writer: documentation generation from code

Slim typescript-pro (256→64 lines) and javascript-pro (281→69 lines):
- Remove verbose code examples (the LLM already knows these patterns)
- Remove persistent memory sections (not used in this project)
- Keep core principles, key patterns list, and verification checklist
- Total token savings ~75% per invocation of these agents
2026-04-12 21:56:40 -05:00
Jeremy McSpadden
6d0b8b4b27 Merge pull request #4084 from jeremymcs/claude/prompt-system-validation-gates-FK9NB
Introduce gate registry as single source of truth for quality gates
2026-04-12 21:54:17 -05:00
Jeremy
c6ba27f371 fix(gsd): cast unknown gate id in test to satisfy GateId type
The gate-registry test intentionally passes an invalid gate id "Q999"
to verify error handling, but the strict GateId union type rejects it
at compile time. Cast to GateId to fix the typecheck:extensions CI step.
2026-04-12 21:30:56 -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