@clarionstack/notesia 0.2.1 → 0.2.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clarionstack/notesia",
3
3
  "private": false,
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "description": "Notesia desktop bridge CLI — read, write, and bulk-import notes",
6
6
  "type": "module",
7
7
  "files": [
package/src/client.mjs CHANGED
@@ -30,15 +30,23 @@ export function getDefaultBridgeInfoPath({
30
30
 
31
31
  export async function loadBridgeInfo({
32
32
  bridgeInfoPath = getDefaultBridgeInfoPath(),
33
+ readFile = fs.readFile,
33
34
  } = {}) {
34
35
  let raw;
35
36
  try {
36
- raw = await fs.readFile(bridgeInfoPath, 'utf8');
37
+ raw = await readFile(bridgeInfoPath, 'utf8');
37
38
  } catch (error) {
39
+ if (error?.code === 'EPERM' || error?.code === 'EACCES') {
40
+ throw new BridgeClientError(
41
+ 'BRIDGE_ACCESS_DENIED',
42
+ `Permission denied reading Notesia bridge info at ${bridgeInfoPath} (this shell may be sandboxed). Run outside the sandbox or allow access to TMPDIR.`,
43
+ { bridgeInfoPath, causeCode: error.code }
44
+ );
45
+ }
38
46
  if (error?.code === 'ENOENT') {
39
47
  throw new BridgeClientError(
40
48
  'NOTESIA_APP_NOT_RUNNING',
41
- 'Notesia desktop app bridge was not found. Start Notesia and try again.',
49
+ `Notesia desktop app bridge was not found at ${bridgeInfoPath}. Start Notesia and try again (if running in a sandboxed shell with a private TMPDIR, run outside the sandbox).`,
42
50
  { bridgeInfoPath }
43
51
  );
44
52
  }
@@ -137,12 +145,32 @@ export async function requestBridge(request, {
137
145
  });
138
146
 
139
147
  client.on('error', (error) => {
140
- if (error?.code === 'ENOENT' || error?.code === 'ECONNREFUSED') {
148
+ if (error?.code === 'EPERM' || error?.code === 'EACCES') {
149
+ doneReject(
150
+ new BridgeClientError(
151
+ 'BRIDGE_ACCESS_DENIED',
152
+ `Permission denied connecting to Notesia bridge at ${bridgeInfo.socketPath} (this shell may be sandboxed). Run outside the sandbox or allow Unix socket connections.`,
153
+ { socketPath: bridgeInfo.socketPath, causeCode: error.code }
154
+ )
155
+ );
156
+ return;
157
+ }
158
+ if (error?.code === 'ECONNREFUSED') {
159
+ doneReject(
160
+ new BridgeClientError(
161
+ 'NOTESIA_APP_NOT_RUNNING',
162
+ `Notesia bridge socket exists at ${bridgeInfo.socketPath} but connection was refused. Ensure the desktop app is running.`,
163
+ { socketPath: bridgeInfo.socketPath, causeCode: error.code }
164
+ )
165
+ );
166
+ return;
167
+ }
168
+ if (error?.code === 'ENOENT') {
141
169
  doneReject(
142
170
  new BridgeClientError(
143
171
  'NOTESIA_APP_NOT_RUNNING',
144
- 'Unable to connect to Notesia bridge. Ensure the desktop app is running.',
145
- { socketPath: bridgeInfo.socketPath }
172
+ `Unable to connect to Notesia bridge at ${bridgeInfo.socketPath}. Ensure the desktop app is running.`,
173
+ { socketPath: bridgeInfo.socketPath, causeCode: error.code }
146
174
  )
147
175
  );
148
176
  return;
package/src/commands.mjs CHANGED
@@ -273,6 +273,7 @@ export function parseArgs(argv = []) {
273
273
  limit: null,
274
274
  offset: null,
275
275
  threshold: null,
276
+ semantic: false,
276
277
  withMeta: false,
277
278
  query: null,
278
279
  conversationId: null,
@@ -397,6 +398,11 @@ export function parseArgs(argv = []) {
397
398
  continue;
398
399
  }
399
400
 
401
+ if (token === '--semantic') {
402
+ parsed.semantic = true;
403
+ continue;
404
+ }
405
+
400
406
  if (token === '--query') {
401
407
  parsed.query = readFlagValue(args, i);
402
408
  i += 1;
@@ -453,15 +459,15 @@ function usageText() {
453
459
  'Commands:',
454
460
  ' get --id <id>|--supabase-id <uuid>|--title <title> [--json] [--with-meta]',
455
461
  ' list [--limit <count>] [--offset <n>] [--folder-id <id>] [--tag <tag>] [--format table|json]',
456
- ' store [--title <title>] [--tag <tag>]... [--folder-id <id>] [--content <text>]',
457
- ' capture [--title <title>] [--tag <tag>]... [--content <text>] (saves to Inbox)',
458
- ' update --id <id>|--supabase-id <uuid>|--match-title <title> [--content <text>] [--title <new>]',
459
- ' append --id <id>|--supabase-id <uuid>|--match-title <title> [--content <text>]',
460
- ' prepend --id <id>|--supabase-id <uuid>|--match-title <title> [--content <text>]',
461
- ' search <query>|--query <text> [--limit <n>] [--threshold <0-1>] [--format text|json]',
462
- ' move --id <id>|--supabase-id <uuid>|--match-title <title> --folder-id <id> (0 = root)',
462
+ ' store [--title <title>] [--tag <tag>]... [--folder-id <id>] [--content <text>] [--format text|json]',
463
+ ' capture [--title <title>] [--tag <tag>]... [--content <text>] [--format text|json] (saves to Inbox)',
464
+ ' update --id <id>|--supabase-id <uuid>|--match-title <title> [--content <text>] [--title <new>] [--format text|json]',
465
+ ' append --id <id>|--supabase-id <uuid>|--match-title <title> [--content <text>] [--format text|json]',
466
+ ' prepend --id <id>|--supabase-id <uuid>|--match-title <title> [--content <text>] [--format text|json]',
467
+ ' search <query>|--query <text> [--limit <n>] [--threshold <0-1>] [--semantic] [--format text|json]',
468
+ ' move --id <id>|--supabase-id <uuid>|--match-title <title> --folder-id <id> [--format text|json] (0 = root)',
463
469
  ' open --id <id>|--supabase-id <uuid>|--title <title>',
464
- ' trash --id <id>|--supabase-id <uuid>|--match-title <title>',
470
+ ' trash --id <id>|--supabase-id <uuid>|--match-title <title> [--format text|json]',
465
471
  ' tags [--format table|json]',
466
472
  ' tag add --id <id>|--supabase-id <uuid>|--match-title <title> --tag <name> [--tag <name2>]...',
467
473
  ' tag remove --id <id>|--supabase-id <uuid>|--match-title <title> --tag <name> [--tag <name2>]...',
@@ -480,10 +486,10 @@ function usageText() {
480
486
  ' [--format text|json] [--quiet] [--verbose]',
481
487
  '',
482
488
  'AI Knowledge Base:',
483
- ' kb search --query <text> [--limit <n>] [--threshold <0-1>] [--format text|json]',
489
+ ' kb search --query <text> [--limit <n>] [--threshold <0-1>] [--semantic] [--format text|json]',
484
490
  ' kb ask --query <text> [--limit <n>] [--threshold <0-1>] [--conversation-id <uuid>] [--format text|json]',
485
491
  ' kb folders [--format text|json]',
486
- ' kb context --query <text> [--limit <n>] [--threshold <0-1>]',
492
+ ' kb context --query <text> [--limit <n>] [--threshold <0-1>] [--semantic]',
487
493
  '',
488
494
  'Pipe examples:',
489
495
  ' notesia get --id 12 > note.md',
@@ -621,7 +627,12 @@ function buildPayload(parsed, pipedContent) {
621
627
  if (!parsed.query) {
622
628
  throw new CliCommandError('MISSING_ARGS', '--query is required for kb search');
623
629
  }
624
- return { query: parsed.query, limit: parsed.limit ?? 20, threshold: parsed.threshold ?? undefined };
630
+ return {
631
+ query: parsed.query,
632
+ limit: parsed.limit ?? 20,
633
+ threshold: parsed.threshold ?? undefined,
634
+ ...(parsed.semantic ? { semantic: true } : {}),
635
+ };
625
636
  }
626
637
 
627
638
  if (parsed.op === 'kb-folders') {
@@ -636,6 +647,7 @@ function buildPayload(parsed, pipedContent) {
636
647
  query: parsed.query,
637
648
  limit: parsed.limit ?? 5,
638
649
  threshold: parsed.threshold ?? undefined,
650
+ ...(parsed.semantic ? { semantic: true } : {}),
639
651
  };
640
652
  }
641
653
 
@@ -655,7 +667,12 @@ function buildPayload(parsed, pipedContent) {
655
667
  if (!parsed.query) {
656
668
  throw new CliCommandError('MISSING_ARGS', '--query is required for search');
657
669
  }
658
- return { query: parsed.query, limit: parsed.limit ?? 20, threshold: parsed.threshold ?? undefined };
670
+ return {
671
+ query: parsed.query,
672
+ limit: parsed.limit ?? 20,
673
+ threshold: parsed.threshold ?? undefined,
674
+ ...(parsed.semantic ? { semantic: true } : {}),
675
+ };
659
676
  }
660
677
 
661
678
  if (parsed.op === 'tags') {
package/src/io.mjs CHANGED
@@ -67,6 +67,17 @@ export function printMutationResult(result, {
67
67
  writeStdout(`${JSON.stringify(result ?? { ok: true }, null, 2)}\n`);
68
68
  return;
69
69
  }
70
+ if (result?.note && result.note.id != null) {
71
+ const parts = [`id: ${result.note.id}`];
72
+ if (result.note.supabase_id) parts.push(`supabase_id: ${result.note.supabase_id}`);
73
+ if (result.note.title) parts.push(`title: ${result.note.title}`);
74
+ writeStdout(`ok (${parts.join(', ')})\n`);
75
+ return;
76
+ }
77
+ if (result?.id != null) {
78
+ writeStdout(`ok (id: ${result.id})\n`);
79
+ return;
80
+ }
70
81
  writeStdout('ok\n');
71
82
  }
72
83
 
package/src/mcp.mjs CHANGED
@@ -109,7 +109,7 @@ export const MCP_TOOLS = [
109
109
  required: ['query'],
110
110
  additionalProperties: false,
111
111
  },
112
- op: 'kb-search',
112
+ op: 'search',
113
113
  toPayload: (args = {}) => ({
114
114
  query: String(args.query ?? ''),
115
115
  limit: args.limit ?? 20,
@@ -385,7 +385,7 @@ const TOOL_BY_NAME = new Map(MCP_TOOLS.map((tool) => [tool.name, tool]));
385
385
 
386
386
  export function createMcpMessageHandler({
387
387
  requestBridge = defaultRequestBridge,
388
- serverVersion = '0.2.1',
388
+ serverVersion = '0.2.2',
389
389
  } = {}) {
390
390
  return async function handleMcpMessage(message) {
391
391
  if (!message || typeof message !== 'object' || message.jsonrpc !== '2.0') {
@@ -545,7 +545,7 @@ export async function runMcpServer(args = [], {
545
545
  stdout = process.stdout,
546
546
  stderr = process.stderr,
547
547
  requestBridge = defaultRequestBridge,
548
- serverVersion = '0.2.1',
548
+ serverVersion = '0.2.2',
549
549
  } = {}) {
550
550
  if (args.includes('--help') || args.includes('-h')) {
551
551
  stdout.write(mcpUsageText());