@zjex/git-workflow 0.3.2 → 0.3.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/dist/index.js CHANGED
@@ -660,7 +660,8 @@ async function listTags(prefix) {
660
660
  exec("git fetch --tags", true);
661
661
  spinner.stop();
662
662
  const pattern = prefix ? `${prefix}*` : "";
663
- const tags = execOutput(`git tag -l ${pattern} --sort=v:refname`).split("\n").filter(Boolean);
663
+ const allTags = execOutput(`git tag -l ${pattern} --sort=v:refname`).split("\n").filter(Boolean);
664
+ const tags = allTags.filter((tag) => /\d/.test(tag));
664
665
  if (tags.length === 0) {
665
666
  console.log(
666
667
  colors.yellow(prefix ? `\u6CA1\u6709 '${prefix}' \u5F00\u5934\u7684 tag` : "\u6CA1\u6709 tag")
@@ -668,31 +669,31 @@ async function listTags(prefix) {
668
669
  return;
669
670
  }
670
671
  if (prefix) {
671
- console.log(colors.green(`\u4EE5 '${prefix}' \u5F00\u5934\u7684 tags:`));
672
- const displayTags = tags.length > 20 ? tags.slice(-20) : tags;
673
- displayTags.forEach((tag) => console.log(` ${tag}`));
674
- if (tags.length > 20) {
675
- console.log(colors.yellow(`
676
- \u5171 ${tags.length} \u4E2A\uFF0C\u4EC5\u663E\u793A\u6700\u65B0 20 \u4E2A`));
672
+ console.log(
673
+ colors.green(`\u4EE5 '${prefix}' \u5F00\u5934\u7684 tags (\u5171 ${tags.length} \u4E2A):`)
674
+ );
675
+ if (tags.length > 5) {
676
+ console.log(colors.dim(" ..."));
677
677
  }
678
+ const displayTags = tags.slice(-5);
679
+ displayTags.forEach((tag) => console.log(` ${tag}`));
678
680
  return;
679
681
  }
680
682
  const grouped = /* @__PURE__ */ new Map();
681
683
  tags.forEach((tag) => {
682
- const prefix2 = tag.replace(/[0-9].*/, "") || "(\u65E0\u524D\u7F00)";
684
+ const prefix2 = tag.replace(/\d.*/, "") || "(\u65E0\u524D\u7F00)";
683
685
  if (!grouped.has(prefix2)) {
684
686
  grouped.set(prefix2, []);
685
687
  }
686
688
  grouped.get(prefix2).push(tag);
687
689
  });
688
690
  if (grouped.size === 1) {
689
- console.log(colors.green("\u6240\u6709 tags:"));
690
- const displayTags = tags.length > 20 ? tags.slice(-20) : tags;
691
- displayTags.forEach((tag) => console.log(` ${tag}`));
692
- if (tags.length > 20) {
693
- console.log(colors.yellow(`
694
- \u5171 ${tags.length} \u4E2A\uFF0C\u4EC5\u663E\u793A\u6700\u65B0 20 \u4E2A`));
691
+ console.log(colors.green(`\u6240\u6709 tags (\u5171 ${tags.length} \u4E2A):`));
692
+ if (tags.length > 5) {
693
+ console.log(colors.dim(" ..."));
695
694
  }
695
+ const displayTags = tags.slice(-5);
696
+ displayTags.forEach((tag) => console.log(` ${tag}`));
696
697
  return;
697
698
  }
698
699
  console.log(colors.green("\u6240\u6709 tags (\u6309\u524D\u7F00\u5206\u7EC4):"));
@@ -735,7 +736,7 @@ async function listTags(prefix) {
735
736
  }
736
737
  }
737
738
  function getLatestTag(prefix) {
738
- const tags = execOutput(`git tag -l "${prefix}*" --sort=-v:refname`).split("\n").filter(Boolean);
739
+ const tags = execOutput(`git tag -l "${prefix}*" --sort=-v:refname`).split("\n").filter((tag) => tag && /\d/.test(tag));
739
740
  return tags[0] || "";
740
741
  }
741
742
  async function createTag(inputPrefix) {
@@ -750,7 +751,7 @@ async function createTag(inputPrefix) {
750
751
  console.log(colors.dim(`(\u4F7F\u7528\u914D\u7F6E\u7684\u9ED8\u8BA4\u524D\u7F00: ${prefix})`));
751
752
  }
752
753
  if (!prefix) {
753
- const allTags = execOutput("git tag -l").split("\n").filter(Boolean);
754
+ const allTags = execOutput("git tag -l").split("\n").filter((tag) => tag && /\d/.test(tag));
754
755
  if (allTags.length === 0) {
755
756
  prefix = await input2({
756
757
  message: "\u5F53\u524D\u4ED3\u5E93\u6CA1\u6709 tag\uFF0C\u8BF7\u8F93\u5165\u524D\u7F00 (\u5982 v):",
@@ -797,7 +798,7 @@ async function createTag(inputPrefix) {
797
798
  return;
798
799
  }
799
800
  const prefixes = [
800
- ...new Set(allTags.map((t) => t.replace(/[0-9].*/, "")).filter(Boolean))
801
+ ...new Set(allTags.map((t) => t.replace(/\d.*/, "")).filter(Boolean))
801
802
  ];
802
803
  if (prefixes.length === 0) {
803
804
  prefix = await input2({
@@ -1463,12 +1464,34 @@ async function init() {
1463
1464
  ],
1464
1465
  theme
1465
1466
  });
1467
+ const aiUseEmoji = await select4({
1468
+ message: "AI \u751F\u6210\u7684 commit message \u662F\u5426\u5305\u542B emoji?",
1469
+ choices: [
1470
+ {
1471
+ name: "\u662F\uFF08\u63A8\u8350\uFF09",
1472
+ value: true,
1473
+ description: "\u5982\uFF1A\u2728 feat(auth): \u6DFB\u52A0\u7528\u6237\u767B\u5F55\u529F\u80FD"
1474
+ },
1475
+ {
1476
+ name: "\u5426",
1477
+ value: false,
1478
+ description: "\u5982\uFF1Afeat(auth): \u6DFB\u52A0\u7528\u6237\u767B\u5F55\u529F\u80FD"
1479
+ },
1480
+ {
1481
+ name: "\u8DDF\u968F\u5168\u5C40\u8BBE\u7F6E",
1482
+ value: void 0,
1483
+ description: `\u5F53\u524D\u5168\u5C40\u8BBE\u7F6E\uFF1A${useEmoji ? "\u542F\u7528" : "\u7981\u7528"} emoji`
1484
+ }
1485
+ ],
1486
+ theme
1487
+ });
1466
1488
  config2.aiCommit = {
1467
1489
  enabled: true,
1468
1490
  provider: aiProvider,
1469
1491
  apiKey: apiKey || void 0,
1470
1492
  language,
1471
- detailedDescription
1493
+ detailedDescription,
1494
+ useEmoji: aiUseEmoji
1472
1495
  };
1473
1496
  const defaultModels = {
1474
1497
  github: "gpt-4o-mini",
@@ -1812,13 +1835,13 @@ function getGitDiff() {
1812
1835
  return "";
1813
1836
  }
1814
1837
  }
1815
- function buildPrompt(diff, language, detailedDescription = false) {
1838
+ function buildPrompt(diff, language, detailedDescription = false, useEmoji = true) {
1816
1839
  const isZh = language === "zh-CN";
1817
1840
  if (detailedDescription) {
1818
1841
  const systemPrompt = isZh ? `\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684 Git commit message \u751F\u6210\u52A9\u624B\u3002\u8BF7\u6839\u636E\u63D0\u4F9B\u7684 git diff \u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684\u8BE6\u7EC6 commit message\u3002
1819
1842
 
1820
1843
  \u683C\u5F0F\u8981\u6C42\uFF1A
1821
- 1. \u7B2C\u4E00\u884C\uFF1A<type>(<scope>): <subject>
1844
+ 1. \u7B2C\u4E00\u884C\uFF1A${useEmoji ? "<emoji> " : ""}<type>(<scope>): <subject>
1822
1845
  2. \u7A7A\u884C
1823
1846
  3. \u8BE6\u7EC6\u63CF\u8FF0\uFF1A\u5217\u51FA\u4E3B\u8981\u4FEE\u6539\u70B9\uFF0C\u6BCF\u4E2A\u4FEE\u6539\u70B9\u4E00\u884C\uFF0C\u4EE5 "- " \u5F00\u5934
1824
1847
 
@@ -1829,9 +1852,22 @@ function buildPrompt(diff, language, detailedDescription = false) {
1829
1852
  - \u8BE6\u7EC6\u63CF\u8FF0\u8981\u5217\u51FA 3-6 \u4E2A\u4E3B\u8981\u4FEE\u6539\u70B9\uFF0C\u6BCF\u4E2A\u4FEE\u6539\u70B9\u7B80\u6D01\u660E\u4E86
1830
1853
  - \u5982\u679C\u4FEE\u6539\u8F83\u5C11\uFF0C\u53EF\u4EE5\u53EA\u5217\u51FA 2-3 \u4E2A\u4FEE\u6539\u70B9
1831
1854
  - \u4E0D\u8981\u6709\u5176\u4ED6\u89E3\u91CA\u6216\u591A\u4F59\u5185\u5BB9
1855
+ ${useEmoji ? `
1856
+ Emoji \u6620\u5C04\u89C4\u5219\uFF1A
1857
+ - feat: \u2728 (\u65B0\u529F\u80FD)
1858
+ - fix: \u{1F41B} (\u4FEE\u590DBug)
1859
+ - docs: \u{1F4DD} (\u6587\u6863)
1860
+ - style: \u{1F484} (\u4EE3\u7801\u683C\u5F0F)
1861
+ - refactor: \u267B\uFE0F (\u91CD\u6784)
1862
+ - perf: \u26A1\uFE0F (\u6027\u80FD\u4F18\u5316)
1863
+ - test: \u2705 (\u6D4B\u8BD5)
1864
+ - build: \u{1F4E6} (\u6784\u5EFA)
1865
+ - ci: \u{1F477} (CI/CD)
1866
+ - chore: \u{1F527} (\u5176\u4ED6\u6742\u9879)
1867
+ - revert: \u23EA (\u56DE\u6EDA)` : ""}
1832
1868
 
1833
1869
  \u793A\u4F8B\uFF1A
1834
- feat(auth): \u6DFB\u52A0\u7528\u6237\u767B\u5F55\u529F\u80FD
1870
+ ${useEmoji ? "\u2728 " : ""}feat(auth): \u6DFB\u52A0\u7528\u6237\u767B\u5F55\u529F\u80FD
1835
1871
 
1836
1872
  - \u5B9E\u73B0\u7528\u6237\u540D\u5BC6\u7801\u767B\u5F55\u63A5\u53E3
1837
1873
  - \u6DFB\u52A0\u767B\u5F55\u72B6\u6001\u9A8C\u8BC1\u4E2D\u95F4\u4EF6
@@ -1839,7 +1875,7 @@ feat(auth): \u6DFB\u52A0\u7528\u6237\u767B\u5F55\u529F\u80FD
1839
1875
  - \u66F4\u65B0\u7528\u6237\u8BA4\u8BC1\u76F8\u5173\u6587\u6863` : `You are a professional Git commit message generator. Generate a detailed commit message following Conventional Commits specification based on the provided git diff.
1840
1876
 
1841
1877
  Format requirements:
1842
- 1. First line: <type>(<scope>): <subject>
1878
+ 1. First line: ${useEmoji ? "<emoji> " : ""}<type>(<scope>): <subject>
1843
1879
  2. Empty line
1844
1880
  3. Detailed description: List main changes, one per line, starting with "- "
1845
1881
 
@@ -1850,9 +1886,22 @@ Rules:
1850
1886
  - Detailed description should list 3-6 main changes, each change should be concise
1851
1887
  - If changes are minimal, list 2-3 changes
1852
1888
  - No explanations or extra content
1889
+ ${useEmoji ? `
1890
+ Emoji mapping rules:
1891
+ - feat: \u2728 (new feature)
1892
+ - fix: \u{1F41B} (bug fix)
1893
+ - docs: \u{1F4DD} (documentation)
1894
+ - style: \u{1F484} (code style)
1895
+ - refactor: \u267B\uFE0F (refactoring)
1896
+ - perf: \u26A1\uFE0F (performance)
1897
+ - test: \u2705 (testing)
1898
+ - build: \u{1F4E6} (build)
1899
+ - ci: \u{1F477} (CI/CD)
1900
+ - chore: \u{1F527} (chore)
1901
+ - revert: \u23EA (revert)` : ""}
1853
1902
 
1854
1903
  Example:
1855
- feat(auth): add user login functionality
1904
+ ${useEmoji ? "\u2728 " : ""}feat(auth): add user login functionality
1856
1905
 
1857
1906
  - Implement username/password login API
1858
1907
  - Add login status validation middleware
@@ -1870,30 +1919,56 @@ ${userPrompt}`;
1870
1919
  const systemPrompt = isZh ? `\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684 Git commit message \u751F\u6210\u52A9\u624B\u3002\u8BF7\u6839\u636E\u63D0\u4F9B\u7684 git diff \u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684 commit message\u3002
1871
1920
 
1872
1921
  \u89C4\u5219\uFF1A
1873
- 1. \u683C\u5F0F\uFF1A<type>(<scope>): <subject>
1922
+ 1. \u683C\u5F0F\uFF1A${useEmoji ? "<emoji> " : ""}<type>(<scope>): <subject>
1874
1923
  2. type \u5FC5\u987B\u662F\u4EE5\u4E0B\u4E4B\u4E00\uFF1Afeat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
1875
1924
  3. scope \u662F\u53EF\u9009\u7684\uFF0C\u8868\u793A\u5F71\u54CD\u8303\u56F4
1876
1925
  4. subject \u7528\u4E2D\u6587\u63CF\u8FF0\uFF0C\u7B80\u6D01\u660E\u4E86\uFF0C\u4E0D\u8D85\u8FC7 50 \u5B57
1877
1926
  5. \u53EA\u8FD4\u56DE\u4E00\u6761 commit message\uFF0C\u5373\u4F7F\u6709\u591A\u4E2A\u6587\u4EF6\u6539\u52A8\u4E5F\u8981\u603B\u7ED3\u6210\u4E00\u6761
1878
1927
  6. \u4E0D\u8981\u6709\u5176\u4ED6\u89E3\u91CA\u6216\u591A\u4F59\u5185\u5BB9
1928
+ ${useEmoji ? `
1929
+ Emoji \u6620\u5C04\u89C4\u5219\uFF1A
1930
+ - feat: \u2728 (\u65B0\u529F\u80FD)
1931
+ - fix: \u{1F41B} (\u4FEE\u590DBug)
1932
+ - docs: \u{1F4DD} (\u6587\u6863)
1933
+ - style: \u{1F484} (\u4EE3\u7801\u683C\u5F0F)
1934
+ - refactor: \u267B\uFE0F (\u91CD\u6784)
1935
+ - perf: \u26A1\uFE0F (\u6027\u80FD\u4F18\u5316)
1936
+ - test: \u2705 (\u6D4B\u8BD5)
1937
+ - build: \u{1F4E6} (\u6784\u5EFA)
1938
+ - ci: \u{1F477} (CI/CD)
1939
+ - chore: \u{1F527} (\u5176\u4ED6\u6742\u9879)
1940
+ - revert: \u23EA (\u56DE\u6EDA)` : ""}
1879
1941
 
1880
1942
  \u793A\u4F8B\uFF1A
1881
- - feat(auth): \u6DFB\u52A0\u7528\u6237\u767B\u5F55\u529F\u80FD
1882
- - fix(api): \u4FEE\u590D\u6570\u636E\u83B7\u53D6\u5931\u8D25\u7684\u95EE\u9898
1883
- - docs(readme): \u66F4\u65B0\u5B89\u88C5\u8BF4\u660E` : `You are a professional Git commit message generator. Generate a commit message following Conventional Commits specification based on the provided git diff.
1943
+ - ${useEmoji ? "\u2728 " : ""}feat(auth): \u6DFB\u52A0\u7528\u6237\u767B\u5F55\u529F\u80FD
1944
+ - ${useEmoji ? "\u{1F41B} " : ""}fix(api): \u4FEE\u590D\u6570\u636E\u83B7\u53D6\u5931\u8D25\u7684\u95EE\u9898
1945
+ - ${useEmoji ? "\u{1F4DD} " : ""}docs(readme): \u66F4\u65B0\u5B89\u88C5\u8BF4\u660E` : `You are a professional Git commit message generator. Generate a commit message following Conventional Commits specification based on the provided git diff.
1884
1946
 
1885
1947
  Rules:
1886
- 1. Format: <type>(<scope>): <subject>
1948
+ 1. Format: ${useEmoji ? "<emoji> " : ""}<type>(<scope>): <subject>
1887
1949
  2. type must be one of: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
1888
1950
  3. scope is optional, indicates the affected area
1889
1951
  4. subject should be concise, no more than 50 characters
1890
1952
  5. Return only ONE commit message, even if multiple files are changed, summarize into one message
1891
1953
  6. No explanations or extra content
1954
+ ${useEmoji ? `
1955
+ Emoji mapping rules:
1956
+ - feat: \u2728 (new feature)
1957
+ - fix: \u{1F41B} (bug fix)
1958
+ - docs: \u{1F4DD} (documentation)
1959
+ - style: \u{1F484} (code style)
1960
+ - refactor: \u267B\uFE0F (refactoring)
1961
+ - perf: \u26A1\uFE0F (performance)
1962
+ - test: \u2705 (testing)
1963
+ - build: \u{1F4E6} (build)
1964
+ - ci: \u{1F477} (CI/CD)
1965
+ - chore: \u{1F527} (chore)
1966
+ - revert: \u23EA (revert)` : ""}
1892
1967
 
1893
1968
  Examples:
1894
- - feat(auth): add user login functionality
1895
- - fix(api): resolve data fetching failure
1896
- - docs(readme): update installation guide`;
1969
+ - ${useEmoji ? "\u2728 " : ""}feat(auth): add user login functionality
1970
+ - ${useEmoji ? "\u{1F41B} " : ""}fix(api): resolve data fetching failure
1971
+ - ${useEmoji ? "\u{1F4DD} " : ""}docs(readme): update installation guide`;
1897
1972
  const userPrompt = isZh ? `\u8BF7\u6839\u636E\u4EE5\u4E0B git diff \u751F\u6210 commit message\uFF1A
1898
1973
 
1899
1974
  ${diff}` : `Generate a commit message based on the following git diff:
@@ -2017,13 +2092,14 @@ async function generateAICommitMessage(config2) {
2017
2092
  const language = aiConfig.language || "zh-CN";
2018
2093
  const detailedDescription = aiConfig.detailedDescription !== false;
2019
2094
  const maxTokens = aiConfig.maxTokens || (detailedDescription ? 400 : 200);
2095
+ const useEmoji = aiConfig.useEmoji !== void 0 ? aiConfig.useEmoji : config2.useEmoji !== false;
2020
2096
  const diff = getGitDiff();
2021
2097
  if (!diff) {
2022
2098
  throw new Error("\u6CA1\u6709\u68C0\u6D4B\u5230\u4EE3\u7801\u66F4\u6539");
2023
2099
  }
2024
2100
  const maxDiffLength = detailedDescription ? 6e3 : 4e3;
2025
2101
  const truncatedDiff = diff.length > maxDiffLength ? diff.slice(0, maxDiffLength) + "\n..." : diff;
2026
- const prompt = buildPrompt(truncatedDiff, language, detailedDescription);
2102
+ const prompt = buildPrompt(truncatedDiff, language, detailedDescription, useEmoji);
2027
2103
  const providerInfo = AI_PROVIDERS[provider];
2028
2104
  if (!providerInfo) {
2029
2105
  throw new Error(`\u4E0D\u652F\u6301\u7684 AI \u63D0\u4F9B\u5546: ${provider}`);
@@ -2244,7 +2320,14 @@ async function commit() {
2244
2320
  }
2245
2321
  const spinner = ora4("\u6B63\u5728\u63D0\u4EA4...").start();
2246
2322
  try {
2247
- const finalStatus = parseGitStatus();
2323
+ let finalStatus = parseGitStatus();
2324
+ if (finalStatus.staged.length === 0 && finalStatus.unstaged.length > 0) {
2325
+ const autoStage = config2.autoStage ?? true;
2326
+ if (autoStage) {
2327
+ execSync5("git add -A", { stdio: "pipe" });
2328
+ finalStatus = parseGitStatus();
2329
+ }
2330
+ }
2248
2331
  if (finalStatus.staged.length === 0) {
2249
2332
  spinner.fail("\u6CA1\u6709\u6682\u5B58\u7684\u6587\u4EF6\u53EF\u4EE5\u63D0\u4EA4");
2250
2333
  console.log("");
@@ -2255,8 +2338,9 @@ async function commit() {
2255
2338
  console.log("");
2256
2339
  return;
2257
2340
  }
2258
- const escapedMessage = message.replace(/"/g, '\\"');
2259
- execSync5(`git commit -m "${escapedMessage}"`, { stdio: "pipe" });
2341
+ execSync5(`git commit -F -`, {
2342
+ input: message
2343
+ });
2260
2344
  spinner.succeed("\u63D0\u4EA4\u6210\u529F");
2261
2345
  const commitHash = execOutput("git rev-parse --short HEAD");
2262
2346
  console.log(colors.dim(`commit: ${commitHash}`));
@@ -2832,7 +2916,7 @@ process.on("SIGTERM", () => {
2832
2916
  console.log("");
2833
2917
  process.exit(0);
2834
2918
  });
2835
- var version = true ? "0.3.2" : "0.0.0-dev";
2919
+ var version = true ? "0.3.4" : "0.0.0-dev";
2836
2920
  async function mainMenu() {
2837
2921
  console.log(
2838
2922
  colors.green(`
@@ -1,43 +1,43 @@
1
1
  {
2
- "hash": "cb9fc065",
2
+ "hash": "f08de2d7",
3
3
  "configHash": "e91271f8",
4
- "lockfileHash": "eae41063",
5
- "browserHash": "fa434d50",
4
+ "lockfileHash": "f6311290",
5
+ "browserHash": "b692a8b2",
6
6
  "optimized": {
7
7
  "vue": {
8
8
  "src": "../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
9
9
  "file": "vue.js",
10
- "fileHash": "69cff841",
10
+ "fileHash": "6f2468ef",
11
11
  "needsInterop": false
12
12
  },
13
13
  "vitepress > @vue/devtools-api": {
14
14
  "src": "../../../../node_modules/@vue/devtools-api/dist/index.js",
15
15
  "file": "vitepress___@vue_devtools-api.js",
16
- "fileHash": "5ad8b965",
16
+ "fileHash": "1a2fc2f9",
17
17
  "needsInterop": false
18
18
  },
19
19
  "vitepress > @vueuse/core": {
20
20
  "src": "../../../../node_modules/@vueuse/core/index.mjs",
21
21
  "file": "vitepress___@vueuse_core.js",
22
- "fileHash": "9696f0e0",
22
+ "fileHash": "b2503aca",
23
23
  "needsInterop": false
24
24
  },
25
25
  "vitepress > @vueuse/integrations/useFocusTrap": {
26
26
  "src": "../../../../node_modules/@vueuse/integrations/useFocusTrap.mjs",
27
27
  "file": "vitepress___@vueuse_integrations_useFocusTrap.js",
28
- "fileHash": "6cc36968",
28
+ "fileHash": "d3937329",
29
29
  "needsInterop": false
30
30
  },
31
31
  "vitepress > mark.js/src/vanilla.js": {
32
32
  "src": "../../../../node_modules/mark.js/src/vanilla.js",
33
33
  "file": "vitepress___mark__js_src_vanilla__js.js",
34
- "fileHash": "08475884",
34
+ "fileHash": "9d53e58c",
35
35
  "needsInterop": false
36
36
  },
37
37
  "vitepress > minisearch": {
38
38
  "src": "../../../../node_modules/minisearch/dist/es/index.js",
39
39
  "file": "vitepress___minisearch.js",
40
- "fileHash": "1cb3d774",
40
+ "fileHash": "4ea50106",
41
41
  "needsInterop": false
42
42
  }
43
43
  },
@@ -61,8 +61,9 @@ export default defineConfig({
61
61
  { text: '概览', link: '/commands/' },
62
62
  { text: '交互式菜单', link: '/commands/interactive' },
63
63
  { text: '分支命令', link: '/commands/branch' },
64
- { text: 'Tag 命令', link: '/commands/tag' },
65
64
  { text: '提交命令', link: '/commands/commit' },
65
+ { text: '日志命令', link: '/commands/log' },
66
+ { text: 'Tag 命令', link: '/commands/tag' },
66
67
  { text: 'Stash 命令', link: '/commands/stash' },
67
68
  { text: '版本命令', link: '/commands/release' },
68
69
  { text: '配置命令', link: '/commands/config' },
@@ -0,0 +1,248 @@
1
+ # gw help - 帮助命令
2
+
3
+ `gw help` 命令提供了完整的命令帮助信息和使用指南。
4
+
5
+ ## 🎯 功能特性
6
+
7
+ - 📋 **命令列表** - 显示所有可用命令及其描述
8
+ - 🔍 **详细说明** - 每个命令的具体用法和参数
9
+ - 💡 **使用示例** - 实际的命令使用示例
10
+ - ⌨️ **快捷键** - 交互式界面的键盘操作
11
+ - 🔗 **相关链接** - 文档链接和更多资源
12
+
13
+ ## 📋 命令格式
14
+
15
+ ```bash
16
+ # 显示帮助信息
17
+ gw help
18
+ gw --help
19
+ gw -h
20
+
21
+ # 显示特定命令的帮助
22
+ gw help <command>
23
+ gw <command> --help
24
+ gw <command> -h
25
+ ```
26
+
27
+ ## 🎨 帮助界面
28
+
29
+ ### 主帮助页面
30
+
31
+ ```bash
32
+ gw help
33
+ ```
34
+
35
+ ```
36
+ Git Workflow v0.3.2 - 极简的 Git 工作流 CLI 工具
37
+
38
+ 用法:
39
+ gw [command] [options]
40
+
41
+ 核心命令:
42
+ gw 显示交互式菜单
43
+ gw f, feat 创建 feature 分支
44
+ gw h, hotfix 创建 hotfix 分支
45
+ gw c, commit 提交代码(支持 AI 生成)
46
+ gw log, ls, l 查看提交历史(GitHub 风格)
47
+ gw t, tag 创建版本标签
48
+ gw d, delete 删除分支
49
+ gw s, stash 管理 stash
50
+
51
+ 辅助命令:
52
+ gw r, release 发布版本
53
+ gw ts, tags 列出标签
54
+ gw td 删除标签
55
+ gw tu 修改标签
56
+ gw init 初始化配置
57
+ gw upt, update 更新工具
58
+
59
+ 全局选项:
60
+ -h, --help 显示帮助信息
61
+ -v, --version 显示版本号
62
+ --config 指定配置文件路径
63
+ --no-emoji 禁用 emoji 显示
64
+
65
+ 示例:
66
+ gw # 显示交互式菜单
67
+ gw f # 创建 feature 分支
68
+ gw c # AI 智能提交
69
+ gw log # 查看提交历史
70
+ gw t v # 创建 v 前缀的标签
71
+
72
+ 更多信息:
73
+ 文档: https://iamzjt-front-end.github.io/git-workflow/
74
+ 问题: https://github.com/iamzjt-front-end/git-workflow/issues
75
+ ```
76
+
77
+ ### 特定命令帮助
78
+
79
+ ```bash
80
+ gw help commit
81
+ # 或
82
+ gw c --help
83
+ ```
84
+
85
+ ```
86
+ gw commit - 提交代码
87
+
88
+ 用法:
89
+ gw c [options]
90
+ gw commit [options]
91
+
92
+ 描述:
93
+ 交互式提交代码,支持 AI 自动生成 commit message
94
+
95
+ 选项:
96
+ -m, --message <msg> 直接指定 commit message
97
+ --ai 强制使用 AI 生成
98
+ --manual 强制手动输入
99
+ --no-verify 跳过 pre-commit 钩子
100
+ --amend 修改上次提交
101
+ -h, --help 显示帮助信息
102
+
103
+ 示例:
104
+ gw c # 交互式选择提交方式
105
+ gw c --ai # 直接使用 AI 生成
106
+ gw c -m "fix: bug" # 直接提交指定消息
107
+ gw c --amend # 修改上次提交
108
+
109
+ 相关命令:
110
+ gw log # 查看提交历史
111
+ gw s # 管理 stash
112
+ ```
113
+
114
+ ## 📚 命令分类帮助
115
+
116
+ ### 分支管理
117
+
118
+ ```bash
119
+ gw help branch
120
+ ```
121
+
122
+ 显示所有分支相关命令的帮助:
123
+ - `gw f` - 创建 feature 分支
124
+ - `gw h` - 创建 hotfix 分支
125
+ - `gw d` - 删除分支
126
+
127
+ ### 版本管理
128
+
129
+ ```bash
130
+ gw help tag
131
+ ```
132
+
133
+ 显示所有标签相关命令的帮助:
134
+ - `gw t` - 创建标签
135
+ - `gw ts` - 列出标签
136
+ - `gw td` - 删除标签
137
+ - `gw tu` - 修改标签
138
+
139
+ ### 提交管理
140
+
141
+ ```bash
142
+ gw help commit
143
+ ```
144
+
145
+ 显示所有提交相关命令的帮助:
146
+ - `gw c` - 提交代码
147
+ - `gw log` - 查看历史
148
+
149
+ ## 🔍 在线帮助
150
+
151
+ ### 快速查找
152
+
153
+ 如果不确定使用哪个命令,可以:
154
+
155
+ 1. **运行交互式菜单**
156
+ ```bash
157
+ gw
158
+ ```
159
+
160
+ 2. **查看完整帮助**
161
+ ```bash
162
+ gw help
163
+ ```
164
+
165
+ 3. **搜索特定功能**
166
+ ```bash
167
+ gw help | grep "分支"
168
+ ```
169
+
170
+ ### 详细文档
171
+
172
+ 每个命令都有详细的在线文档:
173
+
174
+ - [命令概览](/commands/) - 所有命令的快速参考
175
+ - [分支命令](/commands/branch) - 分支管理详细指南
176
+ - [提交命令](/commands/commit) - 提交和 AI 功能
177
+ - [日志命令](/commands/log) - 提交历史查看
178
+ - [标签命令](/commands/tag) - 版本标签管理
179
+ - [Stash 命令](/commands/stash) - 代码暂存管理
180
+
181
+ ## ⌨️ 交互式帮助
182
+
183
+ 在任何交互式界面中,都可以使用以下快捷键获取帮助:
184
+
185
+ | 快捷键 | 功能 |
186
+ |--------|------|
187
+ | `h` / `?` | 显示当前界面的帮助 |
188
+ | `Ctrl+H` | 显示全局帮助 |
189
+ | `F1` | 显示详细帮助 |
190
+ | `Esc` | 返回上级菜单 |
191
+
192
+ ## 🛠️ 故障排除
193
+
194
+ ### 常见问题
195
+
196
+ **Q: 命令不存在或无法识别?**
197
+ ```bash
198
+ # 检查安装
199
+ npm list -g @zjex/git-workflow
200
+
201
+ # 重新安装
202
+ npm install -g @zjex/git-workflow@latest
203
+ ```
204
+
205
+ **Q: 帮助信息显示不完整?**
206
+ ```bash
207
+ # 调整终端窗口大小
208
+ # 或使用分页查看
209
+ gw help | less
210
+ ```
211
+
212
+ **Q: 中文显示乱码?**
213
+ ```bash
214
+ # 检查终端编码设置
215
+ echo $LANG
216
+
217
+ # 设置 UTF-8 编码
218
+ export LANG=zh_CN.UTF-8
219
+ ```
220
+
221
+ ### 获取支持
222
+
223
+ 如果遇到问题,可以通过以下方式获取帮助:
224
+
225
+ 1. **查看详细日志**
226
+ ```bash
227
+ DEBUG=gw:* gw <command>
228
+ ```
229
+
230
+ 2. **检查配置**
231
+ ```bash
232
+ gw init --show-config
233
+ ```
234
+
235
+ 3. **提交问题**
236
+ - [GitHub Issues](https://github.com/iamzjt-front-end/git-workflow/issues)
237
+ - [讨论区](https://github.com/iamzjt-front-end/git-workflow/discussions)
238
+
239
+ ## 📖 更多资源
240
+
241
+ - 📚 [完整文档](https://iamzjt-front-end.github.io/git-workflow/)
242
+ - 🎥 [视频教程](https://github.com/iamzjt-front-end/git-workflow#videos)
243
+ - 💡 [最佳实践](https://github.com/iamzjt-front-end/git-workflow/wiki)
244
+ - 🔄 [更新日志](https://github.com/iamzjt-front-end/git-workflow/blob/main/CHANGELOG.md)
245
+
246
+ ---
247
+
248
+ 通过 `gw help` 命令,你可以随时获取最新的使用指南和帮助信息。如果有任何疑问,不要犹豫,直接查看帮助或访问在线文档。
@@ -12,6 +12,7 @@ Git Workflow 提供了一套简洁而强大的命令,涵盖了 Git 工作流
12
12
  | `gw f` | `feat`, `feature` | 创建 feature 分支 | `gw f --base develop` |
13
13
  | `gw h` | `fix`, `hotfix` | 创建 hotfix 分支 | `gw h` |
14
14
  | `gw c` | `cm`, `commit` | 提交代码(AI 模式) | `gw c` |
15
+ | `gw log`| `ls`, `l` | 查看提交历史 | `gw log` |
15
16
  | `gw t` | `tag` | 创建 tag | `gw t v` |
16
17
  | `gw d` | `del`, `delete` | 删除分支 | `gw d feature/old` |
17
18
  | `gw s` | `st`, `stash` | 管理 stash | `gw s` |
@@ -54,13 +55,14 @@ gw
54
55
  [2] 🐛 创建 hotfix 分支 gw h
55
56
  [3] 🗑️ 删除分支 gw d
56
57
  [4] 📝 提交代码 gw c
57
- [5] 🏷️ 创建 tag gw t
58
- [6] 🗑️ 删除 tag gw td
59
- [7] ✏️ 修改 tag gw tu
60
- [8] 📋 列出 tags gw ts
61
- [9] 📦 发布版本 gw r
62
- [a] 💾 管理 stash gw s
63
- [b] ⚙️ 初始化配置 gw init
58
+ [5] 📋 查看提交历史 gw log
59
+ [6] 🏷️ 创建 tag gw t
60
+ [7] 🗑️ 删除 tag gw td
61
+ [8] ✏️ 修改 tag gw tu
62
+ [9] 📋 列出 tags gw ts
63
+ [a] 📦 发布版本 gw r
64
+ [b] 💾 管理 stash gw s
65
+ [c] ⚙️ 初始化配置 gw init
64
66
  [0] ❓ 帮助
65
67
  [q] 退出
66
68
  ```
@@ -179,6 +181,7 @@ DEBUG=gw:* gw c
179
181
  处理代码提交和提交信息:
180
182
 
181
183
  - [**gw c**](/commands/commit) - 交互式提交(支持 AI 生成)
184
+ - [**gw log**](/commands/log) - 查看 Git 提交历史(GitHub 风格)
182
185
 
183
186
  ### 版本管理
184
187
 
@@ -268,12 +271,14 @@ gw d
268
271
 
269
272
  - [**交互式菜单**](/commands/interactive) - 了解主菜单的所有功能
270
273
  - [**分支命令**](/commands/branch) - 掌握分支管理的最佳实践
271
- - [**Tag 命令**](/commands/tag) - 学习版本标签的高级用法
272
274
  - [**提交命令**](/commands/commit) - 深入了解 AI 提交和手动提交
275
+ - [**日志命令**](/commands/log) - GitHub 风格的提交历史查看
276
+ - [**Tag 命令**](/commands/tag) - 学习版本标签的高级用法
273
277
  - [**Stash 命令**](/commands/stash) - 高效管理代码暂存
274
278
  - [**版本命令**](/commands/release) - 自动化版本发布流程
275
279
  - [**配置命令**](/commands/config) - 自定义工具行为
276
280
  - [**更新命令**](/commands/update) - 保持工具最新状态
281
+ - [**帮助命令**](/commands/help) - 获取详细的使用帮助和故障排除
277
282
 
278
283
  ## 🔍 命令查找
279
284
 
@@ -283,6 +288,7 @@ gw d
283
288
 
284
289
  - **我想创建分支** → `gw f` (feature) 或 `gw h` (hotfix)
285
290
  - **我想提交代码** → `gw c` (commit)
291
+ - **我想查看历史** → `gw log` (log)
286
292
  - **我想创建版本** → `gw t` (tag) 或 `gw r` (release)
287
293
  - **我想删除分支** → `gw d` (delete)
288
294
  - **我想管理 stash** → `gw s` (stash)
@@ -294,6 +300,7 @@ gw d
294
300
  - **开始新功能** → `gw f`
295
301
  - **修复紧急 Bug** → `gw h`
296
302
  - **提交当前更改** → `gw c`
303
+ - **查看项目历史** → `gw log`
297
304
  - **发布新版本** → `gw r` + `gw t`
298
305
  - **清理旧分支** → `gw d`
299
306
  - **暂存当前工作** → `gw s`