farseer-cli 1.18.0 → 1.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/README.md +2 -2
- package/dist/commands/app.js.map +0 -1
- package/dist/commands/apps.js.map +0 -1
- package/dist/commands/cells.js.map +0 -1
- package/dist/commands/code.js.map +0 -1
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/dashboards.js.map +0 -1
- package/dist/commands/diff.js.map +0 -1
- package/dist/commands/dimensions.js.map +0 -1
- package/dist/commands/files.js.map +0 -1
- package/dist/commands/formula.js.map +0 -1
- package/dist/commands/install.js.map +0 -1
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +1 -2
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/mcp-server.js.map +0 -1
- package/dist/commands/model.js.map +0 -1
- package/dist/commands/pipeline.js.map +0 -1
- package/dist/commands/pull.js +1 -1
- package/dist/commands/pull.js.map +1 -2
- package/dist/commands/push.js +2 -2
- package/dist/commands/push.js.map +1 -2
- package/dist/commands/refresh.js.map +0 -1
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/sheets.js.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/tool.js.map +0 -1
- package/dist/commands/variables.js.map +0 -1
- package/dist/commands/whoami.js.map +0 -1
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -2
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/prompts/workflows.js.map +0 -1
- package/dist/mcp/resources/documentation.js.map +0 -1
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/skills.js.map +0 -1
- package/dist/mcp/tools/appTools.js.map +0 -1
- package/dist/mcp/tools/authTools.js +1 -1
- package/dist/mcp/tools/authTools.js.map +1 -2
- package/dist/mcp/tools/cellTools.js.map +0 -1
- package/dist/mcp/tools/dashboardTools.js.map +0 -1
- package/dist/mcp/tools/dataTools.js.map +0 -1
- package/dist/mcp/tools/folderTools.js.map +0 -1
- package/dist/mcp/tools/modelTools.js.map +0 -1
- package/dist/mcp/tools/pipelineContract.js.map +0 -1
- package/dist/mcp/tools/pipelineTools.js.map +0 -1
- package/dist/mcp/tools/runTools.js.map +0 -1
- package/dist/mcp/tools/sheetTools.js.map +0 -1
- package/dist/mcp/tools/syncTools.js +2 -2
- package/dist/mcp/tools/syncTools.js.map +1 -2
- package/dist/mcp/utils/helpers.js.map +0 -1
- package/dist/mcp/utils/launchPin.js.map +0 -1
- package/dist/mcp/utils/registerTool.js.map +0 -1
- package/dist/mcp/utils/session.js.map +0 -1
- package/dist/mcp/utils/tenantPin.js.map +0 -1
- package/dist/pipeline/compatibility.js.map +0 -1
- package/dist/pipeline/connect.js.map +0 -1
- package/dist/pipeline/create.js.map +0 -1
- package/dist/pipeline/errors.js.map +0 -1
- package/dist/pipeline/generated-reference.json +22 -10
- package/dist/pipeline/guide.js.map +0 -1
- package/dist/pipeline/init.js.map +0 -1
- package/dist/pipeline/operations.js.map +0 -1
- package/dist/pipeline/query.js.map +0 -1
- package/dist/pipeline/queryDownloads.js.map +0 -1
- package/dist/pipeline/queryWorker.js.map +0 -1
- package/dist/pipeline/readiness.js.map +0 -1
- package/dist/pipeline/reference.js.map +0 -1
- package/dist/pipeline/requests.js.map +0 -1
- package/dist/pipeline/runArguments.js.map +0 -1
- package/dist/pipeline/runtime.js.map +0 -1
- package/dist/pipeline/service.js.map +0 -1
- package/dist/services/agentApprovalFetch.js +7 -3
- package/dist/services/agentApprovalFetch.js.map +1 -2
- package/dist/services/appSyncService.js.map +0 -1
- package/dist/services/apps.js.map +0 -1
- package/dist/services/authErrors.js.map +0 -1
- package/dist/services/codefirst/api.js +38 -5
- package/dist/services/codefirst/api.js.map +1 -2
- package/dist/services/codefirst/binaryDisk.js.map +0 -1
- package/dist/services/codefirst/byteHashes.js +5 -0
- package/dist/services/codefirst/byteHashes.js.map +1 -2
- package/dist/services/codefirst/documents.js +41 -15
- package/dist/services/codefirst/documents.js.map +1 -2
- package/dist/services/codefirst/layoutBinaryProjection.js +24 -13
- package/dist/services/codefirst/layoutBinaryProjection.js.map +1 -2
- package/dist/services/codefirst/layoutCompose.js +44 -38
- package/dist/services/codefirst/layoutCompose.js.map +1 -2
- package/dist/services/codefirst/layoutCore.js +14 -1
- package/dist/services/codefirst/layoutCore.js.map +1 -2
- package/dist/services/codefirst/layoutPaths.js +80 -4
- package/dist/services/codefirst/layoutPaths.js.map +1 -2
- package/dist/services/codefirst/layoutProjection.js +73 -39
- package/dist/services/codefirst/layoutProjection.js.map +1 -2
- package/dist/services/codefirst/layoutReadback.js +357 -130
- package/dist/services/codefirst/layoutReadback.js.map +2 -3
- package/dist/services/codefirst/layoutReadbackPlacement.js +94 -57
- package/dist/services/codefirst/layoutReadbackPlacement.js.map +2 -3
- package/dist/services/codefirst/layoutReceipt.js +283 -243
- package/dist/services/codefirst/layoutReceipt.js.map +2 -3
- package/dist/services/codefirst/layoutScan.js +208 -110
- package/dist/services/codefirst/layoutScan.js.map +1 -2
- package/dist/services/codefirst/output.js +76 -10
- package/dist/services/codefirst/output.js.map +1 -2
- package/dist/services/codefirst/types.js.map +0 -1
- package/dist/services/codefirst/workflow.js +65 -29
- package/dist/services/codefirst/workflow.js.map +2 -3
- package/dist/services/codefirst/workspace.js.map +0 -1
- package/dist/services/codefirst/workspaceLock.js.map +0 -1
- package/dist/services/codefirst/workspaceRoot.js +2 -1
- package/dist/services/codefirst/workspaceRoot.js.map +1 -2
- package/dist/services/configService.js.map +0 -1
- package/dist/services/credentials.js.map +0 -1
- package/dist/services/farseerService.js +3 -1
- package/dist/services/farseerService.js.map +1 -2
- package/dist/services/httpError.js.map +0 -1
- package/dist/services/modelExport.js.map +0 -1
- package/dist/services/organisation.js.map +0 -1
- package/dist/services/preflight.js.map +0 -1
- package/dist/services/realms.js.map +0 -1
- package/dist/services/syncService.js +3 -3
- package/dist/services/syncService.js.map +1 -2
- package/dist/skills/pipeline.js.map +0 -1
- package/dist/utils/agentSandbox.js.map +0 -1
- package/dist/utils/cliOptions.js.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/entityResolver.js.map +0 -1
- package/dist/utils/errorFormatter.js +59 -11
- package/dist/utils/errorFormatter.js.map +1 -2
- package/dist/utils/fileLogger.js.map +0 -1
- package/dist/utils/fileValidation.js.map +0 -1
- package/dist/utils/folderMatch.js.map +0 -1
- package/dist/utils/formulaFilters.js.map +0 -1
- package/dist/utils/helpers.js.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/nameResolver.js.map +0 -1
- package/dist/utils/packageManager.js.map +0 -1
- package/dist/utils/syncReporting.js.map +0 -1
- package/dist/utils/syncScope.js.map +0 -1
- package/dist/utils/updateCheck.js.map +0 -1
- package/dist/utils/variableValues.js.map +0 -1
- package/dist/utils/workspace.js.map +0 -1
- package/docs/cli-guide.md +1 -1
- package/docs/import-workflows.md +14 -14
- package/docs/new-app-template.md +1 -1
- package/docs/pipeline-client-guide.md +1 -1
- package/docs/pipeline-reference.md +292 -3
- package/package.json +2 -2
- package/skills/farseer-analysis/SKILL.md +132 -0
- package/skills/farseer-dashboards/SKILL.md +40 -0
- package/skills/farseer-formulas/SKILL.md +165 -0
- package/skills/farseer-model/SKILL.md +119 -0
- package/skills/pipeline-authoring/SKILL.md +6 -4
- package/skills/pipeline-authoring/practices.md +6 -5
|
@@ -28,15 +28,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var layoutScan_exports = {};
|
|
30
30
|
__export(layoutScan_exports, {
|
|
31
|
-
captureLayoutWorkspace: () => captureLayoutWorkspace,
|
|
32
31
|
captureLayoutWorkspaceSeed: () => captureLayoutWorkspaceSeed,
|
|
32
|
+
changedObservedPath: () => changedObservedPath,
|
|
33
33
|
hashLayoutPath: () => hashLayoutPath,
|
|
34
34
|
loadLayoutByteEvidence: () => loadLayoutByteEvidence,
|
|
35
|
+
observeLayoutScan: () => observeLayoutScan,
|
|
35
36
|
probeLayoutPath: () => probeLayoutPath,
|
|
36
37
|
resolveLayoutPath: () => resolveLayoutPath,
|
|
37
|
-
sameValue: () => sameValue,
|
|
38
38
|
scanLayout: () => scanLayout,
|
|
39
|
-
stateText: () => stateText
|
|
39
|
+
stateText: () => stateText,
|
|
40
|
+
touchedPathFacts: () => touchedPathFacts
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(layoutScan_exports);
|
|
42
43
|
var fs = __toESM(require("fs"));
|
|
@@ -134,8 +135,43 @@ function physicalLayoutClaims(scan) {
|
|
|
134
135
|
}
|
|
135
136
|
return [...claims.values()];
|
|
136
137
|
}
|
|
138
|
+
function observePath(absolute, startedNs) {
|
|
139
|
+
let stat;
|
|
140
|
+
try {
|
|
141
|
+
stat = fs.lstatSync(absolute, { bigint: true });
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const code = error.code;
|
|
144
|
+
return code === "ENOENT" ? { type: "absent" } : { type: "error", code: code ?? "unknown" };
|
|
145
|
+
}
|
|
146
|
+
const cutoff = startedNs - import_byteHashes.RACY_WINDOW_NS;
|
|
147
|
+
return {
|
|
148
|
+
type: stat.isFile() ? "file" : stat.isDirectory() ? "directory" : stat.isSymbolicLink() ? "symlink" : "other",
|
|
149
|
+
dev: stat.dev,
|
|
150
|
+
ino: stat.ino,
|
|
151
|
+
size: stat.size,
|
|
152
|
+
mtimeNs: stat.mtimeNs,
|
|
153
|
+
ctimeNs: stat.ctimeNs,
|
|
154
|
+
racy: stat.mtimeNs >= cutoff || stat.ctimeNs >= cutoff
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function sameObservedPath(left, right) {
|
|
158
|
+
if (left.type === "absent" || right.type === "absent") return left.type === right.type;
|
|
159
|
+
if (left.type === "error" || right.type === "error")
|
|
160
|
+
return left.type === "error" && right.type === "error" && left.code === right.code;
|
|
161
|
+
if (left.type !== right.type || left.dev !== right.dev || left.ino !== right.ino) return false;
|
|
162
|
+
return left.type === "directory" || left.size === right.size && left.mtimeNs === right.mtimeNs && left.ctimeNs === right.ctimeNs;
|
|
163
|
+
}
|
|
137
164
|
function scanLayout(input) {
|
|
165
|
+
return scanObserved(input, false).scan;
|
|
166
|
+
}
|
|
167
|
+
function observeLayoutScan(input) {
|
|
168
|
+
return scanObserved(input, true);
|
|
169
|
+
}
|
|
170
|
+
function scanObserved(input, keepTexts) {
|
|
138
171
|
const root = path.resolve(input.root);
|
|
172
|
+
const startedNs = (0, import_byteHashes.racyClockNs)();
|
|
173
|
+
const observation = { startedNs, paths: /* @__PURE__ */ new Map(), texts: /* @__PURE__ */ new Map() };
|
|
174
|
+
const observed = observation.paths;
|
|
139
175
|
const artifacts = [];
|
|
140
176
|
const diagnostics = [];
|
|
141
177
|
const opaqueDirectories = /* @__PURE__ */ new Set();
|
|
@@ -147,39 +183,44 @@ function scanLayout(input) {
|
|
|
147
183
|
const claims = /* @__PURE__ */ new Map();
|
|
148
184
|
const allocator = new import_layoutPaths.LayoutPathAllocator();
|
|
149
185
|
const pendingAttachments = [];
|
|
186
|
+
const pendingShareGroups = /* @__PURE__ */ new Set();
|
|
150
187
|
const trackedMarkerDirectories = /* @__PURE__ */ new Set();
|
|
151
188
|
const trackedPaths = new Set(
|
|
152
189
|
input.tracked.flatMap(
|
|
153
190
|
(item) => item.path.split("/").map((_, index, parts) => parts.slice(0, index + 1).join("/"))
|
|
154
191
|
)
|
|
155
192
|
);
|
|
193
|
+
const onlyDirectories = input.only && new Set([...input.only].flatMap((relative) => (0, import_layoutCore.pathAncestors)(relative)));
|
|
194
|
+
const wanted = (relative) => !input.only || input.only.has(relative) || onlyDirectories.has(relative);
|
|
156
195
|
const addDiagnostic = (code, relative, message, relatedPath) => {
|
|
157
196
|
diagnostics.push({ code, path: relative, message, ...relatedPath ? { relatedPath } : {} });
|
|
158
197
|
};
|
|
159
198
|
const rootFailure = () => ({
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
199
|
+
scan: {
|
|
200
|
+
artifacts: [],
|
|
201
|
+
tracked: input.tracked.map((tracked2) => ({
|
|
202
|
+
route: tracked2.route,
|
|
203
|
+
path: tracked2.path,
|
|
204
|
+
status: "missing-subtree"
|
|
205
|
+
})).sort((left, right) => (0, import_layoutCore.compareText)(left.route, right.route)),
|
|
206
|
+
opaqueDirectories: [],
|
|
207
|
+
localOnlyFiles: [],
|
|
208
|
+
diagnostics
|
|
209
|
+
},
|
|
210
|
+
observation
|
|
169
211
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (error.code === "ENOENT") return rootFailure();
|
|
212
|
+
const rootStat = observePath(root, startedNs);
|
|
213
|
+
observed.set(".", rootStat);
|
|
214
|
+
if (rootStat.type === "absent") return rootFailure();
|
|
215
|
+
if (rootStat.type === "error") {
|
|
175
216
|
addDiagnostic("filesystem-error", ".", `Cannot inspect workspace root`);
|
|
176
217
|
return rootFailure();
|
|
177
218
|
}
|
|
178
|
-
if (rootStat.
|
|
219
|
+
if (rootStat.type === "symlink") {
|
|
179
220
|
addDiagnostic("symlink", ".", `Workspace root is a symlink`);
|
|
180
221
|
return rootFailure();
|
|
181
222
|
}
|
|
182
|
-
if (
|
|
223
|
+
if (rootStat.type !== "directory") {
|
|
183
224
|
addDiagnostic("path-role-overlap", ".", `Workspace root is not a directory`);
|
|
184
225
|
return rootFailure();
|
|
185
226
|
}
|
|
@@ -190,14 +231,22 @@ function scanLayout(input) {
|
|
|
190
231
|
throw new Error(`Path escapes workspace root: ${relative}`);
|
|
191
232
|
return resolved;
|
|
192
233
|
};
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
234
|
+
const observe = (relative) => {
|
|
235
|
+
let seen = observed.get(relative);
|
|
236
|
+
if (seen === void 0) {
|
|
237
|
+
try {
|
|
238
|
+
seen = observePath(absolute(relative), startedNs);
|
|
239
|
+
} catch {
|
|
240
|
+
return { type: "error", code: "outside-root" };
|
|
241
|
+
}
|
|
242
|
+
observed.set(relative, seen);
|
|
200
243
|
}
|
|
244
|
+
return seen;
|
|
245
|
+
};
|
|
246
|
+
const lstat = (relative) => {
|
|
247
|
+
const seen = observe(relative);
|
|
248
|
+
if (seen.type === "error") addDiagnostic("filesystem-error", relative, `Cannot inspect ${relative}`);
|
|
249
|
+
return seen.type === "absent" || seen.type === "error" ? void 0 : seen;
|
|
201
250
|
};
|
|
202
251
|
const recordOccupant = (occupant) => {
|
|
203
252
|
const key = (0, import_layoutPaths.layoutCollisionKey)(occupant.path);
|
|
@@ -214,11 +263,11 @@ function scanLayout(input) {
|
|
|
214
263
|
const physicalEntries = (directory) => {
|
|
215
264
|
const stat = lstat(directory);
|
|
216
265
|
if (!stat) return void 0;
|
|
217
|
-
if (stat.
|
|
266
|
+
if (stat.type === "symlink") {
|
|
218
267
|
addDiagnostic("symlink", directory, `Managed path is a symlink: ${directory}`);
|
|
219
268
|
return void 0;
|
|
220
269
|
}
|
|
221
|
-
if (
|
|
270
|
+
if (stat.type !== "directory") {
|
|
222
271
|
addDiagnostic("path-role-overlap", directory, `Expected a directory: ${directory}`);
|
|
223
272
|
return void 0;
|
|
224
273
|
}
|
|
@@ -297,8 +346,11 @@ function scanLayout(input) {
|
|
|
297
346
|
return true;
|
|
298
347
|
};
|
|
299
348
|
const parseJson = (relative) => {
|
|
349
|
+
observe(relative);
|
|
300
350
|
try {
|
|
301
|
-
|
|
351
|
+
const text = readExactText(absolute(relative));
|
|
352
|
+
if (keepTexts) observation.texts.set(relative, text);
|
|
353
|
+
return JSON.parse(text);
|
|
302
354
|
} catch {
|
|
303
355
|
addDiagnostic("malformed-json", relative, `Invalid JSON in ${relative}`);
|
|
304
356
|
return void 0;
|
|
@@ -311,14 +363,19 @@ function scanLayout(input) {
|
|
|
311
363
|
current = current ? `${current}/${parts[index]}` : parts[index];
|
|
312
364
|
const stat = lstat(current);
|
|
313
365
|
if (!stat) return { present: false, symlink: false, missingAncestor: current };
|
|
314
|
-
if (stat.
|
|
315
|
-
if (index < parts.length - 1 &&
|
|
366
|
+
if (stat.type === "symlink") return { present: true, symlink: true, symlinkPath: current };
|
|
367
|
+
if (index < parts.length - 1 && stat.type !== "directory")
|
|
316
368
|
return { present: false, symlink: false, missingAncestor: current };
|
|
317
369
|
}
|
|
318
370
|
return { present: true, symlink: false };
|
|
319
371
|
};
|
|
372
|
+
const sharePresent = (target) => {
|
|
373
|
+
const present = probe(target).present;
|
|
374
|
+
if (present && !wanted(target)) pendingShareGroups.add(target);
|
|
375
|
+
return present;
|
|
376
|
+
};
|
|
320
377
|
const addSharePointer = (artifact, value, field) => {
|
|
321
|
-
addSharePointerToArtifact(artifact, value, field,
|
|
378
|
+
addSharePointerToArtifact(artifact, value, field, sharePresent, addDiagnostic);
|
|
322
379
|
};
|
|
323
380
|
const addAttachmentPointer = (artifact, value, field) => {
|
|
324
381
|
const target = pointerTarget(value, artifact, addDiagnostic);
|
|
@@ -357,11 +414,11 @@ function scanLayout(input) {
|
|
|
357
414
|
const bytes = (0, import_layoutPaths.rawBytesPath)(sidecarPath);
|
|
358
415
|
const state = probe(bytes);
|
|
359
416
|
if (state.symlink) inspectSymlink(bytes);
|
|
360
|
-
const isFile = state.present && !state.symlink &&
|
|
417
|
+
const isFile = state.present && !state.symlink && lstat(bytes)?.type === "file";
|
|
361
418
|
if (state.present && !state.symlink && !isFile)
|
|
362
419
|
addDiagnostic("path-role-overlap", bytes, `Raw sidecar target is not a file`);
|
|
363
420
|
claim(bytes, "file", "raw", sidecarPath);
|
|
364
|
-
artifacts.push(buildRawArtifact(sidecarPath, value, isFile,
|
|
421
|
+
artifacts.push(buildRawArtifact(sidecarPath, value, isFile, sharePresent, addDiagnostic));
|
|
365
422
|
localOnlyFiles.delete(bytes);
|
|
366
423
|
};
|
|
367
424
|
const sidecarNames = (entries) => {
|
|
@@ -371,15 +428,18 @@ function scanLayout(input) {
|
|
|
371
428
|
claimed.set(entry.name.slice(0, -import_layoutPaths.RAW_SIDECAR_SUFFIX.length), entry.name);
|
|
372
429
|
return claimed;
|
|
373
430
|
};
|
|
374
|
-
const scanManagedDirectory = (directory) => {
|
|
431
|
+
const scanManagedDirectory = (directory, anchor = false) => {
|
|
375
432
|
const entries = physicalEntries(directory);
|
|
376
433
|
if (!entries) return;
|
|
377
434
|
const names = new Map(entries.map((entry) => [entry.name, entry]));
|
|
378
435
|
for (const entry of entries) if (entry.isSymbolicLink()) inspectSymlink(`${directory}/${entry.name}`);
|
|
379
436
|
const markerPath = `${directory}/${FOLDER_CONTROL}`;
|
|
380
437
|
const marker = names.get(FOLDER_CONTROL);
|
|
381
|
-
if (marker &&
|
|
382
|
-
|
|
438
|
+
if (marker && anchor)
|
|
439
|
+
addDiagnostic("anchor-folder-marker", markerPath, `A hidden folder has no marker; remove ${markerPath}`);
|
|
440
|
+
else if (marker && !marker.isFile())
|
|
441
|
+
addDiagnostic("path-role-overlap", markerPath, `Folder control is not a file`);
|
|
442
|
+
else if (marker?.isFile()) {
|
|
383
443
|
const markerArtifact = readArtifact(markerPath, "folder-control");
|
|
384
444
|
if (!(0, import_layoutCore.isObject)(markerArtifact.json))
|
|
385
445
|
addDiagnostic("malformed-control", markerPath, `Invalid folder control in ${markerPath}`);
|
|
@@ -387,10 +447,12 @@ function scanLayout(input) {
|
|
|
387
447
|
if ((0, import_layoutCore.isObject)(markerArtifact.json)) addSharePointer(markerArtifact, markerArtifact.json.shares, "shares");
|
|
388
448
|
}
|
|
389
449
|
const sidecars = sidecarNames(entries);
|
|
390
|
-
for (const [, sidecar] of [...sidecars].sort(([left], [right]) => (0, import_layoutCore.compareText)(left, right)))
|
|
391
|
-
|
|
450
|
+
for (const [bytes, sidecar] of [...sidecars].sort(([left], [right]) => (0, import_layoutCore.compareText)(left, right)))
|
|
451
|
+
if (wanted(`${directory}/${sidecar}`) || wanted(`${directory}/${bytes}`))
|
|
452
|
+
scanSidecar(`${directory}/${sidecar}`);
|
|
392
453
|
for (const entry of entries) {
|
|
393
454
|
const relative = `${directory}/${entry.name}`;
|
|
455
|
+
if (!wanted(relative)) continue;
|
|
394
456
|
if (entry.isSymbolicLink() || entry.name === FOLDER_CONTROL) continue;
|
|
395
457
|
if (retiredManifest(entry.name, relative)) continue;
|
|
396
458
|
if (entry.isFile() && ((0, import_layoutPaths.isRawSidecarPath)(entry.name) || sidecars.has(entry.name))) continue;
|
|
@@ -423,6 +485,7 @@ function scanLayout(input) {
|
|
|
423
485
|
if (!entries) return;
|
|
424
486
|
for (const entry of entries) {
|
|
425
487
|
const relative = `${directory}/${entry.name}`;
|
|
488
|
+
if (!wanted(relative)) continue;
|
|
426
489
|
if (entry.isSymbolicLink()) {
|
|
427
490
|
inspectSymlink(relative);
|
|
428
491
|
continue;
|
|
@@ -450,10 +513,11 @@ function scanLayout(input) {
|
|
|
450
513
|
}
|
|
451
514
|
};
|
|
452
515
|
const scanDeclaredRoot = (rootDirectory, declared, exactFiles = {}) => {
|
|
453
|
-
const entries = physicalEntries(rootDirectory);
|
|
516
|
+
const entries = wanted(rootDirectory) ? physicalEntries(rootDirectory) : void 0;
|
|
454
517
|
if (!entries) return;
|
|
455
518
|
for (const entry of entries) {
|
|
456
519
|
const relative = `${rootDirectory}/${entry.name}`;
|
|
520
|
+
if (!wanted(relative)) continue;
|
|
457
521
|
if (entry.isSymbolicLink()) {
|
|
458
522
|
inspectSymlink(relative);
|
|
459
523
|
continue;
|
|
@@ -472,30 +536,33 @@ function scanLayout(input) {
|
|
|
472
536
|
else localOnlyFiles.add(relative);
|
|
473
537
|
}
|
|
474
538
|
};
|
|
475
|
-
const tracked = input.tracked.
|
|
539
|
+
const tracked = input.tracked.flatMap((item) => {
|
|
476
540
|
try {
|
|
477
541
|
(0, import_layoutPaths.parseWorkspacePointer)(item.path);
|
|
478
542
|
} catch (error) {
|
|
479
543
|
addDiagnostic("unsafe-tracked-path", item.path, error.message);
|
|
480
|
-
return { route: item.route, path: item.path, status: "missing-leaf" };
|
|
544
|
+
return [{ route: item.route, path: item.path, status: "missing-leaf" }];
|
|
481
545
|
}
|
|
482
546
|
if (item.role === "folder-control" && item.path.endsWith("/_folder.json"))
|
|
483
547
|
trackedMarkerDirectories.add((0, import_layoutPaths.folderDirectory)(item.path));
|
|
548
|
+
if (!wanted(item.path)) return [];
|
|
484
549
|
const state = probe(item.path);
|
|
485
550
|
if (state.symlink) inspectSymlink(state.symlinkPath ?? item.path);
|
|
486
551
|
if (state.present) {
|
|
487
552
|
const stat = state.symlink ? void 0 : lstat(item.path);
|
|
488
|
-
if (stat && (item.kind === "file" &&
|
|
553
|
+
if (stat && (item.kind === "file" && stat.type !== "file" || item.kind === "directory" && stat.type !== "directory"))
|
|
489
554
|
addDiagnostic("path-role-overlap", item.path, `Tracked path has the wrong physical kind`);
|
|
490
|
-
return { route: item.route, path: item.path, status: "present" };
|
|
555
|
+
return [{ route: item.route, path: item.path, status: "present" }];
|
|
491
556
|
}
|
|
492
557
|
const final = state.missingAncestor === item.path;
|
|
493
|
-
return
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
558
|
+
return [
|
|
559
|
+
{
|
|
560
|
+
route: item.route,
|
|
561
|
+
path: item.path,
|
|
562
|
+
status: final ? "missing-leaf" : "missing-subtree",
|
|
563
|
+
...final || state.missingAncestor === void 0 ? {} : { missingAncestor: state.missingAncestor }
|
|
564
|
+
}
|
|
565
|
+
];
|
|
499
566
|
});
|
|
500
567
|
let rootEntries = [];
|
|
501
568
|
try {
|
|
@@ -505,9 +572,10 @@ function scanLayout(input) {
|
|
|
505
572
|
}
|
|
506
573
|
for (const entry of rootEntries.sort((left, right) => (0, import_layoutCore.compareText)(left.name, right.name)))
|
|
507
574
|
if (entry.isFile()) retiredManifest(entry.name, entry.name);
|
|
508
|
-
const treeEntries = physicalEntries("tree");
|
|
575
|
+
const treeEntries = wanted("tree") ? physicalEntries("tree") : void 0;
|
|
509
576
|
for (const entry of treeEntries ?? []) {
|
|
510
577
|
const relative = `tree/${entry.name}`;
|
|
578
|
+
if (!wanted(relative)) continue;
|
|
511
579
|
if (entry.isSymbolicLink()) {
|
|
512
580
|
inspectSymlink(relative);
|
|
513
581
|
continue;
|
|
@@ -524,6 +592,18 @@ function scanLayout(input) {
|
|
|
524
592
|
addDiagnostic("unknown-json", relative, `Only managed folder directories are valid under tree`);
|
|
525
593
|
else if (entry.isFile()) localOnlyFiles.add(relative);
|
|
526
594
|
}
|
|
595
|
+
for (const entry of wanted(import_layoutPaths.SHARED_ROOT) && physicalEntries(import_layoutPaths.SHARED_ROOT) || []) {
|
|
596
|
+
const relative = `${import_layoutPaths.SHARED_ROOT}/${entry.name}`;
|
|
597
|
+
if (!wanted(relative)) continue;
|
|
598
|
+
if (entry.isSymbolicLink()) inspectSymlink(relative);
|
|
599
|
+
else if (entry.isDirectory()) {
|
|
600
|
+
if ((0, import_layoutPaths.sharedAnchorDirectory)(relative)?.directory === relative) scanManagedDirectory(relative, true);
|
|
601
|
+
else opaqueDirectories.add(relative);
|
|
602
|
+
} else if (entry.isFile() && retiredManifest(entry.name, relative)) continue;
|
|
603
|
+
else if (entry.isFile() && entry.name.endsWith(".json"))
|
|
604
|
+
addDiagnostic("unknown-json", relative, `Only hidden-folder directories are valid under ${import_layoutPaths.SHARED_ROOT}`);
|
|
605
|
+
else if (entry.isFile()) localOnlyFiles.add(relative);
|
|
606
|
+
}
|
|
527
607
|
scanDeclaredRoot("access", {
|
|
528
608
|
shares: () => scanFlatJsonDirectory("access/shares", "share-group"),
|
|
529
609
|
groups: () => scanFlatJsonDirectory("access/groups", "user-group", { namesSupplySemanticName: true }),
|
|
@@ -532,6 +612,7 @@ function scanLayout(input) {
|
|
|
532
612
|
const entries = physicalEntries("access/grants");
|
|
533
613
|
for (const entry of entries ?? []) {
|
|
534
614
|
const relative = `access/grants/${entry.name}`;
|
|
615
|
+
if (!wanted(relative)) continue;
|
|
535
616
|
if (entry.isSymbolicLink()) inspectSymlink(relative);
|
|
536
617
|
else if (entry.isDirectory()) scanFlatJsonDirectory(relative, "user-grant");
|
|
537
618
|
else if (entry.isFile() && retiredManifest(entry.name, relative)) continue;
|
|
@@ -550,7 +631,7 @@ function scanLayout(input) {
|
|
|
550
631
|
attachmentField: "template"
|
|
551
632
|
})
|
|
552
633
|
},
|
|
553
|
-
{ "settings.json": "settings" }
|
|
634
|
+
{ "settings.json": "settings", "global_locks.json": "global-locks" }
|
|
554
635
|
);
|
|
555
636
|
scanDeclaredRoot("detached", {
|
|
556
637
|
...Object.fromEntries(
|
|
@@ -560,6 +641,7 @@ function scanLayout(input) {
|
|
|
560
641
|
const entries = physicalEntries("detached/files");
|
|
561
642
|
for (const entry of entries ?? []) {
|
|
562
643
|
const bucket = `detached/files/${entry.name}`;
|
|
644
|
+
if (!wanted(bucket)) continue;
|
|
563
645
|
if (entry.isSymbolicLink()) inspectSymlink(bucket);
|
|
564
646
|
else if (!entry.isDirectory())
|
|
565
647
|
addDiagnostic("path-role-overlap", bucket, `Detached file entry must be an identity directory`);
|
|
@@ -570,10 +652,12 @@ function scanLayout(input) {
|
|
|
570
652
|
addDiagnostic("missing-raw-sidecar", bucket, `Detached file bucket has no raw sidecar`);
|
|
571
653
|
else if (sidecars.size > 1)
|
|
572
654
|
addDiagnostic("detached-file-count", bucket, `Detached file bucket must hold one raw file`);
|
|
573
|
-
for (const [, sidecar] of [...sidecars].sort(([left], [right]) => (0, import_layoutCore.compareText)(left, right)))
|
|
574
|
-
|
|
655
|
+
for (const [bytes, sidecar] of [...sidecars].sort(([left], [right]) => (0, import_layoutCore.compareText)(left, right)))
|
|
656
|
+
if (wanted(`${bucket}/${sidecar}`) || wanted(`${bucket}/${bytes}`))
|
|
657
|
+
scanSidecar(`${bucket}/${sidecar}`);
|
|
575
658
|
for (const candidate of bucketEntries) {
|
|
576
659
|
const relative = `${bucket}/${candidate.name}`;
|
|
660
|
+
if (!wanted(relative)) continue;
|
|
577
661
|
if (candidate.isSymbolicLink()) inspectSymlink(relative);
|
|
578
662
|
else if (retiredManifest(candidate.name, relative)) continue;
|
|
579
663
|
else if (candidate.isFile() && ((0, import_layoutPaths.isRawSidecarPath)(candidate.name) || sidecars.has(candidate.name)))
|
|
@@ -587,14 +671,20 @@ function scanLayout(input) {
|
|
|
587
671
|
}
|
|
588
672
|
}
|
|
589
673
|
});
|
|
674
|
+
for (const target of [...pendingShareGroups].sort(import_layoutCore.compareText)) {
|
|
675
|
+
const state = probe(target);
|
|
676
|
+
if (state.symlink) inspectSymlink(state.symlinkPath ?? target);
|
|
677
|
+
else if (lstat(target)?.type === "file") readArtifact(target, "share-group");
|
|
678
|
+
}
|
|
590
679
|
for (const pending of pendingAttachments.sort((left, right) => (0, import_layoutCore.compareText)(left.path, right.path))) {
|
|
591
680
|
if (!attachmentTargetValid(pending.owner, pending.path, opaqueDirectories, addDiagnostic)) continue;
|
|
592
681
|
const state = probe(pending.path);
|
|
593
682
|
if (state.symlink) inspectSymlink(state.symlinkPath ?? pending.path);
|
|
594
683
|
const stat = state.present && !state.symlink ? lstat(pending.path) : void 0;
|
|
595
|
-
if (stat &&
|
|
684
|
+
if (stat && stat.type !== "file")
|
|
685
|
+
addDiagnostic("path-role-overlap", pending.path, `Attachment target is not a file`);
|
|
596
686
|
claim(pending.path, "file", "attachment", `${pending.owner.path}:${pending.field}`);
|
|
597
|
-
const present =
|
|
687
|
+
const present = stat?.type === "file";
|
|
598
688
|
(pending.owner.pointers ??= []).push({
|
|
599
689
|
kind: "attachment",
|
|
600
690
|
field: pending.field,
|
|
@@ -611,6 +701,7 @@ function scanLayout(input) {
|
|
|
611
701
|
localOnlyFiles.delete(pending.path);
|
|
612
702
|
}
|
|
613
703
|
for (const markerDirectory of trackedMarkerDirectories) {
|
|
704
|
+
if (!wanted(markerDirectory)) continue;
|
|
614
705
|
const markerPath = `${markerDirectory}/_folder.json`;
|
|
615
706
|
if (probe(markerPath).present || !probe(markerDirectory).present) continue;
|
|
616
707
|
const retained = artifacts.some(
|
|
@@ -625,14 +716,17 @@ function scanLayout(input) {
|
|
|
625
716
|
))
|
|
626
717
|
addDiagnostic("missing-folder-marker", markerPath, `Folder marker is missing with managed descendants`);
|
|
627
718
|
}
|
|
628
|
-
return
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
719
|
+
return {
|
|
720
|
+
scan: finalizeScanResult(
|
|
721
|
+
artifacts,
|
|
722
|
+
tracked,
|
|
723
|
+
opaqueDirectories,
|
|
724
|
+
localOnlyFiles,
|
|
725
|
+
diagnostics,
|
|
726
|
+
unmanageableDirectories
|
|
727
|
+
),
|
|
728
|
+
observation
|
|
729
|
+
};
|
|
636
730
|
}
|
|
637
731
|
function sourceMatchesOwner(source, value) {
|
|
638
732
|
if (source.type !== "resource" || !(0, import_layoutCore.isObject)(value) || value.kind !== source.resource.kind) return false;
|
|
@@ -640,7 +734,7 @@ function sourceMatchesOwner(source, value) {
|
|
|
640
734
|
return value.key === source.resource.key;
|
|
641
735
|
}
|
|
642
736
|
function attachmentTargetValid(owner, target, opaqueDirectories, addDiagnostic) {
|
|
643
|
-
if (!/^(tree|access|definitions|detached)\//.test(target)) {
|
|
737
|
+
if (!/^(tree|shared|access|definitions|detached)\//.test(target)) {
|
|
644
738
|
addDiagnostic("attachment-out-of-scope", owner.path, `Attachment is outside the adapter roots`, target);
|
|
645
739
|
return false;
|
|
646
740
|
}
|
|
@@ -802,24 +896,48 @@ function evidence(state) {
|
|
|
802
896
|
detachedDocumentProofs: state.layout.evidence.detachedDocumentProofs
|
|
803
897
|
};
|
|
804
898
|
}
|
|
805
|
-
function managedJsonText(
|
|
899
|
+
function managedJsonText(scan, texts) {
|
|
806
900
|
const result = {};
|
|
807
901
|
for (const artifact of scan.artifacts) {
|
|
808
902
|
if (!artifact.present || ["raw", "attachment"].includes(artifact.role) || artifact.json === void 0) continue;
|
|
809
903
|
if (Object.prototype.hasOwnProperty.call(result, artifact.path))
|
|
810
904
|
throw new Error(`Duplicate managed JSON artifact: ${artifact.path}`);
|
|
811
|
-
const text =
|
|
812
|
-
|
|
905
|
+
const text = texts.get(artifact.path);
|
|
906
|
+
if (text === void 0) throw new Error(`Managed JSON text is missing: ${artifact.path}`);
|
|
907
|
+
result[artifact.path] = text;
|
|
908
|
+
}
|
|
909
|
+
return result;
|
|
910
|
+
}
|
|
911
|
+
function changedObservedPath(root, observation) {
|
|
912
|
+
const absoluteRoot = path.resolve(root);
|
|
913
|
+
for (const [relative, seen] of observation.paths) {
|
|
914
|
+
const absolute = relative === "." ? absoluteRoot : path.join(absoluteRoot, ...relative.split("/"));
|
|
915
|
+
if (!sameObservedPath(seen, observePath(absolute, observation.startedNs))) return relative;
|
|
916
|
+
if (seen.type !== "file" || !seen.racy) continue;
|
|
917
|
+
const text = observation.texts.get(relative);
|
|
813
918
|
try {
|
|
814
|
-
|
|
919
|
+
if (text !== void 0 && readExactText(absolute) !== text) return relative;
|
|
815
920
|
} catch {
|
|
816
|
-
|
|
921
|
+
return relative;
|
|
817
922
|
}
|
|
818
|
-
if (JSON.stringify(parsed) !== JSON.stringify(artifact.json))
|
|
819
|
-
throw new Error(`Managed JSON changed after scanning: ${artifact.path}`);
|
|
820
|
-
result[artifact.path] = text;
|
|
821
923
|
}
|
|
822
|
-
return
|
|
924
|
+
return void 0;
|
|
925
|
+
}
|
|
926
|
+
function touchedPathFacts(root, observation, paths) {
|
|
927
|
+
const absoluteRoot = path.resolve(root);
|
|
928
|
+
const touched = { startedNs: observation.startedNs, paths: /* @__PURE__ */ new Map(), texts: /* @__PURE__ */ new Map() };
|
|
929
|
+
const pathFacts = [];
|
|
930
|
+
for (const relative of new Set(paths.map(import_layoutPaths.parseWorkspacePointer))) {
|
|
931
|
+
pathFacts.push(probeLayoutPath(root, relative));
|
|
932
|
+
const absolute = path.join(absoluteRoot, ...relative.split("/"));
|
|
933
|
+
const seen = observation.paths.get(relative);
|
|
934
|
+
const now = seen ?? observePath(absolute, observation.startedNs);
|
|
935
|
+
const appeared = seen === void 0 && (now.type === "file" || now.type === "symlink" || now.type === "other") && now.ctimeNs >= observation.startedNs + 1000000n;
|
|
936
|
+
touched.paths.set(relative, appeared ? { type: "absent" } : now);
|
|
937
|
+
const text = observation.texts.get(relative);
|
|
938
|
+
if (text !== void 0) touched.texts.set(relative, text);
|
|
939
|
+
}
|
|
940
|
+
return { observation: touched, pathFacts };
|
|
823
941
|
}
|
|
824
942
|
function completeByteFacts(root, scan, inputEvidence) {
|
|
825
943
|
const loaded = loadLayoutByteEvidence({ root, scan, evidence: inputEvidence });
|
|
@@ -831,52 +949,32 @@ function completeByteFacts(root, scan, inputEvidence) {
|
|
|
831
949
|
for (const relative of paths) if (!facts.has(relative)) facts.set(relative, hashLayoutPath(root, relative));
|
|
832
950
|
return [...paths].sort(import_layoutCore.compareText).map((relative) => facts.get(relative));
|
|
833
951
|
}
|
|
834
|
-
function
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
return [...result].sort(import_layoutCore.compareText);
|
|
838
|
-
}
|
|
839
|
-
function sameValue(left, right) {
|
|
840
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
841
|
-
}
|
|
842
|
-
function capture(root, requiredPaths) {
|
|
843
|
-
const beforeStateText = stateText(root);
|
|
844
|
-
const state = (0, import_documents.peekState)(beforeStateText);
|
|
952
|
+
function captureLayoutWorkspaceSeed(root) {
|
|
953
|
+
const text = stateText(root);
|
|
954
|
+
const state = (0, import_documents.peekState)(text);
|
|
845
955
|
if (!state.layout) throw new Error("Layout state is missing");
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
if (beforeStateText !== afterStateText) throw new Error("Layout state changed while capturing the workspace");
|
|
856
|
-
const seed = {
|
|
857
|
-
scan: firstScan,
|
|
858
|
-
jsonText,
|
|
859
|
-
byteFacts,
|
|
860
|
-
stateText: beforeStateText
|
|
956
|
+
const { scan, observation } = observeLayoutScan({ root, tracked: state.layout.tracked });
|
|
957
|
+
return {
|
|
958
|
+
snapshot: {
|
|
959
|
+
scan,
|
|
960
|
+
jsonText: managedJsonText(scan, observation.texts),
|
|
961
|
+
byteFacts: completeByteFacts(root, scan, evidence(state)),
|
|
962
|
+
stateText: text
|
|
963
|
+
},
|
|
964
|
+
observation
|
|
861
965
|
};
|
|
862
|
-
return pathFacts === void 0 ? { snapshot: seed } : { snapshot: { ...seed, pathFacts } };
|
|
863
|
-
}
|
|
864
|
-
function captureLayoutWorkspaceSeed(root) {
|
|
865
|
-
return capture(root);
|
|
866
|
-
}
|
|
867
|
-
function captureLayoutWorkspace(root, requiredPaths) {
|
|
868
|
-
return capture(root, requiredPaths);
|
|
869
966
|
}
|
|
870
967
|
// Annotate the CommonJS export names for ESM import in node:
|
|
871
968
|
0 && (module.exports = {
|
|
872
|
-
captureLayoutWorkspace,
|
|
873
969
|
captureLayoutWorkspaceSeed,
|
|
970
|
+
changedObservedPath,
|
|
874
971
|
hashLayoutPath,
|
|
875
972
|
loadLayoutByteEvidence,
|
|
973
|
+
observeLayoutScan,
|
|
876
974
|
probeLayoutPath,
|
|
877
975
|
resolveLayoutPath,
|
|
878
|
-
sameValue,
|
|
879
976
|
scanLayout,
|
|
880
|
-
stateText
|
|
977
|
+
stateText,
|
|
978
|
+
touchedPathFacts
|
|
881
979
|
});
|
|
882
980
|
//# sourceMappingURL=layoutScan.js.map
|