vault-cortex 0.10.3 → 0.10.5

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/README.md CHANGED
@@ -49,9 +49,9 @@ What it does:
49
49
  - **Remote** — a VPS with [Obsidian Sync](https://obsidian.md/sync),
50
50
  reachable from any device
51
51
  2. Offers the most common optional settings — memory layer and folder,
52
- daily notes folder and format, file tools, semantic search, port,
53
- timezone (plus sync direction for remote) — press enter to keep the
54
- defaults, or pick the ones you want to change
52
+ daily notes folder and format, file tools, read-only mode, semantic
53
+ search, port, timezone (plus sync direction for remote) — press enter
54
+ to keep the defaults, or pick the ones you want to change
55
55
  3. Generates a `.env` file with a securely generated `MCP_AUTH_TOKEN`
56
56
  4. Optionally starts the container and waits for the health check
57
57
  5. Prints your connection details — the MCP URL, your auth token, and how to
package/dist/env.js CHANGED
@@ -58,6 +58,15 @@ MEMORY_ENABLED=true
58
58
  # Enable or disable file tools — vault_read_file and vault_list_files (default: true).
59
59
  # Set to false when Obsidian Sync has attachment syncing disabled.
60
60
  FILE_TOOLS_ENABLED=true
61
+ # Run the server in read-only mode (default: false).
62
+ # Set to true to hide every tool that changes the vault — clients can only
63
+ # read and search. The memory folder is not auto-created in this mode.
64
+ READONLY_MODE=false
65
+ # Hide individual tools by name, comma-separated (default: none hidden).
66
+ # Names match the README tools table: https://github.com/aliasunder/vault-cortex#tools
67
+ # Subtractive only — it cannot re-enable a tool another setting hides; an
68
+ # unknown tool name stops the server at startup so typos surface immediately.
69
+ # DISABLED_TOOLS=vault_delete_note,vault_move_note
61
70
  # Memory folder name in your vault (default: About Me).
62
71
  MEMORY_DIR=About Me
63
72
 
@@ -160,6 +169,15 @@ MEMORY_ENABLED=true
160
169
  # Enable or disable file tools — vault_read_file and vault_list_files (default: true).
161
170
  # Set to false when Obsidian Sync has attachment syncing disabled.
162
171
  FILE_TOOLS_ENABLED=true
172
+ # Run the server in read-only mode (default: false).
173
+ # Set to true to hide every tool that changes the vault — clients can only
174
+ # read and search. The memory folder is not auto-created in this mode.
175
+ READONLY_MODE=false
176
+ # Hide individual tools by name, comma-separated (default: none hidden).
177
+ # Names match the README tools table: https://github.com/aliasunder/vault-cortex#tools
178
+ # Subtractive only — it cannot re-enable a tool another setting hides; an
179
+ # unknown tool name stops the server at startup so typos surface immediately.
180
+ # DISABLED_TOOLS=vault_delete_note,vault_move_note
163
181
  # Memory folder name in your vault (default: About Me).
164
182
  MEMORY_DIR=About Me
165
183
 
package/dist/init.js CHANGED
@@ -154,8 +154,9 @@ const reportWrites = (params, prompts) => {
154
154
  /**
155
155
  * Offers to start the container, walking a gate ladder where each failed
156
156
  * gate degrades to instructions instead of an error: daemon running → user
157
- * consents → docker run succeeds → health check passes. Returns true only
158
- * when the server is confirmed up.
157
+ * consents → docker run succeeds → health check passes. Returns "running"
158
+ * when the server is confirmed up, "starting" when the container launched
159
+ * but the health check timed out, or "not-started" when a gate failed.
159
160
  */
160
161
  const offerDockerRun = async (params, deps) => {
161
162
  const { targetDir, port, mode, vaultPath } = params;
@@ -168,11 +169,11 @@ const offerDockerRun = async (params, deps) => {
168
169
  nextStep: `\nThen start the server with:\n ${startHint}`,
169
170
  })
170
171
  : buildDaemonNotRunningMessage(`, then run:\n ${startHint}`));
171
- return false;
172
+ return "not-started";
172
173
  }
173
174
  const startNow = await prompts.confirm("Start the server now?", true);
174
175
  if (!startNow)
