@mycadet/assistant 0.12.11 → 0.13.0
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/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/__tests__/ingress.test.ts +2 -2
- package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/ingress.ts +2 -2
- package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/__tests__/ingress.test.ts +2 -2
- package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/ingress.ts +2 -2
- package/node_modules/@mycadet/gateway-client/src/gateway-ipc-contracts.ts +0 -20
- package/node_modules/@mycadet/service-contracts/src/__tests__/ingress.test.ts +2 -2
- package/node_modules/@mycadet/service-contracts/src/ingress.ts +2 -2
- package/openapi.yaml +2 -708
- package/package.json +2 -3
- package/scripts/sync-web-search-catalog.ts +1 -2
- package/src/__tests__/cloud-profile-guard.test.ts +2 -2
- package/src/__tests__/config-schema.test.ts +6 -38
- package/src/__tests__/conversation-queue.test.ts +45 -6
- package/src/__tests__/db-readiness-http-gate.test.ts +0 -6
- package/src/__tests__/persist-onboarding-artifacts.test.ts +0 -1
- package/src/__tests__/persona-resolver.test.ts +0 -51
- package/src/__tests__/provider-cloud-proxy-integration.test.ts +2 -110
- package/src/__tests__/run-due-schedules.test.ts +0 -4
- package/src/__tests__/schedule-store.test.ts +0 -12
- package/src/__tests__/stt-stream-session.test.ts +4 -4
- package/src/__tests__/telephony-tts-guard.test.ts +2 -50
- package/src/__tests__/voice-config-update.test.ts +12 -167
- package/src/__tests__/web-search-catalog-parity.test.ts +0 -2
- package/src/__tests__/workspace-migration-130-speech-mode-to-provider.test.ts +9 -7
- package/src/__tests__/workspace-migration-132-web-search-mode-to-provider.test.ts +6 -6
- package/src/calls/__tests__/voice-session-bridge.test.ts +1 -4
- package/src/calls/resolve-call-tts-provider.ts +6 -25
- package/src/calls/telephony-credential-preflight.ts +0 -10
- package/src/calls/telephony-tts-capability.ts +1 -17
- package/src/cli/commands/tts.ts +1 -2
- package/src/cli/index.help.ts +0 -2
- package/src/cli/program.ts +0 -2
- package/src/config/bundled-skills/settings/tools/voice-config-update.ts +4 -42
- package/src/config/schemas/__tests__/stt.test.ts +10 -14
- package/src/config/schemas/services.ts +5 -6
- package/src/config/schemas/stt.ts +1 -3
- package/src/config/schemas/tts.ts +1 -30
- package/src/daemon/daemon-readiness.ts +4 -29
- package/src/daemon/lifecycle.ts +0 -31
- package/src/daemon/providers-setup.ts +0 -8
- package/src/heartbeat/__tests__/heartbeat-service.test.ts +0 -1
- package/src/heartbeat/heartbeat-service.ts +1 -66
- package/src/ipc/__tests__/db-readiness-ipc-gate.test.ts +1 -9
- package/src/live-voice/__tests__/live-voice-credential-preflight.test.ts +0 -44
- package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +4 -6
- package/src/live-voice/__tests__/live-voice-stt.test.ts +1 -1
- package/src/live-voice/live-voice-credential-preflight.ts +9 -33
- package/src/live-voice/live-voice-session.ts +10 -6
- package/src/live-voice/live-voice-tts.ts +1 -8
- package/src/plugins/defaults/memory/worker.ts +3 -3
- package/src/prompts/persona-resolver.ts +0 -35
- package/src/providers/__tests__/search-provider-catalog.test.ts +5 -8
- package/src/providers/__tests__/voice-error-copy.test.ts +9 -10
- package/src/providers/search-provider-catalog.ts +7 -39
- package/src/providers/speech-to-text/__tests__/provider-catalog.test.ts +3 -47
- package/src/providers/speech-to-text/__tests__/resolve.test.ts +6 -372
- package/src/providers/speech-to-text/provider-catalog.ts +2 -73
- package/src/providers/speech-to-text/resolve.ts +3 -120
- package/src/runtime/http-router-types.ts +1 -3
- package/src/runtime/http-server.ts +1 -1
- package/src/runtime/routes/__tests__/tts-routes.test.ts +2 -6
- package/src/runtime/routes/inbound-stages/transcribe-audio.test.ts +7 -7
- package/src/runtime/routes/index.ts +0 -4
- package/src/runtime/routes/live-voice-routes.test.ts +4 -11
- package/src/runtime/routes/live-voice-routes.ts +8 -11
- package/src/runtime/routes/secret-routes.ts +0 -6
- package/src/runtime/routes/tts-routes.ts +0 -38
- package/src/schedule/__tests__/plugin-schedule-reconciler.test.ts +1 -7
- package/src/schedule/__tests__/worker-mcp-readiness.test.ts +0 -4
- package/src/schedule/schedule-store.ts +0 -7
- package/src/schedule/scheduler.ts +0 -5
- package/src/schedule/worker.ts +1 -1
- package/src/stt/__tests__/daemon-batch-transcriber.test.ts +2 -10
- package/src/stt/daemon-batch-transcriber.ts +4 -38
- package/src/stt/types.ts +1 -9
- package/src/tools/network/__tests__/web-search.test.ts +3 -250
- package/src/tools/network/web-search.ts +4 -165
- package/src/tts/__tests__/provider-resolution.test.ts +0 -5
- package/src/tts/provider-catalog.ts +0 -4
- package/src/tts/types.ts +0 -1
- package/src/__tests__/cloud-speech-defaults.test.ts +0 -330
- package/src/__tests__/migration-cross-version-compatibility.test.ts +0 -1708
- package/src/__tests__/migration-export-http.test.ts +0 -557
- package/src/__tests__/migration-export-streaming.test.ts +0 -350
- package/src/__tests__/migration-export-to-gcs.test.ts +0 -706
- package/src/__tests__/migration-import-commit-http.test.ts +0 -1176
- package/src/__tests__/migration-import-from-gcs.test.ts +0 -534
- package/src/__tests__/migration-import-from-path.test.ts +0 -324
- package/src/__tests__/migration-import-from-url.test.ts +0 -588
- package/src/__tests__/migration-import-preflight-http.test.ts +0 -739
- package/src/__tests__/migration-jobs-status.test.ts +0 -139
- package/src/__tests__/migration-parity-persistence.test.ts +0 -1891
- package/src/__tests__/migration-transport.test.ts +0 -1089
- package/src/__tests__/migration-validate-http.test.ts +0 -634
- package/src/__tests__/migration-wizard.test.ts +0 -1395
- package/src/__tests__/rebind-secrets-screen.test.ts +0 -876
- package/src/__tests__/sanitize-config-for-transfer.test.ts +0 -259
- package/src/__tests__/transfer-progress-screen.test.ts +0 -1217
- package/src/__tests__/validation-results-screen.test.ts +0 -1130
- package/src/__tests__/vbundle-pax-and-symlink.test.ts +0 -147
- package/src/background-wake/background-wake-routes.test.ts +0 -906
- package/src/background-wake/cloud-client.test.ts +0 -328
- package/src/background-wake/cloud-client.ts +0 -196
- package/src/background-wake/next-wake.test.ts +0 -335
- package/src/background-wake/next-wake.ts +0 -188
- package/src/background-wake/publisher.ts +0 -93
- package/src/background-wake/wake-intent-hooks.test.ts +0 -234
- package/src/cli/commands/__tests__/backup.test.ts +0 -363
- package/src/cli/commands/backup.help.ts +0 -180
- package/src/cli/commands/backup.ts +0 -398
- package/src/cloud/cloud-speech.test.ts +0 -335
- package/src/cloud/cloud-speech.ts +0 -300
- package/src/config/cloud-speech-defaults.ts +0 -300
- package/src/config/sanitize-for-transfer.ts +0 -111
- package/src/live-voice/__tests__/live-voice-cloud-speech-fallback.test.ts +0 -250
- package/src/providers/speech-to-text/__tests__/cadet-cloud-realtime.test.ts +0 -457
- package/src/providers/speech-to-text/__tests__/cadet-cloud.test.ts +0 -271
- package/src/providers/speech-to-text/__tests__/cadet-speech-relay-connection.test.ts +0 -126
- package/src/providers/speech-to-text/cadet-cloud-flux-realtime.ts +0 -309
- package/src/providers/speech-to-text/cadet-cloud-realtime.ts +0 -315
- package/src/providers/speech-to-text/cadet-cloud.ts +0 -108
- package/src/providers/speech-to-text/cadet-speech-relay-connection.ts +0 -176
- package/src/runtime/migrations/__tests__/gcs-signed-url.test.ts +0 -254
- package/src/runtime/migrations/__tests__/job-registry.test.ts +0 -346
- package/src/runtime/migrations/__tests__/origin-mode.test.ts +0 -62
- package/src/runtime/migrations/__tests__/rebind-secrets-credentials.test.ts +0 -184
- package/src/runtime/migrations/__tests__/staged-import-path.test.ts +0 -110
- package/src/runtime/migrations/__tests__/v1-test-helpers.ts +0 -112
- package/src/runtime/migrations/__tests__/vbundle-builder-credentials.test.ts +0 -285
- package/src/runtime/migrations/__tests__/vbundle-builder-fd-leak.test.ts +0 -126
- package/src/runtime/migrations/__tests__/vbundle-builder-v1-shape.test.ts +0 -253
- package/src/runtime/migrations/__tests__/vbundle-import-credentials.test.ts +0 -208
- package/src/runtime/migrations/__tests__/vbundle-import-parity.test.ts +0 -485
- package/src/runtime/migrations/__tests__/vbundle-import-policy.test.ts +0 -349
- package/src/runtime/migrations/__tests__/vbundle-import-version-compat.test.ts +0 -196
- package/src/runtime/migrations/__tests__/vbundle-legacy-user-md.test.ts +0 -551
- package/src/runtime/migrations/__tests__/vbundle-metadata-merge-integration.test.ts +0 -428
- package/src/runtime/migrations/__tests__/vbundle-metadata-merge.test.ts +0 -220
- package/src/runtime/migrations/__tests__/vbundle-streaming-importer.test.ts +0 -1823
- package/src/runtime/migrations/__tests__/vbundle-streaming-validator.test.ts +0 -598
- package/src/runtime/migrations/__tests__/vbundle-symlink-importer.test.ts +0 -463
- package/src/runtime/migrations/__tests__/vbundle-symlink-streaming-importer.test.ts +0 -538
- package/src/runtime/migrations/__tests__/vbundle-symlink-streaming.test.ts +0 -515
- package/src/runtime/migrations/__tests__/vbundle-symlink-tar.test.ts +0 -453
- package/src/runtime/migrations/__tests__/vbundle-symlink-walker.test.ts +0 -319
- package/src/runtime/migrations/__tests__/vbundle-tar-stream.test.ts +0 -240
- package/src/runtime/migrations/__tests__/vbundle-validator-v1-schema.test.ts +0 -473
- package/src/runtime/migrations/gcs-signed-url.ts +0 -190
- package/src/runtime/migrations/job-registry.ts +0 -297
- package/src/runtime/migrations/migration-transport.ts +0 -612
- package/src/runtime/migrations/migration-wizard.ts +0 -747
- package/src/runtime/migrations/origin-mode.ts +0 -42
- package/src/runtime/migrations/rebind-secrets-screen.ts +0 -412
- package/src/runtime/migrations/staged-import-path.ts +0 -116
- package/src/runtime/migrations/transfer-progress-screen.ts +0 -323
- package/src/runtime/migrations/validation-results-screen.ts +0 -469
- package/src/runtime/migrations/vbundle-builder.ts +0 -1382
- package/src/runtime/migrations/vbundle-import-analyzer.ts +0 -405
- package/src/runtime/migrations/vbundle-import-policy.ts +0 -241
- package/src/runtime/migrations/vbundle-importer.ts +0 -826
- package/src/runtime/migrations/vbundle-metadata-merge.ts +0 -113
- package/src/runtime/migrations/vbundle-streaming-importer.ts +0 -2844
- package/src/runtime/migrations/vbundle-streaming-validator.ts +0 -426
- package/src/runtime/migrations/vbundle-tar-stream.ts +0 -244
- package/src/runtime/migrations/vbundle-validator.ts +0 -724
- package/src/runtime/routes/__tests__/migration-cadet-metadata-reconcile.test.ts +0 -227
- package/src/runtime/routes/__tests__/migration-export-secrets-redacted.test.ts +0 -54
- package/src/runtime/routes/__tests__/migration-import-allowed-hosts-env.test.ts +0 -70
- package/src/runtime/routes/__tests__/migration-import-credential-filter.test.ts +0 -257
- package/src/runtime/routes/background-wake-routes.ts +0 -387
- package/src/runtime/routes/migration-routes.ts +0 -2584
- package/src/tools/network/__tests__/cloud-search-proxy.test.ts +0 -282
- package/src/tools/network/cloud-search-proxy.ts +0 -211
- package/src/tts/__tests__/cadet-provider.test.ts +0 -253
- package/src/tts/providers/cadet-provider.ts +0 -244
- package/src/types/tar-stream.d.ts +0 -66
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for legacy `prompts/USER.md` translation during vbundle import.
|
|
3
|
-
*
|
|
4
|
-
* Covers:
|
|
5
|
-
* - `DefaultPathResolver` translates `prompts/USER.md` to the current
|
|
6
|
-
* guardian's `users/<slug>.md` path when a guardian exists.
|
|
7
|
-
* - Missing guardian → resolver returns null (commit skips with warn).
|
|
8
|
-
* - Full commit round-trip: legacy bundle writes content into
|
|
9
|
-
* `users/<slug>.md` on a fresh workspace.
|
|
10
|
-
* - Missing guardian: commit skips the legacy entry with a warning
|
|
11
|
-
* instead of crashing.
|
|
12
|
-
* - Already-customized `users/<slug>.md` is NOT overwritten.
|
|
13
|
-
* - Pristine scaffold `users/<slug>.md` (template only) IS overwritten.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
existsSync,
|
|
18
|
-
mkdirSync,
|
|
19
|
-
readFileSync,
|
|
20
|
-
rmSync,
|
|
21
|
-
writeFileSync,
|
|
22
|
-
} from "node:fs";
|
|
23
|
-
import { join } from "node:path";
|
|
24
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
25
|
-
|
|
26
|
-
import { buildVBundle } from "../vbundle-builder.js";
|
|
27
|
-
import {
|
|
28
|
-
analyzeImport,
|
|
29
|
-
DefaultPathResolver,
|
|
30
|
-
} from "../vbundle-import-analyzer.js";
|
|
31
|
-
import { commitImport } from "../vbundle-importer.js";
|
|
32
|
-
import { defaultV1Options } from "./v1-test-helpers.js";
|
|
33
|
-
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
// Shared fixture: per-test workspace under CADET_WORKSPACE_DIR.
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
|
|
38
|
-
const WORKSPACE_ROOT = process.env.CADET_WORKSPACE_DIR!;
|
|
39
|
-
const USERS_DIR = join(WORKSPACE_ROOT, "users");
|
|
40
|
-
|
|
41
|
-
const LEGACY_USER_MD_CONTENT = `# User Profile
|
|
42
|
-
|
|
43
|
-
- Preferred name/reference: Captain Legacy
|
|
44
|
-
- Pronouns: they/them
|
|
45
|
-
- Work role: Archivist
|
|
46
|
-
- Hobbies/fun: Unearthing old bundles
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Bare scaffold template matching `GUARDIAN_PERSONA_TEMPLATE` in
|
|
51
|
-
* `persona-resolver.ts`. Duplicated here intentionally so the test
|
|
52
|
-
* pins the exact bytes that count as "not customized".
|
|
53
|
-
*/
|
|
54
|
-
const PRISTINE_SCAFFOLD = `_ Lines starting with _ are comments - they won't appear in the system prompt
|
|
55
|
-
|
|
56
|
-
# User Profile
|
|
57
|
-
|
|
58
|
-
Store details about your user here. Edit freely - build this over time as you learn about them. Don't be pushy about seeking details, but when you learn something, write it down. More context makes you more useful.
|
|
59
|
-
|
|
60
|
-
- Preferred name/reference:
|
|
61
|
-
- Pronouns:
|
|
62
|
-
- Locale:
|
|
63
|
-
- Work role:
|
|
64
|
-
- Goals:
|
|
65
|
-
- Hobbies/fun:
|
|
66
|
-
- Daily tools:
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Customized guardian persona file — has user-authored content past the
|
|
71
|
-
* bare scaffold. Must survive an import unchanged.
|
|
72
|
-
*/
|
|
73
|
-
const CUSTOMIZED_PERSONA = `_ Lines starting with _ are comments - they won't appear in the system prompt
|
|
74
|
-
|
|
75
|
-
# User Profile
|
|
76
|
-
|
|
77
|
-
- Preferred name/reference: Real User
|
|
78
|
-
- Pronouns: she/her
|
|
79
|
-
- Locale: en-US
|
|
80
|
-
- Work role: Staff Engineer
|
|
81
|
-
- Goals: Ship drop-user-md
|
|
82
|
-
- Hobbies/fun: Reading papers
|
|
83
|
-
- Daily tools: Terminal, Cadet
|
|
84
|
-
`;
|
|
85
|
-
|
|
86
|
-
function cleanWorkspace() {
|
|
87
|
-
try {
|
|
88
|
-
rmSync(USERS_DIR, { recursive: true, force: true });
|
|
89
|
-
} catch {
|
|
90
|
-
/* best effort */
|
|
91
|
-
}
|
|
92
|
-
mkdirSync(USERS_DIR, { recursive: true });
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
beforeEach(() => {
|
|
96
|
-
cleanWorkspace();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
afterEach(() => {
|
|
100
|
-
cleanWorkspace();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// ---------------------------------------------------------------------------
|
|
104
|
-
// DefaultPathResolver — USER.md translation
|
|
105
|
-
// ---------------------------------------------------------------------------
|
|
106
|
-
|
|
107
|
-
describe("DefaultPathResolver prompts/USER.md translation", () => {
|
|
108
|
-
test("rewrites prompts/USER.md to the guardian's users/<slug>.md", () => {
|
|
109
|
-
const guardianPath = join(USERS_DIR, "captain.md");
|
|
110
|
-
const resolver = new DefaultPathResolver(
|
|
111
|
-
WORKSPACE_ROOT,
|
|
112
|
-
undefined,
|
|
113
|
-
() => guardianPath,
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
expect(resolver.resolve("prompts/USER.md")).toBe(guardianPath);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test("returns null when no guardian exists", () => {
|
|
120
|
-
const resolver = new DefaultPathResolver(
|
|
121
|
-
WORKSPACE_ROOT,
|
|
122
|
-
undefined,
|
|
123
|
-
() => null,
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
expect(resolver.resolve("prompts/USER.md")).toBeNull();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test("rejects guardian paths outside the workspace (traversal guard)", () => {
|
|
130
|
-
// Stubbed resolver returns a path outside the workspace — the
|
|
131
|
-
// analyzer resolver must reject it to prevent writing outside
|
|
132
|
-
// the workspace root.
|
|
133
|
-
const resolver = new DefaultPathResolver(
|
|
134
|
-
WORKSPACE_ROOT,
|
|
135
|
-
undefined,
|
|
136
|
-
() => "/etc/passwd",
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
expect(resolver.resolve("prompts/USER.md")).toBeNull();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test("still resolves other prompt files (IDENTITY.md) to workspace root", () => {
|
|
143
|
-
const resolver = new DefaultPathResolver(WORKSPACE_ROOT, undefined, () =>
|
|
144
|
-
join(USERS_DIR, "captain.md"),
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
expect(resolver.resolve("prompts/IDENTITY.md")).toBe(
|
|
148
|
-
join(WORKSPACE_ROOT, "IDENTITY.md"),
|
|
149
|
-
);
|
|
150
|
-
expect(resolver.resolve("prompts/SOUL.md")).toBe(
|
|
151
|
-
join(WORKSPACE_ROOT, "SOUL.md"),
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test("skips unknown prompt filenames regardless of guardian state", () => {
|
|
156
|
-
const resolver = new DefaultPathResolver(WORKSPACE_ROOT, undefined, () =>
|
|
157
|
-
join(USERS_DIR, "captain.md"),
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(resolver.resolve("prompts/SECRET.md")).toBeNull();
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// ---------------------------------------------------------------------------
|
|
165
|
-
// analyzeImport — surfaces the translated destination for preflight
|
|
166
|
-
// ---------------------------------------------------------------------------
|
|
167
|
-
|
|
168
|
-
describe("analyzeImport for legacy prompts/USER.md", () => {
|
|
169
|
-
test("reports a `create` action on a fresh users/<slug>.md", () => {
|
|
170
|
-
const guardianPath = join(USERS_DIR, "captain.md");
|
|
171
|
-
const resolver = new DefaultPathResolver(
|
|
172
|
-
WORKSPACE_ROOT,
|
|
173
|
-
undefined,
|
|
174
|
-
() => guardianPath,
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
const { archive, manifest } = buildVBundle({
|
|
178
|
-
files: [
|
|
179
|
-
{
|
|
180
|
-
path: "data/db/assistant.db",
|
|
181
|
-
data: new Uint8Array(),
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
path: "prompts/USER.md",
|
|
185
|
-
data: new TextEncoder().encode(LEGACY_USER_MD_CONTENT),
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
...defaultV1Options(),
|
|
189
|
-
});
|
|
190
|
-
expect(archive.length).toBeGreaterThan(0);
|
|
191
|
-
|
|
192
|
-
const report = analyzeImport({ manifest, pathResolver: resolver });
|
|
193
|
-
|
|
194
|
-
expect(report.can_import).toBe(true);
|
|
195
|
-
const userMd = report.files.find((f) => f.path === "prompts/USER.md");
|
|
196
|
-
expect(userMd).toBeDefined();
|
|
197
|
-
expect(userMd!.action).toBe("create");
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test("non-blocking skip when no guardian is resolvable (can_import stays true)", () => {
|
|
201
|
-
const resolver = new DefaultPathResolver(
|
|
202
|
-
WORKSPACE_ROOT,
|
|
203
|
-
undefined,
|
|
204
|
-
() => null,
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
const { manifest } = buildVBundle({
|
|
208
|
-
files: [
|
|
209
|
-
{
|
|
210
|
-
path: "data/db/assistant.db",
|
|
211
|
-
data: new Uint8Array(),
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
path: "prompts/USER.md",
|
|
215
|
-
data: new TextEncoder().encode(LEGACY_USER_MD_CONTENT),
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
...defaultV1Options(),
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const report = analyzeImport({ manifest, pathResolver: resolver });
|
|
222
|
-
|
|
223
|
-
// Guardian-less workspaces must not block preflight — the commit-time
|
|
224
|
-
// path warns and skips, so preflight mirrors that behavior.
|
|
225
|
-
expect(report.can_import).toBe(true);
|
|
226
|
-
expect(report.conflicts).toHaveLength(0);
|
|
227
|
-
const userMd = report.files.find((f) => f.path === "prompts/USER.md");
|
|
228
|
-
expect(userMd!.action).toBe("skip");
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
test("retired workspace/UPDATES.md (current format) is a non-blocking skip", () => {
|
|
232
|
-
const resolver = new DefaultPathResolver(
|
|
233
|
-
WORKSPACE_ROOT,
|
|
234
|
-
undefined,
|
|
235
|
-
() => null,
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
const { manifest } = buildVBundle({
|
|
239
|
-
files: [
|
|
240
|
-
{
|
|
241
|
-
path: "data/db/assistant.db",
|
|
242
|
-
data: new Uint8Array(),
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
path: "workspace/UPDATES.md",
|
|
246
|
-
data: new TextEncoder().encode("## Old release notes\n"),
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
...defaultV1Options(),
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
const report = analyzeImport({ manifest, pathResolver: resolver });
|
|
253
|
-
|
|
254
|
-
expect(report.can_import).toBe(true);
|
|
255
|
-
expect(report.conflicts).toHaveLength(0);
|
|
256
|
-
const updatesMd = report.files.find(
|
|
257
|
-
(f) => f.path === "workspace/UPDATES.md",
|
|
258
|
-
);
|
|
259
|
-
expect(updatesMd).toBeDefined();
|
|
260
|
-
expect(updatesMd!.action).toBe("skip");
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test("retired prompts/UPDATES.md in a legacy bundle is a non-blocking skip", () => {
|
|
264
|
-
const resolver = new DefaultPathResolver(
|
|
265
|
-
WORKSPACE_ROOT,
|
|
266
|
-
undefined,
|
|
267
|
-
() => null,
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
const { manifest } = buildVBundle({
|
|
271
|
-
files: [
|
|
272
|
-
{
|
|
273
|
-
path: "data/db/assistant.db",
|
|
274
|
-
data: new Uint8Array(),
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
path: "prompts/UPDATES.md",
|
|
278
|
-
data: new TextEncoder().encode("## Old release notes\n"),
|
|
279
|
-
},
|
|
280
|
-
],
|
|
281
|
-
...defaultV1Options(),
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
const report = analyzeImport({ manifest, pathResolver: resolver });
|
|
285
|
-
|
|
286
|
-
// Bundles exported while the update-bulletin feature existed must stay
|
|
287
|
-
// restorable — the retired file is dropped, never written back, and
|
|
288
|
-
// must not register an UNKNOWN_ARCHIVE_PATH conflict.
|
|
289
|
-
expect(report.can_import).toBe(true);
|
|
290
|
-
expect(report.conflicts).toHaveLength(0);
|
|
291
|
-
const updatesMd = report.files.find((f) => f.path === "prompts/UPDATES.md");
|
|
292
|
-
expect(updatesMd).toBeDefined();
|
|
293
|
-
expect(updatesMd!.action).toBe("skip");
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
// ---------------------------------------------------------------------------
|
|
298
|
-
// commitImport — end-to-end legacy USER.md import
|
|
299
|
-
// ---------------------------------------------------------------------------
|
|
300
|
-
|
|
301
|
-
describe("commitImport for legacy prompts/USER.md", () => {
|
|
302
|
-
test("writes legacy USER.md content into users/<slug>.md", () => {
|
|
303
|
-
const slug = "captain.md";
|
|
304
|
-
const guardianPath = join(USERS_DIR, slug);
|
|
305
|
-
const resolver = new DefaultPathResolver(
|
|
306
|
-
WORKSPACE_ROOT,
|
|
307
|
-
undefined,
|
|
308
|
-
() => guardianPath,
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
const { archive } = buildVBundle({
|
|
312
|
-
files: [
|
|
313
|
-
{
|
|
314
|
-
path: "data/db/assistant.db",
|
|
315
|
-
data: new Uint8Array(),
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
path: "prompts/USER.md",
|
|
319
|
-
data: new TextEncoder().encode(LEGACY_USER_MD_CONTENT),
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
...defaultV1Options(),
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
const result = commitImport({
|
|
326
|
-
archiveData: archive,
|
|
327
|
-
pathResolver: resolver,
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
expect(result.ok).toBe(true);
|
|
331
|
-
if (result.ok) {
|
|
332
|
-
expect(result.report.success).toBe(true);
|
|
333
|
-
// The bundle carries both data/db/assistant.db and prompts/USER.md;
|
|
334
|
-
// the legacy USER.md is the one we care about here.
|
|
335
|
-
expect(
|
|
336
|
-
result.report.files.find((f) => f.path === "prompts/USER.md")?.action,
|
|
337
|
-
).toBe("created");
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
expect(existsSync(guardianPath)).toBe(true);
|
|
341
|
-
expect(readFileSync(guardianPath, "utf-8")).toBe(LEGACY_USER_MD_CONTENT);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
test("overwrites a pristine scaffold users/<slug>.md", () => {
|
|
345
|
-
const slug = "captain.md";
|
|
346
|
-
const guardianPath = join(USERS_DIR, slug);
|
|
347
|
-
writeFileSync(guardianPath, PRISTINE_SCAFFOLD, "utf-8");
|
|
348
|
-
|
|
349
|
-
const resolver = new DefaultPathResolver(
|
|
350
|
-
WORKSPACE_ROOT,
|
|
351
|
-
undefined,
|
|
352
|
-
() => guardianPath,
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
const { archive } = buildVBundle({
|
|
356
|
-
files: [
|
|
357
|
-
{
|
|
358
|
-
path: "data/db/assistant.db",
|
|
359
|
-
data: new Uint8Array(),
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
path: "prompts/USER.md",
|
|
363
|
-
data: new TextEncoder().encode(LEGACY_USER_MD_CONTENT),
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
|
-
...defaultV1Options(),
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
const result = commitImport({
|
|
370
|
-
archiveData: archive,
|
|
371
|
-
pathResolver: resolver,
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
expect(result.ok).toBe(true);
|
|
375
|
-
if (result.ok) {
|
|
376
|
-
expect(
|
|
377
|
-
result.report.files.find((f) => f.path === "prompts/USER.md")?.action,
|
|
378
|
-
).toBe("overwritten");
|
|
379
|
-
}
|
|
380
|
-
expect(readFileSync(guardianPath, "utf-8")).toBe(LEGACY_USER_MD_CONTENT);
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
test("skips with a warning when no guardian exists (no crash)", () => {
|
|
384
|
-
const resolver = new DefaultPathResolver(
|
|
385
|
-
WORKSPACE_ROOT,
|
|
386
|
-
undefined,
|
|
387
|
-
() => null,
|
|
388
|
-
);
|
|
389
|
-
|
|
390
|
-
const { archive } = buildVBundle({
|
|
391
|
-
files: [
|
|
392
|
-
{
|
|
393
|
-
path: "data/db/assistant.db",
|
|
394
|
-
data: new Uint8Array(),
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
path: "prompts/USER.md",
|
|
398
|
-
data: new TextEncoder().encode(LEGACY_USER_MD_CONTENT),
|
|
399
|
-
},
|
|
400
|
-
],
|
|
401
|
-
...defaultV1Options(),
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
const result = commitImport({
|
|
405
|
-
archiveData: archive,
|
|
406
|
-
pathResolver: resolver,
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
expect(result.ok).toBe(true);
|
|
410
|
-
if (result.ok) {
|
|
411
|
-
expect(
|
|
412
|
-
result.report.files.find((f) => f.path === "prompts/USER.md")?.action,
|
|
413
|
-
).toBe("skipped");
|
|
414
|
-
expect(
|
|
415
|
-
result.report.warnings.some((w) => w.includes("prompts/USER.md")),
|
|
416
|
-
).toBe(true);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// No stray file was written anywhere in users/.
|
|
420
|
-
expect(existsSync(join(USERS_DIR, "USER.md"))).toBe(false);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
test("retired workspace/UPDATES.md (current format) is never written back", () => {
|
|
424
|
-
const resolver = new DefaultPathResolver(
|
|
425
|
-
WORKSPACE_ROOT,
|
|
426
|
-
undefined,
|
|
427
|
-
() => null,
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
const { archive } = buildVBundle({
|
|
431
|
-
files: [
|
|
432
|
-
{
|
|
433
|
-
path: "data/db/assistant.db",
|
|
434
|
-
data: new Uint8Array(),
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
path: "workspace/UPDATES.md",
|
|
438
|
-
data: new TextEncoder().encode("## Old release notes\n"),
|
|
439
|
-
},
|
|
440
|
-
],
|
|
441
|
-
...defaultV1Options(),
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
const result = commitImport({
|
|
445
|
-
archiveData: archive,
|
|
446
|
-
pathResolver: resolver,
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
expect(result.ok).toBe(true);
|
|
450
|
-
if (result.ok) {
|
|
451
|
-
expect(result.report.success).toBe(true);
|
|
452
|
-
expect(
|
|
453
|
-
result.report.files.find((f) => f.path === "workspace/UPDATES.md")
|
|
454
|
-
?.action,
|
|
455
|
-
).toBe("skipped");
|
|
456
|
-
expect(result.report.warnings.some((w) => w.includes("UPDATES.md"))).toBe(
|
|
457
|
-
false,
|
|
458
|
-
);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// The retired bulletin file must not be resurrected in the workspace.
|
|
462
|
-
expect(existsSync(join(WORKSPACE_ROOT, "UPDATES.md"))).toBe(false);
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
test("retired prompts/UPDATES.md skips silently — no warning, nothing written", () => {
|
|
466
|
-
const resolver = new DefaultPathResolver(
|
|
467
|
-
WORKSPACE_ROOT,
|
|
468
|
-
undefined,
|
|
469
|
-
() => null,
|
|
470
|
-
);
|
|
471
|
-
|
|
472
|
-
const { archive } = buildVBundle({
|
|
473
|
-
files: [
|
|
474
|
-
{
|
|
475
|
-
path: "data/db/assistant.db",
|
|
476
|
-
data: new Uint8Array(),
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
path: "prompts/UPDATES.md",
|
|
480
|
-
data: new TextEncoder().encode("## Old release notes\n"),
|
|
481
|
-
},
|
|
482
|
-
],
|
|
483
|
-
...defaultV1Options(),
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
const result = commitImport({
|
|
487
|
-
archiveData: archive,
|
|
488
|
-
pathResolver: resolver,
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
expect(result.ok).toBe(true);
|
|
492
|
-
if (result.ok) {
|
|
493
|
-
expect(result.report.success).toBe(true);
|
|
494
|
-
expect(
|
|
495
|
-
result.report.files.find((f) => f.path === "prompts/UPDATES.md")
|
|
496
|
-
?.action,
|
|
497
|
-
).toBe("skipped");
|
|
498
|
-
// Silent skip: the commit report must agree with preflight, which
|
|
499
|
-
// raises neither a conflict nor a warning for retired paths.
|
|
500
|
-
expect(
|
|
501
|
-
result.report.warnings.some((w) => w.includes("prompts/UPDATES.md")),
|
|
502
|
-
).toBe(false);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
expect(existsSync(join(WORKSPACE_ROOT, "UPDATES.md"))).toBe(false);
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
test("does NOT overwrite a customized users/<slug>.md", () => {
|
|
509
|
-
const slug = "captain.md";
|
|
510
|
-
const guardianPath = join(USERS_DIR, slug);
|
|
511
|
-
writeFileSync(guardianPath, CUSTOMIZED_PERSONA, "utf-8");
|
|
512
|
-
|
|
513
|
-
const resolver = new DefaultPathResolver(
|
|
514
|
-
WORKSPACE_ROOT,
|
|
515
|
-
undefined,
|
|
516
|
-
() => guardianPath,
|
|
517
|
-
);
|
|
518
|
-
|
|
519
|
-
const { archive } = buildVBundle({
|
|
520
|
-
files: [
|
|
521
|
-
{
|
|
522
|
-
path: "data/db/assistant.db",
|
|
523
|
-
data: new Uint8Array(),
|
|
524
|
-
},
|
|
525
|
-
{
|
|
526
|
-
path: "prompts/USER.md",
|
|
527
|
-
data: new TextEncoder().encode(LEGACY_USER_MD_CONTENT),
|
|
528
|
-
},
|
|
529
|
-
],
|
|
530
|
-
...defaultV1Options(),
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
const result = commitImport({
|
|
534
|
-
archiveData: archive,
|
|
535
|
-
pathResolver: resolver,
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
expect(result.ok).toBe(true);
|
|
539
|
-
if (result.ok) {
|
|
540
|
-
expect(
|
|
541
|
-
result.report.files.find((f) => f.path === "prompts/USER.md")?.action,
|
|
542
|
-
).toBe("skipped");
|
|
543
|
-
expect(
|
|
544
|
-
result.report.warnings.some((w) => w.includes("guardian persona")),
|
|
545
|
-
).toBe(true);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// Existing customized content is preserved byte-for-byte.
|
|
549
|
-
expect(readFileSync(guardianPath, "utf-8")).toBe(CUSTOMIZED_PERSONA);
|
|
550
|
-
});
|
|
551
|
-
});
|