Skip to content

Commit bdff534

Browse files
committed
feat: cherry-pick improvements from PR #17
- skill-registry: add routers/workflows/guards kind inference - skill-registry: fallback allowed-tools to permissions field - skill-registry: fallback argument-hint to camelCase argumentHint - utils: rmSafe retry with clearReadOnlyRecursive (Windows compat) - install: normalize getSkillPath for Windows path.sep - manifest: add gemini host files declaration - gemini adapter: read core files from manifest via getPackHostFiles
1 parent d8aedf8 commit bdff534

5 files changed

Lines changed: 51 additions & 9 deletions

File tree

bin/adapters/gemini.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
const fs = require('fs');
44
const path = require('path');
5+
const { getPackHostFiles } = require(path.join(__dirname, '..', 'lib', 'pack-registry.js'));
6+
7+
const PROJECT_ROOT = path.join(__dirname, '..', '..');
58

69
const GEMINI_SETTINGS_TEMPLATE = {
710
theme: 'GitHub',
@@ -11,10 +14,7 @@ const GEMINI_SETTINGS_TEMPLATE = {
1114
};
1215

1316
function getGeminiCoreFiles() {
14-
return [
15-
{ src: 'skills', dest: 'skills', root: 'gemini' },
16-
{ src: 'bin/lib', dest: 'bin/lib', root: 'gemini' },
17-
];
17+
return getPackHostFiles(PROJECT_ROOT, 'abyss', 'gemini');
1818
}
1919

2020
function detectGeminiAuth({

bin/install.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,11 @@ const GEMINI_COMMAND_TARGET = {
280280
};
281281

282282
function getSkillPath(skillRoot, skillRelPath) {
283-
return skillRelPath
284-
? `${skillRoot}/${skillRelPath}/SKILL.md`
283+
const normalizedRelPath = skillRelPath
284+
? String(skillRelPath).split(path.sep).join('/')
285+
: '';
286+
return normalizedRelPath
287+
? `${skillRoot}/${normalizedRelPath}/SKILL.md`
285288
: `${skillRoot}/SKILL.md`;
286289
}
287290

bin/lib/skill-registry.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ function inferSkillKind(relPath) {
1717
const [head] = normalizedRelPath.split('/');
1818
if (head === 'tools') return 'tool';
1919
if (head === 'domains') return 'domain';
20+
if (head === 'routers') return 'router';
21+
if (head === 'workflows') return 'workflow';
22+
if (head === 'guards') return 'guard';
2023
if (head === 'orchestration') return 'orchestration';
2124
return 'root';
2225
}
@@ -90,8 +93,13 @@ function normalizeSkillRecord(skillsDir, skillDir, meta) {
9093
}
9194

9295
const userInvocable = normalizeBoolean(normalizedMeta['user-invocable']);
93-
const allowedTools = normalizeAllowedTools(normalizedMeta['allowed-tools'], relPath);
94-
const argumentHint = normalizedMeta['argument-hint'] || '';
96+
const allowedTools = normalizeAllowedTools(
97+
Object.prototype.hasOwnProperty.call(normalizedMeta, 'allowed-tools')
98+
? normalizedMeta['allowed-tools']
99+
: normalizedMeta.permissions,
100+
relPath
101+
);
102+
const argumentHint = normalizedMeta['argument-hint'] || normalizedMeta.argumentHint || '';
95103
const category = inferSkillKind(relPath);
96104
const runtimeType = scriptEntries.length === 1 ? 'scripted' : 'knowledge';
97105
const scriptPath = scriptEntries[0] || null;

bin/lib/utils.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,33 @@ function copyRecursive(src, dest, errors) {
3434
}
3535
}
3636

37+
function clearReadOnlyRecursive(targetPath) {
38+
if (!fs.existsSync(targetPath)) return;
39+
const stat = fs.lstatSync(targetPath);
40+
try {
41+
fs.chmodSync(targetPath, stat.isDirectory() ? 0o777 : 0o666);
42+
} catch {}
43+
if (stat.isDirectory()) {
44+
for (const entry of fs.readdirSync(targetPath)) {
45+
clearReadOnlyRecursive(path.join(targetPath, entry));
46+
}
47+
}
48+
}
49+
3750
function rmSafe(p) {
38-
if (fs.existsSync(p)) fs.rmSync(p, { recursive: true, force: true });
51+
if (!fs.existsSync(p)) return;
52+
const errors = [];
53+
for (let attempt = 0; attempt < 4; attempt += 1) {
54+
try {
55+
clearReadOnlyRecursive(p);
56+
fs.rmSync(p, { recursive: true, force: true });
57+
return;
58+
} catch (error) {
59+
errors.push(error);
60+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50 * (attempt + 1));
61+
}
62+
}
63+
throw errors[errors.length - 1];
3964
}
4065

4166
function deepMergeNew(target, source, prefix, log) {

packs/abyss/manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
{ "src": "skills", "dest": "skills", "root": "codex" },
2121
{ "src": "bin/lib", "dest": "bin/lib", "root": "codex" }
2222
]
23+
},
24+
"gemini": {
25+
"files": [
26+
{ "src": "skills", "dest": "skills", "root": "gemini" },
27+
{ "src": "bin/lib", "dest": "bin/lib", "root": "gemini" }
28+
]
2329
}
2430
}
2531
}

0 commit comments

Comments
 (0)