kibi-cli 0.2.3 → 0.2.6
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.js +3 -28
- package/dist/commands/aggregated-checks.d.ts +4 -1
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +13 -3
- package/dist/commands/branch.d.ts.map +1 -1
- package/dist/commands/branch.js +3 -41
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +55 -45
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +0 -27
- package/dist/commands/gc.d.ts.map +1 -1
- package/dist/commands/gc.js +2 -51
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +23 -36
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +0 -27
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +7 -288
- package/dist/commands/sync/cache.d.ts +13 -0
- package/dist/commands/sync/cache.d.ts.map +1 -0
- package/dist/commands/sync/cache.js +76 -0
- package/dist/commands/sync/discovery.d.ts +8 -0
- package/dist/commands/sync/discovery.d.ts.map +1 -0
- package/dist/commands/sync/discovery.js +50 -0
- package/dist/commands/sync/extraction.d.ts +11 -0
- package/dist/commands/sync/extraction.d.ts.map +1 -0
- package/dist/commands/sync/extraction.js +69 -0
- package/dist/commands/sync/manifest.d.ts +5 -0
- package/dist/commands/sync/manifest.d.ts.map +1 -0
- package/dist/commands/sync/manifest.js +118 -0
- package/dist/commands/sync/persistence.d.ts +16 -0
- package/dist/commands/sync/persistence.d.ts.map +1 -0
- package/dist/commands/sync/persistence.js +188 -0
- package/dist/commands/sync/staging.d.ts +4 -0
- package/dist/commands/sync/staging.d.ts.map +1 -0
- package/dist/commands/sync/staging.js +86 -0
- package/dist/commands/sync.d.ts +2 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +69 -501
- package/dist/extractors/manifest.d.ts +0 -1
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +41 -49
- package/dist/extractors/markdown.d.ts +0 -1
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +28 -50
- package/dist/extractors/relationships.d.ts +39 -0
- package/dist/extractors/relationships.d.ts.map +1 -0
- package/dist/extractors/relationships.js +137 -0
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +0 -27
- package/dist/extractors/symbols-ts.d.ts.map +1 -1
- package/dist/extractors/symbols-ts.js +0 -27
- package/dist/kb/target-resolver.d.ts +80 -0
- package/dist/kb/target-resolver.d.ts.map +1 -0
- package/dist/kb/target-resolver.js +313 -0
- package/dist/prolog/codec.d.ts +63 -0
- package/dist/prolog/codec.d.ts.map +1 -0
- package/dist/prolog/codec.js +434 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +0 -27
- package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/public/extractors/symbols-coordinator.js +0 -27
- package/dist/public/prolog/index.d.ts.map +1 -1
- package/dist/public/prolog/index.js +0 -27
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +10 -27
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +0 -27
- package/dist/query/service.d.ts +35 -0
- package/dist/query/service.d.ts.map +1 -0
- package/dist/query/service.js +149 -0
- package/dist/relationships/shards.d.ts +68 -0
- package/dist/relationships/shards.d.ts.map +1 -0
- package/dist/relationships/shards.js +263 -0
- package/dist/traceability/git-staged.d.ts +4 -1
- package/dist/traceability/git-staged.d.ts.map +1 -1
- package/dist/traceability/git-staged.js +24 -11
- package/dist/types/changeset.d.ts.map +1 -1
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts.map +1 -1
- package/dist/utils/branch-resolver.d.ts +4 -0
- package/dist/utils/branch-resolver.d.ts.map +1 -1
- package/dist/utils/branch-resolver.js +4 -0
- package/dist/utils/config.d.ts +10 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +27 -1
- package/dist/utils/rule-registry.d.ts +47 -0
- package/dist/utils/rule-registry.d.ts.map +1 -0
- package/dist/utils/rule-registry.js +139 -0
- package/package.json +6 -2
- package/schema/config.json +161 -0
- package/src/public/extractors/symbols-coordinator.ts +0 -27
- package/src/public/prolog/index.ts +0 -27
- package/src/public/schemas/entity.ts +10 -27
- package/src/public/schemas/relationship.ts +0 -27
- package/src/schemas/entity.schema.json +11 -1
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
import { execSync } from "node:child_process";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
const WORKSPACE_ENV_KEYS = [
|
|
13
|
+
"KIBI_WORKSPACE",
|
|
14
|
+
"KIBI_PROJECT_ROOT",
|
|
15
|
+
"KIBI_ROOT",
|
|
16
|
+
];
|
|
17
|
+
const KB_PATH_ENV_KEYS = ["KIBI_KB_PATH", "KB_PATH"];
|
|
18
|
+
/**
|
|
19
|
+
* Resolve workspace root directory.
|
|
20
|
+
* Priority: env vars > .kb directory > .git directory > cwd
|
|
21
|
+
*/
|
|
22
|
+
export function resolveWorkspaceRoot(startDir = process.cwd()) {
|
|
23
|
+
const envRoot = readFirstEnv(WORKSPACE_ENV_KEYS);
|
|
24
|
+
if (envRoot) {
|
|
25
|
+
return path.resolve(envRoot);
|
|
26
|
+
}
|
|
27
|
+
const kbRoot = findUpwards(startDir, ".kb");
|
|
28
|
+
if (kbRoot) {
|
|
29
|
+
return kbRoot;
|
|
30
|
+
}
|
|
31
|
+
const gitRoot = findUpwards(startDir, ".git");
|
|
32
|
+
if (gitRoot) {
|
|
33
|
+
return gitRoot;
|
|
34
|
+
}
|
|
35
|
+
return path.resolve(startDir);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve workspace root with reason for resolution.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveWorkspaceRootInfo(startDir = process.cwd()) {
|
|
41
|
+
const envRoot = readFirstEnv(WORKSPACE_ENV_KEYS);
|
|
42
|
+
if (envRoot) {
|
|
43
|
+
return { root: path.resolve(envRoot), reason: "env" };
|
|
44
|
+
}
|
|
45
|
+
const kbRoot = findUpwards(startDir, ".kb");
|
|
46
|
+
if (kbRoot) {
|
|
47
|
+
return { root: kbRoot, reason: "kb" };
|
|
48
|
+
}
|
|
49
|
+
const gitRoot = findUpwards(startDir, ".git");
|
|
50
|
+
if (gitRoot) {
|
|
51
|
+
return { root: gitRoot, reason: "git" };
|
|
52
|
+
}
|
|
53
|
+
return { root: path.resolve(startDir), reason: "cwd" };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve KB path for a given workspace and branch.
|
|
57
|
+
*/
|
|
58
|
+
export function resolveKbPath(workspaceRoot, branch) {
|
|
59
|
+
const envPath = readFirstEnv(KB_PATH_ENV_KEYS);
|
|
60
|
+
if (envPath) {
|
|
61
|
+
const resolved = path.resolve(envPath);
|
|
62
|
+
if (isBranchPath(resolved)) {
|
|
63
|
+
return resolved;
|
|
64
|
+
}
|
|
65
|
+
return path.join(resolved, "branches", branch);
|
|
66
|
+
}
|
|
67
|
+
return path.join(workspaceRoot, ".kb", "branches", branch);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resolve the active branch according to precedence:
|
|
71
|
+
* 1. KIBI_BRANCH env var (if set)
|
|
72
|
+
* 2. Git active branch (from git branch --show-current)
|
|
73
|
+
* 3. Diagnostic failure (no silent fallback)
|
|
74
|
+
*/
|
|
75
|
+
export function resolveActiveBranch(workspaceRoot = process.cwd()) {
|
|
76
|
+
// 1. Check KIBI_BRANCH env var first (highest precedence)
|
|
77
|
+
const envBranch = process.env.KIBI_BRANCH?.trim();
|
|
78
|
+
if (envBranch) {
|
|
79
|
+
if (!isValidBranchName(envBranch)) {
|
|
80
|
+
return {
|
|
81
|
+
error: `Invalid branch name from KIBI_BRANCH environment variable: '${envBranch}'`,
|
|
82
|
+
code: "ENV_OVERRIDE",
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return { branch: envBranch };
|
|
86
|
+
}
|
|
87
|
+
// 2. Try to get the current git branch
|
|
88
|
+
try {
|
|
89
|
+
const branch = execSync("git branch --show-current", {
|
|
90
|
+
cwd: workspaceRoot,
|
|
91
|
+
encoding: "utf8",
|
|
92
|
+
timeout: 5000,
|
|
93
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
94
|
+
}).trim();
|
|
95
|
+
if (!branch) {
|
|
96
|
+
return {
|
|
97
|
+
error: getBranchDiagnostic(undefined, "Git is in detached HEAD state"),
|
|
98
|
+
code: "DETACHED_HEAD",
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (!isValidBranchName(branch)) {
|
|
102
|
+
return {
|
|
103
|
+
error: `Invalid branch name detected: '${branch}'`,
|
|
104
|
+
code: "UNKNOWN_ERROR",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Normalize 'master' to 'main' for consistency
|
|
108
|
+
const normalizedBranch = branch === "master" ? "main" : branch;
|
|
109
|
+
return { branch: normalizedBranch };
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
// Try alternative: git rev-parse --abbrev-ref HEAD
|
|
113
|
+
try {
|
|
114
|
+
const branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
115
|
+
cwd: workspaceRoot,
|
|
116
|
+
encoding: "utf8",
|
|
117
|
+
timeout: 5000,
|
|
118
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
119
|
+
}).trim();
|
|
120
|
+
if (branch === "HEAD") {
|
|
121
|
+
return {
|
|
122
|
+
error: getBranchDiagnostic(undefined, "Git is in detached HEAD state"),
|
|
123
|
+
code: "DETACHED_HEAD",
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (!branch || branch === "") {
|
|
127
|
+
return {
|
|
128
|
+
error: getBranchDiagnostic(undefined, "Unable to determine git branch"),
|
|
129
|
+
code: "UNBORN_BRANCH",
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (!isValidBranchName(branch)) {
|
|
133
|
+
return {
|
|
134
|
+
error: `Invalid branch name detected: '${branch}'`,
|
|
135
|
+
code: "UNKNOWN_ERROR",
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const normalizedBranch = branch === "master" ? "main" : branch;
|
|
139
|
+
return { branch: normalizedBranch };
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
143
|
+
if (errorMessage.includes("not a git repository")) {
|
|
144
|
+
return {
|
|
145
|
+
error: getBranchDiagnostic(undefined, "Not a git repository"),
|
|
146
|
+
code: "NOT_A_GIT_REPO",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (errorMessage.includes("command not found") ||
|
|
150
|
+
errorMessage.includes("ENOENT")) {
|
|
151
|
+
return {
|
|
152
|
+
error: getBranchDiagnostic(undefined, "Git is not installed or not available in PATH"),
|
|
153
|
+
code: "GIT_NOT_AVAILABLE",
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
error: getBranchDiagnostic(undefined, errorMessage),
|
|
158
|
+
code: "UNKNOWN_ERROR",
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated defaultBranch is deprecated. Branch lifecycle now follows git naturally.
|
|
165
|
+
* This function is kept for backward compatibility but should not be used for new code.
|
|
166
|
+
*
|
|
167
|
+
* Resolve the default branch using precedence:
|
|
168
|
+
* 1. Configured defaultBranch from config (if set and valid)
|
|
169
|
+
* 2. Git remote HEAD (refs/remotes/origin/HEAD)
|
|
170
|
+
* 3. Fallback to "main"
|
|
171
|
+
*/
|
|
172
|
+
export function resolveDefaultBranch(cwd = process.cwd(), config) {
|
|
173
|
+
// 1. Check config.defaultBranch first
|
|
174
|
+
const configuredBranch = config?.defaultBranch?.trim();
|
|
175
|
+
if (configuredBranch) {
|
|
176
|
+
if (!isValidBranchName(configuredBranch)) {
|
|
177
|
+
return {
|
|
178
|
+
error: `Invalid defaultBranch configured in .kb/config.json: '${configuredBranch}'`,
|
|
179
|
+
code: "INVALID_CONFIG",
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return { branch: configuredBranch };
|
|
183
|
+
}
|
|
184
|
+
// 2. Try to get the remote default branch from origin/HEAD
|
|
185
|
+
try {
|
|
186
|
+
const remoteHead = execSync("git symbolic-ref refs/remotes/origin/HEAD", {
|
|
187
|
+
cwd,
|
|
188
|
+
encoding: "utf8",
|
|
189
|
+
timeout: 5000,
|
|
190
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
191
|
+
}).trim();
|
|
192
|
+
const match = remoteHead.match(/^refs\/remotes\/origin\/(.+)$/);
|
|
193
|
+
if (match) {
|
|
194
|
+
const branch = match[1];
|
|
195
|
+
if (isValidBranchName(branch)) {
|
|
196
|
+
return { branch };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// origin/HEAD doesn't exist or command failed
|
|
202
|
+
}
|
|
203
|
+
// 3. Final fallback to "main"
|
|
204
|
+
return { branch: "main" };
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Resolve complete KB target with all components.
|
|
208
|
+
*/
|
|
209
|
+
export function resolveKbTarget(options) {
|
|
210
|
+
const workspaceRoot = options?.workspaceRoot ?? resolveWorkspaceRoot();
|
|
211
|
+
let branch;
|
|
212
|
+
let reason;
|
|
213
|
+
if (options?.branch) {
|
|
214
|
+
branch = options.branch;
|
|
215
|
+
reason = "env";
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
const branchResult = resolveActiveBranch(workspaceRoot);
|
|
219
|
+
if ("error" in branchResult) {
|
|
220
|
+
throw new Error(`Failed to resolve active branch: ${branchResult.error}. ` +
|
|
221
|
+
`Ensure you are in a git repository with a valid branch checked out.`);
|
|
222
|
+
}
|
|
223
|
+
branch = branchResult.branch;
|
|
224
|
+
reason = "git";
|
|
225
|
+
}
|
|
226
|
+
const kbPath = resolveKbPath(workspaceRoot, branch);
|
|
227
|
+
return { workspaceRoot, branch, kbPath, reason };
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Check if repository is in detached HEAD state.
|
|
231
|
+
*/
|
|
232
|
+
export function isDetachedHead(workspaceRoot = process.cwd()) {
|
|
233
|
+
try {
|
|
234
|
+
const branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
235
|
+
cwd: workspaceRoot,
|
|
236
|
+
encoding: "utf8",
|
|
237
|
+
timeout: 5000,
|
|
238
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
239
|
+
}).trim();
|
|
240
|
+
return branch === "HEAD";
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Validate a branch name for safety.
|
|
248
|
+
*/
|
|
249
|
+
export function isValidBranchName(name) {
|
|
250
|
+
if (!name || name.length === 0 || name.length > 255)
|
|
251
|
+
return false;
|
|
252
|
+
// Reject path traversal attempts
|
|
253
|
+
if (name.includes("..") || path.isAbsolute(name) || name.startsWith("/")) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
// Only allow safe characters
|
|
257
|
+
if (!/^[a-zA-Z0-9._\-/+]+$/.test(name))
|
|
258
|
+
return false;
|
|
259
|
+
// Reject problematic patterns
|
|
260
|
+
if (name.includes("//") ||
|
|
261
|
+
name.endsWith("/") ||
|
|
262
|
+
name.endsWith(".") ||
|
|
263
|
+
name.includes("\\") ||
|
|
264
|
+
name.startsWith("-")) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Get a detailed diagnostic message for branch resolution failures.
|
|
271
|
+
*/
|
|
272
|
+
export function getBranchDiagnostic(branch, error) {
|
|
273
|
+
const lines = ["Branch Resolution Failed", "", `Reason: ${error}`];
|
|
274
|
+
if (branch) {
|
|
275
|
+
lines.push(`Detected branch: ${branch}`);
|
|
276
|
+
}
|
|
277
|
+
lines.push("", "Resolution options:", "1. Set KIBI_BRANCH environment variable to explicitly specify the branch:", " export KIBI_BRANCH=main", "", "2. Ensure you are in a git repository with a valid checked-out branch", "", "3. If in detached HEAD state, create or checkout a branch:", " git checkout -b my-branch", "", "4. For non-git workspaces, always use KIBI_BRANCH:", " KIBI_BRANCH=feature-branch kibi sync");
|
|
278
|
+
return lines.join("\n");
|
|
279
|
+
}
|
|
280
|
+
function readFirstEnv(keys) {
|
|
281
|
+
for (const key of keys) {
|
|
282
|
+
const value = process.env[key]?.trim();
|
|
283
|
+
if (value) {
|
|
284
|
+
return value;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
function findUpwards(startDir, marker) {
|
|
290
|
+
let current = path.resolve(startDir);
|
|
291
|
+
while (true) {
|
|
292
|
+
const candidate = path.join(current, marker);
|
|
293
|
+
try {
|
|
294
|
+
// Check if path exists (works for both files and directories)
|
|
295
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
296
|
+
import("node:fs").then((fs) => {
|
|
297
|
+
fs.accessSync(candidate);
|
|
298
|
+
});
|
|
299
|
+
return current;
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
const parent = path.dirname(current);
|
|
303
|
+
if (parent === current) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
current = parent;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function isBranchPath(p) {
|
|
311
|
+
const parent = path.basename(path.dirname(p));
|
|
312
|
+
return parent === "branches";
|
|
313
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prolog codec utilities for escaping atoms, parsing responses, and handling
|
|
3
|
+
* Prolog list/property structures.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Escape a string for use as a Prolog atom.
|
|
7
|
+
* Doubles single-quote characters per ISO Prolog standard.
|
|
8
|
+
*/
|
|
9
|
+
export declare function escapeAtom(value: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Convert a string to a Prolog atom, quoting if necessary.
|
|
12
|
+
* Simple atoms (lowercase start, alphanumeric + underscore) pass through.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toPrologAtom(value: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Escape a string for embedding inside a single-quoted Prolog atom.
|
|
17
|
+
* Alias for escapeAtom for semantic clarity.
|
|
18
|
+
*/
|
|
19
|
+
export declare function escapeAtomContent(value: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Split a string by delimiter at the top level (not inside brackets or quotes).
|
|
22
|
+
* This is the general-purpose version that splits at depth 0.
|
|
23
|
+
*/
|
|
24
|
+
export declare function splitTopLevel(str: string, delimiter: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Parse a Prolog list of lists into a JavaScript array.
|
|
27
|
+
* Input: "[[a,b,c],[d,e,f]]"
|
|
28
|
+
* Output: [["a", "b", "c"], ["d", "e", "f"]]
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseListOfLists(listStr: string): string[][];
|
|
31
|
+
/**
|
|
32
|
+
* Parse a single entity from Prolog binding format.
|
|
33
|
+
* Input: "[abc123, req, [id=abc123, title=\"Test\", ...]]"
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseEntityFromBinding(bindingStr: string): Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Parse entity from array returned by parseListOfLists.
|
|
38
|
+
* Input: ["abc123", "req", "[id=abc123, title=\"Test\", ...]"]
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseEntityFromList(data: string[]): Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* Parse Prolog property list into JavaScript object.
|
|
43
|
+
* Input: "[id=abc123, title=\"Test\"]"
|
|
44
|
+
*/
|
|
45
|
+
export declare function parsePropertyList(propsStr: string): Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Parse a single Prolog value, handling typed literals and URIs.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parsePrologValue(valueInput: string): unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Parse an atom list from Prolog response.
|
|
52
|
+
* Input: "[a, b, c]" or atom string
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseAtomList(raw: string): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Parse a list of pairs from Prolog response.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parsePairList(raw: string): Array<[string, string]>;
|
|
59
|
+
/**
|
|
60
|
+
* Parse a list of triples from Prolog response.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseTriples(raw: string): Array<[string, string, string]>;
|
|
63
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/prolog/codec.ts"],"names":[],"mappings":"AAUA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKlD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAwDtE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CA6C5D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAczB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAW3E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6B3E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CA2E5D;AAmED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAcnD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAclE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAczE"}
|