@coggit/core 0.2.0 → 0.2.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.
- package/CHANGELOG.md +8 -2
- package/dist/internal.js +173 -739
- package/dist/public.js +114 -734
- package/package.json +1 -1
package/dist/public.js
CHANGED
|
@@ -5,14 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res, err) => function __init() {
|
|
9
|
-
if (err) throw err[0];
|
|
10
|
-
try {
|
|
11
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
-
} catch (e) {
|
|
13
|
-
throw err = [e], e;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
17
9
|
try {
|
|
18
10
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -42,243 +34,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
42
34
|
));
|
|
43
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
44
36
|
|
|
45
|
-
// src/path-utils.ts
|
|
46
|
-
var path_utils_exports = {};
|
|
47
|
-
__export(path_utils_exports, {
|
|
48
|
-
basename: () => basename,
|
|
49
|
-
dirname: () => dirname,
|
|
50
|
-
isAbsolute: () => isAbsolute,
|
|
51
|
-
join: () => join,
|
|
52
|
-
normalize: () => normalize,
|
|
53
|
-
posix: () => posix,
|
|
54
|
-
relative: () => relative,
|
|
55
|
-
resolve: () => resolve,
|
|
56
|
-
win32: () => win32
|
|
57
|
-
});
|
|
58
|
-
function isAbsolute(p) {
|
|
59
|
-
return p.startsWith("/") || /^[a-zA-Z]:[/\\]/.test(p);
|
|
60
|
-
}
|
|
61
|
-
function dirname(p) {
|
|
62
|
-
const trimmed = p.replace(/[/\\]+$/, "");
|
|
63
|
-
const idx = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
|
|
64
|
-
if (idx < 0) {
|
|
65
|
-
return ".";
|
|
66
|
-
}
|
|
67
|
-
if (idx === 0) {
|
|
68
|
-
return "/";
|
|
69
|
-
}
|
|
70
|
-
return trimmed.slice(0, idx);
|
|
71
|
-
}
|
|
72
|
-
function basename(p) {
|
|
73
|
-
const trimmed = p.replace(/[/\\]+$/, "");
|
|
74
|
-
return trimmed.slice(Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\")) + 1);
|
|
75
|
-
}
|
|
76
|
-
function normalizeParts(p) {
|
|
77
|
-
const parts = [];
|
|
78
|
-
for (const seg of p.replace(/\\/g, "/").split("/")) {
|
|
79
|
-
if (seg === "" || seg === ".") {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (seg === "..") {
|
|
83
|
-
if (parts.length && parts[parts.length - 1] !== "..") {
|
|
84
|
-
parts.pop();
|
|
85
|
-
} else {
|
|
86
|
-
parts.push("..");
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
parts.push(seg);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return parts;
|
|
93
|
-
}
|
|
94
|
-
function normalize(p) {
|
|
95
|
-
const prefix = p.startsWith("/") ? "/" : /^[a-zA-Z]:[/\\]/.test(p) ? p.slice(0, 3) : "";
|
|
96
|
-
return prefix + normalizeParts(p).join("/");
|
|
97
|
-
}
|
|
98
|
-
function resolve(...segments) {
|
|
99
|
-
if (segments.length === 0) {
|
|
100
|
-
return ".";
|
|
101
|
-
}
|
|
102
|
-
let resolved = "";
|
|
103
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
104
|
-
const segment = segments[i];
|
|
105
|
-
if (!segment) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
resolved = resolved ? `${segment}/${resolved}` : segment;
|
|
109
|
-
if (isAbsolute(segment)) {
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return normalize(resolved || ".");
|
|
114
|
-
}
|
|
115
|
-
function relative(from, to) {
|
|
116
|
-
const a = normalizeParts(from);
|
|
117
|
-
const b = normalizeParts(to);
|
|
118
|
-
let i = 0;
|
|
119
|
-
while (i < a.length && i < b.length && a[i] === b[i]) {
|
|
120
|
-
i++;
|
|
121
|
-
}
|
|
122
|
-
const up = a.slice(i).map(() => "..");
|
|
123
|
-
const down = b.slice(i);
|
|
124
|
-
return up.concat(down).join("/") || ".";
|
|
125
|
-
}
|
|
126
|
-
function join(...segments) {
|
|
127
|
-
return normalize(segments.join("/"));
|
|
128
|
-
}
|
|
129
|
-
var posix, win32;
|
|
130
|
-
var init_path_utils = __esm({
|
|
131
|
-
"src/path-utils.ts"() {
|
|
132
|
-
"use strict";
|
|
133
|
-
posix = {
|
|
134
|
-
isAbsolute(p) {
|
|
135
|
-
return p.startsWith("/");
|
|
136
|
-
},
|
|
137
|
-
parse(p) {
|
|
138
|
-
const i = p.lastIndexOf("/");
|
|
139
|
-
const dir = i < 0 ? "" : p.slice(0, i);
|
|
140
|
-
const file = i < 0 ? p : p.slice(i + 1);
|
|
141
|
-
const j = file.lastIndexOf(".");
|
|
142
|
-
if (j <= 0) {
|
|
143
|
-
return { dir, name: file, ext: "" };
|
|
144
|
-
}
|
|
145
|
-
return { dir, name: file.slice(0, j), ext: file.slice(j) };
|
|
146
|
-
},
|
|
147
|
-
join(...segments) {
|
|
148
|
-
return posix.normalize(segments.join("/"));
|
|
149
|
-
},
|
|
150
|
-
normalize(p) {
|
|
151
|
-
const parts = [];
|
|
152
|
-
for (const seg of p.split("/")) {
|
|
153
|
-
if (seg === "" || seg === ".") {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (seg === "..") {
|
|
157
|
-
if (parts.length && parts[parts.length - 1] !== "..") {
|
|
158
|
-
parts.pop();
|
|
159
|
-
} else {
|
|
160
|
-
parts.push("..");
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
parts.push(seg);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return (p.startsWith("/") ? "/" : "") + parts.join("/");
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
win32 = {
|
|
170
|
-
isAbsolute(p) {
|
|
171
|
-
return /^[a-zA-Z]:[/\\]/.test(p);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// src/uri-utils.ts
|
|
178
|
-
var uri_utils_exports = {};
|
|
179
|
-
__export(uri_utils_exports, {
|
|
180
|
-
externalPathFromString: () => externalPathFromString,
|
|
181
|
-
formatUri: () => formatUri,
|
|
182
|
-
isEqualOrChildUri: () => isEqualOrChildUri,
|
|
183
|
-
joinUriPath: () => joinUriPath,
|
|
184
|
-
parseUriKey: () => parseUriKey,
|
|
185
|
-
uriBasename: () => uriBasename,
|
|
186
|
-
uriKey: () => uriKey,
|
|
187
|
-
uriRelativePath: () => uriRelativePath,
|
|
188
|
-
uriToExternalPath: () => uriToExternalPath
|
|
189
|
-
});
|
|
190
|
-
function uriKey(components) {
|
|
191
|
-
return `${components.scheme}://${components.authority}${components.path}${components.query ? "?" + components.query : ""}${components.fragment ? "#" + components.fragment : ""}`;
|
|
192
|
-
}
|
|
193
|
-
function uriRelativePath(root, child) {
|
|
194
|
-
if (root.scheme !== child.scheme || root.authority !== child.authority) {
|
|
195
|
-
return void 0;
|
|
196
|
-
}
|
|
197
|
-
const rootPath = trimTrailingSlash(root.path);
|
|
198
|
-
const childPath = trimTrailingSlash(child.path);
|
|
199
|
-
if (childPath === rootPath) {
|
|
200
|
-
return ".";
|
|
201
|
-
}
|
|
202
|
-
const prefix = rootPath + "/";
|
|
203
|
-
if (!childPath.startsWith(prefix)) {
|
|
204
|
-
return void 0;
|
|
205
|
-
}
|
|
206
|
-
return childPath.slice(prefix.length) || ".";
|
|
207
|
-
}
|
|
208
|
-
function isEqualOrChildUri(parent, child) {
|
|
209
|
-
return uriRelativePath(parent, child) !== void 0;
|
|
210
|
-
}
|
|
211
|
-
function joinUriPath(base, ...segments) {
|
|
212
|
-
let joined = trimTrailingSlash(base.path);
|
|
213
|
-
for (const seg of segments) {
|
|
214
|
-
if (seg === "..") {
|
|
215
|
-
const idx = joined.lastIndexOf("/");
|
|
216
|
-
if (idx > 0) {
|
|
217
|
-
joined = joined.slice(0, idx);
|
|
218
|
-
} else {
|
|
219
|
-
joined = "/";
|
|
220
|
-
}
|
|
221
|
-
} else if (seg !== ".") {
|
|
222
|
-
joined = joined === "/" ? "/" + seg : joined + "/" + seg;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return { ...base, path: joined };
|
|
226
|
-
}
|
|
227
|
-
function uriBasename(uri) {
|
|
228
|
-
const p = trimTrailingSlash(uri.path);
|
|
229
|
-
const idx = p.lastIndexOf("/");
|
|
230
|
-
return idx >= 0 ? p.slice(idx + 1) : p;
|
|
231
|
-
}
|
|
232
|
-
function formatUri(uri) {
|
|
233
|
-
return uriKey(uri);
|
|
234
|
-
}
|
|
235
|
-
function trimTrailingSlash(value) {
|
|
236
|
-
return value.length > 1 ? value.replace(/\/+$/u, "") : value;
|
|
237
|
-
}
|
|
238
|
-
function uriToExternalPath(uri) {
|
|
239
|
-
if (uri.scheme === "file") {
|
|
240
|
-
const p = uri.path;
|
|
241
|
-
if (/^\/[a-zA-Z]:[/\\]/u.test(p)) {
|
|
242
|
-
return p.slice(1);
|
|
243
|
-
}
|
|
244
|
-
return p;
|
|
245
|
-
}
|
|
246
|
-
return uriKey(uri);
|
|
247
|
-
}
|
|
248
|
-
function externalPathFromString(uriKeyStr) {
|
|
249
|
-
if (uriKeyStr.startsWith("file://")) {
|
|
250
|
-
const withoutScheme = uriKeyStr.slice(7);
|
|
251
|
-
if (/^\/[a-zA-Z]:[/\\]/u.test(withoutScheme)) {
|
|
252
|
-
return withoutScheme.slice(1);
|
|
253
|
-
}
|
|
254
|
-
return withoutScheme;
|
|
255
|
-
}
|
|
256
|
-
return uriKeyStr;
|
|
257
|
-
}
|
|
258
|
-
function parseUriKey(uriKeyStr) {
|
|
259
|
-
const schemeEnd = uriKeyStr.indexOf("://");
|
|
260
|
-
if (schemeEnd === -1) {
|
|
261
|
-
throw new Error(`Invalid URI key: ${uriKeyStr}`);
|
|
262
|
-
}
|
|
263
|
-
const scheme = uriKeyStr.slice(0, schemeEnd);
|
|
264
|
-
const rest = uriKeyStr.slice(schemeEnd + 3);
|
|
265
|
-
const authEnd = rest.indexOf("/");
|
|
266
|
-
const authority = authEnd === -1 ? rest : rest.slice(0, authEnd);
|
|
267
|
-
const pathAndMaybeQuery = authEnd === -1 ? "" : rest.slice(authEnd);
|
|
268
|
-
const qIdx = pathAndMaybeQuery.indexOf("?");
|
|
269
|
-
const fIdx = pathAndMaybeQuery.indexOf("#");
|
|
270
|
-
const pathEnd = qIdx !== -1 ? qIdx : fIdx !== -1 ? fIdx : pathAndMaybeQuery.length;
|
|
271
|
-
const path = pathAndMaybeQuery.slice(0, pathEnd);
|
|
272
|
-
const query = qIdx !== -1 ? pathAndMaybeQuery.slice(qIdx + 1, fIdx !== -1 ? fIdx : void 0) : "";
|
|
273
|
-
const fragment = fIdx !== -1 ? pathAndMaybeQuery.slice(fIdx + 1) : "";
|
|
274
|
-
return { scheme, authority, path: path || "/", query, fragment };
|
|
275
|
-
}
|
|
276
|
-
var init_uri_utils = __esm({
|
|
277
|
-
"src/uri-utils.ts"() {
|
|
278
|
-
"use strict";
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
|
|
282
37
|
// ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
|
|
283
38
|
var require_identity = __commonJS({
|
|
284
39
|
"../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js"(exports2) {
|
|
@@ -7606,459 +7361,6 @@ var require_dist = __commonJS({
|
|
|
7606
7361
|
}
|
|
7607
7362
|
});
|
|
7608
7363
|
|
|
7609
|
-
// src/mapping.js
|
|
7610
|
-
var require_mapping = __commonJS({
|
|
7611
|
-
"src/mapping.js"(exports2) {
|
|
7612
|
-
"use strict";
|
|
7613
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
7614
|
-
if (k2 === void 0) k2 = k;
|
|
7615
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7616
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7617
|
-
desc = { enumerable: true, get: function() {
|
|
7618
|
-
return m[k];
|
|
7619
|
-
} };
|
|
7620
|
-
}
|
|
7621
|
-
Object.defineProperty(o, k2, desc);
|
|
7622
|
-
}) : (function(o, m, k, k2) {
|
|
7623
|
-
if (k2 === void 0) k2 = k;
|
|
7624
|
-
o[k2] = m[k];
|
|
7625
|
-
}));
|
|
7626
|
-
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
7627
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
7628
|
-
}) : function(o, v) {
|
|
7629
|
-
o["default"] = v;
|
|
7630
|
-
});
|
|
7631
|
-
var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
|
|
7632
|
-
var ownKeys = function(o) {
|
|
7633
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
7634
|
-
var ar = [];
|
|
7635
|
-
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
7636
|
-
return ar;
|
|
7637
|
-
};
|
|
7638
|
-
return ownKeys(o);
|
|
7639
|
-
};
|
|
7640
|
-
return function(mod) {
|
|
7641
|
-
if (mod && mod.__esModule) return mod;
|
|
7642
|
-
var result = {};
|
|
7643
|
-
if (mod != null) {
|
|
7644
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
7645
|
-
}
|
|
7646
|
-
__setModuleDefault(result, mod);
|
|
7647
|
-
return result;
|
|
7648
|
-
};
|
|
7649
|
-
})();
|
|
7650
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7651
|
-
exports2.getProjectRootPath = getProjectRootPath;
|
|
7652
|
-
exports2.resolveConfigRoots = resolveConfigRoots2;
|
|
7653
|
-
exports2.resolveConfigRootPaths = resolveConfigRootPaths;
|
|
7654
|
-
exports2.resolvePath = resolvePath;
|
|
7655
|
-
exports2.toRelativePath = toRelativePath;
|
|
7656
|
-
exports2.toRelativeUriPath = toRelativeUriPath4;
|
|
7657
|
-
exports2.normalizeSourcePathInput = normalizeSourcePathInput2;
|
|
7658
|
-
exports2.sourceIdentityToCognitionIdentity = sourceIdentityToCognitionIdentity2;
|
|
7659
|
-
exports2.cognitionIdentityToSourceIdentity = cognitionIdentityToSourceIdentity2;
|
|
7660
|
-
exports2.toCognitionFilePath = toCognitionFilePath;
|
|
7661
|
-
exports2.toCognitionFileUri = toCognitionFileUri2;
|
|
7662
|
-
exports2.toCognitionFolderReadmePath = toCognitionFolderReadmePath;
|
|
7663
|
-
exports2.toCognitionFolderReadmeUri = toCognitionFolderReadmeUri2;
|
|
7664
|
-
exports2.inferSourceUriFromCognitionUri = inferSourceUriFromCognitionUri;
|
|
7665
|
-
exports2.inferSourceUriCandidatesFromCognitionUri = inferSourceUriCandidatesFromCognitionUri2;
|
|
7666
|
-
exports2.sourceIdentityToProjectRelative = sourceIdentityToProjectRelative2;
|
|
7667
|
-
exports2.cognitionIdentityToProjectRelative = cognitionIdentityToProjectRelative2;
|
|
7668
|
-
exports2.projectRelativeToSourceIdentity = projectRelativeToSourceIdentity;
|
|
7669
|
-
exports2.getParentDir = getParentDir;
|
|
7670
|
-
exports2.isWithin = isWithin;
|
|
7671
|
-
exports2.basename = basename3;
|
|
7672
|
-
var path = __importStar((init_path_utils(), __toCommonJS(path_utils_exports)));
|
|
7673
|
-
var uri_utils_1 = (init_uri_utils(), __toCommonJS(uri_utils_exports));
|
|
7674
|
-
function getProjectRootPath(configPath) {
|
|
7675
|
-
return path.resolve(path.dirname(configPath), "..");
|
|
7676
|
-
}
|
|
7677
|
-
function resolveConfigRoots2(configUri, config) {
|
|
7678
|
-
const projectRootUri = (0, uri_utils_1.joinUriPath)(configUri, "..", "..");
|
|
7679
|
-
return {
|
|
7680
|
-
projectRootUri,
|
|
7681
|
-
sourceRootUri: resolveUri2(projectRootUri, config.sourceRoot),
|
|
7682
|
-
cognitionRootUri: resolveUri2(projectRootUri, config.cognitionRoot)
|
|
7683
|
-
};
|
|
7684
|
-
}
|
|
7685
|
-
function resolveConfigRootPaths(configPath, config) {
|
|
7686
|
-
const projectRoot = getProjectRootPath(configPath);
|
|
7687
|
-
return {
|
|
7688
|
-
projectRoot,
|
|
7689
|
-
sourceRoot: resolvePath(projectRoot, config.sourceRoot),
|
|
7690
|
-
cognitionRoot: resolvePath(projectRoot, config.cognitionRoot)
|
|
7691
|
-
};
|
|
7692
|
-
}
|
|
7693
|
-
function resolvePath(basePath, targetPath) {
|
|
7694
|
-
if (path.isAbsolute(targetPath)) {
|
|
7695
|
-
return path.normalize(targetPath);
|
|
7696
|
-
}
|
|
7697
|
-
return path.resolve(basePath, targetPath);
|
|
7698
|
-
}
|
|
7699
|
-
function resolveUri2(baseUri, targetPath) {
|
|
7700
|
-
if (isAbsoluteFsPath2(targetPath)) {
|
|
7701
|
-
return { ...baseUri, path: normalizeUriPath2(targetPath) };
|
|
7702
|
-
}
|
|
7703
|
-
const segments = normalizePath2(targetPath).split("/").filter((segment) => segment.length > 0 && segment !== ".");
|
|
7704
|
-
return segments.length === 0 ? baseUri : (0, uri_utils_1.joinUriPath)(baseUri, ...segments);
|
|
7705
|
-
}
|
|
7706
|
-
function isAbsoluteFsPath2(targetPath) {
|
|
7707
|
-
return path.posix.isAbsolute(targetPath) || path.win32.isAbsolute(targetPath);
|
|
7708
|
-
}
|
|
7709
|
-
function normalizeUriPath2(targetPath) {
|
|
7710
|
-
const normalized = normalizePath2(targetPath);
|
|
7711
|
-
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
7712
|
-
}
|
|
7713
|
-
function toRelativePath(sourceRootPath, sourcePath) {
|
|
7714
|
-
return normalizePath2(path.relative(sourceRootPath, sourcePath));
|
|
7715
|
-
}
|
|
7716
|
-
function toRelativeUriPath4(rootUri, uri) {
|
|
7717
|
-
const relativePath = (0, uri_utils_1.uriRelativePath)(rootUri, uri);
|
|
7718
|
-
if (relativePath === void 0) {
|
|
7719
|
-
throw new Error(`URI is not under root: ${(0, uri_utils_1.uriKey)(uri)} is not under ${(0, uri_utils_1.uriKey)(rootUri)}`);
|
|
7720
|
-
}
|
|
7721
|
-
return relativePath;
|
|
7722
|
-
}
|
|
7723
|
-
function normalizeSourcePathInput2(sourcePath, context) {
|
|
7724
|
-
const normalizedPath = trimSlashes2(sourcePath.replace(/\\/g, "/"));
|
|
7725
|
-
if (normalizedPath === "" || normalizedPath === ".") {
|
|
7726
|
-
return normalizedPath;
|
|
7727
|
-
}
|
|
7728
|
-
const sourceRoot = context?.sourceRoot ? trimSlashes2(context.sourceRoot.replace(/\\/g, "/")) : sourceRootPrefixFromUris2(context);
|
|
7729
|
-
if (!sourceRoot || sourceRoot === ".") {
|
|
7730
|
-
return normalizedPath;
|
|
7731
|
-
}
|
|
7732
|
-
if (normalizedPath === sourceRoot) {
|
|
7733
|
-
return ".";
|
|
7734
|
-
}
|
|
7735
|
-
if (normalizedPath.startsWith(sourceRoot + "/")) {
|
|
7736
|
-
return normalizedPath.slice(sourceRoot.length + 1) || ".";
|
|
7737
|
-
}
|
|
7738
|
-
return normalizedPath;
|
|
7739
|
-
}
|
|
7740
|
-
function sourceRootPrefixFromUris2(context) {
|
|
7741
|
-
if (!context?.projectRootUri || !context.sourceRootUri) {
|
|
7742
|
-
return void 0;
|
|
7743
|
-
}
|
|
7744
|
-
return toRelativeUriPath4(context.projectRootUri, context.sourceRootUri);
|
|
7745
|
-
}
|
|
7746
|
-
function trimSlashes2(input) {
|
|
7747
|
-
return input.replace(/^\/+|\/+$/gu, "");
|
|
7748
|
-
}
|
|
7749
|
-
function sourceIdentityToCognitionIdentity2(sourceIdentity, kind) {
|
|
7750
|
-
const identity = sourceIdentity === "" ? "." : sourceIdentity;
|
|
7751
|
-
if (kind === "leaf") {
|
|
7752
|
-
return `${identity}.md`;
|
|
7753
|
-
}
|
|
7754
|
-
return identity === "." ? "README.md" : `${identity}/README.md`;
|
|
7755
|
-
}
|
|
7756
|
-
function cognitionIdentityToSourceIdentity2(cognitionIdentity) {
|
|
7757
|
-
const normalized = cognitionIdentity.replace(/\\/g, "/");
|
|
7758
|
-
if (!normalized.endsWith(".md")) {
|
|
7759
|
-
return void 0;
|
|
7760
|
-
}
|
|
7761
|
-
const withoutMd = normalized.slice(0, -".md".length);
|
|
7762
|
-
if (withoutMd === "") {
|
|
7763
|
-
return void 0;
|
|
7764
|
-
}
|
|
7765
|
-
if (withoutMd === "README") {
|
|
7766
|
-
return { sourceIdentity: ".", kind: "folder" };
|
|
7767
|
-
}
|
|
7768
|
-
const lastSegment = withoutMd.split("/").pop();
|
|
7769
|
-
if (lastSegment === "README") {
|
|
7770
|
-
return {
|
|
7771
|
-
sourceIdentity: withoutMd.slice(0, -"/README".length) || ".",
|
|
7772
|
-
kind: "folder"
|
|
7773
|
-
};
|
|
7774
|
-
}
|
|
7775
|
-
const hasSourceExtension = lastSegment.startsWith(".") ? lastSegment.slice(1).includes(".") : lastSegment.includes(".");
|
|
7776
|
-
if (!hasSourceExtension) {
|
|
7777
|
-
return void 0;
|
|
7778
|
-
}
|
|
7779
|
-
return { sourceIdentity: withoutMd, kind: "leaf" };
|
|
7780
|
-
}
|
|
7781
|
-
function toCognitionFilePath(sourceRootPath, cognitionRootPath, sourceFilePath) {
|
|
7782
|
-
const rel = toRelativePath(sourceRootPath, sourceFilePath);
|
|
7783
|
-
return path.join(cognitionRootPath, sourceIdentityToCognitionIdentity2(rel, "leaf"));
|
|
7784
|
-
}
|
|
7785
|
-
function toCognitionFileUri2(sourceRootUri, cognitionRootUri, sourceFileUri) {
|
|
7786
|
-
const rel = toRelativeUriPath4(sourceRootUri, sourceFileUri);
|
|
7787
|
-
return joinIdentityPath2(cognitionRootUri, sourceIdentityToCognitionIdentity2(rel, "leaf"));
|
|
7788
|
-
}
|
|
7789
|
-
function toCognitionFolderReadmePath(sourceRootPath, cognitionRootPath, folderPath) {
|
|
7790
|
-
const rel = toRelativePath(sourceRootPath, folderPath);
|
|
7791
|
-
return path.join(cognitionRootPath, sourceIdentityToCognitionIdentity2(rel, "folder"));
|
|
7792
|
-
}
|
|
7793
|
-
function toCognitionFolderReadmeUri2(sourceRootUri, cognitionRootUri, folderUri) {
|
|
7794
|
-
const rel = toRelativeUriPath4(sourceRootUri, folderUri);
|
|
7795
|
-
return joinIdentityPath2(cognitionRootUri, sourceIdentityToCognitionIdentity2(rel, "folder"));
|
|
7796
|
-
}
|
|
7797
|
-
function inferSourceUriFromCognitionUri(cognitionUri, sourceRootUri, cognitionRootUri) {
|
|
7798
|
-
const candidates = inferSourceUriCandidatesFromCognitionUri2(cognitionUri, sourceRootUri, cognitionRootUri);
|
|
7799
|
-
return candidates[0];
|
|
7800
|
-
}
|
|
7801
|
-
function inferSourceUriCandidatesFromCognitionUri2(cognitionUri, sourceRootUri, cognitionRootUri) {
|
|
7802
|
-
const relativePath = toRelativeUriPath4(cognitionRootUri, cognitionUri);
|
|
7803
|
-
if (relativePath === ".") {
|
|
7804
|
-
return [];
|
|
7805
|
-
}
|
|
7806
|
-
const mapped = cognitionIdentityToSourceIdentity2(relativePath);
|
|
7807
|
-
if (!mapped) {
|
|
7808
|
-
return [];
|
|
7809
|
-
}
|
|
7810
|
-
return [joinIdentityPath2(sourceRootUri, mapped.sourceIdentity)];
|
|
7811
|
-
}
|
|
7812
|
-
function sourceIdentityToProjectRelative2(root, sourceIdentity) {
|
|
7813
|
-
return prependRootName2(rootName2(root.projectRootUri, root.sourceRootUri), sourceIdentity);
|
|
7814
|
-
}
|
|
7815
|
-
function cognitionIdentityToProjectRelative2(root, cognitionIdentity) {
|
|
7816
|
-
return prependRootName2(rootName2(root.projectRootUri, root.cognitionRootUri), cognitionIdentity);
|
|
7817
|
-
}
|
|
7818
|
-
function projectRelativeToSourceIdentity(root, projectRelative) {
|
|
7819
|
-
return stripRootName(rootName2(root.projectRootUri, root.sourceRootUri), projectRelative);
|
|
7820
|
-
}
|
|
7821
|
-
function rootName2(projectRootUri, rootUri) {
|
|
7822
|
-
return toRelativeUriPath4(projectRootUri, rootUri);
|
|
7823
|
-
}
|
|
7824
|
-
function prependRootName2(rootName3, identity) {
|
|
7825
|
-
if (rootName3 === "." || rootName3 === "") {
|
|
7826
|
-
return identity === "" ? "." : identity;
|
|
7827
|
-
}
|
|
7828
|
-
if (identity === "." || identity === "") {
|
|
7829
|
-
return rootName3;
|
|
7830
|
-
}
|
|
7831
|
-
return `${rootName3}/${identity}`;
|
|
7832
|
-
}
|
|
7833
|
-
function stripRootName(rootName3, projectRelative) {
|
|
7834
|
-
const normalized = projectRelative.replace(/\\/g, "/").replace(/^\/+|\/+$/gu, "");
|
|
7835
|
-
if (rootName3 === "." || rootName3 === "") {
|
|
7836
|
-
return normalized === "" ? "." : normalized;
|
|
7837
|
-
}
|
|
7838
|
-
if (normalized === rootName3) {
|
|
7839
|
-
return ".";
|
|
7840
|
-
}
|
|
7841
|
-
if (normalized.startsWith(`${rootName3}/`)) {
|
|
7842
|
-
return normalized.slice(rootName3.length + 1) || ".";
|
|
7843
|
-
}
|
|
7844
|
-
return normalized;
|
|
7845
|
-
}
|
|
7846
|
-
function joinIdentityPath2(base, identity) {
|
|
7847
|
-
const segments = identity.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0 && segment !== ".");
|
|
7848
|
-
return segments.length === 0 ? base : (0, uri_utils_1.joinUriPath)(base, ...segments);
|
|
7849
|
-
}
|
|
7850
|
-
function getParentDir(filePath) {
|
|
7851
|
-
return path.dirname(filePath);
|
|
7852
|
-
}
|
|
7853
|
-
function isWithin(parentPath, childPath) {
|
|
7854
|
-
const rel = path.relative(parentPath, childPath);
|
|
7855
|
-
return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
7856
|
-
}
|
|
7857
|
-
function basename3(filePath) {
|
|
7858
|
-
return path.basename(filePath);
|
|
7859
|
-
}
|
|
7860
|
-
function normalizePath2(targetPath) {
|
|
7861
|
-
const normalized = targetPath.replace(/\\/g, "/");
|
|
7862
|
-
return normalized === "" ? "." : normalized;
|
|
7863
|
-
}
|
|
7864
|
-
}
|
|
7865
|
-
});
|
|
7866
|
-
|
|
7867
|
-
// src/pathHints.js
|
|
7868
|
-
var require_pathHints = __commonJS({
|
|
7869
|
-
"src/pathHints.js"(exports2) {
|
|
7870
|
-
"use strict";
|
|
7871
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7872
|
-
exports2.PATH_HINT_MESSAGE = exports2.PATH_MISS_MESSAGE = void 0;
|
|
7873
|
-
exports2.suggestPathHints = suggestPathHints3;
|
|
7874
|
-
exports2.pathMissMessage = pathMissMessage2;
|
|
7875
|
-
exports2.pathHintsTryText = pathHintsTryText2;
|
|
7876
|
-
exports2.renderPathMissText = renderPathMissText2;
|
|
7877
|
-
var HINT_COLLECT_CAP2 = 5;
|
|
7878
|
-
function suggestPathHints3(candidatePaths, sourcePath) {
|
|
7879
|
-
if (sourcePath === "" || sourcePath === ".") {
|
|
7880
|
-
return [];
|
|
7881
|
-
}
|
|
7882
|
-
const hints = /* @__PURE__ */ new Set();
|
|
7883
|
-
for (const candidate of candidatePaths) {
|
|
7884
|
-
if (pathHintMatches2(candidate, sourcePath)) {
|
|
7885
|
-
hints.add(candidate);
|
|
7886
|
-
if (hints.size >= HINT_COLLECT_CAP2) {
|
|
7887
|
-
break;
|
|
7888
|
-
}
|
|
7889
|
-
}
|
|
7890
|
-
}
|
|
7891
|
-
return [...hints];
|
|
7892
|
-
}
|
|
7893
|
-
var PATH_MISS_BASE2 = "Path not found in any CogGit project";
|
|
7894
|
-
exports2.PATH_MISS_MESSAGE = `${PATH_MISS_BASE2}.`;
|
|
7895
|
-
exports2.PATH_HINT_MESSAGE = "You may mean one of these source-root-relative source paths.";
|
|
7896
|
-
function pathMissMessage2(sourcePath) {
|
|
7897
|
-
return `${PATH_MISS_BASE2}: ${sourcePath}`;
|
|
7898
|
-
}
|
|
7899
|
-
function pathHintsTryText2(pathHints) {
|
|
7900
|
-
return `Try: ${pathHints.map((hint) => `\`${hint}\``).join(", ")}`;
|
|
7901
|
-
}
|
|
7902
|
-
function renderPathMissText2(result) {
|
|
7903
|
-
const lines = [result.pathMissMessage ?? pathMissMessage2(result.sourcePath ?? "")];
|
|
7904
|
-
if (result.pathHintMessage && result.pathHints.length > 0) {
|
|
7905
|
-
lines.push(result.pathHintMessage);
|
|
7906
|
-
lines.push(pathHintsTryText2(result.pathHints));
|
|
7907
|
-
}
|
|
7908
|
-
return lines.join("\n");
|
|
7909
|
-
}
|
|
7910
|
-
function pathHintMatches2(candidate, sourcePath) {
|
|
7911
|
-
if (candidate === sourcePath) {
|
|
7912
|
-
return false;
|
|
7913
|
-
}
|
|
7914
|
-
const candidateSegments = candidate.split("/").filter(Boolean);
|
|
7915
|
-
const sourceSegments = sourcePath.split("/").filter(Boolean);
|
|
7916
|
-
if (sourceSegments.length === 0) {
|
|
7917
|
-
return false;
|
|
7918
|
-
}
|
|
7919
|
-
if (candidate.endsWith(`/${sourcePath}`)) {
|
|
7920
|
-
return true;
|
|
7921
|
-
}
|
|
7922
|
-
const tail = candidateSegments.slice(-sourceSegments.length);
|
|
7923
|
-
if (tail.length !== sourceSegments.length) {
|
|
7924
|
-
return false;
|
|
7925
|
-
}
|
|
7926
|
-
const queryLeaf = sourceSegments[sourceSegments.length - 1];
|
|
7927
|
-
if (queryLeaf.includes(".")) {
|
|
7928
|
-
return tail.join("/") === sourcePath;
|
|
7929
|
-
}
|
|
7930
|
-
tail[tail.length - 1] = stripLeafExtension2(tail[tail.length - 1]);
|
|
7931
|
-
return tail.join("/") === sourcePath;
|
|
7932
|
-
}
|
|
7933
|
-
function stripLeafExtension2(segment) {
|
|
7934
|
-
if (/^\.+$/u.test(segment)) {
|
|
7935
|
-
return segment;
|
|
7936
|
-
}
|
|
7937
|
-
const dot = segment.lastIndexOf(".");
|
|
7938
|
-
if (dot <= 0) {
|
|
7939
|
-
return segment;
|
|
7940
|
-
}
|
|
7941
|
-
return segment.slice(0, dot);
|
|
7942
|
-
}
|
|
7943
|
-
}
|
|
7944
|
-
});
|
|
7945
|
-
|
|
7946
|
-
// src/projection.js
|
|
7947
|
-
var require_projection = __commonJS({
|
|
7948
|
-
"src/projection.js"(exports2) {
|
|
7949
|
-
"use strict";
|
|
7950
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
7951
|
-
exports2.applyTreeDepth = applyTreeDepth3;
|
|
7952
|
-
exports2.projectTreeFromSnapshot = projectTreeFromSnapshot2;
|
|
7953
|
-
exports2.projectSnapshotTree = projectSnapshotTree2;
|
|
7954
|
-
var mapping_js_1 = require_mapping();
|
|
7955
|
-
function applyTreeDepth3(nodes, depth) {
|
|
7956
|
-
let omittedChildrenCount = 0;
|
|
7957
|
-
const result = nodes.map((node) => {
|
|
7958
|
-
if (depth <= 0) {
|
|
7959
|
-
const nodeOmittedChildrenCount = node.children?.length ?? 0;
|
|
7960
|
-
omittedChildrenCount += nodeOmittedChildrenCount;
|
|
7961
|
-
const { children: _, ...rest } = node;
|
|
7962
|
-
return nodeOmittedChildrenCount > 0 ? {
|
|
7963
|
-
...rest,
|
|
7964
|
-
truncated: true,
|
|
7965
|
-
omittedChildrenCount: nodeOmittedChildrenCount
|
|
7966
|
-
} : rest;
|
|
7967
|
-
}
|
|
7968
|
-
const childResult = node.children ? applyTreeDepth3(node.children, depth - 1) : { nodes: [], truncated: false, omittedChildrenCount: 0 };
|
|
7969
|
-
omittedChildrenCount += childResult.omittedChildrenCount;
|
|
7970
|
-
return {
|
|
7971
|
-
...node,
|
|
7972
|
-
children: childResult.nodes.length > 0 ? childResult.nodes : void 0
|
|
7973
|
-
};
|
|
7974
|
-
});
|
|
7975
|
-
return {
|
|
7976
|
-
nodes: result,
|
|
7977
|
-
truncated: omittedChildrenCount > 0,
|
|
7978
|
-
omittedChildrenCount
|
|
7979
|
-
};
|
|
7980
|
-
}
|
|
7981
|
-
function projectTreeFromSnapshot2(node, options = {}) {
|
|
7982
|
-
const depth = options.depth ?? 2;
|
|
7983
|
-
const scope = options.scope ?? "tracked";
|
|
7984
|
-
const result = renderProjectionNode2(node, 0, { depth, scope });
|
|
7985
|
-
return result ? [result] : [];
|
|
7986
|
-
}
|
|
7987
|
-
function projectSnapshotTree2(snapshot, options = {}) {
|
|
7988
|
-
const depth = options.depth ?? 2;
|
|
7989
|
-
const scope = options.scope ?? "tracked";
|
|
7990
|
-
return snapshot.roots.map((root) => renderProjectionNode2(root, 0, { depth, scope })).filter((node) => node !== void 0);
|
|
7991
|
-
}
|
|
7992
|
-
function renderProjectionNode2(node, currentDepth, options) {
|
|
7993
|
-
const canRenderChildren = options.depth === void 0 || currentDepth < options.depth;
|
|
7994
|
-
const renderedChildren = canRenderChildren ? (node.children ?? []).map((child) => renderProjectionNode2(child, currentDepth + 1, options)).filter((child) => child !== void 0) : [];
|
|
7995
|
-
const matchesScope = nodeMatchesProjectionScope2(node, options.scope);
|
|
7996
|
-
const containsScope = matchesScope || nodeContainsProjectionScope2(node, options.scope);
|
|
7997
|
-
if (!containsScope && renderedChildren.length === 0) {
|
|
7998
|
-
return void 0;
|
|
7999
|
-
}
|
|
8000
|
-
const projectedNode = {
|
|
8001
|
-
path: node.relativePath,
|
|
8002
|
-
label: node.label,
|
|
8003
|
-
kind: node.kind,
|
|
8004
|
-
...node.cognitionUri ? { cognition: toRelativeCognitionPath2(node) } : {},
|
|
8005
|
-
...node.description ? { description: node.description } : {},
|
|
8006
|
-
observedStatus: node.status?.observedStatus ?? null,
|
|
8007
|
-
ownObservedStatus: node.ownStatus?.ownObservedStatus ?? null,
|
|
8008
|
-
tracked: node.ownStatus?.coverage?.ownCognition === "present"
|
|
8009
|
-
};
|
|
8010
|
-
if (renderedChildren.length > 0) {
|
|
8011
|
-
projectedNode.children = renderedChildren;
|
|
8012
|
-
}
|
|
8013
|
-
return projectedNode;
|
|
8014
|
-
}
|
|
8015
|
-
function toRelativeCognitionPath2(node) {
|
|
8016
|
-
if (!node.cognitionUri || !node.root) {
|
|
8017
|
-
return "";
|
|
8018
|
-
}
|
|
8019
|
-
try {
|
|
8020
|
-
return (0, mapping_js_1.toRelativeUriPath)(node.root.cognitionRootUri, node.cognitionUri);
|
|
8021
|
-
} catch {
|
|
8022
|
-
return node.cognitionUri.path;
|
|
8023
|
-
}
|
|
8024
|
-
}
|
|
8025
|
-
function nodeMatchesProjectionScope2(node, scope) {
|
|
8026
|
-
switch (scope) {
|
|
8027
|
-
case "all":
|
|
8028
|
-
return true;
|
|
8029
|
-
case "tracked":
|
|
8030
|
-
return node.ownStatus?.coverage?.ownCognition === "present";
|
|
8031
|
-
case "untracked":
|
|
8032
|
-
return node.ownStatus?.coverage?.ownCognition === "missing" && node.ownStatus.coverage.isMaterializable === true;
|
|
8033
|
-
case "issues":
|
|
8034
|
-
return (node.ownStatus?.issues?.length ?? 0) > 0;
|
|
8035
|
-
default:
|
|
8036
|
-
return false;
|
|
8037
|
-
}
|
|
8038
|
-
}
|
|
8039
|
-
function nodeContainsProjectionScope2(node, scope) {
|
|
8040
|
-
switch (scope) {
|
|
8041
|
-
case "all":
|
|
8042
|
-
return true;
|
|
8043
|
-
case "tracked":
|
|
8044
|
-
return (node.status?.coverage?.coveredCount ?? 0) > 0;
|
|
8045
|
-
case "untracked":
|
|
8046
|
-
return (node.status?.coverage?.missingMaterializableCount ?? 0) > 0;
|
|
8047
|
-
case "issues":
|
|
8048
|
-
return subtreeHasIssues2(node);
|
|
8049
|
-
default:
|
|
8050
|
-
return false;
|
|
8051
|
-
}
|
|
8052
|
-
}
|
|
8053
|
-
function subtreeHasIssues2(node) {
|
|
8054
|
-
if ((node.ownStatus?.issues?.length ?? 0) > 0) {
|
|
8055
|
-
return true;
|
|
8056
|
-
}
|
|
8057
|
-
return (node.children ?? []).some((child) => subtreeHasIssues2(child));
|
|
8058
|
-
}
|
|
8059
|
-
}
|
|
8060
|
-
});
|
|
8061
|
-
|
|
8062
7364
|
// src/public.ts
|
|
8063
7365
|
var public_exports = {};
|
|
8064
7366
|
__export(public_exports, {
|
|
@@ -8213,9 +7515,118 @@ function getEnvLogLevel() {
|
|
|
8213
7515
|
return void 0;
|
|
8214
7516
|
}
|
|
8215
7517
|
|
|
7518
|
+
// src/path-utils.ts
|
|
7519
|
+
function dirname(p) {
|
|
7520
|
+
const trimmed = p.replace(/[/\\]+$/, "");
|
|
7521
|
+
const idx = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
|
|
7522
|
+
if (idx < 0) {
|
|
7523
|
+
return ".";
|
|
7524
|
+
}
|
|
7525
|
+
if (idx === 0) {
|
|
7526
|
+
return "/";
|
|
7527
|
+
}
|
|
7528
|
+
return trimmed.slice(0, idx);
|
|
7529
|
+
}
|
|
7530
|
+
var posix = {
|
|
7531
|
+
isAbsolute(p) {
|
|
7532
|
+
return p.startsWith("/");
|
|
7533
|
+
},
|
|
7534
|
+
parse(p) {
|
|
7535
|
+
const i = p.lastIndexOf("/");
|
|
7536
|
+
const dir = i < 0 ? "" : p.slice(0, i);
|
|
7537
|
+
const file = i < 0 ? p : p.slice(i + 1);
|
|
7538
|
+
const j = file.lastIndexOf(".");
|
|
7539
|
+
if (j <= 0) {
|
|
7540
|
+
return { dir, name: file, ext: "" };
|
|
7541
|
+
}
|
|
7542
|
+
return { dir, name: file.slice(0, j), ext: file.slice(j) };
|
|
7543
|
+
},
|
|
7544
|
+
join(...segments) {
|
|
7545
|
+
return posix.normalize(segments.join("/"));
|
|
7546
|
+
},
|
|
7547
|
+
normalize(p) {
|
|
7548
|
+
const parts = [];
|
|
7549
|
+
for (const seg of p.split("/")) {
|
|
7550
|
+
if (seg === "" || seg === ".") {
|
|
7551
|
+
continue;
|
|
7552
|
+
}
|
|
7553
|
+
if (seg === "..") {
|
|
7554
|
+
if (parts.length && parts[parts.length - 1] !== "..") {
|
|
7555
|
+
parts.pop();
|
|
7556
|
+
} else {
|
|
7557
|
+
parts.push("..");
|
|
7558
|
+
}
|
|
7559
|
+
} else {
|
|
7560
|
+
parts.push(seg);
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
return (p.startsWith("/") ? "/" : "") + parts.join("/");
|
|
7564
|
+
}
|
|
7565
|
+
};
|
|
7566
|
+
var win32 = {
|
|
7567
|
+
isAbsolute(p) {
|
|
7568
|
+
return /^[a-zA-Z]:[/\\]/.test(p);
|
|
7569
|
+
}
|
|
7570
|
+
};
|
|
7571
|
+
|
|
7572
|
+
// src/uri-utils.ts
|
|
7573
|
+
function uriKey(components) {
|
|
7574
|
+
return `${components.scheme}://${components.authority}${components.path}${components.query ? "?" + components.query : ""}${components.fragment ? "#" + components.fragment : ""}`;
|
|
7575
|
+
}
|
|
7576
|
+
function uriRelativePath(root, child) {
|
|
7577
|
+
if (root.scheme !== child.scheme || root.authority !== child.authority) {
|
|
7578
|
+
return void 0;
|
|
7579
|
+
}
|
|
7580
|
+
const rootPath = trimTrailingSlash(root.path);
|
|
7581
|
+
const childPath = trimTrailingSlash(child.path);
|
|
7582
|
+
if (childPath === rootPath) {
|
|
7583
|
+
return ".";
|
|
7584
|
+
}
|
|
7585
|
+
const prefix = rootPath + "/";
|
|
7586
|
+
if (!childPath.startsWith(prefix)) {
|
|
7587
|
+
return void 0;
|
|
7588
|
+
}
|
|
7589
|
+
return childPath.slice(prefix.length) || ".";
|
|
7590
|
+
}
|
|
7591
|
+
function joinUriPath(base, ...segments) {
|
|
7592
|
+
let joined = trimTrailingSlash(base.path);
|
|
7593
|
+
for (const seg of segments) {
|
|
7594
|
+
if (seg === "..") {
|
|
7595
|
+
const idx = joined.lastIndexOf("/");
|
|
7596
|
+
if (idx > 0) {
|
|
7597
|
+
joined = joined.slice(0, idx);
|
|
7598
|
+
} else {
|
|
7599
|
+
joined = "/";
|
|
7600
|
+
}
|
|
7601
|
+
} else if (seg !== ".") {
|
|
7602
|
+
joined = joined === "/" ? "/" + seg : joined + "/" + seg;
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
return { ...base, path: joined };
|
|
7606
|
+
}
|
|
7607
|
+
function uriBasename(uri) {
|
|
7608
|
+
const p = trimTrailingSlash(uri.path);
|
|
7609
|
+
const idx = p.lastIndexOf("/");
|
|
7610
|
+
return idx >= 0 ? p.slice(idx + 1) : p;
|
|
7611
|
+
}
|
|
7612
|
+
function formatUri(uri) {
|
|
7613
|
+
return uriKey(uri);
|
|
7614
|
+
}
|
|
7615
|
+
function trimTrailingSlash(value) {
|
|
7616
|
+
return value.length > 1 ? value.replace(/\/+$/u, "") : value;
|
|
7617
|
+
}
|
|
7618
|
+
function externalPathFromString(uriKeyStr) {
|
|
7619
|
+
if (uriKeyStr.startsWith("file://")) {
|
|
7620
|
+
const withoutScheme = uriKeyStr.slice(7);
|
|
7621
|
+
if (/^\/[a-zA-Z]:[/\\]/u.test(withoutScheme)) {
|
|
7622
|
+
return withoutScheme.slice(1);
|
|
7623
|
+
}
|
|
7624
|
+
return withoutScheme;
|
|
7625
|
+
}
|
|
7626
|
+
return uriKeyStr;
|
|
7627
|
+
}
|
|
7628
|
+
|
|
8216
7629
|
// src/mapping.ts
|
|
8217
|
-
init_path_utils();
|
|
8218
|
-
init_uri_utils();
|
|
8219
7630
|
function resolveConfigRoots(configUri, config) {
|
|
8220
7631
|
const projectRootUri = joinUriPath(configUri, "..", "..");
|
|
8221
7632
|
return {
|
|
@@ -8402,9 +7813,6 @@ function computeCognitionIdentity(content) {
|
|
|
8402
7813
|
return computeContentIdentity("cognition", content);
|
|
8403
7814
|
}
|
|
8404
7815
|
|
|
8405
|
-
// src/project/project.ts
|
|
8406
|
-
init_uri_utils();
|
|
8407
|
-
|
|
8408
7816
|
// src/registry/index.ts
|
|
8409
7817
|
var import_node_crypto2 = require("node:crypto");
|
|
8410
7818
|
var REGISTRY_SCHEMA_VERSION = 6;
|
|
@@ -8740,7 +8148,6 @@ function isIdentity(value) {
|
|
|
8740
8148
|
}
|
|
8741
8149
|
|
|
8742
8150
|
// src/cognitionDiscovery.ts
|
|
8743
|
-
init_uri_utils();
|
|
8744
8151
|
var FILE_TYPE_FILE = 1;
|
|
8745
8152
|
var FILE_TYPE_DIRECTORY = 2;
|
|
8746
8153
|
async function discoverCognitionEntries(fs, cognitionRootUri, options = {}) {
|
|
@@ -8872,7 +8279,6 @@ async function reconcileRegistry(registry, scanResult) {
|
|
|
8872
8279
|
|
|
8873
8280
|
// src/project/workspace.ts
|
|
8874
8281
|
var import_yaml = __toESM(require_dist());
|
|
8875
|
-
init_uri_utils();
|
|
8876
8282
|
async function discoverWorkspaceRoots(fs, config, logger) {
|
|
8877
8283
|
const workspaceFolders = config.getWorkspaceFolders();
|
|
8878
8284
|
const roots = [];
|
|
@@ -9708,11 +9114,7 @@ function describeObservedStatus(status) {
|
|
|
9708
9114
|
}
|
|
9709
9115
|
}
|
|
9710
9116
|
|
|
9711
|
-
// src/snapshot/tree.ts
|
|
9712
|
-
init_uri_utils();
|
|
9713
|
-
|
|
9714
9117
|
// src/gitignore.ts
|
|
9715
|
-
init_uri_utils();
|
|
9716
9118
|
async function loadGitignoreRules(projectRootUri, directoryUri, inheritedRules, fileReader) {
|
|
9717
9119
|
const gitignoreUri = joinUriPath(directoryUri, ".gitignore");
|
|
9718
9120
|
if (!await fileReader.exists(gitignoreUri)) {
|
|
@@ -9843,7 +9245,6 @@ function directoryEntryFingerprint(items) {
|
|
|
9843
9245
|
}
|
|
9844
9246
|
|
|
9845
9247
|
// src/snapshot/mappingIndex.ts
|
|
9846
|
-
init_uri_utils();
|
|
9847
9248
|
function buildMappingIndex(nodes) {
|
|
9848
9249
|
const sourceToCognition = /* @__PURE__ */ new Map();
|
|
9849
9250
|
const cognitionToSource = /* @__PURE__ */ new Map();
|
|
@@ -10544,7 +9945,6 @@ function isStringArray(value) {
|
|
|
10544
9945
|
}
|
|
10545
9946
|
|
|
10546
9947
|
// src/cognitionRoutes.ts
|
|
10547
|
-
init_uri_utils();
|
|
10548
9948
|
var FILE_TYPE_FILE3 = 1;
|
|
10549
9949
|
var FILE_TYPE_DIRECTORY3 = 2;
|
|
10550
9950
|
async function buildCognitionRoutes(root, fs, registryLookup, project, options = {}) {
|
|
@@ -10748,11 +10148,7 @@ var noOpProjectLockManager = {
|
|
|
10748
10148
|
}
|
|
10749
10149
|
};
|
|
10750
10150
|
|
|
10751
|
-
// src/maintenance.ts
|
|
10752
|
-
init_uri_utils();
|
|
10753
|
-
|
|
10754
10151
|
// src/layout.ts
|
|
10755
|
-
init_uri_utils();
|
|
10756
10152
|
async function detectMisplacedCognitionEntries(root, fs, entries) {
|
|
10757
10153
|
const misplaced = [];
|
|
10758
10154
|
for (const [registryKey, entry] of Object.entries(entries)) {
|
|
@@ -10885,9 +10281,6 @@ function joinRelativePath3(rootUri, relativePath) {
|
|
|
10885
10281
|
return segments.length === 0 ? rootUri : joinUriPath(rootUri, ...segments);
|
|
10886
10282
|
}
|
|
10887
10283
|
|
|
10888
|
-
// src/cognition/index.ts
|
|
10889
|
-
init_uri_utils();
|
|
10890
|
-
|
|
10891
10284
|
// src/cognition/leaf-handbook.md
|
|
10892
10285
|
var leaf_handbook_default = "# Leaf Maintenance Handbook\n\n## Role\n\nA leaf is the atomic unit of cognition for one source file.\n\nIt records the design intent, hidden contract, rejected alternative, or\nnon-obvious boundary that would be lost if a reader only inspected the code.\n\n## Creation Rule\n\nNot every source file needs a leaf.\n\nCreate one when the file has:\n\n- A meaningful design decision\n- A boundary that is easy to misread\n- A hidden caller/callee contract\n- A non-obvious dependency rule\n- A role that matters more than what it exports\n\nDo not create one for files whose purpose is fully explained by file name,\ntypes, signatures, and nearby skeleton or module inventory.\n\n## WANOC Test\n\nUse the We-Are-Not-Our-Code test:\n\n> If you only saw the file name and a one-line comment, would this cognition\n> entry still tell you something not recoverable from signatures and code?\n\nIf the answer is no, remove the entry.\n\n## Preferred Structure\n\nUse this minimum shape:\n\n```markdown\n## Role\n\n## Design Decisions\n```\n\nAdd these only when they carry real cognition:\n\n- `Boundaries`\n- `Open Questions`\n\nAvoid standalone sections for:\n\n- `Callers`\n- `Dependencies`\n- `Invariants`\n- `What It Does Not Do`\n- `Responsibilities`\n\nThese sections are not forbidden, but they tend to bloat leaf files. Fold their\nuseful parts into design decisions or boundaries instead.\n\n## Design Source & Collisions\n\n### SSOT Projection\n\nWhen the agent is already working from an external single source of truth\n(SSOT) - an ADR, RFC, design doc, or documented verbal agreement - record its\nlocal projection inside the decision's entry: source identifier plus local\nimplication. Do not create a standalone `## References` section. If the\ndecision is self-evident from code, omit the source.\n\n### Collision Recording\n\nWhen multiple design sources constrain the same file and their constraints\ninteract or conflict, record the collision as a Note within the relevant\ndecision. Include: which sources, what the tension is, and how it was\nresolved at this node. This is the fastest place to surface collisions -\nhigher-level documents cannot see them.\n\n`Source` and `Note` are orthogonal. `Source` records the SSOT projection:\nsource identifier plus local implication. `Note` records the local collision\nwhen projected sources meet here.\n\n### Source-Aware Update\n\nWhen a cited source is relevant to the current change, use it to check whether\nthe local projection still holds. Use the cited Source to clarify local\ntension, not to start routine source auditing.\n\n## Boundaries Rule\n\nOnly record a boundary when a reasonable reader might otherwise misjudge what\nthis module is responsible for.\n\nGood boundary:\n\n- An API facade does not orchestrate multi-step workflows.\n\n## Invariants Rule\n\nRecord leaf-level invariants under the design decision they constrain.\n\n## Dependency Notes Rule\n\nDo not list source-level dependencies.\n\nMention a dependency only when it is design evidence: a boundary, access rule,\nconstraint, or non-obvious choice. Otherwise, let the source speak for itself.\n\n## Anti-Bloat Rule\n\nA leaf should not turn into a code summary, a source-level dependency list, or a\npile of negative claims.\n\nKeep only what adds design cognition beyond signatures and direct\nimplementation.\n\nA leaf that approaches the source file's length is probably restating code.\n\n## Update Rule\n\nUpdate a leaf when:\n\n- A design decision changes.\n- A hidden contract changes.\n- A dependency note that carries design meaning changes.\n- A previous boundary becomes misleading.\n- A design source already in scope changes the local implication.\n- A new collision between design sources at this node is discovered.\n\nDo not update a leaf unless the local design meaning changes.\n";
|
|
10893
10286
|
|
|
@@ -11070,7 +10463,6 @@ function relocateSourcePath(sourcePath, relocation) {
|
|
|
11070
10463
|
}
|
|
11071
10464
|
|
|
11072
10465
|
// src/project/projectContext.ts
|
|
11073
|
-
init_uri_utils();
|
|
11074
10466
|
function projectContextFromRoot(root) {
|
|
11075
10467
|
return {
|
|
11076
10468
|
label: root.label,
|
|
@@ -12183,8 +11575,6 @@ function isCoggitServices(value) {
|
|
|
12183
11575
|
}
|
|
12184
11576
|
|
|
12185
11577
|
// src/project/discover.ts
|
|
12186
|
-
init_path_utils();
|
|
12187
|
-
init_uri_utils();
|
|
12188
11578
|
var DEFAULT_MAX_WALK_DEPTH = 20;
|
|
12189
11579
|
async function findProjectRoot(startUri, fs, options) {
|
|
12190
11580
|
const maxDepth = options?.maxWalkDepth ?? DEFAULT_MAX_WALK_DEPTH;
|
|
@@ -12219,7 +11609,6 @@ function isDotCoggitDir(path) {
|
|
|
12219
11609
|
}
|
|
12220
11610
|
|
|
12221
11611
|
// src/project/init.ts
|
|
12222
|
-
init_uri_utils();
|
|
12223
11612
|
var DEFAULT_SOURCE_ROOT = "src";
|
|
12224
11613
|
var DEFAULT_COGNITION_ROOT = "src_cognition";
|
|
12225
11614
|
var COGGIT_GITIGNORE_RULE = "*.bak";
|
|
@@ -12271,9 +11660,6 @@ async function buildSnapshot(fs, config) {
|
|
|
12271
11660
|
return buildSnapshotFromProjects(projects);
|
|
12272
11661
|
}
|
|
12273
11662
|
|
|
12274
|
-
// src/operations.ts
|
|
12275
|
-
init_uri_utils();
|
|
12276
|
-
|
|
12277
11663
|
// src/pathHints.ts
|
|
12278
11664
|
var HINT_COLLECT_CAP = 5;
|
|
12279
11665
|
function suggestPathHints(candidatePaths, sourcePath) {
|
|
@@ -12842,7 +12228,6 @@ function getCoggitSystemPrompt(kind = "minimal") {
|
|
|
12842
12228
|
}
|
|
12843
12229
|
|
|
12844
12230
|
// src/projection.ts
|
|
12845
|
-
var import_mapping12 = __toESM(require_mapping());
|
|
12846
12231
|
function applyTreeDepth(nodes, depth) {
|
|
12847
12232
|
let omittedChildrenCount = 0;
|
|
12848
12233
|
const result = nodes.map((node) => {
|
|
@@ -12908,7 +12293,7 @@ function toRelativeCognitionPath(node) {
|
|
|
12908
12293
|
return "";
|
|
12909
12294
|
}
|
|
12910
12295
|
try {
|
|
12911
|
-
return
|
|
12296
|
+
return toRelativeUriPath(node.root.cognitionRootUri, node.cognitionUri);
|
|
12912
12297
|
} catch {
|
|
12913
12298
|
return node.cognitionUri.path;
|
|
12914
12299
|
}
|
|
@@ -12949,8 +12334,6 @@ function subtreeHasIssues(node) {
|
|
|
12949
12334
|
}
|
|
12950
12335
|
|
|
12951
12336
|
// src/routesProjection.ts
|
|
12952
|
-
var import_pathHints2 = __toESM(require_pathHints());
|
|
12953
|
-
var import_projection = __toESM(require_projection());
|
|
12954
12337
|
var DEFAULT_ROUTES_DEPTH = 2;
|
|
12955
12338
|
function projectRoutesEntries(entries) {
|
|
12956
12339
|
return buildRoutesProjectionTree(entries.map((entry) => ({
|
|
@@ -12987,7 +12370,7 @@ function selectRoutesBySourcePath(tree, sourcePath, _context) {
|
|
|
12987
12370
|
return { normalizedSourcePath, nodes, missed, pathHints };
|
|
12988
12371
|
}
|
|
12989
12372
|
function suggestHintsFromNormalizedPath(tree, normalizedPath) {
|
|
12990
|
-
return
|
|
12373
|
+
return suggestPathHints(
|
|
12991
12374
|
flattenRouteNodes(tree).map((node) => node.path),
|
|
12992
12375
|
normalizedPath
|
|
12993
12376
|
);
|
|
@@ -13070,7 +12453,7 @@ function assembleRoutesContent(input, options = {}) {
|
|
|
13070
12453
|
projectRootUri: options.projectRootUri,
|
|
13071
12454
|
sourceRootUri: options.sourceRootUri
|
|
13072
12455
|
});
|
|
13073
|
-
const depthResult =
|
|
12456
|
+
const depthResult = applyTreeDepth(selection.nodes, depth);
|
|
13074
12457
|
const content = {
|
|
13075
12458
|
project: input.project,
|
|
13076
12459
|
depth,
|
|
@@ -13641,9 +13024,6 @@ function projectStatusTriage(inspection) {
|
|
|
13641
13024
|
}))
|
|
13642
13025
|
};
|
|
13643
13026
|
}
|
|
13644
|
-
|
|
13645
|
-
// src/public.ts
|
|
13646
|
-
init_uri_utils();
|
|
13647
13027
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13648
13028
|
0 && (module.exports = {
|
|
13649
13029
|
ADD_OPERATION_ERROR_CODES,
|