kibi-cli 2.7.0 → 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/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  2. package/dist/operations/modeling/predicate-applyplan.js +1 -1
  3. package/dist/operations/modeling/predicate-types.d.ts +16 -1
  4. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  5. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  6. package/dist/operations/modeling/suggest-predicates.js +136 -23
  7. package/dist/operations/mutation/validation.d.ts.map +1 -1
  8. package/dist/operations/mutation/validation.js +30 -0
  9. package/dist/operations/mutation/workspace-mutation-lock.d.ts +22 -0
  10. package/dist/operations/mutation/workspace-mutation-lock.d.ts.map +1 -1
  11. package/dist/operations/mutation/workspace-mutation-lock.js +67 -1
  12. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  13. package/dist/operations/planning/apply-plan.js +149 -7
  14. package/dist/public/operations/catalog.d.ts +7 -2
  15. package/dist/public/operations/catalog.d.ts.map +1 -1
  16. package/dist/public/operations/contracts.d.ts.map +1 -1
  17. package/dist/public/operations/contracts.js +36 -22
  18. package/dist/public/operations/runtime-types.d.ts +12 -0
  19. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  20. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  21. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  22. package/dist/public/operations/specs/check-rules.generated.js +2 -1
  23. package/dist/public/operations/specs/check.d.ts +1 -1
  24. package/dist/public/operations/specs/planning.d.ts +6 -1
  25. package/dist/public/operations/specs/planning.d.ts.map +1 -1
  26. package/dist/public/operations/specs/planning.js +6 -1
  27. package/dist/public/skills/kibi-bootstrap/SKILL.md +4 -4
  28. package/dist/public/skills/kibi-usage/SKILL.md +9 -4
  29. package/dist/utils/rule-registry.generated.d.ts +5 -0
  30. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  31. package/dist/utils/rule-registry.generated.js +6 -0
  32. package/package.json +2 -2
  33. package/src/public/operations/contracts.ts +38 -22
  34. package/src/public/operations/runtime-types.ts +14 -0
  35. package/src/public/operations/specs/check-rules.generated.ts +2 -1
  36. package/src/public/operations/specs/planning.ts +7 -1
  37. package/src/public/skills/kibi-bootstrap/SKILL.md +4 -4
  38. package/src/public/skills/kibi-usage/SKILL.md +9 -4
@@ -1 +1 @@
1
- {"version":3,"file":"rule-registry.generated.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.generated.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgTlB,CAAC"}
1
+ {"version":3,"file":"rule-registry.generated.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.generated.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuTlB,CAAC"}
@@ -164,6 +164,12 @@ export const GENERATED_RULES = [
164
164
  enforcementClass: "migration",
165
165
  category: "integrity",
166
166
  },
