kibi-cli 0.5.0 → 0.5.1

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":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAkDA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,SAAS,EAAE,CAAC;AAI1B,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;AA4DD,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgR/B"}
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAmDA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,SAAS,EAAE,CAAC;AAI1B,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;AAmGD,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgR/B"}
@@ -15,8 +15,9 @@
15
15
  You should have received a copy of the GNU Affero General Public License
16
16
  along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
  */
18
+ import { existsSync } from "node:fs";
18
19
  import * as path from "node:path";
19
- import { extractFromManifestString } from "../extractors/manifest.js";
20
+ import { extractFromManifest, extractFromManifestString } from "../extractors/manifest.js";
20
21
  import { extractFromMarkdownString, } from "../extractors/markdown.js";
21
22
  import { PrologProcess } from "../prolog.js";
22
23
  import { escapeAtom, parseTriples, parseViolationRows, } from "../prolog/codec.js";
@@ -33,6 +34,40 @@ import { getCurrentBranch } from "./init-helpers.js";
33
34
  function buildManifestLookup(stagedFiles) {
34
35
  const manifestLookup = new Map();
35
36
  const manifestResults = [];
37
+ // Pre-populate lookup from working-tree manifests so that code-only changes
38
+ // (where symbols.yaml is not staged) still resolve to the correct symbol IDs
39
+ // and relationships already defined on disk.
40
+ const config = loadConfig(process.cwd());
41
+ const symbolsRelPath = config.paths.symbols;
42
+ if (symbolsRelPath) {
43
+ const absSymbolsPath = path.resolve(process.cwd(), symbolsRelPath);
44
+ if (existsSync(absSymbolsPath)) {
45
+ try {
46
+ const entries = extractFromManifest(absSymbolsPath);
47
+ for (const entry of entries) {
48
+ const sourceFile = entry.sourceFile || entry.entity.source || absSymbolsPath;
49
+ const key = `${sourceFile}:${entry.entity.title}`;
50
+ manifestLookup.set(key, {
51
+ id: entry.entity.id,
52
+ relationships: entry.relationships
53
+ .filter((relationship) => relationship.type === "implements" ||
54
+ relationship.type === "covered_by")
55
+ .map((relationship) => ({
56
+ type: relationship.type,
57
+ to: relationship.to,
58
+ })),
59
+ });
60
+ }
61
+ }
62
+ catch (e) {
63
+ // Ignore working-tree manifest parsing errors; staged-only fallback still applies
64
+ if (process.env.KIBI_TRACE || process.env.KIBI_DEBUG) {
65
+ const msg = e instanceof Error ? e.message : String(e);
66
+ console.debug(`[kibi] skipping working-tree manifest ${absSymbolsPath}: ${msg}`);
67
+ }
68
+ }
69
+ }
70
+ }
36
71
  const stagedManifestFiles = stagedFiles.filter((file) => file.content !== undefined &&
37
72
  (file.path.endsWith("/symbols.yaml") ||
38
73
  file.path.endsWith("/symbols.yml") ||
@@ -1 +1 @@
1
- {"version":3,"file":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"AA4BA,wBAAgB,eAAe,IAAI,MAAM,CAyCxC;AACD,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,oBAAoB,CAAoC;IAChE,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;IAyCpB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAuJ1D,eAAe,IAAI,IAAI;IAIvB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,kBAAkB;YAIZ,YAAY;IAkC1B,OAAO,CAAC,WAAW;IAsGnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,cAAc;IA8BtB,SAAS,IAAI,OAAO;IAIpB,MAA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OAAO,CAAC,IAAI,CAAC;CAyBjC"}
package/dist/prolog.js CHANGED
@@ -88,6 +88,7 @@ export class PrologProcess {
88
88
  this.process.stderr.on("data", (chunk) => {
89
89
  this.errorBuffer += chunk.toString();
90
90
  });
91
+ this.process.stdin.write("true.\n");
91
92
  if (!this.onProcessExit) {
92
93
  this.onProcessExit = () => {
93
94
  void this.terminate();
@@ -109,13 +110,14 @@ export class PrologProcess {
109
110
  if (this.errorBuffer.includes("ERROR")) {
110
111
  throw new Error(`Failed to load kb module: ${this.translateError(this.errorBuffer)}`);
111
112
  }
112
- // If stdout or stderr shows any output, assume ready.
113
- if (this.outputBuffer.length > 0 || this.errorBuffer.length > 0) {
114
- break;
113
+ if (this.outputBuffer.includes("true.")) {
114
+ this.outputBuffer = "";
115
+ this.errorBuffer = "";
116
+ return;
115
117
  }
116
118
  // brief pause
117
119
  // eslint-disable-next-line no-await-in-loop
118
- await new Promise((resolve) => setTimeout(resolve, 50));
120
+ await new Promise((resolve) => setTimeout(resolve, 10));
119
121
  }
120
122
  // Final sanity check
121
123
  if (this.errorBuffer.includes("ERROR")) {
@@ -46,6 +46,9 @@ declare const entitySchema: {
46
46
  text_ref: {
47
47
  type: string;
48
48
  };
49
+ sourceFile: {
50
+ type: string;
51
+ };
49
52
  type: {
50
53
  type: string;
51
54
  enum: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/public/schemas/entity.ts"],"names":[],"mappings":"AAwBA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoHjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/public/schemas/entity.ts"],"names":[],"mappings":"AAwBA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -55,6 +55,7 @@ const entitySchema = {
55
55
  severity: { type: "string" },
56
56
  links: { type: "array", items: { type: "string" } },
57
57
  text_ref: { type: "string" },
58
+ sourceFile: { type: "string" },
58
59
  type: {
59
60
  type: "string",
60
61
  enum: [
@@ -38,6 +38,7 @@
38
38
  "severity": { "type": "string" },
39
39
  "links": { "type": "array", "items": { "type": "string" } },
40
40
  "text_ref": { "type": "string" },
41
+ "sourceFile": { "type": "string" },
41
42
  "type": {
42
43
  "type": "string",
43
44
  "enum": [
@@ -1 +1 @@
1
- {"version":3,"file":"temp-kb.d.ts","sourceRoot":"","sources":["../../src/traceability/temp-kb.ts"],"names":[],"mappings":"AAIA,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;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;CACvB;AAuJD,iBAAe,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/D;AAED,OAAO,EAAE,cAAc,EAAE,CAAC;AAG1B,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiCf;AAED,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA2C7E;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,CAkBrE;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BlE"}
1
+ {"version":3,"file":"temp-kb.d.ts","sourceRoot":"","sources":["../../src/traceability/temp-kb.ts"],"names":[],"mappings":"AAIA,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;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;CACvB;AA4ID,iBAAe,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/D;AAED,OAAO,EAAE,cAAc,EAAE,CAAC;AAG1B,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiCf;AAED,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA2C7E;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,CAkBrE;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BlE"}
@@ -3,7 +3,7 @@ import { cp, mkdir, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import path from "node:path";
5
5
  import { PrologProcess } from "../prolog.js";
6
- import { toPrologAtom } from "../prolog/codec.js";
6
+ import { toPrologAtom, toPrologString } from "../prolog/codec.js";
7
7
  const prologByTempDir = new Map();
8
8
  const cleanupByTempDir = new Map();
9
9
  const cleanedTempDirs = new Set();
@@ -37,15 +37,6 @@ function trace(message) {
37
37
  function escapePrologAtom(value) {
38
38
  return `'${value.replace(/'/g, "''")}'`;
39
39
  }
40
- function toPrologString(value) {
41
- const escaped = value
42
- .replace(/\\/g, "\\\\")
43
- .replace(/"/g, '\\"')
44
- .replace(/\n/g, "\\n")
45
- .replace(/\r/g, "\\r")
46
- .replace(/\t/g, "\\t");
47
- return `"${escaped}"`;
48
- }
49
40
  function serializeTypedFactFields(entity) {
50
41
  const fields = [];
51
42
  const entityRecord = entity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "Kibi CLI for knowledge base management",
6
6
  "engines": {
@@ -76,7 +76,7 @@
76
76
  "fast-glob": "^3.2.12",
77
77
  "gray-matter": "^4.0.3",
78
78
  "js-yaml": "^4.1.0",
79
- "kibi-core": "^0.4.0",
79
+ "kibi-core": "^0.4.1",
80
80
  "ts-morph": "^23.0.0"
81
81
  },
82
82
  "devDependencies": {
@@ -62,6 +62,7 @@ const entitySchema = {
62
62
  severity: { type: "string" },
63
63
  links: { type: "array", items: { type: "string" } },
64
64
  text_ref: { type: "string" },
65
+ sourceFile: { type: "string" },
65
66
  type: {
66
67
  type: "string",
67
68
  enum: [
@@ -38,6 +38,7 @@
38
38
  "severity": { "type": "string" },
39
39
  "links": { "type": "array", "items": { "type": "string" } },
40
40
  "text_ref": { "type": "string" },
41
+ "sourceFile": { "type": "string" },
41
42
  "type": {
42
43
  "type": "string",
43
44
  "enum": [