Skip to content

feat(kb,okf): OKF init viewer and script fixes - #82

Merged
duyet merged 7 commits into
masterfrom
kb-okf-init-viewer
Jul 24, 2026
Merged

feat(kb,okf): OKF init viewer and script fixes#82
duyet merged 7 commits into
masterfrom
kb-okf-init-viewer

Conversation

@duyet

@duyet duyet commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Merges kb-okf-init-viewer into master.

https://claude.ai/code/session_01Np7fmVH3ihQc483DEVJBzi

Summary by Sourcery

Add an OKF bundle graph viewer script and integrate it into the kb init scaffolding and OKF skill documentation, while improving Antigravity plugin installation and introducing Command Code dispatch orchestration materials.

New Features:

  • Introduce a render_okf_viewer.py script for OKF bundles, generating index.md files and a self-contained HTML graph viewer.
  • Add a kb init skill and scaffolding scripts/templates to create a shared-brain OKF-conformant knowledge base with its own CLI and wiring helpers.
  • Provide Command Code integration artifacts including a skill, CLI reference, dispatcher agent, and dispatch command docs.

Enhancements:

  • Refine OKF skill and README docs to cover rendering an interactive graph viewer and update validation checklist.
  • Document kb usage and integration with OKF, clarifying how the initialized KB serves as an OKF v0.1 bundle with a viewer.
  • Adjust Antigravity install script plugin discovery to robustly build a plugin list without word-splitting issues.

Documentation:

  • Expand OKF SKILL and README docs with viewer rendering instructions and checklist updates.
  • Add comprehensive kb protocol, dreaming, raw data handling, and usage documentation for the initialized knowledge base.
  • Add Command Code CLI reference, dispatch command docs, and plugin README describing cmd orchestration patterns.

duyet and others added 6 commits July 5, 2026 18:58
kb gains an `init` skill/command that scaffolds a self-contained,
OKF v0.1-conformant shared-brain folder (AGENTS.md/DREAM.md/MEMORY.md,
memory/, raw/inbox/, and a vendored bin/kb CLI) — idempotent, and never
touches anything outside the target folder without explicit confirmation.

okf gains render_okf_viewer.py: a generic self-contained HTML graph
viewer for any OKF bundle, reading edges from related: frontmatter,
[[wikilinks]], and OKF's own [text](path.md) markdown links. kb's
scaffold vendors a copy so a generated kb keeps working standalone.

Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>
scripts/install-antigravity.sh: replace unquoted command-substitution
array assignment (SC2207) with a portable read loop — avoids word
splitting/globbing and stays bash 3.2 compatible (macOS default).

kb/skills/init/templates/scripts/wire.sh: silence SC2088 with an
explicit disable comment — the "~/kb" there is an intentional literal
display string, not a path meant to expand.

Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>
render_okf_viewer.py (okf canonical + kb vendored copy, kept in sync):
- Skip hidden directories (.git, .obsidian, .agent) when walking for
  concepts and when listing subdirs, so stray .md files and vault
  config never leak into the bundle or the graph.
- Fix a dead-link bug: "Groups" links in a generated index.md could
  point at a child directory that itself had no concepts and no
  index.md. Recompute index-worthiness bottom-up so a directory is
  only linked if it (or a descendant) actually has content.
- Warn (not silently corrupt) on duplicate slugs across directories,
  since build_bundle() uses the bare slug as the Cytoscape node id.
- Read notes with utf-8-sig so a UTF-8 BOM doesn't break frontmatter
  parsing.
- Escape text fields (label/type/description/tags/backlinks) before
  building the viewer's innerHTML, restrict the "source" link to
  http(s) URLs, and neutralize <, >, & in the embedded JSON bundle so
  a note's content can't break out of the <script> tag. Documented the
  remaining trust boundary: a concept's markdown body is still
  rendered via marked.parse unsanitized, same as opening a vault in
  Obsidian — this tool assumes the bundle itself is trusted content.

kb templates:
- sync.sh: don't swallow a failed rebase with `|| true` — a conflict
  must stop the script before it commits/pushes conflict markers.
- bin/kb: quote the cron path (spaces in $KB_DIR), add an xdg-open
  fallback for `kb viz` on Linux.
- wire.sh: `wire off` no longer creates a target file that didn't
  already exist.
- AGENTS.md: fix the frontmatter example to include the `<type>-`
  prefix, matching the naming rule described just above it.
- SKILL.md / README.md: markdownlint fixes (blank lines around a
  fenced block, language tag on the directory tree fence).

