Skip to content

fix(open-knowledge): make ok init git-root promotion visible + add…#423

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jul 1, 2026
Merged

fix(open-knowledge): make ok init git-root promotion visible + add…#423
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

fix(open-knowledge): make ok init git-root promotion visible + add --content-dir

When ok init runs in a sub-folder of a git repo, it scaffolds .ok/ at the
git root and scopes the whole repo as content (one .ok/ per git repo). That
promotion previously surfaced only as a single console.log line on stdout,
which ok init 2>&1 | tail / | head silently dropped — so a large repo could
get whole-repo-scoped without the user noticing.

  • The promotion is now disclosed as a styled warning on stderr at decision
    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.
  • New ok init --content-dir <path> flag scopes content to <path> (resolved
    relative to the current directory, written to .ok/config.yml as
    content.dir). --content-dir . from a promoted sub-folder scopes the
    project 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).
  • New ok init --json flag prints a machine-readable summary to stdout
    (projectRoot, gitRootPromoted, promotedFromDir, contentDir,
    contentDirRequested, contentDirApplied, contentFileCount, didGitInit,
    mcpAction, editors[]) so scripts and agents read the promotion + scope
    signals as fields instead of scraping log text. Diagnostics stay on stderr;
    stdout carries only the JSON document.

Behavior of the promotion itself is unchanged.

…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

@inkeep-internal-ci inkeep-internal-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@inkeep-oss-sync
inkeep-oss-sync Bot merged commit 9a42fff into main Jul 1, 2026
2 checks passed
@inkeep-oss-sync
inkeep-oss-sync Bot deleted the copybara/sync branch July 1, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant