kibi-mcp 0.22.0 → 1.0.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/bin/kibi-mcp +12 -11
- package/dist/diagnostics.js +61 -1
- package/dist/env.js +5 -1
- package/dist/runtime/mcp-runtime.js +36 -3
- package/dist/server/docs.js +31 -42
- package/dist/server/icons.js +27 -0
- package/dist/server/json-schema-to-zod.js +18 -1
- package/dist/server/session.js +25 -51
- package/dist/server/tool-registration.js +35 -8
- package/dist/server/tools-runtime.js +4 -4
- package/dist/server/tools.js +86 -7
- package/dist/server.js +16 -1
- package/dist/tools/check-impact.js +1 -1
- package/dist/tools/check.js +1 -1
- package/dist/tools/core-module.js +11 -3
- package/dist/tools/coverage.js +1 -1
- package/dist/tools/delete.js +1 -1
- package/dist/tools/discovery-adapter.js +5 -0
- package/dist/tools/entity-query.js +1 -1
- package/dist/tools/find-gaps.js +9 -1
- package/dist/tools/graph.js +9 -1
- package/dist/tools/model-requirement.js +2 -2
- package/dist/tools/mutation-context.js +15 -9
- package/dist/tools/plan-bootstrap.js +21 -0
- package/dist/tools/prolog-list.js +1 -1
- package/dist/tools/query.js +1 -1
- package/dist/tools/relationship-validation.js +1 -1
- package/dist/tools/search.js +1 -1
- package/dist/tools/semantic-advisor.js +1 -1
- package/dist/tools/skills.js +2 -2
- package/dist/tools/sparql.js +1 -1
- package/dist/tools/status.js +1 -1
- package/dist/tools/suggest-predicates.js +1 -1
- package/dist/tools/symbols.js +310 -68
- package/dist/tools/upsert.js +3 -3
- package/dist/tools/validate-upsert.js +1 -1
- package/dist/tools-config.js +77 -3
- package/dist/workspace.js +3 -2
- package/package.json +13 -8
- package/dist/tools/autopilot-candidates.js +0 -554
- package/dist/tools/autopilot-discovery.js +0 -898
- package/dist/tools/autopilot-generate.js +0 -47
- package/dist/tools/autopilot-test-compat.js +0 -88
- package/dist/tools/autopilot-test-parsers.js +0 -120
- package/dist/tools/check-config.js +0 -67
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { getSpec } from "kibi-
|
|
2
|
-
import { nodeGit } from "kibi-cli/operations/node-ports";
|
|
1
|
+
import { getSpec, nodeFilesystem, nodeGit } from "kibi-runtime";
|
|
3
2
|
import { DIAGNOSTIC_MODE_ENABLED, appendUsageLogLine, classifyDiagnosticError, deriveDiagnosticFields, extractToolCallPayload, } from "../diagnostics.js";
|
|
4
3
|
import { isMcpDebugEnabled } from "../env.js";
|
|
5
4
|
import { createMcpRuntime } from "../runtime/mcp-runtime.js";
|
|
6
5
|
import { TOOLS } from "../tools-config.js";
|
|
7
|
-
import { handleKbAutopilotGenerate } from "../tools/autopilot-generate.js";
|
|
8
6
|
import { handleKbCheck } from "../tools/check.js";
|
|
9
7
|
import { handleKbCoverage } from "../tools/coverage.js";
|
|
10
8
|
import { handleKbDelete } from "../tools/delete.js";
|
|
11
9
|
import { handleKbFindGaps } from "../tools/find-gaps.js";
|
|
12
10
|
import { handleKbGraph } from "../tools/graph.js";
|
|
13
11
|
import { handleKbModelRequirement } from "../tools/model-requirement.js";
|
|
12
|
+
import { handleKbPlanBootstrap } from "../tools/plan-bootstrap.js";
|
|
14
13
|
import { handleKbQuery } from "../tools/query.js";
|
|
15
14
|
import { handleKbSearch } from "../tools/search.js";
|
|
16
15
|
import { handleKbSemanticAdvisor } from "../tools/semantic-advisor.js";
|
|
@@ -96,6 +95,7 @@ const operationRuntime = createMcpRuntime({
|
|
|
96
95
|
attachedBranchKbPath: async () => (await getSessionModule()).attachedBranchKbPath,
|
|
97
96
|
ensureProlog: async () => (await getSessionModule()).ensureProlog(),
|
|
98
97
|
adaptProlog,
|
|
98
|
+
fs: nodeFilesystem,
|
|
99
99
|
git: nodeGit,
|
|
100
100
|
net: { fetch: (input, init) => globalThis.fetch(input, init) },
|
|
101
101
|
refreshAttachedBranchStamp: async () => {
|
|
@@ -148,5 +148,5 @@ export const DEFAULT_TOOLS_RUNTIME = {
|
|
|
148
148
|
handleKbValidateUpsert,
|
|
149
149
|
handleKbModelRequirement,
|
|
150
150
|
handleKbSuggestPredicates,
|
|
151
|
-
|
|
151
|
+
handleKbPlanBootstrap,
|
|
152
152
|
};
|
package/dist/server/tools.js
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
import process from "node:process";
|
|
19
|
-
import { executeOperation
|
|
19
|
+
import { executeOperation } from "kibi-runtime";
|
|
20
|
+
import { operationData, toKibiResult } from "kibi-runtime";
|
|
20
21
|
import { isMcpDebugEnabled } from "../env.js";
|
|
21
22
|
import { appendDiagnosticErrorUsage, appendDiagnosticSuccessUsage, } from "./diagnostic-usage.js";
|
|
22
23
|
import { jsonSchemaToZod } from "./json-schema-to-zod.js";
|
|
@@ -26,6 +27,10 @@ export { jsonSchemaToZod } from "./json-schema-to-zod.js";
|
|
|
26
27
|
export { _resetSessionModulePromise, _setToolsServerDepsForTests };
|
|
27
28
|
const DEFAULT_TOOL_TIMEOUT_MS = 90_000;
|
|
28
29
|
const TOOL_TIMEOUT_ENV = "KIBI_MCP_TOOL_TIMEOUT_MS";
|
|
30
|
+
// Give cancellation and the Prolog reset a short bounded grace period, but do
|
|
31
|
+
// not hold the MCP request open for the full five-second shutdown budget when
|
|
32
|
+
// a handler never observes AbortSignal.
|
|
33
|
+
const TOOL_TIMEOUT_GRACE_MS = 100;
|
|
29
34
|
// implements REQ-008
|
|
30
35
|
function debugLog(...args) {
|
|
31
36
|
if (isMcpDebugEnabled()) {
|
|
@@ -45,7 +50,13 @@ function getToolTimeoutMs() {
|
|
|
45
50
|
}
|
|
46
51
|
// implements REQ-002
|
|
47
52
|
function createToolTimeoutError(toolName, timeoutMs) {
|
|
48
|
-
|
|
53
|
+
const error = new Error(`Tool ${toolName} timed out after ${timeoutMs}ms`);
|
|
54
|
+
Object.assign(error, { code: "KIBI_TOOL_TIMEOUT", toolName, timeoutMs });
|
|
55
|
+
return error;
|
|
56
|
+
}
|
|
57
|
+
function isToolTimeoutError(value) {
|
|
58
|
+
return (value instanceof Error &&
|
|
59
|
+
value.code === "KIBI_TOOL_TIMEOUT");
|
|
49
60
|
}
|
|
50
61
|
// implements REQ-002
|
|
51
62
|
async function withToolTimeout(toolName, operation, onTimeout) {
|
|
@@ -57,8 +68,19 @@ async function withToolTimeout(toolName, operation, onTimeout) {
|
|
|
57
68
|
new Promise((_, reject) => {
|
|
58
69
|
timeout = setTimeout(() => {
|
|
59
70
|
const error = createToolTimeoutError(toolName, timeoutMs);
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
// Do not report the timeout until cancellation/reset has completed
|
|
72
|
+
// and the original request has reached a terminal state. This is
|
|
73
|
+
// especially important for source-first mutations: a caller must
|
|
74
|
+
// never retry while the authoritative journal is still deciding its
|
|
75
|
+
// outcome.
|
|
76
|
+
void onTimeout(error, timeoutMs)
|
|
77
|
+
.then(async () => {
|
|
78
|
+
await Promise.race([
|
|
79
|
+
operation.then(() => undefined, () => undefined),
|
|
80
|
+
new Promise((resolve) => setTimeout(resolve, TOOL_TIMEOUT_GRACE_MS)),
|
|
81
|
+
]);
|
|
82
|
+
})
|
|
83
|
+
.finally(() => reject(error));
|
|
62
84
|
}, timeoutMs);
|
|
63
85
|
}),
|
|
64
86
|
]);
|
|
@@ -74,7 +96,7 @@ export function addTool(server, name, description, inputSchema, handler,
|
|
|
74
96
|
// INTENTIONAL: DEFAULT_TOOLS_RUNTIME is typed as ToolsRuntime<PrologProcess>; the
|
|
75
97
|
// generic TProlog parameter exists so tests can inject a mock type. The cast is safe
|
|
76
98
|
// because the runtime object satisfies the full ToolsRuntime contract at runtime.
|
|
77
|
-
runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations) {
|
|
99
|
+
runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations, outputSchema) {
|
|
78
100
|
const wrappedHandler = async (args) => {
|
|
79
101
|
const startedAt = new Date();
|
|
80
102
|
const diagnosticModeEnabled = runtime.diagnosticModeEnabled();
|
|
@@ -127,6 +149,8 @@ runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations) {
|
|
|
127
149
|
error instanceof Error ? error.message : String(error);
|
|
128
150
|
}
|
|
129
151
|
});
|
|
152
|
+
const data = operationData(result);
|
|
153
|
+
const envelope = toKibiResult(operationSpec, data);
|
|
130
154
|
// Log usage in diagnostic mode
|
|
131
155
|
if (diagnosticModeEnabled) {
|
|
132
156
|
await appendDiagnosticSuccessUsage({
|
|
@@ -137,10 +161,22 @@ runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations) {
|
|
|
137
161
|
businessArgs,
|
|
138
162
|
telemetry,
|
|
139
163
|
startedAt,
|
|
140
|
-
result,
|
|
164
|
+
result: envelope,
|
|
141
165
|
});
|
|
142
166
|
}
|
|
143
|
-
|
|
167
|
+
if (result !== null &&
|
|
168
|
+
typeof result === "object" &&
|
|
169
|
+
!Array.isArray(result) &&
|
|
170
|
+
"content" in result) {
|
|
171
|
+
return {
|
|
172
|
+
...result,
|
|
173
|
+
structuredContent: envelope,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
content: [{ type: "text", text: JSON.stringify(envelope) }],
|
|
178
|
+
structuredContent: envelope,
|
|
179
|
+
};
|
|
144
180
|
}
|
|
145
181
|
catch (error) {
|
|
146
182
|
// Log error in diagnostic mode
|
|
@@ -157,6 +193,48 @@ runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations) {
|
|
|
157
193
|
resetState: { resetAttempted, resetSucceeded, resetError },
|
|
158
194
|
});
|
|
159
195
|
}
|
|
196
|
+
if (isToolTimeoutError(error) &&
|
|
197
|
+
operationSpec.effects.some((effect) => effect === "kb-write" || effect === "workspace-write")) {
|
|
198
|
+
const recoveryActions = [
|
|
199
|
+
{
|
|
200
|
+
operation: "kb_status",
|
|
201
|
+
reason: "Determine whether the mutation crossed the authoritative source/journal commit boundary before taking any further action.",
|
|
202
|
+
required: true,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
operation: "kb_apply_plan",
|
|
206
|
+
reason: "If status exposes a recovery journal, replay that typed journal action; never retry the timed-out mutation request.",
|
|
207
|
+
required: true,
|
|
208
|
+
},
|
|
209
|
+
];
|
|
210
|
+
const timeoutData = {
|
|
211
|
+
effectFailures: [
|
|
212
|
+
{
|
|
213
|
+
kind: "mutation",
|
|
214
|
+
errorCode: "MUTATION_OUTCOME_UNKNOWN",
|
|
215
|
+
detail: {
|
|
216
|
+
requestId,
|
|
217
|
+
timeoutMs: error.timeoutMs,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
nextActions: recoveryActions,
|
|
222
|
+
};
|
|
223
|
+
const envelope = toKibiResult(operationSpec, timeoutData, {
|
|
224
|
+
status: "error",
|
|
225
|
+
nextActions: recoveryActions,
|
|
226
|
+
error: {
|
|
227
|
+
code: "MUTATION_OUTCOME_UNKNOWN",
|
|
228
|
+
message: "The mutation timed out after cancellation; its commit state is indeterminate. Inspect status and replay the typed recovery action if required.",
|
|
229
|
+
retryable: false,
|
|
230
|
+
details: { requestId, tool: name },
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
content: [{ type: "text", text: JSON.stringify(envelope) }],
|
|
235
|
+
structuredContent: envelope,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
160
238
|
throw error;
|
|
161
239
|
}
|
|
162
240
|
finally {
|
|
@@ -176,6 +254,7 @@ runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations) {
|
|
|
176
254
|
server.registerTool(name, {
|
|
177
255
|
description,
|
|
178
256
|
inputSchema: jsonSchemaToZod(inputSchema),
|
|
257
|
+
...(outputSchema ? { outputSchema: jsonSchemaToZod(outputSchema) } : {}),
|
|
179
258
|
...(annotations ? { annotations } : {}),
|
|
180
259
|
}, wrappedHandler);
|
|
181
260
|
}
|
package/dist/server.js
CHANGED
|
@@ -21,18 +21,33 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
21
21
|
import { initializeDiagnosticMode } from "./diagnostics.js";
|
|
22
22
|
import { loadDefaultEnvFile } from "./env.js";
|
|
23
23
|
import { setupDocsAndPrompts } from "./server/docs.js";
|
|
24
|
+
import { KIBI_ICONS } from "./server/icons.js";
|
|
24
25
|
import { registerAllTools } from "./server/tools.js";
|
|
25
26
|
import { connectTransport, setupTransportHandlers, } from "./server/transport.js";
|
|
26
27
|
// Read version from package.json to prevent drift
|
|
27
28
|
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
28
29
|
const VERSION = packageJson.version ?? "0.1.0";
|
|
30
|
+
const SERVER_INSTRUCTIONS = [
|
|
31
|
+
"Kibi is a branch-local requirements knowledge base for software traceability.",
|
|
32
|
+
"Start with kb_search for discovery, then kb_query for exact lookups before any mutation.",
|
|
33
|
+
"Model requirements as linked facts via kb_model_requirement or kb_upsert (create endpoints before linking them).",
|
|
34
|
+
"Mutate sequentially with kb_upsert and kb_delete; validate with kb_check during iteration and run an unfiltered kb_check before completion.",
|
|
35
|
+
"Confirm branch freshness with kb_status. For first-time repository setup, use the kibi-bootstrap prompt.",
|
|
36
|
+
].join(" ");
|
|
29
37
|
export async function startServer() {
|
|
30
38
|
// Load environment configuration
|
|
31
39
|
loadDefaultEnvFile();
|
|
32
40
|
// Initialize diagnostic mode if --diagnostic-mode flag is present
|
|
33
41
|
initializeDiagnosticMode();
|
|
34
42
|
// Create MCP server
|
|
35
|
-
const server = new McpServer({
|
|
43
|
+
const server = new McpServer({
|
|
44
|
+
name: "kibi-mcp",
|
|
45
|
+
title: "Kibi MCP",
|
|
46
|
+
description: "Agent-native requirements compiler: branch-local knowledge base for requirements, scenarios, tests, facts, and code-symbol traceability.",
|
|
47
|
+
websiteUrl: "https://github.com/Looted/kibi",
|
|
48
|
+
version: VERSION,
|
|
49
|
+
icons: KIBI_ICONS,
|
|
50
|
+
}, { instructions: SERVER_INSTRUCTIONS });
|
|
36
51
|
// Setup documentation resources and prompts
|
|
37
52
|
setupDocsAndPrompts(server);
|
|
38
53
|
// Register all KB tools
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
-
import { analyzeChangedFileImpact, } from "kibi-
|
|
18
|
+
import { analyzeChangedFileImpact, } from "kibi-runtime";
|
|
19
19
|
export function hasImpactOptions(args) {
|
|
20
20
|
return Boolean(args.includeImpactDiagnostics ||
|
|
21
21
|
args.staged ||
|
package/dist/tools/check.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { PrologProcess, resolveKbPlPath } from "kibi-
|
|
3
|
-
import { escapeAtomContent } from "kibi-
|
|
2
|
+
import { PrologProcess, resolveKbPlPath } from "kibi-runtime";
|
|
3
|
+
import { escapeAtomContent } from "kibi-runtime";
|
|
4
4
|
import { getCoreModulePathOverride, getKbPlPathOverride } from "../env.js";
|
|
5
|
+
function isPrologProcess(value) {
|
|
6
|
+
return (value instanceof PrologProcess ||
|
|
7
|
+
(value !== null &&
|
|
8
|
+
typeof value === "object" &&
|
|
9
|
+
typeof value.query === "function" &&
|
|
10
|
+
typeof value.invalidateCache ===
|
|
11
|
+
"function"));
|
|
12
|
+
}
|
|
5
13
|
// implements REQ-002, REQ-013
|
|
6
14
|
export function resolveCorePlPath(fileName) {
|
|
7
15
|
const override = getCoreModulePathOverride(fileName);
|
|
@@ -20,7 +28,7 @@ export function resolveCorePlPath(fileName) {
|
|
|
20
28
|
// implements REQ-002, REQ-013
|
|
21
29
|
export async function runJsonModuleQuery(prolog, fileName, goal, errorLabel) {
|
|
22
30
|
const modulePath = escapeAtomContent(resolveCorePlPath(fileName).replace(/\\/g, "/"));
|
|
23
|
-
if (!(prolog
|
|
31
|
+
if (!isPrologProcess(prolog)) {
|
|
24
32
|
const mockedResult = await prolog.query(`(use_module('${modulePath}'), ${goal})`);
|
|
25
33
|
if (!mockedResult.success) {
|
|
26
34
|
throw new Error(`${errorLabel} query failed: ${mockedResult.error || "Unknown error"}`);
|
package/dist/tools/coverage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { executeCoverage, } from "kibi-
|
|
1
|
+
import { executeCoverage, } from "kibi-runtime";
|
|
2
2
|
import { createDiscoveryContext } from "./discovery-adapter.js";
|
|
3
3
|
// implements REQ-002, REQ-013
|
|
4
4
|
export async function handleKbCoverage(prolog, args, context) {
|
package/dist/tools/delete.js
CHANGED
|
@@ -2,11 +2,16 @@ import { resolveWorkspaceRoot } from "../workspace.js";
|
|
|
2
2
|
export function createDiscoveryContext(prolog, baseContext) {
|
|
3
3
|
// implements REQ-kibi-operation-interface-parity
|
|
4
4
|
let lastResult = null;
|
|
5
|
+
const mode = prolog
|
|
6
|
+
.useOneShotMode;
|
|
5
7
|
const port = {
|
|
6
8
|
query: async (goal) => {
|
|
7
9
|
lastResult = await prolog.query(goal);
|
|
8
10
|
return lastResult;
|
|
9
11
|
},
|
|
12
|
+
oneShotMode: mode === undefined
|
|
13
|
+
? typeof globalThis.Bun !== "undefined"
|
|
14
|
+
: Boolean(mode),
|
|
10
15
|
nextSolution: async () => {
|
|
11
16
|
const result = lastResult;
|
|
12
17
|
lastResult = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { VALID_ENTITY_TYPES, buildEntityGoal, dedupeEntities, loadEntities, paginateResults, validateEntityType, } from "kibi-
|
|
1
|
+
export { VALID_ENTITY_TYPES, buildEntityGoal, dedupeEntities, loadEntities, paginateResults, validateEntityType, } from "kibi-runtime";
|
package/dist/tools/find-gaps.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { executeFindGaps } from "kibi-
|
|
1
|
+
import { executeFindGaps } from "kibi-runtime";
|
|
2
|
+
function oneShotMode(prolog) {
|
|
3
|
+
const mode = prolog
|
|
4
|
+
.useOneShotMode;
|
|
5
|
+
return mode === undefined
|
|
6
|
+
? typeof globalThis.Bun !== "undefined"
|
|
7
|
+
: Boolean(mode);
|
|
8
|
+
}
|
|
2
9
|
// implements REQ-002, REQ-013
|
|
3
10
|
export async function handleKbFindGaps(prolog, args) {
|
|
4
11
|
return executeFindGaps({ ...args }, {
|
|
@@ -7,6 +14,7 @@ export async function handleKbFindGaps(prolog, args) {
|
|
|
7
14
|
clock: () => new Date(),
|
|
8
15
|
prolog: {
|
|
9
16
|
query: (goal) => prolog.query(goal),
|
|
17
|
+
oneShotMode: oneShotMode(prolog),
|
|
10
18
|
nextSolution: async () => null,
|
|
11
19
|
save: () => prolog.query("kb_save"),
|
|
12
20
|
},
|
package/dist/tools/graph.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { executeGraph } from "kibi-
|
|
1
|
+
import { executeGraph } from "kibi-runtime";
|
|
2
|
+
function oneShotMode(prolog) {
|
|
3
|
+
const mode = prolog
|
|
4
|
+
.useOneShotMode;
|
|
5
|
+
return mode === undefined
|
|
6
|
+
? typeof globalThis.Bun !== "undefined"
|
|
7
|
+
: Boolean(mode);
|
|
8
|
+
}
|
|
2
9
|
// implements REQ-002, REQ-013
|
|
3
10
|
export async function handleKbGraph(prolog, args) {
|
|
4
11
|
return executeGraph({ ...args }, {
|
|
@@ -7,6 +14,7 @@ export async function handleKbGraph(prolog, args) {
|
|
|
7
14
|
clock: () => new Date(),
|
|
8
15
|
prolog: {
|
|
9
16
|
query: (goal) => prolog.query(goal),
|
|
17
|
+
oneShotMode: oneShotMode(prolog),
|
|
10
18
|
nextSolution: async () => null,
|
|
11
19
|
save: () => prolog.query("kb_save"),
|
|
12
20
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { modelRequirementSpec
|
|
2
|
-
import { estimateNormativeSignalConfidence, extractRequirementClaim, getWorkspaceMigrationWarning, strictWriteSetToApplyPlan, writeSetPrimaryEntityId, } from "kibi-
|
|
1
|
+
import { modelRequirementSpec } from "kibi-runtime";
|
|
2
|
+
import { estimateNormativeSignalConfidence, extractRequirementClaim, getWorkspaceMigrationWarning, strictWriteSetToApplyPlan, writeSetPrimaryEntityId, } from "kibi-runtime";
|
|
3
3
|
import { resolveWorkspaceRoot } from "../workspace.js";
|
|
4
4
|
export { estimateNormativeSignalConfidence, extractRequirementClaim, getWorkspaceMigrationWarning, strictWriteSetToApplyPlan, writeSetPrimaryEntityId, };
|
|
5
5
|
export async function handleKbModelRequirement(_prolog, args) {
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import { resolveWorkspaceRoot } from "../workspace.js";
|
|
3
|
-
const filesystem = {
|
|
4
|
-
readFile: (filePath) => fs.readFile(filePath, "utf8"),
|
|
5
|
-
writeFile: (filePath, data) => fs.writeFile(filePath, data, "utf8"),
|
|
6
|
-
mkdir: async (directoryPath) => {
|
|
7
|
-
await fs.mkdir(directoryPath, { recursive: true });
|
|
8
|
-
},
|
|
9
|
-
stat: (filePath) => fs.stat(filePath),
|
|
10
|
-
};
|
|
11
3
|
// implements REQ-kibi-operation-interface-parity
|
|
12
4
|
export function createMutationContext(prolog) {
|
|
13
5
|
const port = prolog === undefined
|
|
@@ -22,7 +14,21 @@ export function createMutationContext(prolog) {
|
|
|
22
14
|
workspaceRoot: resolveWorkspaceRoot(),
|
|
23
15
|
signal: new AbortController().signal,
|
|
24
16
|
clock: () => new Date(),
|
|
25
|
-
|
|
17
|
+
// The thin direct handler remains a compiled-KB compatibility surface.
|
|
18
|
+
// Production MCP registration supplies sourceFirst through the shared
|
|
19
|
+
// operation runtime while this adapter still exposes filesystem reads for
|
|
20
|
+
// symbol-granularity validation.
|
|
21
|
+
sourceFirst: false,
|
|
22
|
+
...(process.env.KIBI_WORKSPACE !== undefined ? { fs: filesystem } : {}),
|
|
26
23
|
...(port === undefined ? {} : { prolog: port }),
|
|
27
24
|
};
|
|
28
25
|
}
|
|
26
|
+
const filesystem = {
|
|
27
|
+
readFile: (filePath) => fs.readFile(filePath, "utf8"),
|
|
28
|
+
writeFile: (filePath, data) => fs.writeFile(filePath, data, "utf8"),
|
|
29
|
+
mkdir: async (directoryPath) => {
|
|
30
|
+
await fs.mkdir(directoryPath, { recursive: true });
|
|
31
|
+
},
|
|
32
|
+
stat: (filePath) => fs.stat(filePath),
|
|
33
|
+
unlink: (filePath) => fs.unlink(filePath),
|
|
34
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { executePlanBootstrap, } from "kibi-runtime";
|
|
2
|
+
import { nodeFilesystem, nodeGit } from "kibi-runtime";
|
|
3
|
+
import { resolveWorkspaceRoot } from "../workspace.js";
|
|
4
|
+
function isOperationContext(value) {
|
|
5
|
+
return (value !== null &&
|
|
6
|
+
typeof value === "object" &&
|
|
7
|
+
"workspaceRoot" in value &&
|
|
8
|
+
"signal" in value);
|
|
9
|
+
}
|
|
10
|
+
// implements REQ-mcp-kibi-bootstrap-bootstrap-v1, REQ-kibi-operation-interface-parity
|
|
11
|
+
// implements REQ-KIBI-BOOTSTRAP-PLAN
|
|
12
|
+
export async function handleKbPlanBootstrap(input, context) {
|
|
13
|
+
if (!isOperationContext(context))
|
|
14
|
+
throw new TypeError("Invalid bootstrap adapter invocation");
|
|
15
|
+
return executePlanBootstrap(input, {
|
|
16
|
+
...context,
|
|
17
|
+
workspaceRoot: context.workspaceRoot || resolveWorkspaceRoot(),
|
|
18
|
+
fs: context.fs ?? nodeFilesystem,
|
|
19
|
+
git: context.git ?? nodeGit,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
-
import { splitTopLevel } from "kibi-
|
|
18
|
+
import { splitTopLevel } from "kibi-runtime";
|
|
19
19
|
// implements REQ-002
|
|
20
20
|
export function parseAtomList(raw) {
|
|
21
21
|
const trimmed = raw.trim();
|
package/dist/tools/query.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VALID_ENTITY_TYPES, querySpec } from "kibi-
|
|
1
|
+
import { VALID_ENTITY_TYPES, querySpec } from "kibi-runtime";
|
|
2
2
|
import { createDiscoveryContext } from "./discovery-adapter.js";
|
|
3
3
|
export { VALID_ENTITY_TYPES };
|
|
4
4
|
export async function handleKbQuery(prolog, args) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatInvalidRelationshipError, formatInvalidRelationshipTuple, formatRelationshipSourceMismatch, validateLiveRelationshipTargets as validateSharedTargets, } from "kibi-
|
|
1
|
+
import { formatInvalidRelationshipError, formatInvalidRelationshipTuple, formatRelationshipSourceMismatch, validateLiveRelationshipTargets as validateSharedTargets, } from "kibi-runtime";
|
|
2
2
|
export { formatInvalidRelationshipError, formatInvalidRelationshipTuple, formatRelationshipSourceMismatch, };
|
|
3
3
|
export async function validateLiveRelationshipTargets(prolog, entity, relationships) {
|
|
4
4
|
const port = {
|
package/dist/tools/search.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { searchSpec } from "kibi-
|
|
1
|
+
import { searchSpec } from "kibi-runtime";
|
|
2
2
|
import { createDiscoveryContext } from "./discovery-adapter.js";
|
|
3
3
|
export async function handleKbSearch(prolog, args) {
|
|
4
4
|
// implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
|
package/dist/tools/skills.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { skillsListSpec, skillsLoadSpec, skillsReadSpec, } from "kibi-
|
|
2
|
-
import { loadBundledSkill } from "kibi-
|
|
1
|
+
import { skillsListSpec, skillsLoadSpec, skillsReadSpec, } from "kibi-runtime";
|
|
2
|
+
import { loadBundledSkill } from "kibi-runtime";
|
|
3
3
|
function runtimeContext() {
|
|
4
4
|
return {
|
|
5
5
|
workspaceRoot: process.cwd(),
|
package/dist/tools/sparql.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sparqlRemoteSpec } from "kibi-
|
|
1
|
+
import { sparqlRemoteSpec } from "kibi-runtime";
|
|
2
2
|
// implements REQ-002, REQ-013, REQ-kibi-operation-interface-parity
|
|
3
3
|
export async function handleSparql(prologOrArgs, legacyArgs) {
|
|
4
4
|
const args = legacyArgs ?? ("endpoint" in prologOrArgs ? prologOrArgs : undefined);
|
package/dist/tools/status.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { statusSpec } from "kibi-
|
|
1
|
+
import { statusSpec } from "kibi-runtime";
|
|
2
2
|
import { createDiscoveryContext } from "./discovery-adapter.js";
|
|
3
3
|
export async function handleKbStatus(prolog, args, context) {
|
|
4
4
|
// implements REQ-kibi-operation-interface-parity
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { suggestPredicatesSpec
|
|
1
|
+
import { suggestPredicatesSpec } from "kibi-runtime";
|
|
2
2
|
import { resolveWorkspaceRoot } from "../workspace.js";
|
|
3
3
|
import { createDiscoveryContext } from "./discovery-adapter.js";
|
|
4
4
|
export async function handleKbSuggestPredicates(prolog, args) {
|