175
- return false;
176
+ return "not-started";
176
177
  const containerStarted = docker.dockerRun({
177
178
  mode,
178
179
  envFilePath: join(targetDir, ".env"),
@@ -181,7 +182,7 @@ const offerDockerRun = async (params, deps) => {
181
182
  });
182
183
  if (!containerStarted) {
183
184
  prompts.error("docker run failed — see output above.");
184
- return false;
185
+ return "not-started";
185
186
  }
186
187
  const spinner = prompts.spinner();
187
188
  spinner.start("Waiting for the server to come up (first run may take a moment)");
@@ -189,10 +190,10 @@ const offerDockerRun = async (params, deps) => {
189
190
  const healthy = await pollHealth({ url: `http://127.0.0.1:${port}/healthz`, timeoutMs }, fetchFn);
190
191
  if (!healthy) {
191
192
  spinner.stop(healthTimeoutMessage(mode, timeoutMs));
192
- return false;
193
+ return "starting";
193
194
  }
194
195
  spinner.stop("Server is up — health check passed.");
195
- return true;
196
+ return "running";
196
197
  };
197
198
  // Local flow: resolve vault path → resolve target dir → generate token →
198
199
  // write .env → optionally start the container → print connect instructions.
@@ -271,10 +272,16 @@ const runLocalInit = async (flags, deps) => {
271
272
  prompts.log("Generated MCP auth token (saved to .env).");
272
273
  const port = readEnvPort(join(targetDir, ".env"));
273
274
  // --yes is for scripts/CI, so it never starts Docker.
274
- const started = flags.yes
275
- ? false
275
+ const startStatus = flags.yes
276
+ ? "not-started"
276
277
  : await offerDockerRun({ targetDir, port, mode: "local", vaultPath }, deps);
277
- prompts.print(buildLocalConnectMessage({ targetDir, token, started, port, tokenWritten }));
278
+ prompts.print(buildLocalConnectMessage({
279
+ targetDir,
280
+ token,
281
+ startStatus,
282
+ port,
283
+ tokenWritten,
284
+ }));
278
285
  return 0;
279
286
  };
280
287
  // Remote flow (VPS + Obsidian Sync): resolve target dir → PUBLIC_URL →
@@ -347,12 +354,12 @@ const runRemoteInit = async (flags, deps) => {
347
354
  const effectivePublicUrl = readEnvPublicUrl(join(targetDir, ".env")) ?? publicUrl;
348
355
  // Without the sync token the container can't start (init-check-auth fails
349
356
  // and s6 stops it), so only offer docker run when it was provided.
350
- const started = obsidianAuthToken === ""
351
- ? false
357
+ const startStatus = obsidianAuthToken === ""
358
+ ? "not-started"
352
359
  : await offerDockerRun({ targetDir, port, mode: "remote" }, deps);
353
360
  // The container check above hit localhost on this machine; the public URL
354
361
  // is the ingress path clients actually use — probe it too, informationally.
355
- if (started) {
362
+ if (startStatus === "running") {
356
363
  await reportPublicUrlProbe(effectivePublicUrl, {
357
364
  prompts,
358
365
  fetchFn: deps.fetchFn,
@@ -362,7 +369,7 @@ const runRemoteInit = async (flags, deps) => {
362
369
  targetDir,
363
370
  token,
364
371
  publicUrl: effectivePublicUrl,
365
- started,
372
+ startStatus,
366
373
  obsidianTokenMissing: obsidianAuthToken === "",
367
374
  tokenWritten,
368
375
  }));
package/dist/messages.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { styleText } from "node:util";
2
+ import { CONTAINER_NAME } from "./docker.js";
2
3
  // Strip styling when stdout isn't a color TTY (piped output, CI) or NO_COLOR
3
4
  // is set (any value, including empty — per the NO_COLOR spec) so
4
5
  // captured/redirected output stays plain — no stray escape codes in copied
@@ -50,11 +51,14 @@ const upgradeCommand = (targetDir) => `npx vault-cortex@latest upgrade --dir "${
50
51
  // have. `start` runs the same re-create cycle and pulls the image on demand.
51
52
  export const startCommand = (targetDir) => `npx vault-cortex@latest start --dir "${targetDir}"`;
52
53
  const startServerLine = (targetDir) => `Start the server:\n ${startCommand(targetDir)}`;
53
- /** Remote start line: running, blocked on the missing sync token, or ready to start. */
54
+ const startingInBackgroundLine = () => `The server is starting in the background check progress:\n docker logs ${CONTAINER_NAME}`;
55
+ /** Remote start line: running, starting, blocked on the missing sync token, or ready to start. */
54
56
  const remoteStartLine = (params) => {
55
- const { targetDir, started, obsidianTokenMissing } = params;
56
- if (started)
57
+ const { targetDir, startStatus, obsidianTokenMissing } = params;
58
+ if (startStatus === "running")
57
59
  return "The server is running.";
60
+ if (startStatus === "starting")
61
+ return startingInBackgroundLine();
58
62
  if (obsidianTokenMissing) {
59
63
  return `Fill in OBSIDIAN_AUTH_TOKEN in ${targetDir}/.env, then start the server:\n ${startCommand(targetDir)}`;
60
64
  }
@@ -99,13 +103,14 @@ const curlGuidance = (mcpUrl) => `Clients without OAuth, scripts, and curl send
99
103
  const smokeTest = (healthUrl) => `Smoke test:
100
104
  curl ${healthUrl}`;
101
105
  /**
102
- * Remote health-check block. Started: the CLI verified localhost on the VPS,
103
- * but the public URL is a different check (ingress DNS, TLS, proxy), so the
104
- * command stays, reworded as the works-from-any-device check. Not started:
105
- * the plain smoke test to run after starting.
106
+ * Remote health-check block. Running or starting: the CLI verified localhost
107
+ * on the VPS (or the container is still coming up), but the public URL is a
108
+ * different check (ingress — DNS, TLS, proxy), so the command stays, reworded
109
+ * as the works-from-any-device check. Not started: the plain smoke test to
110
+ * run after starting.
106
111
  */
107
- const remoteHealthCheckBlock = (healthUrl, started) => {
108
- if (started) {
112
+ const remoteHealthCheckBlock = (healthUrl, startStatus) => {
113
+ if (startStatus === "running" || startStatus === "starting") {
109
114
  return `Health check — works from any device that can reach the URL:
110
115
  curl ${healthUrl}`;
111
116
  }
@@ -119,18 +124,20 @@ const updateGuidance = (targetDir) => `Update to the latest release:
119
124
  * actually run.
120
125
  */
121
126
  export const buildLocalConnectMessage = (params) => {
122
- const { targetDir, token, started, port, tokenWritten } = params;
127
+ const { targetDir, token, startStatus, port, tokenWritten } = params;
123
128
  const baseUrl = `http://localhost:${port}`;
124
- const startLine = started
129
+ const startLine = startStatus === "running"
125
130
  ? "The server is running."
126
- : startServerLine(targetDir);
131
+ : startStatus === "starting"
132
+ ? startingInBackgroundLine()
133
+ : startServerLine(targetDir);
127
134
  const tokenLine = tokenBlock({ targetDir, token, tokenWritten });
128
135
  // Once the server is confirmed up, the smoke test is dropped — the CLI just
129
136
  // verified this exact URL, so re-printing it reads as leftover homework.
130
137
  // Assembled as a filtered list so the omission leaves no stray blank line.
131
138
  const nonOauthBlocks = [
132
139
  curlGuidance(`${baseUrl}/mcp`),
133
- started ? undefined : smokeTest(`${baseUrl}/healthz`),
140
+ startStatus === "running" ? undefined : smokeTest(`${baseUrl}/healthz`),
134
141
  ]
135
142
  .filter(Boolean)
136
143
  .join("\n\n");
@@ -187,10 +194,10 @@ ${bottomRule()}`;
187
194
  * handling here.
188
195
  */
189
196
  export const buildRemoteConnectMessage = (params) => {
190
- const { targetDir, token, publicUrl, started, obsidianTokenMissing, tokenWritten, } = params;
197
+ const { targetDir, token, publicUrl, startStatus, obsidianTokenMissing, tokenWritten, } = params;
191
198
  const startLine = remoteStartLine({
192
199
  targetDir,
193
- started,
200
+ startStatus,
194
201
  obsidianTokenMissing,
195
202
  });
196
203
  const tokenLine = tokenBlock({ targetDir, token, tokenWritten });
@@ -227,7 +234,7 @@ ${sectionRule("Non-OAuth")}
227
234
 
228
235
  ${curlGuidance(`${publicUrl}/mcp`)}
229
236
 
230
- ${remoteHealthCheckBlock(`${publicUrl}/healthz`, started)}
237
+ ${remoteHealthCheckBlock(`${publicUrl}/healthz`, startStatus)}
231
238
 
232
239
  ${sectionRule("Settings")}
233
240
 
@@ -37,6 +37,13 @@ const OPTIONAL_SETTINGS = [
37
37
  label: "File tools",
38
38
  question: "Enable file tools (read images, PDFs, and other non-Markdown files)?",
39
39
  },
40
+ {
41
+ kind: "toggle",
42
+ name: "READONLY_MODE",
43
+ label: "Read-only mode",
44
+ question: "Run the server in read-only mode (hide all tools that change the vault)?",
45
+ defaultEnabled: false,
46
+ },
40
47
  {
41
48
  kind: "toggle",
42
49
  name: "EMBEDDING_ENABLED",
@@ -127,11 +134,12 @@ export const derivePublicUrlOverride = (envContent, overrides) => {
127
134
  return { ...overrides, PUBLIC_URL: `http://localhost:${newPort}` };
128
135
  };
129
136
  /**
130
- * The .env spellings the server reads as "off" — env-var's asBool accepts
131
- * 0/1 alongside true/false. An absent or unrecognized value falls to the
132
- * server default, which is enabled for every curated toggle.
137
+ * True unless the .env value is an explicit "off" spelling — env-var's asBool
138
+ * accepts 0/1 alongside true/false. An absent or unrecognized value falls to
139
+ * the server default, declared per-toggle via defaultEnabled (enabled unless
140
+ * stated otherwise).
133
141
  */
134
- const isDisabledToggleValue = (value) => ["false", "0"].includes((value ?? "").toLowerCase());
142
+ const isEnabledToggleValue = (value) => !["false", "0"].includes((value ?? "").toLowerCase());
135
143
  /**
136
144
  * Plain digits in the TCP port range. Number() coercion is not enough:
137
145
  * it accepts "1e4"/"0x1F40"/"+9000", which readEnvPort's /^PORT=(\d+)/
@@ -222,7 +230,15 @@ const askSettingValue = async (params, prompts) => {
222
230
  const { setting, currentValue } = params;
223
231
  switch (setting.kind) {
224
232
  case "toggle": {
225
- const enabled = await prompts.confirm(setting.question, !isDisabledToggleValue(currentValue));
233
+ // An unset or empty var means the server default applies — seed the
234
+ // confirm from defaultEnabled, not from the enabled-unless-"false"
235
+ // heuristic (wrong for default-off toggles like READONLY_MODE).
236
+ // Empty string matters: `READONLY_MODE=` in .env is read as unset
237
+ // by Compose's `${VAR:-default}` and env-var's `.default()`.
238
+ const currentlyEnabled = !currentValue
239
+ ? (setting.defaultEnabled ?? true)
240
+ : isEnabledToggleValue(currentValue);
241
+ const enabled = await prompts.confirm(setting.question, currentlyEnabled);
226
242
  return String(enabled);
227
243
  }
228
244
  case "port":
@@ -258,7 +274,7 @@ export const askOptionalSettings = async (params, prompts) => {
258
274
  const currentValue = readOptionalValue(envContent, setting.name);
259
275
  const requiredToggle = OPTIONAL_SETTINGS.find((candidate) => candidate.name === setting.requiresToggle);
260
276
  const dependencyNote = requiredToggle &&
261
- isDisabledToggleValue(readOptionalValue(envContent, requiredToggle.name))
277
+ !isEnabledToggleValue(readOptionalValue(envContent, requiredToggle.name))
262
278
  ? ` · not used while ${requiredToggle.label} is off`
263
279
  : "";
264
280
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vault-cortex",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "Set up a Vault Cortex MCP server for your Obsidian vault in one command: npx vault-cortex@latest init",
5
5
  "license": "MIT",
6
6
  "type": "module",