kibi-cli 2.13.0 → 2.15.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 (114) hide show
  1. package/dist/engine.d.ts.map +1 -1
  2. package/dist/engine.js +5 -2
  3. package/dist/intent-search.d.ts.map +1 -1
  4. package/dist/intent-search.js +16 -4
  5. package/dist/operations/bootstrap/candidate-helpers.d.ts +5 -0
  6. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  7. package/dist/operations/bootstrap/candidate-helpers.js +8 -0
  8. package/dist/operations/bootstrap/candidates.d.ts +12 -1
  9. package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
  10. package/dist/operations/bootstrap/candidates.js +41 -7
  11. package/dist/operations/bootstrap/discovery-evidence.d.ts.map +1 -1
  12. package/dist/operations/bootstrap/discovery-evidence.js +8 -0
  13. package/dist/operations/bootstrap/discovery.d.ts.map +1 -1
  14. package/dist/operations/bootstrap/discovery.js +6 -1
  15. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  16. package/dist/operations/bootstrap/generate.js +18 -5
  17. package/dist/operations/bootstrap/guidance-actions.d.ts +2 -1
  18. package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
  19. package/dist/operations/bootstrap/guidance-actions.js +10 -1
  20. package/dist/operations/bootstrap/guidance.d.ts +2 -0
  21. package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
  22. package/dist/operations/bootstrap/guidance.js +1 -1
  23. package/dist/operations/bootstrap/plugin-offers.d.ts +16 -0
  24. package/dist/operations/bootstrap/plugin-offers.d.ts.map +1 -0
  25. package/dist/operations/bootstrap/plugin-offers.js +66 -0
  26. package/dist/operations/bootstrap/presentation.d.ts +2 -0
  27. package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
  28. package/dist/operations/bootstrap/presentation.js +19 -5
  29. package/dist/operations/bootstrap/types.d.ts +8 -0
  30. package/dist/operations/bootstrap/types.d.ts.map +1 -1
  31. package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -1
  32. package/dist/operations/modeling/predicate-applicability.js +27 -1
  33. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  34. package/dist/operations/modeling/predicate-applyplan.js +9 -5
  35. package/dist/operations/modeling/predicate-binding-hints.d.ts +10 -0
  36. package/dist/operations/modeling/predicate-binding-hints.d.ts.map +1 -1
  37. package/dist/operations/modeling/predicate-binding-hints.js +112 -16
  38. package/dist/operations/modeling/predicate-bindings.d.ts +16 -0
  39. package/dist/operations/modeling/predicate-bindings.d.ts.map +1 -1
  40. package/dist/operations/modeling/predicate-bindings.js +40 -1
  41. package/dist/operations/modeling/predicate-catalog-5.d.ts +2 -2
  42. package/dist/operations/modeling/predicate-catalog-5.js +2 -2
  43. package/dist/operations/modeling/predicate-catalog-6.d.ts +9 -0
  44. package/dist/operations/modeling/predicate-catalog-6.d.ts.map +1 -0
  45. package/dist/operations/modeling/predicate-catalog-6.js +106 -0
  46. package/dist/operations/modeling/predicate-catalog.d.ts.map +1 -1
  47. package/dist/operations/modeling/predicate-catalog.js +2 -0
  48. package/dist/operations/modeling/predicate-usage-hints-4.d.ts.map +1 -1
  49. package/dist/operations/modeling/predicate-usage-hints-4.js +32 -0
  50. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  51. package/dist/operations/modeling/suggest-predicates.js +48 -17
  52. package/dist/operations/mutation/contradictions.d.ts +8 -0
  53. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  54. package/dist/operations/mutation/contradictions.js +13 -0
  55. package/dist/operations/mutation/source-authoring.d.ts +13 -0
  56. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  57. package/dist/operations/mutation/source-authoring.js +70 -2
  58. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  59. package/dist/operations/mutation/upsert.js +9 -3
  60. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  61. package/dist/operations/mutation/validate-upsert.js +30 -4
  62. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  63. package/dist/operations/semantic-advisor/ingestion-boundary.js +20 -1
  64. package/dist/plugins/approved-source-analyzers.generated.d.ts +5 -5
  65. package/dist/plugins/approved-source-analyzers.generated.js +5 -5
  66. package/dist/plugins/check-policies.d.ts +24 -0
  67. package/dist/plugins/check-policies.d.ts.map +1 -0
  68. package/dist/plugins/check-policies.js +73 -0
  69. package/dist/plugins/registry.d.ts.map +1 -1
  70. package/dist/plugins/registry.js +10 -1
  71. package/dist/prolog.d.ts.map +1 -1
  72. package/dist/prolog.js +8 -1
  73. package/dist/provenance-stub.d.ts +15 -0
  74. package/dist/provenance-stub.d.ts.map +1 -0
  75. package/dist/provenance-stub.js +30 -0
  76. package/dist/public/operations/catalog.d.ts +1 -1
  77. package/dist/public/operations/check-executor.d.ts.map +1 -1
  78. package/dist/public/operations/check-executor.js +3 -0
  79. package/dist/public/operations/check-policy-rules.d.ts +49 -0
  80. package/dist/public/operations/check-policy-rules.d.ts.map +1 -0
  81. package/dist/public/operations/check-policy-rules.js +305 -0
  82. package/dist/public/operations/contracts.d.ts.map +1 -1
  83. package/dist/public/operations/contracts.js +5 -0
  84. package/dist/public/operations/source-relationship-parity.d.ts.map +1 -1
  85. package/dist/public/operations/source-relationship-parity.js +16 -1
  86. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  87. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  88. package/dist/public/operations/specs/check-rules.generated.js +3 -1
  89. package/dist/public/operations/specs/check.d.ts +1 -1
  90. package/dist/public/operations/specs/reporting.d.ts +9 -0
  91. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  92. package/dist/public/operations/specs/reporting.js +6 -2
  93. package/dist/public/skills/kibi-bootstrap/SKILL.md +3 -3
  94. package/dist/public/skills/kibi-usage/SKILL.md +81 -5
  95. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +42 -3
  96. package/dist/report/html-report.d.ts.map +1 -1
  97. package/dist/report/html-report.js +13 -2
  98. package/dist/search-answer.d.ts.map +1 -1
  99. package/dist/search-answer.js +7 -0
  100. package/dist/search-ranking.d.ts.map +1 -1
  101. package/dist/search-ranking.js +9 -1
  102. package/dist/utils/rule-registry.generated.d.ts +10 -0
  103. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  104. package/dist/utils/rule-registry.generated.js +12 -0
  105. package/package.json +4 -4
  106. package/src/public/operations/check-executor.ts +7 -0
  107. package/src/public/operations/check-policy-rules.ts +462 -0
  108. package/src/public/operations/contracts.ts +6 -0
  109. package/src/public/operations/source-relationship-parity.ts +17 -2
  110. package/src/public/operations/specs/check-rules.generated.ts +3 -1
  111. package/src/public/operations/specs/reporting.ts +13 -2
  112. package/src/public/skills/kibi-bootstrap/SKILL.md +3 -3
  113. package/src/public/skills/kibi-usage/SKILL.md +81 -5
  114. package/src/public/skills/kibi-usage/resources/ui-requirements.md +42 -3
