luminae-helper 1.0.1 → 1.0.2
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/CHANGELOG.md +1 -1
- package/README.md +4 -4
- package/package.json +1 -1
- package/scripts/fetch-skills.js +4 -3
- package/src/lib/constants.js +1 -48
package/CHANGELOG.md
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
## 0.0.12
|
|
4
4
|
|
|
5
5
|
- Split the public CLI engine into its own `luminae-helper` repository.
|
|
6
|
-
- Load public command/skill content from `evenweiss/ai-
|
|
6
|
+
- Load public command/skill content from `evenweiss/ai-skills` at build time.
|
|
7
7
|
- Export `runCli()` so wrapper packages can reuse the CLI engine with their own bundled content.
|
package/README.md
CHANGED
|
@@ -122,14 +122,14 @@ npm uninstall -g luminae-helper
|
|
|
122
122
|
|
|
123
123
|
### 同步公共技能
|
|
124
124
|
|
|
125
|
-
`commands/` 和 `skills/` 是构建产物(gitignored)。本地开发时,保持 `ai-
|
|
125
|
+
`commands/` 和 `skills/` 是构建产物(gitignored)。本地开发时,保持 `ai-skills` 为同级目录或设置环境变量:
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
|
-
git clone https://github.com/evenweiss/ai-
|
|
129
|
-
LUMINAE_SKILLS_SOURCE=../ai-
|
|
128
|
+
git clone https://github.com/evenweiss/ai-skills.git ../ai-skills
|
|
129
|
+
LUMINAE_SKILLS_SOURCE=../ai-skills npm run sync-skills
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
脚本会扫描 `ai-
|
|
132
|
+
脚本会扫描 `ai-skills/commands/` 和 `ai-skills/skills/`,将包含 `SKILL.md` 的子目录复制到本项目的对应目录。
|
|
133
133
|
|
|
134
134
|
### 发布
|
|
135
135
|
|
package/package.json
CHANGED
package/scripts/fetch-skills.js
CHANGED
|
@@ -7,8 +7,8 @@ import { tmpdir } from "node:os";
|
|
|
7
7
|
const strict = process.argv.includes("--strict");
|
|
8
8
|
const scriptDir = import.meta.dirname;
|
|
9
9
|
const packageRoot = join(scriptDir, "..");
|
|
10
|
-
const sourceRepo = process.env.LUMINAE_SKILLS_SOURCE || join(packageRoot, "..", "ai-
|
|
11
|
-
const remote = process.env.LUMINAE_SKILLS_REPO || "https://github.com/evenweiss/ai-
|
|
10
|
+
const sourceRepo = process.env.LUMINAE_SKILLS_SOURCE || join(packageRoot, "..", "ai-skills");
|
|
11
|
+
const remote = process.env.LUMINAE_SKILLS_REPO || "https://github.com/evenweiss/ai-skills.git";
|
|
12
12
|
const copyDirs = ["commands", "skills"];
|
|
13
13
|
const skip = new Set(["node_modules", ".git", ".DS_Store", "Thumbs.db"]);
|
|
14
14
|
|
|
@@ -32,13 +32,14 @@ function copyDir(from, to) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function resolveSource() {
|
|
35
|
-
|
|
35
|
+
// 优先拉取远端,失败时兜底用本地目录
|
|
36
36
|
const tmp = mkdtempSync(join(tmpdir(), "luminae-skills-"));
|
|
37
37
|
try {
|
|
38
38
|
execFileSync("git", ["clone", "--depth", "1", remote, tmp], { stdio: "inherit" });
|
|
39
39
|
return tmp;
|
|
40
40
|
} catch (e) {
|
|
41
41
|
rmSync(tmp, { recursive: true, force: true });
|
|
42
|
+
if (copyDirs.some(d => hasSkillTree(join(sourceRepo, d)))) return sourceRepo;
|
|
42
43
|
if (strict) throw e;
|
|
43
44
|
return null;
|
|
44
45
|
}
|
package/src/lib/constants.js
CHANGED
|
@@ -46,23 +46,11 @@ export const TOOLS = [
|
|
|
46
46
|
skillDir: () => join(homedir(), ".opencode", "skills"),
|
|
47
47
|
installHint: "npm install -g opencode-ai",
|
|
48
48
|
},
|
|
49
|
-
{
|
|
50
|
-
id: "trae",
|
|
51
|
-
name: "Trae",
|
|
52
|
-
command: "trae",
|
|
53
|
-
commandDir: () => join(homedir(), ".trae", "commands"),
|
|
54
|
-
skillDir: null,
|
|
55
|
-
installHint: "Download from https://trae.ai",
|
|
56
|
-
},
|
|
57
49
|
];
|
|
58
50
|
|
|
59
51
|
// ── Skill auto-discovery ──
|
|
60
52
|
|
|
61
|
-
/**
|
|
62
|
-
* Get the package root directory.
|
|
63
|
-
* import.meta.dirname = <luminae-helper>/src/lib
|
|
64
|
-
* Package root = <luminae-helper>/
|
|
65
|
-
*/
|
|
53
|
+
/** ...same as before... */
|
|
66
54
|
function getPackageDir() {
|
|
67
55
|
if (globalThis.__LUMINAE_PACKAGE_ROOT__) {
|
|
68
56
|
return globalThis.__LUMINAE_PACKAGE_ROOT__;
|
|
@@ -78,10 +66,6 @@ function getPackageDir() {
|
|
|
78
66
|
return selfDir;
|
|
79
67
|
}
|
|
80
68
|
|
|
81
|
-
/**
|
|
82
|
-
* Parse YAML frontmatter from SKILL.md content.
|
|
83
|
-
* Only extracts `name` and `description`.
|
|
84
|
-
*/
|
|
85
69
|
function parseSkillMeta(skillId, content) {
|
|
86
70
|
let name = null;
|
|
87
71
|
let description = null;
|
|
@@ -92,14 +76,11 @@ function parseSkillMeta(skillId, content) {
|
|
|
92
76
|
const m = line.match(/^(\w+):\s*(.+)/);
|
|
93
77
|
if (m) {
|
|
94
78
|
let value = m[2].trim();
|
|
95
|
-
// Strip YAML inline comments (unquoted # after value)
|
|
96
|
-
// But preserve # inside quoted strings
|
|
97
79
|
if (!((value.startsWith('"') && value.endsWith('"')) ||
|
|
98
80
|
(value.startsWith("'") && value.endsWith("'")))) {
|
|
99
81
|
const hashIdx = value.indexOf(" #");
|
|
100
82
|
if (hashIdx !== -1) value = value.slice(0, hashIdx).trim();
|
|
101
83
|
}
|
|
102
|
-
// Strip surrounding quotes (single or double) from YAML values
|
|
103
84
|
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
104
85
|
(value.startsWith("'") && value.endsWith("'"))) {
|
|
105
86
|
value = value.slice(1, -1);
|
|
@@ -110,13 +91,11 @@ function parseSkillMeta(skillId, content) {
|
|
|
110
91
|
}
|
|
111
92
|
}
|
|
112
93
|
|
|
113
|
-
// Default name: skillId, capitalize words separated by hyphens
|
|
114
94
|
if (!name) {
|
|
115
95
|
name = skillId
|
|
116
96
|
.replace(/(^|-)(\w)/g, (_, p, c) => (p === "-" ? " " : "") + c.toUpperCase());
|
|
117
97
|
}
|
|
118
98
|
|
|
119
|
-
// Default description: first blockquote line
|
|
120
99
|
if (!description) {
|
|
121
100
|
const bq = content.match(/^>\s*(.+)/m);
|
|
122
101
|
if (bq) description = bq[1].trim();
|
|
@@ -125,14 +104,6 @@ function parseSkillMeta(skillId, content) {
|
|
|
125
104
|
return { name, description };
|
|
126
105
|
}
|
|
127
106
|
|
|
128
|
-
/**
|
|
129
|
-
* Generate installTargets for an entry based on tool capability.
|
|
130
|
-
* - skillType "command" + tool supports commandDir → file mode (commands/)
|
|
131
|
-
* - skillType "command" + tool only supports skillDir → fallback dir mode
|
|
132
|
-
* - skillType "skill" + tool supports skillDir → dir mode (skills/)
|
|
133
|
-
* - skillType "skill" + tool only supports commandDir → fallback file mode
|
|
134
|
-
* - tool supports neither → skip
|
|
135
|
-
*/
|
|
136
107
|
function generateInstallTargets(skillId, skillType) {
|
|
137
108
|
const targets = [];
|
|
138
109
|
for (const tool of TOOLS) {
|
|
@@ -148,7 +119,6 @@ function generateInstallTargets(skillId, skillType) {
|
|
|
148
119
|
destPath: () => join(tool.commandDir(), `${skillId}.md`),
|
|
149
120
|
});
|
|
150
121
|
} else if (supportsSkill) {
|
|
151
|
-
// Fallback: tool only supports skills, install command as skill
|
|
152
122
|
targets.push({
|
|
153
123
|
toolId: tool.id,
|
|
154
124
|
installMode: "dir",
|
|
@@ -165,7 +135,6 @@ function generateInstallTargets(skillId, skillType) {
|
|
|
165
135
|
destPath: () => join(tool.skillDir(), skillId),
|
|
166
136
|
});
|
|
167
137
|
} else if (supportsCommand) {
|
|
168
|
-
// Fallback: tool only supports commands, install skill as command
|
|
169
138
|
targets.push({
|
|
170
139
|
toolId: tool.id,
|
|
171
140
|
installMode: "file",
|
|
@@ -178,12 +147,6 @@ function generateInstallTargets(skillId, skillType) {
|
|
|
178
147
|
return targets;
|
|
179
148
|
}
|
|
180
149
|
|
|
181
|
-
/**
|
|
182
|
-
* Scan commands/ and skills/ directories and build SKILLS array automatically.
|
|
183
|
-
* Each subdirectory containing a SKILL.md is a valid skill.
|
|
184
|
-
* - commands/<skillId>/ → type: "command"
|
|
185
|
-
* - skills/<skillId>/ → type: "skill"
|
|
186
|
-
*/
|
|
187
150
|
export function discoverSkills() {
|
|
188
151
|
const packageDir = getPackageDir();
|
|
189
152
|
const skills = [];
|
|
@@ -232,11 +195,6 @@ export function discoverSkills() {
|
|
|
232
195
|
|
|
233
196
|
export const SKILLS = discoverSkills();
|
|
234
197
|
|
|
235
|
-
// ── Helpers ──
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Detect which tools are installed on this machine.
|
|
239
|
-
*/
|
|
240
198
|
export function detectInstalledTools() {
|
|
241
199
|
return TOOLS.map((tool) => ({
|
|
242
200
|
...tool,
|
|
@@ -244,11 +202,6 @@ export function detectInstalledTools() {
|
|
|
244
202
|
}));
|
|
245
203
|
}
|
|
246
204
|
|
|
247
|
-
/**
|
|
248
|
-
* Find skill source directory bundled inside this package.
|
|
249
|
-
* - command: <luminae-helper>/commands/<skillId>/
|
|
250
|
-
* - skill: <luminae-helper>/skills/<skillId>/
|
|
251
|
-
*/
|
|
252
205
|
export function getSkillSourcePath(skillId) {
|
|
253
206
|
const skill = SKILLS.find(s => s.id === skillId);
|
|
254
207
|
if (!skill) {
|