gsd-pi 2.80.0-dev.2be7caf18 → 2.80.0-dev.3065f7bfa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/gsd/auto/phases.js +178 -108
- package/dist/resources/extensions/gsd/auto/resolve.js +17 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +20 -30
- package/dist/resources/extensions/gsd/auto/session.js +8 -0
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +5 -32
- package/dist/resources/extensions/gsd/auto-dispatch.js +16 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +17 -4
- package/dist/resources/extensions/gsd/auto-prompts.js +90 -15
- package/dist/resources/extensions/gsd/auto-recovery.js +43 -1
- package/dist/resources/extensions/gsd/auto-start.js +197 -6
- package/dist/resources/extensions/gsd/auto-supervisor.js +8 -1
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +2 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +111 -1
- package/dist/resources/extensions/gsd/auto.js +79 -24
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +42 -2
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +49 -36
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +15 -5
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +9 -3
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +7 -1
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +9 -3
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +8 -2
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +238 -28
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
- package/dist/resources/extensions/gsd/clean-root-preflight.js +24 -6
- package/dist/resources/extensions/gsd/commands-handlers.js +23 -9
- package/dist/resources/extensions/gsd/context-budget.js +37 -2
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +39 -0
- package/dist/resources/extensions/gsd/db-base-schema.js +4 -2
- package/dist/resources/extensions/gsd/db-migration-steps.js +6 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +2 -0
- package/dist/resources/extensions/gsd/git-service.js +36 -4
- package/dist/resources/extensions/gsd/gsd-db.js +46 -13
- package/dist/resources/extensions/gsd/guided-flow.js +66 -32
- package/dist/resources/extensions/gsd/memory-store.js +69 -12
- package/dist/resources/extensions/gsd/native-git-bridge.js +32 -8
- package/dist/resources/extensions/gsd/orphan-stash-audit.js +101 -0
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +13 -3
- package/dist/resources/extensions/gsd/pre-execution-checks.js +22 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +28 -2
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +16 -13
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/dist/resources/extensions/gsd/tools/memory-tools.js +1 -0
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +1 -1
- package/dist/resources/extensions/gsd/unit-runtime.js +11 -0
- package/dist/resources/extensions/gsd/workflow-protocol.js +131 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +68 -21
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +15 -15
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +3 -3
- package/packages/mcp-server/src/workflow-tools.test.ts +9 -2
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +4 -1
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +5 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +2 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/index.d.ts +1 -0
- package/packages/pi-agent-core/dist/index.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/index.js +2 -0
- package/packages/pi-agent-core/dist/index.js.map +1 -1
- package/packages/pi-agent-core/dist/token-audit.d.ts +47 -0
- package/packages/pi-agent-core/dist/token-audit.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/token-audit.js +221 -0
- package/packages/pi-agent-core/dist/token-audit.js.map +1 -0
- package/packages/pi-agent-core/dist/types.d.ts +9 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/src/agent-loop.test.ts +128 -0
- package/packages/pi-agent-core/src/agent-loop.ts +4 -1
- package/packages/pi-agent-core/src/agent.ts +8 -0
- package/packages/pi-agent-core/src/index.ts +2 -0
- package/packages/pi-agent-core/src/token-audit.test.ts +189 -0
- package/packages/pi-agent-core/src/token-audit.ts +287 -0
- package/packages/pi-agent-core/src/types.ts +14 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +32 -0
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js +18 -0
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +12 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +41 -7
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +8 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +3 -6
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +3 -3
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +32 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js +2 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js +46 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +10 -2
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +74 -2
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js +22 -0
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +6 -7
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +2 -3
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +36 -0
- package/packages/pi-coding-agent/src/core/agent-session-tool-refresh.test.ts +25 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +45 -7
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +10 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +3 -3
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +5 -5
- package/packages/pi-coding-agent/src/core/extensions/types.ts +35 -1
- package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +2 -0
- package/packages/pi-coding-agent/src/core/sdk-tool-filter.test.ts +60 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +85 -3
- package/packages/pi-coding-agent/src/core/skill-tool.test.ts +28 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +8 -10
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/gsd/auto/loop-deps.ts +2 -2
- package/src/resources/extensions/gsd/auto/phases.ts +251 -172
- package/src/resources/extensions/gsd/auto/resolve.ts +23 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +25 -30
- package/src/resources/extensions/gsd/auto/session.ts +8 -0
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +8 -34
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +18 -4
- package/src/resources/extensions/gsd/auto-prompts.ts +95 -14
- package/src/resources/extensions/gsd/auto-recovery.ts +54 -0
- package/src/resources/extensions/gsd/auto-start.ts +230 -9
- package/src/resources/extensions/gsd/auto-supervisor.ts +7 -0
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +2 -2
- package/src/resources/extensions/gsd/auto-worktree.ts +123 -0
- package/src/resources/extensions/gsd/auto.ts +87 -19
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +49 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +50 -36
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +16 -5
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +10 -3
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +8 -1
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +10 -3
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +9 -2
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +283 -28
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
- package/src/resources/extensions/gsd/clean-root-preflight.ts +32 -7
- package/src/resources/extensions/gsd/commands-handlers.ts +34 -15
- package/src/resources/extensions/gsd/context-budget.ts +44 -2
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +41 -0
- package/src/resources/extensions/gsd/db-base-schema.ts +4 -2
- package/src/resources/extensions/gsd/db-migration-steps.ts +8 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +3 -0
- package/src/resources/extensions/gsd/git-service.ts +46 -8
- package/src/resources/extensions/gsd/gsd-db.ts +50 -13
- package/src/resources/extensions/gsd/guided-flow.ts +84 -39
- package/src/resources/extensions/gsd/memory-store.ts +77 -12
- package/src/resources/extensions/gsd/native-git-bridge.ts +39 -6
- package/src/resources/extensions/gsd/orphan-stash-audit.ts +117 -0
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +13 -3
- package/src/resources/extensions/gsd/pre-execution-checks.ts +23 -0
- package/src/resources/extensions/gsd/prompt-loader.ts +27 -2
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +16 -13
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +417 -10
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +56 -13
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +168 -6
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +15 -6
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +3 -1
- package/src/resources/extensions/gsd/tests/complete-milestone-excerpt.test.ts +31 -0
- package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/context-budget.test.ts +10 -1
- package/src/resources/extensions/gsd/tests/context-store.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +5 -1
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +313 -0
- package/src/resources/extensions/gsd/tests/execute-task-rendering.test.ts +5 -2
- package/src/resources/extensions/gsd/tests/fast-forward-reused-milestone-branch.test.ts +219 -0
- package/src/resources/extensions/gsd/tests/finalize-survivor-branch.test.ts +132 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +6 -3
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +239 -1
- package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +32 -0
- package/src/resources/extensions/gsd/tests/knowledge.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +242 -0
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +34 -2
- package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/orphan-merge-bootstrap.test.ts +133 -0
- package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +201 -0
- package/src/resources/extensions/gsd/tests/parallel-orchestrator-fast-forward.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +45 -5
- package/src/resources/extensions/gsd/tests/prompt-duplication-cuts.test.ts +230 -0
- package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +38 -17
- package/src/resources/extensions/gsd/tests/schema-v27-v28-sequence.test.ts +156 -0
- package/src/resources/extensions/gsd/tests/select-resumable-milestone.test.ts +96 -0
- package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +106 -0
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +49 -1
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/system-context-memory.test.ts +112 -0
- package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +7 -9
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +291 -0
- package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -4
- package/src/resources/extensions/gsd/tests/workflow-protocol-excerpt.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-path-injection.test.ts +22 -19
- package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +66 -0
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +167 -4
- package/src/resources/extensions/gsd/tools/memory-tools.ts +1 -0
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +1 -1
- package/src/resources/extensions/gsd/unit-runtime.ts +11 -0
- package/src/resources/extensions/gsd/workflow-protocol.ts +160 -0
- package/src/resources/extensions/gsd/worktree-resolver.ts +85 -19
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +0 -97
- /package/dist/web/standalone/.next/static/{3EDDd9ULaybSupPoA_vf- → O2WvnXROue6l7nAp_4dhC}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{3EDDd9ULaybSupPoA_vf- → O2WvnXROue6l7nAp_4dhC}/_ssgManifest.js +0 -0
|
@@ -25,7 +25,7 @@ import { emitWorktreeCreated, emitWorktreeMerged } from "./worktree-telemetry.js
|
|
|
25
25
|
import { getCollapseCadence, getMilestoneResquash, resquashMilestoneOnMain } from "./slice-cadence.js";
|
|
26
26
|
import { loadEffectiveGSDPreferences } from "./preferences.js";
|
|
27
27
|
import { resolveWorktreeProjectRoot, normalizeWorktreePathForCompare } from "./worktree-root.js";
|
|
28
|
-
import { claimMilestoneLease, releaseMilestoneLease } from "./db/milestone-leases.js";
|
|
28
|
+
import { claimMilestoneLease, refreshMilestoneLease, releaseMilestoneLease } from "./db/milestone-leases.js";
|
|
29
29
|
|
|
30
30
|
// ─── Path Comparison Helper ────────────────────────────────────────────────
|
|
31
31
|
/**
|
|
@@ -40,6 +40,16 @@ function isSamePath(a: string, b: string): boolean {
|
|
|
40
40
|
return normalizeWorktreePathForCompare(a) === normalizeWorktreePathForCompare(b);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
class UserNotifiedError extends Error {
|
|
44
|
+
readonly cause?: unknown;
|
|
45
|
+
|
|
46
|
+
constructor(message: string, cause?: unknown) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = "UserNotifiedError";
|
|
49
|
+
this.cause = cause;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
// ─── Dependency Interface ──────────────────────────────────────────────────
|
|
44
54
|
|
|
45
55
|
export interface WorktreeResolverDeps {
|
|
@@ -71,6 +81,13 @@ export interface WorktreeResolverDeps {
|
|
|
71
81
|
milestoneId: string,
|
|
72
82
|
) => void;
|
|
73
83
|
getCurrentBranch: (basePath: string) => string;
|
|
84
|
+
/**
|
|
85
|
+
* Force-checkout the named branch in `basePath`. Required by `_mergeBranchMode`
|
|
86
|
+
* when it discovers the working tree is not on the milestone branch — preflight
|
|
87
|
+
* stash + later operations may have switched HEAD to main, and silently skipping
|
|
88
|
+
* the merge would strand the milestone's commits.
|
|
89
|
+
*/
|
|
90
|
+
checkoutBranch: (basePath: string, branch: string) => void;
|
|
74
91
|
autoWorktreeBranch: (milestoneId: string) => string;
|
|
75
92
|
resolveMilestoneFile: (
|
|
76
93
|
basePath: string,
|
|
@@ -207,23 +224,44 @@ export class WorktreeResolver {
|
|
|
207
224
|
// milestone (re-entry within the same session).
|
|
208
225
|
if (this.s.workerId) {
|
|
209
226
|
if (this.s.currentMilestoneId === milestoneId && this.s.milestoneLeaseToken !== null) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
const refreshed = refreshMilestoneLease(
|
|
228
|
+
this.s.workerId,
|
|
229
|
+
milestoneId,
|
|
230
|
+
this.s.milestoneLeaseToken,
|
|
231
|
+
);
|
|
232
|
+
if (refreshed) {
|
|
233
|
+
debugLog("WorktreeResolver", {
|
|
234
|
+
action: "enterMilestone",
|
|
235
|
+
milestoneId,
|
|
236
|
+
leaseRefreshed: true,
|
|
237
|
+
fencingToken: this.s.milestoneLeaseToken,
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
debugLog("WorktreeResolver", {
|
|
241
|
+
action: "enterMilestone",
|
|
242
|
+
milestoneId,
|
|
243
|
+
staleLeaseToken: this.s.milestoneLeaseToken,
|
|
244
|
+
});
|
|
224
245
|
this.s.milestoneLeaseToken = null;
|
|
225
246
|
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// If we held a different milestone, release it first so other
|
|
250
|
+
// workers don't have to wait for TTL.
|
|
251
|
+
if (this.s.currentMilestoneId && this.s.currentMilestoneId !== milestoneId && this.s.milestoneLeaseToken !== null) {
|
|
252
|
+
try {
|
|
253
|
+
releaseMilestoneLease(this.s.workerId, this.s.currentMilestoneId, this.s.milestoneLeaseToken);
|
|
254
|
+
} catch (err) {
|
|
255
|
+
debugLog("WorktreeResolver", {
|
|
256
|
+
action: "enterMilestone",
|
|
257
|
+
milestoneId,
|
|
258
|
+
releasePriorLeaseError: err instanceof Error ? err.message : String(err),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
this.s.milestoneLeaseToken = null;
|
|
262
|
+
}
|
|
226
263
|
|
|
264
|
+
if (this.s.milestoneLeaseToken === null) {
|
|
227
265
|
try {
|
|
228
266
|
const claim = claimMilestoneLease(this.s.workerId, milestoneId);
|
|
229
267
|
if (claim.ok) {
|
|
@@ -803,16 +841,41 @@ export class WorktreeResolver {
|
|
|
803
841
|
const milestoneBranch = this.deps.autoWorktreeBranch(milestoneId);
|
|
804
842
|
|
|
805
843
|
if (currentBranch !== milestoneBranch) {
|
|
844
|
+
// #5538-followup: previous behavior was to silently `return false`
|
|
845
|
+
// when HEAD wasn't on the milestone branch — that let the loop
|
|
846
|
+
// advance with the milestone's commits stranded on the branch (the
|
|
847
|
+
// exact failure mode reported in the test12345 repro). Attempt
|
|
848
|
+
// recovery by force-checking-out the milestone branch; if the
|
|
849
|
+
// checkout fails, throw so the caller pauses auto-mode and the user
|
|
850
|
+
// sees the failure instead of a silent merge skip.
|
|
806
851
|
debugLog("WorktreeResolver", {
|
|
807
852
|
action: "mergeAndExit",
|
|
808
853
|
milestoneId,
|
|
809
854
|
mode: "branch",
|
|
810
|
-
|
|
811
|
-
reason: "not-on-milestone-branch",
|
|
855
|
+
recovery: "checkout-milestone-branch",
|
|
812
856
|
currentBranch,
|
|
813
857
|
milestoneBranch,
|
|
814
858
|
});
|
|
815
|
-
|
|
859
|
+
try {
|
|
860
|
+
this.deps.checkoutBranch(this.s.basePath, milestoneBranch);
|
|
861
|
+
} catch (checkoutErr) {
|
|
862
|
+
const checkoutMsg = checkoutErr instanceof Error ? checkoutErr.message : String(checkoutErr);
|
|
863
|
+
ctx.notify(
|
|
864
|
+
`Cannot merge milestone ${milestoneId}: working tree is on ${currentBranch} and checkout to ${milestoneBranch} failed (${checkoutMsg}). Resolve manually and run /gsd auto to resume.`,
|
|
865
|
+
"error",
|
|
866
|
+
);
|
|
867
|
+
throw new UserNotifiedError(checkoutMsg, checkoutErr);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
const reverify = this.deps.getCurrentBranch(this.s.basePath);
|
|
871
|
+
if (reverify !== milestoneBranch) {
|
|
872
|
+
const reverifyMsg = `branch checkout to ${milestoneBranch} reported success but current branch is ${reverify}`;
|
|
873
|
+
ctx.notify(
|
|
874
|
+
`Cannot merge milestone ${milestoneId}: ${reverifyMsg}. Resolve manually and run /gsd auto to resume.`,
|
|
875
|
+
"error",
|
|
876
|
+
);
|
|
877
|
+
throw new UserNotifiedError(reverifyMsg);
|
|
878
|
+
}
|
|
816
879
|
}
|
|
817
880
|
|
|
818
881
|
const roadmapPath = this.deps.resolveMilestoneFile(
|
|
@@ -869,7 +932,9 @@ export class WorktreeResolver {
|
|
|
869
932
|
result: "error",
|
|
870
933
|
error: msg,
|
|
871
934
|
});
|
|
872
|
-
|
|
935
|
+
if (!(err instanceof UserNotifiedError)) {
|
|
936
|
+
ctx.notify(`Milestone merge failed (branch mode): ${msg}`, "warning");
|
|
937
|
+
}
|
|
873
938
|
// Re-throw all errors so callers can apply their own recovery logic (#4380).
|
|
874
939
|
throw err;
|
|
875
940
|
}
|
|
@@ -897,6 +962,7 @@ export class WorktreeResolver {
|
|
|
897
962
|
try {
|
|
898
963
|
this.mergeAndExit(currentMilestoneId, ctx);
|
|
899
964
|
} catch (err) {
|
|
965
|
+
if (err instanceof UserNotifiedError) throw err;
|
|
900
966
|
// mergeAndExit emits a warning and restores state when it fails during
|
|
901
967
|
// merge/cleanup. But if it throws before recovery runs (e.g., in
|
|
902
968
|
// validateMilestoneId or emitJournalEvent), basePath won't be restored
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* phases-merge-error-stops-auto.test.ts — Regression test for #2766.
|
|
3
|
-
*
|
|
4
|
-
* When mergeAndExit throws a non-MergeConflictError, the auto loop must
|
|
5
|
-
* stop instead of continuing with unmerged work. This test verifies that
|
|
6
|
-
* all catch blocks in auto/phases.ts that handle mergeAndExit errors
|
|
7
|
-
* call stopAuto and return { action: "break" } for non-conflict errors.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { readFileSync } from "node:fs";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { createTestContext } from "./test-helpers.ts";
|
|
13
|
-
|
|
14
|
-
const { assertTrue, report } = createTestContext();
|
|
15
|
-
|
|
16
|
-
const phasesPath = join(import.meta.dirname, "..", "auto", "phases.ts");
|
|
17
|
-
const phasesSrc = readFileSync(phasesPath, "utf-8");
|
|
18
|
-
|
|
19
|
-
console.log("\n=== #2766: Non-MergeConflictError stops auto mode ===");
|
|
20
|
-
|
|
21
|
-
// ── Test 1: every mergeAndExit call site has a catch (mergeErr) block ──
|
|
22
|
-
|
|
23
|
-
// Count all mergeAndExit catch blocks by finding "} catch (mergeErr)" patterns
|
|
24
|
-
const mergeAndExitCallCount = [...phasesSrc.matchAll(/\.mergeAndExit\(/g)].length;
|
|
25
|
-
const mergeErrCatchCount = [...phasesSrc.matchAll(/\} catch \(mergeErr\)/g)].length;
|
|
26
|
-
assertTrue(
|
|
27
|
-
mergeErrCatchCount === mergeAndExitCallCount && mergeAndExitCallCount > 0,
|
|
28
|
-
`every mergeAndExit call site has a catch (mergeErr) block (calls=${mergeAndExitCallCount}, catches=${mergeErrCatchCount})`,
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
// ── Test 2: Every mergeErr catch block handles non-MergeConflictError ───
|
|
32
|
-
|
|
33
|
-
// Find each catch block and verify it has the non-conflict error handling pattern
|
|
34
|
-
const catchPattern = /\} catch \(mergeErr\) \{/g;
|
|
35
|
-
let match;
|
|
36
|
-
let blocksWithNonConflictHandling = 0;
|
|
37
|
-
let blocksTotal = 0;
|
|
38
|
-
|
|
39
|
-
while ((match = catchPattern.exec(phasesSrc)) !== null) {
|
|
40
|
-
blocksTotal++;
|
|
41
|
-
// Look at the ~800 chars after the catch to find both the MergeConflictError
|
|
42
|
-
// instanceof check AND the non-conflict handling
|
|
43
|
-
const afterCatch = phasesSrc.slice(match.index, match.index + 1200);
|
|
44
|
-
|
|
45
|
-
const hasInstanceofCheck = afterCatch.includes("instanceof MergeConflictError");
|
|
46
|
-
const hasNonConflictStop = afterCatch.includes('reason: "merge-failed"');
|
|
47
|
-
const hasStopAuto = afterCatch.includes("stopAuto");
|
|
48
|
-
const hasLogError = afterCatch.includes("logError");
|
|
49
|
-
|
|
50
|
-
if (hasInstanceofCheck && hasNonConflictStop && hasStopAuto && hasLogError) {
|
|
51
|
-
blocksWithNonConflictHandling++;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
assertTrue(
|
|
56
|
-
blocksWithNonConflictHandling === blocksTotal && blocksTotal >= 3,
|
|
57
|
-
`all ${blocksTotal} mergeAndExit catch blocks stop auto on non-conflict errors (${blocksWithNonConflictHandling}/${blocksTotal})`,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// ── Test 3: Non-conflict handler returns break (does not continue) ──────
|
|
61
|
-
|
|
62
|
-
// Verify the pattern: after the MergeConflictError instanceof block,
|
|
63
|
-
// the non-conflict path returns { action: "break", reason: "merge-failed" }
|
|
64
|
-
const mergeFailedReasons = [...phasesSrc.matchAll(/reason: "merge-failed"/g)].length;
|
|
65
|
-
assertTrue(
|
|
66
|
-
mergeFailedReasons >= 3,
|
|
67
|
-
`all catch blocks return reason: "merge-failed" (found ${mergeFailedReasons}, expected >= 3)`,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
// ── Test 4: Non-conflict handler notifies user ──────────────────────────
|
|
71
|
-
|
|
72
|
-
// Each non-conflict block should call ctx.ui.notify with error severity
|
|
73
|
-
const notifyErrorPattern = /Merge failed:.*Resolve and run \/gsd auto to resume/g;
|
|
74
|
-
const notifyCount = [...phasesSrc.matchAll(notifyErrorPattern)].length;
|
|
75
|
-
assertTrue(
|
|
76
|
-
notifyCount >= 3,
|
|
77
|
-
`all catch blocks notify user about merge failure (found ${notifyCount}, expected >= 3)`,
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
// ── Test 5: logError replaces logWarning for non-conflict merge errors ──
|
|
81
|
-
|
|
82
|
-
// The old code used logWarning — verify logError is used instead
|
|
83
|
-
const logWarningMergePattern = /logWarning\(.*Milestone merge failed with non-conflict error/g;
|
|
84
|
-
const logWarningCount = [...phasesSrc.matchAll(logWarningMergePattern)].length;
|
|
85
|
-
assertTrue(
|
|
86
|
-
logWarningCount === 0,
|
|
87
|
-
"logWarning is no longer used for non-conflict merge errors (replaced by logError)",
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const logErrorMergePattern = /logError\(.*Milestone merge failed with non-conflict error/g;
|
|
91
|
-
const logErrorCount = [...phasesSrc.matchAll(logErrorMergePattern)].length;
|
|
92
|
-
assertTrue(
|
|
93
|
-
logErrorCount >= 3,
|
|
94
|
-
`logError is used for non-conflict merge errors (found ${logErrorCount}, expected >= 3)`,
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
report();
|
|
File without changes
|
|
File without changes
|