Conversation
Add foundational module for relationship shard file operations: - relationshipIdFor(): generates stable relationship IDs - shardForFromId(): determines shard filename from entity ID - readShard()/writeShard(): read/write YAML shard files - mergeRecords(): dedupes and merges relationship records - pruneDangling(): filters out dangling references Includes comprehensive test coverage for all functions.
Remove frontmatter links extraction from markdown extractor: - Remove extractRelationships() function and LinkObject interface - Remove links field from ExtractedEntity interface - Stop extracting relationships from data.links - Update error messages to reference relationship shards instead - Update tests to expect empty relationships array Markdown files now contain only entity metadata and prose; relationships are managed via separate shard files.
Remove relationship extraction from symbols.yaml manifest: - Remove extractRelationships() function and LinkObject interface - Remove relationships and links from ManifestSymbol interface - Remove links field from ExtractedEntity interface - Stop extracting relationships from symbol.relationships and symbol.links - Update tests to expect empty relationships array Symbols now contain only semantic data; relationships are managed via separate shard files.
Add dedicated extractor for relationship shard files: - extractFromRelationshipShards(): discovers and parses .kb/relationships/*.yaml - Validates relationship types against schema - Converts records to ExtractedRelationship format - flattenRelationships(): combines multiple shard results - validateRelationships(): checks for dangling references Includes comprehensive tests covering valid/invalid cases, multiple shards, and validation scenarios.
…tionship shards storage
- Add migration script to extract embedded relationships to shard files - Fix sync command to process relationship shards separately from manifests - Add shard relationship assertion loop to sync command - Fix ESM import extension in relationships extractor - Add rebuild flag support to force re-extraction of all files - Migrate 86 relationships to 42 shard files - Fix sync tests for new shard-based architecture All 85 valid relationships now sync successfully from canonical shard storage.
- Remove duplicate writeFileSync in relationship shard test - Quote ISO dates to prevent YAML auto-conversion to Date objects - Add proper closing parenthesis for writeFileSync call
- Fix missing closing brace in SymbolEntry interface - Add proper JSDoc comments for sourceFile and sourceLine - Add deprecated links field for backward compatibility
- Handle ISO dates parsed as Date objects by YAML parser - Normalize Date.toISOString() output to remove .000Z milliseconds - Add missing exports: shardForFromId, mergeRecords - Add pruneDangling and relationshipIdFor exports All 30 shard tests now pass.
Co-authored-by: Looted <6255880+Looted@users.noreply.github.com>
Address 15 code review issues from file-first storage PR
File first storage
…ts, changelog, and ADR-016 Co-authored-by: Looted <6255880+Looted@users.noreply.github.com>
fix(opencode): address review feedback — prompt formatting, hook contract tests, changelog, ADR-016
Improved opencode guidance, esp comments
- Changed tests to expect empty KB creation when --from is missing/invalid - Removed defaultBranch fallback behavior from tests - Removed deprecated 'uses configured defaultBranch' test - Simplified 'prefers --from' test to focus on valid --from behavior - New behavior: invalid/missing --from creates empty KB, no fallback to main
…ction calls - Convert unit tests to integration tests by calling kibi branch ensure CLI command - This ensures tests verify the actual CLI behavior rather than bypassing integration paths - Fixes false-negative pattern where tests called functions directly instead of through CLI
The MCP package imports escapeAtom and toPrologAtom from kibi-cli/prolog/codec, but this subpath was not exported. This caused the MCP server to crash on startup with ERR_PACKAGE_PATH_NOT_EXPORTED when installed from npm.
…taged.ts Co-authored-by: Looted <6255880+Looted@users.noreply.github.com>
fix(cli): ESM-compatible child_process import + execSync injection in git-staged.ts
…uidance Modularize improve rules improve guidance
There was a problem hiding this comment.
Pull request overview
This PR implements canonical relationship shard storage and expands traceability tooling across the CLI, MCP server, VS Code extension, and OpenCode plugin, alongside related docs/test updates.
Changes:
- Introduces relationship shard extraction/import and adds “symbol-traceability” checking (plus config/schema support for check rules).
- Refactors VS Code extension activation into dedicated modules and improves relationship querying fallbacks.
- Updates OpenCode injected guidance and adds tests to lock down the hook/prompt contract; enhances publish workflow for opencode.
Reviewed changes
Copilot reviewed 168 out of 173 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/vscode/src/treeProvider.ts | Adjusts imports (reorders exec) as part of extension refactor. |
| packages/vscode/src/symbolIndex.ts | Deprecates links, improves CLI relationship query fallback to kibi on PATH. |
| packages/vscode/src/relationshipCache.ts | Removes “header application” comment block noise. |
| packages/vscode/src/hoverProvider.ts | Removes “header application” comment block noise. |
| packages/vscode/src/helpers.ts | Removes “header application” comment block noise. |
| packages/vscode/src/codeLensProvider.ts | Supports paths.symbols, makes links optional/safer. |
| packages/vscode/src/codeActionProvider.ts | Removes “header application” comment block noise. |
| packages/vscode/src/activation/workspace.ts | Adds workspace-root resolution helper (incl. env fallback). |
| packages/vscode/src/activation/treeView.ts | Adds tree view registration + watcher for .kb/branches/**/kb.rdf. |
| packages/vscode/src/activation/traceability.ts | Adds consolidated registration for code actions/lens/hover + symbol index resolution. |
| packages/vscode/src/activation/navigation.ts | Adds navigation commands for opening entities/focusing KB view. |
| packages/vscode/src/activation/mcp.ts | Adds MCP serverPath validation and PATH autodetection helpers. |
| packages/vscode/src/activation/index.ts | Exposes activation helper entry-point exports. |
| packages/vscode/src/activation/contextOnOpen.ts | Adds “context on open” querying via MCP command. |
| packages/vscode/package.json | Bumps VS Code extension version to 0.2.1. |
| packages/vscode/media/kibi-activitybar.svg | Replaces activity bar icon SVG. |
| packages/vscode/icon.svg | Replaces extension icon SVG. |
| packages/opencode/tests/prompt.test.ts | Adds guidance-focused tests and improves sentinel string creation. |
| packages/opencode/tests/hook-contract.test.ts | Adds hook contract tests for hookMode behavior and prompt injection rules. |
| packages/opencode/src/prompt.ts | Refreshes injected guidance; uses buildPrompt() in injection. |
| packages/opencode/package.json | Bumps opencode package version; formats files field. |
| packages/opencode/README.md | Documents /init-kibi + hook policy per ADR-016. |
| packages/opencode/CHANGELOG.md | Adds 0.3.0 release notes. |
| packages/mcp/tsconfig.json | Sets rootDir and adds TS path for kibi-cli/prolog/codec. |
| packages/mcp/tests/tools/query.test.ts | Switches parsing-function imports to codec module. |
| packages/mcp/src/workspace.ts | Removes “header application” comment block noise. |
| packages/mcp/src/types/js-yaml.d.ts | Removes “header application” comment block noise. |
| packages/mcp/src/tools/upsert.ts | Uses shared Prolog codec helpers; cleans up inline helpers. |
| packages/mcp/src/tools/symbols.ts | Removes “header application” comment block noise. |
| packages/mcp/src/tools/suggest-shared-facts.ts | Formatting/robustness tweaks in parsing and query string. |
| packages/mcp/src/tools/query-relationships.ts | Removes “header application” comment block noise. |
| packages/mcp/src/tools/prolog-list.ts | Removes “header application” comment block noise. |
| packages/mcp/src/tools/list-types.ts | Removes “header application” comment block noise. |
| packages/mcp/src/tools/impact.ts | Uses shared escapeAtom; removes local implementation. |
| packages/mcp/src/tools/derive.ts | Uses shared escapeAtom; removes local implementation. |
| packages/mcp/src/tools/delete.ts | Uses shared escapeAtom; removes local implementation. |
| packages/mcp/src/tools/coverage-report.ts | Removes “header application” comment block noise. |
| packages/mcp/src/tools/check.ts | Adds additional rule names + implements symbol-traceability collection. |
| packages/mcp/src/tools/branch.ts | Removes “header application” comment block noise. |
| packages/mcp/src/tools-config.ts | Expands tool descriptions and rule enum list. |
| packages/mcp/src/server/transport.ts | Adds stdio transport error handlers with JSON-RPC error responses + shutdown. |
| packages/mcp/src/env.ts | Removes “header application” comment block noise. |
| packages/core/src/checks.pl | Adds symbol-traceability check + JSON aggregator with options. |
| packages/cli/tests/traceability/traceability.test.ts | Improves git exec mocking by injecting exec function. |
| packages/cli/tests/prolog.test.ts | Reads expected CLI version from package.json instead of hardcoding. |
| packages/cli/tests/hooks.test.ts | Adds coverage for hook update behavior + sed caret regression. |
| packages/cli/tests/extractors/markdown.test.ts | Removes link-extraction tests; updates expectations for relationships = 0. |
| packages/cli/tests/extractors/manifest.test.ts | Updates relationship assertions to content-based matching. |
| packages/cli/tests/commands/sync.test.ts | Updates fixtures/IDs; tests shard-based relationship extraction. |
| packages/cli/tests/commands/init.test.ts | Asserts $schema + checks config defaults in generated config.json. |
| packages/cli/tests/commands/init-helpers.test.ts | Makes git branch tests deterministic + verifies sed caret regression fix. |
| packages/cli/tests/commands/gc.test.ts | Updates gc expectations and “keep-branch” retention scenario. |
| packages/cli/src/utils/rule-registry.ts | Adds centralized rule registry + defaults + merging helpers. |
| packages/cli/src/utils/config.ts | Adds checks config support + schema URL in default config. |
| packages/cli/src/utils/branch-resolver.ts | Marks default-branch resolution as deprecated. |
| packages/cli/src/types/relationships.ts | Removes “header application” comment block noise. |
| packages/cli/src/types/js-yaml.d.ts | Removes “header application” comment block noise. |
| packages/cli/src/types/entities.ts | Removes “header application” comment block noise. |
| packages/cli/src/types/changeset.ts | Removes “header application” comment block noise. |
| packages/cli/src/traceability/git-staged.ts | Adds injected exec fn + improved quoting helper for git commands. |
| packages/cli/src/query/service.ts | Adds a query service with filters, validation, and summary formatting. |
| packages/cli/src/public/schemas/relationship.ts | Removes “header application” comment block noise. |
| packages/cli/src/public/schemas/entity.ts | Removes “header application” comment block noise. |
| packages/cli/src/public/prolog/index.ts | Removes “header application” comment block noise. |
| packages/cli/src/public/extractors/symbols-coordinator.ts | Removes “header application” comment block noise. |
| packages/cli/src/prolog.ts | Removes “header application” comment block noise. |
| packages/cli/src/prolog.d.ts | Re-indents types; removes large comment block. |
| packages/cli/src/extractors/symbols-ts.ts | Removes “header application” comment block noise. |
| packages/cli/src/extractors/symbols-coordinator.ts | Removes “header application” comment block noise. |
| packages/cli/src/extractors/relationships.ts | Adds relationship shard extraction and validation helpers. |
| packages/cli/src/extractors/markdown.ts | Stops persisting links on entities; changes relationship parsing behavior. |
| packages/cli/src/extractors/manifest.ts | Tightens symbol relationship extraction/typing for links/relationships. |
| packages/cli/src/commands/sync/staging.ts | Adds staging env preparation + atomic publish helpers for sync. |
| packages/cli/src/commands/sync/manifest.ts | Adds symbol coordinate refresh routine for symbols.yaml. |
| packages/cli/src/commands/sync/extraction.ts | Adds extraction orchestration with error capture and cache-key handling. |
| packages/cli/src/commands/sync/discovery.ts | Adds file discovery helpers + relationships dir resolution. |
| packages/cli/src/commands/sync/cache.ts | Adds sync cache read/write and hashing helpers. |
| packages/cli/src/commands/init.ts | Removes “header application” comment block noise. |
| packages/cli/src/commands/init-helpers.ts | Fixes sed caret escaping; improves hook install/update semantics. |
| packages/cli/src/commands/gc.ts | Removes defaultBranch-based protection; GC uses actual git branches only. |
| packages/cli/src/commands/doctor.ts | Removes “header application” comment block noise. |
| packages/cli/src/commands/branch.ts | Removes defaultBranch fallback when --from not provided. |
| packages/cli/src/commands/aggregated-checks.ts | Adds requireAdr option + safer Prolog atom escaping. |
| packages/cli/src/cli.ts | Removes “header application” comment block noise. |
| packages/cli/schema/config.json | Adds JSON schema for .kb/config.json including checks config. |
| packages/cli/package.json | Bumps CLI version and exports ./prolog/codec. |
| packages/cli/CHANGELOG.md | Adds 0.2.4 notes (duplicated entry present). |
| documentation/tests/e2e/packed/traceability-gate.test.ts | Tightens passing criteria (no longer accepts “No staged files found”). |
| documentation/tests/e2e/packed/init-sync-check.test.ts | Tightens init/sync assertions to specific success text. |
| documentation/tests/e2e/packed/hooks.test.ts | Strengthens post-checkout hook assertions and validates KB contents via query. |
| documentation/tests/e2e/packed/hook-integration.test.ts | Verifies KB copy semantics and makes expectations more explicit. |
| documentation/tests/e2e/packed/cli-workflows.test.ts | Requires kibi check pass cleanly for created fixtures. |
| documentation/tests/e2e/packed/branch-workflow.test.ts | Strengthens branch KB copy assertions and adds feature-hook-copy scenario. |
| documentation/requirements/REQ-020.md | Removes invalid ADR link entry. |
| documentation/adr/ADR-017.md | Adds ADR for canonical relationship shard storage. |
| documentation/adr/ADR-016.md | Updates ADR-016 hook contract documentation and timestamp. |
| docs/prompts/llm-rules.md | Adds /init-kibi note and refines guidance/anti-patterns. |
| debug-prompts.js | Adds a local script to introspect MCP prompts over stdio. |
| README.md | Expands “What You Get” section and references /init-kibi for OpenCode. |
| CONTRIBUTING.md | Adds note about not accepting contributions currently. |
| AGENTS.md | Adds MCP best practices section. |
| .kb/relationships/f9.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/f4.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/f3.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/e0.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/de.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/da.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/d6.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/d1.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/cf.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/c2.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/bf.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/ae.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/ad.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/ab.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/aa.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/a7.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/9f.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/9d.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/9c.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/99.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/95.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/92.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/83.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/7a.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/63.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/58.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/55.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/4f.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/45.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/42.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/40.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/38.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/36.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/32.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/31.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/2e.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/28.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/23.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/17.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/0f.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/06.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/relationships/05.yaml | Adds relationship shard generated by ADR-017 migration. |
| .kb/config.json | Adds $schema and checks config defaults. |
| .github/workflows/publish.yml | Adds opencode packing/install; adds GitHub release creation job. |
| .changeset/kibi-opencode-init-kibi.md | Adds changeset for opencode guidance update. |
| .changeset/kibi-mcp-init-kibi.md | Adds changeset for MCP prompt/tool guidance update. |
| .changeset/fix-prolog-codec-export.md | Adds changeset describing export fix for prolog codec. |
| .changeset/opencode-plugin.md | Removes old changeset file. |
Comments suppressed due to low confidence (12)
packages/vscode/src/symbolIndex.ts:1
- execSync(cmd)
with string interpolation ofsymbolIdis vulnerable to shell injection and quoting issues. Use a non-shell invocation (e.g., execFile/execFileSync with argument arrays) and passsymbolIdas a separate arg; if you must use a shell string, ensure robust escaping/quoting forsymbolId` and other dynamic values.
packages/cli/src/traceability/git-staged.ts:1 - runGit
still executes shell command strings containing file paths. Even withescapePath, filenames can legally contain characters like$`/backticks/newlines that are significant in shells, which can lead to command injection or incorrect behavior. Prefer execFile/execFileSync with args arrays for all git invocations (diff/show/name-status), eliminating the need for manual escaping.
packages/cli/src/traceability/git-staged.ts:1 - runGit
still executes shell command strings containing file paths. Even withescapePath, filenames can legally contain characters like$`/backticks/newlines that are significant in shells, which can lead to command injection or incorrect behavior. Prefer execFile/execFileSync with args arrays for all git invocations (diff/show/name-status), eliminating the need for manual escaping.
packages/cli/src/traceability/git-staged.ts:1 - runGit
still executes shell command strings containing file paths. Even withescapePath, filenames can legally contain characters like$`/backticks/newlines that are significant in shells, which can lead to command injection or incorrect behavior. Prefer execFile/execFileSync with args arrays for all git invocations (diff/show/name-status), eliminating the need for manual escaping.
packages/cli/src/commands/sync/staging.ts:1 - __dirname
is not defined in Node ESM modules; ifimport.meta.dirnameis undefined at runtime, this expression will throw a ReferenceError while buildingpossibleSchemaPaths. Compute the module directory fromimport.meta.url(e.g., via fileURLToPath + path.dirname) or remove the__dirname` fallback in ESM code.
packages/mcp/tests/tools/query.test.ts:1 - Importing from
../../../cli/src/...couples MCP tests to CLI source layout and bypasses the intended public API (and build output). This is brittle in CI/package contexts and undermines the purpose of addingkibi-cli/prolog/codecas a subpath export. Prefer importing these helpers viakibi-cli/prolog/codec(or an MCP-local module) so tests reflect actual runtime/module resolution.`
packages/cli/CHANGELOG.md:1 - The changelog has a duplicated
## 0.2.4section. Remove one of the entries or merge them into a single 0.2.4 section to avoid confusing release tooling and readers.`
packages/cli/src/utils/config.ts:1 - The checks-config merge logic is duplicated in both
loadConfigandloadSyncConfig, butpackages/cli/src/utils/rule-registry.tsalready introducesmergeChecksConfig. Consolidate these call sites to use the shared merge helper to reduce drift risk when rules/options evolve.`
packages/cli/src/utils/config.ts:1 - The checks-config merge logic is duplicated in both
loadConfigandloadSyncConfig, butpackages/cli/src/utils/rule-registry.tsalready introducesmergeChecksConfig. Consolidate these call sites to use the shared merge helper to reduce drift risk when rules/options evolve.`
packages/cli/src/utils/config.ts:1 - The checks-config merge logic is duplicated in both
loadConfigandloadSyncConfig, butpackages/cli/src/utils/rule-registry.tsalready introducesmergeChecksConfig. Consolidate these call sites to use the shared merge helper to reduce drift risk when rules/options evolve.`
packages/cli/src/extractors/relationships.ts:1 - The function contract says “Returns null if the record is invalid,” but the implementation throws on invalid input and never returns null. Either update the doc/type to reflect throwing behavior (and remove the
filter((r) => r !== null)downstream), or change the function to return null for invalid records (and handle/report errors elsewhere).`
packages/cli/src/commands/aggregated-checks.ts:1 - This query string includes a literal newline after
use_module(...), which can make debugging/escaping issues harder and can be brittle depending on the Prolog query transport. Consider constructing this as a single-line Prolog goal (or joining with explicit spaces) to reduce formatting-driven failures.`
You can also share your feedback on Copilot code review. Take the survey.
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.
No description provided.