167
+ {
168
+ name: "related-requirement-unmodeled",
169
+ description: "A current requirement with unresolved (missing) propositions that relates_to a current requirement modeled with strict property or ground predicate facts; its claims are never compared by domain-contradictions until they are modeled against the same subject or predicates, or it supersedes that requirement",
170
+ enforcementClass: "canonical",
171
+ category: "integrity",
172
+ },
167
173
  {
168
174
  name: "proof-contract-symbols",
169
175
  description: "Detect unresolved required_proofs.symbol_id values, type-shape required proofs, and proof_bindings.source_file disagreement with the named symbol sourceFile",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-cli",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "type": "module",
5
5
  "description": "Kibi CLI for knowledge base management",
6
6
  "engines": {
@@ -235,7 +235,7 @@
235
235
  "fast-glob": "^3.2.12",
236
236
  "gray-matter": "^4.0.3",
237
237
  "js-yaml": "^4.1.0",
238
- "kibi-core": "^0.16.0",
238
+ "kibi-core": "^0.17.0",
239
239
  "kibi-plugin-builtin": "^0.4.2",
240
240
  "kibi-plugin-sdk": "^0.4.1",
241
241
  "kibi-swipl": "^1.0.1",
@@ -393,8 +393,8 @@ const impactReviewAuthorship = objectData(
393
393
  );
394
394
 
395
395
  /**
396
- * kibi.job.v1 receipt returned by async-mode operations (kb_check with
397
- * `async: true`) instead of the synchronous payload. Agents poll
396
+ * kibi.job.v1 receipt returned by async-mode operations (kb_check and
397
+ * kb_apply_plan with `async: true`) instead of the synchronous payload. Agents poll
398
398
  * kb_job_status with the jobId. Declared as a union member of the operation
399
399
  * data contract so hosts validating tool output against the declared schema
400
400
  * accept the receipt without weakening the synchronous payload contract.
@@ -562,11 +562,20 @@ const BASE_DATA_SCHEMAS: Readonly<
562
562
  "provide_argument_bindings",
563
563
  "resolve_schema_reference",
564
564
  "record_ontology_gap",
565
+ "review_nonlogical",
566
+ "already_grounded",
565
567
  ],
566
568
  },
567
569
  recommendedPredicateSchema: { type: ["object", "null"] },
568
570
  applyPlan: recordArray,
569
571
  relationshipPlan: { type: ["object", "null"] },
572
+ relationshipTarget: {
573
+ type: ["string", "null"],
574
+ description:
575
+ "The planned predicate fact id (FACT-PRED-...) that a requires_predicate link must target. Candidate ids (SUGGEST-...) are never relationship targets.",
576
+ },
577
+ existingGrounding: recordArray,
578
+ replacementPlan: { type: ["object", "null"] },
570
579
  warnings: stringArray,
571
580
  }),
572
581
  kb_plan_bootstrap: objectData(
@@ -712,26 +721,33 @@ const BASE_DATA_SCHEMAS: Readonly<
712
721
  diagnostics: stringArray,
713
722
  capabilityPlugins: recordValue,
714
723
  }),
715
- kb_apply_plan: objectData({
716
- version: stringValue,
717
- outcome: stringValue,
718
- planHash: stringValue,
719
- changedEntities: integerValue,
720
- changedRelationships: integerValue,
721
- changedPaths: stringArray,
722
- finalSnapshots: recordValue,
723
- validationSummary: recordValue,
724
- recoveryJournalId: { type: ["string", "null"] },
725
- deleted: integerValue,
726
- sourcePaths: stringArray,
727
- actionResults: recordArray,
728
- notes: stringArray,
729
- remainingPlan: recordValue,
730
- closeout: recordValue,
731
- status: stringValue,
732
- effectFailures: recordArray,
733
- nextActions: recordArray,
734
- }),
724
+ kb_apply_plan: {
725
+ description:
726
+ "Synchronous apply result, or a kibi.job.v1 receipt when async:true detached the apply into a background job (poll kb_job_status with the jobId).",
727
+ anyOf: [
728
+ objectData({
729
+ version: stringValue,
730
+ outcome: stringValue,
731
+ planHash: stringValue,
732
+ changedEntities: integerValue,
733
+ changedRelationships: integerValue,
734
+ changedPaths: stringArray,
735
+ finalSnapshots: recordValue,
736
+ validationSummary: recordValue,
737
+ recoveryJournalId: { type: ["string", "null"] },
738
+ deleted: integerValue,
739
+ sourcePaths: stringArray,
740
+ actionResults: recordArray,
741
+ notes: stringArray,
742
+ remainingPlan: recordValue,
743
+ closeout: recordValue,
744
+ status: stringValue,
745
+ effectFailures: recordArray,
746
+ nextActions: recordArray,
747
+ }),
748
+ jobReceiptData,
749
+ ],
750
+ },
735
751
  kb_ingest_proof: objectData({
736
752
  artifactDigest: stringValue,
737
753
  environmentHash: stringValue,
@@ -185,6 +185,16 @@ export interface NetworkPort {
185
185
 
186
186
  export type Clock = () => Date;
187
187
 
188
+ /** One progress report from a long-running operation (for example one applied plan action). */
189
+ export type OperationProgress = Readonly<{
190
+ progress: number;
191
+ total?: number;
192
+ message?: string;
193
+ }>;
194
+
195
+ /** Host callback for progress reports; MCP forwards them as notifications/progress. */
196
+ export type ProgressReporter = (progress: OperationProgress) => void;
197
+
188
198
  export type RuntimeOptions = {
189
199
  readonly workspaceRoot?: string;
190
200
  readonly signal?: AbortSignal;
@@ -195,6 +205,8 @@ export type RuntimeOptions = {
195
205
  readonly net?: NetworkPort;
196
206
  /** Optional injectable capability registry (or lazy factory). */
197
207
  readonly plugins?: OperationPlugins;
208
+ /** Optional progress sink for long-running operations. */
209
+ readonly onProgress?: ProgressReporter;
198
210
  };
199
211
 
200
212
  export type OperationContext = {
@@ -219,6 +231,8 @@ export type OperationContext = {
219
231
  readonly plugins?: OperationPlugins;
220
232
  /** Lazily materialize the workspace capability registry. */
221
233
  readonly ensurePlugins?: () => Promise<CapabilityRegistry>;
234
+ /** Progress sink a long-running operation reports to; absent when the host does not listen. */
235
+ readonly onProgress?: ProgressReporter;
222
236
  };
223
237
  export interface RuntimeOperationSpec<TInput = unknown, TResult = unknown> {
224
238
  readonly name: string;
@@ -36,6 +36,7 @@ export const SELECTABLE_RULE_NAMES: readonly string[] = [
36
36
  "predicate-verifiability",
37
37
  "strict-readiness",
38
38
  "semantic-completeness",
39
+ "related-requirement-unmodeled",
39
40
  "proof-contract-symbols",
40
41
  "entity-id-style",
41
42
  "domain-redundancy",
@@ -58,4 +59,4 @@ export const SELECTABLE_RULE_NAMES: readonly string[] = [
58
59
  // implements REQ-006
59
60
  /** Comma-separated "Allowed:" fragment for the kb_check rules description. */
60
61
  export const SELECTABLE_RULES_ALLOWED =
61
- "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged";
62
+ "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged";
@@ -245,7 +245,13 @@ export const applyPlanSpec = {
245
245
  type: "string",
246
246
  pattern: "^[A-Za-z0-9._-]+$",
247
247
  description:
248
- "Typed recovery journal identifier returned by a committed_with_repairs result or a PLAN_APPLY_RECOVERY_REQUIRED error. Recovery replays only the immutable journal and never the original plan request; a compile-plan journal (plan-apply-*) is completed or rolled back deterministically and reports which.",
248
+ "Typed recovery journal identifier returned by a committed_with_repairs result or a PLAN_APPLY_RECOVERY_REQUIRED error. Recovery replays only the immutable journal and never the original plan request; a compile-plan journal (plan-apply-*) is completed or rolled back deterministically and reports which. A bootstrap journal left `applying` by a process that died mid-action is resumed without edits: the interrupted action is re-applied and a source lock held by the dead process is reclaimed and recorded in the journal.",
249
+ },
250
+ async: {
251
+ type: "boolean",
252
+ default: false,
253
+ description:
254
+ "MCP only. When true, start the apply as a background job and return a kibi.job.v1 receipt immediately instead of holding the request open; poll kb_job_status with the returned jobId for the final result. Use for large bootstrap plans (hundreds of actions) that can outlast a client's request timeout. The MCP server registers kb_job_status only when KIBI_MCP_OPTIONAL_TOOLS includes it; otherwise async applies synchronously. A synchronous apply sends notifications/progress after each bootstrap action when the request carries a progressToken. The CLI ignores this field.",
249
255
  },
250
256
  },
251
257
  },
@@ -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.4.0
5
+ version: 3.5.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -38,13 +38,13 @@ Seed branch-local Kibi knowledge from cited product intent, without creating a p
38
38
  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`. Read the per-source `Knowledge source …` diagnostics; if a source has claims not planned, report them per source and restate them before approval, or carry them to step 11 with their citation.
39
39
  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. With no answer, stop as "awaiting approval." If declined, replan and ask again with the new hash.
40
40
  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.
41
- 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.
41
+ 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.
42
42
  9. **Read back** with `kb_query` and `kb_search` to confirm writes and citations.
43
43
  10. **Close out** with `kb_check`, then `kb_status`.
44
44
  11. **Deepen.** Bootstrap is complete; the KB is now half-way, holding cited `req` entries and review facts but no scenarios, tests or predicates. Load `kibi-usage` and continue in the normal Kibi workflow, one area at a time, telling the human what you author:
45
45
  - **Unplanned claims.** For every claim suppressed as `invalid_write` and every `sourceOnlySignals` entry ("Author requirement …"), restate the claim's statement and citation (`sourceId:reference`), model it with `kb_model` (`mode: "requirement"`, or `mode: "predicates"` for domain claims), and write the result with `kb_upsert` (`dryRun: true` first).
46
- - **Scenarios.** Write scenarios from the cited ticket's acceptance criteria, one scenario per criterion, not bulk drafts from the requirement title; ask the human when the source states none. Give each a plain title, `expects`, and `assumes` links to the `property_value` facts whose values the scenario relies on, then link the requirement with `specified_by` (upsert the `req` with its stored `title`, a `status` and that relationship only). Example: criterion "Given an annotation in draft state, when the user deletes it, the draft is cleared" becomes `{"type":"scenario","id":"SCEN-annotation-delete-clears-draft","properties":{"title":"Deleting a draft annotation clears the draft","status":"active","expects":"success"},"relationships":[{"type":"assumes","from":"SCEN-annotation-delete-clears-draft","to":"FACT-annotation-state-draft"}]}`, where the assumed fact is a `property_value` (`annotation.state` `eq` `draft`). Link existing tests that exercise it; never invent test evidence.
47
- - **Predicates.** Run `kb_model` with `mode: "predicates"` on each persisted requirement and apply a returned plan with `requires_predicate`, or record the `review:ontology-gap` observation it returns.
46
+ - **Scenarios.** Write scenarios from the cited ticket's acceptance criteria, one scenario per criterion, not bulk drafts from the requirement title; ask the human when the source states none. Give each a plain title, `expects`, the scenario prose in `document.body` (never in `properties`), and `assumes` links to the `property_value` facts whose values the scenario relies on, then link the requirement with `specified_by` (upsert the `req` with its stored `title`, a `status` and that relationship only). Example: criterion "Given an annotation in draft state, when the user deletes it, the draft is cleared" becomes `{"type":"scenario","id":"SCEN-annotation-delete-clears-draft","properties":{"title":"Deleting a draft annotation clears the draft","status":"active","expects":"success"},"document":{"body":"Given an annotation in draft state, when the user deletes it, then the draft is cleared and nothing is published.\n\nThe acceptance criterion comes from the cited ticket; reviewers asked for it so a deleted draft never reappears after reload.\n"},"relationships":[{"type":"assumes","from":"SCEN-annotation-delete-clears-draft","to":"FACT-annotation-state-draft"}]}`, where the assumed fact is a `property_value` (`annotation.state` `eq` `draft`). Link existing tests that exercise it; never invent test evidence.
47
+ - **Predicates.** Run `kb_model` with `mode: "predicates"` and `requirementId` on each persisted requirement and apply a returned plan with `requires_predicate` to its `relationshipTarget` (the planned `FACT-PRED-…` id, never a `SUGGEST-…` candidate id), or record the `review:ontology-gap` observation it returns, with its prose in `document.body`. `already_grounded` means the bootstrap already grounded that claim; leave it unless the human wants the `replacementPlan` swap. Count what `kb_query` shows afterwards, not the calls you made.
48
48
  - **Unrecorded ambiguity.** Record any conflict or open question you found but did not declare in step 3 as a cited `fact_kind: observation` tagged `review:conflict` or `review:open-question`.
49
49
  Finish with `kb_check` and `kb_status`.
50
50
  12. **Report** calls made, result statuses, applied scope, what step 11 authored, gaps, and follow-ups. Classify as complete, partial, awaiting approval, or blocked.
@@ -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.4.0
5
+ version: 2.5.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -263,10 +263,15 @@ prose. Bind them from the claim's own words and call again with the same
263
263
  ```
264
264
 
265
265
  When the retry returns `apply_requires_predicate`, write its `applyPlan` fact,
266
- then the `relationshipPlan` `requires_predicate` row. Record an ontology gap
266
+ then the `relationshipPlan` `requires_predicate` row; its target is
267
+ `relationshipTarget` (the planned `FACT-PRED-…` id), never a candidate's
268
+ `SUGGEST-…` id. `already_grounded` means the requirement already grounds the
269
+ claim (for example a bootstrap `requires_property` fact): a second grounding
270
+ link would fail, so keep it or follow `replacementPlan`. Record an ontology gap
267
271
  only when no returned schema fits the claim, not because bindings were missing.
268
- A review note is an observation that quotes its claim without `claim_key`:
269
- `{"type":"fact","id":"FACT-review-<area>-<behavior>","properties":{"title":"Review: ...","status":"active","fact_kind":"observation","text_ref":"<sourceId>:<reference>","tags":["review:invalid-write"],"claim_text":"<the claim>"}}`.
272
+ A review note is an observation that quotes its claim without `claim_key`, with
273
+ its prose in `document.body`:
274
+ `{"type":"fact","id":"FACT-review-<area>-<behavior>","properties":{"title":"Review: ...","status":"active","fact_kind":"observation","text_ref":"<sourceId>:<reference>","tags":["review:invalid-write"],"claim_text":"<the claim>"},"document":{"body":"<why it needs review, who raised it, the source>"}}`.
270
275
 
271
276
  To add `specified_by` (or another relationship) to an existing requirement,
272
277
  upsert it with its stored `title`, a `status` and the relationship only; Kibi