kibi-cursor 2.8.1 → 2.9.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 (38) hide show
  1. package/.cursor-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +50 -0
  3. package/README.md +3 -3
  4. package/agent-plugin/plugin.json +1 -1
  5. package/agent-plugin/skills/kibi-bootstrap/SKILL.md +2 -2
  6. package/agent-plugin/skills/kibi-commit-review/SKILL.md +125 -0
  7. package/agent-plugin/skills/kibi-commit-review/resources/staged-gate.md +98 -0
  8. package/agent-plugin/skills/kibi-decisions/SKILL.md +130 -0
  9. package/agent-plugin/skills/kibi-decisions/resources/decision-records.md +142 -0
  10. package/agent-plugin/skills/kibi-decisions/resources/signoff-views.md +66 -0
  11. package/agent-plugin/skills/kibi-freshness/SKILL.md +2 -0
  12. package/agent-plugin/skills/kibi-traceability/SKILL.md +4 -0
  13. package/agent-plugin/skills/kibi-usage/SKILL.md +20 -15
  14. package/commands/kibi-signoff.md +26 -0
  15. package/dist/.cursor-plugin/plugin.json +1 -1
  16. package/dist/commands/kibi-signoff.md +26 -0
  17. package/dist/hook-runner.js +14 -7
  18. package/dist/skills/.canon-hash.json +9 -4
  19. package/dist/skills/kibi-bootstrap/SKILL.md +2 -2
  20. package/dist/skills/kibi-commit-review/SKILL.md +125 -0
  21. package/dist/skills/kibi-commit-review/resources/staged-gate.md +98 -0
  22. package/dist/skills/kibi-decisions/SKILL.md +130 -0
  23. package/dist/skills/kibi-decisions/resources/decision-records.md +142 -0
  24. package/dist/skills/kibi-decisions/resources/signoff-views.md +66 -0
  25. package/dist/skills/kibi-freshness/SKILL.md +2 -0
  26. package/dist/skills/kibi-traceability/SKILL.md +4 -0
  27. package/dist/skills/kibi-usage/SKILL.md +20 -15
  28. package/package.json +2 -2
  29. package/skills/.canon-hash.json +9 -4
  30. package/skills/kibi-bootstrap/SKILL.md +2 -2
  31. package/skills/kibi-commit-review/SKILL.md +125 -0
  32. package/skills/kibi-commit-review/resources/staged-gate.md +98 -0
  33. package/skills/kibi-decisions/SKILL.md +130 -0
  34. package/skills/kibi-decisions/resources/decision-records.md +142 -0
  35. package/skills/kibi-decisions/resources/signoff-views.md +66 -0
  36. package/skills/kibi-freshness/SKILL.md +2 -0
  37. package/skills/kibi-traceability/SKILL.md +4 -0
  38. package/skills/kibi-usage/SKILL.md +20 -15
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kibi-cursor",
3
3
  "displayName": "Kibi",
4
- "version": "2.8.1",
4
+ "version": "2.9.0",
5
5
  "description": "Optional Cursor adapter for Kibi. Requires project-local kibi-cli, kibi-mcp, and kibi-core (SWI-Prolog is bundled on Linux and macOS) before the bundled MCP server can start.",
6
6
  "license": "AGPL-3.0-or-later",
