kibi-cli 2.3.0 → 2.4.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/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +2 -2
- package/dist/cli-operation-metadata.d.ts +1 -1
- package/dist/cli-operation-metadata.js +1 -1
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +7 -0
- package/dist/commands/merge-driver.d.ts +31 -0
- package/dist/commands/merge-driver.d.ts.map +1 -0
- package/dist/commands/merge-driver.js +268 -0
- package/dist/operations/bootstrap/candidates.js +1 -1
- package/dist/operations/bootstrap/discovery.js +1 -1
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +21 -5
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +3 -0
- package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance.js +7 -1
- package/dist/operations/bootstrap/intent-claims.d.ts +17 -0
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -0
- package/dist/operations/bootstrap/intent-claims.js +95 -0
- package/dist/operations/bootstrap/presentation.d.ts +2 -0
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +60 -1
- package/dist/operations/bootstrap/types.d.ts +28 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/bootstrap/types.js +16 -0
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-refresh.js +4 -1
- package/dist/public/diagnostic-usage.d.ts +14 -0
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +55 -1
- package/dist/public/operations/catalog.d.ts +73 -1
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/specs/bootstrap.d.ts +73 -1
- package/dist/public/operations/specs/bootstrap.d.ts.map +1 -1
- package/dist/public/operations/specs/bootstrap.js +66 -1
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +3 -1
- package/dist/public/skills/kibi-bootstrap/SKILL.md +47 -11
- package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -1
- package/dist/public/skills/kibi-usage/SKILL.md +14 -0
- package/dist/public/skills/kibi-usage/resources/operation-access.md +4 -0
- package/dist/public/telemetry-acceptance.d.ts +8 -0
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +10 -0
- package/package.json +1 -1
- package/src/public/diagnostic-usage.ts +59 -1
- package/src/public/operations/specs/bootstrap.ts +78 -4
- package/src/public/operations/symbol-repair-plan.ts +3 -1
- package/src/public/skills/kibi-bootstrap/SKILL.md +47 -11
- package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -1
- package/src/public/skills/kibi-usage/SKILL.md +14 -0
- package/src/public/skills/kibi-usage/resources/operation-access.md +4 -0
- package/src/public/telemetry-acceptance.ts +9 -0
|
@@ -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
|
|
5
|
-
version: 3.
|
|
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.0
|
|
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.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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.
|
|
30
|
-
|
|
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
|
|
33
|
-
|
|
34
|
-
`kb_apply_plan`; do not reconstruct
|
|
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.
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Bootstrap resource
|
|
2
2
|
|
|
3
|
-
`kb_plan_bootstrap` is read-only and returns `kibi.bootstrap-plan.v1`.
|
|
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
|
|
@@ -56,6 +56,20 @@ printf '%s\n' '{"query":"checkout","limit":10}' | npx --no-install kibi search -
|
|
|
56
56
|
Read `resources/operation-access.md` for the route, result version, effects,
|
|
57
57
|
mutability, and Prolog requirements of each operation.
|
|
58
58
|
|
|
59
|
+
## Working in a git worktree or another directory
|
|
60
|
+
|
|
61
|
+
Kibi MCP servers start in one project and answer from its knowledge base.
|
|
62
|
+
Every Kibi MCP tool accepts `workspaceRoot`: when your working directory is not
|
|
63
|
+
the project the server started in (a git worktree, a sibling checkout), pass
|
|
64
|
+
your working directory as `workspaceRoot` on every call. Host plugins with
|
|
65
|
+
pre-tool hooks add it for you. The server answers from that workspace when it
|
|
66
|
+
is a worktree of the same repository or lies under the client's MCP roots.
|
|
67
|
+
|
|
68
|
+
If a result carries a `workspace_mismatch` diagnostic, the answer came from a
|
|
69
|
+
different workspace than the one you asked for; its `detail.reason` says why.
|
|
70
|
+
Use the CLI from your working directory instead: `npx --no-install kibi ...`
|
|
71
|
+
runs where you are and needs no `workspaceRoot`.
|
|
72
|
+
|
|
59
73
|
## Safe workflow
|
|
60
74
|
|
|
61
75
|
1. Always discover before you mutate: start with `kb_search`, then exact-filter with `kb_query`. Use
|
|
@@ -41,3 +41,7 @@ printf '%s\n' '{"query":"authentication","limit":10}' | npx --no-install kibi se
|
|
|
41
41
|
`_diagnostic_telemetry` is adapter metadata, not business input. Never copy it
|
|
42
42
|
into entity properties. On `committed_with_repairs`, follow typed required
|
|
43
43
|
`nextActions` and do not retry the original mutation.
|
|
44
|
+
|
|
45
|
+
`workspaceRoot` is an MCP-only routing argument naming the directory a call is
|
|
46
|
+
about (see the kibi-usage skill). The CLI JSON routes do not accept it; they
|
|
47
|
+
always run in the current directory.
|
|
@@ -15,6 +15,14 @@ export declare const DEFAULT_TELEMETRY_ACCEPTANCE_POLICY: {
|
|
|
15
15
|
readonly advisorMaxAgeSeconds: number;
|
|
16
16
|
readonly repeatedMutationFailureThreshold: 3;
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Parse Kibi operation events from `.kb/usage.log`.
|
|
20
|
+
*
|
|
21
|
+
* Host plugin hooks share the log and tag their rows `interface: "hook"`.
|
|
22
|
+
* Those rows describe agent activity around Kibi calls, not Kibi operations,
|
|
23
|
+
* so they are dropped here: otherwise a busy editing session would push every
|
|
24
|
+
* operation out of the bounded acceptance window.
|
|
25
|
+
*/
|
|
18
26
|
export declare function parseTelemetryUsageLog(contents: string): TelemetryUsageEvent[];
|
|
19
27
|
export declare function thresholdStatus(actual: number | undefined, operator: ">=" | "<=" | "<", expected: number): TelemetryMetricStatus;
|
|
20
28
|
export declare function analyzeTelemetryAcceptance(events: readonly TelemetryUsageEvent[], now?: Date, policy?: TelemetryAcceptancePolicy): TelemetryAcceptanceReport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-acceptance.d.ts","sourceRoot":"","sources":["../../src/public/telemetry-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAEV,yBAAyB,EACzB,yBAAyB,EAGzB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EACV,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,4BAA4B,EACvC,8BAAuC,CAAC;AAE1C,eAAO,MAAM,mCAAmC;;;;;;;;;;;;CAYF,CAAC;AAgB/C,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"telemetry-acceptance.d.ts","sourceRoot":"","sources":["../../src/public/telemetry-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAEV,yBAAyB,EACzB,yBAAyB,EAGzB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EACV,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,4BAA4B,EACvC,8BAAuC,CAAC;AAE1C,eAAO,MAAM,mCAAmC;;;;;;;;;;;;CAYF,CAAC;AAgB/C;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,mBAAmB,EAAE,CAuBvB;AA0DD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,EAC3B,QAAQ,EAAE,MAAM,GACf,qBAAqB,CAKvB;AA0dD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,mBAAmB,EAAE,EACtC,GAAG,GAAE,IAAiB,EACtB,MAAM,GAAE,yBAA+D,GACtE,yBAAyB,CA6D3B;AA+DD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,SAAS,iBAAiB,EAAE,CA+E9B"}
|
|
@@ -15,6 +15,14 @@ export const DEFAULT_TELEMETRY_ACCEPTANCE_POLICY = {
|
|
|
15
15
|
function isRecord(value) {
|
|
16
16
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse Kibi operation events from `.kb/usage.log`.
|
|
20
|
+
*
|
|
21
|
+
* Host plugin hooks share the log and tag their rows `interface: "hook"`.
|
|
22
|
+
* Those rows describe agent activity around Kibi calls, not Kibi operations,
|
|
23
|
+
* so they are dropped here: otherwise a busy editing session would push every
|
|
24
|
+
* operation out of the bounded acceptance window.
|
|
25
|
+
*/
|
|
18
26
|
export function parseTelemetryUsageLog(contents) {
|
|
19
27
|
const events = [];
|
|
20
28
|
for (const [index, line] of contents.split(/\r?\n/).entries()) {
|
|
@@ -32,6 +40,8 @@ export function parseTelemetryUsageLog(contents) {
|
|
|
32
40
|
if (!isRecord(parsed)) {
|
|
33
41
|
throw new Error(`Failed to parse .kb/usage.log line ${index + 1}: expected object`);
|
|
34
42
|
}
|
|
43
|
+
if (parsed.interface === "hook")
|
|
44
|
+
continue;
|
|
35
45
|
events.push(parsed);
|
|
36
46
|
}
|
|
37
47
|
return events;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
|
|
5
6
|
import {
|
|
6
7
|
appendPayloadCountField,
|
|
@@ -241,6 +242,60 @@ export function deriveDiagnosticUsageFields(
|
|
|
241
242
|
return fields;
|
|
242
243
|
}
|
|
243
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Whether the operator opted into usage telemetry through the environment.
|
|
247
|
+
*
|
|
248
|
+
* `KIBI_DIAGNOSTIC_MODE` is the one opt-in shared with the MCP server, so a
|
|
249
|
+
* single setting covers both peer surfaces. `KIBI_CLI_DIAGNOSTIC_MODE` is the
|
|
250
|
+
* older CLI-only spelling and keeps working.
|
|
251
|
+
*/
|
|
252
|
+
export function diagnosticEnvOptIn(
|
|
253
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
254
|
+
): boolean {
|
|
255
|
+
return ["KIBI_DIAGNOSTIC_MODE", "KIBI_CLI_DIAGNOSTIC_MODE"].some((key) => {
|
|
256
|
+
const value = env[key]?.trim().toLowerCase();
|
|
257
|
+
return value === "1" || value === "true";
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* The host that ran this CLI call. Hosts that launch Kibi set `KIBI_HOST`;
|
|
263
|
+
* Claude Code marks every shell it runs with `CLAUDECODE=1`, which is the
|
|
264
|
+
* only ambient signal trusted here. Anything else stays `unknown`.
|
|
265
|
+
*/
|
|
266
|
+
export function diagnosticCliHost(
|
|
267
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
268
|
+
): string {
|
|
269
|
+
const explicit = env.KIBI_HOST?.trim() || env.KIBI_MCP_HOST?.trim();
|
|
270
|
+
if (explicit) return explicit;
|
|
271
|
+
return env.CLAUDECODE === "1" ? "claude-code" : "unknown";
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let cachedCliPackageVersion: string | null | undefined;
|
|
275
|
+
|
|
276
|
+
function cliPackageVersion(): string | null {
|
|
277
|
+
if (cachedCliPackageVersion !== undefined) return cachedCliPackageVersion;
|
|
278
|
+
cachedCliPackageVersion = null;
|
|
279
|
+
let current = path.dirname(fileURLToPath(import.meta.url));
|
|
280
|
+
while (true) {
|
|
281
|
+
const candidate = path.join(current, "package.json");
|
|
282
|
+
if (existsSync(candidate)) {
|
|
283
|
+
try {
|
|
284
|
+
const parsed: unknown = JSON.parse(readFileSync(candidate, "utf8"));
|
|
285
|
+
if (isRecord(parsed) && typeof parsed.version === "string") {
|
|
286
|
+
cachedCliPackageVersion = parsed.version;
|
|
287
|
+
}
|
|
288
|
+
} catch {
|
|
289
|
+
// An unreadable manifest leaves the version unknown.
|
|
290
|
+
}
|
|
291
|
+
return cachedCliPackageVersion;
|
|
292
|
+
}
|
|
293
|
+
const parent = path.dirname(current);
|
|
294
|
+
if (parent === current) return null;
|
|
295
|
+
current = parent;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
244
299
|
export function appendCliDiagnosticUsage(input: DiagnosticUsageInput): void {
|
|
245
300
|
const finishedAt = input.finishedAt ?? new Date();
|
|
246
301
|
const requestId = input.requestId ?? `cli-${randomUUID()}`;
|
|
@@ -256,6 +311,9 @@ export function appendCliDiagnosticUsage(input: DiagnosticUsageInput): void {
|
|
|
256
311
|
request_id: requestId,
|
|
257
312
|
tool: input.tool,
|
|
258
313
|
interface: "cli_json",
|
|
314
|
+
host: diagnosticCliHost(),
|
|
315
|
+
package_version: cliPackageVersion(),
|
|
316
|
+
workspace_root: input.workspaceRoot,
|
|
259
317
|
telemetry: input.telemetry,
|
|
260
318
|
business_args: input.businessArgs,
|
|
261
319
|
status: input.status,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { executePlanBootstrap } from "../../../operations/bootstrap/generate.js";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
KNOWLEDGE_SOURCE_AUTHORITIES,
|
|
4
|
+
KNOWLEDGE_SOURCE_KINDS,
|
|
5
|
+
type PlanBootstrapArgs,
|
|
6
|
+
type PlanBootstrapResult,
|
|
5
7
|
} from "../../../operations/bootstrap/types.js";
|
|
6
8
|
import type { OperationSpec } from "../types.js";
|
|
7
9
|
|
|
@@ -17,7 +19,7 @@ export const planBootstrapSpec = {
|
|
|
17
19
|
name: "kb_plan_bootstrap",
|
|
18
20
|
cliName: "plan-bootstrap",
|
|
19
21
|
description:
|
|
20
|
-
"Generate a deterministic, snapshot-bound kibi.bootstrap-plan.v1 for repository onboarding. Read-only analysis returns evidence, bounded context questions, exact dependency-ordered actions, a canonical plan hash, and no mutation side effects.",
|
|
22
|
+
"Generate a deterministic, snapshot-bound kibi.bootstrap-plan.v1 for repository onboarding. Read-only analysis of the repository plus any declared knowledge sources and cited intent claims returns evidence, bounded context questions, exact dependency-ordered actions, a canonical plan hash, and no mutation side effects.",
|
|
21
23
|
businessInputSchema: {
|
|
22
24
|
type: "object",
|
|
23
25
|
properties: {
|
|
@@ -86,6 +88,78 @@ export const planBootstrapSpec = {
|
|
|
86
88
|
description:
|
|
87
89
|
"Optional verification commands, documents, or checkpoints to reference in the output.",
|
|
88
90
|
},
|
|
91
|
+
knowledgeSources: {
|
|
92
|
+
type: "array",
|
|
93
|
+
maxItems: 50,
|
|
94
|
+
description:
|
|
95
|
+
"Knowledge sources outside the code that the human confirmed during the bootstrap interview (issue trackers, wikis, specs, decision logs). Kibi never contacts them; the agent reads them through its own connectors and cites them from intentClaims. Bound into the plan hash.",
|
|
96
|
+
items: {
|
|
97
|
+
type: "object",
|
|
98
|
+
required: ["id", "kind", "title", "locator", "authority"],
|
|
99
|
+
additionalProperties: false,
|
|
100
|
+
properties: {
|
|
101
|
+
id: {
|
|
102
|
+
type: "string",
|
|
103
|
+
pattern: "^[a-z0-9][a-z0-9-]*$",
|
|
104
|
+
description:
|
|
105
|
+
"Stable kebab-case handle that intentClaims cite, for example jira-payments.",
|
|
106
|
+
},
|
|
107
|
+
kind: { type: "string", enum: [...KNOWLEDGE_SOURCE_KINDS] },
|
|
108
|
+
title: { type: "string", minLength: 1 },
|
|
109
|
+
locator: {
|
|
110
|
+
type: "string",
|
|
111
|
+
minLength: 1,
|
|
112
|
+
description:
|
|
113
|
+
"Where the source lives: a URL, project key, space name, or repo-relative path.",
|
|
114
|
+
},
|
|
115
|
+
authority: {
|
|
116
|
+
type: "string",
|
|
117
|
+
enum: [...KNOWLEDGE_SOURCE_AUTHORITIES],
|
|
118
|
+
description:
|
|
119
|
+
"The human's call: authoritative claims become higher-confidence candidates, supporting claims lower ones, and stale sources are cited but never produce candidates.",
|
|
120
|
+
},
|
|
121
|
+
connector: {
|
|
122
|
+
type: "string",
|
|
123
|
+
description:
|
|
124
|
+
"Optional name of the MCP server or tool the agent used to read the source.",
|
|
125
|
+
},
|
|
126
|
+
notes: { type: "string" },
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
intentClaims: {
|
|
131
|
+
type: "array",
|
|
132
|
+
maxItems: 200,
|
|
133
|
+
description:
|
|
134
|
+
"Statements of product intent the agent harvested from knowledgeSources, each citing its source. Normative claims the strict modeler can ground become cited req candidates; the rest become explicit authoring follow-ups. Bound into the plan hash.",
|
|
135
|
+
items: {
|
|
136
|
+
type: "object",
|
|
137
|
+
required: ["statement", "sourceId", "reference"],
|
|
138
|
+
additionalProperties: false,
|
|
139
|
+
properties: {
|
|
140
|
+
statement: {
|
|
141
|
+
type: "string",
|
|
142
|
+
minLength: 1,
|
|
143
|
+
description:
|
|
144
|
+
"One normative statement in the source's meaning, for example 'Refunds must not exceed the original charge.'",
|
|
145
|
+
},
|
|
146
|
+
sourceId: {
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "The id of a declared knowledge source.",
|
|
149
|
+
},
|
|
150
|
+
reference: {
|
|
151
|
+
type: "string",
|
|
152
|
+
minLength: 1,
|
|
153
|
+
description:
|
|
154
|
+
"Exact citation inside the source: a ticket key, page URL, or section anchor.",
|
|
155
|
+
},
|
|
156
|
+
excerpt: {
|
|
157
|
+
type: "string",
|
|
158
|
+
description: "Optional short quote supporting the claim.",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
89
163
|
},
|
|
90
164
|
},
|
|
91
165
|
},
|
|
@@ -71,7 +71,9 @@ export async function inspectCoordinateRepairs(
|
|
|
71
71
|
: {}),
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
|
-
const enriched = await enrichSymbolCoordinates(entries, workspaceRoot
|
|
74
|
+
const enriched = await enrichSymbolCoordinates(entries, workspaceRoot, {
|
|
75
|
+
allowPythonDecoratorCoordinates: true,
|
|
76
|
+
});
|
|
75
77
|
return new Map(
|
|
76
78
|
entries.map((entry, index) => {
|
|
77
79
|
const sourceFile = entry.sourceFile ?? null;
|
|
@@ -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
|
|
5
|
-
version: 3.
|
|
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.0
|
|
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.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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.
|
|
30
|
-
|
|
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
|
|
33
|
-
|
|
34
|
-
`kb_apply_plan`; do not reconstruct
|
|
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.
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Bootstrap resource
|
|
2
2
|
|
|
3
|
-
`kb_plan_bootstrap` is read-only and returns `kibi.bootstrap-plan.v1`.
|
|
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
|
|
@@ -56,6 +56,20 @@ printf '%s\n' '{"query":"checkout","limit":10}' | npx --no-install kibi search -
|
|
|
56
56
|
Read `resources/operation-access.md` for the route, result version, effects,
|
|
57
57
|
mutability, and Prolog requirements of each operation.
|
|
58
58
|
|
|
59
|
+
## Working in a git worktree or another directory
|
|
60
|
+
|
|
61
|
+
Kibi MCP servers start in one project and answer from its knowledge base.
|
|
62
|
+
Every Kibi MCP tool accepts `workspaceRoot`: when your working directory is not
|
|
63
|
+
the project the server started in (a git worktree, a sibling checkout), pass
|
|
64
|
+
your working directory as `workspaceRoot` on every call. Host plugins with
|
|
65
|
+
pre-tool hooks add it for you. The server answers from that workspace when it
|
|
66
|
+
is a worktree of the same repository or lies under the client's MCP roots.
|
|
67
|
+
|
|
68
|
+
If a result carries a `workspace_mismatch` diagnostic, the answer came from a
|
|
69
|
+
different workspace than the one you asked for; its `detail.reason` says why.
|
|
70
|
+
Use the CLI from your working directory instead: `npx --no-install kibi ...`
|
|
71
|
+
runs where you are and needs no `workspaceRoot`.
|
|
72
|
+
|
|
59
73
|
## Safe workflow
|
|
60
74
|
|
|
61
75
|
1. Always discover before you mutate: start with `kb_search`, then exact-filter with `kb_query`. Use
|
|
@@ -41,3 +41,7 @@ printf '%s\n' '{"query":"authentication","limit":10}' | npx --no-install kibi se
|
|
|
41
41
|
`_diagnostic_telemetry` is adapter metadata, not business input. Never copy it
|
|
42
42
|
into entity properties. On `committed_with_repairs`, follow typed required
|
|
43
43
|
`nextActions` and do not retry the original mutation.
|
|
44
|
+
|
|
45
|
+
`workspaceRoot` is an MCP-only routing argument naming the directory a call is
|
|
46
|
+
about (see the kibi-usage skill). The CLI JSON routes do not accept it; they
|
|
47
|
+
always run in the current directory.
|
|
@@ -50,6 +50,14 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
50
50
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Parse Kibi operation events from `.kb/usage.log`.
|
|
55
|
+
*
|
|
56
|
+
* Host plugin hooks share the log and tag their rows `interface: "hook"`.
|
|
57
|
+
* Those rows describe agent activity around Kibi calls, not Kibi operations,
|
|
58
|
+
* so they are dropped here: otherwise a busy editing session would push every
|
|
59
|
+
* operation out of the bounded acceptance window.
|
|
60
|
+
*/
|
|
53
61
|
export function parseTelemetryUsageLog(
|
|
54
62
|
contents: string,
|
|
55
63
|
): TelemetryUsageEvent[] {
|
|
@@ -71,6 +79,7 @@ export function parseTelemetryUsageLog(
|
|
|
71
79
|
`Failed to parse .kb/usage.log line ${index + 1}: expected object`,
|
|
72
80
|
);
|
|
73
81
|
}
|
|
82
|
+
if (parsed.interface === "hook") continue;
|
|
74
83
|
events.push(parsed as TelemetryUsageEvent);
|
|
75
84
|
}
|
|
76
85
|
return events;
|