Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Summary

<!-- One or two sentences describing the overall goal of the PR. -->

## Changes

<!-- Group changes by area with ### subheadings. One bullet per change, describe what not how. -->

## Tests

<!-- Describe what was tested and why. Omit if no test changes. -->
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -14,5 +19,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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
2 changes: 2 additions & 0 deletions src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
};
}),
);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export async function map({ ctx }: { ctx: CommandContext }): Promise<MapResult>
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"),
};
}),
);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
2 changes: 2 additions & 0 deletions src/schemas/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions src/schemas/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions src/schemas/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
});
Expand Down
6 changes: 3 additions & 3 deletions src/utils/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand All @@ -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",
);
}
Expand Down