nexa-skill-compiler 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/LICENSE +21 -0
- package/README.md +77 -0
- package/bin/nsc.js +64 -0
- package/package.json +47 -0
- package/scripts/install.js +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nexa Language Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/ouyangyipeng/Skill-Compiler/main/docs/img/nsc-logo.png" alt="NSC Logo" width="100" />
|
|
3
|
+
<h1>Nexa Skill Compiler</h1>
|
|
4
|
+
<p><b><i>Write Once, Run Anywhere for AI Agent Skills</i></b></p>
|
|
5
|
+
<p>
|
|
6
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="License"/>
|
|
7
|
+
<img src="https://img.shields.io/badge/Version-v1.0-brightgreen.svg?style=for-the-badge" alt="Version"/>
|
|
8
|
+
<img src="https://img.shields.io/badge/Rust-1.75%2B-orange.svg?style=for-the-badge" alt="Rust"/>
|
|
9
|
+
<img src="https://img.shields.io/badge/Status-Stable-green.svg?style=for-the-badge" alt="Status"/>
|
|
10
|
+
</p>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Install via npm
|
|
19
|
+
npm install -g nexa-skill-compiler
|
|
20
|
+
|
|
21
|
+
# Or install the Rust binary directly (recommended)
|
|
22
|
+
cargo install nexa-skill-cli
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Compile a skill for all platforms
|
|
29
|
+
nsc build skill.md
|
|
30
|
+
|
|
31
|
+
# Compile for specific target
|
|
32
|
+
nsc build skill.md --target claude
|
|
33
|
+
|
|
34
|
+
# Validate a skill file
|
|
35
|
+
nsc validate skill.md
|
|
36
|
+
|
|
37
|
+
# Initialize a new skill from template
|
|
38
|
+
nsc init my-skill
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## What is NSC?
|
|
42
|
+
|
|
43
|
+
**Nexa Skill Compiler (NSC)** is an industrial-grade multi-target compiler that transforms unified `SKILL.md` specifications into platform-specific agent instructions.
|
|
44
|
+
|
|
45
|
+
### š Frontend: Parsing & Validation
|
|
46
|
+
- YAML Frontmatter Parser with type validation
|
|
47
|
+
- Permission Auditor for security analysis
|
|
48
|
+
- MCP Dependency Checker
|
|
49
|
+
|
|
50
|
+
### š§ Mid-end: IR & Optimization
|
|
51
|
+
- SkillIR - Platform-independent intermediate representation
|
|
52
|
+
- Anti-Skill Injection - Automatic defense against dangerous behaviors
|
|
53
|
+
- Security Level Analyzer with 4-tier model
|
|
54
|
+
|
|
55
|
+
### š Backend: Multi-Target Emission
|
|
56
|
+
- Claude Target - Claude Code compatible output
|
|
57
|
+
- Codex Target - OpenAI Codex/GPT format
|
|
58
|
+
- Gemini Target - Google Gemini system instructions
|
|
59
|
+
|
|
60
|
+
## Performance
|
|
61
|
+
|
|
62
|
+
Based on large-scale comparative experiments:
|
|
63
|
+
|
|
64
|
+
| Metric | Original Skills | Compiled Skills | Improvement |
|
|
65
|
+
|--------|-----------------|-----------------|-------------|
|
|
66
|
+
| Avg Duration | 45.2s | 37.6s | **16.9% faster** |
|
|
67
|
+
| Success Rate | 96% | 100% | +4% |
|
|
68
|
+
|
|
69
|
+
## Links
|
|
70
|
+
|
|
71
|
+
- š [Documentation](https://github.com/ouyangyipeng/Skill-Compiler#readme)
|
|
72
|
+
- š [Issue Tracker](https://github.com/ouyangyipeng/Skill-Compiler/issues)
|
|
73
|
+
- š¬ [Discussions](https://github.com/ouyangyipeng/Skill-Compiler/discussions)
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
package/bin/nsc.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
// Binary name based on platform
|
|
8
|
+
function getBinaryName() {
|
|
9
|
+
const platform = process.platform;
|
|
10
|
+
const arch = process.arch;
|
|
11
|
+
|
|
12
|
+
if (platform === 'win32') {
|
|
13
|
+
return 'nexa-skill.exe';
|
|
14
|
+
}
|
|
15
|
+
return 'nexa-skill';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Find binary location
|
|
19
|
+
function findBinary() {
|
|
20
|
+
// Check if installed via cargo
|
|
21
|
+
const cargoBin = path.join(process.env.CARGO_HOME || path.join(process.env.HOME || process.env.USERPROFILE, '.cargo', 'bin'), getBinaryName());
|
|
22
|
+
|
|
23
|
+
// Check local node_modules
|
|
24
|
+
const localBin = path.join(__dirname, '..', 'binaries', process.platform, process.arch, getBinaryName());
|
|
25
|
+
|
|
26
|
+
// Check PATH
|
|
27
|
+
const pathBinary = getBinaryName();
|
|
28
|
+
|
|
29
|
+
if (fs.existsSync(cargoBin)) {
|
|
30
|
+
return cargoBin;
|
|
31
|
+
}
|
|
32
|
+
if (fs.existsSync(localBin)) {
|
|
33
|
+
return localBin;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Return the binary name and let the system find it in PATH
|
|
37
|
+
return pathBinary;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Run the binary
|
|
41
|
+
const binary = findBinary();
|
|
42
|
+
const args = process.argv.slice(2);
|
|
43
|
+
|
|
44
|
+
const child = spawn(binary, args, {
|
|
45
|
+
stdio: 'inherit',
|
|
46
|
+
shell: process.platform === 'win32'
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
child.on('error', (err) => {
|
|
50
|
+
if (err.code === 'ENOENT') {
|
|
51
|
+
console.error('\n\x1b[31mError: nexa-skill binary not found.\x1b[0m');
|
|
52
|
+
console.error('\nPlease install the Rust binary first:');
|
|
53
|
+
console.error(' \x1b[36mcargo install nexa-skill-cli\x1b[0m');
|
|
54
|
+
console.error('\nOr visit: https://github.com/ouyangyipeng/Skill-Compiler\n');
|
|
55
|
+
process.exit(1);
|
|
56
|
+
} else {
|
|
57
|
+
console.error('Error running nexa-skill:', err.message);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
child.on('exit', (code) => {
|
|
63
|
+
process.exit(code || 0);
|
|
64
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nexa-skill-compiler",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Industrial-grade multi-target compiler for AI Agent Skills - Write Once, Run Anywhere",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"nsc": "./bin/nsc.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node scripts/install.js",
|
|
11
|
+
"test": "node test/test.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"skill",
|
|
15
|
+
"compiler",
|
|
16
|
+
"ai",
|
|
17
|
+
"agent",
|
|
18
|
+
"claude",
|
|
19
|
+
"gpt",
|
|
20
|
+
"gemini",
|
|
21
|
+
"mcp",
|
|
22
|
+
"llm",
|
|
23
|
+
"nexa"
|
|
24
|
+
],
|
|
25
|
+
"author": "Nexa Language Team",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/ouyangyipeng/Skill-Compiler.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/ouyangyipeng/Skill-Compiler/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/ouyangyipeng/Skill-Compiler#readme",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=14.0.0"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"bin/",
|
|
40
|
+
"scripts/",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
console.log('\nš¦ Nexa Skill Compiler - Post Install\n');
|
|
8
|
+
console.log('Checking for nexa-skill binary...');
|
|
9
|
+
|
|
10
|
+
// Check if binary exists in PATH
|
|
11
|
+
function binaryExists() {
|
|
12
|
+
try {
|
|
13
|
+
execSync('nexa-skill --version', { stdio: 'ignore' });
|
|
14
|
+
return true;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (binaryExists()) {
|
|
21
|
+
console.log('ā
nexa-skill binary found in PATH.\n');
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
console.log('ā ļø nexa-skill binary not found in PATH.');
|
|
26
|
+
console.log('\nTo complete installation, please run one of the following:\n');
|
|
27
|
+
console.log(' \x1b[36m# Option 1: Install via cargo (recommended)\x1b[0m');
|
|
28
|
+
console.log(' cargo install nexa-skill-cli\n');
|
|
29
|
+
console.log(' \x1b[36m# Option 2: Build from source\x1b[0m');
|
|
30
|
+
console.log(' git clone https://github.com/ouyangyipeng/Skill-Compiler');
|
|
31
|
+
console.log(' cd Skill-Compiler');
|
|
32
|
+
console.log(' cargo install --path nexa-skill-cli\n');
|
|
33
|
+
console.log('š Documentation: https://github.com/ouyangyipeng/Skill-Compiler\n');
|