Skip to content

Commit c34570d

Browse files
committed
v1.9.1 feat(cli): add --heading flag to save command
Enables users to specify a target heading when saving blocks to the daily page using `roam save`. If the heading does not exist, it is created, and the new block is nested under it. Changes: - Added `--heading <text>` option to the CLI save command. - Updated command output to print `block_uid parent_uid` when a heading is utilized, facilitating programmatic access to the parent context. - Bumped package version to 1.9.1.
1 parent 0319b40 commit c34570d

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
v1.9.1 - 2026-01-02
4+
5+
- Updated: Added --heading to `roam save` CLI
6+
37
v1.9.0 - 2026-01-02
48

59
- ADDED: `roam_move_block` MCP tool

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "roam-research-mcp",
3-
"version": "1.9.0",
3+
"version": "1.9.1",
44
"description": "A Model Context Protocol (MCP) server (with CLI support) for Roam Research API integration",
55
"private": false,
66
"repository": {

src/cli/commands/save.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ interface SaveOptions {
5959
block?: string | boolean; // Block content or flag for stdin
6060
page?: string; // Target page for block (default: daily page)
6161
parent?: string; // Parent block UID for nested block creation
62+
heading?: string; // Heading text to nest under (finds/creates)
6263
categories?: string; // Comma-separated category tags
6364
todo?: string | boolean; // TODO item text or flag for stdin
6465
json?: boolean; // Input is JSON format (explicit levels)
@@ -81,6 +82,7 @@ export function createSaveCommand(): Command {
8182
.option('-b, --block [text]', 'Add a single block instead of a page (text or stdin)')
8283
.option('-p, --page <title>', 'Target page for block (default: today\'s daily page)')
8384
.option('--parent <uid>', 'Parent block UID for nested block creation (use with -b)')
85+
.option('--heading <text>', 'Heading text to nest block under; finds or creates (use with -b)')
8486
.option('-c, --categories <tags>', 'Comma-separated category tags for block mode')
8587
.option('-t, --todo [text]', 'Add a TODO item to today\'s daily page (text or stdin)')
8688
.option('--json', 'Input is JSON format with explicit levels [{text, level, heading?}]')
@@ -158,6 +160,7 @@ export function createSaveCommand(): Command {
158160
printDebug('Block mode', true);
159161
printDebug('Block text', blockText);
160162
printDebug('Parent UID', options.parent || 'none');
163+
printDebug('Heading', options.heading || 'none');
161164
printDebug('Target page', options.page || 'daily page');
162165
printDebug('Categories', categories || 'none');
163166
}
@@ -194,13 +197,23 @@ export function createSaveCommand(): Command {
194197
return;
195198
}
196199

197-
// Default: use MemoryOperations for daily page
200+
// Use MemoryOperations for daily page (supports heading for nesting)
198201
const memoryOps = new MemoryOperations(graph);
199-
const result = await memoryOps.remember(blockText, categories);
202+
const result = await memoryOps.remember(
203+
blockText,
204+
categories,
205+
options.heading, // Find/create heading to nest under
206+
undefined // parent_uid (use --parent flag path instead)
207+
);
200208

201209
if (result.success) {
202-
// Output UID for programmatic use (e.g., stop-hook linking)
203-
console.log(result.block_uid);
210+
// Output block_uid and parent_uid for programmatic use
211+
// Format: block_uid [parent_uid] - parent_uid only if heading was used
212+
if (options.heading && result.parent_uid) {
213+
console.log(`${result.block_uid} ${result.parent_uid}`);
214+
} else {
215+
console.log(result.block_uid);
216+
}
204217
} else {
205218
exitWithError('Failed to save block');
206219
}

0 commit comments

Comments
 (0)