ai-passport 0.1.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.
Files changed (2) hide show
  1. package/bin/ai-passport.js +67 -0
  2. package/package.json +16 -0
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ const { spawnSync } = require('child_process')
5
+ const { platform } = require('os')
6
+
7
+ const passedArgs = process.argv.slice(2)
8
+ // Default: run the full pipeline and open the browser
9
+ const cliArgs = passedArgs.length === 0 ? ['run', '--open'] : passedArgs
10
+
11
+ // ── Find Python 3.10+ ────────────────────────────────────────────────────────
12
+ function findPython() {
13
+ const candidates = platform() === 'win32'
14
+ ? ['py', 'python', 'python3']
15
+ : ['python3', 'python']
16
+ for (const cmd of candidates) {
17
+ try {
18
+ const r = spawnSync(cmd, ['--version'], { encoding: 'utf8', timeout: 5000 })
19
+ const versionStr = (r.stdout || '') + (r.stderr || '')
20
+ const m = versionStr.match(/Python (\d+)\.(\d+)/)
21
+ if (m && r.status === 0) {
22
+ const [, major, minor] = m.map(Number)
23
+ if (major > 3 || (major === 3 && minor >= 10)) return cmd
24
+ }
25
+ } catch {}
26
+ }
27
+ return null
28
+ }
29
+
30
+ const python = findPython()
31
+ if (!python) {
32
+ console.error(
33
+ '\nError: Python 3.10+ is required.\n' +
34
+ 'Install it from https://python.org and try again.\n'
35
+ )
36
+ process.exit(1)
37
+ }
38
+
39
+ // ── Ensure ai-passport pip package is installed ───────────────────────────────
40
+ const check = spawnSync(python, ['-c', 'import passport'], { encoding: 'utf8', timeout: 10000 })
41
+ if (check.status !== 0) {
42
+ console.log('First run: installing ai-passport Python package…')
43
+ const install = spawnSync(
44
+ python, ['-m', 'pip', 'install', '--quiet', 'ai-passport'],
45
+ { stdio: 'inherit', timeout: 120000 }
46
+ )
47
+ if (install.status !== 0) {
48
+ console.error('\nFailed to install ai-passport. Run manually: pip install ai-passport\n')
49
+ process.exit(1)
50
+ }
51
+ }
52
+
53
+ // ── Check ANTHROPIC_API_KEY for commands that call the API ───────────────────
54
+ const needsKey = !cliArgs[0] || cliArgs[0] === 'run' || cliArgs[0] === 'generate'
55
+ if (needsKey && !process.env.ANTHROPIC_API_KEY) {
56
+ console.error(
57
+ '\nError: ANTHROPIC_API_KEY is not set.\n\n' +
58
+ 'Get your key at https://console.anthropic.com/keys, then set it:\n' +
59
+ ' Mac / Linux: export ANTHROPIC_API_KEY=sk-ant-...\n' +
60
+ ' Windows PS: $env:ANTHROPIC_API_KEY="sk-ant-..."\n'
61
+ )
62
+ process.exit(1)
63
+ }
64
+
65
+ // ── Run the CLI via python -m passport ───────────────────────────────────────
66
+ const result = spawnSync(python, ['-m', 'passport', ...cliArgs], { stdio: 'inherit' })
67
+ process.exit(result.status ?? 1)
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "ai-passport",
3
+ "version": "0.1.0",
4
+ "description": "Generate your AI Capability Passport from Claude Code and Codex sessions",
5
+ "keywords": ["ai", "claude", "passport", "capability", "metrics", "anthropic"],
6
+ "license": "MIT",
7
+ "bin": {
8
+ "ai-passport": "./bin/ai-passport.js"
9
+ },
10
+ "engines": {
11
+ "node": ">=18"
12
+ },
13
+ "files": [
14
+ "bin"
15
+ ]
16
+ }