@moon791017/neo-skills 1.0.17 → 1.0.19

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
@@ -92,13 +92,29 @@ npx -p @moon791017/neo-skills install-copilot-skills
92
92
  npx -p @moon791017/neo-skills install-codex-skills
93
93
  ```
94
94
 
95
+ ### 安裝至指定專案
96
+
97
+ Claude Code、Copilot CLI、Codex CLI 三種安裝指令皆支援 `--project-path` 參數,可將技能安裝至指定專案目錄。技能子目錄會自動附加:
98
+
99
+ ```bash
100
+ # 安裝至 /my/project/.claude/skills
101
+ npx -p @moon791017/neo-skills install-claude-skills --project-path /my/project
102
+
103
+ # 安裝至 /my/project/.github/skills
104
+ npx -p @moon791017/neo-skills install-copilot-skills --project-path /my/project
105
+
106
+ # 安裝至 /my/project/.codex/skills
107
+ npx -p @moon791017/neo-skills install-codex-skills --project-path /my/project
108
+ ```
109
+
110
+ 若未指定 `--project-path`,則安裝至全域路徑(`~/.claude/skills`、`~/.copilot/skills`、`~/.codex/skills`)。
111
+
95
112
  ### 安裝全部AI Agent技能
96
113
 
97
114
  ```bash
98
115
  npx -p @moon791017/neo-skills install-skills
