kibi-cli 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +3 -2
- package/dist/commands/aggregated-checks.d.ts +7 -0
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +25 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +21 -13
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +105 -24
- package/dist/commands/github-init.d.ts +1 -1
- package/dist/commands/github-init.d.ts.map +1 -1
- package/dist/commands/github-init.js +1 -1
- package/dist/commands/init-helpers.d.ts +17 -2
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +123 -23
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +110 -15
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +10 -18
- package/dist/commands/sync/cache.d.ts +20 -1
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +51 -2
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +1 -1
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +8 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +11 -3
- package/dist/engine.d.ts +26 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +126 -29
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +66 -28
- package/dist/extractors/markdown.d.ts +2 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +14 -3
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +1 -0
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +68 -29
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +4 -3
- package/dist/operations/modeling/model-requirement.d.ts +1 -1
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +176 -10
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +14 -2
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +24 -0
- package/dist/operations/modeling/predicate-types.d.ts +4 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
- package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-vocabulary.js +169 -0
- package/dist/operations/modeling/requirement-types.d.ts +5 -0
- package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
- package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
- package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
- package/dist/operations/modeling/vocabulary-alignment.js +178 -0
- package/dist/operations/mutation/contradictions.d.ts +3 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +29 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +33 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
- package/dist/operations/mutation/relationships.d.ts +1 -1
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +1 -0
- package/dist/operations/mutation/saga.d.ts +5 -0
- package/dist/operations/mutation/saga.d.ts.map +1 -1
- package/dist/operations/mutation/saga.js +10 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +2 -0
- package/dist/operations/mutation/source-authoring.d.ts +6 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +65 -26
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +5 -0
- package/dist/operations/mutation/types.d.ts +17 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts +6 -0
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +72 -4
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +24 -1
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +16 -3
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +61 -17
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +3 -1
- package/dist/operations/proof/code-scope.d.ts +17 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -0
- package/dist/operations/proof/code-scope.js +60 -0
- package/dist/operations/proof/ingest-proof.d.ts +4 -2
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +207 -74
- package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
- package/dist/operations/proof/migrate-legacy-receipts.js +7 -5
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +7 -5
- package/dist/plugins/compose-semantic-classifier.d.ts +6 -1
- package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -1
- package/dist/plugins/compose-semantic-classifier.js +8 -3
- package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
- package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
- package/dist/plugins/compose-vocabulary-alignment.js +141 -0
- package/dist/plugins/external-allowlist.d.ts +7 -0
- package/dist/plugins/external-allowlist.d.ts.map +1 -1
- package/dist/plugins/external-allowlist.js +13 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/registry.d.ts +2 -1
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +22 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -0
- package/dist/prolog.d.ts +36 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +78 -9
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +7 -25
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +4 -12
- package/dist/public/operations/catalog.d.ts +36 -7
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +10 -2
- package/dist/public/operations/check-helpers.d.ts +6 -0
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +21 -1
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +16 -0
- package/dist/public/operations/discovery-entities.d.ts +42 -2
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +195 -22
- package/dist/public/operations/discovery-executors.d.ts +1 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +75 -46
- package/dist/public/operations/migration-plan.d.ts +2 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +50 -0
- package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
- package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
- package/dist/public/operations/predicate-schema-conformance.js +242 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +9 -3
- package/dist/public/operations/result-envelope.d.ts +34 -1
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +78 -2
- package/dist/public/operations/runtime-types.d.ts +1 -1
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +8 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/discovery.d.ts +7 -1
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +7 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +21 -3
- package/dist/public/operations/specs/reporting.d.ts +8 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +46 -15
- package/dist/public/operations/specs/upsert.d.ts +28 -5
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +1 -1
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +8 -3
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +22 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +1 -0
- package/dist/public/skills/kibi-usage/SKILL.md +7 -3
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +21 -5
- package/dist/relationships/shards.d.ts +6 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +26 -19
- package/dist/schemas/entity.schema.json +32 -0
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-entity-id-style.d.ts +12 -0
- package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
- package/dist/traceability/staged-entity-id-style.js +68 -0
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +8 -0
- package/dist/traceability/validate.js +1 -1
- package/dist/types/entities.d.ts +2 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts +1 -1
- package/dist/types/relationships.d.ts.map +1 -1
- package/dist/utils/entity-id-style.d.ts +27 -0
- package/dist/utils/entity-id-style.d.ts.map +1 -0
- package/dist/utils/entity-id-style.js +81 -0
- package/dist/utils/git-repository-context.d.ts +50 -0
- package/dist/utils/git-repository-context.d.ts.map +1 -0
- package/dist/utils/git-repository-context.js +259 -0
- package/dist/utils/rule-registry.d.ts +5 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.d.ts +37 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +44 -0
- package/dist/utils/strict-modeling.d.ts +7 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +11 -0
- package/package.json +4 -4
- package/schema/entities.pl +60 -1
- package/schema/relationships.pl +17 -4
- package/schema/validation.pl +118 -20
- package/src/public/diagnostic-usage.ts +16 -24
- package/src/public/impact/full-kb-quality.ts +4 -16
- package/src/public/operations/check-executor.ts +12 -1
- package/src/public/operations/check-helpers.ts +27 -1
- package/src/public/operations/contracts.ts +19 -0
- package/src/public/operations/discovery-entities.ts +292 -23
- package/src/public/operations/discovery-executors.ts +91 -55
- package/src/public/operations/migration-plan.ts +57 -0
- package/src/public/operations/predicate-schema-conformance.ts +362 -0
- package/src/public/operations/prolog-json.ts +9 -3
- package/src/public/operations/result-envelope.ts +114 -2
- package/src/public/operations/runtime-types.ts +1 -1
- package/src/public/operations/specs/check-rules.generated.ts +8 -1
- package/src/public/operations/specs/discovery.ts +8 -1
- package/src/public/operations/specs/mutation-schemas.ts +23 -3
- package/src/public/operations/specs/reporting.ts +69 -22
- package/src/public/operations/specs/upsert.ts +1 -1
- package/src/public/operations/symbol-repair-plan.ts +13 -3
- package/src/public/schemas/entity.ts +22 -0
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skills/kibi-usage/SKILL.md +7 -3
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/src/public/telemetry-acceptance.ts +37 -6
- package/src/schemas/entity.schema.json +32 -0
- package/src/schemas/relationship.schema.json +1 -0
|
@@ -33,11 +33,62 @@ surfaces are a release defect: require a new package version and label any
|
|
|
33
33
|
project override temporary. This skill never selects a package manager or
|
|
34
34
|
edits dependency configuration.
|
|
35
35
|
|
|
36
|
+
## Choosing a discovery mode
|
|
37
|
+
|
|
38
|
+
`kb_search` is not one behavior. It selects deterministic intent ranking when
|
|
39
|
+
you pass `rankingMode: "intent-v1"`, `semanticFacets`, or `sourceLocations`,
|
|
40
|
+
and legacy lexical ranking otherwise. Naming the tool is not enough; the inputs
|
|
41
|
+
decide the path.
|
|
42
|
+
|
|
43
|
+
- **Exact identity** — you already know the ID. Use `kb_query`, not search.
|
|
44
|
+
- **Literal token** — a symbol, file, or error string that appears verbatim.
|
|
45
|
+
Use lexical `kb_search` and keep the query close to the literal text.
|
|
46
|
+
- **Conceptual or behavioral** — "how does checkout handle a declined card".
|
|
47
|
+
Use intent mode and ground it in what you actually know:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"query": "declined card during checkout",
|
|
52
|
+
"rankingMode": "intent-v1",
|
|
53
|
+
"semanticFacets": {
|
|
54
|
+
"actors": ["shopper"],
|
|
55
|
+
"actions": ["pay"],
|
|
56
|
+
"objects": ["card"],
|
|
57
|
+
"constraints": ["declined"]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- **Before changing code** — pass the file you are about to edit as a source
|
|
63
|
+
location, so results are matched against source-linked symbols and return
|
|
64
|
+
source evidence:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"query": "checkout total rounding",
|
|
69
|
+
"rankingMode": "intent-v1",
|
|
70
|
+
"sourceLocations": [{ "path": "src/checkout.ts", "symbol": "computeTotal" }]
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Supply facets only from the request, the code, or prior results. Inventing
|
|
75
|
+
facets fabricates evidence and biases ranking. Intent mode abstains below
|
|
76
|
+
`minScore` instead of returning weak matches; an abstention is an explicit
|
|
77
|
+
no-answer, so widen the query or drop to lexical search rather than treating it
|
|
78
|
+
as "nothing exists". There is no target percentage of intent-mode calls — a
|
|
79
|
+
literal identifier lookup is still best served lexically.
|
|
80
|
+
|
|
81
|
+
Results are summaries by default: identifying metadata, score, reasons, and a
|
|
82
|
+
snippet. Read them to pick candidates, then `kb_query` those IDs for full
|
|
83
|
+
bodies, or pass `fields: "full"` when you genuinely need every body. Extract
|
|
84
|
+
the relevant existing constraints and decisions from the response before
|
|
85
|
+
planning a behavior change; a search receipt is not comprehension.
|
|
86
|
+
|
|
36
87
|
## Discovery to Validation Sequence
|
|
37
88
|
|
|
38
89
|
The canonical workflow for any KB operation follows this pattern:
|
|
39
90
|
|
|
40
|
-
1. **Discover**: `kb_search` with focused probes
|
|
91
|
+
1. **Discover**: `kb_search` with focused probes; pick the mode above
|
|
41
92
|
2. **Confirm**: `kb_query` for exact IDs and state
|
|
42
93
|
3. **Inspect**: `kb_status` when freshness matters
|
|
43
94
|
4. **Decompose**: `kb_semantic_advisor` on the complete normative prose; verify or supply every atomic clause
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-acceptance.d.ts","sourceRoot":"","sources":["../../src/public/telemetry-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAEV,yBAAyB,EACzB,yBAAyB,EAGzB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EACV,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,4BAA4B,EACvC,8BAAuC,CAAC;AAE1C,eAAO,MAAM,mCAAmC;;;;;;;;;;;;CAYF,CAAC;AAgB/C,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,mBAAmB,EAAE,CAsBvB;AA0DD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,EAC3B,QAAQ,EAAE,MAAM,GACf,qBAAqB,CAKvB;
|
|
1
|
+
{"version":3,"file":"telemetry-acceptance.d.ts","sourceRoot":"","sources":["../../src/public/telemetry-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAEV,yBAAyB,EACzB,yBAAyB,EAGzB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EACV,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,4BAA4B,EACvC,8BAAuC,CAAC;AAE1C,eAAO,MAAM,mCAAmC;;;;;;;;;;;;CAYF,CAAC;AAgB/C,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,mBAAmB,EAAE,CAsBvB;AA0DD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,EAC3B,QAAQ,EAAE,MAAM,GACf,qBAAqB,CAKvB;AA0dD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,mBAAmB,EAAE,EACtC,GAAG,GAAE,IAAiB,EACtB,MAAM,GAAE,yBAA+D,GACtE,yBAAyB,CA6D3B;AA+DD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,SAAS,iBAAiB,EAAE,CA+E9B"}
|
|
@@ -251,14 +251,30 @@ function advisorBeforeRequirementWriteMetric(all, recentStart, policy) {
|
|
|
251
251
|
},
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
+
function sourceLookupMessage(zeroResults, lookups, unobservable) {
|
|
255
|
+
const unreadable = unobservable > 0
|
|
256
|
+
? `${unobservable} source-linked lookups recorded no readable result count.`
|
|
257
|
+
: "";
|
|
258
|
+
if (lookups === 0) {
|
|
259
|
+
return (unreadable ||
|
|
260
|
+
"No source-linked query or search calls occurred in the evaluated window.");
|
|
261
|
+
}
|
|
262
|
+
const observed = `${zeroResults}/${lookups} source-linked lookups returned zero results.`;
|
|
263
|
+
return unreadable ? `${observed} ${unreadable}` : observed;
|
|
264
|
+
}
|
|
254
265
|
function sourceLookupMetric(recent, policy) {
|
|
255
|
-
const
|
|
266
|
+
const sourceLinked = recent.filter(({ event }) => {
|
|
256
267
|
if ((event.tool !== "kb_query" && event.tool !== "kb_search") ||
|
|
257
268
|
!eventSucceeded(event)) {
|
|
258
269
|
return false;
|
|
259
270
|
}
|
|
260
271
|
return typeof eventArgs(event).sourceFile === "string";
|
|
261
272
|
});
|
|
273
|
+
// A row whose count could not be read is unobservable, not a hit. Counting
|
|
274
|
+
// it as a non-zero result would let a broken logger report a healthy rate.
|
|
275
|
+
const lookups = sourceLinked.filter(({ event }) => typeof event.result_count === "number" ||
|
|
276
|
+
typeof event.zero_results === "boolean");
|
|
277
|
+
const unobservable = sourceLinked.length - lookups.length;
|
|
262
278
|
const zeroResults = lookups.filter(({ event }) => event.zero_results === true || event.result_count === 0);
|
|
263
279
|
const actual = rate(zeroResults.length, lookups.length);
|
|
264
280
|
const sourceCounts = new Map();
|
|
@@ -268,7 +284,9 @@ function sourceLookupMetric(recent, policy) {
|
|
|
268
284
|
}
|
|
269
285
|
return {
|
|
270
286
|
id: "source_lookup_zero_result_rate",
|
|
271
|
-
status:
|
|
287
|
+
status: lookups.length === 0 && unobservable > 0
|
|
288
|
+
? "insufficient_evidence"
|
|
289
|
+
: thresholdStatus(actual, "<=", policy.sourceLookupZeroResultMaximum),
|
|
272
290
|
numerator: zeroResults.length,
|
|
273
291
|
denominator: lookups.length,
|
|
274
292
|
...(actual !== undefined ? { rate: actual } : {}),
|
|
@@ -276,9 +294,7 @@ function sourceLookupMetric(recent, policy) {
|
|
|
276
294
|
operator: "<=",
|
|
277
295
|
value: policy.sourceLookupZeroResultMaximum,
|
|
278
296
|
},
|
|
279
|
-
message: lookups.length
|
|
280
|
-
? "No source-linked query or search calls occurred in the evaluated window."
|
|
281
|
-
: `${zeroResults.length}/${lookups.length} source-linked lookups returned zero results.`,
|
|
297
|
+
message: sourceLookupMessage(zeroResults.length, lookups.length, unobservable),
|
|
282
298
|
evidence: {
|
|
283
299
|
zeroResultSourceFiles: [...sourceCounts.entries()]
|
|
284
300
|
.sort(([leftFile, leftCount], [rightFile, rightCount]) => rightCount - leftCount || leftFile.localeCompare(rightFile))
|
|
@@ -50,6 +50,12 @@ export type RemovedRelationshipRecords = Readonly<{
|
|
|
50
50
|
* Remove exact legacy-shard relationships using an atomic temp-file rename.
|
|
51
51
|
* The caller is responsible for retracting the compiled RDF edge afterwards.
|
|
52
52
|
*/
|
|
53
|
+
/**
|
|
54
|
+
* A shard's YAML without the selected relationships. The sequence is patched in
|
|
55
|
+
* place so comments, ordering, and unrelated records survive; callers that must
|
|
56
|
+
* approve the bytes before writing (deletion plans) render without writing.
|
|
57
|
+
*/
|
|
58
|
+
export declare function renderShardWithout(text: string, selectors: readonly RelationshipSelector[], shardPath: string): string;
|
|
53
59
|
export declare function removeRelationshipsFromShards(kbRoot: string, selectors: readonly RelationshipSelector[]): RemovedRelationshipRecords[];
|
|
54
60
|
/**
|
|
55
61
|
* Appends a relationship to the appropriate shard.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shards.d.ts","sourceRoot":"","sources":["../../src/relationships/shards.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAsFjE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,EAAE,GAC5B,IAAI,CAoBN;AAwBD,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC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ACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAE1B,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,QAAQ,EAAE,kBAAkB,EAAE,GAC7B,kBAAkB,EAAE,CAgCtB"}
|
|
@@ -163,6 +163,31 @@ function atomicWriteText(targetPath, body) {
|
|
|
163
163
|
* Remove exact legacy-shard relationships using an atomic temp-file rename.
|
|
164
164
|
* The caller is responsible for retracting the compiled RDF edge afterwards.
|
|
165
165
|
*/
|
|
166
|
+
/**
|
|
167
|
+
* A shard's YAML without the selected relationships. The sequence is patched in
|
|
168
|
+
* place so comments, ordering, and unrelated records survive; callers that must
|
|
169
|
+
* approve the bytes before writing (deletion plans) render without writing.
|
|
170
|
+
*/
|
|
171
|
+
// implements REQ-kibi-operation-interface-parity
|
|
172
|
+
export function renderShardWithout(text, selectors, shardPath) {
|
|
173
|
+
const wanted = new Set(selectors.map((selector) => `${selector.type}\0${selector.from}\0${selector.to}`));
|
|
174
|
+
const document = parseDocument(text);
|
|
175
|
+
const sequence = document.get("relationships", true);
|
|
176
|
+
if (!sequence || typeof sequence !== "object" || !("items" in sequence)) {
|
|
177
|
+
throw new Error(`Invalid shard file: missing 'relationships' array at ${shardPath}`);
|
|
178
|
+
}
|
|
179
|
+
const items = sequence.items;
|
|
180
|
+
for (let index = items.length - 1; index >= 0; index -= 1) {
|
|
181
|
+
const item = items[index];
|
|
182
|
+
if (!item || typeof item !== "object" || !("get" in item))
|
|
183
|
+
continue;
|
|
184
|
+
const get = item.get.bind(item);
|
|
185
|
+
if (wanted.has(`${String(get("type"))}\0${String(get("from"))}\0${String(get("to"))}`)) {
|
|
186
|
+
document.deleteIn(["relationships", index]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return document.toString();
|
|
190
|
+
}
|
|
166
191
|
export function removeRelationshipsFromShards(kbRoot, selectors) {
|
|
167
192
|
const wanted = new Set(selectors.map((selector) => `${selector.type}\0${selector.from}\0${selector.to}`));
|
|
168
193
|
const removed = new Map();
|
|
@@ -171,25 +196,7 @@ export function removeRelationshipsFromShards(kbRoot, selectors) {
|
|
|
171
196
|
const matching = records.filter((record) => wanted.has(`${record.type}\0${record.from}\0${record.to}`));
|
|
172
197
|
if (matching.length === 0)
|
|
173
198
|
continue;
|
|
174
|
-
|
|
175
|
-
// records survive a relationship deletion. The compiled store is never
|
|
176
|
-
// the mutation target; this shard remains the canonical source artifact.
|
|
177
|
-
const document = parseDocument(fs.readFileSync(shardPath, "utf8"));
|
|
178
|
-
const sequence = document.get("relationships", true);
|
|
179
|
-
if (!sequence || typeof sequence !== "object" || !("items" in sequence)) {
|
|
180
|
-
throw new Error(`Invalid shard file: missing 'relationships' array at ${shardPath}`);
|
|
181
|
-
}
|
|
182
|
-
const items = sequence.items;
|
|
183
|
-
for (let index = items.length - 1; index >= 0; index -= 1) {
|
|
184
|
-
const item = items[index];
|
|
185
|
-
if (!item || typeof item !== "object" || !("get" in item))
|
|
186
|
-
continue;
|
|
187
|
-
const get = item.get.bind(item);
|
|
188
|
-
if (wanted.has(`${String(get("type"))}\0${String(get("from"))}\0${String(get("to"))}`)) {
|
|
189
|
-
document.deleteIn(["relationships", index]);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
atomicWriteText(shardPath, document.toString());
|
|
199
|
+
atomicWriteText(shardPath, renderShardWithout(fs.readFileSync(shardPath, "utf8"), selectors, shardPath));
|
|
193
200
|
for (const record of matching) {
|
|
194
201
|
const key = `${record.type}\0${record.from}\0${record.to}`;
|
|
195
202
|
const entry = removed.get(key) ?? { paths: [], sources: [] };
|
|
@@ -1173,6 +1173,28 @@
|
|
|
1173
1173
|
"type": "string"
|
|
1174
1174
|
}
|
|
1175
1175
|
},
|
|
1176
|
+
"argument_constants": {
|
|
1177
|
+
"type": "object",
|
|
1178
|
+
"additionalProperties": {
|
|
1179
|
+
"type": "array",
|
|
1180
|
+
"minItems": 1,
|
|
1181
|
+
"uniqueItems": true,
|
|
1182
|
+
"items": {
|
|
1183
|
+
"type": "string",
|
|
1184
|
+
"minLength": 1
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
},
|
|
1188
|
+
"argument_aliases": {
|
|
1189
|
+
"type": "object",
|
|
1190
|
+
"additionalProperties": {
|
|
1191
|
+
"type": "object",
|
|
1192
|
+
"additionalProperties": {
|
|
1193
|
+
"type": "string",
|
|
1194
|
+
"minLength": 1
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
},
|
|
1176
1198
|
"rule_ir": {
|
|
1177
1199
|
"$ref": "#/$defs/logicRule"
|
|
1178
1200
|
},
|
|
@@ -1373,6 +1395,16 @@
|
|
|
1373
1395
|
"predicate_args"
|
|
1374
1396
|
]
|
|
1375
1397
|
},
|
|
1398
|
+
{
|
|
1399
|
+
"required": [
|
|
1400
|
+
"argument_constants"
|
|
1401
|
+
]
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
"required": [
|
|
1405
|
+
"argument_aliases"
|
|
1406
|
+
]
|
|
1407
|
+
},
|
|
1376
1408
|
{
|
|
1377
1409
|
"required": [
|
|
1378
1410
|
"rule_ir"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QualityDiagnostic } from "../public/impact/types.js";
|
|
2
2
|
import { type KibiImpactEvidence } from "./evidence-model.js";
|
|
3
|
-
export type KibiImpactDiagnosticId = "kibi_impact_evidence_missing" | "symbols_manifest_stale" | "symbol_granularity_violation" | "symbol_semantic_review_needed" | "multi_requirement_symbol_review" | "duplicate_symbol_coordinate_review" | "component_mixed_purpose_review" | "broad_requirement_review" | "requirement_status_review" | "strict_fact_modeling_review" | "logical_coverage_review" | "kibi_impact_override_missing_rationale";
|
|
3
|
+
export type KibiImpactDiagnosticId = "kibi_impact_evidence_missing" | "symbols_manifest_stale" | "symbol_granularity_violation" | "symbol_semantic_review_needed" | "multi_requirement_symbol_review" | "duplicate_symbol_coordinate_review" | "component_mixed_purpose_review" | "broad_requirement_review" | "requirement_status_review" | "strict_fact_modeling_review" | "logical_coverage_review" | "kibi_impact_override_missing_rationale" | "entity_id_style_review";
|
|
4
4
|
export interface KibiImpactDiagnostic extends QualityDiagnostic {
|
|
5
5
|
/** Stable staged-enforcement diagnostic identifier. */
|
|
6
6
|
id: KibiImpactDiagnosticId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staged-diagnostics.d.ts","sourceRoot":"","sources":["../../src/traceability/staged-diagnostics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAGL,KAAK,kBAAkB,EAKxB,MAAM,qBAAqB,CAAC;AAQ7B,MAAM,MAAM,sBAAsB,GAC9B,8BAA8B,GAC9B,wBAAwB,GACxB,8BAA8B,GAC9B,+BAA+B,GAC/B,iCAAiC,GACjC,oCAAoC,GACpC,gCAAgC,GAChC,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,GAC7B,yBAAyB,GACzB,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"staged-diagnostics.d.ts","sourceRoot":"","sources":["../../src/traceability/staged-diagnostics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAGL,KAAK,kBAAkB,EAKxB,MAAM,qBAAqB,CAAC;AAQ7B,MAAM,MAAM,sBAAsB,GAC9B,8BAA8B,GAC9B,wBAAwB,GACxB,8BAA8B,GAC9B,+BAA+B,GAC/B,iCAAiC,GACjC,oCAAoC,GACpC,gCAAgC,GAChC,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,GAC7B,yBAAyB,GACzB,wCAAwC,GACxC,wBAAwB,CAAC;AAE7B,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,uDAAuD;IACvD,EAAE,EAAE,sBAAsB,CAAC;IAC3B,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,iEAAiE;IACjE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,gDAAgD;IAChD,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAwID,wBAAgB,wCAAwC,CACtD,QAAQ,EAAE,kBAAkB,GAC3B,oBAAoB,CAoBtB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,kBAAkB,EAC5B,mBAAmB,GAAE,MAAmC,GACvD,oBAAoB,EAAE,CAiDxB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StagedFile } from "./git-staged.js";
|
|
2
|
+
import type { KibiImpactDiagnostic } from "./staged-diagnostics.js";
|
|
3
|
+
/**
|
|
4
|
+
* Naming-style review for entity Markdown that this commit introduces.
|
|
5
|
+
*
|
|
6
|
+
* Only added or renamed files are evaluated: a staged edit to a committed
|
|
7
|
+
* legacy entity such as `REQ-003.md` is never reported, so the legacy numbered
|
|
8
|
+
* lanes stay grandfathered without a cutoff date or history lookup. The
|
|
9
|
+
* diagnostics are advisory and never block a commit.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createStagedEntityIdStyleDiagnostics(stagedFiles: readonly StagedFile[]): KibiImpactDiagnostic[];
|
|
12
|
+
//# sourceMappingURL=staged-entity-id-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staged-entity-id-style.d.ts","sourceRoot":"","sources":["../../src/traceability/staged-entity-id-style.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEpE;;;;;;;GAOG;AAEH,wBAAgB,oCAAoC,CAClD,WAAW,EAAE,SAAS,UAAU,EAAE,GACjC,oBAAoB,EAAE,CAuBxB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { extractFromMarkdownString } from "../extractors/markdown.js";
|
|
19
|
+
import { entityIdStyleIssues } from "../utils/entity-id-style.js";
|
|
20
|
+
import { isEntityLanePath } from "../utils/kb-paths.js";
|
|
21
|
+
/**
|
|
22
|
+
* Naming-style review for entity Markdown that this commit introduces.
|
|
23
|
+
*
|
|
24
|
+
* Only added or renamed files are evaluated: a staged edit to a committed
|
|
25
|
+
* legacy entity such as `REQ-003.md` is never reported, so the legacy numbered
|
|
26
|
+
* lanes stay grandfathered without a cutoff date or history lookup. The
|
|
27
|
+
* diagnostics are advisory and never block a commit.
|
|
28
|
+
*/
|
|
29
|
+
// implements REQ-kibi-entity-id-style
|
|
30
|
+
export function createStagedEntityIdStyleDiagnostics(stagedFiles) {
|
|
31
|
+
const diagnostics = [];
|
|
32
|
+
for (const file of stagedFiles) {
|
|
33
|
+
if (file.status !== "A" && file.status !== "R")
|
|
34
|
+
continue;
|
|
35
|
+
if (!file.path.endsWith(".md") || !isEntityLanePath(file.path))
|
|
36
|
+
continue;
|
|
37
|
+
const id = readEntityId(file);
|
|
38
|
+
if (id === undefined)
|
|
39
|
+
continue;
|
|
40
|
+
for (const issue of entityIdStyleIssues({ id, sourcePath: file.path })) {
|
|
41
|
+
diagnostics.push({
|
|
42
|
+
id: "entity_id_style_review",
|
|
43
|
+
severity: "warning",
|
|
44
|
+
blocking: false,
|
|
45
|
+
category: "naming",
|
|
46
|
+
entityId: id,
|
|
47
|
+
source: file.path,
|
|
48
|
+
files: [file.path],
|
|
49
|
+
docs: ["docs/entity-schema.md"],
|
|
50
|
+
message: issue.message,
|
|
51
|
+
suggestion: issue.suggestion,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return diagnostics;
|
|
56
|
+
}
|
|
57
|
+
function readEntityId(file) {
|
|
58
|
+
if (file.content === undefined)
|
|
59
|
+
return undefined;
|
|
60
|
+
try {
|
|
61
|
+
const id = extractFromMarkdownString(file.content, file.path).entity.id;
|
|
62
|
+
return typeof id === "string" && id.trim() !== "" ? id.trim() : undefined;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Frontmatter errors are reported by staged Markdown validation.
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temp-kb.d.ts","sourceRoot":"","sources":["../../src/traceability/temp-kb.ts"],"names":[],"mappings":"AAMA,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAET;AACD,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,aAAa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ACrB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA6C7E;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,CAkBrE;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BlE"}
|
|
@@ -107,6 +107,14 @@ function serializeTypedFactFields(entity) {
|
|
|
107
107
|
if (ruleIr !== undefined && ruleIr !== null) {
|
|
108
108
|
fields.push(`rule_ir=${toPrologString(JSON.stringify(ruleIr))}`);
|
|
109
109
|
}
|
|
110
|
+
// Predicate-schema vocabularies are objects; like rule_ir they travel as
|
|
111
|
+
// JSON strings and are decoded again at the public boundary.
|
|
112
|
+
for (const field of ["argument_constants", "argument_aliases"]) {
|
|
113
|
+
const value = getEntityField(entity, field);
|
|
114
|
+
if (value !== undefined && value !== null) {
|
|
115
|
+
fields.push(`${field}=${toPrologString(JSON.stringify(value))}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
110
118
|
for (const field of FACT_ATOM_FIELDS) {
|
|
111
119
|
const value = getEntityField(entity, field);
|
|
112
120
|
if (value !== undefined && value !== null) {
|
|
@@ -153,7 +153,7 @@ export function formatViolations(violations) {
|
|
|
153
153
|
const loc = `${v.file}:${v.line}`;
|
|
154
154
|
const name = `${v.name}()`;
|
|
155
155
|
// Suggest adding requirement links with role-specific guidance
|
|
156
|
-
const suggestion = "Add ownership: implements: REQ
|
|
156
|
+
const suggestion = "Add ownership: implements: REQ-<area>-<behavior> (production code), use covered_by for production coverage, or executable_for for executable test code";
|
|
157
157
|
lines.push(`${loc} ${name} -> ${suggestion}`);
|
|
158
158
|
}
|
|
159
159
|
return lines.join("\n");
|
package/dist/types/entities.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface FactFields {
|
|
|
39
39
|
argument_names?: string[];
|
|
40
40
|
argument_types?: string[];
|
|
41
41
|
argument_descriptions?: string[];
|
|
42
|
+
argument_constants?: Record<string, string[]>;
|
|
43
|
+
argument_aliases?: Record<string, Record<string, string>>;
|
|
42
44
|
aliases?: string[];
|
|
43
45
|
examples?: string[];
|
|
44
46
|
predicate_args?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/types/entities.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EACN,SAAS,GACT,gBAAgB,GAChB,aAAa,GACb,MAAM,GACN,kBAAkB,GAClB,WAAW,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;IACtD,UAAU,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,QAAQ,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AM,CAAA;CAAE,CAAC;AACjD,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AACnD,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,MAAM,GACd,WAAW,GACX,QAAQ,GACR,UAAU,GACV,GAAG,GACH,IAAI,GACJ,KAAK,GACL,MAAM,GACN,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface BaseRelationship {
|
|
2
|
-
type: "depends_on" | "specified_by" | "verified_by" | "validates" | "implements" | "covered_by" | "executable_for" | "constrained_by" | "constrains" | "requires_property" | "requires_predicate" | "requires_rule" | "guards" | "publishes" | "consumes" | "supersedes" | "relates_to";
|
|
2
|
+
type: "depends_on" | "specified_by" | "verified_by" | "validates" | "implements" | "covered_by" | "executable_for" | "constrained_by" | "constrains" | "requires_property" | "requires_predicate" | "requires_rule" | "guards" | "publishes" | "consumes" | "supersedes" | "restates" | "relates_to";
|
|
3
3
|
from: string;
|
|
4
4
|
to: string;
|
|
5
5
|
created_at?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/types/relationships.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,YAAY,GACZ,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,QAAQ,GACR,WAAW,GACX,UAAU,GACV,YAAY,GACZ,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAe,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/types/relationships.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,YAAY,GACZ,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,QAAQ,GACR,WAAW,GACX,UAAU,GACV,YAAY,GACZ,UAAU,GACV,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Purely numeric entity ID such as `REQ-001` or `ADR-12`. */
|
|
2
|
+
export declare const NUMERIC_ENTITY_ID_PATTERN: RegExp;
|
|
3
|
+
export type EntityIdStyleIssue = Readonly<{
|
|
4
|
+
code: "numeric_id" | "stem_mismatch";
|
|
5
|
+
message: string;
|
|
6
|
+
suggestion: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function isNumericEntityId(id: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Filename stem for an authored Markdown source, or undefined for non-Markdown
|
|
11
|
+
* sources (symbol manifests, code files, runtime `mcp://` provenance).
|
|
12
|
+
*/
|
|
13
|
+
export declare function markdownSourceStem(sourcePath: string | undefined): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Style issues for one newly created entity. Callers decide whether the entity
|
|
16
|
+
* is new; this function never inspects the KB.
|
|
17
|
+
*/
|
|
18
|
+
export declare function entityIdStyleIssues(input: {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly sourcePath?: string | undefined;
|
|
21
|
+
}): EntityIdStyleIssue[];
|
|
22
|
+
/** Plain-text warnings for mutation receipts. */
|
|
23
|
+
export declare function entityIdStyleWarnings(input: {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly sourcePath?: string | undefined;
|
|
26
|
+
}): string[];
|
|
27
|
+
//# sourceMappingURL=entity-id-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-id-style.d.ts","sourceRoot":"","sources":["../../src/utils/entity-id-style.ts"],"names":[],"mappings":"AAiCA,8DAA8D;AAE9D,eAAO,MAAM,yBAAyB,QAAiB,CAAC;AAGxD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,YAAY,GAAG,eAAe,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAGH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;GAGG;AAEH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,MAAM,GAAG,SAAS,CAOpB;AAED;;;GAGG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,GAAG,kBAAkB,EAAE,CAoBvB;AAED,iDAAiD;AAEjD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,GAAG,MAAM,EAAE,CAIX"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Entity naming style (`entity-id-style`).
|
|
20
|
+
*
|
|
21
|
+
* Entities are named by what they govern (`REQ-cli-gc`), never by "the next
|
|
22
|
+
* number". The compiled KB cannot tell a legacy numbered entity from a new one
|
|
23
|
+
* (`created_at` is stamped at sync time when frontmatter omits it), so purely
|
|
24
|
+
* numeric IDs are reported only at creation boundaries: a `kb_upsert` that
|
|
25
|
+
* creates the entity, and staged added/renamed entity Markdown. Committed
|
|
26
|
+
* legacy entities such as `REQ-003` are therefore never flagged. The Prolog
|
|
27
|
+
* half of the rule (`check_entity_id_style/1`) reports filename-stem/`id`
|
|
28
|
+
* mismatches over the whole KB.
|
|
29
|
+
*/
|
|
30
|
+
import * as path from "node:path";
|
|
31
|
+
/** Purely numeric entity ID such as `REQ-001` or `ADR-12`. */
|
|
32
|
+
// implements REQ-kibi-entity-id-style
|
|
33
|
+
export const NUMERIC_ENTITY_ID_PATTERN = /^[A-Z]+-\d+$/;
|
|
34
|
+
// implements REQ-kibi-entity-id-style
|
|
35
|
+
export function isNumericEntityId(id) {
|
|
36
|
+
return NUMERIC_ENTITY_ID_PATTERN.test(id.trim());
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Filename stem for an authored Markdown source, or undefined for non-Markdown
|
|
40
|
+
* sources (symbol manifests, code files, runtime `mcp://` provenance).
|
|
41
|
+
*/
|
|
42
|
+
// implements REQ-kibi-entity-id-style
|
|
43
|
+
export function markdownSourceStem(sourcePath) {
|
|
44
|
+
if (sourcePath === undefined)
|
|
45
|
+
return undefined;
|
|
46
|
+
const normalized = sourcePath.trim().replaceAll("\\", "/");
|
|
47
|
+
if (!normalized.endsWith(".md") || normalized.includes("://")) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return path.posix.basename(normalized, ".md");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Style issues for one newly created entity. Callers decide whether the entity
|
|
54
|
+
* is new; this function never inspects the KB.
|
|
55
|
+
*/
|
|
56
|
+
// implements REQ-kibi-entity-id-style
|
|
57
|
+
export function entityIdStyleIssues(input) {
|
|
58
|
+
const id = input.id.trim();
|
|
59
|
+
const issues = [];
|
|
60
|
+
if (isNumericEntityId(id)) {
|
|
61
|
+
issues.push({
|
|
62
|
+
code: "numeric_id",
|
|
63
|
+
message: `Entity ID ${id} is a sequence number; parallel branches pick the same next number and collide.`,
|
|
64
|
+
suggestion: "Name the entity by what it governs: <TYPE>-<area>-<behavior> in kebab-case (for example REQ-cli-gc). kb_search the area first and update or supersede an existing entity when one already covers the behavior.",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const stem = markdownSourceStem(input.sourcePath);
|
|
68
|
+
if (stem !== undefined && stem !== id) {
|
|
69
|
+
issues.push({
|
|
70
|
+
code: "stem_mismatch",
|
|
71
|
+
message: `Entity ID ${id} does not match its filename stem ${stem}.`,
|
|
72
|
+
suggestion: `Rename the file to ${id}.md or set frontmatter id: ${stem} so the file name and identity stay aligned.`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return issues;
|
|
76
|
+
}
|
|
77
|
+
/** Plain-text warnings for mutation receipts. */
|
|
78
|
+
// implements REQ-kibi-entity-id-style
|
|
79
|
+
export function entityIdStyleWarnings(input) {
|
|
80
|
+
return entityIdStyleIssues(input).map((issue) => `entity-id-style: ${issue.message} ${issue.suggestion}`);
|
|
81
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface GitRepositoryContext {
|
|
2
|
+
/** Root of the current working tree (the worktree, when linked). */
|
|
3
|
+
worktreeRoot: string;
|
|
4
|
+
/** Absolute Git directory of the current worktree. */
|
|
5
|
+
gitDir: string;
|
|
6
|
+
/** Absolute repository-common Git directory (shared across worktrees). */
|
|
7
|
+
commonGitDir: string;
|
|
8
|
+
/** Absolute hooks directory Git will actually execute (honors core.hooksPath). */
|
|
9
|
+
effectiveHooksDir: string;
|
|
10
|
+
isLinkedWorktree: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Primary checkout root, only when it can be validated as a real checkout
|
|
13
|
+
* (`git -C <candidate> rev-parse --show-toplevel` resolves to the
|
|
14
|
+
* candidate). Null for bare repositories, separate-git-dir layouts, and any
|
|
15
|
+
* candidate that is not itself a working tree.
|
|
16
|
+
*/
|
|
17
|
+
primaryWorktreeRoot: string | null;
|
|
18
|
+
/** Raw core.hooksPath value when configured, else null. */
|
|
19
|
+
hooksPathConfig: string | null;
|
|
20
|
+
/** Config origin line (from --show-origin) for the configured hooksPath. */
|
|
21
|
+
hooksPathOrigin: string | null;
|
|
22
|
+
}
|
|
23
|
+
export type GitRepositoryResolution = {
|
|
24
|
+
status: "ok";
|
|
25
|
+
context: GitRepositoryContext;
|
|
26
|
+
} | {
|
|
27
|
+
status: "not-a-repository";
|
|
28
|
+
} | {
|
|
29
|
+
status: "git-unavailable";
|
|
30
|
+
} | {
|
|
31
|
+
status: "git-refused";
|
|
32
|
+
/** First Git diagnostic (or fs detail) explaining the refusal. */
|
|
33
|
+
reason: string;
|
|
34
|
+
} | {
|
|
35
|
+
status: "unsupported";
|
|
36
|
+
reason: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the effective Git repository context for `cwd` by asking Git
|
|
40
|
+
* instead of assuming `<cwd>/.git`. The result distinguishes "no repository"
|
|
41
|
+
* (callers may fall back to standalone-workspace behavior) from repositories
|
|
42
|
+
* Kibi must not touch (bare repositories) and directories where Git refused
|
|
43
|
+
* operationally (dubious ownership, unreadable `.git`, access failures) — the
|
|
44
|
+
* last must never be mistaken for "no repository", because that would send
|
|
45
|
+
* callers into standalone workspace writes.
|
|
46
|
+
*
|
|
47
|
+
* implements REQ-git-hook-effective-install
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveGitRepository(cwd?: string): GitRepositoryResolution;
|
|
50
|
+
//# sourceMappingURL=git-repository-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-repository-context.d.ts","sourceRoot":"","sources":["../../src/utils/git-repository-context.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,2DAA2D;IAC3D,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,4EAA4E;IAC5E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,MAAM,uBAAuB,GAC/B;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,GAC/C;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAC9B;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAC7B;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAqH9C;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAsB,GAC1B,uBAAuB,CAmJzB"}
|