kibi-opencode 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,6 +96,15 @@ The plugin injects guidance into OpenCode sessions to improve agent grounding. U
96
96
 
97
97
  OpenCode exposes Kibi MCP prompts as slash commands. The `/init-kibi` command runs the retroactive bootstrap workflow using only public MCP tools.
98
98
 
99
+ ### Discovery-first MCP guidance
100
+
101
+ Agent-visible guidance is intentionally limited to the curated public MCP surface:
102
+
103
+ - Discovery/reporting: `kb_search`, `kb_query`, `kb_status`, `kb_find_gaps`, `kb_coverage`, `kb_graph`
104
+ - Mutation/validation: `kb_upsert`, `kb_delete`, `kb_check`
105
+
106
+ The plugin guidance prefers `kb_search` for broad discovery, then `kb_query` for exact/source-linked follow-up.
107
+
99
108
  ### Background Sync Operations
100
109
 
101
110
  Internal maintenance automatically syncs the knowledge base after relevant file edits:
@@ -186,6 +195,7 @@ This repository's OpenCode setup dogfoods local built artifacts. `opencode.json`
186
195
  This is a thin bridge layer per ADR-016:
187
196
 
188
197
  - **Agent-visible guidance**: Public MCP tools (`kb_query`, `kb_upsert`, `kb_check`, etc.) and sanctioned slash commands (`/init-kibi`)
198
+ - **Discovery-first workflow**: Agents are guided to use `kb_search` first, then `kb_query`, then reporting tools like `kb_status`, `kb_find_gaps`, `kb_coverage`, and `kb_graph` when needed
189
199
  - **Internal maintenance**: Background sync operations handle KB synchronization; agents do NOT run sync commands directly
190
200
  - Does NOT own KB storage, parsing, or validation
191
201
 
package/dist/config.js CHANGED
@@ -132,10 +132,6 @@ export function loadConfig(projectDir = process.cwd()) {
132
132
  if (projectObj)
133
133
  merged = { ...merged, ...projectObj };
134
134
  const validated = validateAndMerge(merged);
135
- if (!validated) {
136
- logger.warn("Configuration invalid, falling back to defaults");
137
- return DEFAULTS;
138
- }
139
135
  return validated;
140
136
  }
141
137
  // implements REQ-opencode-kibi-plugin-v1
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
+ import * as path from "node:path";
1
2
  import { analyzeCodeFile, } from "./comment-analysis.js";
2
3
  import * as config from "./config.js";
3
4
  import * as fileFilter from "./file-filter.js";
4
5
  import * as logger from "./logger.js";
5
- import * as path from "node:path";
6
6
  import { analyzePath } from "./path-kind.js";
7
7
  import { injectPrompt } from "./prompt.js";
8
8
  import { isMustPriorityRequirement } from "./requirement-doc.js";
