kibi-cli 0.17.0 → 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 +88 -44
- 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 +41 -8
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +18 -14
- package/dist/cli-register-skills.d.ts.map +1 -1
- package/dist/cli-register-skills.js +8 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -2
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +1 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +30 -12
- package/dist/commands/coverage.d.ts +5 -0
- package/dist/commands/coverage.d.ts.map +1 -1
- package/dist/commands/coverage.js +6 -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/discovery-table.d.ts.map +1 -1
- package/dist/commands/discovery-table.js +96 -5
- 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 +12 -0
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +38 -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 +276 -43
- 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 +521 -27
- package/dist/commands/usage-metrics.d.ts +66 -2
- package/dist/commands/usage-metrics.d.ts.map +1 -1
- package/dist/commands/usage-metrics.js +34 -24
- package/dist/commands/usage-remediation.d.ts +9 -0
- package/dist/commands/usage-remediation.d.ts.map +1 -0
- package/dist/commands/usage-remediation.js +52 -0
- 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/markdown.d.ts +8 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +69 -2
- 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/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +14 -5
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +27 -2
- package/dist/operations/modeling/predicate-applyplan.d.ts +1 -1
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +18 -6
- package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-inference.js +5 -17
- package/dist/operations/modeling/predicate-loader.js +1 -1
- package/dist/operations/modeling/predicate-types.d.ts +9 -1
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +35 -11
- package/dist/operations/mutation/audit.js +1 -1
- package/dist/operations/mutation/contradictions.d.ts +1 -1
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +23 -18
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +6 -3
- package/dist/operations/mutation/upsert.d.ts +3 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +51 -12
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +18 -2
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +8 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +7 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +76 -61
- package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +7 -7
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +18 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.js +167 -0
- package/dist/operations/semantic-advisor/shared.d.ts +8 -0
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/shared.js +37 -3
- package/dist/operations/semantic-advisor/types.d.ts +5 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +9 -2
- package/dist/prolog.d.ts +14 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +279 -69
- package/dist/public/diagnostic-usage.d.ts +17 -0
- package/dist/public/diagnostic-usage.d.ts.map +1 -0
- package/dist/public/diagnostic-usage.js +152 -0
- package/dist/public/distribution-parity.d.ts +90 -0
- package/dist/public/distribution-parity.d.ts.map +1 -0
- package/dist/public/distribution-parity.js +367 -0
- package/dist/public/impact/full-kb-quality.d.ts +2 -0
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +53 -1
- package/dist/public/impact-diagnostics.d.ts +2 -0
- package/dist/public/impact-diagnostics.d.ts.map +1 -1
- package/dist/public/impact-diagnostics.js +1 -0
- package/dist/public/operations/catalog.d.ts +151 -6
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +4 -0
- 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 +6 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +58 -5
- package/dist/public/operations/index.d.ts +4 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +4 -0
- package/dist/public/operations/legacy-migration-plan.d.ts +113 -0
- package/dist/public/operations/legacy-migration-plan.d.ts.map +1 -0
- package/dist/public/operations/legacy-migration-plan.js +409 -0
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +90 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +14 -4
- package/dist/public/operations/repair-plan.d.ts +184 -0
- package/dist/public/operations/repair-plan.d.ts.map +1 -0
- package/dist/public/operations/repair-plan.js +397 -0
- package/dist/public/operations/runtime-types.d.ts +38 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check.d.ts +2 -2
- package/dist/public/operations/specs/check.js +2 -2
- package/dist/public/operations/specs/discovery.d.ts +1 -1
- package/dist/public/operations/specs/discovery.js +1 -1
- package/dist/public/operations/specs/modeling.d.ts +19 -1
- package/dist/public/operations/specs/modeling.d.ts.map +1 -1
- package/dist/public/operations/specs/modeling.js +16 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +96 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +40 -1
- package/dist/public/operations/specs/reporting.d.ts +42 -1
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +70 -6
- package/dist/public/operations/specs/semantic.js +1 -1
- package/dist/public/operations/specs/upsert.d.ts +96 -1
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/workspace-snapshot.d.ts +10 -0
- package/dist/public/operations/workspace-snapshot.d.ts.map +1 -0
- package/dist/public/operations/workspace-snapshot.js +20 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +43 -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 +8 -2
- package/dist/public/skills/kibi-usage/SKILL.md +12 -6
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +1 -1
- package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -1
- package/dist/public/skills/kibi-usage/resources/workflows.md +19 -2
- package/dist/public/telemetry-acceptance.d.ts +89 -0
- package/dist/public/telemetry-acceptance.d.ts.map +1 -0
- package/dist/public/telemetry-acceptance.js +597 -0
- package/dist/public/telemetry-remediation.d.ts +33 -0
- package/dist/public/telemetry-remediation.d.ts.map +1 -0
- package/dist/public/telemetry-remediation.js +257 -0
- package/dist/public/verification-receipt.d.ts +75 -0
- package/dist/public/verification-receipt.d.ts.map +1 -0
- package/dist/public/verification-receipt.js +129 -0
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +33 -37
- package/dist/schemas/entity.schema.json +96 -2
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +36 -3
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/rule-registry.d.ts +2 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/package.json +36 -4
- package/src/public/diagnostic-usage.ts +206 -0
- package/src/public/distribution-parity.ts +580 -0
- package/src/public/impact/full-kb-quality.ts +74 -1
- package/src/public/impact-diagnostics.ts +16 -0
- package/src/public/operations/check-executor.ts +4 -0
- package/src/public/operations/discovery-entities.ts +3 -2
- package/src/public/operations/discovery-executors.ts +68 -5
- package/src/public/operations/index.ts +4 -0
- package/src/public/operations/legacy-migration-plan.ts +688 -0
- package/src/public/operations/node-ports.ts +109 -0
- package/src/public/operations/prolog-json.ts +15 -3
- package/src/public/operations/repair-plan.ts +562 -0
- package/src/public/operations/runtime-types.ts +47 -0
- package/src/public/operations/specs/check.ts +2 -2
- package/src/public/operations/specs/discovery.ts +1 -1
- package/src/public/operations/specs/modeling.ts +19 -1
- package/src/public/operations/specs/mutation-schemas.ts +47 -1
- package/src/public/operations/specs/reporting.ts +91 -6
- package/src/public/operations/specs/semantic.ts +1 -1
- package/src/public/operations/workspace-snapshot.ts +28 -0
- package/src/public/schemas/entity.ts +44 -1
- 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 +8 -2
- package/src/public/skills/kibi-usage/SKILL.md +12 -6
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/src/public/skills/kibi-usage/resources/logic-ir.md +1 -1
- package/src/public/skills/kibi-usage/resources/operation-access.md +1 -1
- package/src/public/skills/kibi-usage/resources/workflows.md +19 -2
- package/src/public/telemetry-acceptance.ts +859 -0
- package/src/public/telemetry-remediation.ts +462 -0
- package/src/public/verification-receipt.ts +170 -0
- package/src/schemas/entity.schema.json +96 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
2
3
|
import * as fs from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
3
5
|
import { promisify } from "node:util";
|
|
4
6
|
import fg from "fast-glob";
|
|
5
7
|
|
|
@@ -21,6 +23,7 @@ type NodeGitPort = GitPort & {
|
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
const execFileAsync = promisify(execFile);
|
|
26
|
+
const SNAPSHOT_EXCLUDED_PREFIXES = [".changeset/", ".kb/", "docs/"] as const;
|
|
24
27
|
const ALWAYS_IGNORED_GLOBS = [
|
|
25
28
|
"**/.git/**",
|
|
26
29
|
"**/.kb/**",
|
|
@@ -35,6 +38,111 @@ const ALWAYS_IGNORED_GLOBS = [
|
|
|
35
38
|
"**/target/**",
|
|
36
39
|
] as const;
|
|
37
40
|
|
|
41
|
+
function includedSnapshotPath(relativePath: string): boolean {
|
|
42
|
+
return !SNAPSHOT_EXCLUDED_PREFIXES.some(
|
|
43
|
+
(prefix) =>
|
|
44
|
+
relativePath === prefix.slice(0, -1) || relativePath.startsWith(prefix),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function withoutVerificationReceiptFrontmatter(content: string): string {
|
|
49
|
+
const lines = content.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
50
|
+
if (lines[0]?.trim() !== "---") return content;
|
|
51
|
+
let inFrontmatter = true;
|
|
52
|
+
let skippingReceipts = false;
|
|
53
|
+
const retained: string[] = [];
|
|
54
|
+
for (const [index, line] of lines.entries()) {
|
|
55
|
+
const trimmed = line.trim();
|
|
56
|
+
if (index > 0 && inFrontmatter && trimmed === "---") {
|
|
57
|
+
inFrontmatter = false;
|
|
58
|
+
skippingReceipts = false;
|
|
59
|
+
retained.push(line);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (inFrontmatter && /^verification_receipts\s*:/.test(line)) {
|
|
63
|
+
skippingReceipts = true;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (
|
|
67
|
+
inFrontmatter &&
|
|
68
|
+
skippingReceipts &&
|
|
69
|
+
/^[A-Za-z_][A-Za-z0-9_-]*\s*:/.test(line)
|
|
70
|
+
) {
|
|
71
|
+
skippingReceipts = false;
|
|
72
|
+
}
|
|
73
|
+
if (!skippingReceipts) retained.push(line);
|
|
74
|
+
}
|
|
75
|
+
return retained.join("");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function snapshotFileContent(relativePath: string, content: Buffer): Buffer {
|
|
79
|
+
if (
|
|
80
|
+
relativePath.startsWith("documentation/") &&
|
|
81
|
+
relativePath.endsWith(".md")
|
|
82
|
+
) {
|
|
83
|
+
return Buffer.from(
|
|
84
|
+
withoutVerificationReceiptFrontmatter(content.toString("utf8")),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return content;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function workspaceSnapshot(workspaceRoot: string) {
|
|
91
|
+
const { stdout: listed } = await execFileAsync(
|
|
92
|
+
"git",
|
|
93
|
+
[
|
|
94
|
+
"-C",
|
|
95
|
+
workspaceRoot,
|
|
96
|
+
"ls-files",
|
|
97
|
+
"--cached",
|
|
98
|
+
"--others",
|
|
99
|
+
"--exclude-standard",
|
|
100
|
+
"-z",
|
|
101
|
+
],
|
|
102
|
+
{ encoding: "buffer", maxBuffer: 64 * 1024 * 1024 },
|
|
103
|
+
);
|
|
104
|
+
const paths = listed
|
|
105
|
+
.toString("utf8")
|
|
106
|
+
.split("\0")
|
|
107
|
+
.filter(Boolean)
|
|
108
|
+
.filter(includedSnapshotPath)
|
|
109
|
+
.sort();
|
|
110
|
+
const digest = createHash("sha256");
|
|
111
|
+
digest.update("kibi.workspace-snapshot.v1\0");
|
|
112
|
+
for (const relativePath of paths) {
|
|
113
|
+
digest.update(relativePath);
|
|
114
|
+
digest.update("\0");
|
|
115
|
+
try {
|
|
116
|
+
const content = await fs.readFile(path.join(workspaceRoot, relativePath));
|
|
117
|
+
digest.update(snapshotFileContent(relativePath, content));
|
|
118
|
+
} catch (error) {
|
|
119
|
+
const code =
|
|
120
|
+
typeof error === "object" && error !== null && "code" in error
|
|
121
|
+
? String(error.code)
|
|
122
|
+
: "unreadable";
|
|
123
|
+
digest.update(`<${code}>`);
|
|
124
|
+
}
|
|
125
|
+
digest.update("\0");
|
|
126
|
+
}
|
|
127
|
+
const { stdout: status } = await execFileAsync(
|
|
128
|
+
"git",
|
|
129
|
+
[
|
|
130
|
+
"-C",
|
|
131
|
+
workspaceRoot,
|
|
132
|
+
"status",
|
|
133
|
+
"--porcelain=v1",
|
|
134
|
+
"--untracked-files=normal",
|
|
135
|
+
],
|
|
136
|
+
{ maxBuffer: 16 * 1024 * 1024 },
|
|
137
|
+
);
|
|
138
|
+
return {
|
|
139
|
+
version: "kibi.workspace-snapshot.v1" as const,
|
|
140
|
+
hash: digest.digest("hex"),
|
|
141
|
+
dirty: status.trim().length > 0,
|
|
142
|
+
fileCount: paths.length,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
38
146
|
export const nodeFilesystem: NodeFilesystemPort = {
|
|
39
147
|
readFile: (filePath) => fs.readFile(filePath, "utf8"),
|
|
40
148
|
writeFile: async (filePath, data) => {
|
|
@@ -67,6 +175,7 @@ export const nodeGit: NodeGitPort = {
|
|
|
67
175
|
]);
|
|
68
176
|
return stdout.trim();
|
|
69
177
|
},
|
|
178
|
+
workspaceSnapshot,
|
|
70
179
|
ignoredPaths: async (workspaceRoot, paths) => {
|
|
71
180
|
const policy = createRepoIgnorePolicy(workspaceRoot);
|
|
72
181
|
return paths.filter((candidate) => policy.isIgnored(candidate));
|
|
@@ -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"}`,
|