@openparachute/vault 0.6.4 → 0.6.5-rc.10

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.
Files changed (53) hide show
  1. package/core/src/__fixtures__/golden-vault.ts +125 -0
  2. package/core/src/__fixtures__/portable-export-golden.json +10 -0
  3. package/core/src/do-param-cap.test.ts +161 -0
  4. package/core/src/links.ts +8 -13
  5. package/core/src/mcp.ts +306 -314
  6. package/core/src/notes.ts +54 -62
  7. package/core/src/onboarding.ts +14 -296
  8. package/core/src/portable-md-batching.test.ts +67 -0
  9. package/core/src/portable-md-golden.test.ts +55 -0
  10. package/core/src/portable-md.ts +579 -435
  11. package/core/src/schema.ts +21 -43
  12. package/core/src/seed-packs.test.ts +191 -0
  13. package/core/src/seed-packs.ts +559 -0
  14. package/core/src/sql-in.test.ts +58 -0
  15. package/core/src/sql-in.ts +76 -0
  16. package/core/src/store.ts +14 -9
  17. package/core/src/transcription/provider.ts +141 -0
  18. package/core/src/txn.test.ts +229 -0
  19. package/core/src/txn.ts +105 -0
  20. package/core/src/types.ts +9 -0
  21. package/core/src/vault-projection.ts +1 -1
  22. package/core/src/wikilinks.ts +10 -4
  23. package/package.json +1 -1
  24. package/src/add-pack.test.ts +142 -0
  25. package/src/cli.ts +778 -7
  26. package/src/onboarding-seed.test.ts +126 -40
  27. package/src/onboarding-seed.ts +41 -46
  28. package/src/routes.ts +25 -7
  29. package/src/server.ts +108 -31
  30. package/src/transcription/build.test.ts +224 -0
  31. package/src/transcription/build.ts +252 -0
  32. package/src/transcription/capability.test.ts +118 -0
  33. package/src/transcription/capability.ts +96 -0
  34. package/src/transcription/install-python.test.ts +366 -0
  35. package/src/transcription/install-python.ts +471 -0
  36. package/src/transcription/install.test.ts +167 -0
  37. package/src/transcription/install.ts +296 -0
  38. package/src/transcription/providers/onnx-asr.test.ts +229 -0
  39. package/src/transcription/providers/onnx-asr.ts +239 -0
  40. package/src/transcription/providers/parakeet-mlx.test.ts +290 -0
  41. package/src/transcription/providers/parakeet-mlx.ts +242 -0
  42. package/src/transcription/providers/scribe-http.test.ts +195 -0
  43. package/src/transcription/providers/scribe-http.ts +144 -0
  44. package/src/transcription/providers/transcribe-cpp.test.ts +314 -0
  45. package/src/transcription/providers/transcribe-cpp.ts +293 -0
  46. package/src/transcription/select.test.ts +259 -0
  47. package/src/transcription/select.ts +334 -0
  48. package/src/transcription/tiers.test.ts +197 -0
  49. package/src/transcription/tiers.ts +184 -0
  50. package/src/transcription-worker.test.ts +44 -0
  51. package/src/transcription-worker.ts +57 -122
  52. package/src/vault-create.test.ts +38 -10
  53. package/src/vault.test.ts +48 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Integration tests for `parachute-vault add-pack <pack> [--vault <name>]`.
