skill4agent 1.0.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 +51 -0
- package/README_CN.md +51 -0
- package/bin/skill4agent.js +3 -0
- package/dist/api.d.ts +30 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +70 -0
- package/dist/api.js.map +1 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +263 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/install.d.ts +11 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +155 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +5 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +19 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +71 -0
- package/dist/main.js.map +1 -0
- package/dist/tools.d.ts +16 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +106 -0
- package/dist/tools.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +30 -0
- package/dist/utils.js.map +1 -0
- package/package.json +39 -0
- package/src/api.ts +99 -0
- package/src/commands/add.ts +311 -0
- package/src/commands/install.ts +186 -0
- package/src/commands/list.ts +15 -0
- package/src/main.ts +78 -0
- package/src/tools.ts +111 -0
- package/src/utils.ts +28 -0
- package/tsconfig.json +19 -0
package/src/tools.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
export interface Agent {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
path: string;
|
|
9
|
+
universal: boolean;
|
|
10
|
+
globalPath?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const UNIVERSAL_AGENTS: Agent[] = [
|
|
14
|
+
{ id: 'amp', name: 'Amp', path: '.agents/skills', universal: true },
|
|
15
|
+
{ id: 'codex', name: 'Codex', path: '.agents/skills', universal: true },
|
|
16
|
+
{ id: 'gemini-cli', name: 'Gemini CLI', path: '.agents/skills', universal: true },
|
|
17
|
+
{ id: 'github-copilot', name: 'GitHub Copilot', path: '.agents/skills', universal: true },
|
|
18
|
+
{ id: 'kimi-code-cli', name: 'Kimi Code CLI', path: '.agents/skills', universal: true },
|
|
19
|
+
{ id: 'opencode', name: 'OpenCode', path: '.agents/skills', universal: true },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export const UNIVERSAL_PATH = '.agents/skills';
|
|
23
|
+
|
|
24
|
+
export const OTHER_AGENTS: Agent[] = [
|
|
25
|
+
{ id: 'antigravity', name: 'Antigravity', path: '.agent/skills', universal: false },
|
|
26
|
+
{ id: 'augment', name: 'Augment', path: '.augment/rules', universal: false },
|
|
27
|
+
{ id: 'claude-code', name: 'Claude Code', path: '.claude/skills', universal: false },
|
|
28
|
+
{ id: 'openclaw', name: 'OpenClaw', path: 'skills', universal: false },
|
|
29
|
+
{ id: 'cline', name: 'Cline', path: '.cline/skills', universal: false },
|
|
30
|
+
{ id: 'codebuddy', name: 'CodeBuddy', path: '.codebuddy/skills', universal: false },
|
|
31
|
+
{ id: 'command-code', name: 'Command Code', path: '.commandcode/skills', universal: false },
|
|
32
|
+
{ id: 'continue', name: 'Continue', path: '.continue/skills', universal: false },
|
|
33
|
+
{ id: 'crush', name: 'Crush', path: '.crush/skills', universal: false },
|
|
34
|
+
{ id: 'cursor', name: 'Cursor', path: '.cursor/skills', universal: false },
|
|
35
|
+
{ id: 'droid', name: 'Droid', path: '.factory/skills', universal: false },
|
|
36
|
+
{ id: 'goose', name: 'Goose', path: '.goose/skills', universal: false },
|
|
37
|
+
{ id: 'junie', name: 'Junie', path: '.junie/skills', universal: false },
|
|
38
|
+
{ id: 'iflow-cli', name: 'iFlow CLI', path: '.iflow/skills', universal: false },
|
|
39
|
+
{ id: 'kilo-code', name: 'Kilo Code', path: '.kilocode/skills', universal: false },
|
|
40
|
+
{ id: 'kiro-cli', name: 'Kiro CLI', path: '.kiro/skills', universal: false },
|
|
41
|
+
{ id: 'kode', name: 'Kode', path: '.kode/skills', universal: false },
|
|
42
|
+
{ id: 'mcpjam', name: 'MCPJam', path: '.mcpjam/skills', universal: false },
|
|
43
|
+
{ id: 'mistral-vibe', name: 'Mistral Vibe', path: '.vibe/skills', universal: false },
|
|
44
|
+
{ id: 'mux', name: 'Mux', path: '.mux/skills', universal: false },
|
|
45
|
+
{ id: 'openhands', name: 'OpenHands', path: '.openhands/skills', universal: false },
|
|
46
|
+
{ id: 'pi', name: 'Pi', path: '.pi/skills', universal: false },
|
|
47
|
+
{ id: 'qoder', name: 'Qoder', path: '.qoder/skills', universal: false },
|
|
48
|
+
{ id: 'qwen-code', name: 'Qwen Code', path: '.qwen/skills', universal: false },
|
|
49
|
+
{ id: 'roo-code', name: 'Roo Code', path: '.roo/skills', universal: false },
|
|
50
|
+
{ id: 'trae', name: 'Trae', path: '.trae/skills', universal: false },
|
|
51
|
+
{ id: 'trae-cn', name: 'Trae CN', path: '.trae/skills', globalPath: '.trae-cn/skills', universal: false },
|
|
52
|
+
{ id: 'windsurf', name: 'Windsurf', path: '.windsurf/skills', universal: false },
|
|
53
|
+
{ id: 'zencoder', name: 'Zencoder', path: '.zencoder/skills', universal: false },
|
|
54
|
+
{ id: 'neovate', name: 'Neovate', path: '.neovate/skills', universal: false },
|
|
55
|
+
{ id: 'pochi', name: 'Pochi', path: '.pochi/skills', universal: false },
|
|
56
|
+
{ id: 'adal', name: 'AdaL', path: '.adal/skills', universal: false },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
export function getGlobalStoragePath(): string {
|
|
60
|
+
const platform = os.platform();
|
|
61
|
+
const homeDir = os.homedir();
|
|
62
|
+
|
|
63
|
+
switch (platform) {
|
|
64
|
+
case 'win32':
|
|
65
|
+
return path.join(process.env.LOCALAPPDATA || path.join(homeDir, 'AppData', 'Local'), 'skill4agent', 'skills');
|
|
66
|
+
case 'linux':
|
|
67
|
+
return path.join(process.env.XDG_DATA_HOME || path.join(homeDir, '.local', 'share'), 'skill4agent', 'skills');
|
|
68
|
+
case 'darwin':
|
|
69
|
+
default:
|
|
70
|
+
return path.join(homeDir, '.skill4agent', 'skills');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function getAgentPath(agentId: string, isGlobal: boolean): string | null {
|
|
75
|
+
const allAgents = [...UNIVERSAL_AGENTS, ...OTHER_AGENTS];
|
|
76
|
+
const agent = allAgents.find(a => a.id === agentId);
|
|
77
|
+
if (!agent) return null;
|
|
78
|
+
|
|
79
|
+
const effectivePath = isGlobal && agent.globalPath ? agent.globalPath : agent.path;
|
|
80
|
+
|
|
81
|
+
if (isGlobal) {
|
|
82
|
+
return path.join(os.homedir(), effectivePath);
|
|
83
|
+
} else {
|
|
84
|
+
return path.resolve(process.cwd(), effectivePath);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function checkAgentExists(agentPath: string): boolean {
|
|
89
|
+
const parentDir = path.dirname(agentPath);
|
|
90
|
+
return fs.existsSync(parentDir);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getAllAgents(): Agent[] {
|
|
94
|
+
return [...UNIVERSAL_AGENTS, ...OTHER_AGENTS];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function getAgentDisplayPath(agentId: string, isGlobal: boolean): string {
|
|
98
|
+
const allAgents = [...UNIVERSAL_AGENTS, ...OTHER_AGENTS];
|
|
99
|
+
const agent = allAgents.find(a => a.id === agentId);
|
|
100
|
+
if (!agent) return 'unknown';
|
|
101
|
+
|
|
102
|
+
const effectivePath = isGlobal && agent.globalPath ? agent.globalPath : agent.path;
|
|
103
|
+
|
|
104
|
+
if (isGlobal) {
|
|
105
|
+
const homeDir = os.homedir();
|
|
106
|
+
const fullPath = path.join(homeDir, effectivePath);
|
|
107
|
+
return fullPath.replace(os.homedir(), '~');
|
|
108
|
+
} else {
|
|
109
|
+
return effectivePath;
|
|
110
|
+
}
|
|
111
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export async function extractZip(zipPath: string, destDir: string): Promise<void> {
|
|
5
|
+
const AdmZip = require('adm-zip');
|
|
6
|
+
const zip = new AdmZip(zipPath);
|
|
7
|
+
zip.extractAllTo(destDir, true);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function formatSize(bytes: number): string {
|
|
11
|
+
if (bytes < 1024) return bytes + ' B';
|
|
12
|
+
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
|
13
|
+
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getSkillDirFromZip(zipPath: string): string | null {
|
|
17
|
+
const AdmZip = require('adm-zip');
|
|
18
|
+
const zip = new AdmZip(zipPath);
|
|
19
|
+
const entries = zip.getEntries();
|
|
20
|
+
|
|
21
|
+
for (const entry of entries) {
|
|
22
|
+
const parts = entry.entryName.split('/');
|
|
23
|
+
if (parts.length > 1 && parts[0] !== '__MACOSX') {
|
|
24
|
+
return parts[0];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|