kibi-cli 0.1.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.
Files changed (75) hide show
  1. package/bin/kibi +19 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +117 -0
  5. package/dist/commands/branch.d.ts +3 -0
  6. package/dist/commands/branch.d.ts.map +1 -0
  7. package/dist/commands/branch.js +66 -0
  8. package/dist/commands/check.d.ts +12 -0
  9. package/dist/commands/check.d.ts.map +1 -0
  10. package/dist/commands/check.js +439 -0
  11. package/dist/commands/doctor.d.ts +2 -0
  12. package/dist/commands/doctor.d.ts.map +1 -0
  13. package/dist/commands/doctor.js +268 -0
  14. package/dist/commands/gc.d.ts +6 -0
  15. package/dist/commands/gc.d.ts.map +1 -0
  16. package/dist/commands/gc.js +117 -0
  17. package/dist/commands/init-helpers.d.ts +8 -0
  18. package/dist/commands/init-helpers.d.ts.map +1 -0
  19. package/dist/commands/init-helpers.js +150 -0
  20. package/dist/commands/init.d.ts +6 -0
  21. package/dist/commands/init.d.ts.map +1 -0
  22. package/dist/commands/init.js +85 -0
  23. package/dist/commands/query.d.ts +12 -0
  24. package/dist/commands/query.d.ts.map +1 -0
  25. package/dist/commands/query.js +469 -0
  26. package/dist/commands/sync.d.ts +7 -0
  27. package/dist/commands/sync.d.ts.map +1 -0
  28. package/dist/commands/sync.js +587 -0
  29. package/dist/extractors/manifest.d.ts +30 -0
  30. package/dist/extractors/manifest.d.ts.map +1 -0
  31. package/dist/extractors/manifest.js +122 -0
  32. package/dist/extractors/markdown.d.ts +39 -0
  33. package/dist/extractors/markdown.d.ts.map +1 -0
  34. package/dist/extractors/markdown.js +203 -0
  35. package/dist/extractors/symbols-coordinator.d.ts +4 -0
  36. package/dist/extractors/symbols-coordinator.d.ts.map +1 -0
  37. package/dist/extractors/symbols-coordinator.js +131 -0
  38. package/dist/extractors/symbols-ts.d.ts +21 -0
  39. package/dist/extractors/symbols-ts.d.ts.map +1 -0
  40. package/dist/extractors/symbols-ts.js +197 -0
  41. package/dist/prolog.d.ts +35 -0
  42. package/dist/prolog.d.ts.map +1 -0
  43. package/dist/prolog.js +328 -0
  44. package/dist/public/extractors/symbols-coordinator.d.ts +2 -0
  45. package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -0
  46. package/dist/public/extractors/symbols-coordinator.js +46 -0
  47. package/dist/public/prolog/index.d.ts +2 -0
  48. package/dist/public/prolog/index.d.ts.map +1 -0
  49. package/dist/public/prolog/index.js +46 -0
  50. package/dist/public/schemas/entity.d.ts +58 -0
  51. package/dist/public/schemas/entity.d.ts.map +1 -0
  52. package/dist/public/schemas/entity.js +102 -0
  53. package/dist/public/schemas/relationship.d.ts +35 -0
  54. package/dist/public/schemas/relationship.d.ts.map +1 -0
  55. package/dist/public/schemas/relationship.js +81 -0
  56. package/dist/types/changeset.d.ts +22 -0
  57. package/dist/types/changeset.d.ts.map +1 -0
  58. package/dist/types/changeset.js +18 -0
  59. package/dist/types/entities.d.ts +40 -0
  60. package/dist/types/entities.d.ts.map +1 -0
  61. package/dist/types/entities.js +18 -0
  62. package/dist/types/relationships.d.ts +11 -0
  63. package/dist/types/relationships.d.ts.map +1 -0
  64. package/dist/types/relationships.js +18 -0
  65. package/package.json +57 -0
  66. package/schema/entities.pl +50 -0
  67. package/schema/relationships.pl +47 -0
  68. package/schema/validation.pl +49 -0
  69. package/src/public/extractors/symbols-coordinator.ts +50 -0
  70. package/src/public/prolog/index.ts +47 -0
  71. package/src/public/schemas/entity.ts +104 -0
  72. package/src/public/schemas/relationship.ts +83 -0
  73. package/src/schemas/changeset.schema.json +48 -0
  74. package/src/schemas/entity.schema.json +55 -0
  75. package/src/schemas/relationship.schema.json +34 -0
