kibi-opencode 0.9.0 → 0.10.0
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 +36 -12
- package/dist/brief-intent.d.ts +15 -4
- package/dist/brief-intent.js +63 -25
- package/dist/briefing-runtime.js +2 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +9 -0
- package/dist/e2e-coverage-signals.d.ts +6 -0
- package/dist/e2e-coverage-signals.js +186 -0
- package/dist/file-entity-links.d.ts +15 -0
- package/dist/file-entity-links.js +254 -0
- package/dist/file-operation-reminders.d.ts +24 -0
- package/dist/file-operation-reminders.js +55 -0
- package/dist/file-operation-state.d.ts +29 -0
- package/dist/file-operation-state.js +113 -0
- package/dist/idle-brief-audit.d.ts +36 -0
- package/dist/idle-brief-audit.js +186 -0
- package/dist/idle-brief-paths.d.ts +6 -0
- package/dist/idle-brief-paths.js +120 -0
- package/dist/idle-brief-reader.d.ts +25 -0
- package/dist/idle-brief-reader.js +142 -0
- package/dist/idle-brief-runtime.d.ts +48 -0
- package/dist/idle-brief-runtime.js +443 -0
- package/dist/idle-brief-store.d.ts +96 -0
- package/dist/idle-brief-store.js +209 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +626 -50
- package/dist/init-kibi-alias.d.ts +14 -0
- package/dist/init-kibi-alias.js +38 -0
- package/dist/init-kibi-capability.d.ts +32 -0
- package/dist/init-kibi-capability.js +202 -0
- package/dist/logger.js +9 -3
- package/dist/plugin-startup.d.ts +1 -0
- package/dist/plugin-startup.js +11 -2
- package/dist/prompt.d.ts +15 -3
- package/dist/prompt.js +103 -33
- package/dist/reconcile-engine.d.ts +15 -0
- package/dist/reconcile-engine.js +112 -0
- package/dist/scheduler.d.ts +1 -0
- package/dist/scheduler.js +37 -1
- package/dist/session-edit-state.d.ts +25 -0
- package/dist/session-edit-state.js +177 -0
- package/dist/session-fingerprint.d.ts +11 -0
- package/dist/session-fingerprint.js +21 -0
- package/dist/source-linked-guidance.d.ts +1 -2
- package/dist/source-linked-guidance.js +5 -168
- package/dist/startup-notifier.js +42 -31
- package/dist/toast.d.ts +21 -22
- package/dist/toast.js +36 -14
- package/dist/tui-brief-delivery.d.ts +47 -0
- package/dist/tui-brief-delivery.js +138 -0
- package/package.json +4 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
* Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*/
|
|
10
|
+
import * as logger from "./logger.js";
|
|
11
|
+
function firstNonEmpty(...values) {
|
|
12
|
+
for (const value of values) {
|
|
13
|
+
const trimmed = value?.trim();
|
|
14
|
+
if (trimmed) {
|
|
15
|
+
return trimmed;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return "Knowledge updates were recorded in this brief.";
|
|
19
|
+
}
|
|
20
|
+
function defaultWhyItMatters() {
|
|
21
|
+
return "This update changes how the project knowledge should be interpreted and applied.";
|
|
22
|
+
}
|
|
23
|
+
function buildTuiBriefMessage(envelope) {
|
|
24
|
+
const lines = [];
|
|
25
|
+
const whatChanged = envelope.schemaVersion === "2.0"
|
|
26
|
+
? envelope.briefing.changeNarrative.map((line) => line.trim()).filter(Boolean)
|
|
27
|
+
: [];
|
|
28
|
+
lines.push("## What changed");
|
|
29
|
+
if (whatChanged.length > 0) {
|
|
30
|
+
lines.push(...whatChanged.slice(0, 2));
|
|
31
|
+
}
|
|
32
|
+
else if (envelope.schemaVersion === "2.0") {
|
|
33
|
+
const fallbackEntity = envelope.changes.entities.modified[0] ?? envelope.changes.entities.added[0];
|
|
34
|
+
if (fallbackEntity) {
|
|
35
|
+
const action = envelope.changes.entities.modified[0] ? "Modified" : "Added";
|
|
36
|
+
lines.push(`${action} ${fallbackEntity.id}: ${fallbackEntity.title ?? "Untitled"}`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
lines.push(firstNonEmpty(envelope.summary, envelope.briefing.tldr));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
lines.push(firstNonEmpty(envelope.summary, envelope.briefing.tldr));
|
|
44
|
+
}
|
|
45
|
+
lines.push("");
|
|
46
|
+
lines.push("## Why it matters");
|
|
47
|
+
lines.push(firstNonEmpty(envelope.briefing.promptBlock, defaultWhyItMatters()));
|
|
48
|
+
lines.push("");
|
|
49
|
+
const hasKnowledgeImpact = envelope.briefing.citations.length > 0 ||
|
|
50
|
+
(envelope.briefing.constraints?.length ?? 0) > 0 ||
|
|
51
|
+
(envelope.briefing.regressionRisks?.length ?? 0) > 0;
|
|
52
|
+
if (hasKnowledgeImpact) {
|
|
53
|
+
lines.push("## Project knowledge impact");
|
|
54
|
+
if (envelope.briefing.citations.length > 0) {
|
|
55
|
+
for (const citation of envelope.briefing.citations) {
|
|
56
|
+
lines.push(`- **${citation.id}**${citation.title ? `: ${citation.title}` : ""}${citation.source ? ` (${citation.source})` : ""}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if ((envelope.briefing.constraints?.length ?? 0) > 0) {
|
|
60
|
+
for (const constraint of envelope.briefing.constraints ?? []) {
|
|
61
|
+
lines.push(`- ${constraint.statement}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if ((envelope.briefing.regressionRisks?.length ?? 0) > 0) {
|
|
65
|
+
for (const risk of envelope.briefing.regressionRisks ?? []) {
|
|
66
|
+
lines.push(`- ${risk.statement}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
lines.push("");
|
|
70
|
+
}
|
|
71
|
+
const hasMissingEvidence = (envelope.briefing.missingEvidence?.length ?? 0) > 0;
|
|
72
|
+
if (envelope.validation.count > 0 || hasMissingEvidence) {
|
|
73
|
+
lines.push("## Interpretation note");
|
|
74
|
+
if (envelope.validation.count > 0) {
|
|
75
|
+
lines.push(`Validation checks reported unresolved items: ${envelope.validation.count} issue(s).`);
|
|
76
|
+
}
|
|
77
|
+
if (hasMissingEvidence) {
|
|
78
|
+
lines.push("This brief includes unresolved evidence notes:");
|
|
79
|
+
for (const item of envelope.briefing.missingEvidence ?? []) {
|
|
80
|
+
lines.push(`- ${item.statement}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
lines.push("");
|
|
84
|
+
}
|
|
85
|
+
while (lines.length > 0 && lines[lines.length - 1] === "") {
|
|
86
|
+
lines.pop();
|
|
87
|
+
}
|
|
88
|
+
return lines.join("\n");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Delivers a Kibi briefing to the TUI via toast notification.
|
|
92
|
+
*
|
|
93
|
+
* Uses the REAL OpenCode plugin API:
|
|
94
|
+
* - client.tui.showToast(payload) — primary (and only) delivery mechanism
|
|
95
|
+
*
|
|
96
|
+
* The toast contains a rich summary from the envelope and is displayed
|
|
97
|
+
* for 8 seconds so users can read the content.
|
|
98
|
+
*
|
|
99
|
+
* @param client - OpenCode client with optional TUI capabilities
|
|
100
|
+
* @param envelope - Idle brief envelope containing briefing content
|
|
101
|
+
* @param sharedPolicy - Shared brief policy from `.kb/config.json`
|
|
102
|
+
* @param localConfig - Local OpenCode config
|
|
103
|
+
*/
|
|
104
|
+
// implements REQ-opencode-kibi-briefing-v4
|
|
105
|
+
export async function deliverBriefTui(client, envelope, sharedPolicy, _localConfig) {
|
|
106
|
+
// Early exit if TUI delivery is disabled
|
|
107
|
+
if (!sharedPolicy.briefs.channels.tui) {
|
|
108
|
+
logger.info("TUI brief delivery disabled by shared policy");
|
|
109
|
+
return { delivered: false };
|
|
110
|
+
}
|
|
111
|
+
const tui = client.tui;
|
|
112
|
+
// Toast is the primary delivery mechanism
|
|
113
|
+
if (sharedPolicy.briefs.tui.toast && typeof tui?.showToast === "function") {
|
|
114
|
+
try {
|
|
115
|
+
const message = buildTuiBriefMessage(envelope);
|
|
116
|
+
await tui.showToast({
|
|
117
|
+
body: {
|
|
118
|
+
variant: envelope.type === "warning" ? "warning" : "info",
|
|
119
|
+
title: "Kibi Knowledge Update",
|
|
120
|
+
message,
|
|
121
|
+
duration: 8000,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
return { delivered: true };
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
logger.error("Failed to deliver brief toast", {
|
|
128
|
+
event: "idle_brief_toast_failed",
|
|
129
|
+
error: err instanceof Error ? err.message : String(err),
|
|
130
|
+
});
|
|
131
|
+
return { delivered: false };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
logger.info("TUI showToast API unavailable, brief not delivered");
|
|
136
|
+
return { delivered: false };
|
|
137
|
+
}
|
|
138
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kibi-opencode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Kibi OpenCode plugin - thin adapter to integrate Kibi with OpenCode sessions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -53,10 +53,11 @@
|
|
|
53
53
|
"prepack": "npm run build"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@opencode-ai/plugin": "^1.2.26"
|
|
56
|
+
"@opencode-ai/plugin": "^1.2.26",
|
|
57
|
+
"kibi-cli": "^0.7.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@types/node": "latest",
|
|
60
61
|
"typescript": "^5.0.0"
|
|
61
62
|
}
|
|
62
|
-
}
|
|
63
|
+
}
|