gsd-pi 2.68.1-dev.362687a → 2.68.1-dev.abc8f2b
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/gsd/auto-model-selection.js +27 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +7 -0
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +1 -5
- package/dist/resources/extensions/gsd/guided-flow.js +25 -70
- package/dist/resources/extensions/gsd/model-router.js +85 -2
- package/dist/resources/extensions/gsd/prompts/discuss.md +2 -0
- package/dist/resources/extensions/gsd/templates/context.md +34 -2
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
- 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 +13 -13
- 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 +1 -1
- package/packages/pi-ai/dist/index.d.ts +3 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +2 -0
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/providers/amazon-bedrock.js +2 -2
- package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +2 -2
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js +2 -2
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/mistral.js +2 -2
- package/packages/pi-ai/dist/providers/mistral.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +2 -2
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses-shared.js +2 -2
- package/packages/pi-ai/dist/providers/openai-responses-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/provider-capabilities.d.ts +59 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.js +173 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.js.map +1 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.js +132 -0
- package/packages/pi-ai/dist/providers/provider-capabilities.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.js +172 -0
- package/packages/pi-ai/dist/providers/transform-messages-report.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages.d.ts +34 -1
- package/packages/pi-ai/dist/providers/transform-messages.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/transform-messages.js +73 -2
- package/packages/pi-ai/dist/providers/transform-messages.js.map +1 -1
- package/packages/pi-ai/src/index.ts +3 -0
- package/packages/pi-ai/src/providers/amazon-bedrock.ts +2 -2
- package/packages/pi-ai/src/providers/anthropic-shared.ts +2 -2
- package/packages/pi-ai/src/providers/google-shared.ts +2 -2
- package/packages/pi-ai/src/providers/mistral.ts +2 -2
- package/packages/pi-ai/src/providers/openai-completions.ts +2 -2
- package/packages/pi-ai/src/providers/openai-responses-shared.ts +2 -2
- package/packages/pi-ai/src/providers/provider-capabilities.test.ts +174 -0
- package/packages/pi-ai/src/providers/provider-capabilities.ts +215 -0
- package/packages/pi-ai/src/providers/transform-messages-report.test.ts +189 -0
- package/packages/pi-ai/src/providers/transform-messages.ts +94 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/index.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 +10 -1
- 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 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +15 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +41 -0
- 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/tools/index.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.d.ts +27 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.js +69 -0
- package/packages/pi-coding-agent/dist/core/tools/tool-compatibility-registry.js.map +1 -0
- package/packages/pi-coding-agent/dist/index.d.ts +2 -2
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js +3 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/src/core/extensions/index.ts +4 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +11 -1
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +18 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +45 -0
- package/packages/pi-coding-agent/src/core/tools/index.ts +7 -0
- package/packages/pi-coding-agent/src/core/tools/tool-compatibility-registry.ts +83 -0
- package/packages/pi-coding-agent/src/index.ts +9 -0
- package/src/resources/extensions/gsd/auto-model-selection.ts +36 -4
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +8 -0
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +1 -5
- package/src/resources/extensions/gsd/guided-flow.ts +22 -84
- package/src/resources/extensions/gsd/model-router.ts +117 -10
- package/src/resources/extensions/gsd/preferences-types.ts +3 -1
- package/src/resources/extensions/gsd/prompts/discuss.md +2 -0
- package/src/resources/extensions/gsd/templates/context.md +34 -2
- package/src/resources/extensions/gsd/tests/capability-router.test.ts +31 -7
- package/src/resources/extensions/gsd/tests/model-router.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/tool-compatibility.test.ts +199 -0
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +13 -16
- package/dist/resources/extensions/gsd/prompt-validation.js +0 -67
- package/dist/resources/extensions/gsd/prompts/discuss-prepared.md +0 -424
- package/dist/resources/extensions/gsd/templates/context-enhanced.md +0 -138
- package/src/resources/extensions/gsd/prompt-validation.ts +0 -88
- package/src/resources/extensions/gsd/prompts/discuss-prepared.md +0 -424
- package/src/resources/extensions/gsd/templates/context-enhanced.md +0 -138
- package/src/resources/extensions/gsd/tests/adversarial-review-fixes.test.ts +0 -223
- package/src/resources/extensions/gsd/tests/integration/test-isolation.ts +0 -53
- package/src/resources/extensions/gsd/tests/integration-prepared-discussion.test.ts +0 -525
- package/src/resources/extensions/gsd/tests/preparation.test.ts +0 -1211
- package/src/resources/extensions/gsd/tests/prompt-builder.test.ts +0 -669
- /package/dist/web/standalone/.next/static/{VkiZZ5UjK7EfSjrWWd5RC → 3HMOXcBoys84RYd2F8a79}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{VkiZZ5UjK7EfSjrWWd5RC → 3HMOXcBoys84RYd2F8a79}/_ssgManifest.js +0 -0
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for adversarial review fixes from PR #3602.
|
|
3
|
-
*
|
|
4
|
-
* These tests verify the fixes for:
|
|
5
|
-
* 1. Cross-session state leak in lastPreparationResult (HIGH)
|
|
6
|
-
* 2. Invalid regex anchor \z in prompt-validation.ts (HIGH)
|
|
7
|
-
* 3. Consecutive error counter in agent-loop.ts (MEDIUM) — UPSTREAM CODE, NOT MODIFIED
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, test, beforeEach, afterEach } from "node:test";
|
|
11
|
-
import assert from "node:assert/strict";
|
|
12
|
-
import { mkdirSync, writeFileSync, rmSync } from "node:fs";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
import { tmpdir } from "node:os";
|
|
15
|
-
|
|
16
|
-
import { getLastPreparationResult, clearPreparationResult } from "../guided-flow.ts";
|
|
17
|
-
import { validateEnhancedContext } from "../prompt-validation.ts";
|
|
18
|
-
|
|
19
|
-
// ─── Test Helpers ───────────────────────────────────────────────────────────────
|
|
20
|
-
|
|
21
|
-
function makeTempDir(prefix: string): string {
|
|
22
|
-
const dir = join(
|
|
23
|
-
tmpdir(),
|
|
24
|
-
`gsd-adversarial-test-${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
25
|
-
);
|
|
26
|
-
mkdirSync(dir, { recursive: true });
|
|
27
|
-
return dir;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function cleanup(dir: string): void {
|
|
31
|
-
try {
|
|
32
|
-
rmSync(dir, { recursive: true, force: true });
|
|
33
|
-
} catch {
|
|
34
|
-
// best-effort
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ─── Fix 1: Cross-session state leak in lastPreparationResult ────────────────────
|
|
39
|
-
|
|
40
|
-
describe("Fix #1 — Cross-session state leak (lastPreparationResult)", () => {
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
clearPreparationResult();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
afterEach(() => {
|
|
46
|
-
clearPreparationResult();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("clearPreparationResult sets lastPreparationResult to null", () => {
|
|
50
|
-
// First, verify the getter returns null after clear
|
|
51
|
-
clearPreparationResult();
|
|
52
|
-
const result = getLastPreparationResult();
|
|
53
|
-
assert.equal(result, null, "lastPreparationResult should be null after clear");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test("getLastPreparationResult returns null initially", () => {
|
|
57
|
-
clearPreparationResult();
|
|
58
|
-
const result = getLastPreparationResult();
|
|
59
|
-
assert.equal(result, null, "should return null when no preparation has run");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Note: The actual test that prepareAndBuildDiscussPrompt clears the result
|
|
63
|
-
// on entry requires mocking ExtensionCommandContext which is complex.
|
|
64
|
-
// The fix is verified by code inspection and integration tests.
|
|
65
|
-
// The key behavior is:
|
|
66
|
-
// 1. lastPreparationResult = null at the start of prepareAndBuildDiscussPrompt
|
|
67
|
-
// 2. If preparation throws, lastPreparationResult stays null
|
|
68
|
-
// 3. If discuss_preparation is false, lastPreparationResult stays null
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// ─── Fix 2: Invalid regex anchor \z in prompt-validation.ts ──────────────────────
|
|
72
|
-
|
|
73
|
-
describe("Fix #2 — Invalid regex anchor (prompt-validation.ts)", () => {
|
|
74
|
-
test("validates content with Architectural Decisions at end of file", () => {
|
|
75
|
-
// This was the bug: \z is PCRE/Ruby, not JS. JS treated it as literal 'z'.
|
|
76
|
-
// The section extraction would fail when Architectural Decisions was the
|
|
77
|
-
// last section (no subsequent ## heading).
|
|
78
|
-
const contentWithDecisionsAtEnd = `
|
|
79
|
-
# M001: Test Milestone
|
|
80
|
-
|
|
81
|
-
## Why This Milestone
|
|
82
|
-
|
|
83
|
-
This is why.
|
|
84
|
-
|
|
85
|
-
## Acceptance Criteria
|
|
86
|
-
|
|
87
|
-
- Criterion 1
|
|
88
|
-
|
|
89
|
-
## Architectural Decisions
|
|
90
|
-
|
|
91
|
-
### Decision 1
|
|
92
|
-
|
|
93
|
-
**Decision:** Use TypeScript
|
|
94
|
-
**Rationale:** Type safety
|
|
95
|
-
`;
|
|
96
|
-
|
|
97
|
-
const result = validateEnhancedContext(contentWithDecisionsAtEnd);
|
|
98
|
-
assert.equal(result.valid, true, "should validate content with decisions at end");
|
|
99
|
-
assert.equal(result.missing.length, 0, "should have no missing sections");
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test("validates content with Architectural Decisions followed by another section", () => {
|
|
103
|
-
const contentWithDecisionsInMiddle = `
|
|
104
|
-
# M001: Test Milestone
|
|
105
|
-
|
|
106
|
-
## Why This Milestone
|
|
107
|
-
|
|
108
|
-
This is why.
|
|
109
|
-
|
|
110
|
-
## Architectural Decisions
|
|
111
|
-
|
|
112
|
-
### Decision 1
|
|
113
|
-
|
|
114
|
-
**Decision:** Use TypeScript
|
|
115
|
-
|
|
116
|
-
## Acceptance Criteria
|
|
117
|
-
|
|
118
|
-
- Criterion 1
|
|
119
|
-
`;
|
|
120
|
-
|
|
121
|
-
const result = validateEnhancedContext(contentWithDecisionsInMiddle);
|
|
122
|
-
assert.equal(result.valid, true, "should validate content with decisions in middle");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("detects missing decision entry when section is empty", () => {
|
|
126
|
-
const contentEmptyDecisions = `
|
|
127
|
-
# M001: Test Milestone
|
|
128
|
-
|
|
129
|
-
## Why This Milestone
|
|
130
|
-
|
|
131
|
-
This is why.
|
|
132
|
-
|
|
133
|
-
## Architectural Decisions
|
|
134
|
-
|
|
135
|
-
(No decisions yet)
|
|
136
|
-
|
|
137
|
-
## Acceptance Criteria
|
|
138
|
-
|
|
139
|
-
- Criterion 1
|
|
140
|
-
`;
|
|
141
|
-
|
|
142
|
-
const result = validateEnhancedContext(contentEmptyDecisions);
|
|
143
|
-
assert.equal(result.valid, false, "should fail when decisions section has no entries");
|
|
144
|
-
assert.ok(
|
|
145
|
-
result.missing.some((m) => m.includes("decision entry")),
|
|
146
|
-
"should report missing decision entry",
|
|
147
|
-
);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test("accepts inline **Decision format", () => {
|
|
151
|
-
const contentInlineDecision = `
|
|
152
|
-
## Why This Milestone
|
|
153
|
-
|
|
154
|
-
Test
|
|
155
|
-
|
|
156
|
-
## Architectural Decisions
|
|
157
|
-
|
|
158
|
-
**Decision:** Use React
|
|
159
|
-
|
|
160
|
-
## Acceptance Criteria
|
|
161
|
-
|
|
162
|
-
- Criterion 1
|
|
163
|
-
`;
|
|
164
|
-
|
|
165
|
-
const result = validateEnhancedContext(contentInlineDecision);
|
|
166
|
-
assert.equal(result.valid, true, "should accept **Decision format");
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test("accepts ### subsection format", () => {
|
|
170
|
-
const contentSubsectionDecision = `
|
|
171
|
-
## Why This Milestone
|
|
172
|
-
|
|
173
|
-
Test
|
|
174
|
-
|
|
175
|
-
## Architectural Decisions
|
|
176
|
-
|
|
177
|
-
### Database Choice
|
|
178
|
-
|
|
179
|
-
We chose SQLite.
|
|
180
|
-
|
|
181
|
-
## Acceptance Criteria
|
|
182
|
-
|
|
183
|
-
- Criterion 1
|
|
184
|
-
`;
|
|
185
|
-
|
|
186
|
-
const result = validateEnhancedContext(contentSubsectionDecision);
|
|
187
|
-
assert.equal(result.valid, true, "should accept ### subsection format");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
test("handles edge case: Architectural Decisions heading without space before content", () => {
|
|
191
|
-
const contentNoSpace = `## Why This Milestone
|
|
192
|
-
Test
|
|
193
|
-
## Architectural Decisions
|
|
194
|
-
### Decision 1
|
|
195
|
-
Content here
|
|
196
|
-
## Acceptance Criteria
|
|
197
|
-
- Done`;
|
|
198
|
-
|
|
199
|
-
const result = validateEnhancedContext(contentNoSpace);
|
|
200
|
-
assert.equal(result.valid, true, "should handle content without extra spacing");
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// ─── Fix 3: Consecutive error counter (agent-loop.ts) ────────────────────────────
|
|
205
|
-
|
|
206
|
-
describe("Fix #3 — Consecutive error counter (UPSTREAM)", () => {
|
|
207
|
-
test("NOTE: agent-loop.ts is upstream code that was not modified", () => {
|
|
208
|
-
// This finding from the adversarial review relates to upstream behavior
|
|
209
|
-
// in packages/pi-agent-core/src/agent-loop.ts.
|
|
210
|
-
//
|
|
211
|
-
// The consecutiveAllToolErrorTurns counter logic was added in PR #3301
|
|
212
|
-
// and refined in PR #3618 by upstream contributors. These PRs fix
|
|
213
|
-
// issues with:
|
|
214
|
-
// - Schema overload detection counting bash exit codes as failures
|
|
215
|
-
// - The counter not resetting properly on successful turns
|
|
216
|
-
//
|
|
217
|
-
// Since this is upstream code (part of pi-agent-core, not gsd extension),
|
|
218
|
-
// we do not modify it here. The fix should be coordinated with upstream.
|
|
219
|
-
//
|
|
220
|
-
// See: packages/pi-agent-core/src/agent-loop.ts lines 191, 298-325
|
|
221
|
-
assert.ok(true, "Documented as upstream behavior — no changes made");
|
|
222
|
-
});
|
|
223
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test isolation utilities for integration tests.
|
|
3
|
-
*
|
|
4
|
-
* Integration tests often call `mergeMilestoneToMain` and other functions that
|
|
5
|
-
* load preferences. If the user's global ~/.gsd/preferences.md has
|
|
6
|
-
* `git.main_branch: master`, tests fail because test repos use `main`.
|
|
7
|
-
*
|
|
8
|
-
* These utilities isolate tests from the user's global environment.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { mkdtempSync, rmSync, realpathSync } from "node:fs";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
|
|
15
|
-
import { _resetServiceCache } from "../../worktree.ts";
|
|
16
|
-
import { _clearGsdRootCache } from "../../paths.ts";
|
|
17
|
-
|
|
18
|
-
let originalHome: string | undefined;
|
|
19
|
-
let fakeHome: string | null = null;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Isolate the test environment from user's global preferences.
|
|
23
|
-
* Creates a fake HOME directory so loadEffectiveGSDPreferences() returns
|
|
24
|
-
* empty global preferences instead of the user's ~/.gsd/preferences.md.
|
|
25
|
-
*
|
|
26
|
-
* Call this in a test.before() hook.
|
|
27
|
-
*/
|
|
28
|
-
export function isolateFromGlobalPreferences(): void {
|
|
29
|
-
originalHome = process.env.HOME;
|
|
30
|
-
fakeHome = realpathSync(mkdtempSync(join(tmpdir(), "gsd-test-home-")));
|
|
31
|
-
process.env.HOME = fakeHome;
|
|
32
|
-
_clearGsdRootCache();
|
|
33
|
-
_resetServiceCache();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Restore the original HOME and clean up the fake home directory.
|
|
38
|
-
*
|
|
39
|
-
* Call this in a test.after() hook.
|
|
40
|
-
*/
|
|
41
|
-
export function restoreGlobalPreferences(): void {
|
|
42
|
-
if (originalHome !== undefined) {
|
|
43
|
-
process.env.HOME = originalHome;
|
|
44
|
-
} else {
|
|
45
|
-
delete process.env.HOME;
|
|
46
|
-
}
|
|
47
|
-
_clearGsdRootCache();
|
|
48
|
-
_resetServiceCache();
|
|
49
|
-
if (fakeHome) {
|
|
50
|
-
rmSync(fakeHome, { recursive: true, force: true });
|
|
51
|
-
fakeHome = null;
|
|
52
|
-
}
|
|
53
|
-
}
|