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.
@@ -200,15 +200,51 @@ function runGitCommand(args4, options = {}) {
200
200
  throw error;
201
201
  }
202
202
  }
203
+ function resolveShellLaunchConfig() {
204
+ const candidates = [];
205
+ const seen = /* @__PURE__ */ new Set();
206
+ const appendCandidate = (executable, shellArgs) => {
207
+ const normalizedExecutable = executable?.trim();
208
+ if (!normalizedExecutable) {
209
+ return;
210
+ }
211
+ if (path.isAbsolute(normalizedExecutable) && !fs.existsSync(normalizedExecutable)) {
212
+ return;
213
+ }
214
+ const key = `${normalizedExecutable}::${shellArgs.join("\0")}`;
215
+ if (seen.has(key)) {
216
+ return;
217
+ }
218
+ seen.add(key);
219
+ candidates.push({
220
+ executable: normalizedExecutable,
221
+ shellArgs
222
+ });
223
+ };
224
+ const shellFromEnv = process.env.SHELL?.trim();
225
+ const envShellName = shellFromEnv ? path.basename(shellFromEnv) : "";
226
+ if (["bash", "zsh", "ksh"].includes(envShellName)) {
227
+ appendCandidate(shellFromEnv, ["-lc"]);
228
+ }
229
+ ["/bin/bash", "/usr/bin/bash", "bash", "/bin/zsh", "/usr/bin/zsh", "zsh"].forEach((shellPath) => {
230
+ appendCandidate(shellPath, ["-lc"]);
231
+ });
232
+ ["/bin/sh", "/usr/bin/sh", "sh"].forEach((shellPath) => {
233
+ appendCandidate(shellPath, ["-c"]);
234
+ });
235
+ return candidates[0] || { executable: "sh", shellArgs: ["-c"] };
236
+ }
203
237
  async function executeShellCommandWithProgress(command, options = {}) {
204
238
  const { progressIntervalMs = 1e4, progressMessage = "\u23F3 \uBA85\uB839\uC744 \uC2E4\uD589\uD558\uB294 \uC911\uC785\uB2C8\uB2E4...", streamOutput = false } = options;
205
239
  const { spawn } = await import('child_process');
240
+ const shellLaunchConfig = resolveShellLaunchConfig();
206
241
  return new Promise((resolve, reject) => {
207
242
  let stdout = "";
208
243
  let stderr = "";
209
244
  const startedAt = Date.now();
210
245
  console.log(progressMessage);
211
- const child = spawn("/bin/zsh", ["-lc", command], {
246
+ helperTrace("shell-command:launcher", `${shellLaunchConfig.executable} ${shellLaunchConfig.shellArgs.join(" ")}`);
247
+ const child = spawn(shellLaunchConfig.executable, [...shellLaunchConfig.shellArgs, command], {
212
248
  stdio: ["ignore", "pipe", "pipe"]
213
249
  });
214
250
  const progressTimer = setInterval(() => {
@@ -587,6 +623,62 @@ function truncateCommitSubject(subject) {
587
623
  }
588
624
  return `${subject.slice(0, 69)}...`;
589
625
  }
626
+ function formatReviewTargetFileCount(fileCount) {
627
+ return fileCount === 0 ? "\uBCC0\uACBD \uC5C6\uC74C" : `${fileCount}\uAC1C \uD30C\uC77C`;
628
+ }
629
+ function buildReviewTargetSectionTitle(target) {
630
+ return target.kind === "commit" ? `${target.hash} ${target.subject}` : `${target.hash} | ${target.subject}`;
631
+ }
632
+ function buildReviewTargetSummaryLine(target) {
633
+ if (target.kind === "commit") {
634
+ return `- ${target.hash} | ${target.subject} | ${target.author} | ${target.relativeDate}`;
635
+ }
636
+ return `- ${target.hash} | ${target.subject}`;
637
+ }
638
+ function buildReviewTargetDiffArgs(target, filePath) {
639
+ const reviewPathspecArgs = getReviewPathspecArgs();
640
+ if (target.kind === "commit") {
641
+ return ["show", "--stat", "--patch", "--format=", target.hash, "--", ...reviewPathspecArgs];
642
+ }
643
+ const diffArgs = ["diff"];
644
+ if (target.kind === "staged") {
645
+ diffArgs.push("--cached");
646
+ }
647
+ diffArgs.push("--stat", "--patch", "--");
648
+ return [...diffArgs, ...reviewPathspecArgs];
649
+ }
650
+ function buildReviewTargetFileArgs(target) {
651
+ const reviewPathspecArgs = getReviewPathspecArgs();
652
+ if (target.kind === "commit") {
653
+ return ["show", "--pretty=format:", "--name-only", target.hash, "--", ...reviewPathspecArgs];
654
+ }
655
+ const diffArgs = ["diff"];
656
+ if (target.kind === "staged") {
657
+ diffArgs.push("--cached");
658
+ }
659
+ return [...diffArgs, "--name-only", "--", ...reviewPathspecArgs];
660
+ }
661
+ function getReviewTargetFiles(target) {
662
+ const output = runGitCommand(buildReviewTargetFileArgs(target), {
663
+ allowFailure: true
664
+ });
665
+ return output.split("\n").map((line) => line.trim()).filter(Boolean);
666
+ }
667
+ function createWorkingTreeReviewOption(kind) {
668
+ const files = getReviewTargetFiles({
669
+ hash: kind,
670
+ kind});
671
+ const subject = kind === "unstaged" ? "\uC544\uC9C1 git add \uD558\uC9C0 \uC54A\uC740 \uBCC0\uACBD\uC0AC\uD56D" : "git add \uB41C \uBCC0\uACBD\uC0AC\uD56D";
672
+ return {
673
+ author: "",
674
+ description: `${subject} | ${formatReviewTargetFileCount(files.length)}`,
675
+ hash: kind,
676
+ kind,
677
+ label: kind,
678
+ relativeDate: "",
679
+ subject
680
+ };
681
+ }
590
682
  function getRecentCommitOptions() {
591
683
  const output = runGitCommand(
592
684
  ["log", `-${COMMIT_FETCH_LIMIT}`, "--date=relative", "--pretty=format:%h%x09%an%x09%ar%x09%s"],
@@ -602,44 +694,43 @@ function getRecentCommitOptions() {
602
694
  author,
603
695
  description: `${author} | ${relativeDate}`,
604
696
  hash,
697
+ kind: "commit",
605
698
  label: `${hash} | ${truncateCommitSubject(subject)}`,
606
699
  relativeDate,
607
700
  subject
608
701
  };
609
702
  });
610
703
  }
704
+ function getReviewTargetOptions() {
705
+ return [createWorkingTreeReviewOption("unstaged"), createWorkingTreeReviewOption("staged"), ...getRecentCommitOptions()];
706
+ }
611
707
  function buildSelectedCommitSummary(commits) {
612
- return commits.map((commit) => `- ${commit.hash} | ${commit.subject} | ${commit.author} | ${commit.relativeDate}`).join("\n");
708
+ return commits.map((commit) => buildReviewTargetSummaryLine(commit)).join("\n");
613
709
  }
614
710
  function getReviewPathspecArgs() {
615
711
  const { includePatterns, excludePatterns } = getGitDiffPathspecs();
616
712
  return [...includePatterns, ...excludePatterns];
617
713
  }
618
714
  function buildSelectedCommitDiff(commits) {
619
- const reviewPathspecArgs = getReviewPathspecArgs();
620
715
  const sections = commits.map((commit) => {
621
- const diff = runGitCommand(["show", "--stat", "--patch", "--format=", commit.hash, "--", ...reviewPathspecArgs], {
716
+ const diff = runGitCommand(buildReviewTargetDiffArgs(commit), {
622
717
  allowFailure: true,
623
718
  trimOutput: false
624
719
  }).trim();
625
720
  if (!diff) {
626
721
  return "";
627
722
  }
628
- return [`## ${commit.hash} ${commit.subject}`, diff].join("\n\n");
723
+ return [`## ${buildReviewTargetSectionTitle(commit)}`, diff].join("\n\n");
629
724
  }).filter(Boolean).join("\n\n");
630
725
  if (!sections) {
631
726
  return "";
632
727
  }
633
- return ["# \uC120\uD0DD\uD55C \uCEE4\uBC0B", buildSelectedCommitSummary(commits), "", "# \uB9AC\uBDF0 \uB300\uC0C1 diff", sections].join("\n");
728
+ return ["# \uC120\uD0DD\uD55C \uB9AC\uBDF0 \uB300\uC0C1", buildSelectedCommitSummary(commits), "", "# \uB9AC\uBDF0 \uB300\uC0C1 diff", sections].join("\n");
634
729
  }
635
730
  function getSelectedCommitFiles(commits) {
636
- const reviewPathspecArgs = getReviewPathspecArgs();
637
731
  const files = /* @__PURE__ */ new Set();
638
732
  commits.forEach((commit) => {
639
- const output = runGitCommand(["show", "--pretty=format:", "--name-only", commit.hash, "--", ...reviewPathspecArgs], {
640
- allowFailure: true
641
- });
642
- output.split("\n").map((line) => line.trim()).filter(Boolean).forEach((filePath) => files.add(filePath));
733
+ getReviewTargetFiles(commit).forEach((filePath) => files.add(filePath));
643
734
  });
644
735
  return [...files];
645
736
  }
@@ -827,13 +918,13 @@ async function showMultiSelect(question, options, windowSize = COMMIT_SELECTION_
827
918
  });
828
919
  }
829
920
  async function selectReviewCommits() {
830
- const commits = getRecentCommitOptions();
921
+ const commits = getReviewTargetOptions();
831
922
  if (commits.length === 0) {
832
- console.log("\u2139\uFE0F \uB9AC\uBDF0\uD560 \uCD5C\uADFC \uCEE4\uBC0B\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
923
+ console.log("\u2139\uFE0F \uB9AC\uBDF0\uD560 \uB300\uC0C1\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
833
924
  return [];
834
925
  }
835
926
  return showMultiSelect(
836
- "\uB9AC\uBDF0\uD560 \uCEE4\uBC0B\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694.",
927
+ "\uB9AC\uBDF0\uD560 \uB300\uC0C1\uC744 \uC120\uD0DD\uD574\uC8FC\uC138\uC694.",
837
928
  commits.map((commit) => ({
838
929
  description: commit.description,
839
930
  label: commit.label,
@@ -1500,8 +1591,8 @@ async function main() {
1500
1591
  trace7("commit-selection:done", `count=${selectedCommits.length}`);
1501
1592
  if (selectedCommits.length === 0) {
1502
1593
  trace7("commit-selection:empty");
1503
- executionTitle = "\uC120\uD0DD\uB41C \uCEE4\uBC0B\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.";
1504
- console.log("\u2139\uFE0F \uC120\uD0DD\uB41C \uCEE4\uBC0B\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
1594
+ executionTitle = "\uC120\uD0DD\uB41C \uB9AC\uBDF0 \uB300\uC0C1\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.";
1595
+ console.log("\u2139\uFE0F \uC120\uD0DD\uB41C \uB9AC\uBDF0 \uB300\uC0C1\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
1505
1596
  deleteTempDiff();
1506
1597
  return;
1507
1598
  }
@@ -1515,8 +1606,8 @@ async function main() {
1515
1606
  trace7("git-diff:build:done", `length=${diff.length}`);
1516
1607
  if (!diff.trim() && !isTest) {
1517
1608
  trace7("empty-diff:exit");
1518
- executionTitle = "\uC120\uD0DD\uD55C \uCEE4\uBC0B\uC5D0\uC11C \uB9AC\uBDF0 \uB300\uC0C1 \uD30C\uC77C \uBCC0\uACBD\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.";
1519
- 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.");
1609
+ executionTitle = "\uC120\uD0DD\uD55C \uB9AC\uBDF0 \uB300\uC0C1\uC5D0\uC11C \uB9AC\uBDF0\uD560 \uBCC0\uACBD\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.";
1610
+ 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.");
1520
1611
  deleteTempDiff();
1521
1612
  return;
1522
1613
  }