Addresses review feedback from CodeRabbit and Gemini Code Assist on
PR #80. Skipped: "open files without a context manager" (flagged
low-value by the bot itself, not worth the churn on a short-lived
CLI); full sanitization of rendered markdown body content (heavy
lift, documented as an explicit trust boundary instead — see
render_okf_viewer.py's module docstring).

Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>
Reformat every shell script touched in this branch with shfmt (default
style, matching the repo's Lint job) and every markdown file with
prettier — whitespace/structure only, no behavior change. Also:
- bin/kb: quote ${f#"$KB_DIR"/} per shellcheck SC2295.
- AGENTS.md: fix the memory-types table's column alignment (MD060).

Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>
Skill + /command-code:dispatch command + cmd-dispatcher agent to drive the
Command Code CLI (cmd) and orchestrate it as a headless sub-agent. Standard
dispatch invocation: cmd -p --yolo --max-turns 100000 --skip-onboarding across
isolated git worktrees, one branch per worker. Registered in both marketplaces.
…ssions

Resuming reloads the entire prior conversation; on a big multi-file run this can
exceed the model context window and fail immediately. Prefer a fresh scoped
cmd -p for small leftover tasks. Learned from a real dispatch this session.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai

sourcery-ai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds an OKF bundle HTML graph viewer script and wires it into the kb/init and okf plugins, documents new kb init and Command Code cmd-dispatch functionality, and fixes the Antigravity plugin installer script to correctly collect plugin names.

Sequence diagram for OKF bundle viewer rendering

sequenceDiagram
    actor User
    participant render_okf_viewer_py as render_okf_viewer.py
    participant FileSystem
    participant Browser

    User->>render_okf_viewer_py: python3 render_okf_viewer.py bundle_dir --title name --out viz.html
    render_okf_viewer_py->>FileSystem: collect(bundle_dir)
    render_okf_viewer_py->>FileSystem: write_indexes(bundle_dir, concepts, title)
    render_okf_viewer_py->>render_okf_viewer_py: build_bundle(bundle_dir, concepts)
    render_okf_viewer_py->>FileSystem: write viz.html

    User->>Browser: open viz.html
    Browser->>Browser: window.BUNDLE = bundle_json
    Browser->>Browser: cytoscape(...) layout using nodes and edges
    Browser->>User: interactive graph viewer (click node → detail pane)
Loading

Sequence diagram for kb init scaffolding with OKF viewer

sequenceDiagram
    actor User
    participant init_skill as kb_init_skill
    participant scaffold_sh as scaffold.sh
    participant Templates
    participant render_okf_viewer_py as render_okf_viewer.py

    User->>init_skill: init [target_path]
    init_skill->>init_skill: resolve target (arg | KB_DIR | ~/kb)
    init_skill->>scaffold_sh: bash scaffold.sh target

    scaffold_sh->>Templates: read AGENTS.md, README.md, scripts/*, memory/_TEMPLATE.md
    scaffold_sh->>scaffold_sh: put(src, dest) for missing files
    scaffold_sh->>scaffold_sh: create starter dirs (memory/*, raw/inbox, .agent)
    scaffold_sh->>render_okf_viewer_py: python3 render_okf_viewer.py memory --title basename(target) --out viz.html
    render_okf_viewer_py->>scaffold_sh: generated index.md + viz.html

    scaffold_sh->>init_skill: report created vs skipped files
    init_skill->>User: summarize scaffold + suggest PATH/git/wire follow-ups
Loading

Sequence diagram for Command Code headless dispatch workflow

sequenceDiagram
    actor User
    participant cmd_dispatcher as cmd_dispatcher_agent
    participant Git
    participant Cmd as cmd_cli

    User->>cmd_dispatcher: /command-code:dispatch "$ARGUMENTS"
    cmd_dispatcher->>Cmd: which cmd && cmd status
    cmd_dispatcher->>cmd_dispatcher: parse $ARGUMENTS into tasks/issues

    loop per task
        cmd_dispatcher->>Git: git worktree add -b feat/slug /path/to/wt/slug base_branch
        cmd_dispatcher->>Cmd: cmd -p "spec for task" --yolo --max-turns 100000 --skip-onboarding > wt.log &
        Cmd-->>Git: implement, test, git commit
    end

    cmd_dispatcher->>Git: git -C /path/to/wt/slug diff --stat base_branch..HEAD
    cmd_dispatcher->>User: report per-branch changes, completion, and merge recommendations
Loading

File-Level Changes

Change Details Files
Fix Antigravity plugin installer to robustly populate the PLUGINS bash array.
  • Replaces command-substitution PLUGINS assignment with a while-read loop appending to the array to avoid word-splitting issues.
  • Keeps manifest discovery logic intact while only changing array population and indentation.
  • Leaves install semantics (all vs single plugin, symlink creation, Python JSON parsing) unchanged.
scripts/install-antigravity.sh
Extend OKF skill and README to cover rendering an interactive graph viewer via render_okf_viewer.py.
  • Updates okf SKILL.md description and checklist to mention rendering viz.html.
  • Adds a dedicated "Render a graph viewer" section documenting usage, link sources, and coloring rules.
  • Mentions render_okf_viewer.py in okf/README.md alongside validate_okf.py and other tooling.
okf/skills/okf/SKILL.md
okf/README.md
Introduce a kb init skill that scaffolds a self-contained shared-brain/OKF kb folder with CLI, templates, and wiring utilities.
  • Adds kb README entries and usage examples for the new init command.
  • Defines kb/skills/init/SKILL.md describing behavior, safety, idempotency, and follow-up wiring steps.
  • Adds kb/commands/init.md describing the /init command semantics.
  • Adds scaffold.sh to create the kb layout, vendor scripts/bin, seed memory groups, and generate initial index.md + viz.html.
  • Introduces vendored kb templates: AGENTS.md protocol, CLAUDE.md pointer, DREAM.md consolidation plan, README.md, memory/_TEMPLATE.md, raw/README.md, .gitignore, .agent/state.json, and empty group dirs.
  • Adds kb scripts: lint.sh (frontmatter + link + secret checks), sync.sh (pull/commit/push with remote), wire.sh (manage global agent config wiring), render_okf_viewer.py (vendored OKF viewer/index generator), and kb CLI shim (bin/kb).
kb/README.md
kb/skills/init/SKILL.md
kb/commands/init.md
kb/skills/init/scripts/scaffold.sh
kb/skills/init/templates/AGENTS.md
kb/skills/init/templates/CLAUDE.md
kb/skills/init/templates/DREAM.md
kb/skills/init/templates/README.md
kb/skills/init/templates/memory/_TEMPLATE.md
kb/skills/init/templates/raw/README.md
kb/skills/init/templates/scripts/lint.sh
kb/skills/init/templates/scripts/sync.sh
kb/skills/init/templates/scripts/wire.sh
kb/skills/init/templates/scripts/render_okf_viewer.py
kb/skills/init/templates/bin/kb
kb/skills/init/templates/gitignore
Add OKF bundle graph viewer script render_okf_viewer.py to the okf plugin.
  • Implements a stdlib-only Python script that scans an OKF bundle, parses flat frontmatter, discovers concepts, and builds a graph model from related/wikilinks/markdown links.
  • Generates OKF index.md files bottom-up for each dir containing concepts or children, with okf_version frontmatter at the root and progressive-disclosure group/concept listings.
  • Emits a self-contained viz.html using Cytoscape + marked from CDN, with type-based color palette, degree-based node sizing, backlinks, and trusted markdown body rendering.
  • Provides CLI flags for bundle_dir, title, and out path, and prints a summary of generated artifacts.
okf/skills/okf/scripts/render_okf_viewer.py
Add a Command Code integration plugin that documents cmd usage and dispatch patterns and introduces a cmd-dispatcher agent.
  • Adds command-code/skills/command-code/SKILL.md detailing when/how to use cmd, mandatory headless flags, worktree isolation, dispatch workflow, safety & consent.
  • Provides command-code/references/cli-reference.md with full cmd CLI option, sub-command, slash command, and exit-code reference.
  • Defines command-code/agents/cmd-dispatcher.md agent spec for orchestrating headless cmd workers with tools and operating rules.
  • Adds command-code/commands/dispatch.md describing /command-code:dispatch workflow for fan-out over issues/tasks.
  • Creates command-code/README.md summarizing plugin purpose, components, dispatch pattern, and safety requirements.
  • Introduces empty plugin.json stubs under .claude-plugin and .codex-plugin for marketplace/plugin wiring.
command-code/skills/command-code/SKILL.md
command-code/references/cli-reference.md
command-code/agents/cmd-dispatcher.md
command-code/commands/dispatch.md
command-code/README.md
command-code/.claude-plugin/plugin.json
command-code/.codex-plugin/plugin.json
Update marketplace and plugin manifests to register kb/init, okf viewer capabilities, and command-code.
  • Modify top-level marketplace.json and per-plugin .claude-plugin/.codex-plugin plugin.json manifests to include new skills, commands, and scripts.
  • Ensure kb and okf plugins advertise init, okf rendering, and graph viewer tooling for Antigravity and Claude/Codex marketplaces.
.claude-plugin/marketplace.json
kb/.claude-plugin/plugin.json
kb/.codex-plugin/plugin.json
marketplace.json
okf/.claude-plugin/plugin.json
okf/.codex-plugin/plugin.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@duyet, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5886e58b-dbb1-4b86-b34f-aafd71005f40

📥 Commits

Reviewing files that changed from the base of the PR and between 82de402 and a00c323.

📒 Files selected for processing (9)
  • .claude-plugin/marketplace.json
  • command-code/.claude-plugin/plugin.json
  • command-code/.codex-plugin/plugin.json
  • command-code/README.md
  • command-code/agents/cmd-dispatcher.md
  • command-code/commands/dispatch.md
  • command-code/skills/command-code/SKILL.md
  • command-code/skills/command-code/references/cli-reference.md
  • marketplace.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kb-okf-init-viewer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@duyet
duyet merged commit aa2a023 into master Jul 24, 2026
4 of 6 checks passed
@duyet
duyet deleted the kb-okf-init-viewer branch July 24, 2026 14:02

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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