remnote-mcp-server 0.13.0 → 0.14.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/CHANGELOG.md +22 -0
- package/README.md +30 -21
- package/dist/remnote-cli/cli.d.ts +3 -0
- package/dist/remnote-cli/cli.js +37 -0
- package/dist/remnote-cli/cli.js.map +1 -0
- package/dist/remnote-cli/client/command-client.d.ts +3 -0
- package/dist/remnote-cli/client/command-client.js +9 -0
- package/dist/remnote-cli/client/command-client.js.map +1 -0
- package/dist/remnote-cli/client/mcp-server-client.d.ts +18 -0
- package/dist/remnote-cli/client/mcp-server-client.js +116 -0
- package/dist/remnote-cli/client/mcp-server-client.js.map +1 -0
- package/dist/remnote-cli/commands/arg-utils.d.ts +33 -0
- package/dist/remnote-cli/commands/arg-utils.js +89 -0
- package/dist/remnote-cli/commands/arg-utils.js.map +1 -0
- package/dist/remnote-cli/commands/content-input.d.ts +31 -0
- package/dist/remnote-cli/commands/content-input.js +81 -0
- package/dist/remnote-cli/commands/content-input.js.map +1 -0
- package/dist/remnote-cli/commands/create.d.ts +2 -0
- package/dist/remnote-cli/commands/create.js +61 -0
- package/dist/remnote-cli/commands/create.js.map +1 -0
- package/dist/remnote-cli/commands/journal.d.ts +2 -0
- package/dist/remnote-cli/commands/journal.js +52 -0
- package/dist/remnote-cli/commands/journal.js.map +1 -0
- package/dist/remnote-cli/commands/read.d.ts +2 -0
- package/dist/remnote-cli/commands/read.js +74 -0
- package/dist/remnote-cli/commands/read.js.map +1 -0
- package/dist/remnote-cli/commands/search.d.ts +3 -0
- package/dist/remnote-cli/commands/search.js +107 -0
- package/dist/remnote-cli/commands/search.js.map +1 -0
- package/dist/remnote-cli/commands/status.d.ts +2 -0
- package/dist/remnote-cli/commands/status.js +41 -0
- package/dist/remnote-cli/commands/status.js.map +1 -0
- package/dist/remnote-cli/commands/table.d.ts +2 -0
- package/dist/remnote-cli/commands/table.js +79 -0
- package/dist/remnote-cli/commands/table.js.map +1 -0
- package/dist/remnote-cli/commands/update.d.ts +2 -0
- package/dist/remnote-cli/commands/update.js +62 -0
- package/dist/remnote-cli/commands/update.js.map +1 -0
- package/dist/remnote-cli/config.d.ts +9 -0
- package/dist/remnote-cli/config.js +10 -0
- package/dist/remnote-cli/config.js.map +1 -0
- package/dist/remnote-cli/index.d.ts +2 -0
- package/dist/remnote-cli/index.js +4 -0
- package/dist/remnote-cli/index.js.map +1 -0
- package/dist/remnote-cli/output/formatter.d.ts +9 -0
- package/dist/remnote-cli/output/formatter.js +28 -0
- package/dist/remnote-cli/output/formatter.js.map +1 -0
- package/dist/remnote-cli/version-compat.d.ts +7 -0
- package/dist/remnote-cli/version-compat.js +28 -0
- package/dist/remnote-cli/version-compat.js.map +1 -0
- package/dist/websocket-server.d.ts +1 -0
- package/dist/websocket-server.js +2 -1
- package/dist/websocket-server.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createCommandClient } from '../client/command-client.js';
|
|
2
|
+
import { formatResult, formatError } from '../output/formatter.js';
|
|
3
|
+
import { EXIT } from '../config.js';
|
|
4
|
+
import { resolveOptionalInlineOrFileContent } from './content-input.js';
|
|
5
|
+
import { checkPayloadForFlags, validateNotFlag } from './arg-utils.js';
|
|
6
|
+
export function registerCreateCommand(program) {
|
|
7
|
+
const subprogram = program.command('create [title]');
|
|
8
|
+
const validate = (val) => validateNotFlag(val, subprogram);
|
|
9
|
+
subprogram
|
|
10
|
+
.description('Create a new note in RemNote (title or content required)')
|
|
11
|
+
.option('--title <text>', 'Note title', validate)
|
|
12
|
+
.option('-c, --content <text>', 'Note content (markdown/flashcard supported)', validate)
|
|
13
|
+
.option('--content-file <path>', 'Read note content from UTF-8 file ("-" for stdin)', validate)
|
|
14
|
+
.option('--parent-id <id>', 'Parent Rem ID', validate)
|
|
15
|
+
.option('-t, --tags <tags...>', 'Tags to add')
|
|
16
|
+
.action(async (titleArg, opts) => {
|
|
17
|
+
const globalOpts = program.opts();
|
|
18
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
19
|
+
const client = createCommandClient(program);
|
|
20
|
+
try {
|
|
21
|
+
const payload = {};
|
|
22
|
+
// Validate shifting flags for positional arguments
|
|
23
|
+
checkPayloadForFlags({ title: titleArg }, subprogram);
|
|
24
|
+
const title = titleArg !== undefined ? titleArg : opts.title;
|
|
25
|
+
if (title !== undefined)
|
|
26
|
+
payload.title = title;
|
|
27
|
+
const content = await resolveOptionalInlineOrFileContent({
|
|
28
|
+
inlineText: opts.content,
|
|
29
|
+
filePath: opts.contentFile,
|
|
30
|
+
inlineFlag: '--content',
|
|
31
|
+
fileFlag: '--content-file',
|
|
32
|
+
});
|
|
33
|
+
if (content !== undefined)
|
|
34
|
+
payload.content = content;
|
|
35
|
+
if (opts.parentId)
|
|
36
|
+
payload.parentId = opts.parentId;
|
|
37
|
+
if (opts.tags && opts.tags.length > 0)
|
|
38
|
+
payload.tags = opts.tags;
|
|
39
|
+
const result = await client.execute('create_note', payload);
|
|
40
|
+
console.log(formatResult(result, format, (data) => {
|
|
41
|
+
const r = data;
|
|
42
|
+
const ids = r.remIds || [];
|
|
43
|
+
const titles = r.titles || [];
|
|
44
|
+
if (ids.length === 0)
|
|
45
|
+
return 'No Rems created.';
|
|
46
|
+
return titles
|
|
47
|
+
.map((t, i) => `Created: ${t || '(untitled)'} (ID: ${ids[i] || 'unknown'})`)
|
|
48
|
+
.join('\n');
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53
|
+
console.error(formatError(message, format));
|
|
54
|
+
process.exit(EXIT.ERROR);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
await client.close();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","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,YAAY,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,SAAS,GAAG,CAAC;qBAC3E,IAAI,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createCommandClient } from '../client/command-client.js';
|
|
2
|
+
import { formatResult, formatError } from '../output/formatter.js';
|
|
3
|
+
import { EXIT } from '../config.js';
|
|
4
|
+
import { resolveJournalContent } from './content-input.js';
|
|
5
|
+
import { checkPayloadForFlags, validateNotFlag } from './arg-utils.js';
|
|
6
|
+
export function registerJournalCommand(program) {
|
|
7
|
+
const subprogram = program.command('journal [content]');
|
|
8
|
+
const validate = (val) => validateNotFlag(val, subprogram);
|
|
9
|
+
subprogram
|
|
10
|
+
.description("Append an entry to today's journal")
|
|
11
|
+
.option('--content <text>', 'Journal entry content', validate)
|
|
12
|
+
.option('--content-file <path>', 'Read journal entry from UTF-8 file ("-" for stdin)', validate)
|
|
13
|
+
.option('--no-timestamp', 'Omit timestamp prefix')
|
|
14
|
+
.action(async (positionalContent, opts) => {
|
|
15
|
+
const globalOpts = program.opts();
|
|
16
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
17
|
+
const client = createCommandClient(program);
|
|
18
|
+
try {
|
|
19
|
+
// Validate shifting for positional content
|
|
20
|
+
checkPayloadForFlags({ content: positionalContent }, program);
|
|
21
|
+
const content = await resolveJournalContent({
|
|
22
|
+
positionalContent: positionalContent,
|
|
23
|
+
optionContent: opts.content,
|
|
24
|
+
contentFile: opts.contentFile,
|
|
25
|
+
});
|
|
26
|
+
const payload = {
|
|
27
|
+
content,
|
|
28
|
+
timestamp: opts.timestamp !== false,
|
|
29
|
+
};
|
|
30
|
+
const result = await client.execute('append_journal', payload);
|
|
31
|
+
console.log(formatResult(result, format, (data) => {
|
|
32
|
+
const r = data;
|
|
33
|
+
const ids = r.remIds || [];
|
|
34
|
+
const titles = r.titles || [];
|
|
35
|
+
if (ids.length === 0)
|
|
36
|
+
return 'No journal entry Rems created.';
|
|
37
|
+
return titles
|
|
38
|
+
.map((t, i) => `Journal entry added: ${t || '(untitled)'} (ID: ${ids[i] || 'unknown'})`)
|
|
39
|
+
.join('\n');
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
44
|
+
console.error(formatError(message, format));
|
|
45
|
+
process.exit(EXIT.ERROR);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
await client.close();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=journal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/journal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MA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EAAE,EAAE;gBACpC,MAAM,CAAC,GAAG,IAAgD,CAAC;gBAC3D,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC;gBAC3B,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC;gBAC9B,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,gCAAgC,CAAC;gBAC9D,OAAO,MAAM;qBACV,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,YAAY,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,SAAS,GAAG,CACnF;qBACA,IAAI,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createCommandClient } from '../client/command-client.js';
|
|
2
|
+
import { formatResult, formatError } from '../output/formatter.js';
|
|
3
|
+
import { EXIT } from '../config.js';
|
|
4
|
+
export function registerReadCommand(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('read <rem-id>')
|
|
7
|
+
.description('Read a note by its Rem ID')
|
|
8
|
+
.option('-d, --depth <n>', 'Depth of child hierarchy to render (default: 5)', '5')
|
|
9
|
+
.option('--include-content <mode>', 'Content rendering mode: "markdown" (default), "none", or "structured"')
|
|
10
|
+
.option('--child-limit <n>', 'Maximum children per level (default: 100)')
|
|
11
|
+
.option('--max-content-length <n>', 'Maximum content character length (default: 100000)')
|
|
12
|
+
.action(async (remId, opts) => {
|
|
13
|
+
const globalOpts = program.opts();
|
|
14
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
15
|
+
const client = createCommandClient(program);
|
|
16
|
+
try {
|
|
17
|
+
const payload = {
|
|
18
|
+
remId,
|
|
19
|
+
depth: parseInt(opts.depth, 10),
|
|
20
|
+
};
|
|
21
|
+
if (opts.includeContent)
|
|
22
|
+
payload.includeContent = opts.includeContent;
|
|
23
|
+
if (opts.childLimit)
|
|
24
|
+
payload.childLimit = parseInt(opts.childLimit, 10);
|
|
25
|
+
if (opts.maxContentLength)
|
|
26
|
+
payload.maxContentLength = parseInt(opts.maxContentLength, 10);
|
|
27
|
+
const result = await client.execute('read_note', payload);
|
|
28
|
+
console.log(formatResult(result, format, (data) => {
|
|
29
|
+
const r = data;
|
|
30
|
+
const lines = [];
|
|
31
|
+
if (r.headline) {
|
|
32
|
+
lines.push(`Title: ${r.headline}`);
|
|
33
|
+
}
|
|
34
|
+
else if (r.title) {
|
|
35
|
+
lines.push(`Title: ${r.title}`);
|
|
36
|
+
}
|
|
37
|
+
if (r.remId)
|
|
38
|
+
lines.push(`ID: ${r.remId}`);
|
|
39
|
+
if (r.remType)
|
|
40
|
+
lines.push(`Type: ${r.remType}`);
|
|
41
|
+
if (typeof r.parentTitle === 'string' && r.parentTitle.length > 0) {
|
|
42
|
+
const parentIdSuffix = typeof r.parentRemId === 'string' ? ` [${r.parentRemId}]` : '';
|
|
43
|
+
lines.push(`Parent: ${r.parentTitle}${parentIdSuffix}`);
|
|
44
|
+
}
|
|
45
|
+
if (r.aliases && Array.isArray(r.aliases) && r.aliases.length > 0) {
|
|
46
|
+
lines.push(`Aliases: ${r.aliases.join(', ')}`);
|
|
47
|
+
}
|
|
48
|
+
if (r.tags && Array.isArray(r.tags) && r.tags.length > 0) {
|
|
49
|
+
lines.push(`Tags: ${r.tags.join(', ')}`);
|
|
50
|
+
}
|
|
51
|
+
if (r.cardDirection)
|
|
52
|
+
lines.push(`Card: ${r.cardDirection}`);
|
|
53
|
+
if (r.contentProperties) {
|
|
54
|
+
const cp = r.contentProperties;
|
|
55
|
+
lines.push(`Children: ${cp.childrenRendered}/${cp.childrenTotal}${cp.contentTruncated ? ' (truncated)' : ''}`);
|
|
56
|
+
}
|
|
57
|
+
if (r.content && typeof r.content === 'string' && r.content.length > 0) {
|
|
58
|
+
lines.push('');
|
|
59
|
+
lines.push(r.content);
|
|
60
|
+
}
|
|
61
|
+
return lines.join('\n');
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
+
console.error(formatError(message, format));
|
|
67
|
+
process.exit(EXIT.ERROR);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
await client.close();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC;SACxB,WAAW,CAAC,2BAA2B,CAAC;SACxC,MAAM,CAAC,iBAAiB,EAAE,iDAAiD,EAAE,GAAG,CAAC;SACjF,MAAM,CACL,0BAA0B,EAC1B,uEAAuE,CACxE;SACA,MAAM,CAAC,mBAAmB,EAAE,2CAA2C,CAAC;SAC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AE,CAAC,CAAC;gBAC5D,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;oBACxB,MAAM,EAAE,GAAG,CAAC,CAAC,iBAA4C,CAAC;oBAC1D,KAAK,CAAC,IAAI,CACR,aAAa,EAAE,CAAC,gBAAgB,IAAI,EAAE,CAAC,aAAa,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CACnG,CAAC;gBACJ,CAAC;gBACD,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACvE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACf,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAiB,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createCommandClient } from '../client/command-client.js';
|
|
2
|
+
import { formatResult, formatError } from '../output/formatter.js';
|
|
3
|
+
import { EXIT } from '../config.js';
|
|
4
|
+
/** Default number of search results. */
|
|
5
|
+
const DEFAULT_SEARCH_LIMIT = 50;
|
|
6
|
+
/** Compact type prefixes for text output (empty for plain text Rems). */
|
|
7
|
+
const TYPE_TAG = {
|
|
8
|
+
document: '[doc] ',
|
|
9
|
+
dailyDocument: '[daily] ',
|
|
10
|
+
concept: '[concept] ',
|
|
11
|
+
descriptor: '[desc] ',
|
|
12
|
+
portal: '[portal] ',
|
|
13
|
+
};
|
|
14
|
+
function applySearchOptions(payload, opts) {
|
|
15
|
+
if (opts.includeContent)
|
|
16
|
+
payload.includeContent = opts.includeContent;
|
|
17
|
+
if (opts.depth)
|
|
18
|
+
payload.depth = parseInt(opts.depth, 10);
|
|
19
|
+
if (opts.childLimit)
|
|
20
|
+
payload.childLimit = parseInt(opts.childLimit, 10);
|
|
21
|
+
if (opts.maxContentLength)
|
|
22
|
+
payload.maxContentLength = parseInt(opts.maxContentLength, 10);
|
|
23
|
+
}
|
|
24
|
+
function formatSearchText(data) {
|
|
25
|
+
const r = data;
|
|
26
|
+
if (!r.results || r.results.length === 0)
|
|
27
|
+
return 'No results found.';
|
|
28
|
+
return r.results
|
|
29
|
+
.map((note, i) => {
|
|
30
|
+
const typeTag = TYPE_TAG[note.remType] ?? '';
|
|
31
|
+
const headline = note.headline || note.title || '(untitled)';
|
|
32
|
+
let aliasesSuffix = '';
|
|
33
|
+
if (note.aliases && Array.isArray(note.aliases) && note.aliases.length > 0) {
|
|
34
|
+
aliasesSuffix = ` (aka: ${note.aliases.join(', ')})`;
|
|
35
|
+
}
|
|
36
|
+
let tagsSuffix = '';
|
|
37
|
+
if (note.tags && Array.isArray(note.tags) && note.tags.length > 0) {
|
|
38
|
+
tagsSuffix = ` [tags: ${note.tags.join(', ')}]`;
|
|
39
|
+
}
|
|
40
|
+
let parentSuffix = '';
|
|
41
|
+
if (typeof note.parentTitle === 'string' && note.parentTitle.length > 0) {
|
|
42
|
+
const parentIdSuffix = typeof note.parentRemId === 'string' ? ` [${note.parentRemId}]` : '';
|
|
43
|
+
parentSuffix = ` <- ${note.parentTitle}${parentIdSuffix}`;
|
|
44
|
+
}
|
|
45
|
+
return `${i + 1}. ${typeTag}${headline}${aliasesSuffix}${tagsSuffix}${parentSuffix} [${note.remId}]`;
|
|
46
|
+
})
|
|
47
|
+
.join('\n');
|
|
48
|
+
}
|
|
49
|
+
function registerCommonSearchOptions(command) {
|
|
50
|
+
return command
|
|
51
|
+
.option('-l, --limit <n>', `Maximum results (default: ${DEFAULT_SEARCH_LIMIT})`, String(DEFAULT_SEARCH_LIMIT))
|
|
52
|
+
.option('--include-content <mode>', 'Content rendering mode: "none" (default), "markdown", or "structured"')
|
|
53
|
+
.option('--depth <n>', 'Depth of child hierarchy to render (default: 1)')
|
|
54
|
+
.option('--child-limit <n>', 'Maximum children per level (default: 20)')
|
|
55
|
+
.option('--max-content-length <n>', 'Maximum content character length (default: 3000)');
|
|
56
|
+
}
|
|
57
|
+
export function registerSearchCommand(program) {
|
|
58
|
+
registerCommonSearchOptions(program.command('search <query>').description('Search for notes in RemNote')).action(async (query, opts) => {
|
|
59
|
+
const globalOpts = program.opts();
|
|
60
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
61
|
+
const client = createCommandClient(program);
|
|
62
|
+
try {
|
|
63
|
+
const payload = {
|
|
64
|
+
query,
|
|
65
|
+
limit: parseInt(opts.limit, 10),
|
|
66
|
+
};
|
|
67
|
+
applySearchOptions(payload, opts);
|
|
68
|
+
const result = await client.execute('search', payload);
|
|
69
|
+
console.log(formatResult(result, format, (data) => formatSearchText(data)));
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
73
|
+
console.error(formatError(message, format));
|
|
74
|
+
process.exit(EXIT.ERROR);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
await client.close();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function registerSearchByTagCommand(program) {
|
|
82
|
+
registerCommonSearchOptions(program
|
|
83
|
+
.command('search-tag <tag>')
|
|
84
|
+
.description('Search notes by tag with ancestor-context resolution')).action(async (tag, opts) => {
|
|
85
|
+
const globalOpts = program.opts();
|
|
86
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
87
|
+
const client = createCommandClient(program);
|
|
88
|
+
try {
|
|
89
|
+
const payload = {
|
|
90
|
+
tag,
|
|
91
|
+
limit: parseInt(opts.limit, 10),
|
|
92
|
+
};
|
|
93
|
+
applySearchOptions(payload, opts);
|
|
94
|
+
const result = await client.execute('search_by_tag', payload);
|
|
95
|
+
console.log(formatResult(result, format, (data) => formatSearchText(data)));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
99
|
+
console.error(formatError(message, format));
|
|
100
|
+
process.exit(EXIT.ERROR);
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
await client.close();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,wCAAwC;AACxC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,yEAAyE;AACzE,MAAM,QAAQ,GAA2B;IACvC,QAAQ,EAAE,QAAQ;IAClB,aAAa,EAAE,UAAU;IACzB,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,SAAS;IACrB,MAAM,EAAE,WAAW;CACpB,CAAC;AAEF,SAAS,kBAAkB,CAAC,OAAgC,EAAE,IAA6B;IACzF,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO,CAA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AAK,EAAE,GAAW,EAAE,IAAI,EAAE,EAAE;QACnC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,MAAM,GAAiB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/D,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAE5C,IAAI,CAAC;YACH,MAAM,OAAO,GAA4B;gBACvC,GAAG;gBACH,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;aAChC,CAAC;YACF,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAElC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YAC9D,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createCommandClient } from '../client/command-client.js';
|
|
2
|
+
import { formatResult, formatError } from '../output/formatter.js';
|
|
3
|
+
import { EXIT } from '../config.js';
|
|
4
|
+
export function registerStatusCommand(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('status')
|
|
7
|
+
.description('Check bridge connection status')
|
|
8
|
+
.action(async () => {
|
|
9
|
+
const globalOpts = program.opts();
|
|
10
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
11
|
+
const client = createCommandClient(program);
|
|
12
|
+
try {
|
|
13
|
+
const result = await client.execute('get_status', {});
|
|
14
|
+
console.log(formatResult(result, format, (data) => {
|
|
15
|
+
const r = data;
|
|
16
|
+
const connected = r.connected ? 'Connected' : 'Not connected';
|
|
17
|
+
const pluginVersion = r.pluginVersion ? ` (plugin v${r.pluginVersion})` : '';
|
|
18
|
+
const cliVersion = r.cliVersion ? `CLI: v${r.cliVersion}` : '';
|
|
19
|
+
const lines = [`Bridge: ${connected}${pluginVersion}`];
|
|
20
|
+
if (cliVersion)
|
|
21
|
+
lines.push(cliVersion);
|
|
22
|
+
if (r.version_warning)
|
|
23
|
+
lines.push(`WARNING: ${r.version_warning}`);
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
29
|
+
if (message.includes('Cannot connect to MCP server')) {
|
|
30
|
+
console.error(formatError(message, format));
|
|
31
|
+
process.exit(EXIT.MCP_SERVER_NOT_RUNNING);
|
|
32
|
+
}
|
|
33
|
+
console.error(formatError(message, format));
|
|
34
|
+
process.exit(EXIT.ERROR);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
await client.close();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,E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AC,eAAe,EAAE,CAAC,CAAC;gBACnE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,IAAI,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE,CAAC;gBACrD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC5C,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createCommandClient } from '../client/command-client.js';
|
|
2
|
+
import { formatResult, formatError } from '../output/formatter.js';
|
|
3
|
+
import { EXIT } from '../config.js';
|
|
4
|
+
export function registerReadTableCommand(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('read-table')
|
|
7
|
+
.description('Read an Advanced Table (columns and row data)')
|
|
8
|
+
.option('--title <title>', 'Exact Advanced Table title')
|
|
9
|
+
.option('--rem-id <id>', 'Table Rem ID')
|
|
10
|
+
.option('-l, --limit <n>', 'Maximum rows to return (default: 50)', '50')
|
|
11
|
+
.option('--offset <n>', 'Row offset for pagination (default: 0)', '0')
|
|
12
|
+
.option('-p, --properties <names>', 'Comma-separated property/column names to include')
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
const globalOpts = program.opts();
|
|
15
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
16
|
+
const client = createCommandClient(program);
|
|
17
|
+
try {
|
|
18
|
+
const payload = {
|
|
19
|
+
limit: parseInt(opts.limit, 10),
|
|
20
|
+
offset: parseInt(opts.offset, 10),
|
|
21
|
+
};
|
|
22
|
+
if ((opts.title ? 1 : 0) + (opts.remId ? 1 : 0) !== 1) {
|
|
23
|
+
throw new Error('Provide exactly one of --title or --rem-id');
|
|
24
|
+
}
|
|
25
|
+
if (opts.title)
|
|
26
|
+
payload.tableTitle = opts.title;
|
|
27
|
+
if (opts.remId)
|
|
28
|
+
payload.tableRemId = opts.remId;
|
|
29
|
+
if (opts.properties) {
|
|
30
|
+
payload.propertyFilter = opts.properties
|
|
31
|
+
.split(',')
|
|
32
|
+
.map((s) => s.trim());
|
|
33
|
+
}
|
|
34
|
+
const result = await client.execute('read_table', payload);
|
|
35
|
+
console.log(formatResult(result, format, (data) => {
|
|
36
|
+
const r = data;
|
|
37
|
+
const lines = [];
|
|
38
|
+
// Table header
|
|
39
|
+
const tableName = r.tableName || '(unnamed)';
|
|
40
|
+
lines.push(`Table: ${tableName} [${r.tableId}]`);
|
|
41
|
+
// Columns
|
|
42
|
+
const columns = (r.columns || []);
|
|
43
|
+
if (columns.length > 0) {
|
|
44
|
+
lines.push(`Columns: ${columns.map((c) => `${c.name} (${c.type})`).join(', ')}`);
|
|
45
|
+
}
|
|
46
|
+
// Row count
|
|
47
|
+
lines.push(`Rows: ${r.rowsReturned}/${r.totalRows}`);
|
|
48
|
+
// Rows
|
|
49
|
+
const rows = (r.rows || []);
|
|
50
|
+
if (rows.length > 0 && columns.length > 0) {
|
|
51
|
+
lines.push('');
|
|
52
|
+
// Header row
|
|
53
|
+
const colNames = ['Name', ...columns.map((c) => c.name)];
|
|
54
|
+
lines.push(colNames.join(' | '));
|
|
55
|
+
lines.push(colNames.map((n) => '─'.repeat(n.length)).join('─┼─'));
|
|
56
|
+
// Data rows
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const values = (row.values || {});
|
|
59
|
+
const cells = [
|
|
60
|
+
String(row.name || ''),
|
|
61
|
+
...columns.map((c) => values[c.propertyId] || ''),
|
|
62
|
+
];
|
|
63
|
+
lines.push(cells.join(' | '));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return lines.join('\n');
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
71
|
+
console.error(formatError(message, format));
|
|
72
|
+
process.exit(EXIT.ERROR);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
await client.close();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,UAAU,wBAAwB,CAAC,OAAgB;IACvD,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,+CAA+C,CAAC;SAC5D,MAAM,CAAC,iBAAiB,EAAE,4BAA4B,CAAC;SACvD,MAAM,CAAC,eAAe,EAAE,cAAc,CAAC;SACvC,MAAM,CAAC,iBAAiB,EAAE,sCAAsC,EAAE,IAAI,CAAC;SACvE,MAAM,CAAC,cAAc,EAAE,wCAAwC,EAAE,GAAG,CAAC;SACrE,MAAM,CAAC,0BAA0B,EAAE,kDAAkD,CAAC;SACtF,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,UAA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C,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;oBAClE,YAAY;oBACZ,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;wBACvB,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAA2B,CAAC;wBAC5D,MAAM,KAAK,GAAG;4BACZ,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;4BACtB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;yBAClD,CAAC;wBACF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;oBAChC,CAAC;gBACH,CAAC;gBAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createCommandClient } from '../client/command-client.js';
|
|
2
|
+
import { formatResult, formatError } from '../output/formatter.js';
|
|
3
|
+
import { EXIT } from '../config.js';
|
|
4
|
+
import { resolveUpdateContent } from './content-input.js';
|
|
5
|
+
import { validateNotFlag } from './arg-utils.js';
|
|
6
|
+
export function registerUpdateCommand(program) {
|
|
7
|
+
const subprogram = program.command('update <rem-id>');
|
|
8
|
+
const validate = (val) => validateNotFlag(val, subprogram);
|
|
9
|
+
subprogram
|
|
10
|
+
.description('Update an existing note')
|
|
11
|
+
.option('--title <text>', 'New title', validate)
|
|
12
|
+
.option('--append <text>', 'Append content', validate)
|
|
13
|
+
.option('--append-file <path>', 'Read appended content from UTF-8 file ("-" for stdin)', validate)
|
|
14
|
+
.option('--replace <text>', 'Replace direct child content (empty string clears all children)', validate)
|
|
15
|
+
.option('--replace-file <path>', 'Read replacement content from UTF-8 file ("-" for stdin; empty file clears all children)', validate)
|
|
16
|
+
.option('--add-tags <tags...>', 'Tags to add')
|
|
17
|
+
.option('--remove-tags <tags...>', 'Tags to remove')
|
|
18
|
+
.action(async (remId, opts) => {
|
|
19
|
+
const globalOpts = program.opts();
|
|
20
|
+
const format = globalOpts.text ? 'text' : 'json';
|
|
21
|
+
const client = createCommandClient(program);
|
|
22
|
+
try {
|
|
23
|
+
const { appendContent, replaceContent } = await resolveUpdateContent({
|
|
24
|
+
appendText: opts.append,
|
|
25
|
+
appendFile: opts.appendFile,
|
|
26
|
+
replaceText: opts.replace,
|
|
27
|
+
replaceFile: opts.replaceFile,
|
|
28
|
+
});
|
|
29
|
+
const payload = { remId };
|
|
30
|
+
if (opts.title)
|
|
31
|
+
payload.title = opts.title;
|
|
32
|
+
if (appendContent !== undefined)
|
|
33
|
+
payload.appendContent = appendContent;
|
|
34
|
+
if (replaceContent !== undefined)
|
|
35
|
+
payload.replaceContent = replaceContent;
|
|
36
|
+
if (opts.addTags && opts.addTags.length > 0)
|
|
37
|
+
payload.addTags = opts.addTags;
|
|
38
|
+
if (opts.removeTags && opts.removeTags.length > 0)
|
|
39
|
+
payload.removeTags = opts.removeTags;
|
|
40
|
+
const result = await client.execute('update_note', payload);
|
|
41
|
+
console.log(formatResult(result, format, (data) => {
|
|
42
|
+
const r = data;
|
|
43
|
+
const ids = r.remIds || [];
|
|
44
|
+
const titles = r.titles || [];
|
|
45
|
+
if (ids.length === 0)
|
|
46
|
+
return `Updated note ${remId} (no Rems created)`;
|
|
47
|
+
return titles
|
|
48
|
+
.map((t, i) => `Updated/Created: ${t || '(untitled)'} (ID: ${ids[i] || 'unknown'})`)
|
|
49
|
+
.join('\n');
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
54
|
+
console.error(formatError(message, format));
|
|
55
|
+
process.exit(EXIT.ERROR);
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
await client.close();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAEnE,UAAU;SACP,WAAW,CAAC,yBAAyB,CAAC;SACtC,MAAM,CAAC,gBAAgB,EAAE,WAAW,EAAE,QAAQ,CAAC;SAC/C,MAAM,CAAC,iBAAiB,EAAE,g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9 @@
|
|
|
1
|
+
export declare const DEFAULT_MCP_URL = "http://127.0.0.1:3001/mcp";
|
|
2
|
+
export declare const REQUEST_TIMEOUT_MS = 15000;
|
|
3
|
+
/** Exit codes for CLI process */
|
|
4
|
+
export declare const EXIT: {
|
|
5
|
+
readonly SUCCESS: 0;
|
|
6
|
+
readonly ERROR: 1;
|
|
7
|
+
readonly MCP_SERVER_NOT_RUNNING: 2;
|
|
8
|
+
readonly BRIDGE_NOT_CONNECTED: 3;
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const DEFAULT_MCP_URL = 'http://127.0.0.1:3001/mcp';
|
|
2
|
+
export const REQUEST_TIMEOUT_MS = 15000;
|
|
3
|
+
/** Exit codes for CLI process */
|
|
4
|
+
export const EXIT = {
|
|
5
|
+
SUCCESS: 0,
|
|
6
|
+
ERROR: 1,
|
|
7
|
+
MCP_SERVER_NOT_RUNNING: 2,
|
|
8
|
+
BRIDGE_NOT_CONNECTED: 3,
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/remnote-cli/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAE3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC,iCAAiC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,sBAAsB,EAAE,CAAC;IACzB,oBAAoB,EAAE,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/remnote-cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type OutputFormat = 'json' | 'text';
|
|
2
|
+
/**
|
|
3
|
+
* Format a successful result for stdout.
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatResult(data: unknown, format: OutputFormat, textFormatter?: (data: unknown) => string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Format an error for stderr/stdout.
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatError(message: string, format: OutputFormat, code?: number): string;
|