taiwan-invoice-skill 2.4.3 → 2.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.
package/README.md CHANGED
@@ -76,7 +76,17 @@ taiwan-invoice update # 檢查更新
76
76
  ```bash
77
77
  taiwan-invoice init --offline # 跳過 GitHub 下載,使用內建資源
78
78
  taiwan-invoice init --force # 覆蓋現有檔案
79
- taiwan-invoice init --global # 安裝到全域目錄
79
+ taiwan-invoice init --global # 安裝到全域目錄(所有專案共用)
80
+ ```
81
+
82
+ ### 全域安裝
83
+
84
+ 使用 `--global` 可將技能安裝到使用者目錄,讓所有專案都能使用:
85
+
86
+ ```bash
87
+ taiwan-invoice init --ai cursor --global # ~/.cursor/skills/taiwan-invoice/
88
+ taiwan-invoice init --ai claude --global # ~/.claude/skills/taiwan-invoice/
89
+ taiwan-invoice init --ai antigravity --global # ~/.gemini/antigravity/global_skills/taiwan-invoice/
80
90
  ```
81
91
 
82
92
  ---
@@ -5,7 +5,8 @@
5
5
  "folderStructure": {
6
6
  "root": ".agent",
7
7
  "skillPath": "skills/taiwan-invoice",
8
- "filename": "SKILL.md"
8
+ "filename": "SKILL.md",
9
+ "globalRoot": "~/.gemini/antigravity/global_skills"
9
10
  },
10
11
  "scriptPath": "skills/taiwan-invoice/scripts",
