@altairalabs/packc 0.0.1

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 ADDED
@@ -0,0 +1,259 @@
1
+ # @altairalabs/packc
2
+
3
+ > PromptKit Pack Compiler - Compile and validate prompt packs for LLM applications
4
+
5
+ ## Installation
6
+
7
+ ### npx (No Installation Required)
8
+
9
+ ```bash
10
+ npx @altairalabs/packc compile -c arena.yaml
11
+ npx @altairalabs/packc validate -c arena.yaml
12
+ ```
13
+
14
+ ### Global Installation
15
+
16
+ ```bash
17
+ npm install -g @altairalabs/packc
18
+
19
+ # Use directly
20
+ packc version
21
+ packc compile -c arena.yaml
22
+ ```
23
+
24
+ ### Project Dev Dependency
25
+
26
+ ```bash
27
+ npm install --save-dev @altairalabs/packc
28
+
29
+ # Use via npm scripts
30
+ # Add to package.json:
31
+ {
32
+ "scripts": {
33
+ "build:prompts": "packc compile -c arena.yaml",
34
+ "validate:prompts": "packc validate -c arena.yaml"
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## What is PackC?
40
+
41
+ PackC is the PromptKit Pack Compiler - a tool for compiling and validating prompt configurations. It helps you:
42
+
43
+ - šŸ“¦ **Compile prompts** from YAML configurations into optimized packs
44
+ - āœ… **Validate configurations** before deployment
45
+ - šŸ” **Inspect prompts** to understand structure and metadata
46
+ - šŸš€ **Optimize** prompt loading for production use
47
+
48
+ ## Quick Start
49
+
50
+ 1. Create a configuration file:
51
+
52
+ ```yaml
53
+ # arena.yaml
54
+ name: My Application
55
+ version: 1.0.0
56
+
57
+ prompts:
58
+ - name: assistant
59
+ system_prompt: |
60
+ You are a helpful AI assistant.
61
+
62
+ - name: code-helper
63
+ system_prompt: |
64
+ You are an expert programmer.
65
+ context:
66
+ - type: file
67
+ path: ./docs/guidelines.md
68
+ ```
69
+
70
+ 2. Compile the prompts:
71
+
72
+ ```bash
73
+ packc compile -c arena.yaml -o prompts.pack
74
+ ```
75
+
76
+ 3. Validate the configuration:
77
+
78
+ ```bash
79
+ packc validate -c arena.yaml
80
+ ```
81
+
82
+ 4. Inspect a specific prompt:
83
+
84
+ ```bash
85
+ packc inspect -c arena.yaml -p assistant
86
+ ```
87
+
88
+ ## Commands
89
+
90
+ ### compile
91
+
92
+ Compile all prompts from a configuration file into a single pack:
93
+
94
+ ```bash
95
+ packc compile -c arena.yaml -o output.pack
96
+ ```
97
+
98
+ Options:
99
+ - `-c, --config`: Path to arena.yaml configuration file (required)
100
+ - `-o, --output`: Output pack file path (default: prompts.pack)
101
+
102
+ ### compile-prompt
103
+
104
+ Compile a single prompt:
105
+
106
+ ```bash
107
+ packc compile-prompt -c arena.yaml -p assistant -o assistant.json
108
+ ```
109
+
110
+ Options:
111
+ - `-c, --config`: Path to configuration file (required)
112
+ - `-p, --prompt`: Name of the prompt to compile (required)
113
+ - `-o, --output`: Output file path (default: stdout)
114
+
115
+ ### validate
116
+
117
+ Validate configuration file without compiling:
118
+
119
+ ```bash
120
+ packc validate -c arena.yaml
121
+ ```
122
+
123
+ Checks for:
124
+ - YAML syntax errors
125
+ - Missing required fields
126
+ - Invalid prompt references
127
+ - Malformed context definitions
128
+ - File path validation
129
+
130
+ ### inspect
131
+
132
+ Inspect a specific prompt's configuration:
133
+
134
+ ```bash
135
+ packc inspect -c arena.yaml -p assistant
136
+ ```
137
+
138
+ Shows:
139
+ - Prompt name and metadata
140
+ - System prompt content
141
+ - Context sources
142
+ - Variable definitions
143
+ - Formatting details
144
+
145
+ ### version
146
+
147
+ Display version information:
148
+
149
+ ```bash
150
+ packc version
151
+ ```
152
+
153
+ ## Use Cases
154
+
155
+ ### CI/CD Validation
156
+
157
+ Add prompt validation to your CI pipeline:
158
+
159
+ ```yaml
160
+ # .github/workflows/validate.yml
161
+ - name: Validate prompts
162
+ run: npx @altairalabs/packc validate -c config/arena.yaml
163
+ ```
164
+
165
+ ### Build Scripts
166
+
167
+ Compile prompts as part of your build process:
168
+
169
+ ```json
170
+ {
171
+ "scripts": {
172
+ "prebuild": "packc compile -c arena.yaml",
173
+ "build": "your-build-command"
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### Local Development
179
+
180
+ Quickly validate changes during development:
181
+
182
+ ```bash
183
+ # Watch for changes and validate
184
+ watch -n 2 'packc validate -c arena.yaml'
185
+ ```
186
+
187
+ ## How It Works
188
+
189
+ This npm package downloads pre-built Go binaries from [GitHub Releases](https://github.com/AltairaLabs/PromptKit/releases) during installation. The binaries are:
190
+
191
+ 1. Downloaded for your specific OS and architecture
192
+ 2. Extracted from the release archive
193
+ 3. Made executable (Unix-like systems)
194
+ 4. Invoked through a thin Node.js wrapper
195
+
196
+ No Go toolchain is required on your machine.
197
+
198
+ ## Supported Platforms
199
+
200
+ - macOS (Intel and Apple Silicon)
201
+ - Linux (x86_64 and arm64)
202
+ - Windows (x86_64 and arm64)
203
+
204
+ ## Documentation
205
+
206
+ - [Full Documentation](https://github.com/AltairaLabs/PromptKit#readme)
207
+ - [Configuration Reference](https://github.com/AltairaLabs/PromptKit/tree/main/docs)
208
+ - [Examples](https://github.com/AltairaLabs/PromptKit/tree/main/examples)
209
+
210
+ ## Troubleshooting
211
+
212
+ ### Binary Download Fails
213
+
214
+ If the postinstall script fails:
215
+
216
+ 1. Check your internet connection
217
+ 2. Verify the version exists in [GitHub Releases](https://github.com/AltairaLabs/PromptKit/releases)
218
+ 3. Check npm proxy/registry settings
219
+ 4. Try manual installation:
220
+
221
+ ```bash
222
+ # Download binary directly
223
+ curl -L https://github.com/AltairaLabs/PromptKit/releases/download/v0.0.1/PromptKit_v0.0.1_Darwin_arm64.tar.gz -o packc.tar.gz
224
+ tar -xzf packc.tar.gz packc
225
+ chmod +x packc
226
+ ```
227
+
228
+ ### Permission Denied
229
+
230
+ On Unix-like systems:
231
+
232
+ ```bash
233
+ chmod +x node_modules/@altairalabs/packc/packc
234
+ ```
235
+
236
+ ## Alternative Installation Methods
237
+
238
+ - **Homebrew**: `brew install altairalabs/tap/promptkit`
239
+ - **Go Install**: `go install github.com/AltairaLabs/PromptKit/tools/packc@latest`
240
+ - **Direct Download**: [GitHub Releases](https://github.com/AltairaLabs/PromptKit/releases)
241
+ - **Build from Source**: Clone repo and run `make install-tools`
242
+
243
+ ## Related Tools
244
+
245
+ - **[@altairalabs/promptarena](https://www.npmjs.com/package/@altairalabs/promptarena)** - Test and evaluate your prompts
246
+ - **PromptKit SDK** - Production deployment library
247
+
248
+ ## License
249
+
250
+ Apache-2.0 - see [LICENSE](https://github.com/AltairaLabs/PromptKit/blob/main/LICENSE)
251
+
252
+ ## Contributing
253
+
254
+ Contributions welcome! See [CONTRIBUTING.md](https://github.com/AltairaLabs/PromptKit/blob/main/CONTRIBUTING.md)
255
+
256
+ ## Support
257
+
258
+ - [GitHub Issues](https://github.com/AltairaLabs/PromptKit/issues)
259
+ - [Discussions](https://github.com/AltairaLabs/PromptKit/discussions)
package/bin/packc.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ const binaryName = process.platform === 'win32' ? 'packc.exe' : 'packc';
8
+ const binaryPath = path.join(__dirname, '..', binaryName);
9
+
10
+ // Check if binary exists
11
+ if (!fs.existsSync(binaryPath)) {
12
+ console.error('Error: packc binary not found.');
13
+ console.error('Please try reinstalling: npm install @altairalabs/packc');
14
+ process.exit(1);
15
+ }
16
+
17
+ // Spawn the Go binary with all arguments
18
+ const child = spawn(binaryPath, process.argv.slice(2), {
19
+ stdio: 'inherit',
20
+ windowsHide: false
21
+ });
22
+
23
+ child.on('error', (err) => {
24
+ console.error('Failed to start packc:', err.message);
25
+ process.exit(1);
26
+ });
27
+
28
+ child.on('exit', (code, signal) => {
29
+ if (signal) {
30
+ process.kill(process.pid, signal);
31
+ } else {
32
+ process.exit(code || 0);
33
+ }
34
+ });
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@altairalabs/packc",
3
+ "version": "0.0.1",
4
+ "description": "PromptKit Pack Compiler - Compile and validate prompt packs for LLM applications",
5
+ "bin": {
6
+ "packc": "./bin/packc.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node postinstall.js",
10
+ "test": "node bin/packc.js version"
11
+ },
12
+ "keywords": [
13
+ "llm",
14
+ "prompt",
15
+ "compiler",
16
+ "validation",
17
+ "ai",
18
+ "prompt-engineering",
19
+ "pack",
20
+ "openai",
21
+ "anthropic",
22
+ "gemini"
23
+ ],
24
+ "author": "Altaira Labs",
25
+ "license": "Apache-2.0",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/AltairaLabs/PromptKit.git",
29
+ "directory": "npm/packc"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/AltairaLabs/PromptKit/issues"
33
+ },
34
+ "homepage": "https://github.com/AltairaLabs/PromptKit#readme",
35
+ "engines": {
36
+ "node": ">=18.0.0"
37
+ },
38
+ "os": [
39
+ "darwin",
40
+ "linux",
41
+ "win32"
42
+ ],
43
+ "cpu": [
44
+ "x64",
45
+ "arm64"
46
+ ],
47
+ "files": [
48
+ "bin/",
49
+ "postinstall.js",
50
+ "README.md"
51
+ ]
52
+ }
package/postinstall.js ADDED
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+
3
+ const https = require('node:https');
4
+ const http = require('node:http');
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
7
+ const { execSync } = require('node:child_process');
8
+ const { pipeline } = require('node:stream');
9
+ const { promisify } = require('node:util');
10
+
11
+ const streamPipeline = promisify(pipeline);
12
+
13
+ const BINARY_NAME = 'packc';
14
+ const GITHUB_REPO = 'AltairaLabs/PromptKit';
15
+ const VERSION = require('./package.json').version;
16
+
17
+ // Platform mapping to match GoReleaser output
18
+ const PLATFORM_MAP = {
19
+ darwin: 'Darwin',
20
+ linux: 'Linux',
21
+ win32: 'Windows'
22
+ };
23
+
24
+ const ARCH_MAP = {
25
+ x64: 'x86_64',
26
+ arm64: 'arm64'
27
+ };
28
+
29
+ function getPlatformInfo() {
30
+ const platform = PLATFORM_MAP[process.platform];
31
+ const arch = ARCH_MAP[process.arch];
32
+
33
+ if (!platform || !arch) {
34
+ throw new Error(`Unsupported platform: ${process.platform}-${process.arch}`);
35
+ }
36
+
37
+ return { platform, arch };
38
+ }
39
+
40
+ function getDownloadUrl(platform, arch) {
41
+ const archiveExt = platform === 'Windows' ? 'zip' : 'tar.gz';
42
+ const archiveName = `PromptKit_v${VERSION}_${platform}_${arch}.${archiveExt}`;
43
+ return `https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${archiveName}`;
44
+ }
45
+
46
+ async function downloadFile(url, destPath) {
47
+ return new Promise((resolve, reject) => {
48
+ const client = url.startsWith('https:') ? https : http;
49
+
50
+ client.get(url, (response) => {
51
+ // Follow redirects
52
+ if (response.statusCode === 302 || response.statusCode === 301) {
53
+ downloadFile(response.headers.location, destPath)
54
+ .then(resolve)
55
+ .catch(reject);
56
+ return;
57
+ }
58
+
59
+ if (response.statusCode !== 200) {
60
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
61
+ return;
62
+ }
63
+
64
+ const fileStream = fs.createWriteStream(destPath);
65
+ streamPipeline(response, fileStream)
66
+ .then(resolve)
67
+ .catch(reject);
68
+ }).on('error', reject);
69
+ });
70
+ }
71
+
72
+ function extractBinary(archivePath, platform, binaryName) {
73
+ const binaryWithExt = platform === 'Windows' ? `${binaryName}.exe` : binaryName;
74
+ const destPath = path.join(__dirname, binaryWithExt);
75
+
76
+ try {
77
+ if (platform === 'Windows') {
78
+ // Extract from zip - the binary should be in the archive root
79
+ execSync(`unzip -j "${archivePath}" "${binaryWithExt}" -d "${__dirname}"`, {
80
+ stdio: 'inherit'
81
+ });
82
+ } else {
83
+ // Extract from tar.gz - the binary should be in the archive root
84
+ execSync(`tar -xzf "${archivePath}" -C "${__dirname}" "${binaryWithExt}"`, {
85
+ stdio: 'inherit'
86
+ });
87
+ }
88
+
89
+ // Make executable on Unix-like systems
90
+ if (platform !== 'Windows') {
91
+ fs.chmodSync(destPath, 0o755);
92
+ }
93
+
94
+ console.log(`āœ“ Extracted ${binaryWithExt}`);
95
+ return destPath;
96
+ } catch (error) {
97
+ throw new Error(`Failed to extract binary: ${error.message}`);
98
+ }
99
+ }
100
+
101
+ async function install() {
102
+ console.log(`Installing ${BINARY_NAME} v${VERSION}...`);
103
+
104
+ const { platform, arch } = getPlatformInfo();
105
+ console.log(`Platform: ${platform} ${arch}`);
106
+
107
+ const url = getDownloadUrl(platform, arch);
108
+ const archiveExt = platform === 'Windows' ? 'zip' : 'tar.gz';
109
+ const archivePath = path.join(__dirname, `archive.${archiveExt}`);
110
+
111
+ try {
112
+ console.log('Downloading binary from GitHub Releases...');
113
+ await downloadFile(url, archivePath);
114
+ console.log('āœ“ Download complete');
115
+
116
+ console.log('Extracting binary...');
117
+ extractBinary(archivePath, platform, BINARY_NAME);
118
+
119
+ // Clean up archive
120
+ fs.unlinkSync(archivePath);
121
+
122
+ console.log(`āœ“ ${BINARY_NAME} installed successfully!`);
123
+ } catch (error) {
124
+ console.error(`\nāŒ Installation failed: ${error.message}`);
125
+ console.error('\nTroubleshooting:');
126
+ console.error('1. Verify version exists: https://github.com/AltairaLabs/PromptKit/releases');
127
+ console.error('2. Check your internet connection');
128
+ console.error('3. Try downloading manually from GitHub Releases');
129
+ console.error(` URL: ${url}`);
130
+ process.exit(1);
131
+ }
132
+ }
133
+
134
+ await install();