package/dist/prompt.js CHANGED
@@ -13,8 +13,9 @@ function buildContextualGuidance(context) {
13
13
  The Kibi knowledge base is managed through public MCP tools and internal maintenance flows. Direct manual edits to files under .kb/** can cause inconsistencies and should be avoided.
14
14
 
15
15
  Instead:
16
+ - Use kb_search to discover relevant entities
16
17
  - Use kb_upsert to create/update entities
17
- - Use kb_query to inspect the KB
18
+ - Use kb_query for exact lookup and source-linked follow-up
18
19
  - Use kb_check to validate consistency
19
20
  `);
20
21
  }
@@ -26,7 +27,7 @@ This repository does not appear to have Kibi initialized. Agents should:
26
27
  - Use \`/init-kibi\` for retroactive bootstrap of existing repos (preferred MCP command)
27
28
  - Ask the user/operator to run setup or repair outside this session if \`/init-kibi\` is insufficient
28
29
 
29
- Do not run \`kibi\` CLI commands directly; use the MCP tools (kb_query, kb_upsert, kb_delete, kb_check).
30
+ Do not run \`kibi\` CLI commands directly; use the public MCP tools (kb_search, kb_query, kb_status, kb_find_gaps, kb_coverage, kb_graph, kb_upsert, kb_delete, kb_check).
30
31
  `);
31
32
  }
32
33
  const codeEdits = context.recentEdits.filter((e) => e.kind === "code");
@@ -77,9 +78,11 @@ This ensures behavior is documented and traceable.`;
77
78
  routingMessage = `📝 **Code changes detected**
78
79
 
79
80
  Before implementing or explaining code:
80
- 1. **Query Kibi first** - Run kb_query by sourceFile to find related requirements, ADRs, tests, and symbols.
81
- 2. **Prefer Kibi over comments** - Store durable knowledge in KB entities instead of inline comments.
82
- 3. **Add traceability** - Add traceability comments to new or modified functions/classes so the pre-commit hook can verify coverage (e.g., \`// implements REQ-xxx\` in JS/TS or docstring references in Python).`;
81
+ 1. **Discover first** - Run kb_search to find related requirements, ADRs, tests, facts, and symbols.
82
+ 2. **Follow up exactly** - Run kb_query by sourceFile, id, type, or tags once you know what you need.
83
+ 3. **Check freshness when needed** - Run kb_status if you need branch or stale-state confirmation.
84
+ 4. **Prefer Kibi over comments** - Store durable knowledge in KB entities instead of inline comments.
85
+ 5. **Add traceability** - Add traceability comments to new or modified functions/classes so the pre-commit hook can verify coverage (e.g., \`// implements REQ-xxx\` in JS/TS or docstring references in Python).`;
83
86
  }
84
87
  parts.push(routingMessage);
85
88
  }
@@ -88,9 +91,11 @@ Before implementing or explaining code:
88
91
  📝 **Code changes detected**
89
92
 
90
93
  Before implementing or explaining code:
91
- 1. **Query Kibi first** - Run kb_query by sourceFile to find related requirements, ADRs, tests, and symbols.
92
- 2. **Prefer Kibi over comments** - Store durable knowledge in KB entities instead of inline comments.
93
- 3. **Add traceability** - Add traceability comments to new or modified functions/classes (e.g., \`// implements REQ-xxx\` in JS/TS or docstring references in Python) so the pre-commit hook can verify coverage.
94
+ 1. **Discover first** - Run kb_search to find related requirements, ADRs, tests, facts, and symbols.
95
+ 2. **Follow up exactly** - Run kb_query by sourceFile, id, type, or tags once you know what you need.
96
+ 3. **Check freshness when needed** - Run kb_status if you need branch or stale-state confirmation.
97
+ 4. **Prefer Kibi over comments** - Store durable knowledge in KB entities instead of inline comments.
98
+ 5. **Add traceability** - Add traceability comments to new or modified functions/classes (e.g., \`// implements REQ-xxx\` in JS/TS or docstring references in Python) so the pre-commit hook can verify coverage.
94
99
 
95
100
  If you're adding long explanatory comments, consider routing that knowledge to:
96
101
  - \`FACT\` for domain invariants, properties, limits, cardinalities
@@ -129,7 +134,7 @@ When editing KB documentation:
129
134
  if (parts.length === 1) {
130
135
  parts.push(`This project uses Kibi (via MCP). Prefer storing durable knowledge in Kibi over code comments.
131
136
 
132
- Before changing behavior: query Kibi by sourceFile, id, type, or tags; do not rely on undocumented tools.
137
+ Before changing behavior: use kb_search for discovery, then kb_query by sourceFile, id, type, or tags for exact follow-up; do not rely on undocumented tools.
133
138
 
134
139
  Keep changed symbols traceable: add \`// implements REQ-xxx\` to every new or modified function/class so the pre-commit hook can verify coverage.
135
140
 
@@ -138,12 +143,14 @@ Run kb_check after KB mutations.
138
143
  Dogfood note for this repo: OpenCode here uses local built \`kibi-mcp\` and \`kibi-opencode\` artifacts. If you change package versions or local package wiring, run \`bun run build\` before relying on OpenCode in this workspace.
139
144
 
140
145
  **Kibi-first workflow:**
141
- 1. **Discover**: Run kb_query with filters (sourceFile, type, tags) to find related requirements, ADRs, tests, and symbols.
142
- 2. **Document intent**: If you are about to explain code, STOP. Route that explanation to kb_upsert instead of inline comments.
143
- 3. **Link during work**: When creating KB entities, include relationship rows: specified_by (req→scenario), verified_by (req→test), implements (symbol→req), covered_by (symbol→test).
144
- 4. **Validate**: Run kb_check after KB mutations to catch violations early.
146
+ 1. **Discover**: Run kb_search to find relevant requirements, ADRs, tests, facts, and symbols.
147
+ 2. **Confirm**: Run kb_query with sourceFile, id, type, or tags once you know the exact follow-up target.
148
+ 3. **Inspect freshness**: Run kb_status when branch or stale-state confidence matters.
149
+ 4. **Document intent**: If you are about to explain code, STOP. Route that explanation to kb_upsert instead of inline comments.
150
+ 5. **Link during work**: When creating KB entities, include relationship rows: specified_by (req→scenario), verified_by (req→test), implements (symbol→req), covered_by (symbol→test).
151
+ 6. **Validate**: Run kb_check after KB mutations to catch violations early.
145
152
 
146
- **Public Kibi tools only:** kb_query, kb_upsert, kb_delete, kb_check.
153
+ **Public Kibi tools only:** kb_search, kb_query, kb_status, kb_find_gaps, kb_coverage, kb_graph, kb_upsert, kb_delete, kb_check.
147
154
 
148
155
  Do not invoke Kibi CLI commands directly from the agent.
149
156
 
@@ -157,7 +164,7 @@ Bootstrap existing repos: use \`/init-kibi\` to run the retroactive initializati
157
164
  const BASE_GUIDANCE = `${SENTINEL}
158
165
  This project uses Kibi (via MCP). Prefer storing durable knowledge in Kibi over code comments.
159
166
 
160
- Before changing behavior: query Kibi by sourceFile, id, type, or tags; do not rely on undocumented tools.
167
+ Before changing behavior: use kb_search for discovery, then kb_query by sourceFile, id, type, or tags for exact follow-up; do not rely on undocumented tools.
161
168
 
162
169
  Keep changed symbols traceable: add \`// implements REQ-xxx\` to every new or modified function/class so the pre-commit hook can verify coverage.
163
170
 
@@ -166,12 +173,14 @@ Run kb_check after KB mutations.
166
173
  Dogfood note for this repo: OpenCode here uses local built \`kibi-mcp\` and \`kibi-opencode\` artifacts. If you change package versions or local package wiring, run \`bun run build\` before relying on OpenCode in this workspace.
167
174
 
168
175
  **Kibi-first workflow:**
169
- 1. **Discover**: Run kb_query with filters (sourceFile, type, tags) to find related requirements, ADRs, tests, and symbols.
170
- 2. **Document intent**: If you are about to explain code, STOP. Route that explanation to kb_upsert instead of inline comments.
171
- 3. **Link during work**: When creating KB entities, include relationship rows: specified_by (req→scenario), verified_by (req→test), implements (symbol→req), covered_by (symbol→test).
172
- 4. **Validate**: Run kb_check after KB mutations to catch violations early.
173
-
174
- **Public Kibi tools only:** kb_query, kb_upsert, kb_delete, kb_check.
176
+ 1. **Discover**: Run kb_search to find relevant requirements, ADRs, tests, facts, and symbols.
177
+ 2. **Confirm**: Run kb_query with sourceFile, id, type, or tags once you know the exact follow-up target.
178
+ 3. **Inspect freshness**: Run kb_status when branch or stale-state confidence matters.
179
+ 4. **Document intent**: If you are about to explain code, STOP. Route that explanation to kb_upsert instead of inline comments.
180
+ 5. **Link during work**: When creating KB entities, include relationship rows: specified_by (req→scenario), verified_by (req→test), implements (symbol→req), covered_by (symbol→test).
181
+ 6. **Validate**: Run kb_check after KB mutations to catch violations early.
182
+
183
+ **Public Kibi tools only:** kb_search, kb_query, kb_status, kb_find_gaps, kb_coverage, kb_graph, kb_upsert, kb_delete, kb_check.
175
184
 
176
185
  Do not invoke Kibi CLI commands directly from the agent.
177
186
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-opencode",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Kibi OpenCode plugin - thin adapter to integrate Kibi with OpenCode sessions",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",