gsd-pi 2.73.0-dev.e1c09f2 → 2.73.1-dev.6ddfa43
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/dist/resources/extensions/claude-code-cli/stream-adapter.js +9 -3
- package/dist/resources/extensions/gsd/auto-model-selection.js +54 -11
- package/dist/resources/extensions/gsd/auto-start.js +20 -6
- package/dist/resources/extensions/gsd/auto.js +5 -1
- package/dist/resources/extensions/gsd/bootstrap/crash-log.js +31 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +18 -7
- package/dist/resources/extensions/gsd/crash-recovery.js +51 -0
- package/dist/resources/extensions/gsd/gsd-db.js +36 -2
- package/dist/resources/extensions/gsd/milestone-actions.js +19 -1
- package/dist/resources/extensions/gsd/preferences-models.js +43 -0
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +22 -0
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +10 -10
- 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 +10 -10
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- 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 +1 -1
- package/packages/pi-ai/dist/index.d.ts +1 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +1 -0
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/src/index.ts +4 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +175 -8
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +12 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +51 -26
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +73 -12
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +198 -8
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +62 -26
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +92 -17
- package/pkg/package.json +1 -1
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +12 -4
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +23 -2
- package/src/resources/extensions/gsd/auto-model-selection.ts +85 -11
- package/src/resources/extensions/gsd/auto-start.ts +27 -6
- package/src/resources/extensions/gsd/auto.ts +5 -0
- package/src/resources/extensions/gsd/bootstrap/crash-log.ts +32 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +19 -7
- package/src/resources/extensions/gsd/crash-recovery.ts +59 -0
- package/src/resources/extensions/gsd/gsd-db.ts +52 -2
- package/src/resources/extensions/gsd/milestone-actions.ts +19 -1
- package/src/resources/extensions/gsd/preferences-models.ts +41 -0
- package/src/resources/extensions/gsd/preferences-types.ts +12 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +23 -0
- package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +51 -2
- package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +235 -0
- package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +137 -1
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +59 -1
- package/src/resources/extensions/gsd/tests/model-isolation.test.ts +91 -2
- package/src/resources/extensions/gsd/tests/park-milestone.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +47 -0
- /package/dist/web/standalone/.next/static/{_XD_gUDcZNBbWV5rI8RgS → r6AvNu-aMwn4nwqjHqAfw}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{_XD_gUDcZNBbWV5rI8RgS → r6AvNu-aMwn4nwqjHqAfw}/_ssgManifest.js +0 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { describe, test } from "node:test";
|
|
8
8
|
import assert from "node:assert/strict";
|
|
9
|
-
import { isFlatRateProvider, resolvePreferredModelConfig } from "../auto-model-selection.ts";
|
|
9
|
+
import { buildFlatRateContext, isFlatRateProvider, resolvePreferredModelConfig } from "../auto-model-selection.ts";
|
|
10
10
|
|
|
11
11
|
describe("flat-rate provider routing guard (#3453)", () => {
|
|
12
12
|
|
|
@@ -48,3 +48,139 @@ describe("flat-rate provider routing guard (#3453)", () => {
|
|
|
48
48
|
assert.equal(result, undefined, "Should not create routing config for copilot");
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
|
+
|
|
52
|
+
describe("flat-rate provider extensibility (any/all/custom)", () => {
|
|
53
|
+
test("regression: built-in providers still flat-rate with no context", () => {
|
|
54
|
+
assert.equal(isFlatRateProvider("github-copilot"), true);
|
|
55
|
+
assert.equal(isFlatRateProvider("copilot"), true);
|
|
56
|
+
assert.equal(isFlatRateProvider("claude-code"), true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("regression: non-flat-rate API providers return false with no context", () => {
|
|
60
|
+
assert.equal(isFlatRateProvider("anthropic"), false);
|
|
61
|
+
assert.equal(isFlatRateProvider("openai"), false);
|
|
62
|
+
assert.equal(isFlatRateProvider("google-vertex"), false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("auto-detection: externalCli auth mode marks provider flat-rate", () => {
|
|
66
|
+
// Any provider registered with authMode: "externalCli" is a local
|
|
67
|
+
// CLI wrapper around the user's subscription — every request costs
|
|
68
|
+
// the same regardless of model, so dynamic routing provides no benefit.
|
|
69
|
+
assert.equal(
|
|
70
|
+
isFlatRateProvider("my-private-cli", { authMode: "externalCli" }),
|
|
71
|
+
true,
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("auto-detection: non-externalCli auth modes do not mark provider flat-rate", () => {
|
|
76
|
+
assert.equal(
|
|
77
|
+
isFlatRateProvider("my-http-proxy", { authMode: "apiKey" }),
|
|
78
|
+
false,
|
|
79
|
+
);
|
|
80
|
+
assert.equal(
|
|
81
|
+
isFlatRateProvider("my-http-proxy", { authMode: "oauth" }),
|
|
82
|
+
false,
|
|
83
|
+
);
|
|
84
|
+
assert.equal(
|
|
85
|
+
isFlatRateProvider("my-http-proxy", { authMode: "none" }),
|
|
86
|
+
false,
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("user preference: custom provider listed in userFlatRate is flat-rate", () => {
|
|
91
|
+
assert.equal(
|
|
92
|
+
isFlatRateProvider("my-ollama-proxy", { userFlatRate: ["my-ollama-proxy"] }),
|
|
93
|
+
true,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("user preference: case-insensitive match against userFlatRate list", () => {
|
|
98
|
+
assert.equal(
|
|
99
|
+
isFlatRateProvider("My-Proxy", { userFlatRate: ["my-proxy"] }),
|
|
100
|
+
true,
|
|
101
|
+
);
|
|
102
|
+
assert.equal(
|
|
103
|
+
isFlatRateProvider("my-proxy", { userFlatRate: ["MY-PROXY"] }),
|
|
104
|
+
true,
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("user preference: provider not in userFlatRate list is not flat-rate", () => {
|
|
109
|
+
assert.equal(
|
|
110
|
+
isFlatRateProvider("other-proxy", { userFlatRate: ["my-proxy"] }),
|
|
111
|
+
false,
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("combined signals: built-in list wins even when context is empty", () => {
|
|
116
|
+
assert.equal(
|
|
117
|
+
isFlatRateProvider("claude-code", { authMode: "apiKey", userFlatRate: [] }),
|
|
118
|
+
true,
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("combined signals: externalCli auto-detection wins alongside userFlatRate miss", () => {
|
|
123
|
+
assert.equal(
|
|
124
|
+
isFlatRateProvider("my-cli", {
|
|
125
|
+
authMode: "externalCli",
|
|
126
|
+
userFlatRate: ["a-different-cli"],
|
|
127
|
+
}),
|
|
128
|
+
true,
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe("buildFlatRateContext()", () => {
|
|
134
|
+
test("builds a context from ctx.modelRegistry.getProviderAuthMode + prefs", () => {
|
|
135
|
+
const ctx = {
|
|
136
|
+
modelRegistry: {
|
|
137
|
+
getProviderAuthMode: (p: string) =>
|
|
138
|
+
p === "my-cli" ? "externalCli" : "apiKey",
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
const prefs = { flat_rate_providers: ["my-proxy"] };
|
|
142
|
+
|
|
143
|
+
const ctxForCli = buildFlatRateContext("my-cli", ctx, prefs);
|
|
144
|
+
assert.equal(ctxForCli.authMode, "externalCli");
|
|
145
|
+
assert.deepEqual(ctxForCli.userFlatRate, ["my-proxy"]);
|
|
146
|
+
assert.equal(isFlatRateProvider("my-cli", ctxForCli), true);
|
|
147
|
+
|
|
148
|
+
const ctxForProxy = buildFlatRateContext("my-proxy", ctx, prefs);
|
|
149
|
+
assert.equal(ctxForProxy.authMode, "apiKey");
|
|
150
|
+
assert.equal(isFlatRateProvider("my-proxy", ctxForProxy), true);
|
|
151
|
+
|
|
152
|
+
const ctxForOther = buildFlatRateContext("anthropic", ctx, prefs);
|
|
153
|
+
assert.equal(ctxForOther.authMode, "apiKey");
|
|
154
|
+
assert.equal(isFlatRateProvider("anthropic", ctxForOther), false);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("survives missing ctx and missing prefs", () => {
|
|
158
|
+
const empty = buildFlatRateContext("anything");
|
|
159
|
+
assert.equal(empty.authMode, undefined);
|
|
160
|
+
assert.equal(empty.userFlatRate, undefined);
|
|
161
|
+
assert.equal(isFlatRateProvider("anything", empty), false);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test("survives a registry lookup that throws", () => {
|
|
165
|
+
const ctx = {
|
|
166
|
+
modelRegistry: {
|
|
167
|
+
getProviderAuthMode: () => {
|
|
168
|
+
throw new Error("registry boom");
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
const result = buildFlatRateContext("anything", ctx);
|
|
173
|
+
// Error must be swallowed — authMode left undefined, function returns.
|
|
174
|
+
assert.equal(result.authMode, undefined);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("registry returning a non-canonical auth mode is ignored", () => {
|
|
178
|
+
const ctx = {
|
|
179
|
+
modelRegistry: {
|
|
180
|
+
getProviderAuthMode: () => "weird-mode",
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
const result = buildFlatRateContext("anything", ctx);
|
|
184
|
+
assert.equal(result.authMode, undefined);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -15,10 +15,14 @@ import {
|
|
|
15
15
|
getRequirementById,
|
|
16
16
|
getActiveDecisions,
|
|
17
17
|
getActiveRequirements,
|
|
18
|
-
getTask,
|
|
19
18
|
transaction,
|
|
20
19
|
_getAdapter,
|
|
21
20
|
_resetProvider,
|
|
21
|
+
insertMilestone,
|
|
22
|
+
insertSlice,
|
|
23
|
+
insertTask,
|
|
24
|
+
getTask,
|
|
25
|
+
getSliceTasks,
|
|
22
26
|
} from '../gsd-db.ts';
|
|
23
27
|
|
|
24
28
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -460,6 +464,60 @@ describe('gsd-db', () => {
|
|
|
460
464
|
assert.ok(!wasDbOpenAttempted(), 'wasDbOpenAttempted should reset after closeDatabase');
|
|
461
465
|
});
|
|
462
466
|
|
|
467
|
+
test('gsd-db: rowToTask tolerates corrupt comma-separated task arrays', () => {
|
|
468
|
+
openDatabase(':memory:');
|
|
469
|
+
insertMilestone({ id: 'M001', status: 'active' });
|
|
470
|
+
insertSlice({ milestoneId: 'M001', id: 'S01', status: 'active' });
|
|
471
|
+
insertTask({
|
|
472
|
+
milestoneId: 'M001',
|
|
473
|
+
sliceId: 'S01',
|
|
474
|
+
id: 'T01',
|
|
475
|
+
title: 'Recover corrupt arrays',
|
|
476
|
+
planning: {
|
|
477
|
+
description: 'desc',
|
|
478
|
+
estimate: 'small',
|
|
479
|
+
files: ['src/original.ts'],
|
|
480
|
+
verify: 'npm test',
|
|
481
|
+
inputs: ['docs/original.md'],
|
|
482
|
+
expectedOutput: ['dist/original.md'],
|
|
483
|
+
observabilityImpact: '',
|
|
484
|
+
},
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
const adapter = _getAdapter()!;
|
|
488
|
+
adapter.prepare(
|
|
489
|
+
`UPDATE tasks
|
|
490
|
+
SET files = ?, inputs = ?, expected_output = ?, key_files = ?, key_decisions = ?
|
|
491
|
+
WHERE milestone_id = ? AND slice_id = ? AND id = ?`,
|
|
492
|
+
).run(
|
|
493
|
+
'src-erf/Models/foo.cs, src-erf/Models/bar.cs',
|
|
494
|
+
'docs/input-a.md, docs/input-b.md',
|
|
495
|
+
'dist/out-a.md, dist/out-b.md',
|
|
496
|
+
'src/resources/extensions/gsd/gsd-db.ts, src/resources/extensions/gsd/state.ts',
|
|
497
|
+
'"decision-1"',
|
|
498
|
+
'M001',
|
|
499
|
+
'S01',
|
|
500
|
+
'T01',
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
const task = getTask('M001', 'S01', 'T01');
|
|
504
|
+
assert.ok(task, 'getTask should still return the corrupt row');
|
|
505
|
+
assert.deepStrictEqual(task!.files, ['src-erf/Models/foo.cs', 'src-erf/Models/bar.cs']);
|
|
506
|
+
assert.deepStrictEqual(task!.inputs, ['docs/input-a.md', 'docs/input-b.md']);
|
|
507
|
+
assert.deepStrictEqual(task!.expected_output, ['dist/out-a.md', 'dist/out-b.md']);
|
|
508
|
+
assert.deepStrictEqual(
|
|
509
|
+
task!.key_files,
|
|
510
|
+
['src/resources/extensions/gsd/gsd-db.ts', 'src/resources/extensions/gsd/state.ts'],
|
|
511
|
+
);
|
|
512
|
+
assert.deepStrictEqual(task!.key_decisions, ['decision-1']);
|
|
513
|
+
|
|
514
|
+
const sliceTasks = getSliceTasks('M001', 'S01');
|
|
515
|
+
assert.equal(sliceTasks.length, 1, 'getSliceTasks should also survive corrupt rows');
|
|
516
|
+
assert.deepStrictEqual(sliceTasks[0]!.files, task!.files);
|
|
517
|
+
|
|
518
|
+
closeDatabase();
|
|
519
|
+
});
|
|
520
|
+
|
|
463
521
|
// ─── Final Report ──────────────────────────────────────────────────────────
|
|
464
522
|
|
|
465
523
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tests for model config isolation between concurrent instances (#650, #1065)
|
|
3
|
-
*
|
|
2
|
+
* Tests for model config isolation between concurrent instances (#650, #1065),
|
|
3
|
+
* session-scoped model precedence behavior including manual session override,
|
|
4
|
+
* GSD preferences override of settings.json defaults (#3517), and custom
|
|
5
|
+
* provider precedence over PREFERENCES.md when set via `/gsd model` (#4122).
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
import { describe, it, beforeEach, afterEach } from "node:test";
|
|
@@ -214,3 +216,90 @@ describe("manual session model override precedence", () => {
|
|
|
214
216
|
"should be null when no model source is available");
|
|
215
217
|
});
|
|
216
218
|
});
|
|
219
|
+
|
|
220
|
+
// ─── Custom provider session model wins over PREFERENCES.md (#4122) ─────────
|
|
221
|
+
|
|
222
|
+
describe("custom provider session model overrides PREFERENCES.md (#4122)", () => {
|
|
223
|
+
// Mirrors the auto-start.ts logic:
|
|
224
|
+
// sessionProviderIsCustom && ctx.model
|
|
225
|
+
// ? ctx.model
|
|
226
|
+
// : (preferredModel ?? ctx.model ?? null)
|
|
227
|
+
function selectStartModel(args: {
|
|
228
|
+
ctxModel: { provider: string; id: string } | null;
|
|
229
|
+
preferredModel: { provider: string; id: string } | undefined;
|
|
230
|
+
sessionProviderIsCustom: boolean;
|
|
231
|
+
}): { provider: string; id: string } | null {
|
|
232
|
+
const { ctxModel, preferredModel, sessionProviderIsCustom } = args;
|
|
233
|
+
if (sessionProviderIsCustom && ctxModel) {
|
|
234
|
+
return { provider: ctxModel.provider, id: ctxModel.id };
|
|
235
|
+
}
|
|
236
|
+
return preferredModel
|
|
237
|
+
?? (ctxModel ? { provider: ctxModel.provider, id: ctxModel.id } : null);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
it("custom provider from /gsd model wins over PREFERENCES.md built-in default", () => {
|
|
241
|
+
// User runs `/gsd model ollama/llama3.1:8b`, then `/gsd auto`.
|
|
242
|
+
// PREFERENCES.md still has the project-template claude-code default.
|
|
243
|
+
const ctxModel = { provider: "ollama", id: "llama3.1:8b" };
|
|
244
|
+
const preferredModel = { provider: "claude-code", id: "claude-sonnet-4-6" };
|
|
245
|
+
|
|
246
|
+
const snapshot = selectStartModel({
|
|
247
|
+
ctxModel,
|
|
248
|
+
preferredModel,
|
|
249
|
+
sessionProviderIsCustom: true,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
assert.equal(snapshot?.provider, "ollama",
|
|
253
|
+
"custom-provider session model must win over PREFERENCES.md");
|
|
254
|
+
assert.equal(snapshot?.id, "llama3.1:8b",
|
|
255
|
+
"custom-provider session model id must be preserved");
|
|
256
|
+
assert.notEqual(snapshot?.provider, "claude-code",
|
|
257
|
+
"claude-code from PREFERENCES.md must NOT be selected when session is custom");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("built-in session provider still defers to PREFERENCES.md (#3517 preserved)", () => {
|
|
261
|
+
// ctx.model is a built-in provider (claude-code) but PREFERENCES.md has
|
|
262
|
+
// an explicit openai-codex preference. PREFERENCES.md should still win.
|
|
263
|
+
const ctxModel = { provider: "claude-code", id: "claude-sonnet-4-6" };
|
|
264
|
+
const preferredModel = { provider: "openai-codex", id: "gpt-5.4" };
|
|
265
|
+
|
|
266
|
+
const snapshot = selectStartModel({
|
|
267
|
+
ctxModel,
|
|
268
|
+
preferredModel,
|
|
269
|
+
sessionProviderIsCustom: false,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
assert.equal(snapshot?.provider, "openai-codex",
|
|
273
|
+
"PREFERENCES.md must still win when session provider is built-in");
|
|
274
|
+
assert.equal(snapshot?.id, "gpt-5.4");
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("custom provider with no PREFERENCES.md still uses ctx.model", () => {
|
|
278
|
+
const ctxModel = { provider: "vllm", id: "qwen2.5-coder:32b" };
|
|
279
|
+
|
|
280
|
+
const snapshot = selectStartModel({
|
|
281
|
+
ctxModel,
|
|
282
|
+
preferredModel: undefined,
|
|
283
|
+
sessionProviderIsCustom: true,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
assert.equal(snapshot?.provider, "vllm");
|
|
287
|
+
assert.equal(snapshot?.id, "qwen2.5-coder:32b");
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it("null ctx.model with custom flag falls through to preferredModel", () => {
|
|
291
|
+
// Defensive: sessionProviderIsCustom can only be true if ctx.model exists,
|
|
292
|
+
// but verify the guard works if that invariant is ever broken.
|
|
293
|
+
const preferredModel = { provider: "claude-code", id: "claude-sonnet-4-6" };
|
|
294
|
+
|
|
295
|
+
const snapshot = selectStartModel({
|
|
296
|
+
ctxModel: null,
|
|
297
|
+
preferredModel,
|
|
298
|
+
sessionProviderIsCustom: true,
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
assert.equal(snapshot?.provider, "claude-code",
|
|
302
|
+
"should fall back to preferredModel when ctx.model is null");
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
@@ -3,10 +3,22 @@ import assert from 'node:assert/strict';
|
|
|
3
3
|
import { mkdtempSync, mkdirSync, rmSync, writeFileSync, existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { tmpdir } from 'node:os';
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
6
7
|
|
|
7
8
|
import { deriveState, invalidateStateCache, getActiveMilestoneId } from '../state.ts';
|
|
8
9
|
import { clearPathCache } from '../paths.ts';
|
|
9
10
|
import { parkMilestone, unparkMilestone, discardMilestone, isParked, getParkedReason } from '../milestone-actions.ts';
|
|
11
|
+
import {
|
|
12
|
+
closeDatabase,
|
|
13
|
+
getMilestone,
|
|
14
|
+
getMilestoneSlices,
|
|
15
|
+
getSliceTasks,
|
|
16
|
+
insertMilestone,
|
|
17
|
+
insertSlice,
|
|
18
|
+
insertTask,
|
|
19
|
+
openDatabase,
|
|
20
|
+
} from "../gsd-db.ts";
|
|
21
|
+
import { createWorktree } from "../worktree-manager.ts";
|
|
10
22
|
|
|
11
23
|
|
|
12
24
|
|
|
@@ -60,9 +72,29 @@ function createMilestone(base: string, mid: string, opts?: { withRoadmap?: boole
|
|
|
60
72
|
}
|
|
61
73
|
|
|
62
74
|
function cleanup(base: string): void {
|
|
75
|
+
try {
|
|
76
|
+
closeDatabase();
|
|
77
|
+
} catch {
|
|
78
|
+
// ignore
|
|
79
|
+
}
|
|
63
80
|
rmSync(base, { recursive: true, force: true });
|
|
64
81
|
}
|
|
65
82
|
|
|
83
|
+
function run(cmd: string, cwd: string): string {
|
|
84
|
+
return execSync(cmd, { cwd, stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8" }).trim();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function initGitRepo(base: string): void {
|
|
88
|
+
writeFileSync(join(base, "README.md"), "# test\n", "utf-8");
|
|
89
|
+
writeFileSync(join(base, ".gsd", "STATE.md"), "# State\n", "utf-8");
|
|
90
|
+
run("git init", base);
|
|
91
|
+
run("git config user.email test@test.com", base);
|
|
92
|
+
run("git config user.name Test", base);
|
|
93
|
+
run("git add .", base);
|
|
94
|
+
run('git commit -m "init"', base);
|
|
95
|
+
run("git branch -M main", base);
|
|
96
|
+
}
|
|
97
|
+
|
|
66
98
|
function clearCaches(): void {
|
|
67
99
|
clearPathCache();
|
|
68
100
|
invalidateStateCache();
|
|
@@ -294,6 +326,38 @@ test('discardMilestone updates queue order', () => {
|
|
|
294
326
|
}
|
|
295
327
|
});
|
|
296
328
|
|
|
329
|
+
test('discardMilestone removes DB rows, worktree, and milestone branch', () => {
|
|
330
|
+
const base = createFixtureBase();
|
|
331
|
+
try {
|
|
332
|
+
createMilestone(base, 'M001', { withRoadmap: true });
|
|
333
|
+
initGitRepo(base);
|
|
334
|
+
clearCaches();
|
|
335
|
+
|
|
336
|
+
assert.ok(openDatabase(join(base, '.gsd', 'gsd.db')), 'database opens');
|
|
337
|
+
insertMilestone({ id: 'M001', title: 'Discard me', status: 'active' });
|
|
338
|
+
insertSlice({ milestoneId: 'M001', id: 'S01', title: 'Only slice', status: 'pending' });
|
|
339
|
+
insertTask({ milestoneId: 'M001', sliceId: 'S01', id: 'T01', title: 'Only task', status: 'pending' });
|
|
340
|
+
|
|
341
|
+
const wt = createWorktree(base, 'M001', { branch: 'milestone/M001' });
|
|
342
|
+
assert.ok(existsSync(wt.path), 'worktree exists before discard');
|
|
343
|
+
assert.ok(run('git branch', base).includes('milestone/M001'), 'milestone branch exists before discard');
|
|
344
|
+
assert.ok(getMilestone('M001'), 'milestone exists in DB before discard');
|
|
345
|
+
assert.equal(getMilestoneSlices('M001').length, 1, 'slice exists in DB before discard');
|
|
346
|
+
assert.equal(getSliceTasks('M001', 'S01').length, 1, 'task exists in DB before discard');
|
|
347
|
+
|
|
348
|
+
const success = discardMilestone(base, 'M001');
|
|
349
|
+
assert.ok(success, 'discardMilestone returns true');
|
|
350
|
+
|
|
351
|
+
assert.equal(getMilestone('M001'), null, 'milestone row removed from DB');
|
|
352
|
+
assert.equal(getMilestoneSlices('M001').length, 0, 'slice rows removed from DB');
|
|
353
|
+
assert.equal(getSliceTasks('M001', 'S01').length, 0, 'task rows removed from DB');
|
|
354
|
+
assert.ok(!existsSync(wt.path), 'worktree removed after discard');
|
|
355
|
+
assert.ok(!run('git branch', base).includes('milestone/M001'), 'milestone branch removed after discard');
|
|
356
|
+
} finally {
|
|
357
|
+
cleanup(base);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
297
361
|
// ─── Test 12: All milestones parked → no active milestone ─────────────
|
|
298
362
|
test('All milestones parked → no active', async () => {
|
|
299
363
|
const base = createFixtureBase();
|
|
@@ -134,6 +134,53 @@ test("invalid value types produce errors and fall back to undefined", () => {
|
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
+
test("flat_rate_providers: accepts string array", () => {
|
|
138
|
+
const { errors, preferences } = validatePreferences({
|
|
139
|
+
flat_rate_providers: ["my-proxy", "private-cli"],
|
|
140
|
+
});
|
|
141
|
+
assert.equal(errors.length, 0);
|
|
142
|
+
assert.deepEqual(preferences.flat_rate_providers, ["my-proxy", "private-cli"]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("flat_rate_providers: trims whitespace and drops empty entries", () => {
|
|
146
|
+
const { errors, preferences } = validatePreferences({
|
|
147
|
+
flat_rate_providers: [" my-proxy ", "", " ", "private-cli"],
|
|
148
|
+
});
|
|
149
|
+
assert.equal(errors.length, 0);
|
|
150
|
+
assert.deepEqual(preferences.flat_rate_providers, ["my-proxy", "private-cli"]);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("flat_rate_providers: non-array rejected", () => {
|
|
154
|
+
const { errors } = validatePreferences({
|
|
155
|
+
flat_rate_providers: "my-proxy" as any,
|
|
156
|
+
});
|
|
157
|
+
assert.ok(
|
|
158
|
+
errors.some(e => e.includes("flat_rate_providers")),
|
|
159
|
+
"should error on non-array value",
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("flat_rate_providers: non-string elements rejected", () => {
|
|
164
|
+
const { errors } = validatePreferences({
|
|
165
|
+
flat_rate_providers: ["ok", 123 as any, "also-ok"],
|
|
166
|
+
});
|
|
167
|
+
assert.ok(
|
|
168
|
+
errors.some(e => e.includes("flat_rate_providers")),
|
|
169
|
+
"should error when array contains non-strings",
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("flat_rate_providers is a recognized preference key (no warning)", () => {
|
|
174
|
+
const { warnings } = validatePreferences({
|
|
175
|
+
flat_rate_providers: ["my-proxy"],
|
|
176
|
+
});
|
|
177
|
+
assert.equal(
|
|
178
|
+
warnings.filter(w => w.includes("flat_rate_providers")).length,
|
|
179
|
+
0,
|
|
180
|
+
"flat_rate_providers must be in KNOWN_PREFERENCE_KEYS",
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
137
184
|
test("valid values pass through correctly", () => {
|
|
138
185
|
const { preferences: p1 } = validatePreferences({ budget_enforcement: "halt" });
|
|
139
186
|
assert.equal(p1.budget_enforcement, "halt");
|
|
File without changes
|
|
File without changes
|