diff --git a/README.md b/README.md index fce3ffd..244999e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ and its package/MCP regression tests. The `gitkb/codex-plugins` marketplace refe Plugin behavior changes belong in this repository. Catalog release promotion only updates the marketplace's approved commit selector. -GitKB gives Codex local code intelligence first: symbols, callers, callees, impact analysis, dead-code detection, semantic search, and service-edge queries through the `git-kb` CLI and MCP tools. Full GitKB setup adds the persistent knowledge graph for tasks, specs, decisions, architecture, and team sync. +GitKB gives Codex local code intelligence first: symbols, callers, callees, impact analysis, dead-code detection, semantic search over KB documents, and service-edge queries through the `git-kb` CLI and MCP tools. Full GitKB setup adds the persistent knowledge graph for tasks, specs, decisions, architecture, and team sync. The user-facing plugin README lives at [plugin/README.md](plugin/README.md). @@ -17,7 +17,7 @@ The user-facing plugin README lives at [plugin/README.md](plugin/README.md). plugin/ # Installable Codex plugin payload plugin/.codex-plugin/plugin.json # Plugin manifest plugin/hooks/hooks.json # Codex hook registration -plugin/.mcp.json # GitKB MCP server registration +plugin/.mcp.json # GitKB core, code and semantic MCP servers plugin/skills/ # Minimal bootstrap skill tests/ # Packaging and policy checks Makefile # Local validation and release checks @@ -28,7 +28,9 @@ Makefile # Local validation and release checks This plugin is a thin marketplace and bootstrap wrapper. It should not become a second copy of GitKB's canonical Codex integration. - Keep first value CLI-backed through `git-kb code ...`. -- Delegate hooks to `git-kb hook codex`. +- Delegate every hook to `git-kb hook codex`. From gitkb/gitkb-core#1767, core + forwards the guidance and search-enrichment events to the code extension and + stays silent without it; see `plugin/README.md` for older cores. - Keep legacy harness behavior out of the plugin identity and behavior. - Do not vendor the full `.kb/skills` set generated by `git-kb init codex`. - Do not add broad command files that duplicate canonical GitKB workflows. diff --git a/plugin/.codex-plugin/plugin.json b/plugin/.codex-plugin/plugin.json index feb0065..9914dff 100644 --- a/plugin/.codex-plugin/plugin.json +++ b/plugin/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "gitkb", - "version": "0.1.2", + "version": "0.1.3", "description": "Codex hooks, skills, and MCP config for GitKB code-intelligence guidance.", "author": { "name": "GitKB", diff --git a/plugin/.mcp.json b/plugin/.mcp.json index 6c0cc04..64b2902 100644 --- a/plugin/.mcp.json +++ b/plugin/.mcp.json @@ -15,6 +15,18 @@ "ATC_ROOT", "ATC_CONFIG" ] + }, + "gitkb-code": { + "command": "git-kb-code", + "args": [ + "mcp" + ] + }, + "gitkb-semantic": { + "command": "git-kb-semantic", + "args": [ + "mcp" + ] } } } diff --git a/plugin/README.md b/plugin/README.md index 1b0e7d7..b72ab70 100644 --- a/plugin/README.md +++ b/plugin/README.md @@ -1,6 +1,6 @@ # GitKB for Codex -GitKB gives Codex local code intelligence first: symbols, callers, callees, impact analysis, dead-code detection, semantic search, and service-edge queries through the `git-kb` CLI and MCP tools. Full GitKB setup adds the persistent knowledge graph for tasks, specs, decisions, architecture, and team sync. +GitKB gives Codex local code intelligence first: symbols, callers, callees, impact analysis, dead-code detection, semantic search over KB documents, and service-edge queries through the `git-kb` CLI and MCP tools. Full GitKB setup adds the persistent knowledge graph for tasks, specs, decisions, architecture, and team sync. ## First Value @@ -21,7 +21,7 @@ git-kb code callers "" --json git-kb code callees "" --json git-kb code impact path/to/file --json git-kb code dead --json -git-kb ai semantic "query" --json +git-kb semantic search "query" --json # committed KB documents, not source code ``` Raw text search remains appropriate for exact strings, logs, config, docs, generated output, snapshots, and one-off file checks. @@ -36,7 +36,28 @@ brew install gitkb/tap/gitkb curl -fsSL https://get.gitkb.com/install.sh | bash ``` -If `git-kb` is missing, the plugin hooks fail open. Codex can still guide installation from the bundled skill. +The plugin needs `git-kb` on `PATH`: it runs every hook and the core MCP +server. + +**MCP servers.** The code and semantic MCP servers need GitKB 1.0.0 or later +with its `git-kb code` and `git-kb semantic` extensions (the `git-kb-code` and +`git-kb-semantic` programs). From 1.0.0 the install script adds both. With an +install of `git-kb` alone, put them on `PATH` beside it from the release's +`gitkb-code-.tar.gz` and `gitkb-semantic-.tar.gz`. A +missing extension's MCP server does not start; the core `gitkb` server still +does, and Codex can still guide installation from the bundled skill. + +**Hooks.** Every hook runs `git-kb hook codex`. What the code-search guidance +events (`SessionStart`, `UserPromptSubmit`, `PostToolUse`) do depends on the +installed core: + +- GitKB 0.2.19: `git-kb hook codex` still has its own built-in guidance. +- GitKB 1.0.0: these three events are silent and never block. +- A release with gitkb/gitkb-core#1767, plus `git-kb-code`: the guidance comes + from the extension. Without the extension these events are silent and never + block. +- No `git-kb` on `PATH`: every hook command fails to start, and Codex reports + the failure. Install `git-kb` first. ## Optional Full KB Setup @@ -52,8 +73,11 @@ git-kb init codex ## What This Plugin Ships - one focused code-intelligence skill; -- Codex lifecycle hooks that call `git-kb hook codex`; -- MCP configuration for `git-kb mcp`; +- Codex lifecycle hooks that call `git-kb hook codex`: safety checks on + `PreToolUse` and `PermissionRequest`, and code-search guidance on + `SessionStart`, `UserPromptSubmit` and `PostToolUse`, which core forwards to + `git-kb-code`; +- MCP configuration for `git-kb mcp`, `git-kb-code mcp` and `git-kb-semantic mcp`; - inherited session activity context for the MCP process; - no vendored copy of the full canonical `git-kb init codex` skill set. @@ -65,7 +89,7 @@ When Codex runs through an ATC shim, the plugin forwards the parent's six Codex filters the MCP environment; installing a newer `git-kb` or `atc` binary alone does not update this plugin launch configuration. -Install the updated plugin (`0.1.2`) from your marketplace and restart or resume +Install the updated plugin (`0.1.3`) from your marketplace and restart or resume Codex through the ATC shim to start a new MCP process. Existing MCP processes keep the environment with which they started. Previously omitted activity records are not backfilled by this update. diff --git a/plugin/skills/gitkb-code-intelligence/SKILL.md b/plugin/skills/gitkb-code-intelligence/SKILL.md index ec89497..eb08b44 100644 --- a/plugin/skills/gitkb-code-intelligence/SKILL.md +++ b/plugin/skills/gitkb-code-intelligence/SKILL.md @@ -13,13 +13,20 @@ git-kb code symbols --file --json git-kb code callers "" --json git-kb code callees "" --json git-kb code impact --json +``` + +To find committed KB documents (tasks, specs, decisions) by meaning — not source code: + +```bash git-kb semantic search "" --json ``` -When MCP tools are enabled, prefer the matching GitKB MCP tools for structured output. +When MCP tools are enabled, prefer the matching tools for structured output: the `gitkb-code` server has the code tools (`kb_symbols`, `kb_callers`, `kb_impact`, ...), `gitkb-semantic` has `kb_semantic`, and `gitkb` has the KB documents. Raw `rg`, `grep`, `find`, and file reads are still appropriate for exact strings, logs, config, docs, generated output, snapshots, and one-off content checks. +`git-kb code` and `git-kb semantic` are extensions (`git-kb-code` and `git-kb-semantic` on `PATH`), not part of core `git-kb`. If `git-kb code --help` or `git-kb semantic --help` fails, or their MCP servers did not start, fall back to raw search and offer to install them: from GitKB 1.0.0, `curl -fsSL https://get.gitkb.com/install.sh | bash` installs `git-kb` with both extensions; otherwise put `git-kb-code` and `git-kb-semantic` from the release's `gitkb-code-.tar.gz` and `gitkb-semantic-.tar.gz` (https://github.com/gitkb/gitkb-releases/releases) on `PATH` beside `git-kb`. + If code intelligence returns no results for code that exists, run: ```bash diff --git a/tests/mcp-contract.py b/tests/mcp-contract.py index 02f70d4..72cd493 100644 --- a/tests/mcp-contract.py +++ b/tests/mcp-contract.py @@ -18,7 +18,7 @@ class LaunchContract(unittest.TestCase): def test_parent_context_is_forwarded_by_name_only(self): """Require the activity/registry allowlist while rejecting fixed environment values.""" config = json.loads((PLUGIN_ROOT / ".mcp.json").read_text()) - self.assertEqual(set(config["mcpServers"]), {"gitkb"}) + self.assertEqual(set(config["mcpServers"]), {"gitkb", "gitkb-code", "gitkb-semantic"}) server = config["mcpServers"]["gitkb"] names = server["env_vars"] self.assertIsInstance(names, list) @@ -29,12 +29,18 @@ def test_parent_context_is_forwarded_by_name_only(self): self.assertEqual(server["command"], "git-kb") self.assertEqual(server["args"], ["mcp"]) + def test_extension_servers_match_their_own_registrations(self): + """Use the names and argv that `git-kb code init` and `git-kb semantic connect` write.""" + servers = json.loads((PLUGIN_ROOT / ".mcp.json").read_text())["mcpServers"] + self.assertEqual(servers["gitkb-code"], {"command": "git-kb-code", "args": ["mcp"]}) + self.assertEqual(servers["gitkb-semantic"], {"command": "git-kb-semantic", "args": ["mcp"]}) + def test_cache_version_changes_with_launch_contract(self): """Ensure the installable version cannot reuse either pre-fix cache entry.""" manifest = json.loads((PLUGIN_ROOT / ".codex-plugin/plugin.json").read_text()) version = tuple(int(part) for part in manifest["version"].split(".")) self.assertEqual(len(version), 3) - self.assertGreaterEqual(version, (0, 1, 2), "old cache versions lack this contract") + self.assertGreaterEqual(version, (0, 1, 3), "old cache versions lack this contract") self.assertEqual(manifest["mcpServers"], "./.mcp.json") diff --git a/tests/package-policy.sh b/tests/package-policy.sh index e7fe9c3..26925c9 100755 --- a/tests/package-policy.sh +++ b/tests/package-policy.sh @@ -31,11 +31,14 @@ jq -e '.skills == "./skills/"' plugin/.codex-plugin/plugin.json >/dev/null \ jq -e '.mcpServers == "./.mcp.json"' plugin/.codex-plugin/plugin.json >/dev/null \ || fail "plugin manifest must point at bundled MCP config" -hook_commands=$(jq -r '.. | objects | select(.type? == "command") | .command' plugin/hooks/hooks.json) -test -n "$hook_commands" || fail "expected command hooks" -if echo "$hook_commands" | grep -v '^git-kb hook codex$' >/dev/null; then - fail "all hooks must delegate to git-kb hook codex" -fi +# Every event goes to core, which forwards the code events to git-kb-code and +# fails open without it. +hook_routes=$(jq -r '.hooks | to_entries[] | .key as $event + | .value[].hooks[] | select(.type == "command") | "\($event)=\(.command)"' plugin/hooks/hooks.json | sort) +expected_routes=$(printf '%s=git-kb hook codex\n' \ + PermissionRequest PostToolUse PreToolUse SessionStart UserPromptSubmit) +test "$hook_routes" = "$expected_routes" \ + || fail "every hook event must delegate to git-kb hook codex" if grep -R "gitkb-a[t]c\\|@personal" . \ --exclude-dir=.git \