@openparachute/vault 0.6.0-rc.1 → 0.6.1

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 (99) hide show
  1. package/.parachute/module.json +14 -3
  2. package/README.md +32 -7
  3. package/core/src/content-range.test.ts +374 -0
  4. package/core/src/content-range.ts +185 -0
  5. package/core/src/core.test.ts +279 -26
  6. package/core/src/expand-visibility.test.ts +102 -0
  7. package/core/src/expand.ts +31 -3
  8. package/core/src/indexed-fields.ts +1 -1
  9. package/core/src/link-count.test.ts +301 -0
  10. package/core/src/links.ts +172 -22
  11. package/core/src/mcp.ts +254 -34
  12. package/core/src/notes.ts +172 -48
  13. package/core/src/obsidian-alignment.test.ts +375 -0
  14. package/core/src/obsidian.ts +234 -14
  15. package/core/src/portable-md.test.ts +40 -0
  16. package/core/src/portable-md.ts +142 -16
  17. package/core/src/query-perf-routing.test.ts +208 -0
  18. package/core/src/schema.ts +87 -11
  19. package/core/src/store.ts +69 -22
  20. package/core/src/tag-expand-axis.test.ts +301 -0
  21. package/core/src/tag-hierarchy.ts +80 -0
  22. package/core/src/tag-schemas.ts +61 -46
  23. package/core/src/triggers-store.test.ts +100 -0
  24. package/core/src/triggers-store.ts +165 -0
  25. package/core/src/types.ts +68 -4
  26. package/core/src/vault-projection.ts +20 -0
  27. package/core/src/wikilinks.ts +2 -2
  28. package/package.json +2 -3
  29. package/src/admin-spa.test.ts +100 -10
  30. package/src/admin-spa.ts +48 -3
  31. package/src/auth-hub-jwt.test.ts +8 -1
  32. package/src/auth-status.ts +2 -2
  33. package/src/auth.test.ts +39 -3
  34. package/src/auth.ts +31 -2
  35. package/src/auto-transcribe.test.ts +51 -0
  36. package/src/auto-transcribe.ts +24 -6
  37. package/src/autostart.test.ts +75 -0
  38. package/src/autostart.ts +84 -0
  39. package/src/cli.ts +434 -140
  40. package/src/config.test.ts +109 -0
  41. package/src/config.ts +157 -10
  42. package/src/content-range-routes.test.ts +178 -0
  43. package/src/export-watch.test.ts +23 -0
  44. package/src/export-watch.ts +14 -0
  45. package/src/git-preflight.test.ts +70 -0
  46. package/src/git-preflight.ts +68 -0
  47. package/src/github-device-flow.test.ts +265 -6
  48. package/src/github-device-flow.ts +297 -45
  49. package/src/hub-jwt.test.ts +75 -2
  50. package/src/hub-jwt.ts +43 -6
  51. package/src/init-summary.test.ts +120 -5
  52. package/src/init-summary.ts +67 -25
  53. package/src/live-match.test.ts +198 -0
  54. package/src/live-match.ts +310 -0
  55. package/src/mcp-install.test.ts +93 -0
  56. package/src/mcp-install.ts +106 -0
  57. package/src/mcp-tools.ts +80 -7
  58. package/src/mirror-config.test.ts +14 -0
  59. package/src/mirror-config.ts +11 -0
  60. package/src/mirror-credentials.test.ts +20 -0
  61. package/src/mirror-credentials.ts +6 -2
  62. package/src/mirror-import.test.ts +110 -0
  63. package/src/mirror-import.ts +71 -13
  64. package/src/mirror-manager.test.ts +51 -0
  65. package/src/mirror-manager.ts +73 -11
  66. package/src/mirror-routes.test.ts +1331 -110
  67. package/src/mirror-routes.ts +787 -30
  68. package/src/oauth-discovery.test.ts +55 -0
  69. package/src/oauth-discovery.ts +24 -5
  70. package/src/routes.ts +763 -122
  71. package/src/routing.test.ts +451 -5
  72. package/src/routing.ts +121 -5
  73. package/src/scopes.ts +1 -1
  74. package/src/server.ts +66 -4
  75. package/src/storage.test.ts +162 -0
  76. package/src/subscribe.test.ts +588 -0
  77. package/src/subscribe.ts +248 -0
  78. package/src/subscriptions.ts +295 -0
  79. package/src/tag-expand-routes.test.ts +45 -0
  80. package/src/tag-scope.ts +68 -1
  81. package/src/token-store.ts +7 -7
  82. package/src/transcription-worker.test.ts +471 -5
  83. package/src/transcription-worker.ts +212 -44
  84. package/src/triggers-api.test.ts +533 -0
  85. package/src/triggers-api.ts +295 -0
  86. package/src/triggers.ts +93 -7
  87. package/src/usage.test.ts +362 -0
  88. package/src/usage.ts +318 -0
  89. package/src/vault-create.test.ts +340 -12
  90. package/src/vault-name.test.ts +61 -3
  91. package/src/vault-name.ts +62 -14
  92. package/src/vault-remove.test.ts +187 -0
  93. package/src/vault-store.ts +10 -3
  94. package/src/vault.test.ts +1353 -62
  95. package/web/ui/dist/assets/index-BPgyIjR7.js +61 -0
  96. package/web/ui/dist/assets/index-J0pVP7I-.css +1 -0
  97. package/web/ui/dist/index.html +2 -2
  98. package/web/ui/dist/assets/index-DBe8Xiah.css +0 -1
  99. package/web/ui/dist/assets/index-DDRo6F4u.js +0 -60
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Decide whether `parachute-vault init` should register a boot/restart daemon
3
+ * (launchd on macOS, systemd on Linux).
4
+ *
5
+ * Pure: extracted so the flag × persisted-config × hub-presence matrix can be
6
+ * unit-tested without spawning the CLI or touching launchd/systemd. The caller
7
+ * passes in the resolved `hubPresent` signal (from `detectHubPresence`) so this
8
+ * function stays side-effect-free.
9
+ *
10
+ * Why hub-presence flips the default (ParachuteComputer/parachute-hub#580):
11
+ * under hub-as-supervisor the hub owns the vault lifecycle — it spawns vault as
12
+ * a supervised child. If init *also* registers a launchd/systemd unit with
13
+ * `KeepAlive`/`RunAtLoad`, two lifecycles race for :1940: the supervisor's
14
+ * child and the platform manager's respawn. `parachute stop` kills the
15
+ * supervised one, launchd resurrects the other (EADDRINUSE crash-loop, pidfile
16
+ * records the loser, the rogue holds the port with no injected
17
+ * PARACHUTE_HUB_ORIGIN → iss mismatch). Defaulting autostart OFF when a hub is
18
+ * present makes the standalone daemon an explicit opt-in.
19
+ *
20
+ * Precedence (first match wins):
21
+ * 1. `--no-autostart` on this run → off (persisted; safer-default
22
+ * precedence beats --autostart)
23
+ * 2. `--autostart` on this run → on (persisted; operator
24
+ * override — caller warns if a
25
+ * supervised hub was detected)
26
+ * 3. Existing `config.autostart` (boolean) → that value (honor prior choice)
27
+ * 4. Hub present, no flag, no persisted value → off (the hub supervisor owns
28
+ * the lifecycle — #580)
29
+ * 5. Default → on (standalone deploys
30
+ * genuinely need a daemon)
31
+ *
32
+ * `persist` is true only when the choice came from an explicit flag (cases 1+2)
33
+ * — matching the prior behavior where a flagless re-run never rewrote the
34
+ * persisted value. The hub-present default (case 4) is intentionally NOT
35
+ * persisted: it's a per-run inference, so a later standalone re-run (no hub)
36
+ * falls back to the register default rather than being stuck off.
37
+ *
38
+ * `overrodeHub` is true only for case 2 when a hub was detected — the signal the
39
+ * caller uses to log the "supervised hub detected, registering anyway" warning.
40
+ */
41
+ export interface AutostartDecisionInput {
42
+ /** `--autostart` present on this invocation. */
43
+ flagOn: boolean;
44
+ /** `--no-autostart` present on this invocation. */
45
+ flagOff: boolean;
46
+ /** Persisted `config.autostart` from a prior run, if a boolean. */
47
+ persisted?: boolean | undefined;
48
+ /** Whether a hub supervisor was detected (from `detectHubPresence`). */
49
+ hubPresent: boolean;
50
+ }
51
+
52
+ export interface AutostartDecision {
53
+ /** Final resolved value. */
54
+ enabled: boolean;
55
+ /** Whether the caller should write `config.autostart` to disk. */
56
+ persist: boolean;
57
+ /** True when `--autostart` forced registration despite a detected hub. */
58
+ overrodeHub: boolean;
59
+ /** Which precedence rule decided the outcome (for testing + copy). */
60
+ reason: "flag-off" | "flag-on" | "persisted" | "hub-default-off" | "default-on";
61
+ }
62
+
63
+ export function decideAutostart(input: AutostartDecisionInput): AutostartDecision {
64
+ const { flagOn, flagOff, persisted, hubPresent } = input;
65
+
66
+ if (flagOff) {
67
+ return { enabled: false, persist: true, overrodeHub: false, reason: "flag-off" };
68
+ }
69
+ if (flagOn) {
70
+ return {
71
+ enabled: true,
72
+ persist: true,
73
+ overrodeHub: hubPresent,
74
+ reason: "flag-on",
75
+ };
76
+ }
77
+ if (typeof persisted === "boolean") {
78
+ return { enabled: persisted, persist: false, overrodeHub: false, reason: "persisted" };
79
+ }
80
+ if (hubPresent) {
81
+ return { enabled: false, persist: false, overrodeHub: false, reason: "hub-default-off" };
82
+ }
83
+ return { enabled: true, persist: false, overrodeHub: false, reason: "default-on" };
84
+ }