7
7
  "author": {
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # kibi-cursor
2
2
 
3
+ ## 2.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5e3541e: Two new bundled skills cover the moments where agents most often went wrong with Kibi.
8
+ - `kibi-decisions` loads when a person states a rule ("must", "never", "from now on"), when a hook asks before an edit to code that implements a firm requirement, when the session ends without recording what changed, or when a request conflicts with a recorded rule. It shows how to read a requirement's firmness and origin, record a person's rule as firm with a reference to their words, supersede a rule with a "Why this changed" section, work through `kb_compile_intent` review candidates, and ask before overriding a firm rule.
9
+ - `kibi-commit-review` loads when `kibi check --staged` or the pre-commit hook blocks a commit, or when preparing a commit or pull-request impact review. It explains the per-file `Detail:` lines, how to add the missing symbols and refresh coordinates, which Kibi files to stage, how to prepare an impact-review record with `kb_prepare_impact_review`, and how merge commits and migration renames are judged.
10
+
11
+ `kibi-usage` now points to these skills instead of repeating their detail, and the OpenCode guidance routes rule and commit questions to them.
12
+
13
+ - 180196c: The requirements signoff view now reads well on every host, not only in the hosts that draw Kibi's fenced block.
14
+ - `kibi signoff` prints plain Markdown by default (`--format chat`): headings, quoted statements and lists that render in any chat window, and in messaging tools for agents whose replies go through one (cloud and project sessions). The path of the self-contained page `.kb/briefs/signoff/latest.html` goes to stderr, so an agent can attach or publish it next to the message. `--format md` keeps the fenced block for the OpenCode terminal card, and `KIBI_SIGNOFF_FORMAT` sets the default per host.
15
+ - After a session writes a requirement, the Claude Code, Codex, Cursor and ZCode stop hooks ask once for the signoff view before the work is reported done, unless `kibi signoff` already ran since. A requirement the agent wrote is put to the person through the view, not retold in the agent's words.
16
+ - `/kibi-signoff` is a new command in Claude Code, Cursor and ZCode.
17
+ - The `kibi-decisions` and `kibi-commit-review` skills (1.2.0) say how to show the view on each host, and `kibi-usage` (2.22.0) points to `kibi signoff` when it says to leave `approved_by` to the person. The OpenCode guidance asks for `--format md` so the terminal card still renders.
18
+ - The Claude Code plugin README shows the `.claude/settings.json` snippet that loads the plugin in cloud sessions.
19
+
20
+ ### Patch Changes
21
+
22
+ - 7a3edce: Signoff is now one readable view instead of loose chat text. `kibi signoff` lists the requirements a change adds, rewrites, retires or affects, each quoted with its firmness, origin, scenarios and proof state, and `kibi signoff --questions` numbers the decisions waiting for you next to the recorded rule each one would change or conflict with. The output is a fenced Markdown block for the agent's reply, a self-contained HTML page (`--format html --open`) or JSON, and every run keeps the latest view in `.kb/briefs/signoff/`.
23
+
24
+ Claude Code renders the block as Markdown through a new `MessageDisplay` hook (`KIBI_SIGNOFF_DISPLAY=0` turns it off), OpenCode 2 draws it as a framed card with a `/kibi-signoff` command and a toast, and VS Code offers a **Kibi: Show Requirements Signoff** panel that refreshes as the agent updates it. The `kibi-decisions` and `kibi-commit-review` skills now tell agents when to run it.
25
+
26
+ - 3b43238: The `kibi-decisions` skill now makes a conflict with a recorded rule the verdict of the answer, naming the rule and what it requires before asking the person anything. A stated rule counts as recorded only once its requirement, scenario and `implements` link have actually been written and `kb_check` is clean. After a `kb_compile_intent` plan is applied, the skill makes the new requirement firm with `origin.ref`, gives a must-priority requirement its `specified_by` scenario, and reruns `kb_check` until nothing is reported about it. In the 2026-10-22c SkillOpt campaign the mean rose from 71.33 to 89.5 and hard passes from 16 to 24 of 30. Compile-intent review went from 31.67 to 85.83. One closeout cell dropped from 100 to 90.
27
+ - 8493b53: The `kibi-freshness` and `kibi-traceability` skills now spell out the order of Kibi calls the agent should make and how to finish authorized writes.
28
+ - `kibi-freshness` runs `kb_status`, then `kb_query`, then `kb_check` before it answers. Consistency questions run `kb_query`, `kb_check` and then `kb_coverage`, and any unmodeled clause is reported as incomplete analysis rather than consistent.
29
+ - `kibi-traceability` starts with `kb_search`, then runs `kb_query` and `kb_graph`, and ends with `kb_status`. It grounds scenario feasibility in the queried entities.
30
+ - Both skills treat a passing `dryRun` upsert as validation only. They then perform the real write and read it back before the final checks.
31
+
32
+ In the 2026-10-21 SkillOpt campaign, on the Claude Code host, the freshness mean rose from 68.67 to 96.67 and the traceability mean from 45.67 to 76.67, with no family regressing. The campaign report is `documentation/evaluations/skillopt/reports/2026-10-21-report.md`.
33
+
34
+ - 98254ef: The `kibi-traceability` skill now explains which edge belongs on which symbol when linking coverage. A production symbol keeps its `implements` link and gets `covered_by` to its test, and `executable_for` is reserved for a symbol that stands for the test itself. If a real `kb_upsert` is refused after a dry run passed, the skill repairs the same target instead of working around it with a new entity. In the 2026-10-21b SkillOpt campaign the traceability mean rose from 82.33 to 93.17, and executable coverage from 51.67 to 95.83, with no family regressing.
35
+ - 0a9c431: Two skills pick up SkillOpt-confirmed guidance.
36
+ - `kibi-usage`: before editing a source file Kibi tracks, the skill runs `kb_search` with that file and then reads each governing requirement by id with `kb_query`. It treats the search answer as discovery only. In the 2026-10-22 campaign the mean rose from 85.5 to 88, and intent consultation rose from 47.5 to 60.
37
+ - `kibi-commit-review`: the skill never reads files under `.kb` directly, even read-only. It reads the governing requirement before deciding what a staged change is, and it sends an authorized write exactly once, after a dry run with the same payload. In the 2026-10-22b campaign the mean rose from 44.67 to 72.67, hard passes rose from 7 to 16 of 30, and security failures (all direct `.kb` reads) fell from 8 to 0.
38
+
39
+ - 06fb484: The `kibi-usage` skill now limits the consultation before a source edit that keeps the governing rule to two calls: `kb_search` with the file, then one `kb_query`. Status, check and coverage run after the edit. For a modeling task, the skill spells out the full order: the exact `kb_query` of the target comes before any `kb_model` call, and the task does not stop at a dry run. In the 2026-10-22d SkillOpt campaign, over 42 cells per arm, the mean rose from 89.64 to 95.95 and hard passes from 33 to 38. Intent consultation went from 50 to 100. Two fact-predicate modeling cells lost an argument (100 to 80).
40
+ - Updated dependencies [180196c]
41
+ - kibi-agent-core@0.9.0
42
+
43
+ ## 2.8.2
44
+
45
+ ### Patch Changes
46
+
47
+ - 10c158c: Bootstrap plans now name what to compare for intent claims they cannot model, not only for the claims they plan. A claim left as "Intent claim needs authoring" next to a prose-only current requirement on the same topic gets a `conflict-review:` diagnostic naming that requirement, with an instruction to compare the two when the claim is compiled with `kb_compile_intent` and to report the verdict through `conflictReviews`; the knowledge-source summary and `recommendedActions` count those claims. The pre-commit hook (`kibi check --staged`) now blocks an entity document the commit adds or edits without the body context that full `kibi check` requires (`entity-context-missing`), so a commit can no longer carry an entity `kb_upsert` warned about.
48
+
49
+ Migration: commits that add or edit a requirement, scenario, test, ADR or observation fact without body context are now refused by the hook. Entities that already lacked context at the last commit, and entities the schema 8 migration acknowledged in `.kb/manifest.json`, are not blocked, so migration commits and edits to legacy entities keep passing; add a `## Context` section (requirements) or a prose body to new entities.
50
+
51
+ A `kb_upsert` refused for a coarse symbol link now returns a coded error (`SYMBOL_GRANULARITY_VIOLATION`) in the MCP error envelope and the CLI JSON route, with the same message; before, only a dry run carried a code. The candidates in that message, and in the hook's `symbol_granularity_violation`, list functions, methods and accessors before properties. `kb_status` `schemaStatus.warning` on a legacy KB without a manifest now says to run `kibi migrate --yes`, matching `bootstrap.nextAction` and `kibi doctor`.
52
+
3
53
  ## 2.8.1
4
54
 
5
55
  ### Patch Changes
package/README.md CHANGED
@@ -114,8 +114,8 @@ agent-plugin/
114
114
  ### Discovery-first rules and skills
115
115
 
116
116
  - **Rules**: always-on capability-based workflow guidance plus optional traceability rules for source files.
117
- - **Skills**: `kibi-usage`, `kibi-bootstrap`, `kibi-freshness`, and `kibi-traceability`.
118
- - **Commands**: `/kibi-bootstrap` documents the `kb_plan_bootstrap` bootstrap workflow.
117
+ - **Skills**: `kibi-usage`, `kibi-bootstrap`, `kibi-freshness`, `kibi-traceability`, `kibi-decisions`, and `kibi-commit-review`.
118
+ - **Commands**: `/kibi-bootstrap` documents the `kb_plan_bootstrap` bootstrap workflow, and `/kibi-signoff` shows the requirements signoff view (or the decisions waiting for you) as Markdown in the chat. The [kibi-vscode](../vscode/README.md) extension also installs in Cursor and adds the **Kibi: Show Requirements Signoff** panel.
119
119
 
120
120
  ### Advisory editor hooks
121
121
 
@@ -127,7 +127,7 @@ Hooks are warning-only and never replace MCP/CLI behavior:
127
127
  - **beforeReadFile** and **postToolUse (Read)**: inject source-linked lookup guidance once per path per session, with the same snippet minus the "must keep true" and "Decision" lines.
128
128
  - **postToolUse** (opt-in telemetry): with `KIBI_DIAGNOSTIC_MODE=1`, appends `interface: "hook"` rows with `host: "cursor"` to `.kb/usage.log` for `kb_*` lookups (MCP or `kibi <route>` in Shell) and for edited files with the requirements they implement, keyed by `conversation_id`. `kibi usage-metrics` reads them for the `lookup_before_first_edit` metric. Nothing is written without the variable.
129
129
  - **postToolUse (Write/Edit)**: inject traceability and freshness guidance once per path per session, including `kb_check({sourceFiles:[...], includeImpactDiagnostics:true, includeWorkingTreeDiff:true})` for meaningful source edits.
130
- - **stop**: emits a single freshness or impact-check follow-up when meaningful paths were **edited** during the turn (reads and search do not count). Plan delivery (`CreatePlan`) stays silent unless that same turn also edited source or mutated the KB. When the conversation changed source files and recorded nothing with `kb_upsert`, the follow-up also asks, once, for the decision behind the change to be recorded.
130
+ - **stop**: emits a single freshness or impact-check follow-up when meaningful paths were **edited** during the turn (reads and search do not count). Plan delivery (`CreatePlan`) stays silent unless that same turn also edited source or mutated the KB. When the conversation changed source files and recorded nothing with `kb_upsert`, the follow-up also asks, once, for the decision behind the change to be recorded. When the conversation wrote a requirement and `kibi signoff` has not run since, it asks, once, for the signoff view to be shown before the work is reported done.
131
131
 
132
132
  ### What the plugin does not do
133
133
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "kibi",
4
- "version": "2.8.1",
4
+ "version": "2.9.0",
5
5
  "description": "Repo-local, per-branch, queryable knowledge base. Portable Agent Plugin packaging Kibi's Agent Skills and MCP server.",
6
6
  "author": { "name": "Kibi" },
7
7
  "homepage": "https://looted.github.io/kibi/",
@@ -2,7 +2,7 @@
2
2
  id: kibi-bootstrap
3
3
  name: kibi-bootstrap
4
4
  description: "Use for any Kibi bootstrap or onboarding task: seeding a new or thin knowledge base; reviewing a bootstrap or onboarding plan, preview, or evidence; judging approval readiness or coverage; diagnosing a blocked, partial, or failed bootstrap or its repair; applying an approved bootstrap plan; or asking the human which knowledge sources hold intent. Covers kb_status first, source interview, cited intent claims, read-only kb_plan_bootstrap preview, explicit approval, exact-plan kb_apply_plan, and repair-safe close-out."
5
- version: 3.15.0
5
+ version: 3.16.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -37,7 +37,7 @@ Seed branch-local Kibi knowledge from cited product intent, without creating a p
37
37
  3. **Declare** `bootstrapContext`: `projectSummary`; `knowledgeSources` (id, kind, title, locator, authority, optional connector, optional `component`); `intentClaims` (statement, sourceId, reference, `excerpt` required for `intent` and `observation` claims and optional for `open_question`, optional `kind`, default `intent`, optional `component` overriding the source's, optional `rationale` with the reason the source or the human gave, never invented); `conflicts` (`claimReferences` naming two or more declared claims by sourceId and reference, plus a one-sentence `note`). Only intent claims can become requirements, and they are recorded as the people's rules: `origin.kind: import` with `sourceId:reference` as `origin.ref`, and `firmness: firm`, so a later agent asks before changing one (normative lines from repository Markdown get the same, citing `path#Lline`). Observations, open questions (tagged `review:open-question`) and conflicts (tagged `review:conflict`) become cited observation facts. Generated subject keys take the shape `component.aspect`: name the component each source or claim is about (for example `recorder`; set `component` on the knowledge source, or on a claim to override it; repository Markdown takes its file or directory name), because an intent claim whose subject is neither one word nor already dotted, with no component, is reported in the plan diagnostics and left as an authoring follow-up instead of a malformed key. The aspect is the claim's subject, or its constrained property when the subject is the component itself. An aspect over four words or 40 characters is shortened to a noun phrase (words before `when`, `while`, `for`, `and`, ...; `support_inbox.update_in_real_time_when_a_new_ticket_is_assigned...` becomes `support_inbox.update_in_real_time`) and reported as `subject-key-shortened:` with both keys; two different subjects that shorten alike get a third segment (`editor.discard_a_draft.leaving`) and a `subject-key-disambiguated:` diagnostic; claims about one subject share one subject fact, and a `subject-key-shared:` diagnostic names the key and its sources. Show these diagnostics to the human with the plan so they can rename a key before approval. Kibi never contacts these sources. It binds your declaration into the plan hash.
38
38
  4. **Preview** with `kb_plan_bootstrap` (or `plan-bootstrap --input`), read-only. On `needs_context`, ask only its bounded questions (four at most), then preview again. When `pluginOffers` is non-empty (for example `kibi-plugin-ui` because UI component files exist), ask the human once whether to enable each offered plugin, naming its evidence files. On yes, install it as a dev dependency and add it to `package.json` `kibi.plugins` with the offered capability in `augment` mode; on no, add its name to `kibi.declinedPlugins` so it is not offered again. Either way the human decides; never enable a plugin unasked. For `kibi-plugin-ui`, step 11 also captures the UI pattern inventory (see `kibi-usage` `resources/ui-requirements.md`).
39
39
  5. **Narrow with filters, not caps.** Read the `tldr` and the `Suppressed candidates by reason` diagnostic before individual rows. If the output is too large or mostly tooling or metadata, re-preview with `entityTypes` or declared `sourceOfTruthPaths`. Generic Markdown is off by default once you declare intent claims; set `includeGenericMarkdown: true` only for repository docs the human named. Keep confirmed intent claims: they are never capped and never use `maxCandidates`, which is the separate budget for candidates Kibi discovers (symbols, tests, repository docs). Raise it only when discovered candidates you need are `over_limit`, and never for provenance stubs: a provider entry with no claim (`Source module: …`, repository metadata, layout roots) is planned last as a `meta` fact tagged `bootstrap:provenance-stub`, `discoverySummary.provenanceStubs` counts them apart from `candidatesWithClaims`, and the `over_limit` diagnostic says how many suppressed candidates are stubs; they add no knowledge, so a plan that is mostly stubs needs `entityTypes` or declared sources, not a higher cap. Read the per-source `Knowledge source …` diagnostics: each splits the claims not planned by reason (suppressed by the activation mode, a `suppressedCandidates` row, a `sourceOnlySignals` follow-up). Report them per source and restate them before approval, or carry them to step 11 with their citation.
40
- 6. **Request approval.** Show the complete `structuredContent.plan`, the full hash (never abbreviated), which candidates cite which sources, what was omitted, the open questions and declared conflicts it records for the human to decide, and any claim that contradicts code. If you find an undeclared contradiction now, add it to `conflicts` and preview again rather than resolving it. A `conflict-review:` diagnostic (and `review_against:<id>` evidence on the candidate) names current requirements Kibi could not check a planned claim against because they have no logic: compare each pair yourself and show any contradiction to the human with the plan; they decide whether to drop the claim or keep it and supersede the requirement after apply. With no answer, stop as "awaiting approval." If declined, replan and ask again with the new hash.
40
+ 6. **Request approval.** Show the complete `structuredContent.plan`, the full hash (never abbreviated), which candidates cite which sources, what was omitted, the open questions and declared conflicts it records for the human to decide, and any claim that contradicts code. If you find an undeclared contradiction now, add it to `conflicts` and preview again rather than resolving it. A `conflict-review:` diagnostic (and `review_against:<id>` evidence on the candidate) names current requirements Kibi could not check a planned claim against because they have no logic: compare each pair yourself and show any contradiction to the human with the plan; they decide whether to drop the claim or keep it and supersede the requirement after apply. A claim left for authoring gets the same diagnostic (and `review_against:<id>` evidence on its follow-up): when you compile it with `kb_compile_intent` in step 11, compare it with the named requirements and send your verdicts in `conflictReviews`. With no answer, stop as "awaiting approval." If declined, replan and ask again with the new hash.
41
41
  7. **Pre-apply check.** The plan you send must equal the returned plan: every top-level field, including `suppressedCandidates`, `diagnostics`, `candidates`, `actions`, and `expected`, with every array the same length and order. Never rebuild it from preview fields. If the host cannot pass the exact object, stop and say so.
42
42
  8. **Apply once** with `kb_apply_plan`, the exact plan, and `approvedPlanHash`. The operation owns dependency ordering, source-first writes, sequential mutation, and recovery journaling. A plan with hundreds of actions can run for minutes: pass a `progressToken` (Kibi sends progress after each action) with a client that resets its timeout on progress, or pass `async: true` and poll `kb_job_status` when the host has it. If the apply is cut off, call `kb_apply_plan` with only the `recoveryJournalId` from `kb_status` or the error; it resumes an action interrupted mid-write and reclaims a lock left by a dead process. Never edit or delete `.kb/recovery` files; if recovery is refused, stop and report it.
43
43
  9. **Read back** with `kb_query` and `kb_search` to confirm writes and citations.
@@ -0,0 +1,125 @@
1
+ ---
2
+ id: kibi-commit-review
3
+ name: kibi-commit-review
4
+ description: "Use when kibi check --staged or the Kibi pre-commit hook blocks a commit (kibi_impact_evidence_missing, symbols_manifest_stale, symbol_granularity_violation, symbol-coverage, kibi check-generated drift, Staged impact review failed), or when preparing a commit or pull-request impact review. Covers reading the per-file Detail lines, authoring .kb/symbols.yaml symbol entries through kb_upsert, kibi sync --refresh-symbol-coordinates, staging the tracked Kibi evidence with git add, kb_prepare_impact_review for a staged or diff scope, the kibi signoff requirements summary to show before a commit, and how merge commits and migration renames are judged."
5
+ version: 1.2.0
6
+ kibiCompatibility: ">=1.0.0"
7
+ tags:
8
+ - kibi
9
+ - commit
10
+ - staged-check
11
+ - traceability
12
+ - agent-guidance
13
+ resources:
14
+ - resources/staged-gate.md
15
+ ---
16
+ ## Goal
17
+
18
+ Get a commit through Kibi's staged gate by fixing the cause: the commit
19
+ carries the knowledge its behavior change needs, with current symbol
20
+ coordinates, so the gate passes for the same reason a reviewer would accept it.
21
+
22
+ ## Interface Selection
23
+
24
+ Use the visible approved MCP tools or the trusted project-local CLI as equal
25
+ peer interfaces (CLI JSON: `printf '%s\n' '{}' | npx --no-install kibi status
26
+ --input -`). The gate itself is CLI: `npx --no-install kibi check --staged`
27
+ (add `--format json` for the full evidence). If neither surface is available,
28
+ stop and name the missing capability. Never read or edit `.kb/` files directly.
29
+
30
+ ## When this applies
31
+
32
+ - `kibi check --staged` fails, or the pre-commit hook (`kibi check-generated
33
+ --staged --changed-only`, then `kibi check --staged`) blocks a commit.
34
+ - You are about to commit or open a pull request and want the impact review
35
+ ready first.
36
+
37
+ Never read or open any file under `.kb`, not even read-only with a file tool to look at symbols or coordinates; doing so fails the session even when nothing is written. What you need is already shown elsewhere: the gate's `Detail:` lines, `kb_query` by `sourceFile` or `id`, and `kb_check` with `staged: true` show which symbols and coordinates are covered and which are missing. Before deciding what the change is, always run `kb_search` with `sourceLocations` for each named file and `kb_query` the requirement that governs it, even when the edit looks coordinate-only or seems to contradict a firm rule. When a write is authorized, keep the supplied target and its intended edges, query those targets first, validate the exact payload with `kb_upsert` and `dryRun: true`, then send that same payload with `kb_upsert` and exact-read the result back with `kb_query` before the final checks. Distinct authorized payloads may need several sequential writes, but never resend a write that is already committed, and let typed `nextActions` drive recovery. A passing dry run is validation only, not completion.
38
+
39
+ ## Steps
40
+
41
+ 1. **Read the whole failure.** Each finding names an id, the files, `Detail:`
42
+ lines and a `Suggestion:`. Detail lines are complete per file: how many
43
+ symbols extraction finds in the staged content, how many the staged
44
+ evidence covers, and every symbol missing from `.kb/symbols.yaml` with its
45
+ line. The common ids and their fixes are in `resources/staged-gate.md`.
46
+ 2. **Find the owning knowledge.** `kb_search` with `sourceLocations` for each
47
+ named file (or `kb_query({sourceFile})`), then `kb_query` the requirements,
48
+ scenarios and tests it returns. Run `kb_check` with `sourceFiles`,
49
+ `includeImpactDiagnostics: true` and `staged: true` to see the impact
50
+ findings, including `requirement_statement_unverified` quotes.
51
+ 3. **Decide what the change is.**
52
+ - Behavior changed: update or record the knowledge (a requirement with a
53
+ scenario, or a new clause) through `kb_upsert`. If the change contradicts
54
+ a recorded rule, stop and ask; load `kibi-decisions`.
55
+ - New or uncovered symbols: author a `symbol` entity per listed symbol
56
+ through `kb_upsert` (`title` = the member the extractor names,
57
+ `sourceFile`, `status: active`, `symbol_role: behavioral`, `implements`
58
+ to the requirement, `covered_by` to the test). Then run
59
+ `kibi sync --refresh-symbol-coordinates`.
60
+ - Only coordinates moved: `kibi sync --refresh-symbol-coordinates`.
61
+ - No behavior change (a genuine false positive): see the audited
62
+ no-impact note in `resources/staged-gate.md`; it never covers a real
63
+ behavior change.
64
+ 4. **Stage the evidence.** Kibi authors tracked files but never Git-stages or
65
+ commits them. `git status --short .kb` lists what it wrote; `git add` the
66
+ entity Markdown, `.kb/relationships/` shards, `.kb/symbols.yaml` and
67
+ `.kb/symbol-coordinates.yaml` that belong to this change (use `git add -p`
68
+ when the files hold unrelated edits).
69
+ 5. **Re-run** `kibi check --staged` (and `kibi check-generated --staged` when it
70
+ failed) until it passes. Never bypass the hook (`--no-verify`) unless the
71
+ person says so.
72
+
73
+ ## Requirements signoff
74
+
75
+ Before you ask the person to approve a commit that adds, rewrites or retires
76
+ requirements, or changes code that implements them, show them what they are
77
+ signing off:
78
+
79
+ ```
80
+ npx --no-install kibi signoff # working tree; --staged for the index
81
+ ```
82
+
83
+ It prints Markdown listing each new, changed, affected and retired
84
+ requirement with its statement (before and after for a rewrite), firmness,
85
+ origin, scenarios and proof state. Put it in your reply unchanged (in the
86
+ messaging tool's message when replies go through one), then add one or two
87
+ sentences on why the requirements changed. Offer the full page with
88
+ `kibi signoff --format html --open`, or attach or publish
89
+ `.kb/briefs/signoff/latest.html` when your host can carry a file or a page;
90
+ past 15 requirements the Markdown stops and only the page lists them all.
91
+ Host details: `kibi-decisions`, `resources/signoff-views.md`. `--no-proof` skips the proof lookup, which reads coverage and is slow
92
+ on a large knowledge base. The summary is not an approval: never set
93
+ `approved_by` or `origin.ref` from it.
94
+
95
+ ## Impact reviews
96
+
97
+ When the repository's base commit carries `.kibi/impact-policy.json`, the gate
98
+ also demands a content-bound review record at `.kibi/impact-review.json`
99
+ (`Staged impact review failed: impact_review_invalid ...`). Prepare it with
100
+ `kb_prepare_impact_review` (`scope: {"kind":"staged"}`, or `{"kind":"diff",
101
+ "baseCommit":"<40-hex sha>","headCommit":"<40-hex sha>"}` for a pull
102
+ request). It is read-only: it returns per-file evidence, requirement scopes,
103
+ residual review obligations and an unauthored record template. Draft each
104
+ file's `decision` from what you verified, leave `reviewer.id` for the person
105
+ who reviews, and never present the record as their approval. Field details are
106
+ in `resources/staged-gate.md`.
107
+
108
+ ## Merge commits and migrations
109
+
110
+ During a merge (`MERGE_HEAD` exists), files staged unchanged from a merged
111
+ parent are skipped (`Merge commit: N staged file(s) are taken unchanged ...`);
112
+ only what the merge resolved or edited is judged. A commit that moves
113
+ knowledge into `.kb/` after `kibi migrate` is compared with the old paths
114
+ (`Baseline: HEAD with N staged knowledge rename(s) ...`), and symbol records
115
+ changed only by the migration are not judged as changed. Debt reported there
116
+ came from the branch or the old layout; the full `kibi check` still shows it.
117
+
118
+ ## Typed results and report
119
+
120
+ Parse `kibiProtocol`, `status`, diagnostics and typed `nextActions` on every
121
+ Kibi write. On `committed_with_repairs`, run the repair actions and never
122
+ resend the original write. Report the findings you fixed (id, file, what
123
+ changed), the knowledge you recorded or confirmed still current, the files
124
+ you staged, the final `kibi check --staged` result, and anything left for the
125
+ person (an open rule conflict, an unauthored review decision).
@@ -0,0 +1,98 @@
1
+ # The staged gate
2
+
3
+ Reference for `kibi-commit-review`: what `kibi check --staged` and
4
+ `kibi check-generated --staged` report, how to fix each finding, and the
5
+ impact-review record. The staged check reads blob content from the Git index,
6
+ not the working tree, so a fix counts only once it is staged.
7
+
8
+ ## Reading a finding
9
+
10
+ ```text
11
+ symbols_manifest_stale: .kb/symbol-coordinates.yaml is stale or missing for staged source files: src/billing/refund.ts
12
+ Detail: src/billing/refund.ts — extraction finds 4 symbol(s), evidence covers 3.
13
+ Not in .kb/symbols.yaml: approveRefund (line 42)
14
+ Suggestion: Author .kb/symbols.yaml entries for the uncovered symbols (kibi upsert, with implements/covered_by links), then run kibi sync --refresh-symbol-coordinates && git add .kb/symbol-coordinates.yaml .kb/symbols.yaml, then re-run kibi check --staged.
15
+ ```
16
+
17
+ - Detail lines name every symbol, never a shortened list. `Evidence without a
18
+ matching symbol:` lists manifest entries whose declaration is gone or
19
+ renamed: rename the symbol's `title`, or retire the entry.
20
+ - `--format json` carries the same lists in the diagnostic `evidence`
21
+ (`symbolsManifest[].missing` / `extra`, `uncoveredSymbols[].titles`).
22
+
23
+ ## Blocking findings
24
+
25
+ | Id or message | Cause | Fix |
26
+ | --- | --- | --- |
27
+ | `kibi_impact_evidence_missing` | A staged behavior edit (changed lines in exported or behavior-bearing code, not comments or formatting) has no staged Kibi evidence. Test-only edits do not need it unless they add executable test symbols. | Query the owning knowledge; update it when behavior changed; stage entity Markdown under `.kb/`, authored `.kb/symbols.yaml` entries for the listed symbols, or refreshed `.kb/symbol-coordinates.yaml`. |
28
+ | `symbols_manifest_stale` | Extraction output changed and the staged coordinates (or manifest) do not match it. | Author entries for the listed symbols first, then `kibi sync --refresh-symbol-coordinates`, then stage both manifests. |
29
+ | `symbol_granularity_violation` | A changed behavioral member is owned only by a coarse class or module symbol while a narrower declaration exists. | Add a symbol for the member itself (`title` = `Class.method` or the exported function) with its own links; use `granularity_reason` (`config-artifact`, `module-level-behavior`, `extractor-miss`, `legacy-link`, `test-suite`) only when it is true. |
30
+ | `symbol-coverage` | A changed symbol, or a symbol whose staged manifest entry changed, fails the full-check rule on the staged knowledge. | The symbol `implements` the requirement and is `covered_by` a test that verifies it: through the requirement's scenario (`verified_by` scenario -> test) when it has one, else `verified_by` requirement -> test. A direct requirement -> test link does not count while a scenario exists. The finding's suggestion names the missing link (see `kibi-traceability`). |
31
+ | `kibi_impact_override_missing_rationale` | A `Kibi-Impact: none` declaration has no `Rationale:` line. | Add the rationale, or drop the declaration and stage real evidence. |
32
+ | `entity-context-missing` (staged entity) | A staged requirement, scenario, test, ADR or observation fact has fewer than 12 words of context. | Upsert a sectioned `document.body` (see `kibi-usage`, Entity body contract). |
33
+ | `domain-contradictions`, `scenario-feasibility`, `exception-claim-keys` (staged `.kb/` change) | The staged knowledge introduces a violation the last commit did not have. | Fix the knowledge; a contradiction with a recorded rule goes to the person (`kibi-decisions`). |
34
+ | Proposition-complete ingestion | A staged requirement's semantic inventory is missing or no longer matches its prose. | Re-derive it (`kb_model` analyze with the complete prose) or run `kibi migrate` for drift. |
35
+ | `kibi check-generated --staged` drift | The staged `.kb/symbols.yaml` or `.kb/symbol-coordinates.yaml` differs from a refresh computed from the index. | `kibi sync --refresh-symbol-coordinates`, review the diff, stage only the intended hunks (`git add -p`). |
36
+ | `Staged impact review failed: impact_review_invalid: ...` | The base commit has `.kibi/impact-policy.json` and the staged `.kibi/impact-review.json` is missing, stale or incomplete. The message names the cause (missing review path, stale fingerprint, ...). | Prepare a fresh record (below). Any later staged change makes the fingerprints stale again, so prepare it last. |
37
+
38
+ ## Advisory findings
39
+
40
+ These warn but do not block. Read them; they are often the real review.
41
+
42
+ - `requirement_statement_unverified`: quotes each current requirement the
43
+ changed code implements, with its firmness. Compare the code with the
44
+ statement yourself.
45
+ - `symbol_semantic_review_needed`: the links exist, but check that the linked
46
+ requirement, scenario and test still describe the changed behavior. In a
47
+ file with no linked symbol it says no recorded intent covers the change.
48
+ - `staged_file_ownership_missing` / `staged_file_impact_review_needed`: a
49
+ staged text file (not TypeScript or JavaScript) has no owning requirement,
50
+ or has one and no matching evidence changed.
51
+
52
+ ## Audited no-impact declaration
53
+
54
+ For a false positive or an edit that changes no behavior, Kibi accepts a
55
+ staged Markdown note in a knowledge lane under `.kb/` with the two lines
56
+
57
+ ```text
58
+ Kibi-Impact: none
59
+ Rationale: <why the staged source edits change no behavior>
60
+ ```
61
+
62
+ It never satisfies a genuine behavior change, and it is visible in review.
63
+ Prefer real evidence; use the note only when the person agrees the edit has
64
+ no behavior impact.
65
+
66
+ ## Impact-review record
67
+
68
+ `kb_prepare_impact_review` (CLI `prepare-impact-review --input`) takes only
69
+ `scope`: `{"kind":"staged"}`, or
70
+ `{"kind":"diff","baseCommit":"<sha>","headCommit":"<sha>"}` with full
71
+ lowercase 40- or 64-hex commit ids. It returns `status: ready_for_authoring`,
72
+ the `snapshot` identity, `recordHeaders` (policy, evaluator and scope
73
+ fingerprints), complete per-file evidence in `files`, `requirementScopes`,
74
+ `residualReviewObligations`, and `authorship` with the record schemas and an
75
+ unauthored `recordTemplate`.
76
+
77
+ Fill only the authored fields (`files[].decision`, `files[].analysisReviews`,
78
+ `reviewer.id`, `reviewedAt`) and write the record to `.kibi/impact-review.json`,
79
+ then stage it. A file `decision` is one of:
80
+
81
+ - `{"kind":"impact","requirementIds":[...],"knowledge":{"state":"still_current","rationale":"..."}}`
82
+ - `{"kind":"impact","requirementIds":[...],"knowledge":{"state":"updated","entities":[{"entityId":"...","artifactPath":"...","beforeFingerprint":"<sha256 or null>","afterFingerprint":"<sha256>"}]}}`
83
+ - `{"kind":"no_impact","reason":"...","rationale":"..."}`
84
+ - `{"kind":"not_applicable","policyReason":"...","rationale":"..."}` (only
85
+ where the policy lists the path as not applicable)
86
+
87
+ `reviewer.source` is `self-claimed-local`: the record says who reviewed, it
88
+ does not prove it. Put the person's id there only when they reviewed it.
89
+
90
+ ## Commands
91
+
92
+ ```bash
93
+ npx --no-install kibi check --staged # the gate
94
+ npx --no-install kibi check --staged --format json # with full evidence
95
+ npx --no-install kibi check-generated --staged # manifest drift
96
+ npx --no-install kibi sync --refresh-symbol-coordinates # refresh coordinates
97
+ git status --short .kb # what Kibi wrote
98
+ ```
@@ -0,0 +1,130 @@
1
+ ---
2
+ id: kibi-decisions
3
+ name: kibi-decisions
4
+ description: "Use when the person states a rule or decision (must, never, always, from now on, we decided), when a Kibi hook asks to confirm or warns about an edit to code that implements a firm requirement, when the Stop hook says source files changed but nothing was recorded, when kb_check quotes requirement_statement_unverified, or when a request conflicts with a recorded requirement or ADR. Covers reading firmness and origin, recording a person's rule as firm with origin.ref, superseding with a Why this changed section, the kb_compile_intent unresolved/reviewCandidates/conflictReviews loop, asking before overriding a firm rule, and putting decisions to the person as one numbered kibi signoff --questions view."
5
+ version: 1.2.0
6
+ kibiCompatibility: ">=1.0.0"
7
+ tags:
8
+ - kibi
9
+ - decisions
10
+ - firmness
11
+ - source-first
12
+ - agent-guidance
13
+ resources:
14
+ - resources/decision-records.md
15
+ - resources/signoff-views.md
16
+ ---
17
+ ## Goal
18
+
19
+ Keep the people's rules theirs. A recorded requirement or ADR says how firmly
20
+ it was decided; follow it, record new rules when they are stated, and put any
21
+ conflict with a rule to the person instead of coding around it.
22
+
23
+ ## Interface Selection
24
+
25
+ Use the visible approved MCP tools or the trusted project-local CLI as equal
26
+ peer interfaces (CLI JSON: `printf '%s\n' '{"query":"..."}' | npx --no-install
27
+ kibi search --input -`). Exact routes are in
28
+ `kibi-usage/resources/operation-access.md`. If neither is available, stop and
29
+ name the missing capability. Never read or edit `.kb/` files directly.
30
+
31
+ ## When this applies
32
+
33
+ - The person states a rule: "must", "never", "always", "from now on", "only
34
+ admins may", "we decided X because Y". The prompt hook may have noted it
35
+ ("this request reads as a rule or decision").
36
+ - A hook says an edit changes code that implements a firm requirement: Claude
37
+ Code puts a permission prompt to the person; Codex, Cursor and ZCode tell
38
+ you to ask first unless the edit keeps the rule.
39
+ - The Stop hook says the session changed source files and recorded nothing.
40
+ - `kb_check` reports `requirement_statement_unverified`, quoting a requirement
41
+ the changed code implements, and the code no longer does what it says.
42
+ - A request contradicts a requirement or ADR you found.
43
+
44
+ ## Read the rule first
45
+
46
+ 1. `kb_search` the topic (or `sourceLocations` for the file you are changing),
47
+ then `kb_query({id})` each governing requirement or ADR. Add
48
+ `includeBody: true` to read its prose and context.
49
+ 2. Read `firmness` (always shown, even when inferred) and `origin`:
50
+ - `firm`: a person set it. Follow it; changing it is the person's call.
51
+ A decision with no `firmness` reads as `firm` unless `origin.kind` is
52
+ `agent`.
53
+ - `default`: delegated or an agent's pick. Follow it; supersede it only on
54
+ evidence (a failing test, a measured cost, a constraint it missed).
55
+ - `exploratory`: a flagged guess; revisit it when you touch the area.
56
+ 3. Compare the request with the statement. A request is not evidence against
57
+ a rule.
58
+
59
+ ## Decide
60
+
61
+ - **Request conflicts with a recorded rule (any firmness):** name the rule (id
62
+ and what it requires) and ask whether to change it. Do not implement the
63
+ request and do not supersede the rule until the person says to change that
64
+ rule.
65
+ - **Edit confirmation declined, or nobody could answer:** the requirement
66
+ stands. Say which rule blocked it and ask how to proceed; never reach the
67
+ same change another way (another tool, a shell write, another file).
68
+ - **Edit confirmation allowed:** if the change still keeps the rule, carry on.
69
+ If it changes what the rule says, update the rule in this same change, citing
70
+ the person's words. Clicking allow is not a stated rule: when their request
71
+ did not state the new behavior, ask them to say it before rewriting the rule.
72
+ - **The person states a new rule:** record it with `kb_upsert` as part of the
73
+ change, not after: a requirement with `firmness: firm`, `origin.ref`
74
+ quoting their words and where they said them, a sectioned `document.body`,
75
+ a scenario, and an `implements` link from the code that enforces it. Use
76
+ `kb_compile_intent` first when the rule may touch several requirements.
77
+ - **The person changes a rule:** supersede it (new requirement linked
78
+ `supersedes` new -> old, `firmness: firm` when the old one was firm, a
79
+ `## Why this changed` section of at least 12 words naming their instruction
80
+ and answering the old reasoning, old one `status: closed` in the same
81
+ change). For a wording correction they asked for in place, update it with a
82
+ new `origin.ref` to those words instead.
83
+ - **You only prefer another approach:** a preference is not evidence. Propose
84
+ it; do not supersede.
85
+
86
+ ## Put decisions to the person in one view
87
+
88
+ Whenever you ask the person to confirm rules (a stated rule to record as
89
+ firm, a change to a recorded rule, a conflict with one), render every open
90
+ question as one numbered view instead of scattering them through the chat:
91
+
92
+ ```
93
+ printf '%s\n' '{"questions":[{"title":"Refund approvals","statement":"Refunds above 500 EUR need a finance approval.","quote":"from now on refunds above 500 EUR must be approved by finance","firmness":"firm","governs":["src/refunds/approve.ts"],"question":"Record this as a firm rule?"}]}' | npx --no-install kibi signoff --questions -
94
+ ```
95
+
96
+ Put the printed Markdown in your reply unchanged (or, when your replies go
97
+ through a messaging tool, in that tool's message, with
98
+ `.kb/briefs/signoff/latest.html` attached or published when it can carry a
99
+ page), then wait. In the OpenCode terminal use `--format md` so the fenced
100
+ block renders as a card. Set `id` when a question would change a recorded
101
+ requirement and `conflictsWith` to the recorded rules it conflicts with: the
102
+ view quotes their current text from the knowledge base, so never retype it.
103
+ When the person answers by number, fill each question's `answer` and render
104
+ again until none is open, then record each rule with their words in
105
+ `origin.ref`. Fields and outputs: `resources/signoff-views.md`.
106
+
107
+ Never invent words for `origin.ref`, never set `approved_by` yourself, and
108
+ mark your own picks `default` and guesses `exploratory`. Payload shapes,
109
+ refusal messages and the `kb_compile_intent` review loop are in
110
+ `resources/decision-records.md`.
111
+
112
+ ## Typed results
113
+
114
+ Parse `kibiProtocol`, `status`, diagnostics and typed `nextActions`. A
115
+ refused write (`Entity validation failed: <ID> is a firm decision ...`)
116
+ wrote nothing: do not retry it with the same payload; ask, then supersede or
117
+ cite new words. On `committed_with_repairs` the write stands: run the repair
118
+ actions and never resend the original. Kibi authors tracked files but never
119
+ Git-stages or commits them.
120
+
121
+ Validation is not completion. When a request conflicts with a recorded rule and you stop to ask, first kb_query that rule by id. Then make the conflict itself the verdict of your final answer: name the rule's id and what it requires, keep the answer format the request asked for (including any verdict field), and add your question after that. Asking the person, or showing a questions view, never takes the place of that verdict. When you record a stated rule or apply a kb_compile_intent plan, keep the actual target ids and the intended edges. Discover and kb_query each target, check each payload with kb_upsert and dryRun: true, then send that same payload as the real kb_upsert. Read the result back by exact id before kb_check. A dry run or kb_model output only validates; it records nothing. A stated rule is recorded only once the requirement, its scenario and the enforcing symbol's implements link have actually been written, followed by kb_check. Separate payloads may need several writes in sequence. Never resend a write that already committed, and handle refusals or repairs as the typed-result rules above say. After you apply a plan, make sure the new requirement is firm, with origin.ref quoting the person's words. A must-priority requirement also needs a scenario through specified_by. Leave compatible recorded rules unchanged. Rerun kb_check after each fix until it reports nothing about the new requirement, and only then report the work as done.
122
+
123
+ ## Report
124
+
125
+ End with `kb_check` (and `kb_status` when freshness matters) and say:
126
+
127
+ - which rules you followed, asked about, recorded or changed (ids, firmness);
128
+ - under "Decisions I changed", each supersede and its evidence;
129
+ - the open question, if a conflict is waiting on the person;
130
+ - or, when the session made no decision, one line saying so.