From 80aace78fa200611fef9c0108e62ca941d703ebe Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 26 Feb 2026 14:40:44 +0700 Subject: [PATCH 1/4] feat: add word_count and size_bytes to list, map, and read output - Derive from parsed body: whitespace split for words, Buffer.byteLength for bytes. - Helps LLMs gauge note size without reading full content. --- src/commands/list.ts | 2 ++ src/commands/map.ts | 2 ++ src/commands/read.ts | 2 ++ src/schemas/list.ts | 2 ++ src/schemas/map.ts | 2 ++ src/schemas/note.ts | 2 ++ 6 files changed, 12 insertions(+) diff --git a/src/commands/list.ts b/src/commands/list.ts index bce3c29..f846a96 100644 --- a/src/commands/list.ts +++ b/src/commands/list.ts @@ -32,6 +32,8 @@ export async function list({ title: (fm.title as string) ?? null, type: (fm.type as string) ?? null, tags, + word_count: parsed.body.split(/\s+/).filter(Boolean).length, + size_bytes: Buffer.byteLength(parsed.body, "utf-8"), }; }), ); diff --git a/src/commands/map.ts b/src/commands/map.ts index 482dd34..29eb905 100644 --- a/src/commands/map.ts +++ b/src/commands/map.ts @@ -35,6 +35,8 @@ export async function map({ ctx }: { ctx: CommandContext }): Promise path: parsed.path, title: (parsed.frontmatter.title as string) ?? null, type: (parsed.frontmatter.type as string) ?? null, + word_count: parsed.body.split(/\s+/).filter(Boolean).length, + size_bytes: Buffer.byteLength(parsed.body, "utf-8"), }; }), ); diff --git a/src/commands/read.ts b/src/commands/read.ts index 4dacb8a..22c6f00 100644 --- a/src/commands/read.ts +++ b/src/commands/read.ts @@ -61,6 +61,8 @@ export async function read({ vault: ctx.vault.name, frontmatter: parsed.frontmatter, body, + word_count: body.split(/\s+/).filter(Boolean).length, + size_bytes: Buffer.byteLength(body, "utf-8"), outgoing_links: parsed.outgoingLinks, incoming_links: incoming.sort(), }; diff --git a/src/schemas/list.ts b/src/schemas/list.ts index aa18227..bf429ee 100644 --- a/src/schemas/list.ts +++ b/src/schemas/list.ts @@ -5,6 +5,8 @@ export const ListEntrySchema = z.object({ title: z.string().nullable(), type: z.string().nullable(), tags: z.array(z.string()), + word_count: z.number(), + size_bytes: z.number(), }); export const ListResultSchema = z.object({ diff --git a/src/schemas/map.ts b/src/schemas/map.ts index 8bfc68f..c4ba581 100644 --- a/src/schemas/map.ts +++ b/src/schemas/map.ts @@ -9,6 +9,8 @@ export const FileEntrySchema = z.object({ path: z.string(), title: z.string().nullable(), type: z.string().nullable(), + word_count: z.number(), + size_bytes: z.number(), }); export const MapResultSchema = z.object({ diff --git a/src/schemas/note.ts b/src/schemas/note.ts index 29058ee..b254035 100644 --- a/src/schemas/note.ts +++ b/src/schemas/note.ts @@ -5,6 +5,8 @@ export const ReadResultSchema = z.object({ vault: z.string(), frontmatter: z.record(z.string(), z.unknown()), body: z.string(), + word_count: z.number(), + size_bytes: z.number(), outgoing_links: z.array(z.string()), incoming_links: z.array(z.string()), }); From ffe65219fe40ac8935cebea12ae69537c9675a8a Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 26 Feb 2026 14:43:22 +0700 Subject: [PATCH 2/4] refactor: rename DOT_OBSIDIAN_PATH env var to OBI_VAULTS_PATH --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- README.md | 2 +- src/utils/vault.ts | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index cfb6794..2774906 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,6 +58,6 @@ Obsidian links can omit `.md` extensions and can be just a filename (shortest un ## Vault Path Resolution -1. `DOT_OBSIDIAN_PATH` env var +1. `OBI_VAULTS_PATH` env var 2. `~/Library/Mobile Documents/iCloud~md~obsidian/Documents` 3. Error with setup instructions diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dbe530..abecaa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,5 +14,5 @@ - Navigation commands: read, toc, links, list - Query commands: query, search, recent, unread - TOON default output with --json fallback -- Vault auto-discovery from iCloud path or DOT_OBSIDIAN_PATH env var +- Vault auto-discovery from iCloud path or OBI_VAULTS_PATH env var - Per-vault and global config support diff --git a/README.md b/README.md index b2e01b6..d52a344 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ obi query --type worker --tag billing ## Vault Resolution -1. `DOT_OBSIDIAN_PATH` env var pointing to the vaults parent directory +1. `OBI_VAULTS_PATH` env var pointing to the vaults parent directory 2. Falls back to `~/Library/Mobile Documents/iCloud~md~obsidian/Documents` 3. If neither exists, errors with setup instructions diff --git a/src/utils/vault.ts b/src/utils/vault.ts index 598bc96..1a902c6 100644 --- a/src/utils/vault.ts +++ b/src/utils/vault.ts @@ -36,13 +36,13 @@ export type VaultContext = { * Resolve the parent directory containing all vaults. */ export function resolveVaultsPath(): string { - const envPath = process.env.DOT_OBSIDIAN_PATH; + const envPath = process.env.OBI_VAULTS_PATH; if (envPath) { const resolved = resolve(envPath); if (existsSync(resolved)) { return resolved; } - throw new ObiError("DOT_OBSIDIAN_PATH does not exist", "VAULTS_PATH_MISSING", { + throw new ObiError("OBI_VAULTS_PATH does not exist", "VAULTS_PATH_MISSING", { path: resolved, }); } @@ -52,7 +52,7 @@ export function resolveVaultsPath(): string { } throw new ObiError( - "No vaults path found. Set DOT_OBSIDIAN_PATH or use iCloud Obsidian sync.", + "No vaults path found. Set OBI_VAULTS_PATH or use iCloud Obsidian sync.", "VAULTS_PATH_MISSING", ); } From 22278496e7d3989595bd39a4624384f448e560bc Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 26 Feb 2026 14:43:55 +0700 Subject: [PATCH 3/4] chore: bump version to 0.0.3 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abecaa1..e186769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.0.3 + +- Add `word_count` and `size_bytes` fields to list, map, and read output +- Rename `DOT_OBSIDIAN_PATH` env var to `OBI_VAULTS_PATH` + ## 0.0.2 - Rename all config paths from `dot-obsidian` to `obi` diff --git a/package.json b/package.json index b467653..ede4cb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@butttons/obi", - "version": "0.0.2", + "version": "0.0.3", "module": "src/index.ts", "type": "module", "description": "Read-only CLI for Obsidian vaults. Structured data for LLM consumption.", From ac26135193c1a4e32fc935e6814f3d97003e04af Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 26 Feb 2026 14:44:53 +0700 Subject: [PATCH 4/4] chore: add PR template --- .github/pull_request_template.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..7de0255 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,11 @@ +## Summary + + + +## Changes + + + +## Tests + +