kibi-cursor 2.1.1 → 2.3.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 (45) hide show
  1. package/.cursor-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +106 -0
  3. package/README.md +7 -3
  4. package/agent-plugin/plugin.json +1 -1
  5. package/agent-plugin/skills/kibi-bootstrap/SKILL.md +52 -11
  6. package/agent-plugin/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
  7. package/agent-plugin/skills/kibi-usage/SKILL.md +82 -18
  8. package/agent-plugin/skills/kibi-usage/resources/fact-lanes.md +5 -5
  9. package/agent-plugin/skills/kibi-usage/resources/kb-improvement.md +1 -1
  10. package/agent-plugin/skills/kibi-usage/resources/logic-ir.md +2 -2
  11. package/agent-plugin/skills/kibi-usage/resources/operation-access.md +29 -1
  12. package/agent-plugin/skills/kibi-usage/resources/ui-requirements.md +4 -4
  13. package/agent-plugin/skills/kibi-usage/resources/workflows.md +42 -25
  14. package/bin/launch-kibi-mcp.mjs +4 -1
  15. package/commands/kibi-bootstrap.md +4 -1
  16. package/dist/.cursor-plugin/plugin.json +1 -1
  17. package/dist/bin/launch-kibi-mcp.mjs +4 -1
  18. package/dist/commands/kibi-bootstrap.md +4 -1
  19. package/dist/guidance.d.ts +8 -0
  20. package/dist/guidance.js +13 -0
  21. package/dist/hook-runner.d.ts +12 -0
  22. package/dist/hook-runner.js +98 -2
  23. package/dist/skills/.canon-hash.json +9 -9
  24. package/dist/skills/kibi-bootstrap/SKILL.md +52 -11
  25. package/dist/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
  26. package/dist/skills/kibi-usage/SKILL.md +82 -18
  27. package/dist/skills/kibi-usage/resources/fact-lanes.md +5 -5
  28. package/dist/skills/kibi-usage/resources/kb-improvement.md +1 -1
  29. package/dist/skills/kibi-usage/resources/logic-ir.md +2 -2
  30. package/dist/skills/kibi-usage/resources/operation-access.md +29 -1
  31. package/dist/skills/kibi-usage/resources/ui-requirements.md +4 -4
  32. package/dist/skills/kibi-usage/resources/workflows.md +42 -25
  33. package/dist/source-linked-requirements.d.ts +13 -3
  34. package/dist/source-linked-requirements.js +14 -15
  35. package/package.json +2 -2
  36. package/skills/.canon-hash.json +9 -9
  37. package/skills/kibi-bootstrap/SKILL.md +52 -11
  38. package/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
  39. package/skills/kibi-usage/SKILL.md +82 -18
  40. package/skills/kibi-usage/resources/fact-lanes.md +5 -5
  41. package/skills/kibi-usage/resources/kb-improvement.md +1 -1
  42. package/skills/kibi-usage/resources/logic-ir.md +2 -2
  43. package/skills/kibi-usage/resources/operation-access.md +29 -1
  44. package/skills/kibi-usage/resources/ui-requirements.md +4 -4
  45. package/skills/kibi-usage/resources/workflows.md +42 -25
@@ -3,13 +3,68 @@
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
+ import { appendHookUsageRows, editTraces, hookTelemetryEnabled, kbUsageTrace, readPackageVersion, } from "kibi-agent-core/hook-usage-log";
7
+ import { stampKibiWorkspace } from "kibi-agent-core/kb-mcp-tools";
8
+ import { createEntitySummarizer, editFocus, fileKnowledgeSnippet, implementedRequirementIds, } from "kibi-agent-core/snippets";
6
9
  import { preEditGuidance, readGuidance, writeGuidance } from "./guidance.js";
7
10
  import { parseHookInput, parseStdinJson, readStdin } from "./hook-input.js";
8
11
  import { addDirtyPaths, clearSessionHookState, hasGuidedPath, loadHookState, recordKbMcpTool, recordPlanDelivered, rememberGuidedPath, resolveStateDir, } from "./hook-state.js";
9
12
  import { extractKbMcpToolCall } from "./kb-mcp-tools.js";
10
13
  import { BOOTSTRAP_REMINDER, DIRECT_KB_EDIT_WARNING, interfaceAdvisory, stopFollowupMessage, } from "./messages.js";
11
14
  import { extractExplicitPathFields, isDirectKbPath, isKbFreshnessRelevantPath, isMeaningfulTrackedPath, toRepoRelativePath, } from "./path-policy.js";
