@dotobokuri/fleet-console 1.24.0 → 1.26.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.
Files changed (69) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +2 -2
  3. package/dist/cli.d.ts +2 -2
  4. package/dist/cli.mjs +3137 -3176
  5. package/dist/client/assets/{_baseUniq-yooYbTgN.js → _baseUniq-DDQ9j_k8.js} +1 -1
  6. package/dist/client/assets/{arc-D4mme5Ts.js → arc-Bfozxruz.js} +1 -1
  7. package/dist/client/assets/{architectureDiagram-Q4EWVU46-BAJOviEX.js → architectureDiagram-Q4EWVU46-DCTNRtj5.js} +1 -1
  8. package/dist/client/assets/{blockDiagram-DXYQGD6D-DuObpxQ3.js → blockDiagram-DXYQGD6D-CWyPMMVT.js} +1 -1
  9. package/dist/client/assets/{c4Diagram-AHTNJAMY-BOT-SD34.js → c4Diagram-AHTNJAMY-Rt5eOwFM.js} +1 -1
  10. package/dist/client/assets/channel-CetR928K.js +1 -0
  11. package/dist/client/assets/{chunk-4BX2VUAB-BF_aMTes.js → chunk-4BX2VUAB-D4PVI1Vt.js} +1 -1
  12. package/dist/client/assets/{chunk-4TB4RGXK-M4brBcnD.js → chunk-4TB4RGXK-C1Oxcig_.js} +1 -1
  13. package/dist/client/assets/{chunk-55IACEB6-CrG-4b2Z.js → chunk-55IACEB6-Cpo6RFvp.js} +1 -1
  14. package/dist/client/assets/{chunk-EDXVE4YY-BxDSygH1.js → chunk-EDXVE4YY-DbsnZ6G8.js} +1 -1
  15. package/dist/client/assets/{chunk-FMBD7UC4-Bh7MEX7E.js → chunk-FMBD7UC4-Dbn5YbUa.js} +1 -1
  16. package/dist/client/assets/{chunk-OYMX7WX6-DBnBwxer.js → chunk-OYMX7WX6-d2kjzA4y.js} +1 -1
  17. package/dist/client/assets/{chunk-QZHKN3VN-bjAogQwW.js → chunk-QZHKN3VN-CYgkgTK2.js} +1 -1
  18. package/dist/client/assets/{chunk-YZCP3GAM-l4FGlk_c.js → chunk-YZCP3GAM-BJU26g8l.js} +1 -1
  19. package/dist/client/assets/classDiagram-6PBFFD2Q-D0UUo5I1.js +1 -0
  20. package/dist/client/assets/classDiagram-v2-HSJHXN6E-D0UUo5I1.js +1 -0
  21. package/dist/client/assets/clone-kWHSuIUT.js +1 -0
  22. package/dist/client/assets/{cose-bilkent-S5V4N54A-Bm5QA4zo.js → cose-bilkent-S5V4N54A-z-z1o5SL.js} +1 -1
  23. package/dist/client/assets/{dagre-KV5264BT-PzXQN-5Q.js → dagre-KV5264BT-BcXLhG5I.js} +1 -1
  24. package/dist/client/assets/{diagram-5BDNPKRD-KhaAKPtX.js → diagram-5BDNPKRD-B-ws82Eu.js} +1 -1
  25. package/dist/client/assets/{diagram-G4DWMVQ6-DBbjfiR8.js → diagram-G4DWMVQ6-BmCJvW_F.js} +1 -1
  26. package/dist/client/assets/{diagram-MMDJMWI5-QWro7PRX.js → diagram-MMDJMWI5-CpqgkpUs.js} +1 -1
  27. package/dist/client/assets/{diagram-TYMM5635-B9LqWrbF.js → diagram-TYMM5635-D9qcELVs.js} +1 -1
  28. package/dist/client/assets/{erDiagram-SMLLAGMA-b0VkMMN4.js → erDiagram-SMLLAGMA-CIrLBm_M.js} +1 -1
  29. package/dist/client/assets/{flowDiagram-DWJPFMVM-edxBAbe6.js → flowDiagram-DWJPFMVM-Cn_vQPc6.js} +1 -1
  30. package/dist/client/assets/{ganttDiagram-T4ZO3ILL-ks2Gg1_V.js → ganttDiagram-T4ZO3ILL-B1NSn3FS.js} +1 -1
  31. package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-DymUyYNl.js → gitGraphDiagram-UUTBAWPF-BoFQ1joe.js} +1 -1
  32. package/dist/client/assets/{graph-B-B_mqfh.js → graph-CxiyRWzn.js} +1 -1
  33. package/dist/client/assets/index-Bf9IE54V.js +380 -0
  34. package/dist/client/assets/index-CjSWaFbs.css +1 -0
  35. package/dist/client/assets/{infoDiagram-42DDH7IO-B5iLIYAc.js → infoDiagram-42DDH7IO-o7pQ1RaC.js} +1 -1
  36. package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-DnztLLn7.js → ishikawaDiagram-UXIWVN3A-Du1ieZFu.js} +1 -1
  37. package/dist/client/assets/{journeyDiagram-VCZTEJTY-BKDRfH1Y.js → journeyDiagram-VCZTEJTY-seGxI0_P.js} +1 -1
  38. package/dist/client/assets/{kanban-definition-6JOO6SKY-DPB3Phvr.js → kanban-definition-6JOO6SKY-fMx5ietE.js} +1 -1
  39. package/dist/client/assets/{layout-BEeRhYTG.js → layout-BaAXqyYr.js} +1 -1
  40. package/dist/client/assets/{linear-QzmfWKSq.js → linear-DMj40Ji6.js} +1 -1
  41. package/dist/client/assets/{mermaid.core-BVka5dgm.js → mermaid.core-BdlXsBT1.js} +4 -4
  42. package/dist/client/assets/{min-CfXk9kSN.js → min-s6WtGnlJ.js} +1 -1
  43. package/dist/client/assets/{mindmap-definition-QFDTVHPH-tGrGhr6Z.js → mindmap-definition-QFDTVHPH-MCWf_KUb.js} +1 -1
  44. package/dist/client/assets/{pieDiagram-DEJITSTG-ZRBqRiRK.js → pieDiagram-DEJITSTG-BLXhYJPc.js} +1 -1
  45. package/dist/client/assets/{quadrantDiagram-34T5L4WZ-VCINZgct.js → quadrantDiagram-34T5L4WZ-DNh1hAV-.js} +1 -1
  46. package/dist/client/assets/{requirementDiagram-MS252O5E-DFLzADh3.js → requirementDiagram-MS252O5E-CqG-OGkG.js} +1 -1
  47. package/dist/client/assets/{sankeyDiagram-XADWPNL6-BbouN8Ji.js → sankeyDiagram-XADWPNL6-CHhecl0F.js} +1 -1
  48. package/dist/client/assets/{sequenceDiagram-FGHM5R23-B58_LF0R.js → sequenceDiagram-FGHM5R23-DVjf5Mte.js} +1 -1
  49. package/dist/client/assets/{stateDiagram-FHFEXIEX-pk-OHHuL.js → stateDiagram-FHFEXIEX-SB71u-q-.js} +1 -1
  50. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-BWyhQXqE.js +1 -0
  51. package/dist/client/assets/{timeline-definition-GMOUNBTQ-4jQdCvaj.js → timeline-definition-GMOUNBTQ-BiFLtGFX.js} +1 -1
  52. package/dist/client/assets/{vennDiagram-DHZGUBPP-CUr1fH6N.js → vennDiagram-DHZGUBPP-gVVHuVaX.js} +1 -1
  53. package/dist/client/assets/{wardley-RL74JXVD-D0cfvvNA.js → wardley-RL74JXVD-DmAOySPQ.js} +1 -1
  54. package/dist/client/assets/{wardleyDiagram-NUSXRM2D-D0l_Rp_Z.js → wardleyDiagram-NUSXRM2D-CxDohXgj.js} +1 -1
  55. package/dist/client/assets/{xychartDiagram-5P7HB3ND-BdR8OEuJ.js → xychartDiagram-5P7HB3ND-CgRIIIEQ.js} +1 -1
  56. package/dist/client/index.html +2 -2
  57. package/dist/desktop-protocol.d.ts +6 -5
  58. package/dist/desktop-protocol.mjs +26 -18
  59. package/dist/fleet-plugins/diff/routes.mjs +127 -19
  60. package/dist/fleet-plugins/file-explorer/routes.mjs +1 -1
  61. package/dist/fleet-plugins/terminal/routes.mjs +3807 -3932
  62. package/package.json +1 -1
  63. package/dist/client/assets/channel-TZYyAq1v.js +0 -1
  64. package/dist/client/assets/classDiagram-6PBFFD2Q-Dh6hZUl4.js +0 -1
  65. package/dist/client/assets/classDiagram-v2-HSJHXN6E-Dh6hZUl4.js +0 -1
  66. package/dist/client/assets/clone-DgWGnVWH.js +0 -1
  67. package/dist/client/assets/index-BgLzfg-v.css +0 -1
  68. package/dist/client/assets/index-pDnb-q6f.js +0 -380
  69. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-xsN122JA.js +0 -1
