kibi-mcp 0.22.0 → 2.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.
Files changed (47) hide show
  1. package/bin/kibi-mcp +12 -11
  2. package/dist/diagnostics.js +68 -8
  3. package/dist/env.js +5 -1
  4. package/dist/runtime/mcp-runtime.js +39 -3
  5. package/dist/server/docs.js +31 -42
  6. package/dist/server/icons.js +27 -0
  7. package/dist/server/jobs.js +107 -0
  8. package/dist/server/json-schema-to-zod.js +33 -9
  9. package/dist/server/session.js +129 -133
  10. package/dist/server/tool-registration.js +46 -9
  11. package/dist/server/tools-runtime.js +10 -10
  12. package/dist/server/tools.js +143 -7
  13. package/dist/server.js +16 -1
  14. package/dist/startup-resolution.js +15 -17
  15. package/dist/tools/check-impact.js +1 -1
  16. package/dist/tools/check.js +1 -1
  17. package/dist/tools/core-module.js +19 -8
  18. package/dist/tools/coverage.js +1 -1
  19. package/dist/tools/delete.js +1 -1
  20. package/dist/tools/discovery-adapter.js +5 -0
  21. package/dist/tools/entity-query.js +1 -1
  22. package/dist/tools/find-gaps.js +9 -1
  23. package/dist/tools/graph.js +9 -1
  24. package/dist/tools/model-requirement.js +2 -2
  25. package/dist/tools/mutation-context.js +15 -9
  26. package/dist/tools/plan-bootstrap.js +21 -0
  27. package/dist/tools/prolog-list.js +1 -1
  28. package/dist/tools/query.js +1 -1
  29. package/dist/tools/relationship-validation.js +1 -1
  30. package/dist/tools/search.js +1 -1
  31. package/dist/tools/semantic-advisor.js +1 -1
  32. package/dist/tools/skills.js +2 -2
  33. package/dist/tools/sparql.js +1 -1
  34. package/dist/tools/status.js +1 -1
  35. package/dist/tools/suggest-predicates.js +1 -1
  36. package/dist/tools/symbols.js +310 -68
  37. package/dist/tools/upsert.js +3 -3
  38. package/dist/tools/validate-upsert.js +1 -1
  39. package/dist/tools-config.js +77 -3
  40. package/dist/workspace.js +10 -8
  41. package/package.json +15 -9
  42. package/dist/tools/autopilot-candidates.js +0 -554
  43. package/dist/tools/autopilot-discovery.js +0 -898
  44. package/dist/tools/autopilot-generate.js +0 -47
  45. package/dist/tools/autopilot-test-compat.js +0 -88
  46. package/dist/tools/autopilot-test-parsers.js +0 -120
  47. package/dist/tools/check-config.js +0 -67
