kibi-opencode 0.18.0 → 0.19.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 +6 -6
- package/dist/e2e-coverage-signals.js +4 -1
- package/dist/enforcement-policy.js +7 -1
- package/dist/init-kibi-alias.js +5 -1
- package/dist/prompt.js +21 -10
- package/dist/repo-posture.js +8 -2
- package/dist/version-metadata.json +1 -1
- package/dist/work-context-resolver.js +17 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Use an exact semver entry when you want a fixed plugin version:
|
|
|
31
31
|
|
|
32
32
|
```json
|
|
33
33
|
{
|
|
34
|
-
"plugin": ["kibi-opencode@0.
|
|
34
|
+
"plugin": ["kibi-opencode@0.18.1"]
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -54,7 +54,7 @@ The plugin now uses a posture-aware, low-token smart-enforcement model before em
|
|
|
54
54
|
- **Risk classification**: separates `safe_docs_only`, `safe_test_only`, `kb_doc_structural`, `req_policy_candidate`, `behavior_candidate`, `traceability_candidate`, and `manual_kb_edit`
|
|
55
55
|
- **Source-linked Kibi links**: risky code edits (`behavior_candidate`, `traceability_candidate`) prepend a concise list of existing Kibi links (e.g., `- Existing Kibi links: REQ-001, REQ-002`) when 1-3 concrete source-linked KB hits are found in `documentation/symbols.yaml`. Skip on cache hit.
|
|
56
56
|
- **Start-task risky cue**: authoritative risky edits also add a compact Kibi context cue so agents can start with explicit source-linked guidance before acting, while staying inside the same single prompt block and token budget.
|
|
57
|
-
- **Effective mode gating**: `advisory` (default) never blocks; `strict` escalates checks and reminders for `root_active` and `hybrid_root_plus_vendored` postures when `requireRootKbForStrict` is enabled; `hard` fails closed for authoritative roots and linked git worktrees, injecting
|
|
57
|
+
- **Effective mode gating**: `advisory` (default) never blocks; `strict` escalates checks and reminders for `root_active` and `hybrid_root_plus_vendored` postures when `requireRootKbForStrict` is enabled; `hard` fails closed for authoritative roots and linked git worktrees, injecting capability-based recovery steps until the Kibi checkpoint passes. `maintenanceDegraded` overrides everything back to `advisory`.
|
|
58
58
|
- **Low-token prompt policy**: docs-only and test-only edits avoid unnecessary discovery prompts; vendored-only repos suppress operational bootstrap nudges; at most one contextual block is injected per prompt (≤120 words, ≤5 bullets)
|
|
59
59
|
- **Completion reminder**: when `completionReminder` is enabled, risky code edits append a single prompt-visible impact-enabled `kb_check` reminder exactly once per cached context
|
|
60
60
|
- **Runtime maintenance overlay**: static `maintenanceDegraded` from posture is merged with a latched runtime overlay (sync disabled/unavailable/failing) so degraded state is consistently reflected in prompts, logs, and mode decisions
|
|
@@ -155,13 +155,13 @@ The plugin injects guidance into OpenCode sessions to improve agent grounding. U
|
|
|
155
155
|
|
|
156
156
|
### Bootstrap Command
|
|
157
157
|
|
|
158
|
-
OpenCode exposes Kibi MCP prompts as slash commands. The \`/init-kibi\` command triggers the \`kb_autopilot_generate\` workflow to assist in retroactive bootstrap
|
|
158
|
+
OpenCode exposes Kibi MCP prompts as slash commands. The \`/init-kibi\` command triggers the \`kb_autopilot_generate\` workflow to assist in retroactive bootstrap. Agents use visible MCP tools when available, a trusted project-local CLI JSON route with `--input` when MCP is unavailable, and stop for operator action when neither interface is available.
|
|
159
159
|
|
|
160
160
|
OpenCode may show Kibi MCP tools with the configured server prefix. For example, canonical MCP names such as `kb_autopilot_generate`, `kb_upsert`, and `kb_check` can appear to agents as `kibi_kb_autopilot_generate`, `kibi_kb_upsert`, and `kibi_kb_check`. Use the visible `kibi_kb_*` identifier when OpenCode requires an exact tool name; it maps to the same MCP operation.
|
|
161
161
|
|
|
162
|
-
### Discovery-first
|
|
162
|
+
### Discovery-first capability guidance
|
|
163
163
|
|
|
164
|
-
Agent-visible guidance
|
|
164
|
+
Agent-visible guidance selects the curated public MCP surface when visible or the equivalent dedicated CLI JSON routes in a trusted workspace:
|
|
165
165
|
|
|
166
166
|
- Discovery/reporting: `kb_search`, `kb_query`, `kb_status`, `kb_find_gaps`, `kb_coverage`, `kb_graph`
|
|
167
167
|
- Mutation/validation: `kb_upsert`, `kb_delete`, `kb_check`
|
|
@@ -307,7 +307,7 @@ If you see a false "workspace needs Kibi bootstrap" warning even though your wor
|
|
|
307
307
|
|
|
308
308
|
This is a thin bridge layer per ADR-016:
|
|
309
309
|
|
|
310
|
-
- **Agent-visible guidance**:
|
|
310
|
+
- **Agent-visible guidance**: visible public MCP tools or trusted project-local CLI JSON routes (`--input`), with a blocked/operator state when neither is available
|
|
311
311
|
- **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
|
|
312
312
|
- **Internal maintenance**: Background sync operations handle KB synchronization; agents do NOT run sync commands directly
|
|
313
313
|
- Does NOT own KB storage, parsing, or validation
|
|
@@ -193,7 +193,13 @@ function hardBlockText(events) {
|
|
|
193
193
|
"Changed relevant files require Kibi verification before continuing:",
|
|
194
194
|
...pathLines,
|
|
195
195
|
...evidenceNotes,
|
|
196
|
-
"
|
|
196
|
+
"Capability-based checkpoint instructions:",
|
|
197
|
+
"- MCP tools and the trusted project-local CLI are peer surfaces over the same 18 operations; choose by what is visible and approved here.",
|
|
198
|
+
"- If Kibi MCP tools are visible and approved, use MCP.",
|
|
199
|
+
"- Otherwise, in a trusted workspace, use the project-local CLI's dedicated JSON routes with `--input <file|->`.",
|
|
200
|
+
"- If neither interface is available, Kibi operation is blocked; tell the operator to enable MCP or the trusted project-local CLI.",
|
|
201
|
+
"- Do not infer MCP availability from config file existence. Do not read or edit `.kb/` files directly.",
|
|
202
|
+
"- Query before mutate. Run `kb_upsert` sequentially. Run `kb_check` before completion.",
|
|
197
203
|
"- Run `kb_search` to discover impacted requirements, tests, ADRs, and facts.",
|
|
198
204
|
`- Run \`kb_query\` with \`sourceFile\` (example sourceFile: \"${representativePath}\") for each listed path.`,
|
|
199
205
|
"- Run `kb_status` if branch or snapshot freshness matters.",
|
package/dist/init-kibi-alias.js
CHANGED
|
@@ -33,7 +33,11 @@ export function buildInitKibiAlias() {
|
|
|
33
33
|
"",
|
|
34
34
|
"## Rules",
|
|
35
35
|
"- Never apply changes without a user-facing preview and approval.",
|
|
36
|
-
"-
|
|
36
|
+
"- MCP tools and the trusted project-local CLI are peer surfaces; choose by what is visible and approved here.",
|
|
37
|
+
"- If Kibi MCP tools are visible and approved, use MCP.",
|
|
38
|
+
"- Otherwise, in a trusted workspace, use the project-local CLI's dedicated JSON routes with `--input <file|->`. If neither interface is available, stop and tell the operator.",
|
|
39
|
+
"- Do not infer MCP availability from config file existence. Do not read or edit `.kb/` files directly.",
|
|
40
|
+
"- Query before mutate. Run `kb_upsert` sequentially. Run `kb_check` before completion.",
|
|
37
41
|
];
|
|
38
42
|
return lines.join("\n");
|
|
39
43
|
}
|
package/dist/prompt.js
CHANGED
|
@@ -66,7 +66,7 @@ function buildBootstrapRequiredBody(capability = getInitKibiCommandCapability())
|
|
|
66
66
|
const commandBullet = capability.supported
|
|
67
67
|
? "- When the Kibi OpenCode plugin is active and native injection is supported, use `/init-kibi` as the canonical short alias; `/kibi:init-kibi:mcp` remains the namespaced MCP fallback."
|
|
68
68
|
: "- This host does not support native `/init-kibi` injection. Kibi must fail closed and does not register a fake native alias; use `/kibi:init-kibi:mcp` instead.";
|
|
69
|
-
return `
|
|
69
|
+
return `Kibi capability selection (MCP tools and the trusted project-local CLI are peer surfaces over the same 18 operations):\n1. If Kibi MCP tools are visible and approved, use MCP.\n2. Otherwise, in a trusted workspace, use the project-local CLI's dedicated JSON routes with \`--input <file|->\`.\n3. If neither interface is available, Kibi operation is blocked; tell the operator.\nDo not infer MCP availability from config file existence. Do not read or edit \`.kb/\` files directly. Query before mutate. Run \`kb_upsert\` sequentially. Run \`kb_check\` before completion.\n\nThis repository does not appear to have Kibi initialized. Agents should:\n${commandBullet}\n- The workflow uses \`kb_autopilot_generate\` for read-only synthesis; always preview and get approval before writes.\n- Ask the operator to handle setup or repair if bootstrap is insufficient.\n- Load \`kibi-usage\` with \`kb_skills_load\` for comprehensive guidance.`;
|
|
70
70
|
}
|
|
71
71
|
function buildHardGateBlock(block) {
|
|
72
72
|
const pathLines = block.shownPaths.map((path) => `- \`${path}\``);
|
|
@@ -80,7 +80,13 @@ function buildHardGateBlock(block) {
|
|
|
80
80
|
reasonLine,
|
|
81
81
|
"Affected files:",
|
|
82
82
|
...pathLines,
|
|
83
|
-
"
|
|
83
|
+
"Capability-based recovery steps:",
|
|
84
|
+
"- MCP tools and the trusted project-local CLI are peer surfaces over the same 18 operations; choose by what is visible and approved here.",
|
|
85
|
+
"- If Kibi MCP tools are visible and approved, use MCP.",
|
|
86
|
+
"- Otherwise, in a trusted workspace, use the project-local CLI's dedicated JSON routes with `--input <file|->`.",
|
|
87
|
+
"- If neither interface is available, Kibi operation is blocked; tell the operator to enable MCP or the trusted project-local CLI.",
|
|
88
|
+
"- Do not infer MCP availability from config file existence. Do not read or edit `.kb/` files directly.",
|
|
89
|
+
"- Query before mutate. Run `kb_upsert` sequentially. Run `kb_check` before completion.",
|
|
84
90
|
"- Run `kb_search` for impacted requirements, tests, ADRs, and facts.",
|
|
85
91
|
"- Run `kb_query` with `sourceFile` for each affected file.",
|
|
86
92
|
"- Run `kb_status` if branch or snapshot freshness matters.",
|
|
@@ -120,7 +126,8 @@ Production code: use \`implements\` (symbol→req) for requirement ownership. Te
|
|
|
120
126
|
- documentation/symbols.yaml refresh is required when extraction output changes; do not revert as scope creep`,
|
|
121
127
|
manual_kb_edit: `⚠️ **WARNING: Direct .kb/ edits bypass validation**
|
|
122
128
|
|
|
123
|
-
The Kibi knowledge base is managed through
|
|
129
|
+
The Kibi knowledge base is managed through visible MCP tools or the trusted project-local CLI — peer surfaces over the same 18 operations. Do not read or edit \`.kb/\` files directly.
|
|
130
|
+
- Query before mutate and run kb_upsert sequentially
|
|
124
131
|
- Use kb_upsert to create/update entities
|
|
125
132
|
- Use kb_delete to remove entities
|
|
126
133
|
- Use kb_check to validate consistency`,
|
|
@@ -292,8 +299,10 @@ If you're adding long explanatory comments, consider routing that knowledge to:
|
|
|
292
299
|
}
|
|
293
300
|
}
|
|
294
301
|
}
|
|
295
|
-
catch {
|
|
296
|
-
|
|
302
|
+
catch (error) {
|
|
303
|
+
if (!(error instanceof Error)) {
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
297
306
|
}
|
|
298
307
|
}
|
|
299
308
|
// ── File-operation reminder folding ─────────────────────────────────
|
|
@@ -471,13 +480,17 @@ Before implementing or explaining code:
|
|
|
471
480
|
*/
|
|
472
481
|
function buildBaseGuidance(capability = getInitKibiCommandCapability()) {
|
|
473
482
|
return `${SENTINEL}
|
|
474
|
-
This project uses Kibi
|
|
483
|
+
This project uses Kibi through capability-selected MCP or CLI JSON routes. Prefer storing durable knowledge in Kibi over code comments.
|
|
475
484
|
|
|
476
485
|
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.
|
|
477
486
|
|
|
478
487
|
Keep changed symbols traceable: production code uses \`implements\` (symbol→req) for ownership; test code uses \`executable_for\`; \`covered_by\` is coverage evidence only. Inline \`// implements REQ-xxx\` comments remain backward-compatible.
|
|
479
488
|
|
|
480
|
-
|
|
489
|
+
Kibi capability selection (MCP tools and the trusted project-local CLI are peer surfaces over the same 18 operations):
|
|
490
|
+
1. If Kibi MCP tools are visible and approved, use MCP.
|
|
491
|
+
2. Otherwise, in a trusted workspace, use the project-local CLI's dedicated JSON routes with \`--input <file|->\`.
|
|
492
|
+
3. If neither interface is available, Kibi operation is blocked; tell the operator to enable MCP or the trusted project-local CLI.
|
|
493
|
+
Do not infer MCP availability from config file existence. Do not read or edit \`.kb/\` files directly. Query before mutate. Run \`kb_upsert\` sequentially. Run \`kb_check\` before completion.
|
|
481
494
|
|
|
482
495
|
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.
|
|
483
496
|
|
|
@@ -490,12 +503,10 @@ Dogfood note for this repo: OpenCode here uses local built \`kibi-mcp\` and \`ki
|
|
|
490
503
|
6. **Validate**: Run kb_check after KB mutations to catch violations early.
|
|
491
504
|
7. **Before completion/commit**: Kibi impact evidence is required before completion/commit. If extraction output changes, refresh documentation/symbols.yaml and do not revert that update as scope creep.
|
|
492
505
|
|
|
493
|
-
|
|
506
|
+
MCP and CLI expose the same 18 Kibi operations. Use the exact MCP tool or dedicated CLI route; do not invent a generic runner.
|
|
494
507
|
|
|
495
508
|
For comprehensive Kibi usage guidance (relationships, fact lanes, workflows), use \`kb_skills_load\` with skill id \`kibi-usage\`.
|
|
496
509
|
|
|
497
|
-
Do not invoke Kibi CLI commands directly from the agent.
|
|
498
|
-
|
|
499
510
|
${buildInitKibiBootstrapReference(capability)}`;
|
|
500
511
|
}
|
|
501
512
|
/**
|
package/dist/repo-posture.js
CHANGED
|
@@ -111,7 +111,10 @@ function hasRootKibiIntent(cwd) {
|
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
catch {
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!(error instanceof Error))
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
115
118
|
for (const guidanceFile of [
|
|
116
119
|
"AGENTS.md",
|
|
117
120
|
join(".github", "copilot-instructions.md"),
|
|
@@ -122,7 +125,10 @@ function hasRootKibiIntent(cwd) {
|
|
|
122
125
|
return true;
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
|
-
catch {
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (!(error instanceof Error))
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
126
132
|
}
|
|
127
133
|
return false;
|
|
128
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"opencode":"0.
|
|
1
|
+
{"opencode":"0.19.2","mcp":"0.20.1","cli":"0.17.0","core":"0.8.1"}
|
|
@@ -46,8 +46,9 @@ function directorySearchStart(candidatePath) {
|
|
|
46
46
|
const stats = safeStat(resolved);
|
|
47
47
|
return stats?.isDirectory() ? resolved : dirname(resolved);
|
|
48
48
|
}
|
|
49
|
-
function findGitMetadata(candidatePath) {
|
|
49
|
+
function findGitMetadata(candidatePath, searchBoundary) {
|
|
50
50
|
let current = directorySearchStart(candidatePath);
|
|
51
|
+
const boundary = searchBoundary ? resolve(searchBoundary) : null;
|
|
51
52
|
while (true) {
|
|
52
53
|
const dotGitPath = join(current, ".git");
|
|
53
54
|
const dotGitStats = safeStat(dotGitPath);
|
|
@@ -70,6 +71,9 @@ function findGitMetadata(candidatePath) {
|
|
|
70
71
|
isLinkedWorktree: false,
|
|
71
72
|
};
|
|
72
73
|
}
|
|
74
|
+
if (boundary !== null && current === boundary) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
73
77
|
const parent = dirname(current);
|
|
74
78
|
if (parent === current) {
|
|
75
79
|
return null;
|
|
@@ -174,8 +178,18 @@ const resolveWorkContext = function resolveWorkContext(input) {
|
|
|
174
178
|
? resolve(input.filePath)
|
|
175
179
|
: resolve(declaredWorktreeRoot, input.filePath)
|
|
176
180
|
: undefined;
|
|
177
|
-
const
|
|
178
|
-
|
|
181
|
+
const fileRelativeToDeclaredRoot = absoluteFilePath
|
|
182
|
+
? relative(declaredWorktreeRoot, absoluteFilePath)
|
|
183
|
+
: null;
|
|
184
|
+
const fileSearchBoundary = fileRelativeToDeclaredRoot !== null &&
|
|
185
|
+
!fileRelativeToDeclaredRoot.startsWith(`..${sep}`) &&
|
|
186
|
+
fileRelativeToDeclaredRoot !== ".." &&
|
|
187
|
+
!isAbsolute(fileRelativeToDeclaredRoot)
|
|
188
|
+
? declaredWorktreeRoot
|
|
189
|
+
: undefined;
|
|
190
|
+
const git = (absoluteFilePath
|
|
191
|
+
? findGitMetadata(absoluteFilePath, fileSearchBoundary)
|
|
192
|
+
: null) ?? findGitMetadata(declaredWorktreeRoot, declaredWorktreeRoot);
|
|
179
193
|
const worktreeRoot = git?.worktreeRoot ?? declaredWorktreeRoot;
|
|
180
194
|
const kibiAuthorityRoot = git
|
|
181
195
|
? resolveAuthorityRoot(git, declaredDirectory)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kibi-opencode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@opencode-ai/plugin": "^1.4.7",
|
|
61
61
|
"@opentui/core": "^0.1.99",
|
|
62
62
|
"@opentui/solid": "^0.1.99",
|
|
63
|
-
"kibi-cli": "^0.
|
|
63
|
+
"kibi-cli": "^0.17.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "latest",
|