3
+ *
4
+ * Spawns the CLI in a temp `PARACHUTE_HOME` (same harness shape as
5
+ * vault-create.test.ts). Covers: listing on no-arg / unknown pack, applying
6
+ * `surface-starter` onto a default-seeded vault, idempotent re-runs, the
7
+ * missing-vault error, and `--vault` targeting.
8
+ *
9
+ * No in-test `Bun.serve` is involved, so `Bun.spawnSync` is fine here (see
10
+ * CLAUDE.md "Subprocess tests + Bun.serve").
11
+ */
12
+
13
+ import { describe, test, expect, beforeEach, afterEach } from "bun:test";
14
+ import { Database } from "bun:sqlite";
15
+ import { resolve } from "path";
16
+ import { mkdtempSync, rmSync } from "fs";
17
+ import { tmpdir } from "os";
18
+ import { join } from "path";
19
+
20
+ const CLI = resolve(import.meta.dir, "cli.ts");
21
+
22
+ function runCli(
23
+ args: string[],
24
+ env: Record<string, string>,
25
+ ): { exitCode: number; stdout: string; stderr: string } {
26
+ // Hermetic: don't inherit the dev/CI box's PARACHUTE_HUB_ORIGIN (see
27
+ // vault-create.test.ts for the rationale).
28
+ const baseEnv: Record<string, string | undefined> = { ...process.env };
29
+ delete baseEnv.PARACHUTE_HUB_ORIGIN;
30
+ const proc = Bun.spawnSync({
31
+ cmd: ["bun", CLI, ...args],
32
+ stdout: "pipe",
33
+ stderr: "pipe",
34
+ env: { ...baseEnv, ...env },
35
+ });
36
+ return {
37
+ exitCode: proc.exitCode ?? -1,
38
+ stdout: new TextDecoder().decode(proc.stdout),
39
+ stderr: new TextDecoder().decode(proc.stderr),
40
+ };
41
+ }
42
+
43
+ /** Read all note paths from a vault's SQLite DB inside the temp home. */
44
+ function readNotePaths(home: string, name: string): (string | null)[] {
45
+ const db = new Database(join(home, "vault", "data", name, "vault.db"), {
46
+ readonly: true,
47
+ });
48
+ try {
49
+ return (db.query("SELECT path FROM notes").all() as { path: string | null }[]).map(
50
+ (r) => r.path,
51
+ );
52
+ } finally {
53
+ db.close();
54
+ }
55
+ }
56
+
57
+ let home: string;
58
+
59
+ beforeEach(() => {
60
+ home = mkdtempSync(join(tmpdir(), "add-pack-test-"));
61
+ });
62
+
63
+ afterEach(() => {
64
+ rmSync(home, { recursive: true, force: true });
65
+ });
66
+
67
+ describe("add-pack — listing + errors", () => {
68
+ test("no arguments → usage + the three packs, exit 1", () => {
69
+ const { exitCode, stderr } = runCli(["add-pack"], { PARACHUTE_HOME: home });
70
+ expect(exitCode).toBe(1);
71
+ expect(stderr).toContain("Usage: parachute-vault add-pack");
72
+ expect(stderr).toContain("Available packs:");
73
+ expect(stderr).toContain("welcome");
74
+ expect(stderr).toContain("getting-started");
75
+ expect(stderr).toContain("surface-starter");
76
+ });
77
+
78
+ test("unknown pack → error + listing, exit 1", () => {
79
+ const { exitCode, stderr } = runCli(["add-pack", "does-not-exist"], {
80
+ PARACHUTE_HOME: home,
81
+ });
82
+ expect(exitCode).toBe(1);
83
+ expect(stderr).toContain('Unknown pack: "does-not-exist"');
84
+ expect(stderr).toContain("Available packs:");
85
+ });
86
+
87
+ test("missing vault → actionable error, exit 1", () => {
88
+ const { exitCode, stderr } = runCli(
89
+ ["add-pack", "surface-starter", "--vault", "ghost"],
90
+ { PARACHUTE_HOME: home },
91
+ );
92
+ expect(exitCode).toBe(1);
93
+ expect(stderr).toContain('Vault "ghost" not found');
94
+ expect(stderr).toContain("parachute-vault create ghost");
95
+ });
96
+ });
97
+
98
+ describe("add-pack surface-starter", () => {
99
+ test("applies onto a default-seeded vault and reports what was added", () => {
100
+ expect(runCli(["create", "packed", "--json"], { PARACHUTE_HOME: home }).exitCode).toBe(0);
101
+ // Default seed does NOT include Surface Starter.
102
+ expect(readNotePaths(home, "packed")).not.toContain("Surface Starter");
103
+
104
+ const { exitCode, stdout } = runCli(
105
+ ["add-pack", "surface-starter", "--vault", "packed"],
106
+ { PARACHUTE_HOME: home },
107
+ );
108
+ expect(exitCode).toBe(0);
109
+ expect(stdout).toContain('Pack "surface-starter" applied to vault "packed"');
110
+ expect(stdout).toContain("+ note Surface Starter");
111
+ expect(readNotePaths(home, "packed")).toContain("Surface Starter");
112
+ });
113
+
114
+ test("idempotent: a re-run skips (exit 0) and doesn't duplicate", () => {
115
+ runCli(["create", "packed", "--json"], { PARACHUTE_HOME: home });
116
+ runCli(["add-pack", "surface-starter", "--vault", "packed"], { PARACHUTE_HOME: home });
117
+
118
+ const { exitCode, stdout } = runCli(
119
+ ["add-pack", "surface-starter", "--vault", "packed"],
120
+ { PARACHUTE_HOME: home },
121
+ );
122
+ expect(exitCode).toBe(0);
123
+ expect(stdout).toContain("= note Surface Starter (already exists — left untouched)");
124
+ expect(stdout).not.toContain("+ note");
125
+
126
+ const paths = readNotePaths(home, "packed");
127
+ expect(paths.filter((p) => p === "Surface Starter")).toHaveLength(1);
128
+ });
129
+
130
+ test("re-applying a default pack is a clean no-op-style run (welcome on a fresh vault)", () => {
131
+ runCli(["create", "packed", "--json"], { PARACHUTE_HOME: home });
132
+ const { exitCode, stdout } = runCli(
133
+ ["add-pack", "welcome", "--vault", "packed"],
134
+ { PARACHUTE_HOME: home },
135
+ );
136
+ expect(exitCode).toBe(0);
137
+ // Notes were already default-seeded → all skipped; tags re-upsert.
138
+ expect(stdout).not.toContain("+ note");
139
+ expect(stdout).toContain("= note Welcome to your vault 🪂 (already exists — left untouched)");
140
+ expect(stdout).toContain("~ tag capture (upserted)");
141
+ });
142
+ });