@@ -1,47 +0,0 @@
1
- import { executeAutopilotGenerate, } from "kibi-cli/operations";
2
- import { nodeFilesystem, nodeGit } from "kibi-cli/operations";
3
- import { PrologProcess } from "kibi-cli/prolog";
4
- import { resolveWorkspaceRoot } from "../workspace.js";
5
- import { executeTestDependencies, resetTestDependencies, setTestDependencies, } from "./autopilot-test-compat.js";
6
- export function _setAutopilotGenerateDepsForTests(dependencies) {
7
- setTestDependencies(dependencies);
8
- }
9
- export function _resetAutopilotGenerateDepsForTests() {
10
- resetTestDependencies();
11
- }
12
- function isOperationContext(value) {
13
- return (value !== null &&
14
- typeof value === "object" &&
15
- "workspaceRoot" in value &&
16
- "signal" in value);
17
- }
18
- function adaptProlog(prolog) {
19
- return {
20
- query: (goal) => prolog.query(goal),
21
- nextSolution: async () => null,
22
- save: () => prolog.query("kb_save"),
23
- };
24
- }
25
- // implements REQ-mcp-init-kibi-autopilot-v1, REQ-kibi-operation-interface-parity
26
- export async function handleKbAutopilotGenerate(first, second) {
27
- if (isOperationContext(second) && !(first instanceof PrologProcess))
28
- return executeAutopilotGenerate(first, {
29
- ...second,
30
- fs: second.fs ?? nodeFilesystem,
31
- git: second.git ?? nodeGit,
32
- });
33
- if (!(first instanceof PrologProcess) || isOperationContext(second))
34
- throw new TypeError("Invalid autopilot adapter invocation");
35
- const testResult = await executeTestDependencies(first, second);
36
- if (testResult)
37
- return testResult;
38
- const context = {
39
- workspaceRoot: resolveWorkspaceRoot(),
40
- signal: new AbortController().signal,
41
- clock: () => new Date(),
42
- fs: nodeFilesystem,
43
- git: nodeGit,
44
- prolog: adaptProlog(first),
45
- };
46
- return executeAutopilotGenerate(second, context);
47
- }
@@ -1,88 +0,0 @@
1
- import { presentAutopilot, selectAutopilotCandidates, } from "kibi-cli/operations";
2
- import { resolveWorkspaceRoot } from "../workspace.js";
3
- import { activation, candidate, record, signal, } from "./autopilot-test-parsers.js";
4
- let testDependencies;
5
- export function setTestDependencies(dependencies) {
6
- testDependencies = dependencies;
7
- }
8
- export function resetTestDependencies() {
9
- testDependencies = undefined;
10
- }
11
- async function invoke(dependencies, name, values) {
12
- const callable = dependencies[name];
13
- return typeof callable === "function"
14
- ? Reflect.apply(callable, undefined, [...values])
15
- : undefined;
16
- }
17
- export async function executeTestDependencies(prolog, input) {
18
- const dependencies = testDependencies;
19
- if (!dependencies)
20
- return null;
21
- const root = resolveWorkspaceRoot();
22
- const policy = activation(await invoke(dependencies, "resolveActivationPolicy", [root, prolog]));
23
- if (!policy)
24
- return null;
25
- const discovered = record(await invoke(dependencies, "discoverProviderEvidence", [root, policy]));
26
- const rawSummary = record(discovered?.summary);
27
- const summary = {
28
- activationState: policy.activationState,
29
- activationMode: policy.activationMode,
30
- applyBlocked: policy.applyBlocked,
31
- reason: policy.reason,
32
- providersRun: [],
33
- providerCounts: {},
34
- detectedLanguages: [],
35
- detectedTestFrameworks: [],
36
- excludedRoots: [],
37
- truncated: false,
38
- scanWarnings: [],
39
- ...(rawSummary ? Object.fromEntries(Object.entries(rawSummary)) : {}),
40
- };
41
- const rawEntities = await invoke(dependencies, "loadEntities", [prolog, {}]);
42
- const existingIds = new Set(Array.isArray(rawEntities)
43
- ? rawEntities
44
- .map((entry) => record(entry)?.id)
45
- .filter((id) => typeof id === "string")
46
- : []);
47
- const discoveryInput = {
48
- evidence: Array.isArray(discovered?.evidence) ? discovered.evidence : [],
49
- };
50
- const context = { ids: existingIds, workspaceRoot: root };
51
- const minConfidence = Math.max(0.6, Math.min(0.95, input.minConfidence ?? 0.8));
52
- const all = [];
53
- for (const name of [
54
- "buildTypedMarkdownCandidates",
55
- "buildSymbolManifestCandidates",
56
- "buildGenericMarkdownCandidates",
57
- "buildNormativeRequirementCandidates",
58
- "buildProviderEvidenceCandidates",
59
- ]) {
60
- const result = await invoke(dependencies, name, [
61
- discoveryInput,
62
- context,
63
- minConfidence,
64
- ]);
65
- if (Array.isArray(result))
66
- all.push(...result.flatMap((entry) => candidate(entry) ?? []));
67
- }
68
- const rawSignals = await invoke(dependencies, "collectSourceOnlyAuthoringSignals", [discoveryInput, context, minConfidence]);
69
- const signals = Array.isArray(rawSignals)
70
- ? rawSignals.flatMap((entry) => signal(entry) ?? [])
71
- : [];
72
- const selected = selectAutopilotCandidates(all.filter((entry) => entry.confidence >= minConfidence), existingIds, input.entityTypes, Math.max(1, Math.min(200, Math.trunc(input.maxCandidates ?? 50))));
73
- const warning = await invoke(dependencies, "getWorkspaceMigrationWarning", [
74
- root,
75
- ]);
76
- return presentAutopilot({
77
- root,
78
- activation: policy,
79
- discoverySummary: summary,
80
- migrationWarning: typeof warning === "string" ? warning : null,
81
- ...(input.bootstrapContext
82
- ? { bootstrapContext: input.bootstrapContext }
83
- : {}),
84
- candidates: selected.candidates,
85
- sourceOnlySignals: signals,
86
- suppressedCandidates: selected.suppressed,
87
- });
88
- }
@@ -1,120 +0,0 @@
1
- export function record(value) {
2
- return value !== null && typeof value === "object" && !Array.isArray(value)
3
- ? Object.fromEntries(Object.entries(value))
4
- : null;
5
- }
6
- export function candidate(value) {
7
- const item = record(value);
8
- if (!item ||
9
- typeof item.candidateId !== "string" ||
10
- typeof item.entityType !== "string" ||
11
- typeof item.title !== "string" ||
12
- typeof item.sourceKind !== "string" ||
13
- typeof item.sourcePath !== "string" ||
14
- typeof item.confidence !== "number" ||
15
- !Array.isArray(item.applyPlan))
16
- return null;
17
- const relationships = Array.isArray(item.relationships)
18
- ? item.relationships.flatMap((entry) => {
19
- const relation = record(entry);
20
- return relation &&
21
- typeof relation.type === "string" &&
22
- typeof relation.from === "string" &&
23
- typeof relation.to === "string"
24
- ? [{ type: relation.type, from: relation.from, to: relation.to }]
25
- : [];
26
- })
27
- : [];
28
- const applyPlan = item.applyPlan
29
- .map(record)
30
- .filter((entry) => entry !== null);
31
- return {
32
- candidateId: item.candidateId,
33
- entityType: item.entityType,
34
- title: item.title,
35
- sourceKind: item.sourceKind,
36
- sourcePath: item.sourcePath,
37
- confidence: item.confidence,
38
- confidenceBand: typeof item.confidenceBand === "string" ? item.confidenceBand : "medium",
39
- evidence: Array.isArray(item.evidence)
40
- ? item.evidence.filter((entry) => typeof entry === "string")
41
- : [],
42
- relationships,
43
- applyPlan,
44
- };
45
- }
46
- export function signal(value) {
47
- const item = record(value);
48
- if (!item ||
49
- !["req", "scenario", "test"].includes(String(item.kind)) ||
50
- typeof item.title !== "string" ||
51
- typeof item.sourcePath !== "string" ||
52
- typeof item.confidence !== "number")
53
- return null;
54
- const kind = item.kind === "req"
55
- ? "req"
56
- : item.kind === "scenario"
57
- ? "scenario"
58
- : "test";
59
- return {
60
- kind,
61
- title: item.title,
62
- sourcePath: item.sourcePath,
63
- confidence: item.confidence,
64
- evidence: Array.isArray(item.evidence)
65
- ? item.evidence.filter((entry) => typeof entry === "string")
66
- : [],
67
- };
68
- }
69
- export function activation(value) {
70
- const item = record(value);
71
- if (!item ||
72
- typeof item.activationState !== "string" ||
73
- typeof item.activationMode !== "string" ||
74
- typeof item.applyBlocked !== "boolean" ||
75
- typeof item.allowCandidateGeneration !== "boolean" ||
76
- typeof item.reason !== "string")
77
- return null;
78
- const states = new Set([
79
- "root_uninitialized",
80
- "root_partial",
81
- "vendored_only",
82
- "root_active_thin",
83
- "root_active_seeded",
84
- ]);
85
- const modes = new Set([
86
- "cold_start_bootstrap",
87
- "repair_bootstrap",
88
- "attached_thin_handoff",
89
- "attached_seeded_handoff",
90
- "vendored_blocked",
91
- ]);
92
- if (!states.has(item.activationState) || !modes.has(item.activationMode))
93
- return null;
94
- return {
95
- activationState: item.activationState === "root_partial"
96
- ? "root_partial"
97
- : item.activationState === "vendored_only"
98
- ? "vendored_only"
99
- : item.activationState === "root_active_thin"
100
- ? "root_active_thin"
101
- : item.activationState === "root_active_seeded"
102
- ? "root_active_seeded"
103
- : "root_uninitialized",
104
- activationMode: item.activationMode === "repair_bootstrap"
105
- ? "repair_bootstrap"
106
- : item.activationMode === "attached_thin_handoff"
107
- ? "attached_thin_handoff"
108
- : item.activationMode === "attached_seeded_handoff"
109
- ? "attached_seeded_handoff"
110
- : item.activationMode === "vendored_blocked"
111
- ? "vendored_blocked"
112
- : "cold_start_bootstrap",
113
- applyBlocked: item.applyBlocked,
114
- allowCandidateGeneration: item.allowCandidateGeneration,
115
- reason: item.reason,
116
- ...(typeof item.handoffMessage === "string"
117
- ? { handoffMessage: item.handoffMessage }
118
- : {}),
119
- };
120
- }
@@ -1,67 +0,0 @@
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
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU Affero General Public License for more details.
14
-
15
- You should have received a copy of the GNU Affero General Public License
16
- along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
- import { readFile } from "node:fs/promises";
19
- import * as path from "node:path";
20
- import { DEFAULT_CHECKS_CONFIG, RULE_NAMES, } from "kibi-cli/public/check-types";
21
- // implements REQ-002
22
- export async function loadChecksConfig(workspaceRoot) {
23
- const configPath = path.join(workspaceRoot, ".kb", "config.json");
24
- try {
25
- const content = await readFile(configPath, "utf8");
26
- const parsed = JSON.parse(content);
27
- const parsedRules = parsed.checks?.rules;
28
- const normalizedRules = {
29
- ...DEFAULT_CHECKS_CONFIG.rules,
30
- };
31
- if (parsedRules && typeof parsedRules === "object") {
32
- for (const [key, value] of Object.entries(parsedRules)) {
33
- if (typeof value === "boolean") {
34
- normalizedRules[key] = value;
35
- }
36
- }
37
- }
38
- const parsedSt = parsed.checks?.symbolTraceability;
39
- const normalizedSt = { ...DEFAULT_CHECKS_CONFIG.symbolTraceability };
40
- if (parsedSt &&
41
- typeof parsedSt === "object" &&
42
- typeof parsedSt.requireAdr === "boolean") {
43
- normalizedSt.requireAdr = parsedSt.requireAdr;
44
- }
45
- return {
46
- rules: normalizedRules,
47
- symbolTraceability: normalizedSt,
48
- };
49
- }
50
- catch {
51
- return DEFAULT_CHECKS_CONFIG;
52
- }
53
- }
54
- // implements REQ-002
55
- export function getEffectiveRules(configRules, requestedRules) {
56
- if (requestedRules && requestedRules.length > 0) {
57
- return new Set(requestedRules.filter((rule) => RULE_NAMES.has(rule)));
58
- }
59
- const effective = new Set();
60
- for (const rule of RULE_NAMES) {
61
- const enabled = configRules[rule] ?? true;
62
- if (enabled) {
63
- effective.add(rule);
64
- }
65
- }
66
- return effective;
67
- }