kibi-cli 0.18.1 → 0.19.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/dist/cli-json-command.d.ts +1 -2
- package/dist/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +2 -34
- package/dist/cli-operation-loader.d.ts +3 -0
- package/dist/cli-operation-loader.d.ts.map +1 -0
- package/dist/cli-operation-loader.js +58 -0
- package/dist/cli-operation-metadata.d.ts +82 -0
- package/dist/cli-operation-metadata.d.ts.map +1 -0
- package/dist/cli-operation-metadata.js +106 -0
- package/dist/cli-protocol.d.ts +1 -1
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +4 -3
- package/dist/cli-register-foundation.d.ts.map +1 -1
- package/dist/cli-register-foundation.js +14 -17
- package/dist/cli-register-json.d.ts +3 -0
- package/dist/cli-register-json.d.ts.map +1 -0
- package/dist/cli-register-json.js +35 -0
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +35 -10
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +13 -14
- package/dist/cli-register-skills.d.ts.map +1 -1
- package/dist/cli-register-skills.js +8 -6
- package/dist/cli.js +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +30 -12
- package/dist/commands/coverage.js +1 -1
- package/dist/commands/discovery-shared.d.ts +2 -1
- package/dist/commands/discovery-shared.d.ts.map +1 -1
- package/dist/commands/discovery-shared.js +35 -13
- package/dist/commands/engine.d.ts +8 -0
- package/dist/commands/engine.d.ts.map +1 -0
- package/dist/commands/engine.js +100 -0
- package/dist/commands/gaps.js +1 -1
- package/dist/commands/graph.js +1 -1
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +3 -1
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +3 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +2 -1
- package/dist/commands/sync/cache.d.ts +10 -0
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +30 -1
- package/dist/commands/sync/persistence.d.ts +10 -1
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +220 -44
- package/dist/commands/sync/staging.d.ts +10 -1
- package/dist/commands/sync/staging.d.ts.map +1 -1
- package/dist/commands/sync/staging.js +84 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +450 -13
- package/dist/engine-daemon.d.ts +3 -0
- package/dist/engine-daemon.d.ts.map +1 -0
- package/dist/engine-daemon.js +34 -0
- package/dist/engine.d.ts +63 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +1256 -0
- package/dist/extractors/relationships.d.ts +2 -0
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +15 -17
- package/dist/prolog.d.ts +8 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +39 -8
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +3 -2
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +40 -3
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +14 -4
- package/dist/public/operations/runtime-types.d.ts +31 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/skills/init-kibi/SKILL.md +2 -2
- package/dist/public/skills/kibi-freshness/SKILL.md +2 -2
- package/dist/public/skills/kibi-traceability/SKILL.md +1 -1
- package/dist/public/skills/kibi-usage/SKILL.md +2 -2
- package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -1
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +33 -37
- package/package.json +8 -4
- package/src/public/operations/discovery-entities.ts +3 -2
- package/src/public/operations/discovery-executors.ts +44 -3
- package/src/public/operations/prolog-json.ts +15 -3
- package/src/public/operations/runtime-types.ts +39 -0
- package/src/public/skills/init-kibi/SKILL.md +2 -2
- package/src/public/skills/kibi-freshness/SKILL.md +2 -2
- package/src/public/skills/kibi-traceability/SKILL.md +1 -1
- package/src/public/skills/kibi-usage/SKILL.md +2 -2
- package/src/public/skills/kibi-usage/resources/operation-access.md +1 -1
|
@@ -80,6 +80,36 @@ export async function executeQuery(
|
|
|
80
80
|
// implements REQ-kibi-operation-interface-parity
|
|
81
81
|
const { type, id, tags, sourceFile, limit = 100, offset = 0 } = input;
|
|
82
82
|
try {
|
|
83
|
+
const prolog = requireProlog(context);
|
|
84
|
+
const indexedPage = prolog.queryEntities
|
|
85
|
+
? await prolog.queryEntities({
|
|
86
|
+
...(type !== undefined ? { type } : {}),
|
|
87
|
+
...(id !== undefined ? { id } : {}),
|
|
88
|
+
...(tags !== undefined ? { tags } : {}),
|
|
89
|
+
...(sourceFile !== undefined ? { sourceFile } : {}),
|
|
90
|
+
limit,
|
|
91
|
+
offset,
|
|
92
|
+
})
|
|
93
|
+
: null;
|
|
94
|
+
if (indexedPage !== null) {
|
|
95
|
+
const paginated = indexedPage.entities;
|
|
96
|
+
const text =
|
|
97
|
+
indexedPage.count === 0
|
|
98
|
+
? `No entities found${type ? ` of type '${type}'` : ""}.`
|
|
99
|
+
: `Found ${indexedPage.count} entities${type ? ` of type '${type}'` : ""}. Showing ${paginated.length} (offset ${offset}, limit ${limit}): ${paginated
|
|
100
|
+
.map((entity) => {
|
|
101
|
+
const entityId = String(entity.id ?? "").replace(
|
|
102
|
+
/^file:\/\/.*\//,
|
|
103
|
+
"",
|
|
104
|
+
);
|
|
105
|
+
return `${entityId} (${String(entity.title ?? "")}, status=${String(entity.status ?? "")})`;
|
|
106
|
+
})
|
|
107
|
+
.join(", ")}`;
|
|
108
|
+
return {
|
|
109
|
+
content: [{ type: "text", text }],
|
|
110
|
+
structuredContent: { entities: paginated, count: indexedPage.count },
|
|
111
|
+
};
|
|
112
|
+
}
|
|
83
113
|
const entities = await loadEntities(requireProlog(context), {
|
|
84
114
|
...(type !== undefined ? { type } : {}),
|
|
85
115
|
...(id !== undefined ? { id } : {}),
|
|
@@ -123,9 +153,20 @@ export async function executeSearch(
|
|
|
123
153
|
}
|
|
124
154
|
validateEntityType(type);
|
|
125
155
|
try {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
156
|
+
const prolog = requireProlog(context);
|
|
157
|
+
const indexedCandidates = prolog.searchEntities
|
|
158
|
+
? await prolog.searchEntities({
|
|
159
|
+
query: trimmedQuery,
|
|
160
|
+
...(type !== undefined ? { type } : {}),
|
|
161
|
+
limit: 100_000,
|
|
162
|
+
offset: 0,
|
|
163
|
+
})
|
|
164
|
+
: null;
|
|
165
|
+
const entities = indexedCandidates
|
|
166
|
+
? [...indexedCandidates.entities]
|
|
167
|
+
: await loadEntities(prolog, {
|
|
168
|
+
...(type !== undefined ? { type } : {}),
|
|
169
|
+
});
|
|
129
170
|
const matches = await rankEntities(
|
|
130
171
|
entities,
|
|
131
172
|
trimmedQuery,
|
|
@@ -22,11 +22,23 @@ export async function runOperationJsonQuery<T>(
|
|
|
22
22
|
const modulePath = escapeAtom(
|
|
23
23
|
resolveCoreModulePath(fileName).replaceAll("\\", "/"),
|
|
24
24
|
);
|
|
25
|
+
// Loading a module and invoking its predicate in one interactive goal makes
|
|
26
|
+
// SWI reject `use_module/1` under the engine's guarded `once/1` wrapper, so
|
|
27
|
+
// use two serialized requests for production and retain the combined goal
|
|
28
|
+
// only for the repository's Bun-based one-shot tests.
|
|
29
|
+
const longLivedEngine =
|
|
30
|
+
typeof (prolog as { storageStatus?: unknown }).storageStatus === "function";
|
|
25
31
|
const oneShotMode =
|
|
32
|
+
!longLivedEngine &&
|
|
33
|
+
process.env.NODE_ENV === "test" &&
|
|
26
34
|
typeof (globalThis as { Bun?: unknown }).Bun !== "undefined";
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
const typedStatusQuery = prolog.queryStatusJson;
|
|
36
|
+
const result =
|
|
37
|
+
fileName === "status.pl" && typeof typedStatusQuery === "function"
|
|
38
|
+
? await typedStatusQuery.call(prolog)
|
|
39
|
+
: oneShotMode
|
|
40
|
+
? await prolog.query(`(use_module('${modulePath}'), ${goal})`)
|
|
41
|
+
: await runInteractiveModuleQuery(prolog, modulePath, goal, errorLabel);
|
|
30
42
|
if (!result.success) {
|
|
31
43
|
throw new Error(
|
|
32
44
|
`${errorLabel} query failed: ${result.error ?? "Unknown error"}`,
|
|
@@ -8,12 +8,51 @@ export type PrologQueryResult = {
|
|
|
8
8
|
readonly error?: string;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
export type PrologEntityQueryInput = Readonly<{
|
|
12
|
+
type?: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
tags?: readonly string[];
|
|
15
|
+
sourceFile?: string;
|
|
16
|
+
limit: number;
|
|
17
|
+
offset: number;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export type PrologEntityQueryResult = Readonly<{
|
|
21
|
+
entities: readonly Record<string, unknown>[];
|
|
22
|
+
count: number;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export type PrologSearchQueryInput = Readonly<{
|
|
26
|
+
query: string;
|
|
27
|
+
type?: string;
|
|
28
|
+
/** Candidate bound before deterministic TypeScript ranking. */
|
|
29
|
+
limit: number;
|
|
30
|
+
offset: number;
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
export type PrologSearchQueryResult = Readonly<{
|
|
34
|
+
entities: readonly Record<string, unknown>[];
|
|
35
|
+
count: number;
|
|
36
|
+
}>;
|
|
37
|
+
|
|
11
38
|
// implements REQ-kibi-operation-interface-parity
|
|
12
39
|
export interface PrologPort {
|
|
13
40
|
query(goal: string): Promise<PrologQueryResult>;
|
|
41
|
+
/** Optional index-backed page query supplied by the journaled engine. */
|
|
42
|
+
queryEntities?(
|
|
43
|
+
input: PrologEntityQueryInput,
|
|
44
|
+
): Promise<PrologEntityQueryResult>;
|
|
45
|
+
/** Optional normalized-token candidate lookup supplied by the engine. */
|
|
46
|
+
searchEntities?(
|
|
47
|
+
input: PrologSearchQueryInput,
|
|
48
|
+
): Promise<PrologSearchQueryResult>;
|
|
14
49
|
nextSolution(): Promise<PrologQueryResult | null>;
|
|
15
50
|
invalidateCache?(): void;
|
|
16
51
|
save(): Promise<PrologQueryResult>;
|
|
52
|
+
/** Present on the journaled engine; used to distinguish a persistent port from one-shot SWI. */
|
|
53
|
+
storageStatus?(): Promise<PrologQueryResult>;
|
|
54
|
+
/** Typed public freshness query; avoids exposing module loading over RPC. */
|
|
55
|
+
queryStatusJson?(): Promise<PrologQueryResult>;
|
|
17
56
|
}
|
|
18
57
|
|
|
19
58
|
export type FilesystemStat = {
|
|
@@ -17,7 +17,7 @@ Set up or refresh Kibi knowledge for the current branch through approved Kibi in
|
|
|
17
17
|
## Interface Selection
|
|
18
18
|
|
|
19
19
|
1. If approved Kibi MCP tools are visible, use the MCP route.
|
|
20
|
-
2. Otherwise, in a trusted workspace, use the canonical project-local CLI fallback: `npx --no-install kibi
|
|
20
|
+
2. Otherwise, in a trusted workspace, use the canonical project-local CLI fallback: `npx --no-install kibi ...`.
|
|
21
21
|
3. If neither approved MCP tools nor the project-local CLI are available, stop and tell the operator to enable or install Kibi for this workspace.
|
|
22
22
|
4. Never use a global fallback, an installing runner, or any route outside the approved Kibi interface.
|
|
23
23
|
|
|
@@ -59,4 +59,4 @@ echo '{"maxCandidates":25,"minConfidence":0.8}' | npx --no-install kibi autopilo
|
|
|
59
59
|
|
|
60
60
|
```json
|
|
61
61
|
[{"taskId":"init-kibi-bootstrap-analysis-train-1","family":"bootstrap-analysis","reflection":"Analyze the cold-start repository and produce a read-only bootstrap preview. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"init-kibi-bootstrap-analysis-train-2","family":"bootstrap-analysis","reflection":"Analyze the cold-start repository and produce a read-only bootstrap preview. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"init-kibi-bounded-context-questions-train-1","family":"bounded-context-questions","reflection":"Ask only the bounded context questions needed before bootstrap synthesis. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"init-kibi-bounded-context-questions-train-2","family":"bounded-context-questions","reflection":"Ask only the bounded context questions needed before bootstrap synthesis. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"init-kibi-approval-sequential-writes-train-1","family":"approval-sequential-writes","reflection":"Apply the approved bootstrap plan sequentially and finish with validation. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"init-kibi-approval-sequential-writes-train-2","family":"approval-sequential-writes","reflection":"Apply the approved bootstrap plan sequentially and finish with validation. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"init-kibi-repair-escalation-train-1","family":"repair-escalation","reflection":"Identify the partial setup and stop at the documented operator repair boundary. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"init-kibi-repair-escalation-train-2","family":"repair-escalation","reflection":"Identify the partial setup and stop at the documented operator repair boundary. This is train case 2; use only the public Kibi MCP surface."}]
|
|
62
|
-
```
|
|
62
|
+
```
|
|
@@ -17,7 +17,7 @@ Help agents decide whether Kibi knowledge is current enough to support safe chan
|
|
|
17
17
|
## Interface Selection
|
|
18
18
|
|
|
19
19
|
1. If Kibi MCP tools are visible and approved for the workspace, use the MCP surface only.
|
|
20
|
-
2. Otherwise, in a trusted workspace, use the canonical project-local CLI fallback through `npx --no-install kibi
|
|
20
|
+
2. Otherwise, in a trusted workspace, use the canonical project-local CLI fallback through `npx --no-install kibi ...`.
|
|
21
21
|
3. If the project-local CLI is unavailable or too old, stop and tell the operator to enable or install Kibi.
|
|
22
22
|
4. Never use a global fallback or an installing runner.
|
|
23
23
|
|
|
@@ -41,4 +41,4 @@ echo '{}' | npx --no-install kibi status --input -
|
|
|
41
41
|
- If entities look stale, refresh context through an approved Kibi capability and then re-query.
|
|
42
42
|
- Preserve source-file traceability by carrying `sourceFile`, text references, and validation evidence through discovery, mutation, and completion.
|
|
43
43
|
- Do not read or edit files inside `.kb` directly; use the selected Kibi interface instead.
|
|
44
|
-
- Completion must state one freshness outcome: KB updated, no KB impact with rationale, or deferred/failed.
|
|
44
|
+
- Completion must state one freshness outcome: KB updated, no KB impact with rationale, or deferred/failed.
|
|
@@ -17,7 +17,7 @@ Validate and strengthen requirement, scenario, test, behavioral-symbol, and sour
|
|
|
17
17
|
## Interface Selection
|
|
18
18
|
|
|
19
19
|
1. If Kibi MCP tools are visible and approved, use the MCP surface as the primary authority.
|
|
20
|
-
2. Otherwise, in a trusted workspace, use the canonical project-local CLI fallback through `npx --no-install kibi
|
|
20
|
+
2. Otherwise, in a trusted workspace, use the canonical project-local CLI fallback through `npx --no-install kibi ...`.
|
|
21
21
|
3. If neither approved MCP tools nor the project-local CLI are available, or if the CLI is unavailable or too old, stop and tell the operator to enable or install Kibi.
|
|
22
22
|
4. Never use a global fallback or an installing runner.
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ Consult this skill before any Kibi knowledge base operation, on first interactio
|
|
|
27
27
|
Kibi exposes two peer surfaces over the same 18 operations: visible MCP tools and the trusted project-local CLI. Both accept the same business input and effects (see `resources/operation-access.md`). Choose by what is visible and approved in the current environment — MCP and the CLI are equal choices, not a preference order:
|
|
28
28
|
|
|
29
29
|
1. If Kibi MCP tools are visible and approved in the current environment, use MCP.
|
|
30
|
-
2. Otherwise, in a trusted workspace, use the project-local CLI through a non-installing runner: `npx --no-install kibi
|
|
30
|
+
2. Otherwise, in a trusted workspace, use the project-local CLI through a non-installing runner: `npx --no-install kibi ...`. The CLI is a peer interface, not a fallback.
|
|
31
31
|
3. If the project-local CLI is unavailable or too old for the needed route, stop and tell the operator to enable or install Kibi.
|
|
32
32
|
4. Never use a global fallback or an installing runner. Never probe or install packages as a side effect of interface selection.
|
|
33
33
|
|
|
@@ -40,7 +40,7 @@ echo '{"type":"req","id":"REQ-001","properties":{"title":"Test","status":"open"}
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
echo '{"query":"authentication","limit":10}' |
|
|
43
|
+
echo '{"query":"authentication","limit":10}' | npx --no-install kibi search --input -
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
## MCP Tool Names
|
|
@@ -36,7 +36,7 @@ echo '{"type":"req","id":"REQ-001","properties":{"title":"Test","status":"open"}
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
echo '{"rules":["required-fields","no-dangling-refs"]}' |
|
|
39
|
+
echo '{"rules":["required-fields","no-dangling-refs"]}' | npx --no-install kibi check --input -
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Telemetry handling
|