@@ -0,0 +1,58 @@
1
+ declare const entitySchema: {
2
+ $id: string;
3
+ title: string;
4
+ type: string;
5
+ properties: {
6
+ id: {
7
+ type: string;
8
+ };
9
+ title: {
10
+ type: string;
11
+ };
12
+ status: {
13
+ type: string;
14
+ enum: string[];
15
+ };
16
+ created_at: {
17
+ type: string;
18
+ };
19
+ updated_at: {
20
+ type: string;
21
+ };
22
+ source: {
23
+ type: string;
24
+ };
25
+ tags: {
26
+ type: string;
27
+ items: {
28
+ type: string;
29
+ };
30
+ };
31
+ owner: {
32
+ type: string;
33
+ };
34
+ priority: {
35
+ type: string;
36
+ };
37
+ severity: {
38
+ type: string;
39
+ };
40
+ links: {
41
+ type: string;
42
+ items: {
43
+ type: string;
44
+ };
45
+ };
46
+ text_ref: {
47
+ type: string;
48
+ };
49
+ type: {
50
+ type: string;
51
+ enum: string[];
52
+ };
53
+ };
54
+ required: string[];
55
+ additionalProperties: boolean;
56
+ };
57
+ export default entitySchema;
58
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/public/schemas/entity.ts"],"names":[],"mappings":"AA+CA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,102 @@
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
+ How to apply this header to source files (examples)
20
+
21
+ 1) Prepend header to a single file (POSIX shells):
22
+
23
+ cat LICENSE_HEADER.txt "$FILE" > "$FILE".with-header && mv "$FILE".with-header "$FILE"
24
+
25
+ 2) Apply to multiple files (example: the project's main entry files):
26
+
27
+ for f in packages/cli/bin/kibi packages/mcp/bin/kibi-mcp packages/cli/src/*.ts packages/mcp/src/*.ts; do
28
+ if [ -f "$f" ]; then
29
+ cp "$f" "$f".bak
30
+ (cat LICENSE_HEADER.txt; echo; cat "$f" ) > "$f".new && mv "$f".new "$f"
31
+ fi
32
+ done
33
+
34
+ 3) Avoid duplicating the header: run a quick guard to only add if missing
35
+
36
+ for f in packages/cli/bin/kibi packages/mcp/bin/kibi-mcp; do
37
+ if [ -f "$f" ]; then
38
+ if ! head -n 5 "$f" | grep -q "Copyright (C) 2026 Piotr Franczyk"; then
39
+ cp "$f" "$f".bak
40
+ (cat LICENSE_HEADER.txt; echo; cat "$f" ) > "$f".new && mv "$f".new "$f"
41
+ fi
42
+ fi
43
+ done
44
+ */
45
+ // Public export of entity schema
46
+ // Generated from entity.schema.json
47
+ const entitySchema = {
48
+ $id: "entity.schema.json",
49
+ title: "Entity",
50
+ type: "object",
51
+ properties: {
52
+ id: { type: "string" },
53
+ title: { type: "string" },
54
+ status: {
55
+ type: "string",
56
+ enum: [
57
+ "active",
58
+ "draft",
59
+ "archived",
60
+ "deleted",
61
+ "approved",
62
+ "rejected",
63
+ "pending",
64
+ "in_progress",
65
+ "superseded",
66
+ ],
67
+ },
68
+ created_at: { type: "string" },
69
+ updated_at: { type: "string" },
70
+ source: { type: "string" },
71
+ tags: { type: "array", items: { type: "string" } },
72
+ owner: { type: "string" },
73
+ priority: { type: "string" },
74
+ severity: { type: "string" },
75
+ links: { type: "array", items: { type: "string" } },
76
+ text_ref: { type: "string" },
77
+ type: {
78
+ type: "string",
79
+ enum: [
80
+ "req",
81
+ "scenario",
82
+ "test",
83
+ "adr",
84
+ "flag",
85
+ "event",
86
+ "symbol",
87
+ "fact",
88
+ ],
89
+ },
90
+ },
91
+ required: [
92
+ "id",
93
+ "title",
94
+ "status",
95
+ "created_at",
96
+ "updated_at",
97
+ "source",
98
+ "type",
99
+ ],
100
+ additionalProperties: false,
101
+ };
102
+ export default entitySchema;
@@ -0,0 +1,35 @@
1
+ declare const relationshipSchema: {
2
+ $id: string;
3
+ title: string;
4
+ type: string;
5
+ properties: {
6
+ type: {
7
+ type: string;
8
+ enum: string[];
9
+ };
10
+ from: {
11
+ type: string;
12
+ };
13
+ to: {
14
+ type: string;
15
+ };
16
+ created_at: {
17
+ type: string;
18
+ };
19
+ created_by: {
20
+ type: string;
21
+ };
22
+ source: {
23
+ type: string;
24
+ };
25
+ confidence: {
26
+ type: string;
27
+ minimum: number;
28
+ maximum: number;
29
+ };
30
+ };
31
+ required: string[];
32
+ additionalProperties: boolean;
33
+ };
34
+ export default relationshipSchema;
35
+ //# sourceMappingURL=relationship.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationship.d.ts","sourceRoot":"","sources":["../../../src/public/schemas/relationship.ts"],"names":[],"mappings":"AA+CA,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -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
+ How to apply this header to source files (examples)
20
+
21
+ 1) Prepend header to a single file (POSIX shells):
22
+
23
+ cat LICENSE_HEADER.txt "$FILE" > "$FILE".with-header && mv "$FILE".with-header "$FILE"
24
+
25
+ 2) Apply to multiple files (example: the project's main entry files):
26
+
27
+ for f in packages/cli/bin/kibi packages/mcp/bin/kibi-mcp packages/cli/src/*.ts packages/mcp/src/*.ts; do
28
+ if [ -f "$f" ]; then
29
+ cp "$f" "$f".bak
30
+ (cat LICENSE_HEADER.txt; echo; cat "$f" ) > "$f".new && mv "$f".new "$f"
31
+ fi
32
+ done
33
+
34
+ 3) Avoid duplicating the header: run a quick guard to only add if missing
35
+
36
+ for f in packages/cli/bin/kibi packages/mcp/bin/kibi-mcp; do
37
+ if [ -f "$f" ]; then
38
+ if ! head -n 5 "$f" | grep -q "Copyright (C) 2026 Piotr Franczyk"; then
39
+ cp "$f" "$f".bak
40
+ (cat LICENSE_HEADER.txt; echo; cat "$f" ) > "$f".new && mv "$f".new "$f"
41
+ fi
42
+ fi
43
+ done
44
+ */
45
+ // Public export of relationship schema
46
+ // Generated from relationship.schema.json
47
+ const relationshipSchema = {
48
+ $id: "relationship.schema.json",
49
+ title: "Relationship",
50
+ type: "object",
51
+ properties: {
52
+ type: {
53
+ type: "string",
54
+ enum: [
55
+ "depends_on",
56
+ "specified_by",
57
+ "verified_by",
58
+ "validates",
59
+ "implements",
60
+ "covered_by",
61
+ "constrained_by",
62
+ "constrains",
63
+ "requires_property",
64
+ "guards",
65
+ "publishes",
66
+ "consumes",
67
+ "supersedes",
68
+ "relates_to",
69
+ ],
70
+ },
71
+ from: { type: "string" },
72
+ to: { type: "string" },
73
+ created_at: { type: "string" },
74
+ created_by: { type: "string" },
75
+ source: { type: "string" },
76
+ confidence: { type: "number", minimum: 0, maximum: 1 },
77
+ },
78
+ required: ["type", "from", "to"],
79
+ additionalProperties: false,
80
+ };
81
+ export default relationshipSchema;
@@ -0,0 +1,22 @@
1
+ import type { Entity } from "./entities";
2
+ import type BaseRelationship from "./relationships";
3
+ export interface UpsertOperation {
4
+ operation: "upsert";
5
+ entity: Entity;
6
+ relationships?: BaseRelationship[];
7
+ }
8
+ export interface DeleteOperation {
9
+ operation: "delete";
10
+ id: string;
11
+ }
12
+ export type ChangesetOperation = UpsertOperation | DeleteOperation;
13
+ export interface Changeset {
14
+ operations: ChangesetOperation[];
15
+ metadata?: {
16
+ timestamp: string;
17
+ author?: string;
18
+ source?: string;
19
+ };
20
+ }
21
+ export default Changeset;
22
+ //# sourceMappingURL=changeset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeset.d.ts","sourceRoot":"","sources":["../../src/types/changeset.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,gBAAgB,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,QAAQ,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,eAAe,CAAC;AAEnE,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,18 @@
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
+ export {};
@@ -0,0 +1,40 @@
1
+ export interface BaseEntity {
2
+ id: string;
3
+ title: string;
4
+ status: string;
5
+ created_at: string;
6
+ updated_at: string;
7
+ source: string;
8
+ tags?: string[];
9
+ owner?: string;
10
+ priority?: string;
11
+ severity?: string;
12
+ links?: string[];
13
+ text_ref?: string;
14
+ }
15
+ export type Requirement = BaseEntity & {
16
+ type: "req";
17
+ };
18
+ export type Scenario = BaseEntity & {
19
+ type: "scenario";
20
+ };
21
+ export type TestEntity = BaseEntity & {
22
+ type: "test";
23
+ };
24
+ export type ADR = BaseEntity & {
25
+ type: "adr";
26
+ };
27
+ export type Flag = BaseEntity & {
28
+ type: "flag";
29
+ };
30
+ export type Event = BaseEntity & {
31
+ type: "event";
32
+ };
33
+ export type Symbol = BaseEntity & {
34
+ type: "symbol";
35
+ };
36
+ export type Fact = BaseEntity & {
37
+ type: "fact";
38
+ };
39
+ export type Entity = Requirement | Scenario | TestEntity | ADR | Flag | Event | Symbol | Fact;
40
+ //# sourceMappingURL=entities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/types/entities.ts"],"names":[],"mappings":"AA6CA,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;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AACvD,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AACzD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACvD,MAAM,MAAM,GAAG,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAC/C,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,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;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,MAAM,MAAM,MAAM,GACd,WAAW,GACX,QAAQ,GACR,UAAU,GACV,GAAG,GACH,IAAI,GACJ,KAAK,GACL,MAAM,GACN,IAAI,CAAC"}
@@ -0,0 +1,18 @@
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
+ export {};
@@ -0,0 +1,11 @@
1
+ export interface BaseRelationship {
2
+ type: "depends_on" | "specified_by" | "verified_by" | "implements" | "covered_by" | "constrained_by" | "constrains" | "requires_property" | "guards" | "publishes" | "consumes" | "supersedes" | "relates_to";
3
+ from: string;
4
+ to: string;
5
+ created_at?: string;
6
+ created_by?: string;
7
+ source?: string;
8
+ confidence?: number;
9
+ }
10
+ export default BaseRelationship;
11
+ //# sourceMappingURL=relationships.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/types/relationships.ts"],"names":[],"mappings":"AA6CA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,YAAY,GACZ,cAAc,GACd,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,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"}
@@ -0,0 +1,18 @@
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
+ export {};
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "kibi-cli",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Kibi CLI for knowledge base management",
6
+ "engines": {
7
+ "node": ">=18",
8
+ "bun": ">=1.0"
9
+ },
10
+ "main": "./dist/cli.js",
11
+ "bin": {
12
+ "kibi": "./bin/kibi"
13
+ },
14
+ "files": ["dist", "bin", "schema", "src/schemas", "src/public"],
15
+ "scripts": {
16
+ "build": "tsc -p tsconfig.json",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/cli.d.ts",
22
+ "default": "./dist/cli.js"
23
+ },
24
+ "./prolog": {
25
+ "types": "./dist/public/prolog/index.d.ts",
26
+ "default": "./dist/public/prolog/index.js"
27
+ },
28
+ "./extractors/symbols-coordinator": {
29
+ "types": "./dist/public/extractors/symbols-coordinator.d.ts",
30
+ "default": "./dist/public/extractors/symbols-coordinator.js"
31
+ },
32
+ "./schemas/entity": {
33
+ "types": "./dist/public/schemas/entity.d.ts",
34
+ "default": "./dist/public/schemas/entity.js"
35
+ },
36
+ "./schemas/relationship": {
37
+ "types": "./dist/public/schemas/relationship.d.ts",
38
+ "default": "./dist/public/schemas/relationship.js"
39
+ }
40
+ },
41
+ "types": "./dist/cli.d.ts",
42
+ "dependencies": {
43
+ "ajv": "^8.12.0",
44
+ "cli-table3": "^0.6.5",
45
+ "commander": "^11.0.0",
46
+ "fast-glob": "^3.2.12",
47
+ "gray-matter": "^4.0.3",
48
+ "js-yaml": "^4.1.0",
49
+ "ts-morph": "^23.0.0"
50
+ },
51
+ "license": "AGPL-3.0-or-later",
52
+ "author": "Piotr Franczyk",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "https://github.com/Looted/kibi.git"
56
+ }
57
+ }
@@ -0,0 +1,50 @@
1
+ % Module: kibi_entities
2
+ % Entity type and property definitions for Kibi knowledge base
3
+ :- module(kibi_entities, [entity_type/1, entity_property/3, required_property/2, optional_property/2]).
4
+
5
+ % Entity types
6
+ entity_type(req).
7
+ entity_type(scenario).
8
+ entity_type(test).
9
+ entity_type(adr).
10
+ entity_type(flag).
11
+ entity_type(event).
12
+ entity_type(symbol).
13
+ entity_type(fact).
14
+
15
+ % entity_property(EntityType, Property, Type).
16
+ % Basic typing hints (atom, string, datetime, list, uri)
17
+ entity_property(_, id, atom).
18
+ entity_property(_, title, string).
19
+ entity_property(_, status, atom).
20
+ entity_property(_, created_at, datetime).
21
+ entity_property(_, updated_at, datetime).
22
+ entity_property(_, source, uri).
23
+
24
+ % Optional properties
25
+ entity_property(_, tags, list).
26
+ entity_property(_, owner, atom).
27
+ entity_property(_, priority, atom).
28
+ entity_property(_, severity, atom).
29
+ entity_property(_, links, list).
30
+ entity_property(_, text_ref, uri).
31
+
32
+ % Required properties for all entity types
33
+ required_property(Type, id) :- entity_type(Type).
34
+ required_property(Type, title) :- entity_type(Type).
35
+ required_property(Type, status) :- entity_type(Type).
36
+ required_property(Type, created_at) :- entity_type(Type).
37
+ required_property(Type, updated_at) :- entity_type(Type).
38
+ required_property(Type, source) :- entity_type(Type).
39
+
40
+ % Optional properties for all entity types
41
+ optional_property(Type, tags) :- entity_type(Type).
42
+ optional_property(Type, owner) :- entity_type(Type).
43
+ optional_property(Type, priority) :- entity_type(Type).
44
+ optional_property(Type, severity) :- entity_type(Type).
45
+ optional_property(Type, links) :- entity_type(Type).
46
+ optional_property(Type, text_ref) :- entity_type(Type).
47
+
48
+ % Documentation helpers
49
+ % list all entity types
50
+ all_entity_types(Ts) :- findall(T, entity_type(T), Ts).
@@ -0,0 +1,47 @@
1
+ % Module: kibi_relationships
2
+ % Relationship type definitions and valid entity combinations
3
+ :- module(kibi_relationships, [relationship_type/1, valid_relationship/3, relationship_metadata/1]).
4
+
5
+ % Relationship types
6
+ relationship_type(depends_on).
7
+ relationship_type(specified_by).
8
+ relationship_type(verified_by).
9
+ relationship_type(validates).
10
+ relationship_type(implements).
11
+ relationship_type(covered_by).
12
+ relationship_type(constrained_by).
13
+ relationship_type(guards).
14
+ relationship_type(publishes).
15
+ relationship_type(consumes).
16
+ relationship_type(relates_to).
17
+ relationship_type(supersedes).
18
+ relationship_type(constrains).
19
+ relationship_type(requires_property).
20
+
21
+ % valid_relationship(RelType, FromType, ToType).
22
+ valid_relationship(depends_on, req, req).
23
+ valid_relationship(specified_by, req, scenario).
24
+ valid_relationship(verified_by, req, test).
25
+ valid_relationship(validates, test, req).
26
+ valid_relationship(implements, symbol, req).
27
+ valid_relationship(covered_by, symbol, test).
28
+ valid_relationship(constrained_by, symbol, adr).
29
+ % guards can target symbol, event, or req
30
+ valid_relationship(guards, flag, symbol).
31
+ valid_relationship(guards, flag, event).
32
+ valid_relationship(guards, flag, req).
33
+ valid_relationship(publishes, symbol, event).
34
+ valid_relationship(consumes, symbol, event).
35
+ valid_relationship(constrains, req, fact).
36
+ valid_relationship(requires_property, req, fact).
37
+
38
+ %% supersedes(+NewAdrId, +OldAdrId)
39
+ %% NewAdrId is the decision that replaces OldAdrId.
40
+ %% OldAdrId's status should be archived or deprecated as a consequence.
41
+ valid_relationship(supersedes, adr, adr).
42
+ valid_relationship(supersedes, req, req).
43
+ % escape hatch - allow any to any
44
+ valid_relationship(relates_to, _, _).
45
+
46
+ % Relationship metadata fields (some optional)
47
+ relationship_metadata([created_at, created_by, source, confidence]).
@@ -0,0 +1,49 @@
1
+ % Module: kibi_validation
2
+ % Validation rules for entities and relationships in Kibi
3
+ :- module(kibi_validation,
4
+ [ validate_entity/2, % +Type, +Props
5
+ validate_relationship/3, % +RelType, +FromEntity, +ToEntity
6
+ validate_property_type/3 % +Type, +Prop, +Value
7
+ ]).
8
+
9
+ :- use_module('entities.pl').
10
+ :- use_module('relationships.pl').
11
+
12
+ % validate_entity(+Type, +Props:list)
13
+ % Props is a list of Property=Value pairs (e.g. id=ID, title=Title)
14
+ validate_entity(Type, Props) :-
15
+ % check entity type exists
16
+ entity_type(Type),
17
+ % required properties present
18
+ forall(required_property(Type, P), memberchk(P=_Val, Props)),
19
+ % all properties have correct types
20
+ forall(member(Key=Val, Props), validate_property_type(Type, Key, Val)).
21
+
22
+ % validate_relationship(+RelType, +From, +To)
23
+ % From and To are pairs Type=Id or structures type(Type) - allow Type or Type=Id
24
+ validate_relationship(RelType, From, To) :-
25
+ relationship_type(RelType),
26
+ % extract types
27
+ type_of(From, FromType),
28
+ type_of(To, ToType),
29
+ % valid combination
30
+ valid_relationship(RelType, FromType, ToType).
31
+
32
+ type_of(Type, Type) :- atom(Type), entity_type(Type), !.
33
+ type_of(Type=_Id, Type) :- atom(Type), entity_type(Type), !.
34
+
35
+ % validate_property_type(+EntityType, +Prop, +Value)
36
+ validate_property_type(_Type, Prop, Value) :-
37
+ % find declared property type, default to atom
38
+ ( entity_property(_Any, Prop, Kind) -> true ; Kind = atom ),
39
+ check_kind(Kind, Value), !.
40
+
41
+ % check_kind(Kind, Value) succeeds if Value matches Kind
42
+ check_kind(atom, V) :- atom(V).
43
+ check_kind(string, V) :- string(V).
44
+ check_kind(datetime, V) :- string(V). % accept ISO strings for now
45
+ check_kind(list, V) :- is_list(V).
46
+ check_kind(uri, V) :- string(V).
47
+
48
+ % Fallback false
49
+ check_kind(_, _) :- fail.