kibi-mcp 0.5.0 → 0.6.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/dist/diagnostics.js +5 -0
- package/dist/server/docs.js +11 -2
- package/dist/tools/check.js +2 -23
- package/dist/tools/core-module.js +6 -16
- package/dist/tools/symbols.js +2 -0
- package/dist/tools/upsert.js +10 -1
- package/package.json +3 -3
package/dist/diagnostics.js
CHANGED
|
@@ -88,6 +88,11 @@ export function deriveDiagnosticFields(toolName, args, telemetry, result) {
|
|
|
88
88
|
const fields = {
|
|
89
89
|
telemetry_status: telemetry ? "provided" : "missing",
|
|
90
90
|
};
|
|
91
|
+
if (telemetry) {
|
|
92
|
+
fields.telemetry_is_autonomous = telemetry.is_autonomous ?? null;
|
|
93
|
+
fields.telemetry_confidence_score = telemetry.confidence_score ?? null;
|
|
94
|
+
fields.telemetry_attempt_number = telemetry.attempt_number ?? null;
|
|
95
|
+
}
|
|
91
96
|
const structuredContent = result && typeof result === "object" && "structuredContent" in result
|
|
92
97
|
? result
|
|
93
98
|
.structuredContent
|
package/dist/server/docs.js
CHANGED
|
@@ -30,8 +30,9 @@ function renderToolsDoc() {
|
|
|
30
30
|
const required = Array.isArray(tool.inputSchema?.required)
|
|
31
31
|
? tool.inputSchema.required.join(", ")
|
|
32
32
|
: "none";
|
|
33
|
-
lines.push(`| ${tool.name} | ${tool.description} | ${required} |`);
|
|
34
33
|
}
|
|
34
|
+
lines.push("");
|
|
35
|
+
lines.push("Modeling note: Prefer query-first discovery; create `fact` entities before `req` entities and express semantics via `constrains` + `requires_property`.");
|
|
35
36
|
return lines.join("\n");
|
|
36
37
|
}
|
|
37
38
|
export const PROMPTS = [
|
|
@@ -124,6 +125,8 @@ export const PROMPTS = [
|
|
|
124
125
|
"- Run `kb_check` after meaningful mutations to catch integrity issues early.",
|
|
125
126
|
"- Prefer explicit IDs and enum values to avoid invalid parameters.",
|
|
126
127
|
"- Assume every write can affect downstream traceability queries.",
|
|
128
|
+
"- Model requirements by first creating/reusing fact entities, then express req semantics with `constrains` + `requires_property` relationships (create-before-link).",
|
|
129
|
+
"- flag gates runtime/config behavior; use `fact` with `fact_kind: observation` or `meta` for bug and workaround notes.",
|
|
127
130
|
].join("\n"),
|
|
128
131
|
},
|
|
129
132
|
{
|
|
@@ -131,7 +134,6 @@ export const PROMPTS = [
|
|
|
131
134
|
description: "Step-by-step call order for discovery, mutation, and verification.",
|
|
132
135
|
text: [
|
|
133
136
|
"# kibi-mcp Workflow",
|
|
134
|
-
"",
|
|
135
137
|
"Follow this sequence for reliable operation:",
|
|
136
138
|
"",
|
|
137
139
|
"1. **Discover first**: Call `kb_search` for exploratory discovery, then `kb_query` to confirm exact current state before mutation.",
|
|
@@ -206,6 +208,13 @@ function registerDocResources() {
|
|
|
206
208
|
"4. Reuse the same constrained fact ID across related requirements; vary property facts only when semantics differ",
|
|
207
209
|
'5. `kb_check` with `{ "rules": ["required-fields","no-dangling-refs"] }` for targeted validation',
|
|
208
210
|
"",
|
|
211
|
+
"Note: Create or reuse `fact` entities first, then create `req` entities and link with `constrains` and `requires_property` (create-before-link). Use `flag` for runtime/config gates; use `fact` with `fact_kind: observation` or `meta` for bug and workaround notes.",
|
|
212
|
+
"",
|
|
213
|
+
"## Find missing coverage",
|
|
214
|
+
'1. `kb_find_gaps` with `{ "type": "req", "missingRelationships": ["specified_by", "verified_by"] }` to find under-linked requirements',
|
|
215
|
+
"",
|
|
216
|
+
"## Find missing coverage",
|
|
217
|
+
"",
|
|
209
218
|
"## Find missing coverage",
|
|
210
219
|
'1. `kb_find_gaps` with `{ "type": "req", "missingRelationships": ["specified_by", "verified_by"] }` to find under-linked requirements',
|
|
211
220
|
'2. `kb_coverage` with `{ "by": "req", "includePassing": false }` to review evaluated coverage rows',
|
package/dist/tools/check.js
CHANGED
|
@@ -16,31 +16,10 @@
|
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
import { existsSync, readFileSync } from "node:fs";
|
|
19
|
-
import { createRequire } from "node:module";
|
|
20
19
|
import * as path from "node:path";
|
|
21
20
|
import { DEFAULT_CHECKS_CONFIG, RULE_NAMES, } from "kibi-cli/public/check-types";
|
|
22
21
|
import { resolveWorkspaceRoot } from "../workspace.js";
|
|
23
|
-
|
|
24
|
-
function resolveChecksPlPath() {
|
|
25
|
-
const overrideChecksPath = process.env.KIBI_CHECKS_PL_PATH;
|
|
26
|
-
if (overrideChecksPath && existsSync(overrideChecksPath)) {
|
|
27
|
-
return overrideChecksPath;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
const installedChecksPl = require.resolve("kibi-core/src/checks.pl");
|
|
31
|
-
if (existsSync(installedChecksPl)) {
|
|
32
|
-
return installedChecksPl;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
// require.resolve not available or package not installed
|
|
37
|
-
}
|
|
38
|
-
const localChecksPl = path.join(process.cwd(), "packages/core/src/checks.pl");
|
|
39
|
-
if (existsSync(localChecksPl)) {
|
|
40
|
-
return localChecksPl;
|
|
41
|
-
}
|
|
42
|
-
throw new Error("Unable to resolve checks.pl path");
|
|
43
|
-
}
|
|
22
|
+
import { resolveCorePlPath } from "./core-module.js";
|
|
44
23
|
function formatDiagnosticsForMcp(diagnostics) {
|
|
45
24
|
return diagnostics.map((d) => ({
|
|
46
25
|
category: d.category,
|
|
@@ -173,7 +152,7 @@ export async function handleKbCheck(prolog, args) {
|
|
|
173
152
|
// implements REQ-002
|
|
174
153
|
async function runAggregatedChecks(prolog, rulesAllowlist, requireAdr) {
|
|
175
154
|
const violations = [];
|
|
176
|
-
const checksPlPath =
|
|
155
|
+
const checksPlPath = resolveCorePlPath("checks.pl");
|
|
177
156
|
const normalizedChecksPlPath = checksPlPath.replace(/\\/g, "/");
|
|
178
157
|
const checksPlPathEscaped = normalizedChecksPlPath.replace(/'/g, "''");
|
|
179
158
|
// Use check_all_json_with_options if available, otherwise fall back to check_all_json
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
import path from "node:path";
|
|
4
|
-
import { PrologProcess } from "kibi-cli/prolog";
|
|
3
|
+
import { PrologProcess, resolveKbPlPath } from "kibi-cli/prolog";
|
|
5
4
|
import { escapeAtomContent } from "kibi-cli/prolog/codec";
|
|
6
|
-
const require = createRequire(import.meta.url);
|
|
7
5
|
// implements REQ-002, REQ-013
|
|
8
6
|
export function resolveCorePlPath(fileName) {
|
|
9
7
|
const envKey = `KIBI_${fileName.replace(/\W/g, "_").toUpperCase()}_PATH`;
|
|
@@ -11,20 +9,12 @@ export function resolveCorePlPath(fileName) {
|
|
|
11
9
|
if (override && existsSync(override)) {
|
|
12
10
|
return override;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
// require.resolve not available or package not installed
|
|
22
|
-
}
|
|
23
|
-
const localPath = path.join(process.cwd(), "packages/core/src", fileName);
|
|
24
|
-
if (existsSync(localPath)) {
|
|
25
|
-
return localPath;
|
|
12
|
+
const kbPlPath = resolveKbPlPath();
|
|
13
|
+
const sibling = path.join(path.dirname(kbPlPath), fileName);
|
|
14
|
+
if (existsSync(sibling)) {
|
|
15
|
+
return sibling;
|
|
26
16
|
}
|
|
27
|
-
throw new Error(`
|
|
17
|
+
throw new Error(`Root-consistency error: resolveKbPlPath() resolved to '${kbPlPath}' but sibling '${fileName}' not found at '${sibling}'`);
|
|
28
18
|
}
|
|
29
19
|
// implements REQ-002, REQ-013
|
|
30
20
|
export async function runJsonModuleQuery(prolog, fileName, goal, errorLabel) {
|
package/dist/tools/symbols.js
CHANGED
|
@@ -45,6 +45,7 @@ const SOURCE_EXTENSIONS = new Set([
|
|
|
45
45
|
".cjs",
|
|
46
46
|
]);
|
|
47
47
|
export async function handleKbSymbolsRefresh(args) {
|
|
48
|
+
// implements REQ-vscode-traceability
|
|
48
49
|
const dryRun = args.dryRun === true;
|
|
49
50
|
const workspaceRoot = resolveWorkspaceRoot();
|
|
50
51
|
const manifestPath = resolveManifestPath(workspaceRoot);
|
|
@@ -112,6 +113,7 @@ export async function handleKbSymbolsRefresh(args) {
|
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
export async function refreshCoordinatesForSymbolId(symbolId, workspaceRoot = resolveWorkspaceRoot()) {
|
|
116
|
+
// implements REQ-vscode-traceability
|
|
115
117
|
const manifestPath = resolveManifestPath(workspaceRoot);
|
|
116
118
|
const rawContent = readFileSync(manifestPath, "utf8");
|
|
117
119
|
const parsed = parseYAML(rawContent);
|
package/dist/tools/upsert.js
CHANGED
|
@@ -20,6 +20,7 @@ import { escapeAtom, toPrologAtom, toPrologString, } from "kibi-cli/prolog/codec
|
|
|
20
20
|
import entitySchema from "kibi-cli/schemas/entity";
|
|
21
21
|
import relationshipSchema from "kibi-cli/schemas/relationship";
|
|
22
22
|
import { refreshCoordinatesForSymbolId } from "./symbols.js";
|
|
23
|
+
let refreshCoordinatesForSymbolIdImpl = refreshCoordinatesForSymbolId;
|
|
23
24
|
const ajv = new Ajv({ strict: false });
|
|
24
25
|
const validateEntity = ajv.compile(entitySchema);
|
|
25
26
|
const validateRelationship = ajv.compile(relationshipSchema);
|
|
@@ -155,7 +156,7 @@ export async function handleKbUpsert(prolog, args) {
|
|
|
155
156
|
}
|
|
156
157
|
if (type === "symbol") {
|
|
157
158
|
try {
|
|
158
|
-
await
|
|
159
|
+
await refreshCoordinatesForSymbolIdImpl(id);
|
|
159
160
|
}
|
|
160
161
|
catch (error) {
|
|
161
162
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -183,6 +184,12 @@ export async function handleKbUpsert(prolog, args) {
|
|
|
183
184
|
throw new Error(`Upsert execution failed: ${message}`);
|
|
184
185
|
}
|
|
185
186
|
}
|
|
187
|
+
export const __test__ = {
|
|
188
|
+
// implements REQ-vscode-traceability
|
|
189
|
+
setRefreshCoordinatesForSymbolIdForTests(fn) {
|
|
190
|
+
refreshCoordinatesForSymbolIdImpl = fn ?? refreshCoordinatesForSymbolId;
|
|
191
|
+
},
|
|
192
|
+
};
|
|
186
193
|
/**
|
|
187
194
|
* Build Prolog property list from entity object
|
|
188
195
|
* Returns simple Key=Value format without typed literals
|
|
@@ -216,6 +223,8 @@ function buildPropertyList(entity) {
|
|
|
216
223
|
for (const [key, value] of Object.entries(entity)) {
|
|
217
224
|
if (key === "type")
|
|
218
225
|
continue;
|
|
226
|
+
if (value === undefined || value === null)
|
|
227
|
+
continue;
|
|
219
228
|
let prologValue;
|
|
220
229
|
if (key === "id" && typeof value === "string") {
|
|
221
230
|
prologValue = `'${value.replace(/'/g, "''")}'`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kibi-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
6
6
|
"ajv": "^8.18.0",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"fast-glob": "^3.2.12",
|
|
10
10
|
"gray-matter": "^4.0.3",
|
|
11
11
|
"js-yaml": "^4.1.0",
|
|
12
|
-
"kibi-cli": "^0.
|
|
13
|
-
"kibi-core": "^0.
|
|
12
|
+
"kibi-cli": "^0.5.0",
|
|
13
|
+
"kibi-core": "^0.4.0",
|
|
14
14
|
"mcpcat": "^0.1.12",
|
|
15
15
|
"ts-morph": "^23.0.0",
|
|
16
16
|
"zod": "^4.3.6"
|