@@ -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.9.0
5
+ version: 2.11.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -209,6 +209,71 @@ An interrupted plan is settled by the next `kb_apply_plan`, `kb_upsert`, or
209
209
  re-apply the original plan. On a detached HEAD, reads answer from a read-only
210
210
  snapshot and writes are refused; check out a branch before mutating.
211
211
 
212
+ ## Second-agent edits
213
+
214
+ Recipes for an agent changing a knowledge base another agent or person
215
+ authored. Each one is the order the write path accepts.
216
+
217
+ 1. **New strict requirement with a predicate grounding.** `kb_model` mode
218
+ `analyze` with the complete prose; copy `inventory_contract` into
219
+ `semantic_inventory_version`, `semantic_source_field` and
220
+ `semantic_source_hash`, the prose into `semantic_text`, `propositions`
221
+ into `semantic_inventory` and the assertive `claim_key`s into
222
+ `logic_claims`. `kb_model` mode `predicates` per clause; `kb_upsert` the
223
+ returned `applyPlan` fact first (it carries the clause's `claim_key`).
224
+ Then write the requirement in one `kb_upsert` with the ledger (that
225
+ clause `status: modeled`), a sectioned `document.body`, `constrains` to
226
+ the subject fact and `requires_predicate` to `relationshipTarget`. A
227
+ `modeled` entry and its grounding link must arrive in the same write
228
+ (`modeled semantic_inventory entries (n) must equal logical grounding
229
+ relationships (m)`); a clause not grounded yet stays `status: missing`
230
+ and is switched to `modeled` together with its link later. A partial
231
+ `{title, status}` upsert (plus relationships) is enough only for an
232
+ existing entity, whose stored ledger Kibi keeps.
233
+ 2. **Changing the text of a grounded requirement.** New prose means new
234
+ claim keys, so a bare rewrite is refused with `modeled proposition
235
+ claim_keys must match logical grounding target claim_keys exactly`.
236
+ Prefer supersession for a change of meaning: analyze the new prose,
237
+ write its facts, write the new requirement (`-v2`) with `supersedes` to
238
+ the old one, then set the old one to `status: closed`. For a wording fix
239
+ that keeps the meaning, re-ground in place: analyze the new prose,
240
+ `kb_upsert` each grounding fact with the new `claim_key`/`claim_text`
241
+ (same fact id), then `kb_upsert` the requirement with the new ledger,
242
+ `semantic_text` and the same grounding links in one write. The requirement
243
+ write checks the targets' stored claim keys, so the facts go first;
244
+ between the two writes `kb_check` reports the requirement until the
245
+ second lands.
246
+ 3. **Deleting authored entities.** `kb_delete` on an authored entity that
247
+ is not a requirement (scenario, test, fact, ADR, …) returns a hash-bound
248
+ `kibi.entity-deletion-plan.v1` in `deletionPlan`; apply it unchanged with
249
+ `kb_apply_plan` (`plan` plus `approvedPlanHash: plan.planHash`). For an
250
+ authored requirement the plan carries `supersessionRequired: true` and
251
+ `kb_apply_plan` refuses it (`REQUIREMENT_SUPERSESSION_REQUIRED`): Kibi
252
+ never deletes an authored requirement. Evolve it instead with a new
253
+ requirement linked by `supersedes` and close the old one, or, for an
254
+ agent-origin requirement nobody approved and nothing links to, upsert it
255
+ with `status: closed` (keep its `title`); it stays on disk as history. A
256
+ person may remove the file in Git and run `kibi sync`; agents do not edit
257
+ `.kb/` directly.
258
+ 4. **After a commit-time refusal** (`Contradiction detected …
259
+ (stage=contradiction_check)`, strict-lane pairing, proposition-complete
260
+ ingestion): the result is `status: error` and nothing was written. The
261
+ authored file, the relationship shards, the pending-source receipt of an
262
+ untracked file and the file times are restored, so `kb_check` (including
263
+ `source-relationship-parity`) stays clean and `kb_status` stays `fresh`;
264
+ verify both, fix the cause (supersede, pair the lane, re-ground), and
265
+ resend the whole payload. A `committed_with_repairs` result is the
266
+ opposite case: the commit stands and only its repair actions are run.
267
+ 5. **What `dryRun: true` does and does not check.** It runs every
268
+ pre-commit validation and, for a `req`, the commit-time contradiction
269
+ check against a staged, rolled-back copy of the store, so `valid: true`
270
+ means the commit would accept the payload as far as the store can tell.
271
+ It writes nothing, so it cannot report what only a write reveals:
272
+ `DOCUMENT_PATH_REQUIRED` for a new entity with no single writable target,
273
+ filesystem, lock and receipt failures, a concurrent writer, or
274
+ `kb_check`-only rules such as `logic-coverage` and `scenario-feasibility`
275
+ (`entity-context-missing` is returned as a warning).
276
+
212
277
  ## Origin and approvals
213
278
 
214
279
  Entities record `origin` (`kind`: `human`, `agent`, `migration`, or `import`,
@@ -264,7 +329,17 @@ subject. A schema without a `subject` argument (`permission_rule`) records
264
329
  that key as the planned fact's `subject_key` instead; when the requirement
265
330
  constrains several subjects, an unbound `subject_key` asks you to pass
266
331
  `subjectHint` with one of them. A participant (`actor`, `resource`, entity)
267
- is a short noun, never a clause of the claim. Bind them
332
+ is a short noun, never a clause of the claim, and an `actor`, `role` or
333
+ `owner` is never the requirement's subject key: the planned fact already
334
+ carries that key as `subject_key`, so `actor = <subject key>` stays unbound
335
+ with a reason. When the claim names no participant for such an argument (the
336
+ value is empty, the subject key or a clause that opens with a gerund such as
337
+ "Discarding a draft while …", and none of the schema's constants or example
338
+ values occurs in the claim), the schema does
339
+ not fit the claim and Kibi answers `record_ontology_gap` with the gap
340
+ observation in `applyPlan`; the candidate stays listed as `incomplete` with
341
+ its `bindingHints`. Write the observation instead of inventing a participant.
342
+ For every other unbound argument, bind it
268
343
  from the claim's own words and call again with the same `text` and
269
344
  `requirementId`, plus `schemaId` and `argumentBindings` keyed by
270
345
  `argument_names` (reuse `argument_constants` values when the schema has them).
@@ -283,9 +358,10 @@ grounds the claim (for example a bootstrap `requires_property` fact); the action
283
358
  still names the predicate state. `replace_grounding` means a predicate fits but
284
359
  a second grounding link would fail, so keep the existing link or apply the
285
360
  `replacementPlan` steps unchanged, in order and back to back (predicate fact,
286
- `kb_delete` of the old link, requirement link; `kb_check` reports
287
- `logic-coverage` only between the last two; on a failed last step apply
288
- `rollback`); `provide_argument_bindings` and `record_ontology_gap` mean
361
+ `kb_delete` of the old link, requirement link; between the last two `kb_check`
362
+ reports both `logic-coverage` and `strict-req-fact-pairing` for the
363
+ requirement, as `expected.kbCheckAfterStep` states; run `kb_check` after the
364
+ last step and apply `rollback` if it is not clean); `provide_argument_bindings` and `record_ontology_gap` mean
289
365
  the same as for an ungrounded claim, and the gap observation is not a grounding
290
366
  link, so write it exactly as returned (tags, `claim_text`, `document.body`, no
291
367
  `claim_key`, no relationships). Record an ontology gap only when no returned schema fits the
@@ -1,7 +1,10 @@
1
1
  # UI / Visual Requirement Modeling
2
2
 
3
3
  Optional, per-project lane for recording what the screen should look like so UI edits cannot
4
- silently drift from the spec. Non-UI projects skip it entirely; no check rule requires it.
4
+ silently drift from the spec. Non-UI projects skip it entirely. Without the experimental
5
+ `kibi-plugin-ui` no check rule requires it; with that plugin active, `kb_check` blocks
6
+ components that lack a design requirement (`policy-ownership`) and implementations that
7
+ lose their pattern markers (`policy-markers`).
5
8
 
6
9
  ## Three layers
7
10
 
@@ -13,12 +16,48 @@ silently drift from the spec. Non-UI projects skip it entirely; no check rule re
13
16
  from two current requirements are rejected on write unless `supersedes`.
14
17
  3. **Relational predicates** — ground `fact_kind: predicate` linked with `requires_predicate`.
15
18
  The built-in `visual_layout_rule(subject, relation, target)` covers "X must remain visually
16
- aligned with Y" (relation `aligned_with`). Other relational layout claims need a
17
- project-local `predicate_schema` when the task authorizes ontology extension.
19
+ aligned with Y" (relation `aligned_with`); `ui_pattern`, `same_pattern` and
20
+ `pattern_marker` cover patterns (below); `ui_container(subject, size, overflow)` covers
21
+ "a half-page panel that scrolls". Other relational layout claims need a project-local
22
+ `predicate_schema` when the task authorizes ontology extension.
18
23
 
19
24
  Kibi enforces stated facts and links, not pixels. Freeform spatial prose is stored and
20
25
  searchable but is not machine-checked.
21
26
 
27
+ ## Patterns and variants
28
+
29
+ Name the visual pattern a concept uses, and which variants must share it, so a rewrite to a
30
+ different pattern (a line-and-dots timeline redone as cards) is a visible contradiction
31
+ instead of a silent drift. All three predicates are built in:
32
+
33
+ - `ui_pattern(subject, pattern)`: `ui_pattern(activity_feed, line_dots_timeline)`.
34
+ - `same_pattern(subject, variant, other_variant)`: `same_pattern(activity_feed, editor_view, read_only_view)`.
35
+ - `pattern_marker(pattern, marker)`: `pattern_marker(line_dots_timeline, timeline_dot)`; the
36
+ marker is a literal class name or test id every implementation of the pattern contains.
37
+
38
+ Link the first two from the requirement with `requires_predicate`. Marker facts belong to
39
+ the pattern, not to one requirement, so link them from the requirement that introduced the
40
+ pattern or leave them standalone. With `kibi-plugin-ui` active, every component that
41
+ implements a requirement naming a `ui_pattern` must contain each marker of that pattern in
42
+ its source or its `.html` template. A component with no design constraint (a
43
+ layout-free wrapper) carries the tag `review:ui-unconstrained` instead of a requirement.
44
+
45
+ A requirement grounded only in `ui_pattern`, `same_pattern` and `pattern_marker` is proved
46
+ by component tests: a test with `verification_scope: unit` or `integration` and a fresh
47
+ passing receipt satisfies its scenarios. Write one component test per variant named in
48
+ `same_pattern`; that is what catches a divergent branch inside one template, which the
49
+ static marker check cannot see. Adding any other fact (`ui_container`, a property) brings
50
+ back the end-to-end requirement.
51
+
52
+ ### Capturing the inventory
53
+
54
+ When the plugin is first enabled on an existing UI, list the patterns the code already
55
+ uses per screen, ask the human which is intended wherever two variants of one concept
56
+ differ, and record each answer as a requirement. Record a divergence the human has not
57
+ decided as an `observation` fact tagged `review:ui-divergence`, citing both files, rather
58
+ than guessing which variant is right. Colours, spacing and component-library choices
59
+ (which scrollbar component to use) belong in a linter, not here.
60
+
22
61
  ## Button position
23
62
 
24
63
  ```yaml