11
12
  "frontmatter": {
@@ -5,7 +5,8 @@
5
5
  "folderStructure": {
6
6
  "root": ".claude",
7
7
  "skillPath": "skills/taiwan-invoice",
8
- "filename": "SKILL.md"
8
+ "filename": "SKILL.md",
9
+ "globalRoot": "~/.claude"
9
10
  },
10
11
  "scriptPath": "skills/taiwan-invoice/scripts",
11
12
  "frontmatter": {
@@ -5,7 +5,8 @@
5
5
  "folderStructure": {
6
6
  "root": ".codex",
7
7
  "skillPath": "skills/taiwan-invoice",
8
- "filename": "SKILL.md"
8
+ "filename": "SKILL.md",
9
+ "globalRoot": "~/.codex"
9
10
  },
10
11
  "scriptPath": "skills/taiwan-invoice/scripts",
11
12
  "frontmatter": {
@@ -5,7 +5,8 @@
5
5
  "folderStructure": {
6
6
  "root": ".cursor",
7
7
  "skillPath": "skills/taiwan-invoice",
8
- "filename": "SKILL.md"
8
+ "filename": "SKILL.md",
9
+ "globalRoot": "~/.cursor"
9
10
  },
10
11
  "scriptPath": "skills/taiwan-invoice/scripts",
11
12
  "frontmatter": {
package/dist/index.js CHANGED
@@ -15940,154 +15940,29 @@ async function copyTaiwanInvoiceAssets(targetSkillDir, sections) {
15940
15940
  await (0, import_promises.cp)((0, import_node_path.join)(sourceDir, "data"), dataTarget, { recursive: true });
15941
15941
  }
15942
15942
  }
15943
- async function renderWorkflowFile(config) {
15944
- const frontmatter = renderFrontmatter(config.frontmatter);
15945
- const sharedPath = config.folderStructure.sharedPath || "taiwan-invoice";
15946
- const content = `# ${config.title}
15947
-
15948
- ${config.description}
15949
-
15950
- ## Prerequisites
15951
-
15952
- Check if Python is installed:
15953
-
15954
- \`\`\`bash
15955
- python3 --version || python --version
15956
- \`\`\`
15957
-
15958
- ---
15959
-
15960
- ## How to Use This Workflow
15961
-
15962
- When user requests Taiwan E-Invoice work (issue, void, allowance, print, query), follow this workflow:
15963
-
15964
- ### Step 1: Analyze User Requirements
15965
-
15966
- Extract key information:
15967
- - **Provider**: ECPay, SmilePay, or Amego
15968
- - **Invoice type**: B2C (\u4E8C\u806F\u5F0F) or B2B (\u4E09\u806F\u5F0F)
15969
- - **Operation**: issue, void, allowance, print, query
15970
-
15971
- ### Step 2: Recommend Provider (Optional)
15972
-
15973
- \`\`\`bash
15974
- python3 .shared/${sharedPath}/scripts/recommend.py "<keywords>"
15975
- \`\`\`
15976
-
15977
- Example:
15978
- \`\`\`bash
15979
- python3 .shared/${sharedPath}/scripts/recommend.py "\u96FB\u5546 \u9AD8\u4EA4\u6613\u91CF \u7A69\u5B9A"
15980
- \`\`\`
15981
-
15982
- ### Step 3: Search for Information
15983
-
15984
- \`\`\`bash
15985
- python3 .shared/${sharedPath}/scripts/search.py "<keyword>" --domain <domain>
15986
- \`\`\`
15987
-
15988
- Available domains:
15989
- | Domain | Description |
15990
- |--------|-------------|
15991
- | provider | Provider comparison |
15992
- | operation | API endpoints |
15993
- | error | Error codes |
15994
- | field | Field mappings |
15995
- | tax | Tax rules |
15996
- | troubleshoot | Troubleshooting |
15997
-
15998
- ### Step 4: Generate Service Code
15999
-
16000
- \`\`\`bash
16001
- python3 .shared/${sharedPath}/scripts/generate-invoice-service.py <Provider> --output ts
16002
- \`\`\`
16003
-
16004
- ### Step 5: Initialize Project Config (Optional)
16005
-
16006
- \`\`\`bash
16007
- python3 .shared/${sharedPath}/scripts/persist.py init <Provider>
16008
- \`\`\`
16009
-
16010
- ---
16011
-
16012
- ## Quick Reference
16013
-
16014
- ### B2C Invoice (\u4E8C\u806F\u5F0F)
16015
- - Amount: **Tax-inclusive**
16016
- - BuyerIdentifier: \`0000000000\`
16017
- - TaxAmount: \`0\`
16018
- - Can use carrier/donation
16019
-
16020
- ### B2B Invoice (\u4E09\u806F\u5F0F)
16021
- - Amount: **Tax-exclusive**
16022
- - Must fill 8-digit tax ID
16023
- - Calculate tax: \`TaxAmount = round(Total - Total/1.05)\`
16024
- - **Cannot** use carrier/donation
16025
-
16026
- ---
16027
-
16028
- ## Test Credentials
16029
-
16030
- ### ECPay
16031
- \`\`\`
16032
- MerchantID: 2000132
16033
- HashKey: ejCk326UnaZWKisg
16034
- HashIV: q9jcZX8Ib9LM8wYk
16035
- \`\`\`
16036
-
16037
- ### SmilePay
16038
- \`\`\`
16039
- Grvc: SEI1000034
16040
- Verify_key: 9D73935693EE0237FABA6AB744E48661
16041
- \`\`\`
16042
-
16043
- ### Amego
16044
- \`\`\`
16045
- Invoice: 12345678
16046
- App Key: sHeq7t8G1wiQvhAuIM27
16047
- \`\`\`
16048
-
16049
- ---
16050
-
16051
- *Generated by Taiwan Invoice Skill*
16052
- `;
16053
- return frontmatter + content;
16054
- }
16055
- async function generatePlatformFiles(targetDir, aiType) {
15943
+ async function generatePlatformFiles(targetDir, aiType, isGlobal = false) {
16056
15944
  const config = await loadPlatformConfig(aiType);
16057
15945
  const createdFolders = [];
16058
- if (config.installType === "workflow") {
16059
- const workflowDir = (0, import_node_path.join)(
15946
+ let skillDir;
15947
+ if (isGlobal) {
15948
+ let skillPath = config.folderStructure.skillPath;
15949
+ if (config.folderStructure.globalRoot?.includes("global_skills")) {
15950
+ skillPath = skillPath.replace(/^skills\//, "");
15951
+ }
15952
+ skillDir = (0, import_node_path.join)(targetDir, skillPath);
15953
+ createdFolders.push(targetDir);
15954
+ } else {
15955
+ skillDir = (0, import_node_path.join)(
16060
15956
  targetDir,
16061
15957
  config.folderStructure.root,
16062
15958
  config.folderStructure.skillPath
16063
15959
  );
16064
- await (0, import_promises.mkdir)(workflowDir, { recursive: true });
16065
- const workflowContent = await renderWorkflowFile(config);
16066
- const workflowFilePath = (0, import_node_path.join)(workflowDir, config.folderStructure.filename);
16067
- await (0, import_promises.writeFile)(workflowFilePath, workflowContent, "utf-8");
16068
15960
  createdFolders.push(config.folderStructure.root);
16069
- if (config.folderStructure.sharedRoot && config.folderStructure.sharedPath) {
16070
- const sharedDir = (0, import_node_path.join)(
16071
- targetDir,
16072
- config.folderStructure.sharedRoot,
16073
- config.folderStructure.sharedPath
16074
- );
16075
- await (0, import_promises.mkdir)(sharedDir, { recursive: true });
16076
- await copyTaiwanInvoiceAssets(sharedDir, config.sections);
16077
- createdFolders.push(config.folderStructure.sharedRoot);
16078
- }
16079
- return createdFolders;
16080
15961
  }
16081
- const skillDir = (0, import_node_path.join)(
16082
- targetDir,
16083
- config.folderStructure.root,
16084
- config.folderStructure.skillPath
16085
- );
16086
15962
  await (0, import_promises.mkdir)(skillDir, { recursive: true });
16087
15963
  const skillContent = await renderSkillFile(config);
16088
15964
  const skillFilePath = (0, import_node_path.join)(skillDir, config.folderStructure.filename);
16089
15965
  await (0, import_promises.writeFile)(skillFilePath, skillContent, "utf-8");
16090
- createdFolders.push(config.folderStructure.root);
16091
15966
  await copyTaiwanInvoiceAssets(skillDir, config.sections);
16092
15967
  return createdFolders;
16093
15968
  }
@@ -16484,15 +16359,29 @@ async function initCommand(options) {
16484
16359
  }
16485
16360
  aiType = response.aiType;
16486
16361
  }
16487
- logger.info(`Installing for: ${import_chalk3.default.cyan(getAITypeDescription(aiType))}`);
16488
- const cwd = process.cwd();
16362
+ let targetDir = process.cwd();
16363
+ if (options.global && aiType !== "all") {
16364
+ try {
16365
+ const config = await loadPlatformConfig(aiType);
16366
+ if (config.folderStructure.globalRoot) {
16367
+ const globalRoot = config.folderStructure.globalRoot.replace(/^~/, os.homedir());
16368
+ targetDir = globalRoot;
16369
+ logger.info(`Installing globally to: ${import_chalk3.default.cyan(targetDir)}`);
16370
+ } else {
16371
+ logger.warn(`Global installation not supported for ${aiType}, using project directory`);
16372
+ }
16373
+ } catch {
16374
+ logger.warn("Failed to load platform config, using project directory");
16375
+ }
16376
+ }
16377
+ logger.info(`Installing for: ${import_chalk3.default.cyan(getAITypeDescription(aiType))}${options.global ? " (global)" : ""}`);
16489
16378
  let copiedFolders = [];
16490
16379
  let usedGitHub = false;
16491
16380
  try {
16492
16381
  if (!options.offline && aiType !== "all") {
16493
16382
  const progress = new InstallProgress(INSTALL_STEPS);
16494
16383
  progress.start();
16495
- const result = await tryGitHubDownload(aiType, cwd, progress);
16384
+ const result = await tryGitHubDownload(aiType, targetDir, progress);
16496
16385
  if (result.success) {
16497
16386
  copiedFolders = result.folders;
16498
16387
  usedGitHub = true;
@@ -16508,9 +16397,9 @@ async function initCommand(options) {
16508
16397
  await animatedDelay(300);
16509
16398
  progress.nextStep();
16510
16399
  if (aiType === "all") {
16511
- copiedFolders = await generateAllPlatformFiles(cwd);
16400
+ copiedFolders = await generateAllPlatformFiles(targetDir);
16512
16401
  } else {
16513
- copiedFolders = await generatePlatformFiles(cwd, aiType);
16402
+ copiedFolders = await generatePlatformFiles(targetDir, aiType, options.global);
16514
16403
  }
16515
16404
  progress.nextStep();
16516
16405
  await animatedDelay(200);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taiwan-invoice-skill",
3
- "version": "2.4.3",
3
+ "version": "2.5.0",
4
4
  "description": "CLI to install Taiwan E-Invoice skill for AI coding assistants",
5
5
  "bin": {
6
6
  "taiwan-invoice": "./dist/index.js"