@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,463 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Symlink-handling coverage for the buffer-mode `commitImport`.
|
|
3
|
-
*
|
|
4
|
-
* Scenarios:
|
|
5
|
-
* 1. Round-trip: a typeflag-2 manifest entry is recreated as a real symlink
|
|
6
|
-
* under the workspace, points at its sibling regular file, and reads
|
|
7
|
-
* back its target's contents through the link.
|
|
8
|
-
* 2. Defense-in-depth: a hand-built `preValidatedManifest` carrying a
|
|
9
|
-
* `..`-traversal `link_target` is skipped (not written), with a
|
|
10
|
-
* "escapes workspace" warning.
|
|
11
|
-
* 3. Defense-in-depth: an absolute `link_target` ("/etc/passwd") is
|
|
12
|
-
* skipped with the same warning shape.
|
|
13
|
-
* 4. Overwrite: an existing regular file at the symlink's target path is
|
|
14
|
-
* backed up, then replaced by the symlink. Backup contents match the
|
|
15
|
-
* pre-existing file.
|
|
16
|
-
* 5. Symlink-overwrites-symlink: a different pre-existing symlink at the
|
|
17
|
-
* target path is replaced cleanly without an EEXIST.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
lstatSync,
|
|
22
|
-
mkdirSync,
|
|
23
|
-
mkdtempSync,
|
|
24
|
-
readdirSync,
|
|
25
|
-
readFileSync,
|
|
26
|
-
readlinkSync,
|
|
27
|
-
rmSync,
|
|
28
|
-
symlinkSync,
|
|
29
|
-
writeFileSync,
|
|
30
|
-
} from "node:fs";
|
|
31
|
-
import { tmpdir } from "node:os";
|
|
32
|
-
import { dirname, join } from "node:path";
|
|
33
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
34
|
-
|
|
35
|
-
import { buildVBundle } from "../vbundle-builder.js";
|
|
36
|
-
import { DefaultPathResolver } from "../vbundle-import-analyzer.js";
|
|
37
|
-
import { commitImport } from "../vbundle-importer.js";
|
|
38
|
-
import type { VBundleTarEntry } from "../vbundle-validator.js";
|
|
39
|
-
import { buildTestManifest, defaultV1Options } from "./v1-test-helpers.js";
|
|
40
|
-
|
|
41
|
-
let workspaceDir: string;
|
|
42
|
-
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
workspaceDir = mkdtempSync(join(tmpdir(), "vbundle-symlink-importer-"));
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
afterEach(() => {
|
|
48
|
-
if (workspaceDir) {
|
|
49
|
-
rmSync(workspaceDir, { recursive: true, force: true });
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
function makePathResolver(): DefaultPathResolver {
|
|
54
|
-
// Pass a stub guardian persona resolver to avoid the production lookup
|
|
55
|
-
// touching the real contact store during tests.
|
|
56
|
-
return new DefaultPathResolver(workspaceDir, undefined, () => null);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
describe("commitImport — symlinks", () => {
|
|
60
|
-
test("round-trip: recreates a typeflag-2 entry as a real symlink", () => {
|
|
61
|
-
const files = [
|
|
62
|
-
{
|
|
63
|
-
path: "workspace/data/db/assistant.db",
|
|
64
|
-
data: new TextEncoder().encode("db-bytes"),
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
path: "workspace/skills/bar.md",
|
|
68
|
-
data: new TextEncoder().encode("hello bar"),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
path: "workspace/skills/foo.md",
|
|
72
|
-
data: new Uint8Array(0),
|
|
73
|
-
linkTarget: "bar.md",
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
const { archive } = buildVBundle({ files, ...defaultV1Options() });
|
|
77
|
-
|
|
78
|
-
const result = commitImport({
|
|
79
|
-
archiveData: archive,
|
|
80
|
-
pathResolver: makePathResolver(),
|
|
81
|
-
workspaceDir,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
expect(result.ok).toBe(true);
|
|
85
|
-
if (!result.ok) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const fooPath = join(workspaceDir, "skills/foo.md");
|
|
90
|
-
expect(lstatSync(fooPath).isSymbolicLink()).toBe(true);
|
|
91
|
-
expect(readlinkSync(fooPath)).toBe("bar.md");
|
|
92
|
-
expect(readFileSync(fooPath, "utf8")).toBe("hello bar");
|
|
93
|
-
|
|
94
|
-
const fooReport = result.report.files.find(
|
|
95
|
-
(f) => f.path === "workspace/skills/foo.md",
|
|
96
|
-
);
|
|
97
|
-
expect(fooReport).toBeDefined();
|
|
98
|
-
expect(fooReport!.action).toBe("created");
|
|
99
|
-
expect(fooReport!.size).toBe(0);
|
|
100
|
-
expect(fooReport!.backup_path).toBeNull();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test("defense-in-depth: traversal link_target is skipped with warning", () => {
|
|
104
|
-
// Bypass `validateVBundle` (which would reject the traversal first) by
|
|
105
|
-
// handing `commitImport` a hand-built manifest + entries map.
|
|
106
|
-
const linkTarget = "../../../tmp/escape";
|
|
107
|
-
const archivePath = "workspace/skills/escape.md";
|
|
108
|
-
const manifest = buildTestManifest({
|
|
109
|
-
contents: [
|
|
110
|
-
{
|
|
111
|
-
path: "workspace/data/db/assistant.db",
|
|
112
|
-
sha256: "0".repeat(64),
|
|
113
|
-
size_bytes: 8,
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
path: archivePath,
|
|
117
|
-
sha256: "0".repeat(64),
|
|
118
|
-
size_bytes: 0,
|
|
119
|
-
link_target: linkTarget,
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
});
|
|
123
|
-
const entries = new Map<string, VBundleTarEntry>([
|
|
124
|
-
[
|
|
125
|
-
"workspace/data/db/assistant.db",
|
|
126
|
-
{
|
|
127
|
-
name: "workspace/data/db/assistant.db",
|
|
128
|
-
data: new TextEncoder().encode("db-bytes"),
|
|
129
|
-
size: 8,
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
[
|
|
133
|
-
archivePath,
|
|
134
|
-
{
|
|
135
|
-
name: archivePath,
|
|
136
|
-
data: new Uint8Array(0),
|
|
137
|
-
size: 0,
|
|
138
|
-
linkname: linkTarget,
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
]);
|
|
142
|
-
|
|
143
|
-
const result = commitImport({
|
|
144
|
-
archiveData: new Uint8Array(0),
|
|
145
|
-
pathResolver: makePathResolver(),
|
|
146
|
-
preValidatedManifest: manifest,
|
|
147
|
-
preValidatedEntries: entries,
|
|
148
|
-
workspaceDir,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
expect(result.ok).toBe(true);
|
|
152
|
-
if (!result.ok) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const entry = result.report.files.find((f) => f.path === archivePath);
|
|
157
|
-
expect(entry).toBeDefined();
|
|
158
|
-
expect(entry!.action).toBe("skipped");
|
|
159
|
-
expect(
|
|
160
|
-
result.report.warnings.some((w) => w.includes("escapes workspace")),
|
|
161
|
-
).toBe(true);
|
|
162
|
-
|
|
163
|
-
// Nothing should have landed on disk for the rejected entry.
|
|
164
|
-
expect(() => lstatSync(join(workspaceDir, "skills/escape.md"))).toThrow();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test("defense-in-depth: absolute link_target is skipped with warning", () => {
|
|
168
|
-
const linkTarget = "/etc/passwd";
|
|
169
|
-
const archivePath = "workspace/skills/abs.md";
|
|
170
|
-
const manifest = buildTestManifest({
|
|
171
|
-
contents: [
|
|
172
|
-
{
|
|
173
|
-
path: "workspace/data/db/assistant.db",
|
|
174
|
-
sha256: "0".repeat(64),
|
|
175
|
-
size_bytes: 8,
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
path: archivePath,
|
|
179
|
-
sha256: "0".repeat(64),
|
|
180
|
-
size_bytes: 0,
|
|
181
|
-
link_target: linkTarget,
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
});
|
|
185
|
-
const entries = new Map<string, VBundleTarEntry>([
|
|
186
|
-
[
|
|
187
|
-
"workspace/data/db/assistant.db",
|
|
188
|
-
{
|
|
189
|
-
name: "workspace/data/db/assistant.db",
|
|
190
|
-
data: new TextEncoder().encode("db-bytes"),
|
|
191
|
-
size: 8,
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
[
|
|
195
|
-
archivePath,
|
|
196
|
-
{
|
|
197
|
-
name: archivePath,
|
|
198
|
-
data: new Uint8Array(0),
|
|
199
|
-
size: 0,
|
|
200
|
-
linkname: linkTarget,
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
]);
|
|
204
|
-
|
|
205
|
-
const result = commitImport({
|
|
206
|
-
archiveData: new Uint8Array(0),
|
|
207
|
-
pathResolver: makePathResolver(),
|
|
208
|
-
preValidatedManifest: manifest,
|
|
209
|
-
preValidatedEntries: entries,
|
|
210
|
-
workspaceDir,
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
expect(result.ok).toBe(true);
|
|
214
|
-
if (!result.ok) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const entry = result.report.files.find((f) => f.path === archivePath);
|
|
219
|
-
expect(entry).toBeDefined();
|
|
220
|
-
expect(entry!.action).toBe("skipped");
|
|
221
|
-
expect(
|
|
222
|
-
result.report.warnings.some((w) => w.includes("escapes workspace")),
|
|
223
|
-
).toBe(true);
|
|
224
|
-
|
|
225
|
-
expect(() => lstatSync(join(workspaceDir, "skills/abs.md"))).toThrow();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test("overwrite: pre-existing regular file is backed up and replaced", () => {
|
|
229
|
-
// Hand-build the manifest and skip `workspaceDir` so the workspace
|
|
230
|
-
// clear (Step 1b) doesn't wipe the regular file we plant below — that
|
|
231
|
-
// way we exercise the in-loop overwrite branch directly.
|
|
232
|
-
const archivePath = "workspace/skills/foo.md";
|
|
233
|
-
const linkTarget = "bar.md";
|
|
234
|
-
|
|
235
|
-
const manifest = buildTestManifest({
|
|
236
|
-
contents: [
|
|
237
|
-
{
|
|
238
|
-
path: "workspace/data/db/assistant.db",
|
|
239
|
-
sha256: "0".repeat(64),
|
|
240
|
-
size_bytes: 8,
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
path: archivePath,
|
|
244
|
-
sha256: "0".repeat(64),
|
|
245
|
-
size_bytes: 0,
|
|
246
|
-
link_target: linkTarget,
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
});
|
|
250
|
-
const entries = new Map<string, VBundleTarEntry>([
|
|
251
|
-
[
|
|
252
|
-
"workspace/data/db/assistant.db",
|
|
253
|
-
{
|
|
254
|
-
name: "workspace/data/db/assistant.db",
|
|
255
|
-
data: new TextEncoder().encode("db-bytes"),
|
|
256
|
-
size: 8,
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
[
|
|
260
|
-
archivePath,
|
|
261
|
-
{
|
|
262
|
-
name: archivePath,
|
|
263
|
-
data: new Uint8Array(0),
|
|
264
|
-
size: 0,
|
|
265
|
-
linkname: linkTarget,
|
|
266
|
-
},
|
|
267
|
-
],
|
|
268
|
-
]);
|
|
269
|
-
|
|
270
|
-
// Pre-create the conflicting regular file at the resolved target.
|
|
271
|
-
const fooDiskPath = join(workspaceDir, "skills/foo.md");
|
|
272
|
-
mkdirSync(dirname(fooDiskPath), { recursive: true });
|
|
273
|
-
writeFileSync(fooDiskPath, "old");
|
|
274
|
-
|
|
275
|
-
const result = commitImport({
|
|
276
|
-
archiveData: new Uint8Array(0),
|
|
277
|
-
pathResolver: makePathResolver(),
|
|
278
|
-
preValidatedManifest: manifest,
|
|
279
|
-
preValidatedEntries: entries,
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
expect(result.ok).toBe(true);
|
|
283
|
-
if (!result.ok) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
expect(lstatSync(fooDiskPath).isSymbolicLink()).toBe(true);
|
|
288
|
-
expect(readlinkSync(fooDiskPath)).toBe("bar.md");
|
|
289
|
-
|
|
290
|
-
const report = result.report.files.find((f) => f.path === archivePath)!;
|
|
291
|
-
expect(report.action).toBe("overwritten");
|
|
292
|
-
expect(report.backup_path).not.toBeNull();
|
|
293
|
-
|
|
294
|
-
// A backup file matching the foo.md.backup-* glob should exist and
|
|
295
|
-
// contain the pre-existing regular-file bytes.
|
|
296
|
-
const skillsDir = join(workspaceDir, "skills");
|
|
297
|
-
const siblings = readdirSync(skillsDir);
|
|
298
|
-
const backups = siblings.filter((n) => n.startsWith("foo.md.backup-"));
|
|
299
|
-
expect(backups.length).toBeGreaterThan(0);
|
|
300
|
-
const backupContents = readFileSync(join(skillsDir, backups[0]), "utf8");
|
|
301
|
-
expect(backupContents).toBe("old");
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
test("legacy prompts/USER.md symlink is skipped when guardian persona is already customized", () => {
|
|
305
|
-
// Bundle ships prompts/USER.md as a symlink. The destination workspace
|
|
306
|
-
// already has a customized guardian persona at users/<slug>.md, so the
|
|
307
|
-
// import must skip the entry rather than clobber the user's content.
|
|
308
|
-
// Hand-build the manifest and skip `workspaceDir` so the workspace
|
|
309
|
-
// clear (Step 1b) doesn't wipe the customized persona we plant below.
|
|
310
|
-
const archivePath = "prompts/USER.md";
|
|
311
|
-
const linkTarget = "../skills/something.md";
|
|
312
|
-
|
|
313
|
-
const customizedPersona = `_ Lines starting with _ are comments - they won't appear in the system prompt
|
|
314
|
-
|
|
315
|
-
# User Profile
|
|
316
|
-
|
|
317
|
-
- Preferred name/reference: Real User
|
|
318
|
-
- Pronouns: she/her
|
|
319
|
-
- Locale: en-US
|
|
320
|
-
- Work role: Staff Engineer
|
|
321
|
-
- Goals: Ship drop-user-md
|
|
322
|
-
- Hobbies/fun: Reading papers
|
|
323
|
-
- Daily tools: Terminal, Cadet
|
|
324
|
-
`;
|
|
325
|
-
|
|
326
|
-
const guardianPath = join(workspaceDir, "users/captain.md");
|
|
327
|
-
mkdirSync(dirname(guardianPath), { recursive: true });
|
|
328
|
-
writeFileSync(guardianPath, customizedPersona, "utf-8");
|
|
329
|
-
|
|
330
|
-
const manifest = buildTestManifest({
|
|
331
|
-
contents: [
|
|
332
|
-
{
|
|
333
|
-
path: "workspace/data/db/assistant.db",
|
|
334
|
-
sha256: "0".repeat(64),
|
|
335
|
-
size_bytes: 8,
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
path: archivePath,
|
|
339
|
-
sha256: "0".repeat(64),
|
|
340
|
-
size_bytes: 0,
|
|
341
|
-
link_target: linkTarget,
|
|
342
|
-
},
|
|
343
|
-
],
|
|
344
|
-
});
|
|
345
|
-
const entries = new Map<string, VBundleTarEntry>([
|
|
346
|
-
[
|
|
347
|
-
"workspace/data/db/assistant.db",
|
|
348
|
-
{
|
|
349
|
-
name: "workspace/data/db/assistant.db",
|
|
350
|
-
data: new TextEncoder().encode("db-bytes"),
|
|
351
|
-
size: 8,
|
|
352
|
-
},
|
|
353
|
-
],
|
|
354
|
-
[
|
|
355
|
-
archivePath,
|
|
356
|
-
{
|
|
357
|
-
name: archivePath,
|
|
358
|
-
data: new Uint8Array(0),
|
|
359
|
-
size: 0,
|
|
360
|
-
linkname: linkTarget,
|
|
361
|
-
},
|
|
362
|
-
],
|
|
363
|
-
]);
|
|
364
|
-
|
|
365
|
-
// Resolver returns the customized guardian persona path for prompts/USER.md.
|
|
366
|
-
const resolver = new DefaultPathResolver(
|
|
367
|
-
workspaceDir,
|
|
368
|
-
undefined,
|
|
369
|
-
() => guardianPath,
|
|
370
|
-
);
|
|
371
|
-
|
|
372
|
-
const result = commitImport({
|
|
373
|
-
archiveData: new Uint8Array(0),
|
|
374
|
-
pathResolver: resolver,
|
|
375
|
-
preValidatedManifest: manifest,
|
|
376
|
-
preValidatedEntries: entries,
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
expect(result.ok).toBe(true);
|
|
380
|
-
if (!result.ok) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// The customized persona file must remain a regular file (NOT a symlink).
|
|
385
|
-
const stat = lstatSync(guardianPath);
|
|
386
|
-
expect(stat.isSymbolicLink()).toBe(false);
|
|
387
|
-
expect(stat.isFile()).toBe(true);
|
|
388
|
-
expect(readFileSync(guardianPath, "utf-8")).toBe(customizedPersona);
|
|
389
|
-
|
|
390
|
-
// The import report must record the entry as skipped.
|
|
391
|
-
const entry = result.report.files.find((f) => f.path === archivePath);
|
|
392
|
-
expect(entry).toBeDefined();
|
|
393
|
-
expect(entry!.action).toBe("skipped");
|
|
394
|
-
|
|
395
|
-
// Warning should mention the customized guardian persona.
|
|
396
|
-
expect(
|
|
397
|
-
result.report.warnings.some(
|
|
398
|
-
(w) =>
|
|
399
|
-
w.includes("guardian persona") && w.includes("already customized"),
|
|
400
|
-
),
|
|
401
|
-
).toBe(true);
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
test("symlink-overwrites-symlink: replaces an existing symlink without EEXIST", () => {
|
|
405
|
-
const archivePath = "workspace/skills/foo.md";
|
|
406
|
-
const linkTarget = "bar.md";
|
|
407
|
-
|
|
408
|
-
const manifest = buildTestManifest({
|
|
409
|
-
contents: [
|
|
410
|
-
{
|
|
411
|
-
path: "workspace/data/db/assistant.db",
|
|
412
|
-
sha256: "0".repeat(64),
|
|
413
|
-
size_bytes: 8,
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
path: archivePath,
|
|
417
|
-
sha256: "0".repeat(64),
|
|
418
|
-
size_bytes: 0,
|
|
419
|
-
link_target: linkTarget,
|
|
420
|
-
},
|
|
421
|
-
],
|
|
422
|
-
});
|
|
423
|
-
const entries = new Map<string, VBundleTarEntry>([
|
|
424
|
-
[
|
|
425
|
-
"workspace/data/db/assistant.db",
|
|
426
|
-
{
|
|
427
|
-
name: "workspace/data/db/assistant.db",
|
|
428
|
-
data: new TextEncoder().encode("db-bytes"),
|
|
429
|
-
size: 8,
|
|
430
|
-
},
|
|
431
|
-
],
|
|
432
|
-
[
|
|
433
|
-
archivePath,
|
|
434
|
-
{
|
|
435
|
-
name: archivePath,
|
|
436
|
-
data: new Uint8Array(0),
|
|
437
|
-
size: 0,
|
|
438
|
-
linkname: linkTarget,
|
|
439
|
-
},
|
|
440
|
-
],
|
|
441
|
-
]);
|
|
442
|
-
|
|
443
|
-
// Pre-create a different symlink at the target path.
|
|
444
|
-
const fooDiskPath = join(workspaceDir, "skills/foo.md");
|
|
445
|
-
mkdirSync(dirname(fooDiskPath), { recursive: true });
|
|
446
|
-
symlinkSync("other.md", fooDiskPath);
|
|
447
|
-
|
|
448
|
-
const result = commitImport({
|
|
449
|
-
archiveData: new Uint8Array(0),
|
|
450
|
-
pathResolver: makePathResolver(),
|
|
451
|
-
preValidatedManifest: manifest,
|
|
452
|
-
preValidatedEntries: entries,
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
expect(result.ok).toBe(true);
|
|
456
|
-
if (!result.ok) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
expect(lstatSync(fooDiskPath).isSymbolicLink()).toBe(true);
|
|
461
|
-
expect(readlinkSync(fooDiskPath)).toBe("bar.md");
|
|
462
|
-
});
|
|
463
|
-
});
|