sales-frontend-gemini-cli 0.4.4 → 0.5.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.
@@ -209,15 +209,51 @@ function runGitCommand(args4, options = {}) {
209
209
  throw error;
210
210
  }
211
211
  }
212
+ function resolveShellLaunchConfig() {
213
+ const candidates = [];
214
+ const seen = /* @__PURE__ */ new Set();
215
+ const appendCandidate = (executable, shellArgs) => {
216
+ const normalizedExecutable = executable?.trim();
217
+ if (!normalizedExecutable) {
218
+ return;
219
+ }
220
+ if (path__default.default.isAbsolute(normalizedExecutable) && !fs__default.default.existsSync(normalizedExecutable)) {
221
+ return;
222
+ }
223
+ const key = `${normalizedExecutable}::${shellArgs.join("\0")}`;
224
+ if (seen.has(key)) {
225
+ return;
226
+ }
227
+ seen.add(key);
228
+ candidates.push({
229
+ executable: normalizedExecutable,
230
+ shellArgs
231
+ });
232
+ };
233
+ const shellFromEnv = process.env.SHELL?.trim();
234
+ const envShellName = shellFromEnv ? path__default.default.basename(shellFromEnv) : "";
235
+ if (["bash", "zsh", "ksh"].includes(envShellName)) {
236
+ appendCandidate(shellFromEnv, ["-lc"]);
237
+ }
238
+ ["/bin/bash", "/usr/bin/bash", "bash", "/bin/zsh", "/usr/bin/zsh", "zsh"].forEach((shellPath) => {
239
+ appendCandidate(shellPath, ["-lc"]);
240
+ });
241
+ ["/bin/sh", "/usr/bin/sh", "sh"].forEach((shellPath) => {
242
+ appendCandidate(shellPath, ["-c"]);
243
+ });
244
+ return candidates[0] || { executable: "sh", shellArgs: ["-c"] };
245
+ }
212
246
  async function executeShellCommandWithProgress(command, options = {}) {
213
247
  const { progressIntervalMs = 1e4, progressMessage = "\u23F3 \uBA85\uB839\uC744 \uC2E4\uD589\uD558\uB294 \uC911\uC785\uB2C8\uB2E4...", streamOutput = false } = options;
214
248
  const { spawn } = await import('child_process');
249
+ const shellLaunchConfig = resolveShellLaunchConfig();
215
250
  return new Promise((resolve, reject) => {
216
251
  let stdout = "";
217
252
  let stderr = "";
218
253
  const startedAt = Date.now();
219
254
  console.log(progressMessage);
220
- const child = spawn("/bin/zsh", ["-lc", command], {
255
+ helperTrace("shell-command:launcher", `${shellLaunchConfig.executable} ${shellLaunchConfig.shellArgs.join(" ")}`);
256
+ const child = spawn(shellLaunchConfig.executable, [...shellLaunchConfig.shellArgs, command], {
221
257
  stdio: ["ignore", "pipe", "pipe"]
222
258
  });
223
259
  const progressTimer = setInterval(() => {
@@ -596,6 +632,62 @@ function truncateCommitSubject(subject) {
596
632
  }
597
633
  return `${subject.slice(0, 69)}...`;
598
634
  }
635
+ function formatReviewTargetFileCount(fileCount) {
636
+ return fileCount === 0 ? "\uBCC0\uACBD \uC5C6\uC74C" : `${fileCount}\uAC1C \uD30C\uC77C`;
637
+ }
638
+ function buildReviewTargetSectionTitle(target) {
639
+ return target.kind === "commit" ? `${target.hash} ${target.subject}` : `${target.hash} | ${target.subject}`;
640
+ }
641
+ function buildReviewTargetSummaryLine(target) {
642
+ if (target.kind === "commit") {
643
+ return `- ${target.hash} | ${target.subject} | ${target.author} | ${target.relativeDate}`;
644
+ }
645
+ return `- ${target.hash} | ${target.subject}`;
646
+ }
647
+ function buildReviewTargetDiffArgs(target, filePath) {
648
+ const reviewPathspecArgs = getReviewPathspecArgs();
649
+ if (target.kind === "commit") {
650
+ return ["show", "--stat", "--patch", "--format=", target.hash, "--", ...reviewPathspecArgs];
651
+ }
652
+ const diffArgs = ["diff"];
653
+ if (target.kind === "staged") {
654
+ diffArgs.push("--cached");
655
+ }
656
+ diffArgs.push("--stat", "--patch", "--");
657
+ return [...diffArgs, ...reviewPathspecArgs];
658
+ }
659
+ function buildReviewTargetFileArgs(target) {
660
+ const reviewPathspecArgs = getReviewPathspecArgs();
661
+ if (target.kind === "commit") {
662
+ return ["show", "--pretty=format:", "--name-only", target.hash, "--", ...reviewPathspecArgs];
663
+ }
664
+ const diffArgs = ["diff"];
665
+ if (target.kind === "staged") {
666
+ diffArgs.push("--cached");
667
+ }
668
+ return [...diffArgs, "--name-only", "--", ...reviewPathspecArgs];
669
+ }
670
+ function getReviewTargetFiles(target) {
671
+ const output = runGitCommand(buildReviewTargetFileArgs(target), {
672
+ allowFailure: true
673
+ });
674
+ return output.split("\n").map((line) => line.trim()).filter(Boolean);
675
+ }
676
+ function createWorkingTreeReviewOption(kind) {
677
+ const files = getReviewTargetFiles({
678
+ hash: kind,
679
+ kind});
680
+ const subject = kind === "unstaged" ? "\uC544\uC9C1 git add \uD558\uC9C0 \uC54A\uC740 \uBCC0\uACBD\uC0AC\uD56D" : "git add \uB41C \uBCC0\uACBD\uC0AC\uD56D";
681
+ return {
682
+ author: "",
683
+ description: `${subject} | ${formatReviewTargetFileCount(files.length)}`,
684
+ hash: kind,
685
+ kind,
686
+ label: kind,
687
+ relativeDate: "",
688
+ subject
689
+ };
690
+ }
599
691
  function getRecentCommitOptions() {
600
692
  const output = runGitCommand(
601
693
  ["log", `-${COMMIT_FETCH_LIMIT}`, "--date=relative", "--pretty=format:%h%x09%an%x09%ar%x09%s"],
@@ -611,44 +703,43 @@ function getRecentCommitOptions() {
611
703
  author,
612
704
  description: `${author} | ${relativeDate}`,
613
705
  hash,
706
+ kind: "commit",
614
707
  label: `${hash} | ${truncateCommitSubject(subject)}`,
615
708
  relativeDate,
616
709
  subject
617
710
  };
618
711
  });
619
712
  }
713
+ function getReviewTargetOptions() {
714
+ return [createWorkingTreeReviewOption("unstaged"), createWorkingTreeReviewOption("staged"), ...getRecentCommitOptions()];
715
+ }
620
716
  function buildSelectedCommitSummary(commits) {
621
- return commits.map((commit) => `- ${commit.hash} | ${commit.subject} | ${commit.author} | ${commit.relativeDate}`).join("\n");
717
+ return commits.map((commit) => buildReviewTargetSummaryLine(commit)).join("\n");
622
718
  }
623
719
  function getReviewPathspecArgs() {
624
720
  const { includePatterns, excludePatterns } = getGitDiffPathspecs();
625
721
  return [...includePatterns, ...excludePatterns];
626
722
  }
627
723
  function buildSelectedCommitDiff(commits) {
628
- const reviewPathspecArgs = getReviewPathspecArgs();
629
724
  const sections = commits.map((commit) => {
630
- const diff = runGitCommand(["show", "--stat", "--patch", "--format=", commit.hash, "--", ...reviewPathspecArgs], {
725
+ const diff = runGitCommand(buildReviewTargetDiffArgs(commit), {
631
726
  allowFailure: true,
632
727
  trimOutput: false
633
728
  }).trim();
634
729
  if (!diff) {
635
730
  return "";
636
731
  }
637
- return [`## ${commit.hash} ${commit.subject}`, diff].join("\n\n");
732
+ return [`## ${buildReviewTargetSectionTitle(commit)}`, diff].join("\n\n");
638
733
  }).filter(Boolean).join("\n\n");
639
734
  if (!sections) {
640
735
  return "";
641
736
  }
642
- return ["# \uC120\uD0DD\uD55C \uCEE4\uBC0B", buildSelectedCommitSummary(commits), "", "# \uB9AC\uBDF0 \uB300\uC0C1 diff", sections].join("\n");
737
+ return ["# \uC120\uD0DD\uD55C \uB9AC\uBDF0 \uB300\uC0C1", buildSelectedCommitSummary(commits), "", "# \uB9AC\uBDF0 \uB300\uC0C1 diff", sections].join("\n");
643
738
  }
644
739
  function getSelectedCommitFiles(commits) {
645
- const reviewPathspecArgs = getReviewPathspecArgs();
646
740
  const files = /* @__PURE__ */ new Set();
647
741
  commits.forEach((commit) => {
648
- const output = runGitCommand(["show", "--pretty=format:", "--name-only", commit.hash, "--", ...reviewPathspecArgs], {
649
- allowFailure: true
650
- });
651
- output.split("\n").map((line) => line.trim()).filter(Boolean).forEach((filePath) => files.add(filePath));
742
+ getReviewTargetFiles(commit).forEach((filePath) => files.add(filePath));
652
743
  });
653
744
  return [...files];
654
745
  }
@@ -836,13 +927,13 @@ async function showMultiSelect(question, options, windowSize = COMMIT_SELECTION_
836
927
  });
837
928
  }
838
929
  async function selectReviewCommits() {
839
- const commits = getRecentCommitOptions();
930
+ const commits = getReviewTargetOptions();
840
931
  if (commits.length === 0) {
841
- console.log("\u2139\uFE0F \uB9AC\uBDF0\uD560 \uCD5C\uADFC \uCEE4\uBC0B\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
932
+ console.log("\u2139\uFE0F \uB9AC\uBDF0\uD560 \uB300\uC0C1\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
842
933
  return [];
843
934
  }
844
935
  return showMultiSelect(
845
- "\uB9AC\uBDF0\uD560 \uCEE4\uBC0B\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694.",
936
+ "\uB9AC\uBDF0\uD560 \uB300\uC0C1\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694.",
846
937
  commits.map((commit) => ({
847
938
  description: commit.description,
848
939
  label: commit.label,
@@ -1509,8 +1600,8 @@ async function main() {
1509
1600
  trace7("commit-selection:done", `count=${selectedCommits.length}`);
1510
1601
  if (selectedCommits.length === 0) {
1511
1602
  trace7("commit-selection:empty");
1512
- executionTitle = "\uC120\uD0DD\uB41C \uCEE4\uBC0B\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.";
1513
- console.log("\u2139\uFE0F \uC120\uD0DD\uB41C \uCEE4\uBC0B\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
1603
+ executionTitle = "\uC120\uD0DD\uB41C \uB9AC\uBDF0 \uB300\uC0C1\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.";
1604
+ console.log("\u2139\uFE0F \uC120\uD0DD\uB41C \uB9AC\uBDF0 \uB300\uC0C1\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
1514
1605
  deleteTempDiff();
1515
1606
  return;
1516
1607
  }
@@ -1524,8 +1615,8 @@ async function main() {
1524
1615
  trace7("git-diff:build:done", `length=${diff.length}`);
1525
1616
  if (!diff.trim() && !isTest) {
1526
1617
  trace7("empty-diff:exit");
1527
- executionTitle = "\uC120\uD0DD\uD55C \uCEE4\uBC0B\uC5D0\uC11C \uB9AC\uBDF0 \uB300\uC0C1 \uD30C\uC77C \uBCC0\uACBD\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.";
1528
- console.log("\u2139\uFE0F \uC120\uD0DD\uD55C \uCEE4\uBC0B\uC5D0\uC11C \uB9AC\uBDF0 \uB300\uC0C1 \uD30C\uC77C \uBCC0\uACBD\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.");
1618
+ executionTitle = "\uC120\uD0DD\uD55C \uB9AC\uBDF0 \uB300\uC0C1\uC5D0\uC11C \uB9AC\uBDF0\uD560 \uBCC0\uACBD\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.";
1619
+ console.log("\u2139\uFE0F \uC120\uD0DD\uD55C \uB9AC\uBDF0 \uB300\uC0C1\uC5D0\uC11C \uB9AC\uBDF0\uD560 \uBCC0\uACBD\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.");
1529
1620
  deleteTempDiff();
1530
1621
  return;
1531
1622
  }