kibi-cli 0.1.6 → 0.1.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"aggregated-checks.d.ts","sourceRoot":"","sources":["../../src/commands/aggregated-checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC,CAoFtB"}
1
+ {"version":3,"file":"aggregated-checks.d.ts","sourceRoot":"","sources":["../../src/commands/aggregated-checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAU5C;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC,CAqDtB"}
@@ -7,27 +7,6 @@ import { resolveKbPlPath } from "../prolog.js";
7
7
  */
8
8
  export async function runAggregatedChecks(prolog, rulesAllowlist) {
9
9
  const violations = [];
10
- // Build the check goal based on allowlist
11
- const checkGoals = [];
12
- const supportedRules = [
13
- "must-priority-coverage",
14
- "symbol-coverage",
15
- "no-dangling-refs",
16
- "no-cycles",
17
- "required-fields",
18
- "deprecated-adr-no-successor",
19
- "domain-contradictions",
20
- ];
21
- for (const rule of supportedRules) {
22
- if (!rulesAllowlist || rulesAllowlist.has(rule)) {
23
- // Convert kebab-case to snake_case for Prolog
24
- const prologRule = rule.replace(/-/g, "_");
25
- checkGoals.push(`findall(V, checks:check_${prologRule}(V), ${prologRule}_violations)`);
26
- }
27
- }
28
- if (checkGoals.length === 0) {
29
- return violations;
30
- }
31
10
  const checksPlPath = path.join(path.dirname(resolveKbPlPath()), "checks.pl");
32
11
  const checksPlPathEscaped = checksPlPath.replace(/'/g, "''");
33
12
  const query = `(use_module('${checksPlPathEscaped}'), call(checks:check_all_json(JsonString)))`;
@@ -37,37 +16,33 @@ export async function runAggregatedChecks(prolog, rulesAllowlist) {
37
16
  console.warn("Aggregated checks query failed, falling back to individual checks");
38
17
  return [];
39
18
  }
40
- // Parse the JSON from the binding
41
19
  let violationsDict;
42
20
  try {
43
21
  const jsonString = result.bindings.JsonString;
44
- if (jsonString) {
45
- violationsDict = JSON.parse(jsonString);
46
- }
47
- else {
22
+ if (!jsonString) {
48
23
  throw new Error("No JSON string in binding");
49
24
  }
25
+ let parsed = JSON.parse(jsonString);
26
+ if (typeof parsed === "string") {
27
+ parsed = JSON.parse(parsed);
28
+ }
29
+ violationsDict = parsed;
50
30
  }
51
31
  catch (parseError) {
52
32
  console.warn("Failed to parse violations JSON:", parseError);
53
33
  return [];
54
34
  }
55
- // Convert Prolog violation terms to Violation objects
56
- for (const [ruleKey, ruleViolations] of Object.entries(violationsDict)) {
57
- const rule = ruleKey.replace(/_/g, "-");
35
+ for (const ruleViolations of Object.values(violationsDict)) {
58
36
  for (const v of ruleViolations) {
59
- if (typeof v === "string") {
60
- // Parse Prolog violation/5 term: violation(Rule, EntityId, Desc, Sugg, Source)
61
- const match = v.match(/violation\(([^,]+),\s*'([^']+)'\s*,\s*"([^"]*)"\s*,\s*"([^"]*)"\s*,\s*"([^"]*)"\)/);
62
- if (match) {
63
- violations.push({
64
- rule: rule,
65
- entityId: match[2],
66
- description: match[3],
67
- suggestion: match[4] || undefined,
68
- source: match[5] || undefined,
69
- });
70
- }
37
+ const isAllowed = !rulesAllowlist || rulesAllowlist.has(v.rule);
38
+ if (isAllowed) {
39
+ violations.push({
40
+ rule: v.rule,
41
+ entityId: v.entityId,
42
+ description: v.description,
43
+ suggestion: v.suggestion || undefined,
44
+ source: v.source || undefined,
45
+ });
71
46
  }
72
47
  }
73
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAsDA,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqMvE"}
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AA8DA,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA6MvE"}
@@ -46,10 +46,10 @@ import * as path from "node:path";
46
46
  import { PrologProcess } from "../prolog.js";
47
47
  import { getStagedFiles } from "../traceability/git-staged.js";
48
48
  import { extractSymbolsFromStagedFile } from "../traceability/symbol-extract.js";
49
- import { cleanupTempKb, consultOverlay, createOverlayFacts, createTempKb } from "../traceability/temp-kb.js";
50
- import { formatViolations as formatStagedViolations, validateStagedSymbols } from "../traceability/validate.js";
51
- import { getCurrentBranch } from "./init-helpers.js";
49
+ import { cleanupTempKb, consultOverlay, createOverlayFacts, createTempKb, } from "../traceability/temp-kb.js";
50
+ import { formatViolations as formatStagedViolations, validateStagedSymbols, } from "../traceability/validate.js";
52
51
  import { runAggregatedChecks } from "./aggregated-checks.js";
52
+ import { getCurrentBranch } from "./init-helpers.js";
53
53
  export async function checkCommand(options) {
54
54
  try {
55
55
  // Resolve KB path with priority:
@@ -111,7 +111,10 @@ export async function checkCommand(options) {
111
111
  await fs.writeFile(tempCtx.overlayPath, overlayFacts, "utf8");
112
112
  await consultOverlay(tempCtx);
113
113
  // Validate staged symbols using the temp KB prolog session
114
- const violationsRaw = await validateStagedSymbols({ minLinks, prolog: tempCtx.prolog });
114
+ const violationsRaw = await validateStagedSymbols({
115
+ minLinks,
116
+ prolog: tempCtx.prolog,
117
+ });
115
118
  const violationsFormatted = formatStagedViolations(violationsRaw);
116
119
  if (violationsRaw && violationsRaw.length > 0) {
117
120
  console.log(violationsFormatted);
@@ -167,16 +170,16 @@ export async function checkCommand(options) {
167
170
  // This is significantly faster in Bun/Docker environments where one-shot mode
168
171
  // spawns a new Prolog process for each query
169
172
  const supportedRules = [
170
- 'must-priority-coverage',
171
- 'symbol-coverage',
172
- 'no-dangling-refs',
173
- 'no-cycles',
174
- 'required-fields',
175
- 'deprecated-adr-no-successor',
176
- 'domain-contradictions',
173
+ "must-priority-coverage",
174
+ "symbol-coverage",
175
+ "no-dangling-refs",
176
+ "no-cycles",
177
+ "required-fields",
178
+ "deprecated-adr-no-successor",
179
+ "domain-contradictions",
177
180
  ];
178
181
  const canUseAggregated = !rulesAllowlist ||
179
- Array.from(rulesAllowlist).every(r => supportedRules.includes(r));
182
+ Array.from(rulesAllowlist).every((r) => supportedRules.includes(r));
180
183
  if (canUseAggregated) {
181
184
  // Fast path: single Prolog call returning all violations
182
185
  const aggregatedViolations = await runAggregatedChecks(prolog, rulesAllowlist);
@@ -193,14 +196,6 @@ export async function checkCommand(options) {
193
196
  await runCheck("deprecated-adr-no-successor", checkDeprecatedAdrs);
194
197
  await runCheck("domain-contradictions", checkDomainContradictions);
195
198
  }
196
- await runCheck("must-priority-coverage", checkMustPriorityCoverage);
197
- await runCheck("symbol-coverage", checkSymbolCoverage);
198
- await runCheck("no-dangling-refs", checkNoDanglingRefs);
199
- await runCheck("no-cycles", checkNoCycles);
200
- const allEntityIds = await getAllEntityIds(prolog);
201
- await runCheck("required-fields", checkRequiredFields, allEntityIds);
202
- await runCheck("deprecated-adr-no-successor", checkDeprecatedAdrs);
203
- await runCheck("domain-contradictions", checkDomainContradictions);
204
199
  await prolog.query("kb_detach");
205
200
  await prolog.terminate();
206
201
  if (violations.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "description": "Kibi CLI for knowledge base management",
6
6
  "engines": {
@@ -11,13 +11,7 @@
11
11
  "bin": {
12
12
  "kibi": "bin/kibi"
13
13
  },
14
- "files": [
15
- "dist",
16
- "bin",
17
- "schema",
18
- "src/schemas",
19
- "src/public"
20
- ],
14
+ "files": ["dist", "bin", "schema", "src/schemas", "src/public"],
21
15
  "scripts": {
22
16
  "build": "tsc -p tsconfig.json",
23
17
  "prepack": "npm run build"
@@ -52,7 +46,7 @@
52
46
  "fast-glob": "^3.2.12",
53
47
  "gray-matter": "^4.0.3",
54
48
  "js-yaml": "^4.1.0",
55
- "kibi-core": "^0.1.5",
49
+ "kibi-core": "^0.1.6",
56
50
  "ts-morph": "^23.0.0"
57
51
  },
58
52
  "license": "AGPL-3.0-or-later",