Add headless YAOS CLI (packages/cli)#13
Closed
enieuwy wants to merge 3 commits intokavinsood:mainfrom
Closed
Conversation
Two bugs prevented the filesystem watcher from working: 1. shouldIgnoreNormalizedPath treated null-stats paths as files. When chokidar calls _isIgnored for the root directory without stats, the path was checked against isMarkdownSyncable (returns false for directory names not ending in .md), causing the entire tree to be pruned. Fix: when stats are null, only ignore paths that are definitively non-markdown files (have an extension but not .md). 2. Chokidar's internal _isIgnored calls .map() on the ignored option. When ignored is a bare function, .map() throws TypeError (functions don't have .map), which is silently caught — the watcher starts but watches nothing. Wrapping in an array preserves the function through normalizeIgnored's type check. Also upgraded chokidar from 4.0.3 to 5.0.0.
Author
|
Superseded by #16 (feat/headless-cli-fresh branch with code review fixes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11
Adds a headless CLI client that syncs a filesystem directory to a YAOS CRDT room — no Obsidian UI required.
What this does
@yaos/cliis a new npm workspace (packages/cli/) that reuses the existingVaultSynccore, replaces the ObsidianVaultAPI with Nodefs+ chokidar, and runs as a long-lived daemon or one-shot sync tool.Commands
Architecture
Shared code changes (minimal, non-breaking):
normalizeVaultPath()tosrc/utils/normalizeVaultPath.ts(replaces runtimeobsidian.normalizePathinVaultSync)VaultSyncaccept an optionalVaultSyncPersistenceFactoryto inject persistence (headless uses a no-op adapter; plugin uses IndexedDB as before)logPersistenceOpenErroroption to suppress expected no-op persistence errorsCLI-only code (
packages/cli/):NodeDiskMirror— bidirectional fs-to-CRDT sync with: chokidar watcher, write suppression (content-hash fingerprint), per-path write locks, dirty-path coalescing, debounced write batching, rename inference from create+delete pairs, frontmatter guardHeadlessYaosClient— orchestrates VaultSync + NodeDiskMirror lifecycle, reconnection reconciliation with generation tracking~/.config/yaos/cli.jsonWhat is intentionally deferred (v1 scope)
y-leveldbor similar is a natural follow-up.fs.writeFiledirectly; write-to-temp-then-rename would be safer.Verification
npm run buildpassnpm run test:regressionspassnpm run typecheck --workspace @yaos/clipassnpm run build --workspace @yaos/clipassnpm run test --workspace @yaos/clipass (2 passing)yaos-cli syncwith unreachable server produces structured JSON output with conservative reconcile mode