@@ -8,12 +8,12 @@ import fs from 'fs/promises';
8
8
  function definePlugin(definition) {
9
9
  return definition;
10
10
  }
11
- function registerRouter(ctx, path3, handler) {
12
- ctx.registerRouter(normalizePath(path3), handler);
11
+ function registerRouter(ctx, path4, handler) {
12
+ ctx.registerRouter(normalizePath(path4), handler);
13
13
  }
14
- function normalizePath(path3) {
15
- if (path3.length === 0 || path3 === "/") return "/";
16
- return path3;
14
+ function normalizePath(path4) {
15
+ if (path4.length === 0 || path4 === "/") return "/";
16
+ return path4;
17
17
  }
18
18
 
19
19
  // ../../packages/core-process/src/hidden.ts
@@ -100,17 +100,22 @@ function runGit(args, opts) {
100
100
  function isPlainObject(value) {
101
101
  return typeof value === "object" && value !== null && !Array.isArray(value);
102
102
  }
103
+ function literalPathspec(relativePath) {
104
+ return `:(literal)${relativePath}`;
105
+ }
103
106
  function normalizeNumstatPath(p) {
104
107
  const match = /^(.*?)\{[^}]* => ([^}]*)\}(.*)$/.exec(p);
105
- if (!match) return p;
106
- return (match[1] ?? "") + (match[2] ?? "") + (match[3] ?? "");
108
+ if (match) return (match[1] ?? "") + (match[2] ?? "") + (match[3] ?? "");
109
+ const plainRename = /^.+ => (.+)$/.exec(p);
110
+ return plainRename?.[1] ?? p;
107
111
  }
108
112
  function parseDiffFileList(nameStatusOutput, numstatOutput) {
109
113
  const numstatMap = /* @__PURE__ */ new Map();
110
114
  for (const line of numstatOutput.split("\n")) {
111
115
  const parts = line.split(" ");
112
116
  if (parts.length < 3) continue;
113
- const [adds, dels, filePath] = parts;
117
+ const [adds, dels] = parts;
118
+ const filePath = parts.length > 3 ? parts[parts.length - 1] : parts[2];
114
119
  if (!filePath) continue;
115
120
  numstatMap.set(normalizeNumstatPath(filePath), {
116
121
  additions: parseInt(adds ?? "0", 10) || 0,
@@ -123,11 +128,12 @@ function parseDiffFileList(nameStatusOutput, numstatOutput) {
123
128
  const [rawStatus, ...pathParts] = line.split(" ");
124
129
  if (!rawStatus || pathParts.length === 0) continue;
125
130
  const statusChar = rawStatus.charAt(0).toUpperCase();
126
- if (statusChar !== "M" && statusChar !== "A" && statusChar !== "D" && statusChar !== "R") continue;
131
+ if (statusChar !== "M" && statusChar !== "A" && statusChar !== "D" && statusChar !== "R" && statusChar !== "T") continue;
132
+ const oldPath = statusChar === "R" ? pathParts[0] : void 0;
127
133
  const filePath = statusChar === "R" ? pathParts[1] ?? pathParts[0] ?? "" : pathParts[0] ?? "";
128
134
  if (!filePath) continue;
129
135
  const nums = numstatMap.get(filePath) ?? { additions: 0, deletions: 0 };
130
- files.push({ path: filePath, status: statusChar, ...nums });
136
+ files.push({ path: filePath, ...oldPath ? { oldPath } : {}, status: statusChar, ...nums });
131
137
  }
132
138
  return files;
133
139
  }
@@ -204,16 +210,16 @@ async function handleDiffChanged(req, res, ctx) {
204
210
  let truncated = false;
205
211
  try {
206
212
  const [nameStatusResult, numstatResult] = await Promise.all([
207
- runGit(["diff", "HEAD", "--relative", "--name-status", "--diff-filter=MADR", "--", "."], { cwd: gitCwd }),
208
- runGit(["diff", "HEAD", "--relative", "--numstat", "--diff-filter=MADR", "--", "."], { cwd: gitCwd })
213
+ runGit(["diff", "HEAD", "--relative", "--name-status", "--diff-filter=MADRT", "--", "."], { cwd: gitCwd }),
214
+ runGit(["diff", "HEAD", "--relative", "--numstat", "--diff-filter=MADRT", "--", "."], { cwd: gitCwd })
209
215
  ]);
210
216
  files = parseDiffFileList(nameStatusResult.stdout, numstatResult.stdout);
211
217
  truncated = nameStatusResult.truncated || numstatResult.truncated;
212
218
  } catch (err) {
213
219
  if (!isNoHeadError(err)) throw err;
214
220
  const [nsResult, nsNumstat] = await Promise.all([
215
- runGit(["diff", "--cached", "--relative", "--name-status", "--diff-filter=MADR", "--", "."], { cwd: gitCwd }),
216
- runGit(["diff", "--cached", "--relative", "--numstat", "--diff-filter=MADR", "--", "."], { cwd: gitCwd })
221
+ runGit(["diff", "--cached", "--relative", "--name-status", "--diff-filter=MADRT", "--", "."], { cwd: gitCwd }),
222
+ runGit(["diff", "--cached", "--relative", "--numstat", "--diff-filter=MADRT", "--", "."], { cwd: gitCwd })
217
223
  ]);
218
224
  files = parseDiffFileList(nsResult.stdout, nsNumstat.stdout);
219
225
  truncated = nsResult.truncated || nsNumstat.truncated;
@@ -320,10 +326,10 @@ async function handleDiffFile(req, res, ctx) {
320
326
  }
321
327
  let result;
322
328
  try {
323
- result = await runGit(["diff", "HEAD", "--relative", "--unified=3", "--", relativePath], { cwd: gitCwd });
329
+ result = await runGit(["diff", "HEAD", "--relative", "--unified=3", "--", literalPathspec(relativePath)], { cwd: gitCwd });
324
330
  } catch (err) {
325
331
  if (!isNoHeadError(err)) throw err;
326
- result = await runGit(["diff", "--cached", "--relative", "--unified=3", "--", relativePath], { cwd: gitCwd });
332
+ result = await runGit(["diff", "--cached", "--relative", "--unified=3", "--", literalPathspec(relativePath)], { cwd: gitCwd });
327
333
  }
328
334
  ctx.host.http.writeJson(res, 200, { content: result.stdout, truncated: result.truncated });
329
335
  } catch (error) {
@@ -344,6 +350,22 @@ var REF_RE = /^[0-9a-f]{7,40}$/i;
344
350
  function isPlainObject2(value) {
345
351
  return typeof value === "object" && value !== null && !Array.isArray(value);
346
352
  }
353
+ function parseCommitMeta(output) {
354
+ const fields = output.split("\0");
355
+ if (fields.length < 6) return null;
356
+ const [authorName, authorEmail, rawAuthorAt, subject, rawParents, ...bodyParts] = fields;
357
+ if (authorName === void 0 || authorEmail === void 0 || rawAuthorAt === void 0 || subject === void 0 || rawParents === void 0) return null;
358
+ const authorAt = Number.parseInt(rawAuthorAt, 10);
359
+ if (!Number.isFinite(authorAt)) return null;
360
+ return {
361
+ authorName,
362
+ authorEmail,
363
+ authorAt,
364
+ subject,
365
+ body: bodyParts.join("\0").trimEnd(),
366
+ parents: rawParents.split(" ").filter(Boolean).map((full) => ({ full, short: full.slice(0, 9) }))
367
+ };
368
+ }
347
369
  async function handleDiffCommit(req, res, ctx) {
348
370
  if (req.method !== "POST") {
349
371
  ctx.host.http.writeJson(res, 405, { error: "Method not allowed" });
@@ -381,7 +403,89 @@ async function handleDiffCommit(req, res, ctx) {
381
403
  }
382
404
  const { gitCwd } = cwdResult;
383
405
  try {
384
- const result = await runGit(["show", ref, "--relative", "--unified=3", "--format=", "--", "."], { cwd: gitCwd });
406
+ const [metaResult, nameStatusResult, numstatResult] = await Promise.all([
407
+ runGit(["show", "-s", "--format=%an%x00%ae%x00%at%x00%s%x00%P%x00%b", ref], { cwd: gitCwd }),
408
+ runGit(["show", "--first-parent", "--format=", "--relative", "--name-status", "--diff-filter=MADRT", ref, "--", "."], { cwd: gitCwd }),
409
+ runGit(["show", "--first-parent", "--format=", "--relative", "--numstat", "--diff-filter=MADRT", ref, "--", "."], { cwd: gitCwd })
410
+ ]);
411
+ const meta = parseCommitMeta(metaResult.stdout);
412
+ if (!meta) {
413
+ ctx.host.http.writeJson(res, 500, { error: "git_failed" });
414
+ return;
415
+ }
416
+ ctx.host.http.writeJson(res, 200, {
417
+ meta,
418
+ files: parseDiffFileList(nameStatusResult.stdout, numstatResult.stdout),
419
+ ...metaResult.truncated || nameStatusResult.truncated || numstatResult.truncated ? { truncated: true } : {}
420
+ });
421
+ } catch (error) {
422
+ if (error instanceof GitExecutorError) {
423
+ if (error.code === "no_git_repo" || error.code === "git_unavailable") {
424
+ ctx.host.http.writeJson(res, 422, { error: error.code });
425
+ return;
426
+ }
427
+ ctx.host.http.writeJson(res, 500, { error: "git_failed" });
428
+ return;
429
+ }
430
+ throw error;
431
+ }
432
+ }
433
+ function isPlainObject3(value) {
434
+ return typeof value === "object" && value !== null && !Array.isArray(value);
435
+ }
436
+ function resolveLiteralFilePath(gitCwd, rawPath) {
437
+ const relativePath = path2.normalize(rawPath);
438
+ const resolved = path2.resolve(gitCwd, relativePath);
439
+ if (relativePath === ".." || relativePath.startsWith(".." + path2.sep) || !resolved.startsWith(gitCwd + path2.sep)) return null;
440
+ return relativePath;
441
+ }
442
+ function literalPathspec2(relativePath) {
443
+ return `:(literal)${relativePath}`;
444
+ }
445
+ async function handleDiffCommitFile(req, res, ctx) {
446
+ if (req.method !== "POST") {
447
+ ctx.host.http.writeJson(res, 405, { error: "Method not allowed" });
448
+ return;
449
+ }
450
+ if (!ctx.host.security.isTerminalAuthorized(req)) {
451
+ ctx.host.http.writeJson(res, 401, { error: "unauthorized" });
452
+ return;
453
+ }
454
+ const body = await ctx.host.http.readJsonBody(req);
455
+ if (!isPlainObject3(body) || typeof body.theaterId !== "string" || typeof body.ref !== "string" || typeof body.filePath !== "string") {
456
+ ctx.host.http.writeJson(res, 400, { error: "invalid_request" });
457
+ return;
458
+ }
459
+ if (!REF_RE.test(body.ref)) {
460
+ ctx.host.http.writeJson(res, 400, { error: "invalid_ref" });
461
+ return;
462
+ }
463
+ if (!body.filePath) {
464
+ ctx.host.http.writeJson(res, 400, { error: "invalid_file_path" });
465
+ return;
466
+ }
467
+ if (body.oldPath !== void 0 && (typeof body.oldPath !== "string" || !body.oldPath)) {
468
+ ctx.host.http.writeJson(res, 400, { error: "invalid_file_path" });
469
+ return;
470
+ }
471
+ const theaterPath = ctx.host.paths.resolveTheaterPath(body.theaterId);
472
+ if (!theaterPath) {
473
+ ctx.host.http.writeJson(res, 404, { error: "theater_not_found" });
474
+ return;
475
+ }
476
+ const cwdResult = await resolveGitCwd(theaterPath, typeof body.subPath === "string" ? body.subPath : "");
477
+ if (!cwdResult) {
478
+ ctx.host.http.writeJson(res, 403, { error: "path_outside_theater" });
479
+ return;
480
+ }
481
+ const relativePath = resolveLiteralFilePath(cwdResult.gitCwd, body.filePath);
482
+ const oldPath = typeof body.oldPath === "string" ? resolveLiteralFilePath(cwdResult.gitCwd, body.oldPath) : void 0;
483
+ if (!relativePath || body.oldPath !== void 0 && !oldPath) {
484
+ ctx.host.http.writeJson(res, 403, { error: "path_outside_theater" });
485
+ return;
486
+ }
487
+ try {
488
+ const result = await runGit(oldPath ? ["show", "--first-parent", body.ref, "-M", "--format=", "--unified=3", "--", literalPathspec2(oldPath), literalPathspec2(relativePath)] : ["show", "--first-parent", body.ref, "--format=", "--unified=3", "--", literalPathspec2(relativePath)], { cwd: cwdResult.gitCwd });
385
489
  ctx.host.http.writeJson(res, 200, { content: result.stdout, ...result.truncated ? { truncated: true } : {} });
386
490
  } catch (error) {
387
491
  if (error instanceof GitExecutorError) {
@@ -396,7 +500,7 @@ async function handleDiffCommit(req, res, ctx) {
396
500
  }
397
501
  }
398
502
  var WORKTREE_SHA_RE = /^[0-9a-f]{40}$/;
399
- function isPlainObject3(value) {
503
+ function isPlainObject4(value) {
400
504
  return typeof value === "object" && value !== null && !Array.isArray(value);
401
505
  }
402
506
  function parseLogOutput(stdout) {
@@ -514,7 +618,7 @@ async function handleDiffLog(req, res, ctx) {
514
618
  return;
515
619
  }
516
620
  const body = await ctx.host.http.readJsonBody(req);
517
- if (!isPlainObject3(body)) {
621
+ if (!isPlainObject4(body)) {
518
622
  ctx.host.http.writeJson(res, 400, { error: "invalid_request" });
519
623
  return;
520
624
  }
@@ -592,6 +696,10 @@ var routes_default = definePlugin({
592
696
  await handleDiffCommit(req, res, ctx);
593
697
  return true;
594
698
  });
699
+ registerRouter(ctx, "commit-file", async ({ req, res }) => {
700
+ await handleDiffCommitFile(req, res, ctx);
701
+ return true;
702
+ });
595
703
  }
596
704
  });
597
705
 
@@ -205,7 +205,7 @@ async function collectContentsEntries(targetPath, theaterPath, opendir, stat, en
205
205
  }
206
206
  async function openDirectory(targetPath, opendir) {
207
207
  try {
208
- return await opendir(targetPath);
208
+ return await opendir(targetPath, { bufferSize: DIRECTORY_ENTRY_CAP + 1 });
209
209
  } catch (error) {
210
210
  throw mapFsError(error);
211
211
  }