kibi-cli 0.1.0 → 0.1.5

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":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"AAoDA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,cAAc,CACyC;IAC/D,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,aAAa,CAA6B;gBAEtC,OAAO,GAAE,aAAkB;IAKjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAqCd,YAAY;IAapB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAmF1D,eAAe,IAAI,IAAI;IAIvB,OAAO,CAAC,eAAe;YAYT,YAAY;IA0B1B,OAAO,CAAC,WAAW;IA8EnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,cAAc;IA8BtB,SAAS,IAAI,OAAO;IAIpB,MAAM,IAAI,MAAM;IAIV,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAyBjC"}
1
+ {"version":3,"file":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"AA8FA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,cAAc,CACyC;IAC/D,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,aAAa,CAA6B;gBAEtC,OAAO,GAAE,aAAkB;IAKjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAoCd,YAAY;IAapB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAmF1D,eAAe,IAAI,IAAI;IAIvB,OAAO,CAAC,eAAe;YAYT,YAAY;IA0B1B,OAAO,CAAC,WAAW;IA8EnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,cAAc;IA8BtB,SAAS,IAAI,OAAO;IAIpB,MAAM,IAAI,MAAM;IAIV,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAyBjC"}
package/dist/prolog.js CHANGED
@@ -44,9 +44,40 @@
44
44
  */
45
45
  import { spawn, spawnSync } from "node:child_process";
46
46
  import { existsSync } from "node:fs";
47
+ import { createRequire } from "node:module";
47
48
  import path from "node:path";
48
49
  import { fileURLToPath } from "node:url";
49
50
  const importMetaDir = path.dirname(fileURLToPath(import.meta.url));
51
+ const require = createRequire(import.meta.url);
52
+ function resolveKbPlPath() {
53
+ const overrideKbPath = process.env.KIBI_KB_PL_PATH;
54
+ if (overrideKbPath && existsSync(overrideKbPath)) {
55
+ return overrideKbPath;
56
+ }
57
+ try {
58
+ const installedKbPl = require.resolve("kibi-core/src/kb.pl");
59
+ if (existsSync(installedKbPl))
60
+ return installedKbPl;
61
+ }
62
+ catch { }
63
+ const startDirs = [importMetaDir, process.cwd()];
64
+ for (const startDir of startDirs) {
65
+ let currentDir = path.resolve(startDir);
66
+ while (true) {
67
+ const candidate = path.join(currentDir, "packages", "core", "src", "kb.pl");
68
+ if (existsSync(candidate)) {
69
+ return candidate;
70
+ }
71
+ const parentDir = path.dirname(currentDir);
72
+ if (parentDir === currentDir) {
73
+ break;
74
+ }
75
+ currentDir = parentDir;
76
+ }
77
+ }
78
+ throw new Error("Unable to resolve kb.pl. Expected kibi-core to be installed (node_modules) " +
79
+ "or to be running inside the monorepo checkout.");
80
+ }
50
81
  export class PrologProcess {
51
82
  process = null;
52
83
  swiplPath;
@@ -65,7 +96,7 @@ export class PrologProcess {
65
96
  if (!existsSync(this.swiplPath) && this.swiplPath !== "swipl") {
66
97
  throw new Error(`SWI-Prolog not found at ${this.swiplPath}. Please install SWI-Prolog or check your PATH.`);
67
98
  }
68
- const kbPath = path.resolve(importMetaDir, "../../core/src/kb.pl");
99
+ const kbPath = resolveKbPlPath();
69
100
  this.process = spawn(this.swiplPath, [
70
101
  "-g",
71
102
  `use_module('${kbPath}'), set_prolog_flag(answer_write_options, [max_depth(0), quoted(true)])`,
@@ -207,7 +238,7 @@ export class PrologProcess {
207
238
  : [this.normalizeGoal(goal)];
208
239
  const isBatch = goalList.length > 1;
209
240
  const combinedGoal = goalList.length === 1 ? goalList[0] : `(${goalList.join(", ")})`;
210
- const kbModulePath = path.resolve(importMetaDir, "../../core/src/kb.pl");
241
+ const kbModulePath = resolveKbPlPath();
211
242
  const prologGoal = [
212
243
  `use_module('${kbModulePath}')`,
213
244
  "use_module(library(semweb/rdf_db))",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "Kibi CLI for knowledge base management",
6
6
  "engines": {
@@ -11,7 +11,13 @@
11
11
  "bin": {
12
12
  "kibi": "./bin/kibi"
13
13
  },
14
- "files": ["dist", "bin", "schema", "src/schemas", "src/public"],
14
+ "files": [
15
+ "dist",
16
+ "bin",
17
+ "schema",
18
+ "src/schemas",
19
+ "src/public"
20
+ ],
15
21
  "scripts": {
16
22
  "build": "tsc -p tsconfig.json",
17
23
  "prepublishOnly": "npm run build"
@@ -46,8 +52,10 @@
46
52
  "fast-glob": "^3.2.12",
47
53
  "gray-matter": "^4.0.3",
48
54
  "js-yaml": "^4.1.0",
55
+ "kibi-core": "^0.1.5",
49
56
  "ts-morph": "^23.0.0"
50
57
  },
58
+
51
59
  "license": "AGPL-3.0-or-later",
52
60
  "author": "Piotr Franczyk",
53
61
  "repository": {