@debugbundle/cli 1.19.3 → 1.19.4
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 +9 -0
- package/dist/main.cjs +354 -240
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -54914,12 +54914,15 @@ var RetrievalApiError = class extends Error {
|
|
|
54914
54914
|
this.code = code;
|
|
54915
54915
|
}
|
|
54916
54916
|
};
|
|
54917
|
-
var
|
|
54918
|
-
function
|
|
54919
|
-
const parsed =
|
|
54920
|
-
if (!parsed.success) throw new RetrievalApiError(400,
|
|
54917
|
+
var ResourceIdSchema = external_exports.string().max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
54918
|
+
function parseResourceId(value, code) {
|
|
54919
|
+
const parsed = ResourceIdSchema.safeParse(value);
|
|
54920
|
+
if (!parsed.success) throw new RetrievalApiError(400, code);
|
|
54921
54921
|
return parsed.data;
|
|
54922
54922
|
}
|
|
54923
|
+
function parseIncidentId(value) {
|
|
54924
|
+
return parseResourceId(value, "invalid_incident_id");
|
|
54925
|
+
}
|
|
54923
54926
|
function parseApiError(status, body) {
|
|
54924
54927
|
const parsed = ApiErrorResponseSchema.safeParse(body);
|
|
54925
54928
|
if (!parsed.success) {
|
|
@@ -55195,7 +55198,7 @@ function createRetrievalApi(client) {
|
|
|
55195
55198
|
const parsed = await expectParsed(
|
|
55196
55199
|
client.request({
|
|
55197
55200
|
method: "GET",
|
|
55198
|
-
path: `/v1/improvements/${input3.improvementId}`,
|
|
55201
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}`,
|
|
55199
55202
|
bearerToken: input3.bearerToken
|
|
55200
55203
|
}),
|
|
55201
55204
|
ImprovementResponseSchema
|
|
@@ -55206,7 +55209,7 @@ function createRetrievalApi(client) {
|
|
|
55206
55209
|
const parsed = await expectMutation(
|
|
55207
55210
|
client.request({
|
|
55208
55211
|
method: "POST",
|
|
55209
|
-
path: `/v1/improvements/${input3.improvementId}/resolve`,
|
|
55212
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/resolve`,
|
|
55210
55213
|
bearerToken: input3.bearerToken
|
|
55211
55214
|
}),
|
|
55212
55215
|
ImprovementResponseSchema
|
|
@@ -55217,7 +55220,7 @@ function createRetrievalApi(client) {
|
|
|
55217
55220
|
const parsed = await expectMutation(
|
|
55218
55221
|
client.request({
|
|
55219
55222
|
method: "POST",
|
|
55220
|
-
path: `/v1/improvements/${input3.improvementId}/reopen`,
|
|
55223
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/reopen`,
|
|
55221
55224
|
bearerToken: input3.bearerToken
|
|
55222
55225
|
}),
|
|
55223
55226
|
ImprovementResponseSchema
|
|
@@ -55228,7 +55231,7 @@ function createRetrievalApi(client) {
|
|
|
55228
55231
|
const parsed = await expectMutation(
|
|
55229
55232
|
client.request({
|
|
55230
55233
|
method: "POST",
|
|
55231
|
-
path: `/v1/improvements/${input3.improvementId}/snooze`,
|
|
55234
|
+
path: `/v1/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/snooze`,
|
|
55232
55235
|
bearerToken: input3.bearerToken,
|
|
55233
55236
|
body: { snoozed_until: input3.snoozedUntil }
|
|
55234
55237
|
}),
|
|
@@ -55240,7 +55243,7 @@ function createRetrievalApi(client) {
|
|
|
55240
55243
|
return await expectParsed(
|
|
55241
55244
|
client.request({
|
|
55242
55245
|
method: "GET",
|
|
55243
|
-
path: `/v1/projects/${input3.projectId}/improvements/${input3.improvementId}/bundle`,
|
|
55246
|
+
path: `/v1/projects/${encodeURIComponent(parseResourceId(input3.projectId, "invalid_project_id"))}/improvements/${encodeURIComponent(parseResourceId(input3.improvementId, "invalid_improvement_id"))}/bundle`,
|
|
55244
55247
|
bearerToken: input3.bearerToken
|
|
55245
55248
|
}),
|
|
55246
55249
|
external_exports.union([
|
|
@@ -57678,11 +57681,11 @@ async function safePath(root, file2, allowLeafLink = false) {
|
|
|
57678
57681
|
}
|
|
57679
57682
|
return target;
|
|
57680
57683
|
}
|
|
57681
|
-
async function readManaged(root, file2) {
|
|
57684
|
+
async function readManaged(root, file2, maxBytes = 1024 * 1024) {
|
|
57682
57685
|
const path = await safePath(root, file2);
|
|
57683
57686
|
try {
|
|
57684
57687
|
const initial = await (0, import_promises2.lstat)(path);
|
|
57685
|
-
if (!initial.isFile() || initial.size >
|
|
57688
|
+
if (!initial.isFile() || initial.size > maxBytes)
|
|
57686
57689
|
throw new Error(`Invalid or oversized managed file: ${file2}`);
|
|
57687
57690
|
const handle = await (0, import_promises2.open)(
|
|
57688
57691
|
path,
|
|
@@ -57690,16 +57693,17 @@ async function readManaged(root, file2) {
|
|
|
57690
57693
|
);
|
|
57691
57694
|
try {
|
|
57692
57695
|
const info = await handle.stat();
|
|
57693
|
-
if (!info.isFile() || info.size >
|
|
57696
|
+
if (!info.isFile() || info.size > maxBytes)
|
|
57694
57697
|
throw new Error(`Invalid or oversized managed file: ${file2}`);
|
|
57695
|
-
const
|
|
57698
|
+
const limit = Math.min(maxBytes, info.size);
|
|
57699
|
+
const buffer = Buffer.alloc(limit + 1);
|
|
57696
57700
|
let total = 0;
|
|
57697
57701
|
while (total < buffer.length) {
|
|
57698
57702
|
const { bytesRead } = await handle.read(buffer, total, buffer.length - total, total);
|
|
57699
57703
|
if (bytesRead === 0) break;
|
|
57700
57704
|
total += bytesRead;
|
|
57701
57705
|
}
|
|
57702
|
-
if (total >
|
|
57706
|
+
if (total > limit) throw new Error(`Oversized or growing managed file: ${file2}`);
|
|
57703
57707
|
try {
|
|
57704
57708
|
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
|
|
57705
57709
|
buffer.subarray(0, total)
|
|
@@ -57715,7 +57719,7 @@ async function readManaged(root, file2) {
|
|
|
57715
57719
|
throw error62;
|
|
57716
57720
|
}
|
|
57717
57721
|
}
|
|
57718
|
-
async function writeManaged(root, file2, value, expected) {
|
|
57722
|
+
async function writeManaged(root, file2, value, expected, maxBytes = 1024 * 1024) {
|
|
57719
57723
|
const path = await safePath(root, file2);
|
|
57720
57724
|
await (0, import_promises2.mkdir)((0, import_node_path2.dirname)(path), { recursive: true });
|
|
57721
57725
|
await safePath(root, file2);
|
|
@@ -57733,7 +57737,7 @@ async function writeManaged(root, file2, value, expected) {
|
|
|
57733
57737
|
await handle.writeFile(value, "utf8");
|
|
57734
57738
|
if (previousMode !== void 0) await handle.chmod(previousMode);
|
|
57735
57739
|
await handle.close();
|
|
57736
|
-
if (await readManaged(root, file2) !== expected)
|
|
57740
|
+
if (await readManaged(root, file2, maxBytes) !== expected)
|
|
57737
57741
|
throw new Error(`File changed during setup: ${file2}`);
|
|
57738
57742
|
await safePath(root, file2);
|
|
57739
57743
|
await (0, import_promises2.rename)(temporary, path);
|
|
@@ -61945,23 +61949,57 @@ async function agentReadCommand(input3, dependencies = {}) {
|
|
|
61945
61949
|
}
|
|
61946
61950
|
|
|
61947
61951
|
// src/clean-command.ts
|
|
61948
|
-
var
|
|
61952
|
+
var import_promises10 = require("node:fs/promises");
|
|
61949
61953
|
var import_node_path12 = require("node:path");
|
|
61950
61954
|
|
|
61951
|
-
// src/
|
|
61955
|
+
// src/local-artifact-paths.ts
|
|
61952
61956
|
var import_node_path9 = require("node:path");
|
|
61957
|
+
var paths = {
|
|
61958
|
+
bundle: external_exports.string().regex(/^\.debugbundle\/bundles\/local\/[A-Za-z0-9][A-Za-z0-9._-]*\.bundle\.json$/),
|
|
61959
|
+
reproduction: external_exports.string().regex(
|
|
61960
|
+
/^\.debugbundle\/bundles\/local\/reproductions\/[A-Za-z0-9][A-Za-z0-9._-]*\.reproduction\.json$/
|
|
61961
|
+
)
|
|
61962
|
+
};
|
|
61963
|
+
function validateLocalArtifactPath(value, kind) {
|
|
61964
|
+
const result = paths[kind].safeParse(value);
|
|
61965
|
+
if (!result.success) throw new RetrievalApiError(400, "invalid_local_artifact_path");
|
|
61966
|
+
return result.data;
|
|
61967
|
+
}
|
|
61968
|
+
async function resolveLocalArtifactPath(root, value, kind) {
|
|
61969
|
+
const path = validateLocalArtifactPath(value, kind);
|
|
61970
|
+
try {
|
|
61971
|
+
return await safePath(root, path);
|
|
61972
|
+
} catch {
|
|
61973
|
+
throw new RetrievalApiError(400, "invalid_local_artifact_path");
|
|
61974
|
+
}
|
|
61975
|
+
}
|
|
61976
|
+
var LOCAL_FILE_LIMIT = 2 ** 31 - 1;
|
|
61977
|
+
async function readWorkspaceFile(root, path, reader, maxBytes = LOCAL_FILE_LIMIT) {
|
|
61978
|
+
const file2 = (0, import_node_path9.relative)(root, path);
|
|
61979
|
+
await safePath(root, file2);
|
|
61980
|
+
const raw = reader ? await reader(path) : await readManaged(root, file2, maxBytes);
|
|
61981
|
+
if (raw === void 0)
|
|
61982
|
+
throw Object.assign(new Error("Local file not found."), { code: "ENOENT" });
|
|
61983
|
+
if (Buffer.byteLength(raw, "utf8") > maxBytes) throw new Error("Oversized local file.");
|
|
61984
|
+
return raw;
|
|
61985
|
+
}
|
|
61986
|
+
async function writeWorkspaceFile(root, path, contents, writer) {
|
|
61987
|
+
const file2 = (0, import_node_path9.relative)(root, path);
|
|
61988
|
+
await safePath(root, file2);
|
|
61989
|
+
if (writer) return writer(path, contents);
|
|
61990
|
+
const previous = await readManaged(root, file2, LOCAL_FILE_LIMIT);
|
|
61991
|
+
await writeManaged(root, file2, contents, previous, LOCAL_FILE_LIMIT);
|
|
61992
|
+
}
|
|
61993
|
+
|
|
61994
|
+
// src/cli-fs-helpers.ts
|
|
61953
61995
|
function isRecord2(value) {
|
|
61954
61996
|
return typeof value === "object" && value !== null;
|
|
61955
61997
|
}
|
|
61956
61998
|
function isMissingPathError(error62) {
|
|
61957
61999
|
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === "ENOENT";
|
|
61958
62000
|
}
|
|
61959
|
-
function resolveWorkspacePath(rootDirectory, targetPath) {
|
|
61960
|
-
return (0, import_node_path9.isAbsolute)(targetPath) ? targetPath : (0, import_node_path9.join)(rootDirectory, targetPath);
|
|
61961
|
-
}
|
|
61962
62001
|
|
|
61963
62002
|
// src/local-retrieval-store.ts
|
|
61964
|
-
var import_promises9 = require("node:fs/promises");
|
|
61965
62003
|
var import_node_path10 = require("node:path");
|
|
61966
62004
|
|
|
61967
62005
|
// ../../packages/event-normalizer/src/local-correlation-scope.ts
|
|
@@ -62053,8 +62091,17 @@ function projectLocalEvidence(value) {
|
|
|
62053
62091
|
return projected.value;
|
|
62054
62092
|
}
|
|
62055
62093
|
async function readLocalArtifact(path, dependencies) {
|
|
62056
|
-
const
|
|
62057
|
-
const raw = await
|
|
62094
|
+
const reader = dependencies?.readFile;
|
|
62095
|
+
const raw = await readWorkspaceFile(
|
|
62096
|
+
getWorkspaceRoot(dependencies),
|
|
62097
|
+
path,
|
|
62098
|
+
reader ? (file2) => reader(file2, "utf8") : void 0,
|
|
62099
|
+
MAX_ARTIFACT_BYTES
|
|
62100
|
+
).catch((error62) => {
|
|
62101
|
+
if (error62 instanceof Error && /oversized/i.test(error62.message))
|
|
62102
|
+
throw createReadError(503, "privacy_projection_unavailable");
|
|
62103
|
+
throw error62;
|
|
62104
|
+
});
|
|
62058
62105
|
if (Buffer.byteLength(raw, "utf8") > MAX_ARTIFACT_BYTES) {
|
|
62059
62106
|
throw createReadError(503, "privacy_projection_unavailable");
|
|
62060
62107
|
}
|
|
@@ -62072,9 +62119,15 @@ function createReadError(status, code) {
|
|
|
62072
62119
|
return new RetrievalApiError(status, code);
|
|
62073
62120
|
}
|
|
62074
62121
|
async function readJsonFile(path, dependencies) {
|
|
62075
|
-
const
|
|
62122
|
+
const reader = dependencies?.readFile;
|
|
62076
62123
|
try {
|
|
62077
|
-
return JSON.parse(
|
|
62124
|
+
return JSON.parse(
|
|
62125
|
+
await readWorkspaceFile(
|
|
62126
|
+
getWorkspaceRoot(dependencies),
|
|
62127
|
+
path,
|
|
62128
|
+
reader ? (file2) => reader(file2, "utf8") : void 0
|
|
62129
|
+
)
|
|
62130
|
+
);
|
|
62078
62131
|
} catch (error62) {
|
|
62079
62132
|
if (isRecord2(error62) && error62["code"] === "ENOENT") {
|
|
62080
62133
|
throw error62;
|
|
@@ -62144,6 +62197,8 @@ function parseLocalIncident(candidate) {
|
|
|
62144
62197
|
if (!isStringArray(candidate["source_event_types"]) || !isStringArray(candidate["matched_fields"])) {
|
|
62145
62198
|
throw createReadError(400, "invalid_local_state");
|
|
62146
62199
|
}
|
|
62200
|
+
validateLocalArtifactPath(candidate["bundle_path"], "bundle");
|
|
62201
|
+
validateLocalArtifactPath(candidate["reproduction_path"], "reproduction");
|
|
62147
62202
|
const serviceRuntime = candidate["service_runtime"];
|
|
62148
62203
|
const serviceFramework = candidate["service_framework"];
|
|
62149
62204
|
const incidentReason = candidate["matched_fields"].includes("request_anomaly") ? deriveIncidentReasonFromSignal({
|
|
@@ -62268,9 +62323,15 @@ async function readLocalState(dependencies) {
|
|
|
62268
62323
|
}
|
|
62269
62324
|
async function writeLocalState(state2, dependencies) {
|
|
62270
62325
|
const rootDirectory = getWorkspaceRoot(dependencies);
|
|
62271
|
-
|
|
62272
|
-
|
|
62273
|
-
|
|
62326
|
+
parseLocalState(state2);
|
|
62327
|
+
const writer = dependencies?.writeFile;
|
|
62328
|
+
await writeWorkspaceFile(
|
|
62329
|
+
rootDirectory,
|
|
62330
|
+
getStateFilePath(rootDirectory),
|
|
62331
|
+
`${JSON.stringify(state2, null, 2)}
|
|
62332
|
+
`,
|
|
62333
|
+
writer ? (path, contents) => writer(path, contents, "utf8") : void 0
|
|
62334
|
+
);
|
|
62274
62335
|
}
|
|
62275
62336
|
async function updateLocalIncidentStatus(input3, dependencies) {
|
|
62276
62337
|
const state2 = await readLocalState(dependencies);
|
|
@@ -62333,7 +62394,7 @@ async function getLocalBundle(input3, dependencies) {
|
|
|
62333
62394
|
if (incident === void 0) throw createReadError(404, "incident_not_found");
|
|
62334
62395
|
try {
|
|
62335
62396
|
return await readLocalArtifact(
|
|
62336
|
-
|
|
62397
|
+
await resolveLocalArtifactPath(rootDirectory, incident.bundle_path, "bundle"),
|
|
62337
62398
|
dependencies
|
|
62338
62399
|
);
|
|
62339
62400
|
} catch (error62) {
|
|
@@ -62352,7 +62413,7 @@ async function getLocalReproduction(input3, dependencies) {
|
|
|
62352
62413
|
if (incident === void 0) throw createReadError(404, "incident_not_found");
|
|
62353
62414
|
try {
|
|
62354
62415
|
return await readLocalArtifact(
|
|
62355
|
-
|
|
62416
|
+
await resolveLocalArtifactPath(rootDirectory, incident.reproduction_path, "reproduction"),
|
|
62356
62417
|
dependencies
|
|
62357
62418
|
);
|
|
62358
62419
|
} catch (error62) {
|
|
@@ -62376,7 +62437,7 @@ async function reopenLocalIncident(input3, dependencies) {
|
|
|
62376
62437
|
}
|
|
62377
62438
|
|
|
62378
62439
|
// src/cloud-artifact-cache.ts
|
|
62379
|
-
var
|
|
62440
|
+
var import_promises9 = require("node:fs/promises");
|
|
62380
62441
|
var import_node_path11 = require("node:path");
|
|
62381
62442
|
|
|
62382
62443
|
// src/retrieval-source.ts
|
|
@@ -62529,9 +62590,9 @@ async function pruneCloudArtifactCache(input3, dependencies) {
|
|
|
62529
62590
|
}
|
|
62530
62591
|
async function pruneExpiredArtifactsInDirectory(directoryPath, now, olderThanMs, dependencies) {
|
|
62531
62592
|
await checkedCachePath(directoryPath, dependencies);
|
|
62532
|
-
const readdir = dependencies?.readdir ??
|
|
62533
|
-
const rm = dependencies?.rm ??
|
|
62534
|
-
const stat = dependencies?.stat ??
|
|
62593
|
+
const readdir = dependencies?.readdir ?? import_promises9.readdir;
|
|
62594
|
+
const rm = dependencies?.rm ?? import_promises9.rm;
|
|
62595
|
+
const stat = dependencies?.stat ?? import_promises9.lstat;
|
|
62535
62596
|
let fileNames;
|
|
62536
62597
|
try {
|
|
62537
62598
|
fileNames = await readdir(directoryPath);
|
|
@@ -62685,9 +62746,9 @@ function parseOlderThan(value) {
|
|
|
62685
62746
|
return Number.parseInt(match[1], 10) * 24 * 60 * 60 * 1e3;
|
|
62686
62747
|
}
|
|
62687
62748
|
async function cleanProcessedEventFiles(input3, dependencies) {
|
|
62688
|
-
const readdir = dependencies.readdir ??
|
|
62689
|
-
const rm = dependencies.rm ??
|
|
62690
|
-
const stat = dependencies.stat ??
|
|
62749
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62750
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62751
|
+
const stat = dependencies.stat ?? import_promises10.stat;
|
|
62691
62752
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62692
62753
|
const eventsDirectoryPath = (0, import_node_path12.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH);
|
|
62693
62754
|
const state2 = await readLocalState(dependencies);
|
|
@@ -62722,9 +62783,9 @@ async function cleanProcessedEventFiles(input3, dependencies) {
|
|
|
62722
62783
|
return { removed, retained };
|
|
62723
62784
|
}
|
|
62724
62785
|
async function cleanRelaySpoolFiles(input3, dependencies) {
|
|
62725
|
-
const readdir = dependencies.readdir ??
|
|
62726
|
-
const rm = dependencies.rm ??
|
|
62727
|
-
const stat = dependencies.stat ??
|
|
62786
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62787
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62788
|
+
const stat = dependencies.stat ?? import_promises10.stat;
|
|
62728
62789
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62729
62790
|
const spoolDirectoryPath = (0, import_node_path12.join)(rootDirectory, LOCAL_RELAY_SPOOL_DIRECTORY_PATH);
|
|
62730
62791
|
let spoolFileNames;
|
|
@@ -62775,7 +62836,7 @@ function sortLocalIncidentRemovalPriority(left, right) {
|
|
|
62775
62836
|
return left.incident_id.localeCompare(right.incident_id);
|
|
62776
62837
|
}
|
|
62777
62838
|
async function applyLocalIncidentRetention(dependencies) {
|
|
62778
|
-
const rm = dependencies.rm ??
|
|
62839
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62779
62840
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62780
62841
|
const state2 = await readLocalState(dependencies);
|
|
62781
62842
|
const incidents = Object.values(state2.incidents);
|
|
@@ -62789,8 +62850,13 @@ async function applyLocalIncidentRetention(dependencies) {
|
|
|
62789
62850
|
const nextIncidents = { ...state2.incidents };
|
|
62790
62851
|
for (const incident of incidentsToRemove) {
|
|
62791
62852
|
delete nextIncidents[incident.incident_id];
|
|
62792
|
-
await rm(
|
|
62793
|
-
|
|
62853
|
+
await rm(await resolveLocalArtifactPath(rootDirectory, incident.bundle_path, "bundle"), {
|
|
62854
|
+
force: true
|
|
62855
|
+
});
|
|
62856
|
+
await rm(
|
|
62857
|
+
await resolveLocalArtifactPath(rootDirectory, incident.reproduction_path, "reproduction"),
|
|
62858
|
+
{ force: true }
|
|
62859
|
+
);
|
|
62794
62860
|
}
|
|
62795
62861
|
await writeLocalState(
|
|
62796
62862
|
{
|
|
@@ -62808,10 +62874,12 @@ async function countLocalIncidents(dependencies) {
|
|
|
62808
62874
|
return Object.keys((await readLocalState(dependencies)).incidents).length;
|
|
62809
62875
|
}
|
|
62810
62876
|
async function countDirectoryFiles(directoryPath, dependencies, extension) {
|
|
62811
|
-
const readdir = dependencies.readdir ??
|
|
62877
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62812
62878
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62813
62879
|
try {
|
|
62814
|
-
return (await readdir((0, import_node_path12.join)(rootDirectory, directoryPath))).filter(
|
|
62880
|
+
return (await readdir((0, import_node_path12.join)(rootDirectory, directoryPath))).filter(
|
|
62881
|
+
(fileName) => fileName.endsWith(extension)
|
|
62882
|
+
).length;
|
|
62815
62883
|
} catch (error62) {
|
|
62816
62884
|
if (isMissingPathError(error62)) {
|
|
62817
62885
|
return 0;
|
|
@@ -62826,10 +62894,15 @@ async function countRelaySpoolEventFiles(dependencies) {
|
|
|
62826
62894
|
return countDirectoryFiles(LOCAL_RELAY_SPOOL_DIRECTORY_PATH, dependencies, ".events.json");
|
|
62827
62895
|
}
|
|
62828
62896
|
async function resetRuntimeData(dependencies) {
|
|
62829
|
-
const mkdir5 = dependencies.mkdir ??
|
|
62830
|
-
const rm = dependencies.rm ??
|
|
62897
|
+
const mkdir5 = dependencies.mkdir ?? import_promises10.mkdir;
|
|
62898
|
+
const rm = dependencies.rm ?? import_promises10.rm;
|
|
62831
62899
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62832
|
-
const [
|
|
62900
|
+
const [
|
|
62901
|
+
processedEventFilesRemoved,
|
|
62902
|
+
relaySpoolFilesRemoved,
|
|
62903
|
+
cloudCacheFilesRemoved,
|
|
62904
|
+
localIncidentCount
|
|
62905
|
+
] = await Promise.all([
|
|
62833
62906
|
countProcessedAndUnprocessedEventFiles(dependencies),
|
|
62834
62907
|
countRelaySpoolEventFiles(dependencies),
|
|
62835
62908
|
countCloudArtifactFiles(dependencies),
|
|
@@ -62872,6 +62945,17 @@ async function cleanCommand(input3, dependencies = {}) {
|
|
|
62872
62945
|
output: "Invalid value for --older-than."
|
|
62873
62946
|
};
|
|
62874
62947
|
}
|
|
62948
|
+
const root = (dependencies.cwd ?? process.cwd)();
|
|
62949
|
+
for (const path of [
|
|
62950
|
+
".debugbundle/local/state.json",
|
|
62951
|
+
LOCAL_EVENTS_DIRECTORY_PATH,
|
|
62952
|
+
LOCAL_RELAY_SPOOL_DIRECTORY_PATH,
|
|
62953
|
+
LOCAL_BUNDLE_DIRECTORY_PATH2,
|
|
62954
|
+
LOCAL_REPRODUCTION_DIRECTORY_PATH,
|
|
62955
|
+
CLOUD_BUNDLE_DIRECTORY_PATH2,
|
|
62956
|
+
CLOUD_REPRODUCTION_DIRECTORY_PATH2
|
|
62957
|
+
])
|
|
62958
|
+
await safePath(root, path);
|
|
62875
62959
|
const hasEventsFlag = input3.events === true;
|
|
62876
62960
|
const hasBundlesFlag = input3.bundles === true;
|
|
62877
62961
|
const hasAllFlag = input3.all === true;
|
|
@@ -62898,9 +62982,15 @@ async function cleanCommand(input3, dependencies = {}) {
|
|
|
62898
62982
|
output: input3.json ? JSON.stringify(summary2) : formatCleanOutput(summary2)
|
|
62899
62983
|
};
|
|
62900
62984
|
}
|
|
62901
|
-
const processedEvents = runEventsCleanup ? await cleanProcessedEventFiles(
|
|
62985
|
+
const processedEvents = runEventsCleanup ? await cleanProcessedEventFiles(
|
|
62986
|
+
{ removeAllProcessed: input3.events === true, now },
|
|
62987
|
+
dependencies
|
|
62988
|
+
) : { removed: 0, retained: await countProcessedAndUnprocessedEventFiles(dependencies) };
|
|
62902
62989
|
const relaySpool = await cleanRelaySpoolFiles({ now }, dependencies);
|
|
62903
|
-
const cloudCache = runBundleCleanup ? await pruneCloudArtifactCache(
|
|
62990
|
+
const cloudCache = runBundleCleanup ? await pruneCloudArtifactCache(
|
|
62991
|
+
{ olderThanMs: bundleRetentionMs ?? DEFAULT_CLOUD_CACHE_RETENTION_MS },
|
|
62992
|
+
{ ...dependencies, now: () => now }
|
|
62993
|
+
) : await countCloudArtifactCache(dependencies);
|
|
62904
62994
|
const localIncidents = runLocalIncidentCleanup ? await applyLocalIncidentRetention(dependencies) : { removed: 0, retained: await countLocalIncidents(dependencies) };
|
|
62905
62995
|
const summary = {
|
|
62906
62996
|
status: "ok",
|
|
@@ -62919,10 +63009,12 @@ async function cleanCommand(input3, dependencies = {}) {
|
|
|
62919
63009
|
};
|
|
62920
63010
|
}
|
|
62921
63011
|
async function countProcessedAndUnprocessedEventFiles(dependencies) {
|
|
62922
|
-
const readdir = dependencies.readdir ??
|
|
63012
|
+
const readdir = dependencies.readdir ?? import_promises10.readdir;
|
|
62923
63013
|
const rootDirectory = (dependencies.cwd ?? process.cwd)();
|
|
62924
63014
|
try {
|
|
62925
|
-
return (await readdir((0, import_node_path12.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH))).filter(
|
|
63015
|
+
return (await readdir((0, import_node_path12.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH))).filter(
|
|
63016
|
+
(fileName) => fileName.endsWith(".events.json")
|
|
63017
|
+
).length;
|
|
62926
63018
|
} catch (error62) {
|
|
62927
63019
|
if (isMissingPathError(error62)) {
|
|
62928
63020
|
return 0;
|
|
@@ -62931,11 +63023,14 @@ async function countProcessedAndUnprocessedEventFiles(dependencies) {
|
|
|
62931
63023
|
}
|
|
62932
63024
|
}
|
|
62933
63025
|
async function countCloudArtifactCache(dependencies) {
|
|
62934
|
-
return pruneCloudArtifactCache(
|
|
63026
|
+
return pruneCloudArtifactCache(
|
|
63027
|
+
{ olderThanMs: Number.MAX_SAFE_INTEGER },
|
|
63028
|
+
{ ...dependencies, now: () => /* @__PURE__ */ new Date(0) }
|
|
63029
|
+
);
|
|
62935
63030
|
}
|
|
62936
63031
|
|
|
62937
63032
|
// src/connect-command.ts
|
|
62938
|
-
var
|
|
63033
|
+
var import_promises12 = require("node:fs/promises");
|
|
62939
63034
|
var import_node_path14 = require("node:path");
|
|
62940
63035
|
|
|
62941
63036
|
// src/connection-config.ts
|
|
@@ -62974,12 +63069,12 @@ async function readConnectionConfig(rootDirectory, readFile) {
|
|
|
62974
63069
|
|
|
62975
63070
|
// src/interactive-auth.ts
|
|
62976
63071
|
var import_node_process = require("node:process");
|
|
62977
|
-
var
|
|
63072
|
+
var import_promises11 = require("node:readline/promises");
|
|
62978
63073
|
function isInteractiveTerminal() {
|
|
62979
63074
|
return import_node_process.stdin.isTTY === true && import_node_process.stdout.isTTY === true;
|
|
62980
63075
|
}
|
|
62981
63076
|
async function promptForInteractiveLoginSelection() {
|
|
62982
|
-
const readlineInterface = (0,
|
|
63077
|
+
const readlineInterface = (0, import_promises11.createInterface)({
|
|
62983
63078
|
input: import_node_process.stdin,
|
|
62984
63079
|
output: import_node_process.stdout
|
|
62985
63080
|
});
|
|
@@ -63584,9 +63679,9 @@ function buildValidationFailureResult(input3) {
|
|
|
63584
63679
|
}
|
|
63585
63680
|
async function connectCommand(input3, dependencies = {}) {
|
|
63586
63681
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
63587
|
-
const readFile = dependencies.readFile ?? ((path) => (0,
|
|
63588
|
-
const stat = dependencies.stat ??
|
|
63589
|
-
const writeFile = dependencies.writeFile ??
|
|
63682
|
+
const readFile = dependencies.readFile ?? ((path) => (0, import_promises12.readFile)(path, "utf8"));
|
|
63683
|
+
const stat = dependencies.stat ?? import_promises12.stat;
|
|
63684
|
+
const writeFile = dependencies.writeFile ?? import_promises12.writeFile;
|
|
63590
63685
|
const readAuthState = dependencies.readAuthState ?? ((authInput) => readCliAuthState(authInput));
|
|
63591
63686
|
const createHttpClient = dependencies.createHttpClient ?? ((clientInput) => {
|
|
63592
63687
|
const httpClientDependencies = {};
|
|
@@ -63793,7 +63888,7 @@ var legacy_skill_hashes_default = {
|
|
|
63793
63888
|
};
|
|
63794
63889
|
|
|
63795
63890
|
// src/agent-setup.ts
|
|
63796
|
-
var
|
|
63891
|
+
var import_promises13 = require("node:readline/promises");
|
|
63797
63892
|
var import_node_process2 = require("node:process");
|
|
63798
63893
|
var MANAGED_AGENTS_START = "<!-- debugbundle:start -->";
|
|
63799
63894
|
var MANAGED_AGENTS_END = "<!-- debugbundle:end -->";
|
|
@@ -63831,7 +63926,7 @@ async function chooseAgents(root, input3, dependencies) {
|
|
|
63831
63926
|
let answer;
|
|
63832
63927
|
if (dependencies.promptUser) answer = await dependencies.promptUser(prompt);
|
|
63833
63928
|
else {
|
|
63834
|
-
const terminal = (0,
|
|
63929
|
+
const terminal = (0, import_promises13.createInterface)({ input: import_node_process2.stdin, output: import_node_process2.stdout });
|
|
63835
63930
|
try {
|
|
63836
63931
|
answer = await terminal.question(prompt);
|
|
63837
63932
|
} finally {
|
|
@@ -63883,7 +63978,7 @@ function localScaffoldFailure(error62, json2 = false) {
|
|
|
63883
63978
|
}
|
|
63884
63979
|
|
|
63885
63980
|
// src/doctor-command.ts
|
|
63886
|
-
var
|
|
63981
|
+
var import_promises14 = require("node:fs/promises");
|
|
63887
63982
|
var import_node_path15 = require("node:path");
|
|
63888
63983
|
|
|
63889
63984
|
// ../../packages/event-normalizer/src/fingerprints.ts
|
|
@@ -65589,13 +65684,13 @@ async function runDoctorCommand(input3, dependencies = {}) {
|
|
|
65589
65684
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
65590
65685
|
const fetchImpl = dependencies.fetchImpl ?? nodeFetch;
|
|
65591
65686
|
const readAuthStateImpl = dependencies.readAuthState ?? readCliAuthState;
|
|
65592
|
-
const readdir = dependencies.readdir ??
|
|
65687
|
+
const readdir = dependencies.readdir ?? import_promises14.readdir;
|
|
65593
65688
|
const readFile = dependencies.readFile ?? (async (filePath) => {
|
|
65594
65689
|
const content = await readManaged(rootDirectory, (0, import_node_path15.relative)(rootDirectory, filePath));
|
|
65595
65690
|
if (content === void 0) throw Object.assign(new Error("Missing local scaffold file."), { code: "ENOENT" });
|
|
65596
65691
|
return content;
|
|
65597
65692
|
});
|
|
65598
|
-
const stat = dependencies.stat ??
|
|
65693
|
+
const stat = dependencies.stat ?? import_promises14.stat;
|
|
65599
65694
|
const rootDirectory = await projectRoot(cwd());
|
|
65600
65695
|
const currentTime = now();
|
|
65601
65696
|
const { check: profileCheck, profile, validationErrors } = await loadProfile(rootDirectory, { readFile, stat });
|
|
@@ -65641,8 +65736,8 @@ async function doctorCommand(input3, dependencies = {}) {
|
|
|
65641
65736
|
|
|
65642
65737
|
// src/ingest-command.ts
|
|
65643
65738
|
var import_node_crypto8 = require("node:crypto");
|
|
65644
|
-
var
|
|
65645
|
-
var
|
|
65739
|
+
var import_promises16 = require("node:fs/promises");
|
|
65740
|
+
var import_node_path18 = require("node:path");
|
|
65646
65741
|
|
|
65647
65742
|
// ../../packages/log-parser/src/project-id.ts
|
|
65648
65743
|
var import_node_crypto5 = require("node:crypto");
|
|
@@ -66130,6 +66225,10 @@ function parseIncidentState(candidate) {
|
|
|
66130
66225
|
if (!isRecord2(candidate)) {
|
|
66131
66226
|
return null;
|
|
66132
66227
|
}
|
|
66228
|
+
if (typeof candidate["bundle_path"] === "string")
|
|
66229
|
+
validateLocalArtifactPath(candidate["bundle_path"], "bundle");
|
|
66230
|
+
if (typeof candidate["reproduction_path"] === "string")
|
|
66231
|
+
validateLocalArtifactPath(candidate["reproduction_path"], "reproduction");
|
|
66133
66232
|
if (candidate["source"] !== "local" || candidate["status"] !== "open" && candidate["status"] !== "resolved") {
|
|
66134
66233
|
return null;
|
|
66135
66234
|
}
|
|
@@ -66206,8 +66305,11 @@ function parseIncidentState(candidate) {
|
|
|
66206
66305
|
const occurrenceCount = candidate["occurrence_count"];
|
|
66207
66306
|
const sourceEventId = candidate["source_event_id"];
|
|
66208
66307
|
const sourceOccurredAt = candidate["source_occurred_at"];
|
|
66209
|
-
const bundlePath = candidate["bundle_path"];
|
|
66210
|
-
const reproductionPath =
|
|
66308
|
+
const bundlePath = validateLocalArtifactPath(candidate["bundle_path"], "bundle");
|
|
66309
|
+
const reproductionPath = validateLocalArtifactPath(
|
|
66310
|
+
candidate["reproduction_path"],
|
|
66311
|
+
"reproduction"
|
|
66312
|
+
);
|
|
66211
66313
|
const generationNumber = candidate["generation_number"];
|
|
66212
66314
|
const normalizedSourceEventTypes = [...sourceEventTypes].sort();
|
|
66213
66315
|
return {
|
|
@@ -66301,8 +66403,9 @@ async function readState(statePath, readFile, stat) {
|
|
|
66301
66403
|
}
|
|
66302
66404
|
try {
|
|
66303
66405
|
return parseState(await readFile(statePath));
|
|
66304
|
-
} catch {
|
|
66305
|
-
return null;
|
|
66406
|
+
} catch (error62) {
|
|
66407
|
+
if (error62 instanceof SyntaxError) return null;
|
|
66408
|
+
throw error62;
|
|
66306
66409
|
}
|
|
66307
66410
|
}
|
|
66308
66411
|
async function readEventBatches(eventDirectoryPath, fileNames, readFile) {
|
|
@@ -66362,9 +66465,6 @@ function serializeState(state2) {
|
|
|
66362
66465
|
`;
|
|
66363
66466
|
}
|
|
66364
66467
|
|
|
66365
|
-
// src/local-bundle-artifacts.ts
|
|
66366
|
-
var import_node_path17 = require("node:path");
|
|
66367
|
-
|
|
66368
66468
|
// ../../packages/bundle-engine/src/envelope-selection.ts
|
|
66369
66469
|
function selectLatestEnvelope(envelopes, predicate) {
|
|
66370
66470
|
for (let index = envelopes.length - 1; index >= 0; index -= 1) {
|
|
@@ -68003,12 +68103,20 @@ function localBundle(input3) {
|
|
|
68003
68103
|
});
|
|
68004
68104
|
}
|
|
68005
68105
|
async function writeLocalBundleArtifacts(input3) {
|
|
68106
|
+
const bundlePath = await resolveLocalArtifactPath(
|
|
68107
|
+
input3.rootDirectory,
|
|
68108
|
+
input3.incident.bundle_path,
|
|
68109
|
+
"bundle"
|
|
68110
|
+
);
|
|
68111
|
+
const reproductionPath = await resolveLocalArtifactPath(
|
|
68112
|
+
input3.rootDirectory,
|
|
68113
|
+
input3.incident.reproduction_path,
|
|
68114
|
+
"reproduction"
|
|
68115
|
+
);
|
|
68006
68116
|
let previous = null;
|
|
68007
68117
|
if (input3.readFile) {
|
|
68008
68118
|
try {
|
|
68009
|
-
previous = BundleV1Schema.parse(
|
|
68010
|
-
JSON.parse(await input3.readFile((0, import_node_path17.join)(input3.rootDirectory, input3.incident.bundle_path)))
|
|
68011
|
-
);
|
|
68119
|
+
previous = BundleV1Schema.parse(JSON.parse(await input3.readFile(bundlePath)));
|
|
68012
68120
|
} catch {
|
|
68013
68121
|
}
|
|
68014
68122
|
}
|
|
@@ -68018,19 +68126,19 @@ async function writeLocalBundleArtifacts(input3) {
|
|
|
68018
68126
|
});
|
|
68019
68127
|
if (previous && JSON.stringify({ ...bundle, metadata: previous.metadata }) === JSON.stringify(previous))
|
|
68020
68128
|
return;
|
|
68021
|
-
await input3.writeFile(
|
|
68022
|
-
|
|
68023
|
-
|
|
68024
|
-
`
|
|
68025
|
-
);
|
|
68026
|
-
await input3.writeFile(
|
|
68027
|
-
(0, import_node_path17.join)(input3.rootDirectory, input3.incident.reproduction_path),
|
|
68028
|
-
`${JSON.stringify(bundle.reproduction, null, 2)}
|
|
68029
|
-
`
|
|
68030
|
-
);
|
|
68129
|
+
await input3.writeFile(bundlePath, `${JSON.stringify(bundle, null, 2)}
|
|
68130
|
+
`);
|
|
68131
|
+
await input3.writeFile(reproductionPath, `${JSON.stringify(bundle.reproduction, null, 2)}
|
|
68132
|
+
`);
|
|
68031
68133
|
}
|
|
68032
68134
|
async function rebuildLocalDiagnosticArtifacts(input3) {
|
|
68033
68135
|
const { incident } = input3;
|
|
68136
|
+
const bundlePath = await resolveLocalArtifactPath(
|
|
68137
|
+
input3.rootDirectory,
|
|
68138
|
+
incident.bundle_path,
|
|
68139
|
+
"bundle"
|
|
68140
|
+
);
|
|
68141
|
+
await resolveLocalArtifactPath(input3.rootDirectory, incident.reproduction_path, "reproduction");
|
|
68034
68142
|
const primary = incident.source_events.find((event) => event.event_id === incident.source_event_id) ?? null;
|
|
68035
68143
|
const association = associateDiagnosticEvidence({
|
|
68036
68144
|
failure: primary,
|
|
@@ -68039,9 +68147,7 @@ async function rebuildLocalDiagnosticArtifacts(input3) {
|
|
|
68039
68147
|
});
|
|
68040
68148
|
let previous = null;
|
|
68041
68149
|
try {
|
|
68042
|
-
previous = BundleV1Schema.parse(
|
|
68043
|
-
JSON.parse(await input3.readFile((0, import_node_path17.join)(input3.rootDirectory, incident.bundle_path)))
|
|
68044
|
-
);
|
|
68150
|
+
previous = BundleV1Schema.parse(JSON.parse(await input3.readFile(bundlePath)));
|
|
68045
68151
|
} catch {
|
|
68046
68152
|
}
|
|
68047
68153
|
if (association.events.length === 0 && previous?.context.recovery === void 0 && previous?.context.resource_observations === void 0)
|
|
@@ -68066,8 +68172,8 @@ async function rebuildLocalDiagnosticArtifacts(input3) {
|
|
|
68066
68172
|
|
|
68067
68173
|
// src/process-command.ts
|
|
68068
68174
|
var import_node_crypto7 = require("node:crypto");
|
|
68069
|
-
var
|
|
68070
|
-
var
|
|
68175
|
+
var import_promises15 = require("node:fs/promises");
|
|
68176
|
+
var import_node_path17 = require("node:path");
|
|
68071
68177
|
var LOCAL_EVENTS_DIRECTORY_PATH3 = ".debugbundle/local/events";
|
|
68072
68178
|
var LOCAL_STATE_FILE_PATH = ".debugbundle/local/state.json";
|
|
68073
68179
|
var LOCAL_BUNDLE_DIRECTORY_PATH3 = ".debugbundle/bundles/local";
|
|
@@ -68330,18 +68436,26 @@ function requireProjectId(event) {
|
|
|
68330
68436
|
}
|
|
68331
68437
|
async function processCommand(input3, dependencies = {}) {
|
|
68332
68438
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
68333
|
-
const mkdir5 = dependencies.mkdir ?? import_promises16.mkdir;
|
|
68334
|
-
const readFile = dependencies.readFile ?? ((filePath) => (0, import_promises16.readFile)(filePath, "utf8"));
|
|
68335
|
-
const readdir = dependencies.readdir ?? import_promises16.readdir;
|
|
68336
|
-
const stat = dependencies.stat ?? import_promises16.stat;
|
|
68337
|
-
const writeFile = dependencies.writeFile ?? ((filePath, content) => (0, import_promises16.writeFile)(filePath, content, "utf8"));
|
|
68338
68439
|
const rootDirectory = cwd();
|
|
68339
|
-
const
|
|
68340
|
-
const
|
|
68341
|
-
const
|
|
68342
|
-
const
|
|
68440
|
+
const mkdir5 = dependencies.mkdir ?? import_promises15.mkdir;
|
|
68441
|
+
const readFile = (filePath) => readWorkspaceFile(rootDirectory, filePath, dependencies.readFile);
|
|
68442
|
+
const readdir = dependencies.readdir ?? import_promises15.readdir;
|
|
68443
|
+
const stat = dependencies.stat ?? import_promises15.stat;
|
|
68444
|
+
const writeFile = (filePath, content) => writeWorkspaceFile(rootDirectory, filePath, content, dependencies.writeFile);
|
|
68445
|
+
const eventsDirectoryPath = (0, import_node_path17.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH3);
|
|
68446
|
+
const statePath = (0, import_node_path17.join)(rootDirectory, LOCAL_STATE_FILE_PATH);
|
|
68447
|
+
const bundleDirectoryPath = (0, import_node_path17.join)(rootDirectory, LOCAL_BUNDLE_DIRECTORY_PATH3);
|
|
68448
|
+
const reproductionDirectoryPath = (0, import_node_path17.join)(rootDirectory, LOCAL_REPRODUCTION_DIRECTORY_PATH2);
|
|
68343
68449
|
const capturePreset = input3.preset ?? "minimal";
|
|
68344
|
-
|
|
68450
|
+
for (const path of [
|
|
68451
|
+
".debugbundle/local",
|
|
68452
|
+
LOCAL_STATE_FILE_PATH,
|
|
68453
|
+
LOCAL_EVENTS_DIRECTORY_PATH3,
|
|
68454
|
+
LOCAL_BUNDLE_DIRECTORY_PATH3,
|
|
68455
|
+
LOCAL_REPRODUCTION_DIRECTORY_PATH2
|
|
68456
|
+
])
|
|
68457
|
+
await safePath(rootDirectory, path);
|
|
68458
|
+
await mkdir5((0, import_node_path17.join)(rootDirectory, ".debugbundle", "local"), { recursive: true });
|
|
68345
68459
|
await mkdir5(bundleDirectoryPath, { recursive: true });
|
|
68346
68460
|
await mkdir5(reproductionDirectoryPath, { recursive: true });
|
|
68347
68461
|
const previousState = await readState(statePath, readFile, stat);
|
|
@@ -68374,7 +68488,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
68374
68488
|
};
|
|
68375
68489
|
}
|
|
68376
68490
|
const batches = await readEventBatches(eventsDirectoryPath, targetEventFileNames, readFile);
|
|
68377
|
-
const diagnosticReceiptPath = (0,
|
|
68491
|
+
const diagnosticReceiptPath = (0, import_node_path17.join)(rootDirectory, ".debugbundle/local/evidence-receipts.json");
|
|
68378
68492
|
const ledger = await pathExists4(diagnosticReceiptPath, stat) ? parseDiagnosticReceipts(JSON.parse(await readFile(diagnosticReceiptPath))) : { diagnostic_receipts: {}, diagnostic_payload_hashes: {} };
|
|
68379
68493
|
const receipts = ledger.diagnostic_receipts;
|
|
68380
68494
|
for (const [id, at] of Object.entries(previousState?.diagnostic_receipts ?? {})) {
|
|
@@ -68639,7 +68753,7 @@ function buildEventFileName(events, filePath) {
|
|
|
68639
68753
|
return Number.isFinite(candidate) && candidate > latest ? candidate : latest;
|
|
68640
68754
|
}, 0);
|
|
68641
68755
|
const digest4 = (0, import_node_crypto8.createHash)("sha256").update([filePath, ...events.map((event) => event.event_id)].join("\0")).digest("hex").slice(0, 8);
|
|
68642
|
-
return `${lastOccurredAt}-${digest4}-${slugify3(events[0]?.service.name ?? (0,
|
|
68756
|
+
return `${lastOccurredAt}-${digest4}-${slugify3(events[0]?.service.name ?? (0, import_node_path18.basename)(filePath))}.events.json`;
|
|
68643
68757
|
}
|
|
68644
68758
|
function formatHumanOutput(summary) {
|
|
68645
68759
|
return [
|
|
@@ -68649,7 +68763,7 @@ function formatHumanOutput(summary) {
|
|
|
68649
68763
|
].join("\n");
|
|
68650
68764
|
}
|
|
68651
68765
|
async function readProfile(rootDirectory, readFile) {
|
|
68652
|
-
const parsedProfile = ProfileSchema2.safeParse(JSON.parse(await readFile((0,
|
|
68766
|
+
const parsedProfile = ProfileSchema2.safeParse(JSON.parse(await readFile((0, import_node_path18.join)(rootDirectory, PROFILE_FILE_PATH))));
|
|
68653
68767
|
if (!parsedProfile.success) {
|
|
68654
68768
|
throw new Error(`Invalid ${PROFILE_FILE_PATH}`);
|
|
68655
68769
|
}
|
|
@@ -68664,11 +68778,11 @@ async function ingestCommand(input3, dependencies = {}) {
|
|
|
68664
68778
|
};
|
|
68665
68779
|
}
|
|
68666
68780
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
68667
|
-
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0,
|
|
68781
|
+
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0, import_promises16.mkdir)(path, options));
|
|
68668
68782
|
const processLocalEvents = dependencies.processCommand ?? processCommand;
|
|
68669
|
-
const readFile = dependencies.readFile ?? (async (path) => (0,
|
|
68670
|
-
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0,
|
|
68671
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
68783
|
+
const readFile = dependencies.readFile ?? (async (path) => (0, import_promises16.readFile)(path, "utf8"));
|
|
68784
|
+
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0, import_promises16.rename)(sourcePath, destinationPath));
|
|
68785
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises16.writeFile)(path, content, "utf8"));
|
|
68672
68786
|
try {
|
|
68673
68787
|
const rootDirectory = cwd();
|
|
68674
68788
|
const profile = await readProfile(rootDirectory, readFile);
|
|
@@ -68684,9 +68798,9 @@ async function ingestCommand(input3, dependencies = {}) {
|
|
|
68684
68798
|
output: "No supported events were found in the input file."
|
|
68685
68799
|
};
|
|
68686
68800
|
}
|
|
68687
|
-
const eventDirectory = (0,
|
|
68801
|
+
const eventDirectory = (0, import_node_path18.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH4);
|
|
68688
68802
|
const eventFile = buildEventFileName(events, input3.filePath);
|
|
68689
|
-
const destinationPath = (0,
|
|
68803
|
+
const destinationPath = (0, import_node_path18.join)(eventDirectory, eventFile);
|
|
68690
68804
|
const temporaryPath = `${destinationPath}.tmp`;
|
|
68691
68805
|
await mkdir5(eventDirectory, { recursive: true });
|
|
68692
68806
|
await writeFile(temporaryPath, `${JSON.stringify(events, null, 2)}
|
|
@@ -68725,8 +68839,8 @@ async function ingestCommand(input3, dependencies = {}) {
|
|
|
68725
68839
|
}
|
|
68726
68840
|
|
|
68727
68841
|
// src/watch-command.ts
|
|
68728
|
-
var
|
|
68729
|
-
var
|
|
68842
|
+
var import_promises17 = require("node:fs/promises");
|
|
68843
|
+
var import_node_path19 = require("node:path");
|
|
68730
68844
|
function normalizeBaseUrl5(baseUrl) {
|
|
68731
68845
|
return baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
68732
68846
|
}
|
|
@@ -68771,25 +68885,25 @@ async function watchCommand(input3, dependencies = {}) {
|
|
|
68771
68885
|
};
|
|
68772
68886
|
}
|
|
68773
68887
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
68774
|
-
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0,
|
|
68888
|
+
const mkdir5 = dependencies.mkdir ?? (async (path, options) => (0, import_promises17.mkdir)(path, options));
|
|
68775
68889
|
const pollIntervalMs = dependencies.pollIntervalMs ?? 1e3;
|
|
68776
68890
|
const processLocalEvents = dependencies.processCommand ?? processCommand;
|
|
68777
|
-
const readFile = dependencies.readFile ?? (async (path) => (0,
|
|
68891
|
+
const readFile = dependencies.readFile ?? (async (path) => (0, import_promises17.readFile)(path));
|
|
68778
68892
|
const readEnv = dependencies.readEnv ?? ((name) => process.env[name]);
|
|
68779
|
-
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0,
|
|
68893
|
+
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0, import_promises17.rename)(sourcePath, destinationPath));
|
|
68780
68894
|
const fetchDependencies = dependencies.fetchImpl === void 0 ? void 0 : { fetchImpl: dependencies.fetchImpl };
|
|
68781
68895
|
const sendEvents = dependencies.sendEvents ?? ((requestInput) => sendEventsToApi(requestInput, fetchDependencies));
|
|
68782
68896
|
const signal = dependencies.signal;
|
|
68783
68897
|
const sleep = dependencies.sleep ?? (async (milliseconds) => new Promise((resolve5) => setTimeout(resolve5, milliseconds)));
|
|
68784
|
-
const stat = dependencies.stat ??
|
|
68785
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
68898
|
+
const stat = dependencies.stat ?? import_promises17.stat;
|
|
68899
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises17.writeFile)(path, content, "utf8"));
|
|
68786
68900
|
try {
|
|
68787
68901
|
const rootDirectory = cwd();
|
|
68788
68902
|
const profile = await readProfile(
|
|
68789
68903
|
rootDirectory,
|
|
68790
68904
|
async (path) => (await readFile(path)).toString("utf8")
|
|
68791
68905
|
);
|
|
68792
|
-
const eventDirectory = (0,
|
|
68906
|
+
const eventDirectory = (0, import_node_path19.join)(rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH4);
|
|
68793
68907
|
const useCloudDelivery = input3.cloud === true;
|
|
68794
68908
|
const connectionConfig = useCloudDelivery ? await readConnectionConfig(
|
|
68795
68909
|
rootDirectory,
|
|
@@ -68870,7 +68984,7 @@ async function watchCommand(input3, dependencies = {}) {
|
|
|
68870
68984
|
events,
|
|
68871
68985
|
`${input3.logPath}:${batchesWritten + 1}`
|
|
68872
68986
|
);
|
|
68873
|
-
const destinationPath = (0,
|
|
68987
|
+
const destinationPath = (0, import_node_path19.join)(eventDirectory, eventFile);
|
|
68874
68988
|
const temporaryPath = `${destinationPath}.tmp`;
|
|
68875
68989
|
await writeFile(temporaryPath, `${JSON.stringify(events, null, 2)}
|
|
68876
68990
|
`);
|
|
@@ -68921,11 +69035,11 @@ async function watchCommand(input3, dependencies = {}) {
|
|
|
68921
69035
|
}
|
|
68922
69036
|
|
|
68923
69037
|
// src/setup-command.ts
|
|
68924
|
-
var
|
|
68925
|
-
var
|
|
69038
|
+
var import_promises19 = require("node:fs/promises");
|
|
69039
|
+
var import_node_path22 = require("node:path");
|
|
68926
69040
|
|
|
68927
69041
|
// src/setup-service-discovery.ts
|
|
68928
|
-
var
|
|
69042
|
+
var import_node_path20 = require("node:path");
|
|
68929
69043
|
var IGNORED_ROOT_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
68930
69044
|
"apps",
|
|
68931
69045
|
"contracts",
|
|
@@ -69021,36 +69135,36 @@ async function inferRuntime(rootDirectory, servicePath, packageJson, stat, prima
|
|
|
69021
69135
|
return "Node.js";
|
|
69022
69136
|
}
|
|
69023
69137
|
for (const fileName of ["tsconfig.json", "tsconfig.base.json"]) {
|
|
69024
|
-
if (await pathExists5((0,
|
|
69138
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, fileName), stat)) {
|
|
69025
69139
|
return "Node.js";
|
|
69026
69140
|
}
|
|
69027
69141
|
}
|
|
69028
|
-
if (await pathExists5((0,
|
|
69142
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "requirements.txt"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "pyproject.toml"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "manage.py"), stat)) {
|
|
69029
69143
|
return "Python";
|
|
69030
69144
|
}
|
|
69031
|
-
if (await pathExists5((0,
|
|
69145
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "composer.json"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "artisan"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "wp-config.php"), stat)) {
|
|
69032
69146
|
return "PHP";
|
|
69033
69147
|
}
|
|
69034
|
-
if (await pathExists5((0,
|
|
69148
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "go.mod"), stat)) {
|
|
69035
69149
|
return "Go";
|
|
69036
69150
|
}
|
|
69037
|
-
if (await pathExists5((0,
|
|
69151
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile.lock"), stat)) {
|
|
69038
69152
|
return "Ruby";
|
|
69039
69153
|
}
|
|
69040
|
-
if (await pathExists5((0,
|
|
69154
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "pom.xml"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "build.gradle"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "build.gradle.kts"), stat)) {
|
|
69041
69155
|
return "Java";
|
|
69042
69156
|
}
|
|
69043
|
-
if (await pathExists5((0,
|
|
69157
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "Cargo.toml"), stat)) {
|
|
69044
69158
|
return "Rust";
|
|
69045
69159
|
}
|
|
69046
69160
|
return allowFallback ? inferRuntimeFromLanguages(primaryLanguages) : "unknown";
|
|
69047
69161
|
}
|
|
69048
69162
|
async function inferPythonFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69049
|
-
if (await pathExists5((0,
|
|
69163
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "manage.py"), stat)) {
|
|
69050
69164
|
return "Django";
|
|
69051
69165
|
}
|
|
69052
69166
|
for (const fileName of ["requirements.txt", "pyproject.toml"]) {
|
|
69053
|
-
const filePath = (0,
|
|
69167
|
+
const filePath = (0, import_node_path20.join)(rootDirectory, servicePath, fileName);
|
|
69054
69168
|
try {
|
|
69055
69169
|
const contents = await readFile(filePath);
|
|
69056
69170
|
if (/fastapi/iu.test(contents)) {
|
|
@@ -69068,39 +69182,39 @@ async function inferPythonFramework(rootDirectory, servicePath, readFile, stat)
|
|
|
69068
69182
|
return "unknown";
|
|
69069
69183
|
}
|
|
69070
69184
|
async function inferPhpFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69071
|
-
if (await pathExists5((0,
|
|
69185
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "artisan"), stat)) {
|
|
69072
69186
|
return "Laravel";
|
|
69073
69187
|
}
|
|
69074
|
-
if (await pathExists5((0,
|
|
69188
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "wp-config.php"), stat)) {
|
|
69075
69189
|
return "WordPress";
|
|
69076
69190
|
}
|
|
69077
|
-
if (await fileContains((0,
|
|
69191
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "composer.json"), /laravel\/framework/iu, readFile)) {
|
|
69078
69192
|
return "Laravel";
|
|
69079
69193
|
}
|
|
69080
|
-
if (await fileContains((0,
|
|
69194
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "composer.json"), /symfony\/(framework-bundle|http-kernel)/iu, readFile)) {
|
|
69081
69195
|
return "Symfony";
|
|
69082
69196
|
}
|
|
69083
69197
|
return "unknown";
|
|
69084
69198
|
}
|
|
69085
69199
|
async function inferRubyFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69086
|
-
if (await pathExists5((0,
|
|
69200
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "config", "application.rb"), stat)) {
|
|
69087
69201
|
return "Rails";
|
|
69088
69202
|
}
|
|
69089
|
-
if (await fileContains((0,
|
|
69203
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile"), /gem\s+["']rails["']/iu, readFile)) {
|
|
69090
69204
|
return "Rails";
|
|
69091
69205
|
}
|
|
69092
|
-
if (await pathExists5((0,
|
|
69206
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "config.ru"), stat) || await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, "Gemfile"), /gem\s+["']rack["']/iu, readFile)) {
|
|
69093
69207
|
return "Rack";
|
|
69094
69208
|
}
|
|
69095
69209
|
return "unknown";
|
|
69096
69210
|
}
|
|
69097
69211
|
async function inferJavaFramework(rootDirectory, servicePath, readFile, stat) {
|
|
69098
69212
|
for (const fileName of ["pom.xml", "build.gradle", "build.gradle.kts"]) {
|
|
69099
|
-
if (await fileContains((0,
|
|
69213
|
+
if (await fileContains((0, import_node_path20.join)(rootDirectory, servicePath, fileName), /spring-boot/iu, readFile)) {
|
|
69100
69214
|
return "Spring Boot";
|
|
69101
69215
|
}
|
|
69102
69216
|
}
|
|
69103
|
-
if (await pathExists5((0,
|
|
69217
|
+
if (await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "src", "main", "webapp"), stat) || await pathExists5((0, import_node_path20.join)(rootDirectory, servicePath, "src", "main", "webapp", "WEB-INF", "web.xml"), stat)) {
|
|
69104
69218
|
return "Servlet";
|
|
69105
69219
|
}
|
|
69106
69220
|
return "unknown";
|
|
@@ -69148,13 +69262,13 @@ function inferServiceKind(serviceName, servicePath, framework, packageJson) {
|
|
|
69148
69262
|
return "backend";
|
|
69149
69263
|
}
|
|
69150
69264
|
async function buildDetectedService(rootDirectory, servicePath, readFile, stat, fallbackPackageJson, primaryLanguages, allowFallback) {
|
|
69151
|
-
const packageJson = await readJsonFile2((0,
|
|
69265
|
+
const packageJson = await readJsonFile2((0, import_node_path20.join)(rootDirectory, servicePath, "package.json"), readFile);
|
|
69152
69266
|
const runtime = await inferRuntime(rootDirectory, servicePath, packageJson, stat, primaryLanguages, allowFallback);
|
|
69153
69267
|
if (runtime === "unknown" && !allowFallback) {
|
|
69154
69268
|
return null;
|
|
69155
69269
|
}
|
|
69156
69270
|
const framework = await inferServiceFramework(rootDirectory, servicePath, runtime, packageJson, readFile, stat, fallbackPackageJson, allowFallback);
|
|
69157
|
-
const name = packageJson?.name ?? (0,
|
|
69271
|
+
const name = packageJson?.name ?? (0, import_node_path20.basename)(servicePath);
|
|
69158
69272
|
return {
|
|
69159
69273
|
name,
|
|
69160
69274
|
kind: inferServiceKind(name, servicePath, framework, packageJson),
|
|
@@ -69172,12 +69286,12 @@ async function detectRootServicePaths(rootDirectory, readdir, stat) {
|
|
|
69172
69286
|
if (entry.startsWith(".") || IGNORED_ROOT_DIRECTORIES.has(entry)) {
|
|
69173
69287
|
continue;
|
|
69174
69288
|
}
|
|
69175
|
-
const entryPath = (0,
|
|
69289
|
+
const entryPath = (0, import_node_path20.join)(rootDirectory, entry);
|
|
69176
69290
|
const entryStats = await stat(entryPath);
|
|
69177
69291
|
if (!entryStats.isDirectory()) {
|
|
69178
69292
|
continue;
|
|
69179
69293
|
}
|
|
69180
|
-
if (await pathExists5((0,
|
|
69294
|
+
if (await pathExists5((0, import_node_path20.join)(entryPath, "package.json"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "requirements.txt"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "pyproject.toml"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "manage.py"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "composer.json"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "artisan"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "wp-config.php"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "go.mod"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "Gemfile"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "Gemfile.lock"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "pom.xml"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "build.gradle"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "build.gradle.kts"), stat) || await pathExists5((0, import_node_path20.join)(entryPath, "Cargo.toml"), stat)) {
|
|
69181
69295
|
servicePaths.push(entry);
|
|
69182
69296
|
}
|
|
69183
69297
|
}
|
|
@@ -69185,11 +69299,11 @@ async function detectRootServicePaths(rootDirectory, readdir, stat) {
|
|
|
69185
69299
|
}
|
|
69186
69300
|
async function detectServices(rootDirectory, readdir, readFile, stat, packageJson, primaryLanguages) {
|
|
69187
69301
|
const services = [];
|
|
69188
|
-
const appsDirectory = (0,
|
|
69302
|
+
const appsDirectory = (0, import_node_path20.join)(rootDirectory, "apps");
|
|
69189
69303
|
if (await pathExists5(appsDirectory, stat)) {
|
|
69190
69304
|
const entries2 = (await readdir(appsDirectory)).sort();
|
|
69191
69305
|
for (const entry of entries2) {
|
|
69192
|
-
const entryPath = (0,
|
|
69306
|
+
const entryPath = (0, import_node_path20.join)(appsDirectory, entry);
|
|
69193
69307
|
const entryStats = await stat(entryPath);
|
|
69194
69308
|
if (!entryStats.isDirectory()) {
|
|
69195
69309
|
continue;
|
|
@@ -69226,7 +69340,7 @@ async function detectServices(rootDirectory, readdir, readFile, stat, packageJso
|
|
|
69226
69340
|
}
|
|
69227
69341
|
|
|
69228
69342
|
// src/setup-relay-guidance.ts
|
|
69229
|
-
var
|
|
69343
|
+
var import_node_path21 = require("node:path");
|
|
69230
69344
|
var RELAY_ROUTE_PATH = "/debugbundle/browser";
|
|
69231
69345
|
var WORDPRESS_RELAY_ROUTE_PATH = "/wp-json/debugbundle/v1/browser";
|
|
69232
69346
|
async function pathExists6(filePath, stat) {
|
|
@@ -69252,7 +69366,7 @@ async function readJsonFile3(filePath, readFile) {
|
|
|
69252
69366
|
}
|
|
69253
69367
|
async function readPackageJsonForService(rootDirectory, servicePath, readFile) {
|
|
69254
69368
|
const normalizedServicePath = servicePath === "." ? "" : servicePath ?? "";
|
|
69255
|
-
return readJsonFile3((0,
|
|
69369
|
+
return readJsonFile3((0, import_node_path21.join)(rootDirectory, normalizedServicePath, "package.json"), readFile);
|
|
69256
69370
|
}
|
|
69257
69371
|
function collectDependencyNames2(packageJson) {
|
|
69258
69372
|
return /* @__PURE__ */ new Set([
|
|
@@ -69333,9 +69447,9 @@ function buildInstructionOnlyGuidance(backendService, frontendServices, runtimeI
|
|
|
69333
69447
|
}
|
|
69334
69448
|
async function scaffoldFastifyRelayRoute(rootDirectory, servicePath, dependencies, frontendServices, backendService) {
|
|
69335
69449
|
const candidatePath = await findFirstExistingPath([
|
|
69336
|
-
(0,
|
|
69337
|
-
(0,
|
|
69338
|
-
(0,
|
|
69450
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "server.ts"),
|
|
69451
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "main.ts"),
|
|
69452
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "server.ts")
|
|
69339
69453
|
], dependencies.stat);
|
|
69340
69454
|
if (candidatePath === null) {
|
|
69341
69455
|
return buildInstructionOnlyGuidance(
|
|
@@ -69375,9 +69489,9 @@ async function scaffoldFastifyRelayRoute(rootDirectory, servicePath, dependencie
|
|
|
69375
69489
|
}
|
|
69376
69490
|
async function scaffoldExpressRelayRoute(rootDirectory, servicePath, dependencies, frontendServices, backendService) {
|
|
69377
69491
|
const candidatePath = await findFirstExistingPath([
|
|
69378
|
-
(0,
|
|
69379
|
-
(0,
|
|
69380
|
-
(0,
|
|
69492
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "server.ts"),
|
|
69493
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "app.ts"),
|
|
69494
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "server.ts")
|
|
69381
69495
|
], dependencies.stat);
|
|
69382
69496
|
if (candidatePath === null) {
|
|
69383
69497
|
return buildInstructionOnlyGuidance(
|
|
@@ -69417,8 +69531,8 @@ async function scaffoldExpressRelayRoute(rootDirectory, servicePath, dependencie
|
|
|
69417
69531
|
}
|
|
69418
69532
|
async function scaffoldNextJsRelayRoute(rootDirectory, servicePath, dependencies, frontendServices, backendService) {
|
|
69419
69533
|
const candidateAppRoot = await findFirstExistingPath([
|
|
69420
|
-
(0,
|
|
69421
|
-
(0,
|
|
69534
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "app"),
|
|
69535
|
+
(0, import_node_path21.join)(rootDirectory, servicePath, "src", "app")
|
|
69422
69536
|
], dependencies.stat);
|
|
69423
69537
|
if (candidateAppRoot === null) {
|
|
69424
69538
|
return buildInstructionOnlyGuidance(
|
|
@@ -69427,8 +69541,8 @@ async function scaffoldNextJsRelayRoute(rootDirectory, servicePath, dependencies
|
|
|
69427
69541
|
`Add app/debugbundle/browser/route.ts in ${servicePath} and export debugBundleRelay as POST from @debugbundle/sdk-node/relay/nextjs.`
|
|
69428
69542
|
);
|
|
69429
69543
|
}
|
|
69430
|
-
const routeDirectory = (0,
|
|
69431
|
-
const routePath = (0,
|
|
69544
|
+
const routeDirectory = (0, import_node_path21.join)(candidateAppRoot, "debugbundle", "browser");
|
|
69545
|
+
const routePath = (0, import_node_path21.join)(routeDirectory, "route.ts");
|
|
69432
69546
|
await dependencies.mkdir(routeDirectory, { recursive: true });
|
|
69433
69547
|
await dependencies.writeFile(routePath, 'export { debugBundleRelay as POST } from "@debugbundle/sdk-node/relay/nextjs";\n');
|
|
69434
69548
|
return {
|
|
@@ -69597,10 +69711,10 @@ async function resolveRelaySetup(rootDirectory, services, selectedTargetNames, r
|
|
|
69597
69711
|
}
|
|
69598
69712
|
|
|
69599
69713
|
// src/setup-target-selection.ts
|
|
69600
|
-
var
|
|
69714
|
+
var import_promises18 = require("node:readline/promises");
|
|
69601
69715
|
var import_node_process3 = require("node:process");
|
|
69602
69716
|
function defaultPromptUser(prompt) {
|
|
69603
|
-
const terminal = (0,
|
|
69717
|
+
const terminal = (0, import_promises18.createInterface)({ input: import_node_process3.stdin, output: import_node_process3.stdout });
|
|
69604
69718
|
return terminal.question(prompt).finally(() => {
|
|
69605
69719
|
terminal.close();
|
|
69606
69720
|
});
|
|
@@ -69715,41 +69829,41 @@ function detectPackageManagers(rootDirectory, packageJson, existingPaths) {
|
|
|
69715
69829
|
if (declaredPackageManager === "yarn") {
|
|
69716
69830
|
packageManagers.add("yarn");
|
|
69717
69831
|
}
|
|
69718
|
-
if (existingPaths.has((0,
|
|
69832
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "pnpm-lock.yaml")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "pnpm-workspace.yaml"))) {
|
|
69719
69833
|
packageManagers.add("pnpm");
|
|
69720
69834
|
}
|
|
69721
|
-
if (existingPaths.has((0,
|
|
69835
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "package-lock.json"))) {
|
|
69722
69836
|
packageManagers.add("npm");
|
|
69723
69837
|
}
|
|
69724
|
-
if (existingPaths.has((0,
|
|
69838
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "yarn.lock"))) {
|
|
69725
69839
|
packageManagers.add("yarn");
|
|
69726
69840
|
}
|
|
69727
|
-
if (existingPaths.has((0,
|
|
69841
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "poetry.lock")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "pyproject.toml"))) {
|
|
69728
69842
|
packageManagers.add("poetry");
|
|
69729
69843
|
}
|
|
69730
|
-
if (existingPaths.has((0,
|
|
69844
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "composer.json"))) {
|
|
69731
69845
|
packageManagers.add("composer");
|
|
69732
69846
|
}
|
|
69733
69847
|
return [...packageManagers].sort();
|
|
69734
69848
|
}
|
|
69735
69849
|
function detectPrimaryLanguages(rootDirectory, existingPaths) {
|
|
69736
69850
|
const languages = /* @__PURE__ */ new Set();
|
|
69737
|
-
if (existingPaths.has((0,
|
|
69851
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "tsconfig.json")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "tsconfig.base.json"))) {
|
|
69738
69852
|
languages.add("TypeScript");
|
|
69739
|
-
} else if (existingPaths.has((0,
|
|
69853
|
+
} else if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "package.json"))) {
|
|
69740
69854
|
languages.add("JavaScript");
|
|
69741
69855
|
}
|
|
69742
|
-
if (existingPaths.has((0,
|
|
69856
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "pyproject.toml"))) {
|
|
69743
69857
|
languages.add("Python");
|
|
69744
69858
|
}
|
|
69745
|
-
if (existingPaths.has((0,
|
|
69859
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "composer.json"))) {
|
|
69746
69860
|
languages.add("PHP");
|
|
69747
69861
|
}
|
|
69748
69862
|
return [...languages].sort();
|
|
69749
69863
|
}
|
|
69750
69864
|
function detectDeploymentTargets(rootDirectory, existingPaths) {
|
|
69751
69865
|
const targets = /* @__PURE__ */ new Set();
|
|
69752
|
-
if (existingPaths.has((0,
|
|
69866
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "docker-compose.yml")) || existingPaths.has((0, import_node_path22.join)(rootDirectory, "deploy", "selfhost", "docker-compose.yml"))) {
|
|
69753
69867
|
targets.add("docker-compose");
|
|
69754
69868
|
}
|
|
69755
69869
|
return [...targets].sort();
|
|
@@ -69759,7 +69873,7 @@ function detectDeveloperWorkflow(packageJson, workflowName, existingPaths, rootD
|
|
|
69759
69873
|
if (typeof packageScript === "string" && packageScript.length > 0) {
|
|
69760
69874
|
return packageScript;
|
|
69761
69875
|
}
|
|
69762
|
-
if (existingPaths.has((0,
|
|
69876
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "Makefile"))) {
|
|
69763
69877
|
return `make ${workflowName}`;
|
|
69764
69878
|
}
|
|
69765
69879
|
return "manual";
|
|
@@ -69780,7 +69894,7 @@ function detectInstallWorkflow(packageManagers, existingPaths, rootDirectory) {
|
|
|
69780
69894
|
if (packageManagers.includes("composer")) {
|
|
69781
69895
|
return "composer install";
|
|
69782
69896
|
}
|
|
69783
|
-
if (existingPaths.has((0,
|
|
69897
|
+
if (existingPaths.has((0, import_node_path22.join)(rootDirectory, "Makefile"))) {
|
|
69784
69898
|
return "make install";
|
|
69785
69899
|
}
|
|
69786
69900
|
return "manual";
|
|
@@ -69813,7 +69927,7 @@ async function detectRootPaths(rootDirectory, readdir, stat) {
|
|
|
69813
69927
|
if (entry.startsWith(".") || entry === "node_modules") {
|
|
69814
69928
|
continue;
|
|
69815
69929
|
}
|
|
69816
|
-
const entryStats = await stat((0,
|
|
69930
|
+
const entryStats = await stat((0, import_node_path22.join)(rootDirectory, entry));
|
|
69817
69931
|
if (entryStats.isDirectory()) {
|
|
69818
69932
|
rootPaths.push(entry);
|
|
69819
69933
|
}
|
|
@@ -69823,8 +69937,8 @@ async function detectRootPaths(rootDirectory, readdir, stat) {
|
|
|
69823
69937
|
async function detectInfrastructure(rootDirectory, readFile) {
|
|
69824
69938
|
const composeContents = [];
|
|
69825
69939
|
for (const candidatePath of [
|
|
69826
|
-
(0,
|
|
69827
|
-
(0,
|
|
69940
|
+
(0, import_node_path22.join)(rootDirectory, "docker-compose.yml"),
|
|
69941
|
+
(0, import_node_path22.join)(rootDirectory, "deploy", "selfhost", "docker-compose.yml")
|
|
69828
69942
|
]) {
|
|
69829
69943
|
try {
|
|
69830
69944
|
composeContents.push(await readFile(candidatePath));
|
|
@@ -69856,21 +69970,21 @@ async function detectInfrastructure(rootDirectory, readFile) {
|
|
|
69856
69970
|
};
|
|
69857
69971
|
}
|
|
69858
69972
|
async function buildProfile(rootDirectory, dependencies) {
|
|
69859
|
-
const packageJson = await readJsonFile4((0,
|
|
69973
|
+
const packageJson = await readJsonFile4((0, import_node_path22.join)(rootDirectory, "package.json"), dependencies.readFile);
|
|
69860
69974
|
const existingPaths = /* @__PURE__ */ new Set([
|
|
69861
|
-
(0,
|
|
69862
|
-
(0,
|
|
69863
|
-
(0,
|
|
69864
|
-
(0,
|
|
69865
|
-
(0,
|
|
69866
|
-
(0,
|
|
69867
|
-
(0,
|
|
69868
|
-
(0,
|
|
69869
|
-
(0,
|
|
69870
|
-
(0,
|
|
69871
|
-
(0,
|
|
69872
|
-
(0,
|
|
69873
|
-
(0,
|
|
69975
|
+
(0, import_node_path22.join)(rootDirectory, "package.json"),
|
|
69976
|
+
(0, import_node_path22.join)(rootDirectory, "pnpm-lock.yaml"),
|
|
69977
|
+
(0, import_node_path22.join)(rootDirectory, "pnpm-workspace.yaml"),
|
|
69978
|
+
(0, import_node_path22.join)(rootDirectory, "package-lock.json"),
|
|
69979
|
+
(0, import_node_path22.join)(rootDirectory, "yarn.lock"),
|
|
69980
|
+
(0, import_node_path22.join)(rootDirectory, "poetry.lock"),
|
|
69981
|
+
(0, import_node_path22.join)(rootDirectory, "pyproject.toml"),
|
|
69982
|
+
(0, import_node_path22.join)(rootDirectory, "composer.json"),
|
|
69983
|
+
(0, import_node_path22.join)(rootDirectory, "docker-compose.yml"),
|
|
69984
|
+
(0, import_node_path22.join)(rootDirectory, "deploy", "selfhost", "docker-compose.yml"),
|
|
69985
|
+
(0, import_node_path22.join)(rootDirectory, "Makefile"),
|
|
69986
|
+
(0, import_node_path22.join)(rootDirectory, "tsconfig.json"),
|
|
69987
|
+
(0, import_node_path22.join)(rootDirectory, "tsconfig.base.json")
|
|
69874
69988
|
]);
|
|
69875
69989
|
const confirmedExistingPaths = /* @__PURE__ */ new Set();
|
|
69876
69990
|
for (const candidatePath of existingPaths) {
|
|
@@ -69920,21 +70034,21 @@ async function buildProfile(rootDirectory, dependencies) {
|
|
|
69920
70034
|
async function setupCommand(input3, dependencies = {}) {
|
|
69921
70035
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
69922
70036
|
const mkdir5 = dependencies.mkdir ?? (async (path, options) => {
|
|
69923
|
-
await (0,
|
|
70037
|
+
await (0, import_promises19.mkdir)(path, options);
|
|
69924
70038
|
});
|
|
69925
|
-
const readFile = dependencies.readFile ?? (async (path) => (0,
|
|
69926
|
-
const readdir = dependencies.readdir ?? (async (path) => (0,
|
|
69927
|
-
const stat = dependencies.stat ?? (async (path) => (0,
|
|
69928
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
70039
|
+
const readFile = dependencies.readFile ?? (async (path) => (0, import_promises19.readFile)(path, "utf8"));
|
|
70040
|
+
const readdir = dependencies.readdir ?? (async (path) => (0, import_promises19.readdir)(path));
|
|
70041
|
+
const stat = dependencies.stat ?? (async (path) => (0, import_promises19.stat)(path));
|
|
70042
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises19.writeFile)(path, content, "utf8"));
|
|
69929
70043
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
69930
70044
|
try {
|
|
69931
70045
|
const rootDirectory = await projectRoot(cwd());
|
|
69932
70046
|
const selectedAgents = await chooseAgents(rootDirectory, input3, dependencies);
|
|
69933
|
-
const packageJson = await readJsonFile4((0,
|
|
70047
|
+
const packageJson = await readJsonFile4((0, import_node_path22.join)(rootDirectory, "package.json"), readFile);
|
|
69934
70048
|
for (const filePath of [...GENERATED_FILE_PATHS, GITIGNORE_FILE_PATH]) await safePath(rootDirectory, filePath);
|
|
69935
70049
|
for (const directoryPath of ENSURED_DIRECTORY_PATHS) {
|
|
69936
70050
|
await safePath(rootDirectory, directoryPath);
|
|
69937
|
-
await mkdir5((0,
|
|
70051
|
+
await mkdir5((0, import_node_path22.join)(rootDirectory, directoryPath), { recursive: true });
|
|
69938
70052
|
}
|
|
69939
70053
|
const profile = await buildProfile(rootDirectory, {
|
|
69940
70054
|
now,
|
|
@@ -69952,11 +70066,11 @@ async function setupCommand(input3, dependencies = {}) {
|
|
|
69952
70066
|
if (!preservedProfile) {
|
|
69953
70067
|
const contents = `${JSON.stringify(profile, null, 2)}
|
|
69954
70068
|
`;
|
|
69955
|
-
if (dependencies.writeFile) await dependencies.writeFile((0,
|
|
70069
|
+
if (dependencies.writeFile) await dependencies.writeFile((0, import_node_path22.join)(rootDirectory, PROFILE_FILE_PATH), contents);
|
|
69956
70070
|
else await writeManaged(rootDirectory, PROFILE_FILE_PATH, contents, void 0);
|
|
69957
70071
|
}
|
|
69958
70072
|
if (!preservedConnection) {
|
|
69959
|
-
if (dependencies.writeFile) await dependencies.writeFile((0,
|
|
70073
|
+
if (dependencies.writeFile) await dependencies.writeFile((0, import_node_path22.join)(rootDirectory, CONNECTION_FILE_PATH), buildConnectionConfig());
|
|
69960
70074
|
else await writeManaged(rootDirectory, CONNECTION_FILE_PATH, buildConnectionConfig(), void 0);
|
|
69961
70075
|
}
|
|
69962
70076
|
const agentReport = await manageAgentSetup({ root: rootDirectory, files: canonicalFiles(), legacyHashes: legacy_skill_hashes_default, instruction: buildManagedAgentsSection(), fix: true, legacyInstructions: true, ...selectedAgents === void 0 ? {} : { selected: selectedAgents } });
|
|
@@ -71395,14 +71509,14 @@ async function listServicesWithAuthCommand(input3, dependencies) {
|
|
|
71395
71509
|
}
|
|
71396
71510
|
|
|
71397
71511
|
// src/project-adoption-commands.ts
|
|
71398
|
-
var
|
|
71512
|
+
var import_node_path24 = require("node:path");
|
|
71399
71513
|
|
|
71400
71514
|
// ../../packages/project-adoption/src/index.ts
|
|
71401
71515
|
var import_node_fs3 = require("node:fs");
|
|
71402
|
-
var
|
|
71516
|
+
var import_promises20 = require("node:fs/promises");
|
|
71403
71517
|
var import_node_crypto9 = require("node:crypto");
|
|
71404
|
-
var
|
|
71405
|
-
var
|
|
71518
|
+
var import_node_path23 = require("node:path");
|
|
71519
|
+
var paths2 = [".debugbundle/local/connection.json", ".debugbundle/profile.json"];
|
|
71406
71520
|
var digest3 = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
71407
71521
|
var changeSchema = external_exports.object({ pointer: external_exports.string(), before: external_exports.string().nullable(), after: external_exports.string().nullable() }).strict();
|
|
71408
71522
|
var planBody = external_exports.object({
|
|
@@ -71414,7 +71528,7 @@ var planBody = external_exports.object({
|
|
|
71414
71528
|
manifest_digest: digest3,
|
|
71415
71529
|
files: external_exports.array(
|
|
71416
71530
|
external_exports.object({
|
|
71417
|
-
path: external_exports.enum(
|
|
71531
|
+
path: external_exports.enum(paths2),
|
|
71418
71532
|
before_sha256: digest3,
|
|
71419
71533
|
after_sha256: digest3,
|
|
71420
71534
|
changes: external_exports.array(changeSchema)
|
|
@@ -71441,20 +71555,20 @@ function manifestFor(input3) {
|
|
|
71441
71555
|
fail("adoption_manifest_stale");
|
|
71442
71556
|
return { operation, manifest };
|
|
71443
71557
|
}
|
|
71444
|
-
async function hierarchy(root,
|
|
71445
|
-
if ((0,
|
|
71558
|
+
async function hierarchy(root, relative8) {
|
|
71559
|
+
if ((0, import_node_path23.resolve)(root) !== root || await (0, import_promises20.realpath)(root) !== root) fail("adoption_unsafe_path");
|
|
71446
71560
|
try {
|
|
71447
|
-
await safePath(root,
|
|
71561
|
+
await safePath(root, relative8);
|
|
71448
71562
|
} catch {
|
|
71449
71563
|
fail("adoption_unsafe_path");
|
|
71450
71564
|
}
|
|
71451
71565
|
}
|
|
71452
71566
|
async function read(root, path) {
|
|
71453
71567
|
await hierarchy(root, path);
|
|
71454
|
-
const full = (0,
|
|
71568
|
+
const full = (0, import_node_path23.join)(root, path), before = await (0, import_promises20.lstat)(full);
|
|
71455
71569
|
if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1)
|
|
71456
71570
|
fail("adoption_unsafe_path");
|
|
71457
|
-
const file2 = await (0,
|
|
71571
|
+
const file2 = await (0, import_promises20.open)(full, import_node_fs3.constants.O_RDONLY | import_node_fs3.constants.O_NOFOLLOW | import_node_fs3.constants.O_NONBLOCK);
|
|
71458
71572
|
try {
|
|
71459
71573
|
const info = await file2.stat();
|
|
71460
71574
|
if (!info.isFile() || info.dev !== before.dev || info.ino !== before.ino || info.size > 1024 * 1024)
|
|
@@ -71494,7 +71608,7 @@ function child(parent, key) {
|
|
|
71494
71608
|
}
|
|
71495
71609
|
function render(file2, manifest, original, operationId) {
|
|
71496
71610
|
const document = structuredClone(file2.data), changes = [];
|
|
71497
|
-
if (file2.path ===
|
|
71611
|
+
if (file2.path === paths2[0]) {
|
|
71498
71612
|
const parsed = ConnectionConfigSchema.safeParse(document);
|
|
71499
71613
|
if (!parsed.success || parsed.data.mode !== "connected" || !manifest.origin_project_ids.includes(parsed.data.cloud_project_id ?? ""))
|
|
71500
71614
|
fail("adoption_workspace_not_in_merge");
|
|
@@ -71549,7 +71663,7 @@ function render(file2, manifest, original, operationId) {
|
|
|
71549
71663
|
}
|
|
71550
71664
|
async function previewProjectAdoption(input3) {
|
|
71551
71665
|
const { operation, manifest } = manifestFor(input3.operation);
|
|
71552
|
-
const files = await Promise.all(
|
|
71666
|
+
const files = await Promise.all(paths2.map((path) => read(input3.workspace_root, path)));
|
|
71553
71667
|
let original = files[0].data["cloud_project_id"];
|
|
71554
71668
|
if (typeof original !== "string" || !manifest.origin_project_ids.includes(original))
|
|
71555
71669
|
fail("adoption_workspace_not_in_merge");
|
|
@@ -71578,9 +71692,9 @@ async function previewProjectAdoption(input3) {
|
|
|
71578
71692
|
return { ...body, plan_digest: hash2(JSON.stringify(body)) };
|
|
71579
71693
|
}
|
|
71580
71694
|
async function replace(root, snapshot, bytes, expectedHash) {
|
|
71581
|
-
const path = (0,
|
|
71695
|
+
const path = (0, import_node_path23.join)(root, snapshot.path), temporary = (0, import_node_path23.join)((0, import_node_path23.dirname)(path), `.debugbundle-adoption-${(0, import_node_crypto9.randomBytes)(16).toString("hex")}.tmp`);
|
|
71582
71696
|
await hierarchy(root, snapshot.path);
|
|
71583
|
-
const handle = await (0,
|
|
71697
|
+
const handle = await (0, import_promises20.open)(
|
|
71584
71698
|
temporary,
|
|
71585
71699
|
import_node_fs3.constants.O_WRONLY | import_node_fs3.constants.O_CREAT | import_node_fs3.constants.O_EXCL | import_node_fs3.constants.O_NOFOLLOW,
|
|
71586
71700
|
384
|
|
@@ -71598,10 +71712,10 @@ async function replace(root, snapshot, bytes, expectedHash) {
|
|
|
71598
71712
|
if (hash2(current.bytes) !== expectedHash || current.dev !== snapshot.dev || current.ino !== snapshot.ino)
|
|
71599
71713
|
fail("adoption_file_changed");
|
|
71600
71714
|
await hierarchy(root, snapshot.path);
|
|
71601
|
-
await (0,
|
|
71715
|
+
await (0, import_promises20.rename)(temporary, path);
|
|
71602
71716
|
return { ...snapshot, bytes, dev: placed.dev, ino: placed.ino };
|
|
71603
71717
|
} finally {
|
|
71604
|
-
await (0,
|
|
71718
|
+
await (0, import_promises20.unlink)(temporary).catch(() => void 0);
|
|
71605
71719
|
}
|
|
71606
71720
|
}
|
|
71607
71721
|
async function applyProjectAdoption(input3, hooks = {}) {
|
|
@@ -71613,9 +71727,9 @@ async function applyProjectAdoption(input3, hooks = {}) {
|
|
|
71613
71727
|
const { operation, manifest } = manifestFor(input3.operation);
|
|
71614
71728
|
if (operation.operation_id !== plan.operation_id || operation.canonical_project_id !== plan.canonical_project_id || hash2(JSON.stringify(manifest)) !== plan.manifest_digest || !manifest.origin_project_ids.includes(plan.original_project_id))
|
|
71615
71729
|
fail("adoption_manifest_stale");
|
|
71616
|
-
await hierarchy(plan.workspace_root,
|
|
71617
|
-
const lockPath = (0,
|
|
71618
|
-
const lock = await (0,
|
|
71730
|
+
await hierarchy(plan.workspace_root, paths2[0]);
|
|
71731
|
+
const lockPath = (0, import_node_path23.join)(plan.workspace_root, ".debugbundle/adoption.lock");
|
|
71732
|
+
const lock = await (0, import_promises20.open)(
|
|
71619
71733
|
lockPath,
|
|
71620
71734
|
import_node_fs3.constants.O_WRONLY | import_node_fs3.constants.O_CREAT | import_node_fs3.constants.O_EXCL | import_node_fs3.constants.O_NOFOLLOW,
|
|
71621
71735
|
384
|
|
@@ -71678,10 +71792,10 @@ async function applyProjectAdoption(input3, hooks = {}) {
|
|
|
71678
71792
|
} finally {
|
|
71679
71793
|
await lock.close();
|
|
71680
71794
|
await hierarchy(plan.workspace_root, ".debugbundle/adoption.lock");
|
|
71681
|
-
const current = await (0,
|
|
71795
|
+
const current = await (0, import_promises20.lstat)(lockPath).catch(() => null);
|
|
71682
71796
|
if (!lockIdentity || !current?.isFile() || current.nlink !== 1 || current.dev !== lockIdentity.dev || current.ino !== lockIdentity.ino)
|
|
71683
71797
|
fail("adoption_lock_changed_review_required");
|
|
71684
|
-
await (0,
|
|
71798
|
+
await (0, import_promises20.unlink)(lockPath);
|
|
71685
71799
|
}
|
|
71686
71800
|
}
|
|
71687
71801
|
|
|
@@ -71771,7 +71885,7 @@ function createProjectMergesApi(client) {
|
|
|
71771
71885
|
}
|
|
71772
71886
|
|
|
71773
71887
|
// src/project-merge-commands.ts
|
|
71774
|
-
var
|
|
71888
|
+
var import_promises21 = require("node:fs/promises");
|
|
71775
71889
|
async function projectMergeWithAuthCommand(input3, dependencies = {}) {
|
|
71776
71890
|
try {
|
|
71777
71891
|
const auth2 = await (dependencies.readAuthState ?? readCliAuthState)(
|
|
@@ -71797,7 +71911,7 @@ async function projectMergeWithAuthCommand(input3, dependencies = {}) {
|
|
|
71797
71911
|
async function readProjectMergeJson(path, maximumBytes = 4 * 1024 * 1024) {
|
|
71798
71912
|
let file2;
|
|
71799
71913
|
try {
|
|
71800
|
-
file2 = await (0,
|
|
71914
|
+
file2 = await (0, import_promises21.open)(path, "r");
|
|
71801
71915
|
const info = await file2.stat();
|
|
71802
71916
|
if (!info.isFile() || info.size > maximumBytes) throw new Error("invalid");
|
|
71803
71917
|
const buffer = Buffer.alloc(maximumBytes + 1);
|
|
@@ -71915,7 +72029,7 @@ async function handleProjectAdoptionCommand(argv, run = projectAdoptionWithAuthC
|
|
|
71915
72029
|
if (action === "preview") {
|
|
71916
72030
|
expectNoUnknownOptions(argv, [...common, "operation-id", "workspace-root"]);
|
|
71917
72031
|
const operation_id = option("operation-id"), workspace_root = option("workspace-root");
|
|
71918
|
-
if (!external_exports.string().guid().safeParse(operation_id).success || !(0,
|
|
72032
|
+
if (!external_exports.string().guid().safeParse(operation_id).success || !(0, import_node_path24.isAbsolute)(workspace_root) || (0, import_node_path24.resolve)(workspace_root) !== workspace_root)
|
|
71919
72033
|
throw new CliInputError(
|
|
71920
72034
|
"Provide a valid operation ID and one canonical absolute workspace root."
|
|
71921
72035
|
);
|
|
@@ -72238,8 +72352,8 @@ function formatCloudResult(input3, exitCode, checks, errors, incidentId, verific
|
|
|
72238
72352
|
|
|
72239
72353
|
// src/verify-command.ts
|
|
72240
72354
|
var import_node_crypto10 = require("node:crypto");
|
|
72241
|
-
var
|
|
72242
|
-
var
|
|
72355
|
+
var import_promises22 = require("node:fs/promises");
|
|
72356
|
+
var import_node_path25 = require("node:path");
|
|
72243
72357
|
function localFailureStepName(checks) {
|
|
72244
72358
|
let hasLocalProcessing = false;
|
|
72245
72359
|
let hasIncidentRetrieval = false;
|
|
@@ -72442,10 +72556,10 @@ function buildVerificationEvent(now, projectId) {
|
|
|
72442
72556
|
};
|
|
72443
72557
|
}
|
|
72444
72558
|
async function writeVerificationEventBatch(input3, dependencies) {
|
|
72445
|
-
const eventDirectory = (0,
|
|
72559
|
+
const eventDirectory = (0, import_node_path25.join)(input3.rootDirectory, LOCAL_EVENTS_DIRECTORY_PATH4);
|
|
72446
72560
|
await dependencies.mkdir(eventDirectory, { recursive: true });
|
|
72447
72561
|
const fileName = buildEventFileName([input3.event], `debugbundle-verify-local-${input3.runId}`);
|
|
72448
|
-
const destinationPath = (0,
|
|
72562
|
+
const destinationPath = (0, import_node_path25.join)(eventDirectory, fileName);
|
|
72449
72563
|
const temporaryPath = `${destinationPath}.tmp`;
|
|
72450
72564
|
await dependencies.writeFile(temporaryPath, `${JSON.stringify([input3.event], null, 2)}
|
|
72451
72565
|
`);
|
|
@@ -72455,14 +72569,14 @@ async function writeVerificationEventBatch(input3, dependencies) {
|
|
|
72455
72569
|
async function verifyLocalCommand(input3, dependencies = {}) {
|
|
72456
72570
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
72457
72571
|
const mkdir5 = dependencies.mkdir ?? (async (path, options) => {
|
|
72458
|
-
await (0,
|
|
72572
|
+
await (0, import_promises22.mkdir)(path, options);
|
|
72459
72573
|
});
|
|
72460
72574
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
72461
72575
|
const processLocal = dependencies.processCommand ?? processCommand;
|
|
72462
72576
|
const readVerifiedLocalState = dependencies.readLocalState ?? readLocalState;
|
|
72463
72577
|
const readVerifiedLocalBundle = dependencies.getLocalBundle ?? getLocalBundle;
|
|
72464
|
-
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0,
|
|
72465
|
-
const writeFile = dependencies.writeFile ?? (async (path, content) => (0,
|
|
72578
|
+
const rename4 = dependencies.rename ?? (async (sourcePath, destinationPath) => (0, import_promises22.rename)(sourcePath, destinationPath));
|
|
72579
|
+
const writeFile = dependencies.writeFile ?? (async (path, content) => (0, import_promises22.writeFile)(path, content, "utf8"));
|
|
72466
72580
|
const checks = [];
|
|
72467
72581
|
function finalize2(exitCode, errors, incidentId) {
|
|
72468
72582
|
return formatResult(input3, exitCode, checks, errors, incidentId);
|
|
@@ -72483,7 +72597,7 @@ async function verifyLocalCommand(input3, dependencies = {}) {
|
|
|
72483
72597
|
});
|
|
72484
72598
|
try {
|
|
72485
72599
|
const rootDirectory = cwd();
|
|
72486
|
-
const profile = await readProfile(rootDirectory, async (path) => (0,
|
|
72600
|
+
const profile = await readProfile(rootDirectory, async (path) => (0, import_promises22.readFile)(path, "utf8"));
|
|
72487
72601
|
const projectId = buildProjectId(profile);
|
|
72488
72602
|
const verificationNow = now();
|
|
72489
72603
|
const runId = verificationNow.toISOString().replace(/[-:.TZ]/g, "").slice(0, 14);
|
|
@@ -73238,8 +73352,8 @@ function formatUsage() {
|
|
|
73238
73352
|
}
|
|
73239
73353
|
|
|
73240
73354
|
// src/validate-command.ts
|
|
73241
|
-
var
|
|
73242
|
-
var
|
|
73355
|
+
var import_promises23 = require("node:fs/promises");
|
|
73356
|
+
var import_node_path26 = require("node:path");
|
|
73243
73357
|
var SUGGESTED_ACTIONS2 = [
|
|
73244
73358
|
"Run debugbundle setup if .debugbundle/profile.json is missing.",
|
|
73245
73359
|
"Run debugbundle profile validate for field-level profile errors.",
|
|
@@ -73345,22 +73459,22 @@ function buildValidateJsonOutput(checks, profileErrors, autoFixAvailable) {
|
|
|
73345
73459
|
});
|
|
73346
73460
|
}
|
|
73347
73461
|
async function fixMissingFile(rootDirectory, filePath, buildContent, dependencies) {
|
|
73348
|
-
const absoluteFilePath = (0,
|
|
73349
|
-
await dependencies.mkdir((0,
|
|
73462
|
+
const absoluteFilePath = (0, import_node_path26.join)(rootDirectory, filePath);
|
|
73463
|
+
await dependencies.mkdir((0, import_node_path26.dirname)(absoluteFilePath), { recursive: true });
|
|
73350
73464
|
if (dependencies.writeFile) await dependencies.writeFile(absoluteFilePath, buildContent());
|
|
73351
73465
|
else await writeManaged(rootDirectory, filePath, buildContent(), void 0);
|
|
73352
73466
|
}
|
|
73353
73467
|
async function runValidateCommand(input3, dependencies = {}) {
|
|
73354
73468
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
73355
73469
|
const mkdir5 = dependencies.mkdir ?? (async (path, options) => {
|
|
73356
|
-
await (0,
|
|
73470
|
+
await (0, import_promises23.mkdir)(path, options);
|
|
73357
73471
|
});
|
|
73358
73472
|
const readFile = dependencies.readFile ?? (async (filePath) => {
|
|
73359
|
-
const content = await readManaged(rootDirectory, (0,
|
|
73473
|
+
const content = await readManaged(rootDirectory, (0, import_node_path26.relative)(rootDirectory, filePath));
|
|
73360
73474
|
if (content === void 0) throw Object.assign(new Error("Missing local scaffold file."), { code: "ENOENT" });
|
|
73361
73475
|
return content;
|
|
73362
73476
|
});
|
|
73363
|
-
const stat = dependencies.stat ??
|
|
73477
|
+
const stat = dependencies.stat ?? import_promises23.stat;
|
|
73364
73478
|
const rootDirectory = await projectRoot(cwd());
|
|
73365
73479
|
for (const file2 of [PROFILE_FILE_PATH, CONNECTION_FILE_PATH, GITIGNORE_FILE_PATH]) await safePath(rootDirectory, file2);
|
|
73366
73480
|
const profileValidation = await validateProfile(rootDirectory, { readFile, stat });
|
|
@@ -73387,7 +73501,7 @@ async function runValidateCommand(input3, dependencies = {}) {
|
|
|
73387
73501
|
checks.push({ name: fixableFile.name, status: status2, message: file2.status === "ok" ? previous.status === "missing" ? `Wrote missing ${file2.path}` : previous.status === "stale" ? `Updated stale ${file2.path}` : `Found ${file2.path}` : file2.status === "missing" ? `Missing ${file2.path}` : file2.status === "stale" ? `Stale ${file2.path}; run debugbundle validate --fix to refresh it.` : file2.message });
|
|
73388
73502
|
continue;
|
|
73389
73503
|
}
|
|
73390
|
-
if (await pathExists8((0,
|
|
73504
|
+
if (await pathExists8((0, import_node_path26.join)(rootDirectory, fixableFile.filePath), stat)) {
|
|
73391
73505
|
checks.push({ name: fixableFile.name, status: "ok", message: `Found ${fixableFile.filePath}` });
|
|
73392
73506
|
} else if (input3.fix) {
|
|
73393
73507
|
await fixMissingFile(rootDirectory, fixableFile.filePath, fixableFile.buildContent, { mkdir: mkdir5, ...dependencies.writeFile ? { writeFile: dependencies.writeFile } : {} });
|
|
@@ -82404,7 +82518,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
|
|
|
82404
82518
|
// package.json
|
|
82405
82519
|
var package_default = {
|
|
82406
82520
|
name: "@debugbundle/cli",
|
|
82407
|
-
version: "1.19.
|
|
82521
|
+
version: "1.19.4",
|
|
82408
82522
|
private: false,
|
|
82409
82523
|
description: "Command-line interface for DebugBundle",
|
|
82410
82524
|
license: "Apache-2.0",
|