gsd-pi 2.41.0-dev.9446b20 → 2.41.0-dev.97349b1
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 +69 -29
- package/dist/cli-web-branch.d.ts +6 -0
- package/dist/cli-web-branch.js +17 -0
- package/dist/onboarding.js +2 -1
- package/dist/resources/extensions/gsd/auto/loop.js +9 -1
- package/dist/resources/extensions/gsd/auto/phases.js +26 -8
- package/dist/resources/extensions/gsd/auto-dashboard.js +6 -2
- package/dist/resources/extensions/gsd/auto-dispatch.js +19 -2
- package/dist/resources/extensions/gsd/auto-post-unit.js +7 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +12 -4
- package/dist/resources/extensions/gsd/auto-start.js +8 -3
- package/dist/resources/extensions/gsd/auto-worktree.js +147 -13
- package/dist/resources/extensions/gsd/auto.js +36 -1
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +199 -164
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +62 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +2 -0
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +16 -0
- package/dist/resources/extensions/gsd/commands/catalog.js +8 -1
- package/dist/resources/extensions/gsd/commands/handlers/core.js +1 -0
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +5 -0
- package/dist/resources/extensions/gsd/context-store.js +4 -3
- package/dist/resources/extensions/gsd/db-writer.js +5 -2
- package/dist/resources/extensions/gsd/detection.js +1 -1
- package/dist/resources/extensions/gsd/doctor.js +11 -1
- package/dist/resources/extensions/gsd/exit-command.js +12 -2
- package/dist/resources/extensions/gsd/export.js +9 -13
- package/dist/resources/extensions/gsd/extension-manifest.json +2 -2
- package/dist/resources/extensions/gsd/files.js +28 -11
- package/dist/resources/extensions/gsd/forensics.js +10 -3
- package/dist/resources/extensions/gsd/git-service.js +5 -1
- package/dist/resources/extensions/gsd/gsd-db.js +25 -8
- package/dist/resources/extensions/gsd/guided-flow-queue.js +1 -1
- package/dist/resources/extensions/gsd/guided-flow.js +7 -3
- package/dist/resources/extensions/gsd/journal.js +85 -0
- package/dist/resources/extensions/gsd/md-importer.js +5 -0
- package/dist/resources/extensions/gsd/milestone-ids.js +1 -1
- package/dist/resources/extensions/gsd/native-git-bridge.js +2 -2
- package/dist/resources/extensions/gsd/post-unit-hooks.js +24 -412
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences.js +1 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +34 -4
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +11 -10
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +2 -2
- package/dist/resources/extensions/gsd/prompts/discuss.md +1 -1
- package/dist/resources/extensions/gsd/prompts/queue.md +1 -1
- package/dist/resources/extensions/gsd/repo-identity.js +46 -2
- package/dist/resources/extensions/gsd/rule-registry.js +489 -0
- package/dist/resources/extensions/gsd/rule-types.js +6 -0
- package/dist/resources/extensions/gsd/service-tier.js +138 -0
- package/dist/resources/extensions/gsd/structured-data-formatter.js +2 -1
- package/dist/resources/extensions/gsd/templates/decisions.md +2 -2
- package/dist/resources/extensions/gsd/workflow-templates.js +13 -1
- package/dist/resources/extensions/gsd/worktree-manager.js +20 -6
- package/dist/resources/extensions/gsd/worktree-resolver.js +19 -2
- package/dist/resources/extensions/subagent/index.js +7 -3
- package/dist/resources/extensions/voice/index.js +4 -4
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +16 -16
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
- 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/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +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 +16 -16
- package/dist/web/standalone/.next/server/chunks/229.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +2 -2
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/4024.c195dc1fdd2adbea.js +9 -0
- package/dist/web/standalone/.next/static/chunks/{webpack-9afaaebf6042a1d7.js → webpack-fa307370fcf9fb2c.js} +1 -1
- package/dist/web-mode.d.ts +2 -0
- package/dist/web-mode.js +29 -7
- package/package.json +1 -1
- package/packages/native/src/__tests__/text.test.mjs +33 -0
- package/packages/pi-coding-agent/dist/core/discovery-cache.test.js +3 -1
- package/packages/pi-coding-agent/dist/core/discovery-cache.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +10 -7
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/packages/pi-coding-agent/src/core/discovery-cache.test.ts +4 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +11 -7
- package/src/resources/extensions/gsd/auto/loop-deps.ts +5 -1
- package/src/resources/extensions/gsd/auto/loop.ts +10 -1
- package/src/resources/extensions/gsd/auto/phases.ts +28 -8
- package/src/resources/extensions/gsd/auto/types.ts +4 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +7 -2
- package/src/resources/extensions/gsd/auto-dispatch.ts +25 -5
- package/src/resources/extensions/gsd/auto-post-unit.ts +8 -0
- package/src/resources/extensions/gsd/auto-recovery.ts +12 -4
- package/src/resources/extensions/gsd/auto-start.ts +8 -3
- package/src/resources/extensions/gsd/auto-worktree.ts +162 -18
- package/src/resources/extensions/gsd/auto.ts +40 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +209 -162
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +62 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +2 -0
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +13 -0
- package/src/resources/extensions/gsd/commands/catalog.ts +8 -1
- package/src/resources/extensions/gsd/commands/handlers/core.ts +1 -0
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +5 -0
- package/src/resources/extensions/gsd/context-store.ts +4 -3
- package/src/resources/extensions/gsd/db-writer.ts +6 -2
- package/src/resources/extensions/gsd/detection.ts +1 -1
- package/src/resources/extensions/gsd/doctor.ts +12 -1
- package/src/resources/extensions/gsd/exit-command.ts +14 -2
- package/src/resources/extensions/gsd/export.ts +8 -15
- package/src/resources/extensions/gsd/extension-manifest.json +2 -2
- package/src/resources/extensions/gsd/files.ts +29 -12
- package/src/resources/extensions/gsd/forensics.ts +9 -3
- package/src/resources/extensions/gsd/git-service.ts +5 -4
- package/src/resources/extensions/gsd/gsd-db.ts +37 -8
- package/src/resources/extensions/gsd/guided-flow-queue.ts +1 -1
- package/src/resources/extensions/gsd/guided-flow.ts +7 -3
- package/src/resources/extensions/gsd/journal.ts +134 -0
- package/src/resources/extensions/gsd/md-importer.ts +6 -0
- package/src/resources/extensions/gsd/milestone-ids.ts +1 -1
- package/src/resources/extensions/gsd/native-git-bridge.ts +2 -2
- package/src/resources/extensions/gsd/post-unit-hooks.ts +24 -462
- package/src/resources/extensions/gsd/preferences-types.ts +3 -0
- package/src/resources/extensions/gsd/preferences.ts +1 -0
- package/src/resources/extensions/gsd/prompt-loader.ts +35 -4
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +11 -10
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +2 -2
- package/src/resources/extensions/gsd/prompts/discuss.md +1 -1
- package/src/resources/extensions/gsd/prompts/queue.md +1 -1
- package/src/resources/extensions/gsd/repo-identity.ts +47 -2
- package/src/resources/extensions/gsd/rule-registry.ts +599 -0
- package/src/resources/extensions/gsd/rule-types.ts +68 -0
- package/src/resources/extensions/gsd/service-tier.ts +171 -0
- package/src/resources/extensions/gsd/structured-data-formatter.ts +3 -1
- package/src/resources/extensions/gsd/templates/decisions.md +2 -2
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +103 -120
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +202 -0
- package/src/resources/extensions/gsd/tests/captures.test.ts +12 -1
- package/src/resources/extensions/gsd/tests/context-store.test.ts +10 -5
- package/src/resources/extensions/gsd/tests/continue-here.test.ts +20 -20
- package/src/resources/extensions/gsd/tests/db-writer.test.ts +10 -0
- package/src/resources/extensions/gsd/tests/doctor-completion-deferral.test.ts +15 -10
- package/src/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +5 -4
- package/src/resources/extensions/gsd/tests/doctor-roadmap-summary-atomicity.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/doctor-task-done-missing-summary-slice-loop.test.ts +174 -0
- package/src/resources/extensions/gsd/tests/exit-command.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +8 -1
- package/src/resources/extensions/gsd/tests/gsd-tools.test.ts +7 -7
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +513 -0
- package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +147 -0
- package/src/resources/extensions/gsd/tests/journal.test.ts +386 -0
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +31 -1
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/milestone-id-reservation.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/parsers.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +47 -25
- package/src/resources/extensions/gsd/tests/prompt-db.test.ts +3 -1
- package/src/resources/extensions/gsd/tests/repo-identity-worktree.test.ts +61 -1
- package/src/resources/extensions/gsd/tests/routing-history.test.ts +11 -22
- package/src/resources/extensions/gsd/tests/rule-registry.test.ts +413 -0
- package/src/resources/extensions/gsd/tests/service-tier.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/skill-lifecycle.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +102 -0
- package/src/resources/extensions/gsd/tests/structured-data-formatter.test.ts +4 -3
- package/src/resources/extensions/gsd/tests/tool-naming.test.ts +117 -0
- package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +6 -1
- package/src/resources/extensions/gsd/tests/windows-path-normalization.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/worktree-db-integration.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-db.test.ts +4 -0
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +178 -0
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +195 -105
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +78 -3
- package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +74 -0
- package/src/resources/extensions/gsd/types.ts +3 -0
- package/src/resources/extensions/gsd/workflow-templates.ts +12 -1
- package/src/resources/extensions/gsd/worktree-manager.ts +21 -6
- package/src/resources/extensions/gsd/worktree-resolver.ts +30 -9
- package/src/resources/extensions/subagent/index.ts +7 -3
- package/src/resources/extensions/voice/index.ts +4 -4
- package/dist/web/standalone/.next/static/chunks/4024.279c423e4661ece1.js +0 -9
- /package/dist/web/standalone/.next/static/{02cti5IXH7FycOqkbAkWL → ZrI3HOoXD7Fh84fAHZVxb}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{02cti5IXH7FycOqkbAkWL → ZrI3HOoXD7Fh84fAHZVxb}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Tier — gating, status formatting, icon resolution, and
|
|
3
|
+
* the /gsd fast command handler.
|
|
4
|
+
*
|
|
5
|
+
* Service tiers (priority/flex) are an OpenAI feature that only applies
|
|
6
|
+
* to gpt-5.4 variants. This module centralizes the model-gating logic
|
|
7
|
+
* so that icons, preferences, and the before_provider_request hook all
|
|
8
|
+
* use a single source of truth.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
12
|
+
|
|
13
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
14
|
+
import { saveFile } from "./files.js";
|
|
15
|
+
import {
|
|
16
|
+
getGlobalGSDPreferencesPath,
|
|
17
|
+
loadEffectiveGSDPreferences,
|
|
18
|
+
loadGlobalGSDPreferences,
|
|
19
|
+
} from "./preferences.js";
|
|
20
|
+
import { ensurePreferencesFile, serializePreferencesToFrontmatter } from "./commands-prefs-wizard.js";
|
|
21
|
+
|
|
22
|
+
// ─── Types ───────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
export type ServiceTierSetting = "priority" | "flex" | undefined;
|
|
25
|
+
|
|
26
|
+
// ─── Gating ──────────────────────────────────────────────────────────────────
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns true when the given model ID supports OpenAI service tiers.
|
|
30
|
+
* Currently only gpt-5.4 variants qualify.
|
|
31
|
+
*/
|
|
32
|
+
export function supportsServiceTier(modelId: string): boolean {
|
|
33
|
+
if (!modelId) return false;
|
|
34
|
+
// Strip provider prefix if present (e.g. "openai/gpt-5.4" → "gpt-5.4")
|
|
35
|
+
const bare = modelId.includes("/") ? modelId.split("/").pop()! : modelId;
|
|
36
|
+
return bare.startsWith("gpt-5.4");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ─── Status Formatting ───────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Human-readable description of the current service tier setting.
|
|
43
|
+
*/
|
|
44
|
+
export function formatServiceTierStatus(tier: ServiceTierSetting): string {
|
|
45
|
+
if (!tier) {
|
|
46
|
+
return [
|
|
47
|
+
"Service tier: disabled",
|
|
48
|
+
"",
|
|
49
|
+
"Usage:",
|
|
50
|
+
" /gsd fast on Set to priority (2x cost, faster)",
|
|
51
|
+
" /gsd fast flex Set to flex (0.5x cost, slower)",
|
|
52
|
+
" /gsd fast off Disable service tier",
|
|
53
|
+
"",
|
|
54
|
+
"Only affects gpt-5.4 models.",
|
|
55
|
+
].join("\n");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const label = tier === "priority" ? "priority (2x cost, faster)" : "flex (0.5x cost, slower)";
|
|
59
|
+
return [
|
|
60
|
+
`Service tier: ${label}`,
|
|
61
|
+
"",
|
|
62
|
+
"Usage:",
|
|
63
|
+
" /gsd fast on Set to priority (2x cost, faster)",
|
|
64
|
+
" /gsd fast flex Set to flex (0.5x cost, slower)",
|
|
65
|
+
" /gsd fast off Disable service tier",
|
|
66
|
+
"",
|
|
67
|
+
"Only affects gpt-5.4 models.",
|
|
68
|
+
].join("\n");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ─── Icon Resolution ─────────────────────────────────────────────────────────
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns the appropriate icon for the active service tier and model.
|
|
75
|
+
* Returns empty string when the tier is inactive or the model doesn't
|
|
76
|
+
* support service tiers.
|
|
77
|
+
*/
|
|
78
|
+
export function resolveServiceTierIcon(tier: ServiceTierSetting, modelId: string): string {
|
|
79
|
+
if (!tier || !supportsServiceTier(modelId)) return "";
|
|
80
|
+
return tier === "priority" ? "⚡" : "💰";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ─── Preference Read ─────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Read the effective service_tier setting from preferences.
|
|
87
|
+
*/
|
|
88
|
+
export function getEffectiveServiceTier(): ServiceTierSetting {
|
|
89
|
+
const prefs = loadEffectiveGSDPreferences()?.preferences;
|
|
90
|
+
const raw = prefs?.service_tier;
|
|
91
|
+
if (raw === "priority" || raw === "flex") return raw;
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ─── Preference Write ────────────────────────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
function extractBodyAfterFrontmatter(content: string): string | null {
|
|
98
|
+
const start = content.startsWith("---\n") ? 4 : content.startsWith("---\r\n") ? 5 : -1;
|
|
99
|
+
if (start === -1) return null;
|
|
100
|
+
const closingIdx = content.indexOf("\n---", start);
|
|
101
|
+
if (closingIdx === -1) return null;
|
|
102
|
+
const after = content.slice(closingIdx + 4);
|
|
103
|
+
return after.trim() ? after : null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function writeGlobalServiceTier(
|
|
107
|
+
ctx: ExtensionCommandContext,
|
|
108
|
+
tier: ServiceTierSetting,
|
|
109
|
+
): Promise<void> {
|
|
110
|
+
const path = getGlobalGSDPreferencesPath();
|
|
111
|
+
await ensurePreferencesFile(path, ctx, "global");
|
|
112
|
+
|
|
113
|
+
const existing = loadGlobalGSDPreferences();
|
|
114
|
+
const prefs: Record<string, unknown> = existing?.preferences ? { ...existing.preferences } : {};
|
|
115
|
+
prefs.version = prefs.version || 1;
|
|
116
|
+
|
|
117
|
+
if (tier) {
|
|
118
|
+
prefs.service_tier = tier;
|
|
119
|
+
} else {
|
|
120
|
+
delete prefs.service_tier;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const frontmatter = serializePreferencesToFrontmatter(prefs);
|
|
124
|
+
let body = "\n# GSD Skill Preferences\n\nSee `~/.gsd/agent/extensions/gsd/docs/preferences-reference.md` for full field documentation and examples.\n";
|
|
125
|
+
if (existsSync(path)) {
|
|
126
|
+
const preserved = extractBodyAfterFrontmatter(readFileSync(path, "utf-8"));
|
|
127
|
+
if (preserved) body = preserved;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
await saveFile(path, `---\n${frontmatter}---${body}`);
|
|
131
|
+
await ctx.waitForIdle();
|
|
132
|
+
await ctx.reload();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ─── Command Handler ─────────────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Handle `/gsd fast [on|off|flex|status]`.
|
|
139
|
+
*/
|
|
140
|
+
export async function handleFast(args: string, ctx: ExtensionCommandContext): Promise<void> {
|
|
141
|
+
const trimmed = args.trim().toLowerCase();
|
|
142
|
+
|
|
143
|
+
if (!trimmed || trimmed === "status") {
|
|
144
|
+
const tier = getEffectiveServiceTier();
|
|
145
|
+
ctx.ui.notify(formatServiceTierStatus(tier), "info");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (trimmed === "on") {
|
|
150
|
+
await writeGlobalServiceTier(ctx, "priority");
|
|
151
|
+
ctx.ui.notify("Service tier set to priority (2x cost, faster responses). Only affects gpt-5.4 models.", "info");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (trimmed === "off") {
|
|
156
|
+
await writeGlobalServiceTier(ctx, undefined);
|
|
157
|
+
ctx.ui.notify("Service tier disabled.", "info");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (trimmed === "flex") {
|
|
162
|
+
await writeGlobalServiceTier(ctx, "flex");
|
|
163
|
+
ctx.ui.notify("Service tier set to flex (0.5x cost, slower responses). Only affects gpt-5.4 models.", "info");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
ctx.ui.notify(
|
|
168
|
+
"Usage: /gsd fast [on|off|flex|status]\n\n on Priority tier (2x cost, faster)\n off Disable service tier\n flex Flex tier (0.5x cost, slower)\n status Show current setting",
|
|
169
|
+
"warning",
|
|
170
|
+
);
|
|
171
|
+
}
|
|
@@ -25,6 +25,7 @@ interface DecisionInput {
|
|
|
25
25
|
choice: string;
|
|
26
26
|
rationale: string;
|
|
27
27
|
revisable: string;
|
|
28
|
+
made_by?: string;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
interface RequirementInput {
|
|
@@ -61,6 +62,7 @@ export function formatDecisionCompact(decision: DecisionInput): string {
|
|
|
61
62
|
decision.choice,
|
|
62
63
|
decision.rationale,
|
|
63
64
|
decision.revisable,
|
|
65
|
+
decision.made_by ?? 'agent',
|
|
64
66
|
].join(" | ");
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -70,7 +72,7 @@ export function formatDecisionsCompact(decisions: DecisionInput[]): string {
|
|
|
70
72
|
return "# Decisions (compact)\n(none)";
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
const header = "# Decisions (compact)\nFields: id | when | scope | decision | choice | rationale | revisable";
|
|
75
|
+
const header = "# Decisions (compact)\nFields: id | when | scope | decision | choice | rationale | revisable | made_by";
|
|
74
76
|
const lines = decisions.map(formatDecisionCompact);
|
|
75
77
|
return `${header}\n\n${lines.join("\n")}`;
|
|
76
78
|
}
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
To reverse a decision, add a new row that supersedes it.
|
|
5
5
|
Read this file at the start of any planning or research phase. -->
|
|
6
6
|
|
|
7
|
-
| # | When | Scope | Decision | Choice | Rationale | Revisable? |
|
|
8
|
-
|
|
7
|
+
| # | When | Scope | Decision | Choice | Rationale | Revisable? | Made By |
|
|
8
|
+
|---|------|-------|----------|--------|-----------|------------|---------|
|
|
@@ -337,7 +337,7 @@ function makeMockDeps(
|
|
|
337
337
|
pruneQueueOrder: () => {},
|
|
338
338
|
isInAutoWorktree: () => false,
|
|
339
339
|
shouldUseWorktreeIsolation: () => false,
|
|
340
|
-
mergeMilestoneToMain: () => ({ pushed: false }),
|
|
340
|
+
mergeMilestoneToMain: () => ({ pushed: false, codeFilesChanged: true }),
|
|
341
341
|
teardownAutoWorktree: () => {},
|
|
342
342
|
createAutoWorktree: () => "/tmp/wt",
|
|
343
343
|
captureIntegrationBranch: () => {},
|
|
@@ -416,6 +416,7 @@ function makeMockDeps(
|
|
|
416
416
|
getSessionFile: () => "/tmp/session.json",
|
|
417
417
|
rebuildState: async () => {},
|
|
418
418
|
resolveModelId: (id: string, models: any[]) => models.find((m: any) => m.id === id),
|
|
419
|
+
emitJournalEvent: () => {},
|
|
419
420
|
};
|
|
420
421
|
|
|
421
422
|
const merged = { ...baseDeps, ...overrides, callLog };
|
|
@@ -594,7 +595,6 @@ test("autoLoop calls deriveState → resolveDispatch → runUnit in sequence", a
|
|
|
594
595
|
ctx.sessionManager = { getSessionFile: () => "/tmp/session.json" };
|
|
595
596
|
const pi = makeMockPi();
|
|
596
597
|
|
|
597
|
-
let loopCount = 0;
|
|
598
598
|
const s = makeLoopSession();
|
|
599
599
|
|
|
600
600
|
const deps = makeMockDeps({
|
|
@@ -620,11 +620,8 @@ test("autoLoop calls deriveState → resolveDispatch → runUnit in sequence", a
|
|
|
620
620
|
},
|
|
621
621
|
postUnitPostVerification: async () => {
|
|
622
622
|
deps.callLog.push("postUnitPostVerification");
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
if (loopCount >= 1) {
|
|
626
|
-
s.active = false;
|
|
627
|
-
}
|
|
623
|
+
// Deactivate after first iteration to exit the loop
|
|
624
|
+
s.active = false;
|
|
628
625
|
return "continue" as const;
|
|
629
626
|
},
|
|
630
627
|
});
|
|
@@ -682,7 +679,6 @@ test("crash lock records session file from AFTER newSession, not before (#1710)"
|
|
|
682
679
|
};
|
|
683
680
|
const pi = makeMockPi();
|
|
684
681
|
|
|
685
|
-
let loopCount = 0;
|
|
686
682
|
const s = makeLoopSession({
|
|
687
683
|
cmdCtx: {
|
|
688
684
|
newSession: () => {
|
|
@@ -730,10 +726,8 @@ test("crash lock records session file from AFTER newSession, not before (#1710)"
|
|
|
730
726
|
},
|
|
731
727
|
postUnitPostVerification: async () => {
|
|
732
728
|
deps.callLog.push("postUnitPostVerification");
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
s.active = false;
|
|
736
|
-
}
|
|
729
|
+
// Deactivate after first iteration to exit the loop
|
|
730
|
+
s.active = false;
|
|
737
731
|
return "continue" as const;
|
|
738
732
|
},
|
|
739
733
|
});
|
|
@@ -790,6 +784,23 @@ test("autoLoop handles verification retry by continuing loop", async (t) => {
|
|
|
790
784
|
let deriveCallCount = 0;
|
|
791
785
|
const s = makeLoopSession();
|
|
792
786
|
|
|
787
|
+
// Pre-queued verification actions: each entry provides a side-effect + return value
|
|
788
|
+
type VerifyAction = { sideEffect?: () => void; response: "retry" | "continue" };
|
|
789
|
+
const verificationActions: VerifyAction[] = [
|
|
790
|
+
{
|
|
791
|
+
sideEffect: () => {
|
|
792
|
+
// Simulate retry — set pendingVerificationRetry on session
|
|
793
|
+
s.pendingVerificationRetry = {
|
|
794
|
+
unitId: "M001/S01/T01",
|
|
795
|
+
failureContext: "test failed: expected X got Y",
|
|
796
|
+
attempt: 1,
|
|
797
|
+
};
|
|
798
|
+
},
|
|
799
|
+
response: "retry",
|
|
800
|
+
},
|
|
801
|
+
{ response: "continue" },
|
|
802
|
+
];
|
|
803
|
+
|
|
793
804
|
const deps = makeMockDeps({
|
|
794
805
|
deriveState: async () => {
|
|
795
806
|
deriveCallCount++;
|
|
@@ -804,19 +815,11 @@ test("autoLoop handles verification retry by continuing loop", async (t) => {
|
|
|
804
815
|
} as any;
|
|
805
816
|
},
|
|
806
817
|
runPostUnitVerification: async () => {
|
|
818
|
+
const action = verificationActions[verifyCallCount] ?? { response: "continue" as const };
|
|
807
819
|
verifyCallCount++;
|
|
808
820
|
deps.callLog.push("runPostUnitVerification");
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
s.pendingVerificationRetry = {
|
|
812
|
-
unitId: "M001/S01/T01",
|
|
813
|
-
failureContext: "test failed: expected X got Y",
|
|
814
|
-
attempt: 1,
|
|
815
|
-
};
|
|
816
|
-
return "retry" as const;
|
|
817
|
-
}
|
|
818
|
-
// Second call: pass
|
|
819
|
-
return "continue" as const;
|
|
821
|
+
action.sideEffect?.();
|
|
822
|
+
return action.response;
|
|
820
823
|
},
|
|
821
824
|
postUnitPostVerification: async () => {
|
|
822
825
|
deps.callLog.push("postUnitPostVerification");
|
|
@@ -893,19 +896,17 @@ test("autoLoop handles dispatch skip action by continuing", async (t) => {
|
|
|
893
896
|
const s = makeLoopSession();
|
|
894
897
|
|
|
895
898
|
let dispatchCallCount = 0;
|
|
899
|
+
// Pre-queued dispatch responses: first call returns "skip", second returns "stop"
|
|
900
|
+
const dispatchResponses = [
|
|
901
|
+
{ action: "skip" as const },
|
|
902
|
+
{ action: "stop" as const, reason: "done", level: "info" as const },
|
|
903
|
+
];
|
|
896
904
|
const deps = makeMockDeps({
|
|
897
905
|
resolveDispatch: async () => {
|
|
906
|
+
const response = dispatchResponses[dispatchCallCount] ?? dispatchResponses[dispatchResponses.length - 1];
|
|
898
907
|
dispatchCallCount++;
|
|
899
908
|
deps.callLog.push("resolveDispatch");
|
|
900
|
-
|
|
901
|
-
return { action: "skip" as const };
|
|
902
|
-
}
|
|
903
|
-
// Second time: stop to exit the loop
|
|
904
|
-
return {
|
|
905
|
-
action: "stop" as const,
|
|
906
|
-
reason: "done",
|
|
907
|
-
level: "info" as const,
|
|
908
|
-
};
|
|
909
|
+
return response;
|
|
909
910
|
},
|
|
910
911
|
});
|
|
911
912
|
|
|
@@ -935,22 +936,26 @@ test("autoLoop drains sidecar queue after postUnitPostVerification enqueues item
|
|
|
935
936
|
const s = makeLoopSession();
|
|
936
937
|
|
|
937
938
|
let postVerCallCount = 0;
|
|
939
|
+
const postVerActions: Array<() => void> = [
|
|
940
|
+
() => {
|
|
941
|
+
// First call (main unit): enqueue a sidecar item
|
|
942
|
+
s.sidecarQueue.push({
|
|
943
|
+
kind: "hook" as const,
|
|
944
|
+
unitType: "hook/review",
|
|
945
|
+
unitId: "M001/S01/T01/review",
|
|
946
|
+
prompt: "review the code",
|
|
947
|
+
});
|
|
948
|
+
},
|
|
949
|
+
() => {
|
|
950
|
+
// Second call (sidecar unit completed): deactivate
|
|
951
|
+
s.active = false;
|
|
952
|
+
},
|
|
953
|
+
];
|
|
938
954
|
const deps = makeMockDeps({
|
|
939
955
|
postUnitPostVerification: async () => {
|
|
956
|
+
postVerActions[postVerCallCount]?.();
|
|
940
957
|
postVerCallCount++;
|
|
941
958
|
deps.callLog.push("postUnitPostVerification");
|
|
942
|
-
if (postVerCallCount === 1) {
|
|
943
|
-
// First call (main unit): enqueue a sidecar item
|
|
944
|
-
s.sidecarQueue.push({
|
|
945
|
-
kind: "hook" as const,
|
|
946
|
-
unitType: "hook/review",
|
|
947
|
-
unitId: "M001/S01/T01/review",
|
|
948
|
-
prompt: "review the code",
|
|
949
|
-
});
|
|
950
|
-
return "continue" as const;
|
|
951
|
-
}
|
|
952
|
-
// Second call (sidecar unit completed): done
|
|
953
|
-
s.active = false;
|
|
954
959
|
return "continue" as const;
|
|
955
960
|
},
|
|
956
961
|
});
|
|
@@ -1118,13 +1123,13 @@ test("startAuto calls selfHealRuntimeRecords before autoLoop (#1727)", () => {
|
|
|
1118
1123
|
assert.ok(healIdx > -1, "startAuto must call selfHealRuntimeRecords");
|
|
1119
1124
|
assert.ok(healIdx < loopIdx, "selfHealRuntimeRecords must be called before autoLoop");
|
|
1120
1125
|
|
|
1121
|
-
// Verify the second autoLoop call site also has selfHeal before it
|
|
1126
|
+
// Verify the second autoLoop call site also has selfHeal before it (if present)
|
|
1122
1127
|
const secondLoopIdx = fnBlock.indexOf("autoLoop(", loopIdx + 1);
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
+
const secondHealIdx = fnBlock.indexOf("selfHealRuntimeRecords", healIdx + 1);
|
|
1129
|
+
assert.ok(
|
|
1130
|
+
secondLoopIdx === -1 || (secondHealIdx > -1 && secondHealIdx < secondLoopIdx),
|
|
1131
|
+
"if a second autoLoop call exists, it must also be preceded by selfHealRuntimeRecords",
|
|
1132
|
+
);
|
|
1128
1133
|
});
|
|
1129
1134
|
|
|
1130
1135
|
test("agent_end handler calls resolveAgentEnd (not handleAgentEnd)", () => {
|
|
@@ -1286,25 +1291,29 @@ test("stuck detection: window resets recovery when deriveState returns a differe
|
|
|
1286
1291
|
const s = makeLoopSession();
|
|
1287
1292
|
|
|
1288
1293
|
let deriveCallCount = 0;
|
|
1294
|
+
let postVerCallCount = 0;
|
|
1289
1295
|
let stopCalled = false;
|
|
1290
1296
|
|
|
1297
|
+
// First 3 derives return T01, 4th returns T02; dispatch follows the derived task
|
|
1298
|
+
const derivedTaskIds = ["T01", "T01", "T01", "T02"];
|
|
1299
|
+
|
|
1291
1300
|
const deps = makeMockDeps({
|
|
1292
1301
|
deriveState: async () => {
|
|
1302
|
+
const taskId = derivedTaskIds[Math.min(deriveCallCount, derivedTaskIds.length - 1)];
|
|
1293
1303
|
deriveCallCount++;
|
|
1294
1304
|
deps.callLog.push("deriveState");
|
|
1295
1305
|
return {
|
|
1296
1306
|
phase: "executing",
|
|
1297
1307
|
activeMilestone: { id: "M001", title: "Test", status: "active" },
|
|
1298
1308
|
activeSlice: { id: "S01", title: "Slice 1" },
|
|
1299
|
-
activeTask: { id:
|
|
1309
|
+
activeTask: { id: taskId },
|
|
1300
1310
|
registry: [{ id: "M001", status: "active" }],
|
|
1301
1311
|
blockers: [],
|
|
1302
1312
|
} as any;
|
|
1303
1313
|
},
|
|
1304
1314
|
resolveDispatch: async () => {
|
|
1315
|
+
const taskId = derivedTaskIds[Math.min(deriveCallCount - 1, derivedTaskIds.length - 1)];
|
|
1305
1316
|
deps.callLog.push("resolveDispatch");
|
|
1306
|
-
// Return dispatch matching the task from deriveState
|
|
1307
|
-
const taskId = deriveCallCount <= 3 ? "T01" : "T02";
|
|
1308
1317
|
return {
|
|
1309
1318
|
action: "dispatch" as const,
|
|
1310
1319
|
unitType: "execute-task",
|
|
@@ -1318,11 +1327,11 @@ test("stuck detection: window resets recovery when deriveState returns a differe
|
|
|
1318
1327
|
s.active = false;
|
|
1319
1328
|
},
|
|
1320
1329
|
postUnitPostVerification: async () => {
|
|
1330
|
+
postVerCallCount++;
|
|
1321
1331
|
deps.callLog.push("postUnitPostVerification");
|
|
1322
|
-
//
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
}
|
|
1332
|
+
// Exit on the 4th call (after T02 unit completes)
|
|
1333
|
+
const shouldExit = postVerCallCount >= 4;
|
|
1334
|
+
s.active = !shouldExit;
|
|
1326
1335
|
return "continue" as const;
|
|
1327
1336
|
},
|
|
1328
1337
|
});
|
|
@@ -1361,6 +1370,14 @@ test("stuck detection: does not push to window during verification retry", async
|
|
|
1361
1370
|
let verifyCallCount = 0;
|
|
1362
1371
|
let stopReason = "";
|
|
1363
1372
|
|
|
1373
|
+
// Pre-queued responses: 3 retries then a continue (exit)
|
|
1374
|
+
const verifyActions: Array<() => "retry" | "continue"> = [
|
|
1375
|
+
() => { s.pendingVerificationRetry = { unitId: "M001/S01/T01", failureContext: "test failed", attempt: 1 }; return "retry"; },
|
|
1376
|
+
() => { s.pendingVerificationRetry = { unitId: "M001/S01/T01", failureContext: "test failed", attempt: 2 }; return "retry"; },
|
|
1377
|
+
() => { s.pendingVerificationRetry = { unitId: "M001/S01/T01", failureContext: "test failed", attempt: 3 }; return "retry"; },
|
|
1378
|
+
() => { s.active = false; return "continue"; },
|
|
1379
|
+
];
|
|
1380
|
+
|
|
1364
1381
|
const deps = makeMockDeps({
|
|
1365
1382
|
deriveState: async () =>
|
|
1366
1383
|
({
|
|
@@ -1378,20 +1395,10 @@ test("stuck detection: does not push to window during verification retry", async
|
|
|
1378
1395
|
prompt: "do the thing",
|
|
1379
1396
|
}),
|
|
1380
1397
|
runPostUnitVerification: async () => {
|
|
1398
|
+
const action = verifyActions[verifyCallCount] ?? (() => { s.active = false; return "continue" as const; });
|
|
1381
1399
|
verifyCallCount++;
|
|
1382
1400
|
deps.callLog.push("runPostUnitVerification");
|
|
1383
|
-
|
|
1384
|
-
// Set pendingVerificationRetry — should prevent stuck counter increment
|
|
1385
|
-
s.pendingVerificationRetry = {
|
|
1386
|
-
unitId: "M001/S01/T01",
|
|
1387
|
-
failureContext: "test failed",
|
|
1388
|
-
attempt: verifyCallCount,
|
|
1389
|
-
};
|
|
1390
|
-
return "retry" as const;
|
|
1391
|
-
}
|
|
1392
|
-
// After 3 retries, exit gracefully
|
|
1393
|
-
s.active = false;
|
|
1394
|
-
return "continue" as const;
|
|
1401
|
+
return action();
|
|
1395
1402
|
},
|
|
1396
1403
|
stopAuto: async (_ctx?: any, _pi?: any, reason?: string) => {
|
|
1397
1404
|
deps.callLog.push("stopAuto");
|
|
@@ -1543,7 +1550,7 @@ test("autoLoop lifecycle: advances through research → plan → execute → ver
|
|
|
1543
1550
|
const dispatchedUnitTypes: string[] = [];
|
|
1544
1551
|
|
|
1545
1552
|
// Phase sequence: each deriveState call returns a different phase.
|
|
1546
|
-
//
|
|
1553
|
+
// The 6th entry (index 5) is the terminal "complete" phase that stops the loop.
|
|
1547
1554
|
const phases = [
|
|
1548
1555
|
// Call 1: researching → dispatches research-slice
|
|
1549
1556
|
{
|
|
@@ -1575,6 +1582,12 @@ test("autoLoop lifecycle: advances through research → plan → execute → ver
|
|
|
1575
1582
|
activeSlice: { id: "S01", title: "Complete Slice" },
|
|
1576
1583
|
activeTask: null,
|
|
1577
1584
|
},
|
|
1585
|
+
// Call 6: terminal — deactivate to exit the loop
|
|
1586
|
+
{
|
|
1587
|
+
phase: "complete",
|
|
1588
|
+
activeSlice: null,
|
|
1589
|
+
activeTask: null,
|
|
1590
|
+
},
|
|
1578
1591
|
];
|
|
1579
1592
|
|
|
1580
1593
|
const dispatches = [
|
|
@@ -1587,46 +1600,26 @@ test("autoLoop lifecycle: advances through research → plan → execute → ver
|
|
|
1587
1600
|
|
|
1588
1601
|
const deps = makeMockDeps({
|
|
1589
1602
|
deriveState: async () => {
|
|
1603
|
+
const p = phases[Math.min(deriveCallCount, phases.length - 1)];
|
|
1590
1604
|
deriveCallCount++;
|
|
1591
1605
|
deps.callLog.push("deriveState");
|
|
1592
1606
|
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
return {
|
|
1597
|
-
phase: "complete",
|
|
1598
|
-
activeMilestone: { id: "M001", title: "Test", status: "complete" },
|
|
1599
|
-
activeSlice: null,
|
|
1600
|
-
activeTask: null,
|
|
1601
|
-
registry: [{ id: "M001", status: "complete" }],
|
|
1602
|
-
blockers: [],
|
|
1603
|
-
} as any;
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
const p = phases[deriveCallCount - 1];
|
|
1607
|
+
const terminalPhases: Record<string, string> = { complete: "complete" };
|
|
1608
|
+
s.active = p.phase !== "complete";
|
|
1609
|
+
const milestoneStatus = terminalPhases[p.phase] ?? "active";
|
|
1607
1610
|
return {
|
|
1608
1611
|
phase: p.phase,
|
|
1609
|
-
activeMilestone: { id: "M001", title: "Test", status:
|
|
1610
|
-
activeSlice: p.activeSlice,
|
|
1611
|
-
activeTask: p.activeTask,
|
|
1612
|
-
registry: [{ id: "M001", status:
|
|
1612
|
+
activeMilestone: { id: "M001", title: "Test", status: milestoneStatus },
|
|
1613
|
+
activeSlice: p.activeSlice ?? null,
|
|
1614
|
+
activeTask: p.activeTask ?? null,
|
|
1615
|
+
registry: [{ id: "M001", status: milestoneStatus }],
|
|
1613
1616
|
blockers: [],
|
|
1614
1617
|
} as any;
|
|
1615
1618
|
},
|
|
1616
1619
|
resolveDispatch: async () => {
|
|
1620
|
+
const d = dispatches[Math.min(dispatchCallCount, dispatches.length - 1)];
|
|
1617
1621
|
dispatchCallCount++;
|
|
1618
1622
|
deps.callLog.push("resolveDispatch");
|
|
1619
|
-
|
|
1620
|
-
if (dispatchCallCount > dispatches.length) {
|
|
1621
|
-
// Safety: shouldn't reach here, but stop if it does
|
|
1622
|
-
return {
|
|
1623
|
-
action: "stop" as const,
|
|
1624
|
-
reason: "done",
|
|
1625
|
-
level: "info" as const,
|
|
1626
|
-
};
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
const d = dispatches[dispatchCallCount - 1];
|
|
1630
1623
|
dispatchedUnitTypes.push(d.unitType);
|
|
1631
1624
|
return {
|
|
1632
1625
|
action: "dispatch" as const,
|
|
@@ -1691,18 +1684,11 @@ test("autoLoop lifecycle: advances through research → plan → execute → ver
|
|
|
1691
1684
|
`callLog should have at least 5 resolveDispatch entries (got ${dispatchEntries.length})`,
|
|
1692
1685
|
);
|
|
1693
1686
|
|
|
1694
|
-
// Verify interleaving:
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
if (entry === "deriveState" && dispatchSeen > 0) {
|
|
1701
|
-
// A deriveState after a resolveDispatch confirms the loop advanced
|
|
1702
|
-
break;
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
assert.ok(dispatchSeen > 0, "resolveDispatch should appear in callLog");
|
|
1687
|
+
// Verify interleaving: a deriveState must follow a resolveDispatch (confirms loop advanced)
|
|
1688
|
+
const firstDispatchIdx = deps.callLog.indexOf("resolveDispatch");
|
|
1689
|
+
const firstDeriveAfterDispatch = deps.callLog.indexOf("deriveState", firstDispatchIdx + 1);
|
|
1690
|
+
assert.ok(firstDispatchIdx >= 0, "resolveDispatch should appear in callLog");
|
|
1691
|
+
assert.ok(firstDeriveAfterDispatch > firstDispatchIdx, "deriveState should follow resolveDispatch to confirm loop advanced");
|
|
1706
1692
|
|
|
1707
1693
|
// Assert the exact sequence of dispatched unit types
|
|
1708
1694
|
assert.deepEqual(
|
|
@@ -1775,6 +1761,8 @@ test("autoLoop re-iterates when postUnitPreVerification returns retry (#1571)",
|
|
|
1775
1761
|
const s = makeLoopSession();
|
|
1776
1762
|
|
|
1777
1763
|
let preVerifyCallCount = 0;
|
|
1764
|
+
// Pre-queued responses: first call returns "retry", second returns "continue"
|
|
1765
|
+
const preVerifyResponses = ["retry", "continue"] as const;
|
|
1778
1766
|
|
|
1779
1767
|
const deps = makeMockDeps({
|
|
1780
1768
|
deriveState: async () => {
|
|
@@ -1790,11 +1778,7 @@ test("autoLoop re-iterates when postUnitPreVerification returns retry (#1571)",
|
|
|
1790
1778
|
},
|
|
1791
1779
|
postUnitPreVerification: async () => {
|
|
1792
1780
|
deps.callLog.push("postUnitPreVerification");
|
|
1793
|
-
preVerifyCallCount
|
|
1794
|
-
if (preVerifyCallCount === 1) {
|
|
1795
|
-
return "retry" as const;
|
|
1796
|
-
}
|
|
1797
|
-
return "continue" as const;
|
|
1781
|
+
return preVerifyResponses[preVerifyCallCount++] ?? "continue";
|
|
1798
1782
|
},
|
|
1799
1783
|
postUnitPostVerification: async () => {
|
|
1800
1784
|
deps.callLog.push("postUnitPostVerification");
|
|
@@ -1907,9 +1891,8 @@ test("autoLoop rejects execute-task with 0 tool calls as hallucinated (#1833)",
|
|
|
1907
1891
|
postUnitPostVerification: async () => {
|
|
1908
1892
|
deps.callLog.push("postUnitPostVerification");
|
|
1909
1893
|
iterationCount++;
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
}
|
|
1894
|
+
// Deactivate after 2nd iteration
|
|
1895
|
+
s.active = iterationCount < 2;
|
|
1913
1896
|
return "continue" as const;
|
|
1914
1897
|
},
|
|
1915
1898
|
});
|
|
@@ -2122,7 +2105,7 @@ test("autoLoop stops when worktree has no project files for execute-task (#1833)
|
|
|
2122
2105
|
"should stop auto-mode when worktree has no project files",
|
|
2123
2106
|
);
|
|
2124
2107
|
const healthNotification = notifications.find(
|
|
2125
|
-
(n) => n.includes("Worktree health check failed") && n.includes("no
|
|
2108
|
+
(n) => n.includes("Worktree health check failed") && n.includes("no recognized project files"),
|
|
2126
2109
|
);
|
|
2127
2110
|
assert.ok(
|
|
2128
2111
|
healthNotification,
|