12
- import { getSourceLinkedRequirementIds } from "./source-linked-requirements.js";
15
+ import { getSourceLinkedSymbols, } from "./source-linked-requirements.js";
16
+ const MAX_LINKED_REQUIREMENTS = 3;
17
+ /**
18
+ * The shared kibi-agent-core snippet for a file that implements requirements,
19
+ * or undefined so the generic Cursor guidance applies. Test-only links
20
+ * (`covered_by`, `executable_for`) are not requirement ownership here.
21
+ */
22
+ // implements REQ-cursor-kibi-plugin-v1
23
+ function knowledgeFor(workspaceRoot, linked, surface, focus) {
24
+ if (implementedRequirementIds(linked.symbols).length === 0)
25
+ return undefined;
26
+ return fileKnowledgeSnippet({
27
+ relativePath: linked.relativePath,
28
+ symbols: linked.symbols,
29
+ surface,
30
+ focus,
31
+ summarize: createEntitySummarizer(workspaceRoot),
32
+ });
33
+ }
34
+ let cachedPackageVersion;
35
+ function packageVersion() {
36
+ // dist/hook-runner.js sits one level below the package root.
37
+ if (cachedPackageVersion !== undefined)
38
+ return cachedPackageVersion;
39
+ cachedPackageVersion = readPackageVersion(path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json"));
40
+ return cachedPackageVersion;
41
+ }
42
+ /**
43
+ * Opt-in (`KIBI_DIAGNOSTIC_MODE`) hook rows for the lookup-before-first-edit
44
+ * telemetry metric: Kibi lookups through MCP or the CLI, and edits with the
45
+ * requirements the edited files implement.
46
+ */
47
+ // implements REQ-cursor-kibi-plugin-v1
48
+ function recordToolTelemetry(input, workspaceRoot, stateDir, startedAt, env) {
49
+ if (!hookTelemetryEnabled(env))
50
+ return;
51
+ const kbUsage = kbUsageTrace(input.toolName, input.toolInput);
52
+ const traces = kbUsage
53
+ ? [kbUsage]
54
+ : isKnownEditableTool(input.toolName)
55
+ ? editTraces(extractExplicitPathFields(input.toolInput).map((candidate) => toRepoRelativePath(candidate, workspaceRoot)), (relativePath) => implementedRequirementIds(getSourceLinkedSymbols(workspaceRoot, relativePath, stateDir)
56
+ .symbols))
57
+ : [];
58
+ appendHookUsageRows({
59
+ host: "cursor",
60
+ packageVersion: packageVersion(),
61
+ workspaceRoot,
62
+ event: "postToolUse",
63
+ sessionId: input.conversationId,
64
+ hostTool: input.toolName,
65
+ startedAt,
66
+ }, traces, env);
67
+ }
13
68
  const editableTools = new Set([
14
69
  "Edit",
15
70
  "MultiEdit",
@@ -29,6 +84,26 @@ function hasKibiConfig(cwd) {
29
84
  }
30
85
  return fs.existsSync(path.join(cwd, ".kb", "manifest.json"));
31
86
  }
87
+ /**
88
+ * The Kibi workspace that owns `directory`: the nearest ancestor with
89
+ * `.kb/manifest.json`, without crossing a `.git` boundary.
90
+ */
91
+ export function kibiWorkspaceFor(directory) {
92
+ if (!directory)
93
+ return undefined;
94
+ let current = path.resolve(directory);
95
+ for (;;) {
96
+ if (fs.existsSync(path.join(current, ".kb", "manifest.json"))) {
97
+ return current;
98
+ }
99
+ if (fs.existsSync(path.join(current, ".git")))
100
+ return undefined;
101
+ const parent = path.dirname(current);
102
+ if (parent === current)
103
+ return undefined;
104
+ current = parent;
105
+ }
106
+ }
32
107
  function isEditLikeTool(toolName) {
33
108
  return toolName === undefined || editableTools.has(toolName);
34
109
  }
@@ -57,6 +132,7 @@ function resolvePrimaryPath(input) {
57
132
  return explicitPaths[0];
58
133
  }
59
134
  export async function runHook(rawInput, environment = {}) {
135
+ const startedAt = new Date();
60
136
  const input = parseHookInput(rawInput);
61
137
  const pluginData = environment.pluginData ?? process.env.PLUGIN_DATA;
62
138
  const stateDir = resolveStateDir(pluginData, input.conversationId);
@@ -79,6 +155,14 @@ export async function runHook(rawInput, environment = {}) {
79
155
  return advisory ? { additional_context: advisory } : emptyResult();
80
156
  }
81
157
  case "preToolUse": {
158
+ // Name the agent's workspace on every Kibi MCP call so the launcher
159
+ // answers from it, also for agents working in a git worktree. The
160
+ // per-call cwd wins over workspace_roots, which can be the window's
161
+ // folders rather than the agent's checkout.
162
+ const stamped = stampKibiWorkspace(input.toolName, input.toolInput, kibiWorkspaceFor(input.cwd ?? input.workspaceRoots?.[0]));
163
+ if (stamped) {
164
+ return { updated_input: stamped };
165
+ }
82
166
  const explicitPaths = extractExplicitPathFields(input.toolInput);
83
167
  const hasDirectKbEdit = isEditLikeTool(input.toolName) && explicitPaths.some(isDirectKbPath);
84
168
  if (hasDirectKbEdit) {
@@ -96,12 +180,14 @@ export async function runHook(rawInput, environment = {}) {
96
180
  if (hasGuidedPath(state, "pre-edit", relativePath)) {
97
181
  return emptyResult();
98
182
  }
183
+ const linked = getSourceLinkedSymbols(cwd, primaryPath, stateDir);
99
184
  const guidance = preEditGuidance(primaryPath, {
100
185
  cwd,
101
186
  hasKibi: kibiReady,
102
187
  mcpState: state.mcpState,
103
188
  workspaceTrusted,
104
- linkedRequirementIds: getSourceLinkedRequirementIds(cwd, primaryPath, stateDir),
189
+ linkedRequirementIds: implementedRequirementIds(linked.symbols).slice(0, MAX_LINKED_REQUIREMENTS),
190
+ knowledge: knowledgeFor(cwd, linked, "edit", editFocus(path.resolve(cwd, primaryPath), input.toolInput)),
105
191
  });
106
192
  if (!guidance) {
107
193
  return emptyResult();
@@ -124,6 +210,7 @@ export async function runHook(rawInput, environment = {}) {
124
210
  hasKibi: kibiReady,
125
211
  mcpState: state.mcpState,
126
212
  workspaceTrusted,
213
+ knowledge: knowledgeFor(cwd, getSourceLinkedSymbols(cwd, primaryPath, stateDir), "read"),
127
214
  });
128
215
  if (!guidance) {
129
216
  return { permission: "allow" };
@@ -135,6 +222,14 @@ export async function runHook(rawInput, environment = {}) {
135
222
  };
136
223
  }
137
224
  case "postToolUse": {
225
+ if (kibiReady) {
226
+ try {
227
+ recordToolTelemetry(input, cwd, stateDir, startedAt, environment.env);
228
+ }
229
+ catch {
230
+ // Telemetry is best effort and must never change the hook's output.
231
+ }
232
+ }
138
233
  const kbToolCall = extractKbMcpToolCall(input.toolName, input.toolInput);
139
234
  if (kbToolCall) {
140
235
  recordKbMcpTool(stateDir, kbToolCall.toolName, {
@@ -170,6 +265,7 @@ export async function runHook(rawInput, environment = {}) {
170
265
  hasKibi: kibiReady,
171
266
  mcpState: state.mcpState,
172
267
  workspaceTrusted,
268
+ knowledge: knowledgeFor(cwd, getSourceLinkedSymbols(cwd, primaryPath, stateDir), "read"),
173
269
  });
174
270
  if (!guidance) {
175
271
  return emptyResult();
@@ -1,6 +1,6 @@
1
1
  {
2
- "kibi-bootstrap/SKILL.md": "adf7ebe4985ee871e2f1d2d89fd90a20c596fa24460bfec4df525bdcebd3f1d6",
3
- "kibi-bootstrap/resources/bootstrap.md": "e46d5dec74204d0652d4cba7061676c76c2f066bf6d98b073efa9fa44557be80",
2
+ "kibi-bootstrap/SKILL.md": "de228e10d65b428d4ea3e2229fa106407da60521fb8da8387ce6a52242b3a349",
3
+ "kibi-bootstrap/resources/bootstrap.md": "566f44253c7f1258a56dc4f0770128d451ca7757c6901febc5a0e596ed4621e0",
4
4
  "kibi-bootstrap/resources/branch-lifecycle.md": "c854264ce888439140883a3fc636db5e522f020dd27b30a5c1ecc4105b64ed13",
5
5
  "kibi-bootstrap/resources/operation-access.md": "b5a6a59e72d800c376e7fad79132897623c32a0ce152a1e8d73f9628b444db51",
6
6
  "kibi-bootstrap/resources/source-authoring.md": "bf296e62f69474e01797d6cb9469bf624551dca834dd188abb6e705bd96fa586",
@@ -13,15 +13,15 @@
13
13
  "kibi-traceability/resources/operation-access.md": "39f7972ab7f4ae7479e78f7072bb50e8e6c4cdf4f857425f69d2522d37db437c",
14
14
  "kibi-traceability/resources/source-authoring.md": "408c6ee2bef1b84e0194c0538ef929c26a0a617e631b2234247388140dbbdd08",
15
15
  "kibi-traceability/resources/traceability.md": "38c290a0bc71bd1692e115f22694743946e2f69630e134acfd43cee5f613fb88",
16
- "kibi-usage/SKILL.md": "83567f8ead944457719e0254ad6bc1dbedda3a70d04266d2ff041a670336dcc6",
16
+ "kibi-usage/SKILL.md": "251f72f95551c17ac85453024a9e1a78cd3261f62ad13ebea9d2397fdcdad856",
17
17
  "kibi-usage/resources/branch-lifecycle.md": "f1bf359e9826e83c548f3cd0287f8175a62456527b0132b06b3f9f74aa59b7d6",
18
- "kibi-usage/resources/fact-lanes.md": "7ac928cc6b3d189eee6a9cda282918677d5a222cd7ba9b7f324e6553cd3adce8",
19
- "kibi-usage/resources/kb-improvement.md": "17e8b6cf6a0dd43b443a2bfd92e7205d099647a5f1c75fe85413a6cea63d86c6",
20
- "kibi-usage/resources/logic-ir.md": "151675d0ffa813cb9e271084102a3af42de369b8f9a0c64866af0cdc4d924063",
21
- "kibi-usage/resources/operation-access.md": "e2b8c101c6d8b8204aa2907f48091ed97ff1037c287043586a1aa180b1d80209",
18
+ "kibi-usage/resources/fact-lanes.md": "97f5a9aaa331835018312d6684038c2b2a0c383827716fb7c9de3faedbee622b",
19
+ "kibi-usage/resources/kb-improvement.md": "a8408fce27342bdce6415a6718599e53fe00bb33aa1fd3dc42353ec6f61adcd7",
20
+ "kibi-usage/resources/logic-ir.md": "0e8ce8aad07433ab4803ec169149ff6c4e1cf8cf010af18fa6fd67862d9be807",
21
+ "kibi-usage/resources/operation-access.md": "eb455796c066787ffd3fae8db0db1d3e87a84265a57f06ae61e30103cd6aed66",
22
22
  "kibi-usage/resources/proof.md": "7391046fbdeece4858b668360c60755f184af6dfedda9dbc67e2fa4574dbce7f",
23
23
  "kibi-usage/resources/relationship-directions.md": "0fdd67032c2d15299f772845fc4f807eb9435b09507bd87a5911ab33db2f143d",
24
24
  "kibi-usage/resources/source-authoring.md": "80978cea0614484292c7a70d511a3f50458f48ef976bf0675b8bb96abe9d3d36",
25
- "kibi-usage/resources/ui-requirements.md": "b7c31ab1affa3ab25ae5242d8fd8c4d546532d1cafc65d84088375317c1682cc",
26
- "kibi-usage/resources/workflows.md": "52cadc2b1e41af7d0c3129b721d81bb542fefb97113ba3a7c817f7ab7a1f787e"
25
+ "kibi-usage/resources/ui-requirements.md": "ea8e8a4c546acb668963ec354cd31711152c3ca3bc7d3078d2252ff9e2cd44a3",
26
+ "kibi-usage/resources/workflows.md": "bde1cc6f1aaba6cbc1db59cfe23f01986bf95e02e471f2d066ce428d5a81e1f0"
27
27
  }
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  id: kibi-bootstrap
3
3
  name: kibi-bootstrap
4
- description: Bootstrap Kibi from the current Git checkout with exact Git attachment, preview approval, source-first writes, and repair-safe completion.
5
- version: 3.0.0
4
+ description: Bootstrap Kibi from the current Git checkout and the project's existing knowledge sources, with a source interview, cited intent claims, preview approval, source-first writes, and repair-safe completion.
5
+ version: 3.1.1
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -18,20 +18,56 @@ resources:
18
18
  ## Goal
19
19
 
20
20
  Seed branch-local Kibi knowledge for an attached but thin repository without
21
- creating a parallel human-maintained ticket system. Ask at most four bounded
22
- context questions only when the planner says repository evidence is
23
- insufficient; agents own deterministic translation and humans resolve genuine
24
- ambiguity. A seeded repository hands off to the normal Kibi workflow.
21
+ creating a parallel human-maintained ticket system. Code shows what the
22
+ system does, not why; intent usually lives elsewhere (issue trackers, wikis,
23
+ specs, decision logs). Lead a short interview to find those sources, harvest
24
+ cited intent from them, and let the planner consolidate it with repository
25
+ evidence. Agents own reading and translation; humans name the sources,
26
+ judge their authority, and resolve genuine ambiguity. A seeded repository
27
+ hands off to the normal Kibi workflow.
25
28
 
26
29
  ## Interface and preview
27
30
 
28
31
  Use the visible approved MCP surface or the trusted project-local CLI as equal
29
- peer interfaces. If neither is available, stop. Run `kb_plan_bootstrap` (or
30
- `plan-bootstrap --input`) read-only. If it returns `needs_context`, ask only its
32
+ peer interfaces. If neither is available, stop. Interview first, then plan,
33
+ then preview the exact plan for approval.
34
+
35
+ ## Interview first
36
+
37
+ Before planning:
38
+
39
+ 1. Inventory what you can already read: your own MCP connectors and tools
40
+ (issue trackers such as Jira, YouTrack, Linear, or GitHub Issues; wikis such
41
+ as Confluence or Notion; drives and design tools), and in-repo docs, ADRs,
42
+ and specs.
43
+ 2. Ask the human, in one message: what the repository is for; which of those
44
+ sources hold product intent; which are authoritative, supporting, or stale;
45
+ what is missing; and which product areas matter first. If an important
46
+ source has no connector, say which one and suggest connecting it, then
47
+ continue with what is reachable. Never invent access you lack.
48
+ 3. Read the confirmed, non-stale sources through your connectors. Harvest one
49
+ normative statement per behavior, each citing its source and an exact
50
+ reference (ticket key, page URL, or section anchor). Keep the source's
51
+ meaning; do not merge, generalize, or resolve conflicts yourself.
52
+
53
+ Declare the result in `bootstrapContext`: `projectSummary`,
54
+ `knowledgeSources` (id, kind, title, locator, authority, optional connector),
55
+ and `intentClaims` (statement, sourceId, reference, optional excerpt). Kibi
56
+ never contacts those sources; it binds what you declare into the plan hash.
57
+
58
+ ## Plan and approval
59
+
60
+ Run `kb_plan_bootstrap` (or `plan-bootstrap --input`) read-only with that
61
+ context. Grounded authoritative or supporting claims become cited `req`
62
+ candidates; claims the strict modeler cannot ground come back as authoring
63
+ follow-ups; stale sources produce no candidates; undeclared sources are
64
+ reported in diagnostics. If the plan returns `needs_context`, ask only its
31
65
  bounded questions (never more than four), then rerun the planner. Show the
32
- complete returned `structuredContent.plan`, including its canonical hash, and
33
- get explicit approval before any write. Pass that plan object unchanged to
34
- `kb_apply_plan`; do not reconstruct it from preview fields.
66
+ complete returned `structuredContent.plan`, including its canonical hash and
67
+ which candidates cite which sources, and get explicit approval before any
68
+ write. Pass that plan object unchanged to `kb_apply_plan`; do not reconstruct
69
+ it from preview fields. When a claim contradicts the code or another claim,
70
+ put it to the human instead of choosing.
35
71
 
36
72
  For CLI JSON, use the trusted route with `--input` (for example
37
73
  `printf '%s\n' '{}' | kibi status --input -`); MCP and CLI are semantic peers.
@@ -51,6 +87,11 @@ Finish with `kb_check` and `kb_status`.
51
87
  Consume the versioned `kibiProtocol: 1` result envelope: inspect `status`, `effects`,
52
88
  `diagnostics`, and `nextActions`. On `committed_with_repairs`, execute required
53
89
  repair actions and never retry the original mutation.
90
+ On `BOOTSTRAP_PLAN_INVALID`, obtain a corrected preview and approval before
91
+ applying. On `BOOTSTRAP_PLAN_REJECTED`, inspect committed `data.actionResults`
92
+ and re-plan from the current state; the journal is terminal and cannot recover.
93
+ Review `suppressedCandidates`, `sourceOnlySignals`, and diagnostics for invalid,
94
+ ungroundable, unreadable, or over-limit candidates before approving a plan.
54
95
 
55
96
  Kibi may author tracked Markdown/YAML/manifests and relationship shards
56
97
  transactionally, but never Git-stages or commits them. Never read or edit
@@ -1,6 +1,11 @@
1
1
  # Bootstrap resource
2
2
 
3
- `kb_plan_bootstrap` is read-only and returns `kibi.bootstrap-plan.v1`. Review
3
+ `kb_plan_bootstrap` is read-only and returns `kibi.bootstrap-plan.v1`. Declared
4
+ `knowledgeSources` and cited `intentClaims` are part of `declaredContext` and
5
+ therefore of the plan hash; a candidate built from a claim has `sourceKind:
6
+ intent_claim` and evidence rows `intent_claim:<sourceId>:<reference>`,
7
+ `knowledge_source:<kind>:<locator>`, and `source_authority:<authority>`. Its
8
+ requirement keeps the citation as `text_ref: <sourceId>:<reference>`. Review
4
9
  candidate evidence, exact actions, dependencies, expected snapshots, source
5
10
  hashes, bounded questions, diagnostics, and the canonical `planHash` before
6
11
  approving. A preview does not authorize source edits. After approval, pass the
@@ -9,3 +14,9 @@ approved hash; inspect its typed result
9
14
  and follow `nextActions` if it returns `committed_with_repairs`. Direct
10
15
  `kb_upsert` is forbidden for every bootstrap task; never manually replay the
11
16
  plan through it.
17
+
18
+ `BOOTSTRAP_PLAN_INVALID` fails before bootstrap writes or a new journal; request
19
+ a corrected plan. `BOOTSTRAP_PLAN_REJECTED` reports a deterministic failure and
20
+ may include earlier committed `data.actionResults`. Re-plan from the current
21
+ state; its terminal journal cannot recover. Review candidate suppressions and
22
+ cited authoring follow-ups, including any `over_limit` entries, before approval.
@@ -2,7 +2,7 @@
2
2
  id: kibi-usage
3
3
  name: Kibi Usage
4
4
  description: Use Kibi's source-first, exact-Git, migration-aware, proof-aware operations safely across MCP or the trusted local CLI, including partial completion repair.
5
- version: 2.2.0
5
+ version: 2.3.1
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -47,6 +47,18 @@ Use whichever capability is visible and approved. The surfaces are equal peers:
47
47
  Hosts may expose prefixed identifiers such as `kibi_kb_search`,
48
48
  `kibi_kb_query`, and `kibi_kb_upsert`; map them to the canonical MCP names.
49
49
 
50
+ The MCP server keeps its tool list short. Load skills with `kb_skills`
51
+ (`action: "list" | "load" | "read"`; CLI `kibi skill` or `kibi skills
52
+ list|load|read`). Model prose with `kb_model` (`mode: "analyze"` for the
53
+ semantic advisor, `"requirement"` for strict claims, `"predicates"` for
54
+ ontology predicates; CLI `kibi model` or `semantic-advisor`,
55
+ `model-requirement`, `suggest-predicates`). Preflight a write with
56
+ `kb_upsert` plus `dryRun: true` (CLI `upsert` with `"dryRun": true` or
57
+ `validate-upsert`); it validates and writes nothing. Result payloads still name
58
+ catalog operations such as `kb_model_requirement` or `kb_validate_upsert` in
59
+ `recommended_tools` and repair steps; translate them with the list in
60
+ `resources/operation-access.md`.
61
+
50
62
  The CLI JSON route accepts the same business object as MCP:
51
63
 
52
64
  ```bash
@@ -56,16 +68,36 @@ printf '%s\n' '{"query":"checkout","limit":10}' | npx --no-install kibi search -
56
68
  Read `resources/operation-access.md` for the route, result version, effects,
57
69
  mutability, and Prolog requirements of each operation.
58
70
 
71
+ ## Working in a git worktree or another directory
72
+
73
+ Kibi MCP servers start in one project and answer from its knowledge base.
74
+ Every Kibi MCP tool accepts `workspaceRoot`: when your working directory is not
75
+ the project the server started in (a git worktree, a sibling checkout), pass
76
+ your working directory as `workspaceRoot` on every call. Host plugins with
77
+ pre-tool hooks add it for you. The server answers from that workspace when it
78
+ is a worktree of the same repository or lies under the client's MCP roots.
79
+
80
+ If a result carries a `workspace_mismatch` diagnostic, the answer came from a
81
+ different workspace than the one you asked for; its `detail.reason` says why.
82
+ Use the CLI from your working directory instead: `npx --no-install kibi ...`
83
+ runs where you are and needs no `workspaceRoot`.
84
+
59
85
  ## Safe workflow
60
86
 
61
87
  1. Always discover before you mutate: start with `kb_search`, then exact-filter with `kb_query`. Use
62
- `kb_status` when branch or freshness confidence matters. `kb_search` ranks
63
- lexically unless you pass `rankingMode: "intent-v1"`, `semanticFacets`, or
64
- `sourceLocations`; use intent mode with grounded facets for conceptual
65
- questions and before changing a source file, and keep lexical search for
66
- literal identifiers. See `resources/workflows.md` for the mode recipe.
67
- 2. Resolve genuine ambiguity with the human; use semantic advisor/modeling
68
- operations for deterministic interpretation and typed facts.
88
+ `kb_status` when branch or freshness confidence matters. `kb_search`
89
+ defaults to intent ranking, so you can ask it a question ("what governs
90
+ checkout rounding?"); its `data.answer` layer lists the current governing
91
+ requirements with linked facts, scenarios, tests, and ADRs, separates
92
+ superseded requirements, and labels observations as notes. Each governing
93
+ requirement also carries a `verdict` (`contradiction`, `infeasible`,
94
+ `unknown`, or `none`, which is not proof), the `exceptions` that exempt it,
95
+ and the `unknowns` the checks could not decide. Those links and verdicts are
96
+ discovery, not proof. Pass `sourceLocations` before changing a source file,
97
+ and `rankingMode: "legacy"` for literal identifier lookups. See
98
+ `resources/workflows.md` for the mode recipe.
99
+ 2. Resolve genuine ambiguity with the human; use `kb_model` for deterministic
100
+ interpretation and typed facts.
69
101
  3. Create endpoints before relationships and upsert small batches sequentially.
70
102
  Keep the canonical `REQ-* -> SCEN-* -> TEST-*` chain.
71
103
  4. Author tracked Markdown/YAML/manifests and relationship shards through Kibi;
@@ -77,9 +109,9 @@ mutability, and Prolog requirements of each operation.
77
109
  Run `kb_check` with specific rules during iteration and the unfiltered final
78
110
  check. Never fire `kb_upsert` calls in parallel; create or confirm endpoint
79
111
  entities before linking them. The canonical MCP names are `kb_search`,
80
- `kb_query`, `kb_upsert`, and `kb_check`.
112
+ `kb_query`, `kb_model`, `kb_upsert`, and `kb_check`.
81
113
 
82
- For a task that explicitly supplies a malformed concrete mutation payload, locate and read that public request artifact before choosing an entity, preserving its exact entity ID, type, requested changes, and every intended relationship and endpoint. Do not substitute a seeded or convenient entity for the requested target. Start with kb_search, then exact-filter those targets with kb_query, and run kb_validate_upsert on that same payload; validation is not completion. Correct only diagnosed pre-commit errors and revalidate the corrected payload. Once authorized, apply the identical corrected and authorized payload with kb_upsert. If it returns committed_with_repairs, treat the mutation as committed, follow only the required repair actions, and neither retry it nor trigger unrelated semantic backfill for a schema-only repair. Exact-read every changed entity and relationship endpoint with kb_query, then finish with an unfiltered kb_check followed by a final kb_status.
114
+ For a task that explicitly supplies a malformed concrete mutation payload, locate and read that public request artifact before choosing an entity, preserving its exact entity ID, type, requested changes, and every intended relationship and endpoint. Do not substitute a seeded or convenient entity for the requested target. Start with kb_search, then exact-filter those targets with kb_query, and run kb_upsert with dryRun: true on that same payload (CLI: validate-upsert); validation is not completion. Correct only diagnosed pre-commit errors and revalidate the corrected payload. Once authorized, apply the identical corrected and authorized payload with kb_upsert. If it returns committed_with_repairs, treat the mutation as committed, follow only the required repair actions, and neither retry it nor trigger unrelated semantic backfill for a schema-only repair. Exact-read every changed entity and relationship endpoint with kb_query, then finish with an unfiltered kb_check followed by a final kb_status.
83
115
 
84
116
  ## Closeout fields
85
117
 
@@ -110,8 +142,13 @@ migration, worktrees, quarantine, restore, and purge.
110
142
  ## Typed results and recovery
111
143
 
112
144
  Every CLI JSON/MCP result has `kibiProtocol`, `operation`, `resultVersion`,
113
- `status`, `data`, `effects`, `diagnostics`, and typed `nextActions`. Treat
114
- `status: error` as a failed pre-commit operation. If the status is
145
+ `status`, `data`, `effects`, `diagnostics`, and typed `nextActions`.
146
+ `status: error` normally means a failed pre-commit operation. The bootstrap
147
+ error `BOOTSTRAP_PLAN_REJECTED` can follow earlier committed actions: inspect
148
+ `data.actionResults` and `data.applied`, then re-plan from the current state.
149
+ Its journal is terminal; never recover or replay it. `BOOTSTRAP_PLAN_INVALID`
150
+ fails preflight before bootstrap writes or a new journal; obtain a corrected
151
+ plan. If the status is
115
152
  `committed_with_repairs`, the mutation already committed: inspect failed effects,
116
153
  execute each required repair action in order, and never retry the original
117
154
  operation. Record effect failures, followed actions, and unsafe retries in
@@ -124,8 +161,35 @@ Existing entities preserve body bytes when `document.body` is omitted; new
124
161
  requirements default their body to `semantic_text`. Relationship mutations
125
162
  patch canonical shards while preserving unrelated records. Authored entity
126
163
  deletion returns a hash-bound approval plan; requirements normally evolve via a
127
- new entity linked with `supersedes`. Read `resources/source-authoring.md` before
128
- source writes, deletion approval, or recovery.
164
+ new entity linked with `supersedes`; set the replaced requirement to
165
+ `status: closed` in the same change, because `kb_check` blocks an open
166
+ superseded requirement and supersession cycles. Kibi compiles `source` from
167
+ the entity's own file and never writes an authored `source` field, so
168
+ `kb_upsert` cannot change one. When `kb_check` blocks a leftover value
169
+ (`source-path-dangling`), run `kibi migrate`: its automatic
170
+ `source_path_rewrite` action removes the value, or rewrites it when the file
171
+ moved. Never hand-edit `.kb/` for it. Read `resources/source-authoring.md`
172
+ before source writes, deletion approval, or recovery.
173
+
174
+ `kb_apply_plan` applies a whole plan atomically: a failure changes nothing.
175
+ An interrupted plan is settled by the next `kb_apply_plan`, `kb_upsert`, or
176
+ `kb_delete` call, or by `kb_apply_plan` with its `recoveryJournalId`; never
177
+ re-apply the original plan. On a detached HEAD, reads answer from a read-only
178
+ snapshot and writes are refused; check out a branch before mutating.
179
+
180
+ ## Origin and approvals
181
+
182
+ Entities record `origin` (`kind`: `human`, `agent`, `migration`, or `import`,
183
+ plus optional `ref` and `approved_by`). `kb_upsert` records `kind: agent` on
184
+ entities you create; leave `origin.approved_by` to the person who reviews them.
185
+ An exception (a requirement that `exempts` another) exempts nothing until a
186
+ human sets `approved_by`; `kb_check` flags approvals an agent recorded without
187
+ corroboration. Never fill in an approval yourself. Record why a requirement
188
+ exists in `rationale`, or link the ADR that explains it.
189
+
190
+ Conditional clauses ("only when", "only if", "must not ... unless") compile
191
+ into typed `forbid` rules linked by `requires_rule`, not property facts; one
192
+ `kb_model` or `kb_compile_intent` cannot translate stays an `ontology_gap`.
129
193
 
130
194
  ## Semantic and proof guardrails
131
195
 
@@ -143,20 +207,20 @@ to committed `proof/baseline.json` with `kibi proof impact`.
143
207
 
144
208
  ## Predicate Ontology Decision Tree
145
209
 
146
- Call `kb_semantic_advisor` on the complete prose before encoding a clause.
210
+ Call `kb_model` with `mode: "analyze"` on the complete prose before encoding a clause.
147
211
  Set requirement `logic_claims` to exactly the assertive `claim_key` values.
148
- For each relational clause, call `kb_suggest_predicates` with that clause and
212
+ For each relational clause, call `kb_model` with `mode: "predicates"`, that clause, and
149
213
  `existingLogicClaims`. If lexical rank is a false positive, retry with the
150
214
  reviewed `schemaId`. If `binding_status` is `incomplete`, supply
151
215
  `argumentBindings` and retry. Persist `fact_kind: predicate` with the same
152
216
  `claim_key` / `claim_text`, then link `REQ -> fact` with `requires_predicate`.
153
- Use `kb_model_requirement` for strict scalar clauses. Use
217
+ Use `kb_model` with `mode: "requirement"` for strict scalar clauses. Use
154
218
  `fact_kind: observation` only for a true ontology gap. The manifest is not
155
219
  grounding: run `logic-coverage` so each key binds to one ground fact.
156
220
  Relationship direction is fixed, and every `from` in a relationship batch
157
221
  must equal the upserted entity ID.
158
222
 
159
- For conditional relational claims, after the initial `kb_suggest_predicates` and before any `kb_upsert`—including one needed for a missing schema—call read-only `kb_model_requirement` to preview suitable scalar or typed-rule modeling. Treat the preview as advisory: do not apply an irrelevant result or create unrequested facts, and retain an approved ground-predicate plan when it captures the whole claim. Preserve supplied arity, ordered argument roles, polarity, bound values, and one claim key per actual assertion; never split arguments across clauses or schemas or alter values to force uniqueness.
223
+ For conditional relational claims, after the initial `kb_model` predicates call and before any `kb_upsert`—including one needed for a missing schema—call read-only `kb_model` with `mode: "requirement"` to preview suitable scalar or typed-rule modeling. Treat the preview as advisory: do not apply an irrelevant result or create unrequested facts, and retain an approved ground-predicate plan when it captures the whole claim. Preserve supplied arity, ordered argument roles, polarity, bound values, and one claim key per actual assertion; never split arguments across clauses or schemas or alter values to force uniqueness.
160
224
 
161
225
  ## Symbol-First Traceability
162
226
 
@@ -4,7 +4,7 @@ Requirement prose remains the human-readable source. Facts add queryable semanti
4
4
 
5
5
  ## Atomic Claim Coverage
6
6
 
7
- Logical coverage is clause-based, not entity-based. Give `kb_semantic_advisor` the complete requirement body and verify that its `clauses` list contains every atomic obligation. Supply the `clauses` input yourself when automatic splitting would combine or omit obligations. For every normative clause:
7
+ Logical coverage is clause-based, not entity-based. Give `kb_model` (`mode: "analyze"`) the complete requirement body and verify that its `clauses` list contains every atomic obligation. Supply the `clauses` input yourself when automatic splitting would combine or omit obligations. For every normative clause:
8
8
 
9
9
  - preserve the returned stable key as `claim_key` and the exact clause as `claim_text` on its ground fact;
10
10
  - add the key to the exact current `logic_claims` set, removing only stale keys whose propositions no longer exist in the source;
@@ -17,7 +17,7 @@ Example compound prose: “Checkout requires payment authorization before order
17
17
 
18
18
  ## Predicate Lane (Relational Claims)
19
19
 
20
- Call `kb_semantic_advisor`, then `kb_suggest_predicates`. Apply a candidate only when its schema meaning and ordered arguments fit the claim. Use the returned `applyPlan` rather than hand-writing unsupported predicate names, and link the requirement to the predicate fact with `requires_predicate`.
20
+ Call `kb_model` with `mode: "analyze"`, then with `mode: "predicates"`. Apply a candidate only when its schema meaning and ordered arguments fit the claim. Use the returned `applyPlan` rather than hand-writing unsupported predicate names, and link the requirement to the predicate fact with `requires_predicate`.
21
21
 
22
22
  Treat the result as a Prolog-shaped ground term, not executable source: `predicate_name(arg1,...,argN)`. The selected `predicate_schema` fixes the name, arity, argument roles, and order. Store that model through `predicate_name`, `predicate_args`, `canonical_key`, and `polarity`; never interpolate prose into raw Prolog, introduce variables, or use a graph relationship such as `verified_by` as the predicate name.
23
23
 
@@ -84,15 +84,15 @@ The full logical representation of a requirement is the conjunction of all of it
84
84
 
85
85
  Treat the advisor's proposition status as a hard routing decision. `nonlogical`/`subjective` prose is not a logical claim: keep it as one observation when needed and do not add its key to `logic_claims`. `ambiguous` prose stays an ambiguity observation. `ontology_gap` prose stays unresolved unless an approved schema or validated Logic IR is available. Never split a subjective or commentary sentence into synthetic clauses just because it contains conditional words or domain vocabulary.
86
86
 
87
- If authorized input supplies `projectLocalSchemas`, use those signatures as the authority. Create the minimal `predicate_schema` endpoint before lookup, then rerun `kb_suggest_predicates` on the complete relation if the first lookup had no candidate. Apply exactly one ground predicate and one claim key for that relation. For `must not`, `never`, `cannot`, or `forbidden` wording, preserve the positive schema and set `polarity: deny`; do not turn the result into an asserted predicate or invent a negative name. An empty lookup before the declared schema exists is a retry condition, not proof of an ontology gap.
87
+ If authorized input supplies `projectLocalSchemas`, use those signatures as the authority. Create the minimal `predicate_schema` endpoint before lookup, then rerun `kb_model` with `mode: "predicates"` on the complete relation if the first lookup had no candidate. Apply exactly one ground predicate and one claim key for that relation. For `must not`, `never`, `cannot`, or `forbidden` wording, preserve the positive schema and set `polarity: deny`; do not turn the result into an asserted predicate or invent a negative name. An empty lookup before the declared schema exists is a retry condition, not proof of an ontology gap.
88
88
 
89
89
  ## Typed rule lane
90
90
 
91
- Use a validated `kibi.logic.v1` object for a proposition whose meaning includes a condition, exception, obligation, prohibition, permission, quantifier, cardinality bound, or bounded temporal relation. `kb_model_requirement` returns the `rule_schema` and `rule` facts plus a `requires_rule` edge. The rule stores canonical JSON and a deterministic hash; any rendered Prolog is an audit view and is never executed. Reject raw goals, function symbols, cuts, meta-calls, dynamic predicates, I/O, unsafe variables, unstratified negation, and unbounded aggregation. Keep the exact proposition in `claim_text`, its advisor key in `claim_key`, and its byte span in the semantic ledger. Run `rule-safety` and `rule-verifiability` before treating the rule as modeled.
91
+ Use a validated `kibi.logic.v1` object for a proposition whose meaning includes a condition, exception, obligation, prohibition, permission, quantifier, cardinality bound, or bounded temporal relation. `kb_model` with `mode: "requirement"` returns the `rule_schema` and `rule` facts plus a `requires_rule` edge. The rule stores canonical JSON and a deterministic hash; any rendered Prolog is an audit view and is never executed. Reject raw goals, function symbols, cuts, meta-calls, dynamic predicates, I/O, unsafe variables, unstratified negation, and unbounded aggregation. Keep the exact proposition in `claim_text`, its advisor key in `claim_key`, and its byte span in the semantic ledger. Run `rule-safety` and `rule-verifiability` before treating the rule as modeled.
92
92
 
93
93
  ### Strict scalar
94
94
 
95
- Claim: “Sessions expire after at most 30 minutes.” This is a scalar limit, not a predicate. Route it through `kb_model_requirement` to a subject plus `property_value` with `operator: lte`, `value_type: int`, and `value_int: 30`, linked by `constrains` and `requires_property`.
95
+ Claim: “Sessions expire after at most 30 minutes.” This is a scalar limit, not a predicate. Route it through `kb_model` with `mode: "requirement"` to a subject plus `property_value` with `operator: lte`, `value_type: int`, and `value_int: 30`, linked by `constrains` and `requires_property`.
96
96
 
97
97
  ### Ambiguous claim
98
98
 
@@ -19,7 +19,7 @@ are in `resources/fact-lanes.md` and the Predicate-First workflow in
19
19
  | Process or governance note | `meta` | usually `relates_to` |
20
20
  | Runtime or config gate | `flag` | `guards` |
21
21
 
22
- Call `kb_semantic_advisor` on the complete requirement body before encoding a
22
+ Call `kb_model` with `mode: "analyze"` on the complete requirement body before encoding a
23
23
  clause. Apply a predicate only when a returned schema fits; otherwise leave an
24
24
  ontology-gap observation.
25
25
 
@@ -4,12 +4,12 @@ Kibi stores human prose as readable requirement text, but verifiable meaning bel
4
4
 
5
5
  ## Two-pass extraction
6
6
 
7
- 1. Run `kb_semantic_advisor` over the complete text. Supply explicit `clauses` when sentence splitting could hide a condition, exception, definition, descriptive assertion, threshold, quantity, or temporal qualifier.
7
+ 1. Run `kb_model` with `mode: "analyze"` over the complete text. Supply explicit `clauses` when sentence splitting could hide a condition, exception, definition, descriptive assertion, threshold, quantity, or temporal qualifier.
8
8
  2. Audit the returned `propositions` against the original UTF-8 text. Every assertive span must be `modeled`, `ambiguous`, `ontology_gap`, or `missing`; rationale, examples, and subjective commentary are `nonlogical` and remain readable prose.
9
9
  3. For each assertive proposition, submit up to three typed `interpretations` when alternatives are plausible. Kibi compares canonical semantic keys; materially different valid interpretations remain unresolved regardless of confidence.
10
10
  4. Apply only a validated plan, then read back the requirement, rule schema, rule fact, and all relationship targets. Run `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, and `domain-contradictions` before the final unfiltered check.
11
11
 
12
- When a project-local schema names several ordered arguments, those arguments are facets of one relation, not separate propositions. Preserve the advisor claim key for the complete relation and do not manufacture clauses for each argument. Supporting `predicate_schema` facts carry the declared signature only; the ground predicate fact carries the claim provenance. Apply the exact `kb_suggest_predicates`/`kb_model_requirement` plan, reducing a rejected schema payload through `kb_validate_upsert` rather than silently downgrading a fitting declared relation to an observation.
12
+ When a project-local schema names several ordered arguments, those arguments are facets of one relation, not separate propositions. Preserve the advisor claim key for the complete relation and do not manufacture clauses for each argument. Supporting `predicate_schema` facts carry the declared signature only; the ground predicate fact carries the claim provenance. Apply the exact `kb_model` predicates/requirement plan, reducing a rejected schema payload through `kb_upsert` with `dryRun: true` rather than silently downgrading a fitting declared relation to an observation.
13
13
 
14
14
  ## Logic IR shape
15
15
 
@@ -4,11 +4,12 @@ Generated from the public `OperationSpec` catalog. CLI JSON and MCP structured
4
4
  content use the same `KibiResult` envelope (protocol 1); result data is versioned
5
5
  per operation. Effects are authoritative for mutability and adapter annotations.
6
6
 
7
- | MCP tool name | CLI route | Input mode | Mutability | Requires Prolog | Effects | Interface | Result version | Destructive | Retry safety | Open-world | Output schema |
7
+ | Operation | CLI route | Input mode | Mutability | Requires Prolog | Effects | Interface | Result version | Destructive | Retry safety | Open-world | Output schema |
8
8
  |---|---|---|---|---|---|---|---|---|---|---|---|
9
9
  | `kb_skills_list` | `skills-list` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_skills_list.v1 | no | safe | no | yes |
10
10
  | `kb_skills_load` | `skills-load` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_skills_load.v1 | no | safe | no | yes |
11
11
  | `kb_skills_read` | `skills-read` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_skills_read.v1 | no | safe | no | yes |
12
+ | `kb_skills` | `skill` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_skills.v1 | no | safe | no | yes |
12
13
  | `kb_query` | `query` | --input JSON or flags | read | yes | kb-read | peer; capability-selected | kibi.kb_query.v1 | no | safe | no | yes |
13
14
  | `kb_search` | `search` | --input JSON or flags | read | yes | kb-read | peer; capability-selected | kibi.kb_search.v1 | no | safe | no | yes |
14
15
  | `kb_status` | `status` | --input JSON or flags | read | no | kb-read, workspace-read | peer; capability-selected | kibi.kb_status.v1 | no | safe | no | yes |
@@ -18,6 +19,7 @@ per operation. Effects are authoritative for mutability and adapter annotations.
18
19
  | `kb_semantic_advisor` | `semantic-advisor` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_semantic_advisor.v1 | no | safe | no | yes |
19
20
  | `kb_model_requirement` | `model-requirement` | --input JSON | read | yes | kb-read | peer; capability-selected | kibi.kb_model_requirement.v1 | no | safe | no | yes |
20
21
  | `kb_suggest_predicates` | `suggest-predicates` | --input JSON | read | yes | kb-read | peer; capability-selected | kibi.kb_suggest_predicates.v1 | no | safe | no | yes |
22
+ | `kb_model` | `model` | --input JSON | read | yes | kb-read | peer; capability-selected | kibi.kb_model.v1 | no | safe | no | yes |
21
23
  | `kb_plan_bootstrap` | `plan-bootstrap` | --input JSON | read | no | workspace-read | peer; capability-selected | kibi.kb_plan_bootstrap.v1 | no | safe | no | yes |
22
24
  | `kb_validate_upsert` | `validate-upsert` | --input JSON | read | yes | kb-read | peer; capability-selected | kibi.kb_validate_upsert.v1 | no | safe | no | yes |
23
25
  | `kb_upsert` | `upsert` | --input JSON | write | yes | kb-write, workspace-write | peer; capability-selected | kibi.kb_upsert.v1 | yes | unsafe | no | yes |
@@ -29,6 +31,28 @@ per operation. Effects are authoritative for mutability and adapter annotations.
29
31
  | `kb_apply_plan` | `apply-plan` | --input JSON | write | yes | kb-read, kb-write, workspace-read, workspace-write | peer; capability-selected | kibi.kb_apply_plan.v1 | yes | unsafe | no | yes |
30
32
  | `kb_ingest_proof` | `ingest-proof` | --input JSON | write | yes | kb-read, kb-write, workspace-read | peer; capability-selected | kibi.kb_ingest_proof.v1 | yes | unsafe | no | yes |
31
33
 
34
+ ## MCP tools versus catalog operations
35
+
36
+ The MCP server registers 16 tools. Most carry their catalog operation name; the
37
+ operations below are reached through a consolidated MCP call instead, while the
38
+ CLI keeps their dedicated routes. Result payloads (for example
39
+ `recommended_tools`, `suggested_next_tool`, or repair-plan steps) still name
40
+ catalog operations, so translate them with this list.
41
+
42
+ - `kb_skills_list`: MCP `kb_skills` with `action: "list"`; CLI `kibi skills list` (`skills-list`)
43
+ - `kb_skills_load`: MCP `kb_skills` with `action: "load"`; CLI `kibi skills load` (`skills-load`)
44
+ - `kb_skills_read`: MCP `kb_skills` with `action: "read"`; CLI `kibi skills read` (`skills-read`)
45
+ - `kb_semantic_advisor`: MCP `kb_model` with `mode: "analyze"`; CLI `kibi semantic-advisor` (`semantic-advisor`)
46
+ - `kb_model_requirement`: MCP `kb_model` with `mode: "requirement"`; CLI `kibi model-requirement` (`model-requirement`)
47
+ - `kb_suggest_predicates`: MCP `kb_model` with `mode: "predicates"`; CLI `kibi suggest-predicates` (`suggest-predicates`)
48
+ - `kb_validate_upsert`: MCP `kb_upsert` with `dryRun: true`; CLI `kibi validate-upsert` (`validate-upsert`)
49
+ - `kb_sparql_remote`: MCP `kb_sparql_remote`, registered only when `KIBI_MCP_OPTIONAL_TOOLS` names it; CLI `kibi sparql-remote` (`sparql-remote`)
50
+
51
+ The consolidated tools also have their own CLI routes: `kibi skill` for
52
+ `kb_skills` and `kibi model` for `kb_model`. `kb_job_status` is likewise
53
+ opt-in through `KIBI_MCP_OPTIONAL_TOOLS`; without it, `kb_check` with
54
+ `async: true` runs synchronously.
55
+
32
56
  ## JSON execution recipe
33
57
 
34
58
  Use a trusted project-local, non-installing runner. Stdin contains one UTF-8 JSON
@@ -41,3 +65,7 @@ printf '%s\n' '{"query":"authentication","limit":10}' | npx --no-install kibi se
41
65
  `_diagnostic_telemetry` is adapter metadata, not business input. Never copy it
42
66
  into entity properties. On `committed_with_repairs`, follow typed required
43
67
  `nextActions` and do not retry the original mutation.
68
+
69
+ `workspaceRoot` is an MCP-only routing argument naming the directory a call is
70
+ about (see the kibi-usage skill). The CLI JSON routes do not accept it; they
71
+ always run in the current directory.
@@ -82,14 +82,14 @@ diagnostics (`symbol_semantic_review_needed`).
82
82
 
83
83
  ## Workflow
84
84
 
85
- 1. `kb_semantic_advisor` on the full description; audit or supply `clauses`.
86
- 2. Relational clauses: `kb_suggest_predicates`, apply the predicate plan and
85
+ 1. `kb_model` (`mode: "analyze"`) on the full description; audit or supply `clauses`.
86
+ 2. Relational clauses: `kb_model` (`mode: "predicates"`), apply the predicate plan and
87
87
  `requires_predicate`.
88
- 3. Scalar placement/alignment/order clauses: `kb_model_requirement`, apply the strict
88
+ 3. Scalar placement/alignment/order clauses: `kb_model` (`mode: "requirement"`), apply the strict
89
89
  subject/property plan and `constrains` / `requires_property`.
90
90
  4. Preserve `claim_key` / `claim_text`; merge every key into the requirement
91
91
  `logic_claims` manifest.
92
- 5. `kb_validate_upsert`, create endpoints first, then sequential `kb_upsert`.
92
+ 5. `kb_upsert` with `dryRun: true`, create endpoints first, then sequential `kb_upsert`.
93
93
  6. `kb_check` with `logic-coverage`, `predicate-verifiability`, `domain-contradictions`,
94
94
  then a final unfiltered `kb_check`.
95
95