kibi-plugin-builtin 0.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/CHANGELOG.md +53 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/ontology/builtin-ontology-pack.d.ts +11 -0
- package/dist/ontology/builtin-ontology-pack.d.ts.map +1 -0
- package/dist/ontology/builtin-ontology-pack.js +78 -0
- package/dist/ontology/normalize.d.ts +7 -0
- package/dist/ontology/normalize.d.ts.map +1 -0
- package/dist/ontology/normalize.js +55 -0
- package/dist/ontology/predicate-rule.d.ts +26 -0
- package/dist/ontology/predicate-rule.d.ts.map +1 -0
- package/dist/ontology/predicate-rule.js +55 -0
- package/dist/ontology/predicate-rules-core.d.ts +94 -0
- package/dist/ontology/predicate-rules-core.d.ts.map +1 -0
- package/dist/ontology/predicate-rules-core.js +156 -0
- package/dist/ontology/predicate-rules-launcher.d.ts +58 -0
- package/dist/ontology/predicate-rules-launcher.d.ts.map +1 -0
- package/dist/ontology/predicate-rules-launcher.js +105 -0
- package/dist/ontology/predicate-rules-policy.d.ts +99 -0
- package/dist/ontology/predicate-rules-policy.d.ts.map +1 -0
- package/dist/ontology/predicate-rules-policy.js +167 -0
- package/dist/ontology/predicate-rules-product-tail.d.ts +57 -0
- package/dist/ontology/predicate-rules-product-tail.d.ts.map +1 -0
- package/dist/ontology/predicate-rules-product-tail.js +112 -0
- package/dist/ontology/predicate-rules-product.d.ts +84 -0
- package/dist/ontology/predicate-rules-product.d.ts.map +1 -0
- package/dist/ontology/predicate-rules-product.js +147 -0
- package/dist/semantic/builtin-classifier.d.ts +22 -0
- package/dist/semantic/builtin-classifier.d.ts.map +1 -0
- package/dist/semantic/builtin-classifier.js +134 -0
- package/dist/symbols/ts-morph-enrichment.d.ts +21 -0
- package/dist/symbols/ts-morph-enrichment.d.ts.map +1 -0
- package/dist/symbols/ts-morph-enrichment.js +371 -0
- package/dist/symbols/ts-morph-extractor.d.ts +8 -0
- package/dist/symbols/ts-morph-extractor.d.ts.map +1 -0
- package/dist/symbols/ts-morph-extractor.js +229 -0
- package/dist/symbols/ts-morph-granularity.d.ts +11 -0
- package/dist/symbols/ts-morph-granularity.d.ts.map +1 -0
- package/dist/symbols/ts-morph-granularity.js +98 -0
- package/dist/symbols/ts-morph-shared.d.ts +15 -0
- package/dist/symbols/ts-morph-shared.d.ts.map +1 -0
- package/dist/symbols/ts-morph-shared.js +71 -0
- package/package.json +42 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# kibi-plugin-builtin
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 783cc75: Coordinate enrichment, granularity candidate collection, and private-member helpers now live in `kibi-plugin-builtin`, so the CLI can analyze TypeScript/JavaScript symbols without depending on `ts-morph` directly. Hosts that only install `kibi-cli` still get the same enrichment and staged-symbol behavior through the builtin plugin.
|
|
8
|
+
|
|
9
|
+
- Export `enrichSymbolCoordinatesWithTsMorph`, `collectGranularityCandidates`, `onlyCandidate`, and `isPrivateClassMember` from `kibi-plugin-builtin`
|
|
10
|
+
- Thin-wrap those helpers from CLI `symbols-ts`, `symbol-granularity`, and `symbol-extract`
|
|
11
|
+
- Drop `ts-morph` from `kibi-cli` runtime dependencies (kept as a test-only devDependency for AST spies)
|
|
12
|
+
|
|
13
|
+
- 783cc75: Kibi ships a default capability plugin package so TypeScript symbol extraction, ontology matching, and semantic lane classification live behind the public plugin protocol instead of private CLI paths.
|
|
14
|
+
|
|
15
|
+
- Add `kibi-plugin-builtin@0.1.0` with `kibiPlugin` exporting all three capabilities
|
|
16
|
+
- Built-in ts-morph extractor, ontology pack (launcher→core→policy→product→product-tail), and sync semantic classifier
|
|
17
|
+
- CLI depends on this package and thin-wraps the extractor / ontology pack for default parity
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- b375e8f: This maintenance update brings the affected package code and tests into line with Kibi's Biome checks while preserving runtime behavior. It also replaces MCP non-null assertions with receiver-preserving method calls.
|
|
22
|
+
|
|
23
|
+
- Format affected files, sort imports, and remove unnecessary template literals.
|
|
24
|
+
- Preserve EngineClient `this` when forwarding optional Prolog methods.
|
|
25
|
+
|
|
26
|
+
- e6571b4: External classifiers stay limited to the two allowlisted operations, ontology matches keep their claim keys through host composition, and CLI predicate rule tables now re-export the builtin pack so advisor and modeling cannot drift. Lane selection from the builtin classifier also accepts host snake_case signal shapes, which unblocks typecheck/build for capability-plugin call sites.
|
|
27
|
+
|
|
28
|
+
- fix(builtin): chooseLane accepts kind-only LaneSignal (unblocks analysis-receipt typecheck)
|
|
29
|
+
- feat(cli): stamp claimKey on composed ontology match candidates
|
|
30
|
+
- refactor(cli): re-export predicate rule tables from kibi-plugin-builtin
|
|
31
|
+
- chore(builtin): export rule sets + package.json subpath
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [e6be0cc]
|
|
34
|
+
- Updated dependencies [8985874]
|
|
35
|
+
- Updated dependencies [783cc75]
|
|
36
|
+
- kibi-plugin-sdk@0.2.0
|
|
37
|
+
|
|
38
|
+
## Unreleased
|
|
39
|
+
|
|
40
|
+
### Minor Changes
|
|
41
|
+
|
|
42
|
+
- Export TypeScript coordinate enrichment, granularity candidate collection,
|
|
43
|
+
and private-member helpers so hosts (including `kibi-cli`) can drop a direct
|
|
44
|
+
`ts-morph` dependency while keeping the same analysis behavior.
|
|
45
|
+
|
|
46
|
+
## 0.1.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- Initial default capability plugin package: built-in TypeScript/JavaScript
|
|
51
|
+
symbol extractor (`ts-morph`), ontology pack (launcher → core → policy →
|
|
52
|
+
product → product-tail predicate rules), and deterministic semantic
|
|
53
|
+
classifier (signal patterns + lane choice).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { createBuiltinOntologyPack } from "./ontology/builtin-ontology-pack.js";
|
|
2
|
+
export { BuiltinOntologyPack, BUILTIN_PREDICATE_RULE_SETS, } from "./ontology/builtin-ontology-pack.js";
|
|
3
|
+
export { detectPredicateRules, schemaIdFor, type PredicateRule, } from "./ontology/predicate-rule.js";
|
|
4
|
+
export { CORE_PREDICATE_RULES } from "./ontology/predicate-rules-core.js";
|
|
5
|
+
export { LAUNCHER_PREDICATE_RULES, exactLauncherPredicateArgs, } from "./ontology/predicate-rules-launcher.js";
|
|
6
|
+
export { POLICY_PREDICATE_RULES } from "./ontology/predicate-rules-policy.js";
|
|
7
|
+
export { PRODUCT_PREDICATE_RULES } from "./ontology/predicate-rules-product.js";
|
|
8
|
+
export { PRODUCT_TAIL_PREDICATE_RULES } from "./ontology/predicate-rules-product-tail.js";
|
|
9
|
+
export { normalizeKey, normalizePredicateToken, normalizeSubjectKey, singularize, commaList, } from "./ontology/normalize.js";
|
|
10
|
+
export { createBuiltinSemanticClassifier, BuiltinSemanticClassifier, detectSignals, chooseLane, } from "./semantic/builtin-classifier.js";
|
|
11
|
+
export { createBuiltinTsMorphSymbolExtractor, createBuiltinTsMorphSourceAnalysisProvider, } from "./symbols/ts-morph-extractor.js";
|
|
12
|
+
export { enrichSymbolCoordinatesWithTsMorph, type ManifestSymbolEntry, type SymbolCoordinates, } from "./symbols/ts-morph-enrichment.js";
|
|
13
|
+
export { collectGranularityCandidates, type GranularitySymbolCandidate, } from "./symbols/ts-morph-granularity.js";
|
|
14
|
+
export { isPrivateClassMember, onlyCandidate, } from "./symbols/ts-morph-shared.js";
|
|
15
|
+
/**
|
|
16
|
+
* Default Kibi capability plugin.
|
|
17
|
+
*/
|
|
18
|
+
export declare const kibiPlugin: {
|
|
19
|
+
apiVersion: "kibi.plugin.v1";
|
|
20
|
+
id: string;
|
|
21
|
+
version: string;
|
|
22
|
+
permissions: {
|
|
23
|
+
network: false;
|
|
24
|
+
metered: false;
|
|
25
|
+
secrets: never[];
|
|
26
|
+
};
|
|
27
|
+
capabilities: {
|
|
28
|
+
semanticClassifier: import("kibi-plugin-sdk").SemanticClassifierV1;
|
|
29
|
+
ontologyPack: import("kibi-plugin-sdk").OntologyPackV1;
|
|
30
|
+
symbolExtractor: import("kibi-plugin-sdk").SymbolExtractorV1;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export default kibiPlugin;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,KAAK,aAAa,GACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAE1F,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,WAAW,EACX,SAAS,GACV,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,+BAA+B,EAC/B,yBAAyB,EACzB,aAAa,EACb,UAAU,GACX,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mCAAmC,EACnC,0CAA0C,GAC3C,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,kCAAkC,EAClC,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,4BAA4B,EAC5B,KAAK,0BAA0B,GAChC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,oBAAoB,EACpB,aAAa,GACd,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;CAcrB,CAAC;AAGH,eAAe,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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 { createRequire } from "node:module";
|
|
19
|
+
import { KIBI_PLUGIN_API_VERSION, defineKibiPlugin } from "kibi-plugin-sdk";
|
|
20
|
+
import { createBuiltinOntologyPack } from "./ontology/builtin-ontology-pack.js";
|
|
21
|
+
import { createBuiltinSemanticClassifier } from "./semantic/builtin-classifier.js";
|
|
22
|
+
import { createBuiltinTsMorphSymbolExtractor } from "./symbols/ts-morph-extractor.js";
|
|
23
|
+
const packageJson = createRequire(import.meta.url)("../package.json");
|
|
24
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
25
|
+
export { createBuiltinOntologyPack } from "./ontology/builtin-ontology-pack.js";
|
|
26
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
27
|
+
export { BuiltinOntologyPack, BUILTIN_PREDICATE_RULE_SETS, } from "./ontology/builtin-ontology-pack.js";
|
|
28
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
29
|
+
export { detectPredicateRules, schemaIdFor, } from "./ontology/predicate-rule.js";
|
|
30
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
31
|
+
export { CORE_PREDICATE_RULES } from "./ontology/predicate-rules-core.js";
|
|
32
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
33
|
+
export { LAUNCHER_PREDICATE_RULES, exactLauncherPredicateArgs, } from "./ontology/predicate-rules-launcher.js";
|
|
34
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
35
|
+
export { POLICY_PREDICATE_RULES } from "./ontology/predicate-rules-policy.js";
|
|
36
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
37
|
+
export { PRODUCT_PREDICATE_RULES } from "./ontology/predicate-rules-product.js";
|
|
38
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
39
|
+
export { PRODUCT_TAIL_PREDICATE_RULES } from "./ontology/predicate-rules-product-tail.js";
|
|
40
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
41
|
+
export { normalizeKey, normalizePredicateToken, normalizeSubjectKey, singularize, commaList, } from "./ontology/normalize.js";
|
|
42
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
43
|
+
export { createBuiltinSemanticClassifier, BuiltinSemanticClassifier, detectSignals, chooseLane, } from "./semantic/builtin-classifier.js";
|
|
44
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
45
|
+
export { createBuiltinTsMorphSymbolExtractor, createBuiltinTsMorphSourceAnalysisProvider, } from "./symbols/ts-morph-extractor.js";
|
|
46
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
47
|
+
export { enrichSymbolCoordinatesWithTsMorph, } from "./symbols/ts-morph-enrichment.js";
|
|
48
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
49
|
+
export { collectGranularityCandidates, } from "./symbols/ts-morph-granularity.js";
|
|
50
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
51
|
+
export { isPrivateClassMember, onlyCandidate, } from "./symbols/ts-morph-shared.js";
|
|
52
|
+
/**
|
|
53
|
+
* Default Kibi capability plugin.
|
|
54
|
+
*/
|
|
55
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
56
|
+
export const kibiPlugin = defineKibiPlugin({
|
|
57
|
+
apiVersion: KIBI_PLUGIN_API_VERSION,
|
|
58
|
+
id: "kibi-plugin-builtin",
|
|
59
|
+
version: packageJson.version,
|
|
60
|
+
permissions: {
|
|
61
|
+
network: false,
|
|
62
|
+
metered: false,
|
|
63
|
+
secrets: [],
|
|
64
|
+
},
|
|
65
|
+
capabilities: {
|
|
66
|
+
semanticClassifier: createBuiltinSemanticClassifier(),
|
|
67
|
+
ontologyPack: createBuiltinOntologyPack(),
|
|
68
|
+
symbolExtractor: createBuiltinTsMorphSymbolExtractor(),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
72
|
+
export default kibiPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OntologyMatchCandidate, OntologyMatchContext, OntologyPackV1, PredicateSchemaDefinition } from "kibi-plugin-sdk";
|
|
2
|
+
import { type PredicateRule } from "./predicate-rule.js";
|
|
3
|
+
/** Same evaluation order as CLI analyze-prose predicate detection. */
|
|
4
|
+
export declare const BUILTIN_PREDICATE_RULE_SETS: readonly (readonly PredicateRule[])[];
|
|
5
|
+
export declare class BuiltinOntologyPack implements OntologyPackV1 {
|
|
6
|
+
readonly id = "kibi-plugin-builtin.ontology";
|
|
7
|
+
schemas(): readonly PredicateSchemaDefinition[];
|
|
8
|
+
match(input: OntologyMatchContext): readonly OntologyMatchCandidate[];
|
|
9
|
+
}
|
|
10
|
+
export declare function createBuiltinOntologyPack(): OntologyPackV1;
|
|
11
|
+
//# sourceMappingURL=builtin-ontology-pack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-ontology-pack.d.ts","sourceRoot":"","sources":["../../src/ontology/builtin-ontology-pack.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAO7B,sEAAsE;AAEtE,eAAO,MAAM,2BAA2B,EAAE,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,EAO1E,CAAC;AAiCJ,qBAAa,mBAAoB,YAAW,cAAc;IACxD,QAAQ,CAAC,EAAE,kCAAkC;IAE7C,OAAO,IAAI,SAAS,yBAAyB,EAAE;IAI/C,KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,sBAAsB,EAAE;CAStE;AAGD,wBAAgB,yBAAyB,IAAI,cAAc,CAE1D"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 { detectPredicateRules, schemaIdFor, } from "./predicate-rule.js";
|
|
19
|
+
import { CORE_PREDICATE_RULES } from "./predicate-rules-core.js";
|
|
20
|
+
import { LAUNCHER_PREDICATE_RULES } from "./predicate-rules-launcher.js";
|
|
21
|
+
import { POLICY_PREDICATE_RULES } from "./predicate-rules-policy.js";
|
|
22
|
+
import { PRODUCT_TAIL_PREDICATE_RULES } from "./predicate-rules-product-tail.js";
|
|
23
|
+
import { PRODUCT_PREDICATE_RULES } from "./predicate-rules-product.js";
|
|
24
|
+
/** Same evaluation order as CLI analyze-prose predicate detection. */
|
|
25
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
26
|
+
export const BUILTIN_PREDICATE_RULE_SETS = [
|
|
27
|
+
LAUNCHER_PREDICATE_RULES,
|
|
28
|
+
CORE_PREDICATE_RULES,
|
|
29
|
+
POLICY_PREDICATE_RULES,
|
|
30
|
+
PRODUCT_PREDICATE_RULES,
|
|
31
|
+
PRODUCT_TAIL_PREDICATE_RULES,
|
|
32
|
+
];
|
|
33
|
+
function deriveSchemas(ruleSets) {
|
|
34
|
+
const byId = new Map();
|
|
35
|
+
for (const rules of ruleSets) {
|
|
36
|
+
for (const rule of rules) {
|
|
37
|
+
const schemaId = rule.catalogSchemaId ?? schemaIdFor(rule.name, rule.arity);
|
|
38
|
+
if (byId.has(schemaId))
|
|
39
|
+
continue;
|
|
40
|
+
const argumentNames = rule.argumentNames ??
|
|
41
|
+
Array.from({ length: rule.arity }, (_, i) => `arg${i}`);
|
|
42
|
+
const argumentTypes = rule.argumentTypes ??
|
|
43
|
+
Array.from({ length: rule.arity }, () => "string");
|
|
44
|
+
byId.set(schemaId, {
|
|
45
|
+
schemaId,
|
|
46
|
+
predicateName: rule.name,
|
|
47
|
+
argumentNames,
|
|
48
|
+
argumentTypes,
|
|
49
|
+
title: rule.name,
|
|
50
|
+
description: rule.rationale,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return [...byId.values()];
|
|
55
|
+
}
|
|
56
|
+
const BUILTIN_SCHEMAS = deriveSchemas(BUILTIN_PREDICATE_RULE_SETS);
|
|
57
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
58
|
+
export class BuiltinOntologyPack {
|
|
59
|
+
id = "kibi-plugin-builtin.ontology";
|
|
60
|
+
schemas() {
|
|
61
|
+
return BUILTIN_SCHEMAS;
|
|
62
|
+
}
|
|
63
|
+
match(input) {
|
|
64
|
+
const statement = input.statement.trim();
|
|
65
|
+
if (!statement)
|
|
66
|
+
return [];
|
|
67
|
+
for (const rules of BUILTIN_PREDICATE_RULE_SETS) {
|
|
68
|
+
const hits = detectPredicateRules(statement, rules);
|
|
69
|
+
if (hits.length > 0)
|
|
70
|
+
return hits;
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
76
|
+
export function createBuiltinOntologyPack() {
|
|
77
|
+
return new BuiltinOntologyPack();
|
|
78
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Copied from CLI semantic-advisor shared helpers — do not import from kibi-cli. */
|
|
2
|
+
export declare function normalizeKey(value: string): string;
|
|
3
|
+
export declare function normalizePredicateToken(value: string): string;
|
|
4
|
+
export declare function singularize(value: string): string;
|
|
5
|
+
export declare function normalizeSubjectKey(value: string): string;
|
|
6
|
+
export declare function commaList(value: string, separator?: RegExp): string;
|
|
7
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/ontology/normalize.ts"],"names":[],"mappings":"AAkBA,qFAAqF;AAGrF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOlD;AAGD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ7D;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjD;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAGD,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,MAAqB,GAC/B,MAAM,CAMR"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
/** Copied from CLI semantic-advisor shared helpers — do not import from kibi-cli. */
|
|
19
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
20
|
+
export function normalizeKey(value) {
|
|
21
|
+
return value
|
|
22
|
+
.trim()
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replace(/['’]/g, "")
|
|
25
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
26
|
+
.replace(/^_+|_+$/g, "");
|
|
27
|
+
}
|
|
28
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
29
|
+
export function normalizePredicateToken(value) {
|
|
30
|
+
return value
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/\b(?:a|an|the)\b\s*/gi, "")
|
|
33
|
+
.replace(/['’]/g, "")
|
|
34
|
+
.replace(/\s+/g, "_")
|
|
35
|
+
.replace(/[^A-Za-z0-9_-]+/g, "_")
|
|
36
|
+
.replace(/^_+|_+$/g, "");
|
|
37
|
+
}
|
|
38
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
39
|
+
export function singularize(value) {
|
|
40
|
+
if (["status", "results"].includes(value))
|
|
41
|
+
return value;
|
|
42
|
+
return value.endsWith("s") && value.length > 3 ? value.slice(0, -1) : value;
|
|
43
|
+
}
|
|
44
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
45
|
+
export function normalizeSubjectKey(value) {
|
|
46
|
+
return normalizeKey(value).split("_").map(singularize).join(".");
|
|
47
|
+
}
|
|
48
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
49
|
+
export function commaList(value, separator = /,|\band\b/i) {
|
|
50
|
+
return value
|
|
51
|
+
.split(separator)
|
|
52
|
+
.map((part) => normalizeKey(part.trim()))
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.join(",");
|
|
55
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { OntologyMatchCandidate } from "kibi-plugin-sdk";
|
|
2
|
+
import { commaList, normalizeKey, normalizePredicateToken, normalizeSubjectKey, singularize } from "./normalize.js";
|
|
3
|
+
export { commaList, normalizeKey, normalizePredicateToken, normalizeSubjectKey, singularize, };
|
|
4
|
+
export type MatchGroups = Readonly<Record<string, string | undefined>>;
|
|
5
|
+
export interface PredicateRule {
|
|
6
|
+
readonly pattern: RegExp;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly args: (groups: MatchGroups) => readonly string[];
|
|
9
|
+
readonly rationale: string;
|
|
10
|
+
/** Declared argument count; must match args() length. Do not probe via args({}). */
|
|
11
|
+
readonly arity: number;
|
|
12
|
+
readonly argumentNames?: readonly string[];
|
|
13
|
+
readonly argumentTypes?: readonly string[];
|
|
14
|
+
/** Optional rich catalog schema id (e.g. FACT-SCHEMA-GUARD). */
|
|
15
|
+
readonly catalogSchemaId?: string;
|
|
16
|
+
readonly polarity?: "assert" | "deny";
|
|
17
|
+
readonly accepts?: (statement: string) => boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const BUILTIN_PREDICATE_CONFIDENCE = 0.84;
|
|
20
|
+
export declare function schemaIdFor(predicateName: string, arity: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* First-match semantics (identical to CLI detectPredicateRules): return at most
|
|
23
|
+
* one candidate from the given rule set.
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectPredicateRules(statement: string, rules: readonly PredicateRule[]): OntologyMatchCandidate[];
|
|
26
|
+
//# sourceMappingURL=predicate-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicate-rule.d.ts","sourceRoot":"","sources":["../../src/ontology/predicate-rule.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,SAAS,EACT,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,WAAW,GACZ,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAGvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,SAAS,MAAM,EAAE,CAAC;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,gEAAgE;IAChE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CACnD;AAGD,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAGjD,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;GAGG;AAEH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,aAAa,EAAE,GAC9B,sBAAsB,EAAE,CAwB1B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { commaList, normalizeKey, normalizePredicateToken, normalizeSubjectKey, singularize, } from "./normalize.js";
|
|
19
|
+
export { commaList, normalizeKey, normalizePredicateToken, normalizeSubjectKey, singularize, };
|
|
20
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
21
|
+
export const BUILTIN_PREDICATE_CONFIDENCE = 0.84;
|
|
22
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
23
|
+
export function schemaIdFor(predicateName, arity) {
|
|
24
|
+
return `builtin.${predicateName}.${arity}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* First-match semantics (identical to CLI detectPredicateRules): return at most
|
|
28
|
+
* one candidate from the given rule set.
|
|
29
|
+
*/
|
|
30
|
+
// implements REQ-capability-plugin-builtin-parity-v1
|
|
31
|
+
export function detectPredicateRules(statement, rules) {
|
|
32
|
+
for (const rule of rules) {
|
|
33
|
+
if (rule.accepts && !rule.accepts(statement))
|
|
34
|
+
continue;
|
|
35
|
+
const match = statement.match(rule.pattern);
|
|
36
|
+
if (!match?.groups)
|
|
37
|
+
continue;
|
|
38
|
+
const args = rule.args(match.groups);
|
|
39
|
+
if (args.length !== rule.arity) {
|
|
40
|
+
throw new Error(`Predicate rule '${rule.name}' arity mismatch: declared ${rule.arity}, args() returned ${args.length}`);
|
|
41
|
+
}
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
schemaId: rule.catalogSchemaId ?? schemaIdFor(rule.name, rule.arity),
|
|
45
|
+
predicateName: rule.name,
|
|
46
|
+
arguments: args,
|
|
47
|
+
polarity: rule.polarity ?? "assert",
|
|
48
|
+
confidence: BUILTIN_PREDICATE_CONFIDENCE,
|
|
49
|
+
evidence: match[0],
|
|
50
|
+
rationale: rule.rationale,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { commaList } from "./predicate-rule.js";
|
|
2
|
+
export declare const CORE_PREDICATE_RULES: readonly [{
|
|
3
|
+
readonly pattern: RegExp;
|
|
4
|
+
readonly name: "guard";
|
|
5
|
+
readonly arity: 3;
|
|
6
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
7
|
+
readonly rationale: "Disabled-until prose defines a condition that guards behavior availability and should be queryable as a predicate.";
|
|
8
|
+
}, {
|
|
9
|
+
readonly pattern: RegExp;
|
|
10
|
+
readonly name: "temporal_order";
|
|
11
|
+
readonly arity: 3;
|
|
12
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
13
|
+
readonly rationale: "Before/after ordering is relational temporal logic and should be modeled as a predicate.";
|
|
14
|
+
}, {
|
|
15
|
+
readonly pattern: RegExp;
|
|
16
|
+
readonly name: "conditional_behavior";
|
|
17
|
+
readonly arity: 3;
|
|
18
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
19
|
+
readonly rationale: "If/then requirement prose is conditional behavior and should be queryable as a predicate.";
|
|
20
|
+
}, {
|
|
21
|
+
readonly pattern: RegExp;
|
|
22
|
+
readonly name: "conditional_behavior";
|
|
23
|
+
readonly arity: 3;
|
|
24
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
25
|
+
readonly rationale: "When/must prose is conditional behavior and should be queryable as a predicate.";
|
|
26
|
+
}, {
|
|
27
|
+
readonly pattern: RegExp;
|
|
28
|
+
readonly name: "exception_rule";
|
|
29
|
+
readonly arity: 3;
|
|
30
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
31
|
+
readonly rationale: "Unless/except prose defines an explicit exception to required behavior and should be queryable as a predicate.";
|
|
32
|
+
}, {
|
|
33
|
+
readonly pattern: RegExp;
|
|
34
|
+
readonly name: "mutual_exclusion";
|
|
35
|
+
readonly arity: 2;
|
|
36
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
37
|
+
readonly rationale: "Mutual-exclusion prose is a relational constraint and should be queryable as a predicate.";
|
|
38
|
+
}, {
|
|
39
|
+
readonly pattern: RegExp;
|
|
40
|
+
readonly name: "dependency_rule";
|
|
41
|
+
readonly arity: 3;
|
|
42
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
43
|
+
readonly rationale: "Requires-before prose defines a prerequisite relationship and should be queryable as a predicate.";
|
|
44
|
+
}, {
|
|
45
|
+
readonly pattern: RegExp;
|
|
46
|
+
readonly name: "ownership_rule";
|
|
47
|
+
readonly arity: 2;
|
|
48
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
49
|
+
readonly rationale: "Ownership prose assigns responsibility for a resource or behavior and should be queryable as a predicate.";
|
|
50
|
+
}, {
|
|
51
|
+
readonly pattern: RegExp;
|
|
52
|
+
readonly name: "merge_policy";
|
|
53
|
+
readonly arity: 3;
|
|
54
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
55
|
+
readonly rationale: "Same-slot merge prose defines ontology-lite merge behavior and should be queryable as a predicate.";
|
|
56
|
+
}, {
|
|
57
|
+
readonly pattern: RegExp;
|
|
58
|
+
readonly name: "retry_policy";
|
|
59
|
+
readonly arity: 3;
|
|
60
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
61
|
+
readonly rationale: "Retry prose defines bounded recovery behavior and should be queryable as a predicate.";
|
|
62
|
+
}, {
|
|
63
|
+
readonly pattern: RegExp;
|
|
64
|
+
readonly name: "escalation_rule";
|
|
65
|
+
readonly arity: 4;
|
|
66
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
67
|
+
readonly rationale: "Escalation prose defines delayed handoff behavior and should be queryable as a predicate.";
|
|
68
|
+
}, {
|
|
69
|
+
readonly pattern: RegExp;
|
|
70
|
+
readonly name: "availability_sla";
|
|
71
|
+
readonly arity: 4;
|
|
72
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
73
|
+
readonly rationale: "Availability SLA prose defines a service target over a window and should be queryable as a predicate.";
|
|
74
|
+
}, {
|
|
75
|
+
readonly pattern: RegExp;
|
|
76
|
+
readonly name: "notification_route";
|
|
77
|
+
readonly arity: 3;
|
|
78
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
79
|
+
readonly rationale: "Notification routing prose defines a recipient and channel and should be queryable as a predicate.";
|
|
80
|
+
}, {
|
|
81
|
+
readonly pattern: RegExp;
|
|
82
|
+
readonly name: "idempotency_rule";
|
|
83
|
+
readonly arity: 2;
|
|
84
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
85
|
+
readonly rationale: "Idempotency prose defines deduplication behavior and should be queryable as a predicate.";
|
|
86
|
+
}, {
|
|
87
|
+
readonly pattern: RegExp;
|
|
88
|
+
readonly name: "idempotency_rule";
|
|
89
|
+
readonly arity: 2;
|
|
90
|
+
readonly args: (g: Readonly<Record<string, string | undefined>>) => string[];
|
|
91
|
+
readonly rationale: "Deduplication prose defines idempotent handling of repeated or concurrent operations and should be queryable as a predicate.";
|
|
92
|
+
}];
|
|
93
|
+
export { commaList };
|
|
94
|
+
//# sourceMappingURL=predicate-rules-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicate-rules-core.d.ts","sourceRoot":"","sources":["../../src/ontology/predicate-rules-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAKV,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsLY,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,CAAC"}
|