remnote-mcp-server 0.13.1 → 0.14.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.
- package/CHANGELOG.md +40 -0
- package/README.md +44 -23
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- 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/mcpb/remnote-local/.mcpbignore +5 -0
- package/mcpb/remnote-local/README.md +25 -0
- package/mcpb/remnote-local/manifest.json +87 -0
- package/mcpb/remnote-local/package.json +11 -0
- package/mcpb/remnote-local/remnote-local.mcpb +0 -0
- package/mcpb/remnote-local/server/index.js +300 -0
- package/package.json +16 -9
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { InvalidArgumentError } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* A memory-safe cache that stores the flattened list of registered flags for each Command.
|
|
4
|
+
* Using a WeakMap ensures that once a Command object is garbage collected (e.g., after a test run),
|
|
5
|
+
* its associated cache is also freed, preventing memory leaks.
|
|
6
|
+
*/
|
|
7
|
+
const flagCache = new WeakMap();
|
|
8
|
+
/**
|
|
9
|
+
* Traverses the current Command and all its parent commands to collect every registered flag.
|
|
10
|
+
* Uses caching to ensure this expensive traversal only happens once per Command instance.
|
|
11
|
+
*
|
|
12
|
+
* @param cmd - The Commander.js Command instance to inspect.
|
|
13
|
+
* @returns An array of all registered short and long flags (e.g., ['-c', '--content', ...]).
|
|
14
|
+
*/
|
|
15
|
+
const getAllRegisteredFlags = (cmd) => {
|
|
16
|
+
if (flagCache.has(cmd)) {
|
|
17
|
+
return flagCache.get(cmd);
|
|
18
|
+
}
|
|
19
|
+
let flags = [];
|
|
20
|
+
let current = cmd;
|
|
21
|
+
while (current) {
|
|
22
|
+
if (current.options) {
|
|
23
|
+
const currentFlags = current.options.flatMap((opt) => [opt.short, opt.long].filter(Boolean));
|
|
24
|
+
flags = [...flags, ...currentFlags];
|
|
25
|
+
}
|
|
26
|
+
// Move up the command tree to catch globally registered options
|
|
27
|
+
current = current.parent;
|
|
28
|
+
}
|
|
29
|
+
flagCache.set(cmd, flags);
|
|
30
|
+
return flags;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Determines if a given string value looks like a CLI flag instead of a standard argument.
|
|
34
|
+
* This is used to detect "argument shifting" (e.g., when an empty string "" is swallowed by the shell,
|
|
35
|
+
* causing the next flag to be incorrectly parsed as the value for the current option).
|
|
36
|
+
*
|
|
37
|
+
* @param value - The string argument to evaluate.
|
|
38
|
+
* @param cmd - (Optional) The Command instance. If provided, enables strict matching against registered flags.
|
|
39
|
+
* @returns True if the value is likely a shifted flag; otherwise, false.
|
|
40
|
+
*/
|
|
41
|
+
export function isFlag(value, cmd) {
|
|
42
|
+
if (!value)
|
|
43
|
+
return false;
|
|
44
|
+
// Strict Match: If a Command context is provided, check against actually registered flags.
|
|
45
|
+
if (cmd) {
|
|
46
|
+
const knownFlags = getAllRegisteredFlags(cmd);
|
|
47
|
+
if (knownFlags.includes(value))
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validates an entire record of parsed arguments to ensure none of them are shifted flags.
|
|
54
|
+
* Useful for running a bulk check after Commander has finished parsing,
|
|
55
|
+
* especially when using dynamic commands or positional arguments.
|
|
56
|
+
*
|
|
57
|
+
* @param fields - A key-value record of parsed arguments (e.g., { title: '--content', parentId: '123' }).
|
|
58
|
+
* @param cmd - (Optional) The Command instance for strict flag matching.
|
|
59
|
+
* @throws {Error} If any value is identified as a shifted flag.
|
|
60
|
+
*/
|
|
61
|
+
export function checkPayloadForFlags(fields, cmd) {
|
|
62
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
63
|
+
if (isFlag(value, cmd)) {
|
|
64
|
+
throw new Error(`Argument shifting detected: "${value}" was misinterpreted as the value for "${name}". ` +
|
|
65
|
+
`This usually indicates argument shifting (e.g. the shell swallowed an empty string ""). ` +
|
|
66
|
+
`To fix this, use explicit flags (e.g. --title="", --content="") or check your quoting.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A higher-order function designed to be used as a custom processing function in Commander's `.option()`.
|
|
72
|
+
* It binds the Command context to the validation logic.
|
|
73
|
+
*
|
|
74
|
+
* @param cmd - The current Commander instance.
|
|
75
|
+
* @returns A validation function that throws an InvalidArgumentError if the value is a shifted flag.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const check = validateNotFlag(program);
|
|
79
|
+
* program.option('--title <text>', 'Note title', check);
|
|
80
|
+
*/
|
|
81
|
+
export function validateNotFlag(value, cmd) {
|
|
82
|
+
if (isFlag(value, cmd)) {
|
|
83
|
+
throw new InvalidArgumentError(`"${value}" looks like a flag but was passed as an option value. ` +
|
|
84
|
+
`This usually indicates argument shifting (e.g. the shell swallowed an empty string ""). ` +
|
|
85
|
+
`To fix this, use explicit flags (e.g. --title="", --content="") or check your quoting.`);
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=arg-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arg-utils.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/arg-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAA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ClC,MAA0C,EAC1C,GAAa;IAEb,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,gCAAgC,KAAK,0CAA0C,IAAI,KAAK;gBACtF,0FAA0F;gBAC1F,wFAAwF,CAC3F,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,GAAa;IAC1D,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,oBAAoB,CAC5B,IAAI,KAAK,yDAAyD;YAChE,0FAA0F;YAC1F,wFAAwF,CAC3F,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
export declare const MAX_WRITE_CONTENT_BYTES: number;
|
|
3
|
+
export declare function readContentFileOrStdin(pathOrDash: string, stdin?: Readable): Promise<string>;
|
|
4
|
+
interface OptionalContentArgs {
|
|
5
|
+
inlineText: string | undefined;
|
|
6
|
+
filePath: string | undefined;
|
|
7
|
+
inlineFlag: string;
|
|
8
|
+
fileFlag: string;
|
|
9
|
+
stdin?: Readable;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolveOptionalInlineOrFileContent({ inlineText, filePath, inlineFlag, fileFlag, stdin, }: OptionalContentArgs): Promise<string | undefined>;
|
|
12
|
+
interface UpdateContentArgs {
|
|
13
|
+
appendText: string | undefined;
|
|
14
|
+
appendFile: string | undefined;
|
|
15
|
+
replaceText: string | undefined;
|
|
16
|
+
replaceFile: string | undefined;
|
|
17
|
+
stdin?: Readable;
|
|
18
|
+
}
|
|
19
|
+
interface ResolvedUpdateContent {
|
|
20
|
+
appendContent: string | undefined;
|
|
21
|
+
replaceContent: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function resolveUpdateContent({ appendText, appendFile, replaceText, replaceFile, stdin, }: UpdateContentArgs): Promise<ResolvedUpdateContent>;
|
|
24
|
+
interface JournalContentArgs {
|
|
25
|
+
positionalContent: string | undefined;
|
|
26
|
+
optionContent: string | undefined;
|
|
27
|
+
contentFile: string | undefined;
|
|
28
|
+
stdin?: Readable;
|
|
29
|
+
}
|
|
30
|
+
export declare function resolveJournalContent({ positionalContent, optionContent, contentFile, stdin, }: JournalContentArgs): Promise<string>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
export const MAX_WRITE_CONTENT_BYTES = 100 * 1024;
|
|
3
|
+
function formatLimit() {
|
|
4
|
+
return `${MAX_WRITE_CONTENT_BYTES / 1024} KB`;
|
|
5
|
+
}
|
|
6
|
+
function ensureWithinLimit(byteLength, sourceLabel) {
|
|
7
|
+
if (byteLength > MAX_WRITE_CONTENT_BYTES) {
|
|
8
|
+
throw new Error(`${sourceLabel} exceeds ${formatLimit()} limit`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function readUtf8FromStream(stream, sourceLabel) {
|
|
12
|
+
const chunks = [];
|
|
13
|
+
let totalBytes = 0;
|
|
14
|
+
for await (const chunk of stream) {
|
|
15
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
16
|
+
totalBytes += buffer.byteLength;
|
|
17
|
+
ensureWithinLimit(totalBytes, sourceLabel);
|
|
18
|
+
chunks.push(buffer);
|
|
19
|
+
}
|
|
20
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
21
|
+
}
|
|
22
|
+
export async function readContentFileOrStdin(pathOrDash, stdin = process.stdin) {
|
|
23
|
+
if (pathOrDash === '-') {
|
|
24
|
+
return readUtf8FromStream(stdin, 'Stdin content');
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const buffer = await readFile(pathOrDash);
|
|
28
|
+
ensureWithinLimit(buffer.byteLength, `Content file "${pathOrDash}"`);
|
|
29
|
+
return buffer.toString('utf8');
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
33
|
+
throw new Error(`Failed to read content file "${pathOrDash}": ${message}`, {
|
|
34
|
+
cause: error,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function resolveOptionalInlineOrFileContent({ inlineText, filePath, inlineFlag, fileFlag, stdin, }) {
|
|
39
|
+
if (inlineText !== undefined && filePath !== undefined) {
|
|
40
|
+
throw new Error(`Cannot use ${inlineFlag} and ${fileFlag} together`);
|
|
41
|
+
}
|
|
42
|
+
if (filePath !== undefined) {
|
|
43
|
+
return readContentFileOrStdin(filePath, stdin);
|
|
44
|
+
}
|
|
45
|
+
// convert literal \n strings into actual newline characters
|
|
46
|
+
return inlineText?.replace(/\\n/g, '\n');
|
|
47
|
+
}
|
|
48
|
+
export async function resolveUpdateContent({ appendText, appendFile, replaceText, replaceFile, stdin, }) {
|
|
49
|
+
const appendContent = await resolveOptionalInlineOrFileContent({
|
|
50
|
+
inlineText: appendText,
|
|
51
|
+
filePath: appendFile,
|
|
52
|
+
inlineFlag: '--append',
|
|
53
|
+
fileFlag: '--append-file',
|
|
54
|
+
stdin,
|
|
55
|
+
});
|
|
56
|
+
const replaceContent = await resolveOptionalInlineOrFileContent({
|
|
57
|
+
inlineText: replaceText,
|
|
58
|
+
filePath: replaceFile,
|
|
59
|
+
inlineFlag: '--replace',
|
|
60
|
+
fileFlag: '--replace-file',
|
|
61
|
+
stdin,
|
|
62
|
+
});
|
|
63
|
+
if (appendContent !== undefined && replaceContent !== undefined) {
|
|
64
|
+
throw new Error('Cannot combine append and replace content options (--append/--append-file with --replace/--replace-file)');
|
|
65
|
+
}
|
|
66
|
+
return { appendContent, replaceContent };
|
|
67
|
+
}
|
|
68
|
+
export async function resolveJournalContent({ positionalContent, optionContent, contentFile, stdin, }) {
|
|
69
|
+
const providedCount = [positionalContent, optionContent, contentFile].filter((value) => value !== undefined).length;
|
|
70
|
+
if (providedCount !== 1) {
|
|
71
|
+
throw new Error('Provide exactly one journal content source: positional <content>, --content <text>, or --content-file <path|->');
|
|
72
|
+
}
|
|
73
|
+
if (contentFile !== undefined) {
|
|
74
|
+
return readContentFileOrStdin(contentFile, stdin);
|
|
75
|
+
}
|
|
76
|
+
if (optionContent !== undefined) {
|
|
77
|
+
return optionContent;
|
|
78
|
+
}
|
|
79
|
+
return positionalContent;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=content-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-input.js","sourceRoot":"","sources":["../../../src/remnote-cli/commands/content-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,CAAC;AAElD,SAAS,WAAW;IAClB,OAAO,GAAG,uBAAuB,GAAG,IAAI,KAAK,CAAC;AAChD,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAkB,EAAE,WAAmB;IAChE,IAAI,UAAU,GAAG,uBAAuB,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,YAAY,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,MAAgB,EAAE,WAAmB;IACrE,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,C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jH,CAAC;IACJ,CAAC;IAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,sBAAsB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,iBAA2B,CAAC;AACrC,CAAC"}
|
|
@@ -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":"","sources":["../../../src/remnote-cli/commands/create.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,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAA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AAK,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,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAEnE,UAAU;SACP,WAAW,CAAC,oCAAoC,CAAC;SACjD,MAAM,CAAC,kBAAkB,EAAE,uBAAuB,EAAE,QAAQ,CAAC;SAC7D,MAAM,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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;SACxE,MAAM,CAAC,0BAA0B,EAAE,oDAAoD,CAAC;SACxF,MAAM,CAAC,KAAK,EAAE,KAAa,EAAE,IAAI,EAAE,EAAE;QACpC,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;Q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AAC,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,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IACtE,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAe,EAAE,EAAE,CAAC,CAAC;IACnE,IAAI,IAAI,CAAC,UAAU;QAAE,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAoB,EAAE,EAAE,CAAC,CAAC;IAClF,IAAI,IAAI,CAAC,gBAAgB;QACvB,OAAO,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AK,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,EAAqB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,MAAM,GAAiB,UAAU,C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