fix(open-knowledge): make ok init git-root promotion visible + add…#423
Merged
Conversation
…ir/--json (#2335) * fix(open-knowledge): surface ok init git-root promotion + add --content-dir and --json ok init in a git sub-folder scaffolds .ok/ at the git root and scopes the whole repo as content. That promotion previously surfaced only as a stdout log line that a piped tail could drop, so a large repo could get whole-repo-scoped unnoticed. - Disclose the promotion as a stderr warning at decision time and repeat it in the init summary next to the file-count preview. - Add ok init --content-dir <dir> to scope content to a sub-folder (written to .ok/config.yml as content.dir). Out-of-project, missing, or file paths are rejected with a usage error (exit 64). An explicit scope suppresses the whole-repo promotion warning. - Add ok init --json to emit a structured summary (projectRoot, gitRootPromoted, contentDir, contentFileCount, and more) to stdout; diagnostics stay on stderr. The content-scope disclosure distinguishes a scaffolding failure from a pre-existing config so it never falsely claims config.yml already exists. * fix(open-knowledge): symlink-safe --content-dir + independent --json scope read Address two review edge cases on the ok init scope surfaces: - resolveRequestedContentDir canonicalizes both the project root and the requested path before the containment check, so --content-dir . no longer wrongly throws under a symlinked working tree (macOS /var to /private/var). - The --json contentDir field reads config.content.dir in its own try, independent of the preview walk, so a preview failure on a narrowed re-init can't leave the scope field at a stale '.' seed that contradicts disk. * fix(open-knowledge): sharpen --content-dir errors, --help, and --json preview signal Address improvement-grade review recommendations: - resolveRequestedContentDir distinguishes ENOENT from other stat errors (EACCES/ELOOP/ENOTDIR) so a readable-but-inaccessible path no longer reports 'does not exist'. - --content-dir help text notes it is ignored on re-init when config.yml already exists. - --json adds a previewError field so a null contentFileCount is unambiguous (preview failure vs genuinely zero files). * docs(open-knowledge): clarify --content-dir help — input is cwd-relative, stored git-root-relative The prior help text conflated the input anchor (current directory) with the storage anchor (git root), making it unclear which a relative path resolves against. Spell out that <dir> is interpreted relative to the current directory and then saved to config.yml as a git-root-relative content.dir. * docs(open-knowledge): simplify --content-dir help text GitOrigin-RevId: f3ceccba8dbf668aceee9c0c998969f4d003de28
Contributor
There was a problem hiding this comment.
Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/28541831550). Source of truth is the monorepo; direct edits on inkeep/open-knowledge are overwritten on next sync.
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.
fix(open-knowledge): make
ok initgit-root promotion visible + add--content-dirWhen
ok initruns in a sub-folder of a git repo, it scaffolds.ok/at thegit root and scopes the whole repo as content (one
.ok/per git repo). Thatpromotion previously surfaced only as a single
console.logline on stdout,which
ok init 2>&1 | tail/| headsilently dropped — so a large repo couldget whole-repo-scoped without the user noticing.
time, and repeated in the init summary directly next to the "Found N markdown
files" preview, naming the sub-folder and how to narrow scope.
ok init --content-dir <path>flag scopes content to<path>(resolvedrelative to the current directory, written to
.ok/config.ymlascontent.dir).--content-dir .from a promoted sub-folder scopes theproject to that folder. Paths outside the project root, missing paths, or
files are rejected with a clear usage error (exit 64). Supplying the flag
suppresses the whole-repo promotion warning (the scope choice was explicit).
ok init --jsonflag prints a machine-readable summary to stdout(
projectRoot,gitRootPromoted,promotedFromDir,contentDir,contentDirRequested,contentDirApplied,contentFileCount,didGitInit,mcpAction,editors[]) so scripts and agents read the promotion + scopesignals as fields instead of scraping log text. Diagnostics stay on stderr;
stdout carries only the JSON document.
Behavior of the promotion itself is unchanged.