99
116
  ```
100
117
 
101
-
102
118
  ## 💡 常用指令範例
103
119
 
104
120
  您可以直接對 AI 代理下達以下指令或在對話中描述需求:
@@ -113,7 +129,6 @@ npx -p @moon791017/neo-skills install-skills
113
129
  | **生成 C# Interface** | `幫我針對這個 class 產生介面` 或 `/neo:dotnet-gen-interface` |
114
130
  | **技術解析與架構洞察** | `分析這個專案的架構` 或 `/neo:explain` |
115
131
 
116
-
117
132
  ## 🛠 開發指南
118
133
 
119
134
  本專案使用 **Bun** 進行開發與建置。
package/bin/_utils.js CHANGED
@@ -19,30 +19,49 @@ const sourceDir = join(packageRoot, 'skills');
19
19
  /**
20
20
  * Agent 設定中心 — 所有 agent 的安裝參數集中管理於此。
21
21
  * key 須與檔名 install-{key}-skills.js 一致。
22
+ *
23
+ * 各欄位說明:
24
+ * name — 顯示用名稱,用於 CLI 輸出的 log 標籤。
25
+ * homePath — 全域安裝路徑(相對於 $HOME)。未指定 --project-path 時使用。
26
+ * projectPath — (選填)專案安裝路徑(相對於 --project-path)。
27
+ * 指定 --project-path 且此欄位有值時,優先使用此路徑取代 homePath。
28
+ * 例如 Copilot:全域 ~/.copilot/skills,專案 <project>/.github/skills。
29
+ * hint — 安裝成功後顯示的提示訊息。
22
30
  */
23
31
  export const AGENTS = {
24
32
  claude: {
25
33
  name: 'Claude',
26
- targetSubDir: '.claude/skills',
34
+ homePath: '.claude/skills',
27
35
  hint: '請確保您的 Claude Desktop 或相關插件已指向此目錄。',
28
36
  },
29
37
  copilot: {
30
38
  name: 'Copilot',
31
- targetSubDir: '.copilot/skills',
39
+ homePath: '.copilot/skills',
40
+ projectPath: '.github/skills',
32
41
  hint: '請確保您的 GitHub Copilot CLI 已指向此目錄。',
33
42
  },
34
43
  codex: {
35
44
  name: 'Codex',
36
- targetSubDir: '.codex/skills',
45
+ homePath: '.codex/skills',
37
46
  hint: '請確保您的 Codex CLI 已指向此目錄。',
38
47
  },
39
48
  // gemini: {
40
49
  // name: 'Gemini',
41
- // targetSubDir: '.gemini/skills/neo-skills',
50
+ // homePath: '.gemini/skills/neo-skills',
42
51
  // hint: '請確保您的 Gemini CLI 已指向此目錄。',
43
52
  // },
44
53
  };
45
54
 
55
+ /**
56
+ * 從 CLI 參數解析 --project-path 值
57
+ * @returns {string | undefined}
58
+ */
59
+ function parseProjectPath() {
60
+ const idx = process.argv.indexOf('--project-path');
61
+ if (idx === -1 || idx + 1 >= process.argv.length) return undefined;
62
+ return process.argv[idx + 1];
63
+ }
64
+
46
65
  /**
47
66
  * 從檔名解析 agent key: install-{key}-skills.js → key
48
67
  */
@@ -54,9 +73,25 @@ function extractAgentKey(importMetaUrl) {
54
73
  }
55
74
 
56
75
  /**
57
- * 根據 agent config 建立 installer 函式
76
+ * 根據 agent config 建立 installer 函式。
77
+ *
78
+ * 路徑解析邏輯:
79
+ * 1. 決定根目錄 (baseDir):
80
+ * - 有 --project-path → 使用者指定的絕對路徑
81
+ * - 無 --project-path → $HOME
82
+ * 2. 決定子目錄 (subDir):
83
+ * - 有 --project-path 且 config 定義了 projectPath → 使用 projectPath
84
+ * - 其餘情況 → 使用 homePath
85
+ * 3. 最終安裝路徑 = baseDir + subDir
86
+ *
87
+ * 範例(以 Copilot 為例):
88
+ * 預設: ~/.copilot/skills (homedir + homePath)
89
+ * --project-path /my/project: /my/project/.github/skills (targetPath + projectPath)
90
+ *
91
+ * @param {object} config - AGENTS 中的 agent 設定物件
92
+ * @param {string} [targetPath] - 使用者透過 --project-path 指定的自訂根目錄
58
93
  */
59
- export function createInstaller({ name: agentName, targetSubDir, hint }) {
94
+ export function createInstaller({ name: agentName, homePath, projectPath, hint }, targetPath) {
60
95
  return async function install() {
61
96
  console.log(`🚀 [${agentName}] 開始同步 Neo Skills...`);
62
97
 
@@ -68,7 +103,11 @@ export function createInstaller({ name: agentName, targetSubDir, hint }) {
68
103
  return { success: false, message: msg };
69
104
  }
70
105
 
71
- const targetSkillsDir = join(homedir(), targetSubDir);
106
+ // 根目錄:--project-path 優先,否則 $HOME
107
+ const baseDir = targetPath ? resolve(targetPath) : homedir();
108
+ // 子目錄:專案層級有獨立路徑時採用 projectPath,否則用預設的 homePath
109
+ const subDir = targetPath && projectPath ? projectPath : homePath;
110
+ const targetSkillsDir = join(baseDir, subDir);
72
111
 
73
112
  console.log(`📁 來源路徑: ${sourceDir}`);
74
113
  console.log(`🎯 目標路徑: ${targetSkillsDir}`);
@@ -92,7 +131,8 @@ export function createInstaller({ name: agentName, targetSubDir, hint }) {
92
131
  return { success: true, message: '沒有任何檔案被複製' };
93
132
  }
94
133
 
95
- const msg = `已同步 ${copyCount} 個檔案/資料夾至 ${targetSubDir}`;
134
+ const displayPath = targetPath || homePath;
135
+ const msg = `已同步 ${copyCount} 個檔案/資料夾至 ${displayPath}`;
96
136
  console.log(`✅ [${agentName}] 安裝成功!${msg}`);
97
137
  if (hint) console.log(`💡 提示: ${hint}`);
98
138
  return { success: true, message: msg };
@@ -102,12 +142,13 @@ export function createInstaller({ name: agentName, targetSubDir, hint }) {
102
142
  /**
103
143
  * 從呼叫端的檔名自動解析 agent,建立對應的 installer。
104
144
  * @param {string} importMetaUrl - 呼叫端的 import.meta.url
145
+ * @param {string} [targetPath] - 使用者透過 --project-path 指定的自訂路徑
105
146
  */
106
- export function createInstallerFromFile(importMetaUrl) {
147
+ export function createInstallerFromFile(importMetaUrl, targetPath) {
107
148
  const key = extractAgentKey(importMetaUrl);
108
149
  const config = AGENTS[key];
109
150
  if (!config) throw new Error(`未知的 agent: "${key}"。請在 _utils.js 的 AGENTS 中註冊。`);
110
- return createInstaller(config);
151
+ return createInstaller(config, targetPath);
111
152
  }
112
153
 
113
154
  /**
@@ -137,7 +178,12 @@ export function runAsMain(installFn, callerUrl) {
137
178
  process.exit(1);
138
179
  });
139
180
 
140
- installFn().then((result) => {
181
+ const targetPath = parseProjectPath();
182
+ const actualInstallFn = targetPath
183
+ ? createInstallerFromFile(callerUrl, targetPath)
184
+ : installFn;
185
+
186
+ actualInstallFn().then((result) => {
141
187
  if (!result.success) process.exit(1);
142
188
  }).catch((error) => {
143
189
  console.error(`❌ [${agentName}] 安裝失敗:`, error.message || error);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "neo-skills",
3
3
  "description": "A universal capability extension for Gemini CLI",
4
- "version": "0.46.4",
4
+ "version": "0.47.1",
5
5
  "mcpServers": {
6
6
  "neo-skills": {
7
7
  "command": "node",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon791017/neo-skills",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "type": "module",
5
5
  "description": "Neo Skills: A Universal Expert Agent Extension",
6
6
  "homepage": "https://neo-blog-iota.vercel.app/",