@esimplicity/prima-code 1.0.0-dev
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 +86 -0
- package/bin/prima.js +144 -0
- package/bin/rg +79 -0
- package/package.json +21 -0
- package/vendor/aarch64-apple-darwin/path/rg +0 -0
- package/vendor/aarch64-apple-darwin/prima/prima +0 -0
- package/vendor/x86_64-apple-darwin/path/rg +0 -0
- package/vendor/x86_64-apple-darwin/prima/prima +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Prima Code CLI
|
|
2
|
+
|
|
3
|
+
Prima Code is a cross-platform command-line workspace assistant. It gives you an interactive shell for searching, editing, and reasoning inside your repositories with the help of the Prima agent.
|
|
4
|
+
|
|
5
|
+
## Install from npm
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @esimplicity/prima-code
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Requirements
|
|
12
|
+
|
|
13
|
+
- macOS, Linux, or Windows (x64 or arm64)
|
|
14
|
+
- Node.js 16+ and npm (or use `corepack` to manage npm versions)
|
|
15
|
+
- A Prima governance platform
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
1. Authenticate with npm (if your organization requires it) and install the package globally.
|
|
20
|
+
2. Create a config.toml at ~/.prima/config.toml that looks similar to:
|
|
21
|
+
```bash
|
|
22
|
+
approval_policy = "on-request"
|
|
23
|
+
sandbox_mode = "workspace-write"
|
|
24
|
+
|
|
25
|
+
[model_providers.prima]
|
|
26
|
+
name = "OpenAI"
|
|
27
|
+
base_url = "http://api.prima.<yoursite>.com/v1"
|
|
28
|
+
env_key = "PRIMA_API_KEY"
|
|
29
|
+
wire_api = "chat"
|
|
30
|
+
|
|
31
|
+
[profiles.prima]
|
|
32
|
+
model_provider = "prima"
|
|
33
|
+
model = "prima-gpt-5"
|
|
34
|
+
```
|
|
35
|
+
3. Launch the CLI:
|
|
36
|
+
```bash
|
|
37
|
+
prima
|
|
38
|
+
```
|
|
39
|
+
4. Follow the on-screen prompts. Press `Ctrl+C` to exit.
|
|
40
|
+
|
|
41
|
+
## Updating
|
|
42
|
+
|
|
43
|
+
To upgrade to the latest published version:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm update -g @esimplicity/prima-code
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Check the current version with:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
prima --version
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
- Prima uses the config.toml to load the models and workspaces available via prima.
|
|
58
|
+
- Additional settings can be provided through the CLI flags; run `prima --help` for details.
|
|
59
|
+
- Proxy or custom CA environments should configure standard Node.js variables (`HTTPS_PROXY`, `NODE_EXTRA_CA_CERTS`, etc.).
|
|
60
|
+
|
|
61
|
+
## Troubleshooting
|
|
62
|
+
|
|
63
|
+
- **Binary not found:** Reinstall the package or ensure that your global npm bin directory (e.g., `~/.npm-global/bin`) is on `PATH`.
|
|
64
|
+
- **Permission errors on install:** Use `npm config set prefix ~/.npm-global` or install via `fnm/nvm`-managed Node to avoid using `sudo`.
|
|
65
|
+
- **401 or rate limits from Prima:** Verify the API key, usage quotas, and network connectivity.
|
|
66
|
+
|
|
67
|
+
## Develop from source
|
|
68
|
+
|
|
69
|
+
Developers who clone the repository can build the CLI manually:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd codex-rs
|
|
73
|
+
cargo build
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The debug binary lands in `codex-rs/target/debug/prima`. You still need to export `OPENAI_API_KEY` before running it.
|
|
77
|
+
|
|
78
|
+
Run the Rust unit tests with:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
cargo test
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Contributing
|
|
85
|
+
|
|
86
|
+
Issues and pull requests are welcome. Please use the repository issue tracker to report bugs or request features. When contributing code, run `cargo fmt`, `cargo test`, and follow the project’s linting rules described in the `codex-rs` README and the `/codex-cli/scripts` documentation.
|
package/bin/prima.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unified entry point for the Prima CLI.
|
|
3
|
+
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { existsSync } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
|
|
9
|
+
// __dirname equivalent in ESM
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
|
|
13
|
+
const { platform, arch } = process;
|
|
14
|
+
|
|
15
|
+
let targetTriple = null;
|
|
16
|
+
switch (platform) {
|
|
17
|
+
case "linux":
|
|
18
|
+
case "android":
|
|
19
|
+
switch (arch) {
|
|
20
|
+
case "x64":
|
|
21
|
+
targetTriple = "x86_64-unknown-linux-musl";
|
|
22
|
+
break;
|
|
23
|
+
case "arm64":
|
|
24
|
+
targetTriple = "aarch64-unknown-linux-musl";
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case "darwin":
|
|
31
|
+
switch (arch) {
|
|
32
|
+
case "x64":
|
|
33
|
+
targetTriple = "x86_64-apple-darwin";
|
|
34
|
+
break;
|
|
35
|
+
case "arm64":
|
|
36
|
+
targetTriple = "aarch64-apple-darwin";
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case "win32":
|
|
43
|
+
switch (arch) {
|
|
44
|
+
case "x64":
|
|
45
|
+
targetTriple = "x86_64-pc-windows-msvc";
|
|
46
|
+
break;
|
|
47
|
+
case "arm64":
|
|
48
|
+
targetTriple = "aarch64-pc-windows-msvc";
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!targetTriple) {
|
|
59
|
+
throw new Error(`Unsupported platform: ${platform} (${arch})`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const vendorRoot = path.join(__dirname, "..", "vendor");
|
|
63
|
+
const archRoot = path.join(vendorRoot, targetTriple);
|
|
64
|
+
const primaBinaryName = process.platform === "win32" ? "prima.exe" : "prima";
|
|
65
|
+
const binaryPath = path.join(archRoot, "prima", primaBinaryName);
|
|
66
|
+
|
|
67
|
+
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
68
|
+
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
69
|
+
// executing. This allows us to forward those signals to the child process
|
|
70
|
+
// and guarantees that when either the child terminates or the parent
|
|
71
|
+
// receives a fatal signal, both processes exit in a predictable manner.
|
|
72
|
+
|
|
73
|
+
function getUpdatedPath(newDirs) {
|
|
74
|
+
const pathSep = process.platform === "win32" ? ";" : ":";
|
|
75
|
+
const existingPath = process.env.PATH || "";
|
|
76
|
+
const updatedPath = [
|
|
77
|
+
...newDirs,
|
|
78
|
+
...existingPath.split(pathSep).filter(Boolean),
|
|
79
|
+
].join(pathSep);
|
|
80
|
+
return updatedPath;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const additionalDirs = [];
|
|
84
|
+
const pathDir = path.join(archRoot, "path");
|
|
85
|
+
if (existsSync(pathDir)) {
|
|
86
|
+
additionalDirs.push(pathDir);
|
|
87
|
+
}
|
|
88
|
+
const updatedPath = getUpdatedPath(additionalDirs);
|
|
89
|
+
|
|
90
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
91
|
+
stdio: "inherit",
|
|
92
|
+
env: { ...process.env, PATH: updatedPath, CODEX_MANAGED_BY_NPM: "1" },
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
child.on("error", (err) => {
|
|
96
|
+
// Typically triggered when the binary is missing or not executable.
|
|
97
|
+
// Re-throwing here will terminate the parent with a non-zero exit code
|
|
98
|
+
// while still printing a helpful stack trace.
|
|
99
|
+
// eslint-disable-next-line no-console
|
|
100
|
+
console.error(err);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Forward common termination signals to the child so that it shuts down
|
|
105
|
+
// gracefully. In the handler we temporarily disable the default behavior of
|
|
106
|
+
// exiting immediately; once the child has been signaled we simply wait for
|
|
107
|
+
// its exit event which will in turn terminate the parent (see below).
|
|
108
|
+
const forwardSignal = (signal) => {
|
|
109
|
+
if (child.killed) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
child.kill(signal);
|
|
114
|
+
} catch {
|
|
115
|
+
/* ignore */
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
|
|
120
|
+
process.on(sig, () => forwardSignal(sig));
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// When the child exits, mirror its termination reason in the parent so that
|
|
124
|
+
// shell scripts and other tooling observe the correct exit status.
|
|
125
|
+
// Wrap the lifetime of the child process in a Promise so that we can await
|
|
126
|
+
// its termination in a structured way. The Promise resolves with an object
|
|
127
|
+
// describing how the child exited: either via exit code or due to a signal.
|
|
128
|
+
const childResult = await new Promise((resolve) => {
|
|
129
|
+
child.on("exit", (code, signal) => {
|
|
130
|
+
if (signal) {
|
|
131
|
+
resolve({ type: "signal", signal });
|
|
132
|
+
} else {
|
|
133
|
+
resolve({ type: "code", exitCode: code ?? 1 });
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (childResult.type === "signal") {
|
|
139
|
+
// Re-emit the same signal so that the parent terminates with the expected
|
|
140
|
+
// semantics (this also sets the correct exit code of 128 + n).
|
|
141
|
+
process.kill(process.pid, childResult.signal);
|
|
142
|
+
} else {
|
|
143
|
+
process.exit(childResult.exitCode);
|
|
144
|
+
}
|
package/bin/rg
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env dotslash
|
|
2
|
+
|
|
3
|
+
{
|
|
4
|
+
"name": "rg",
|
|
5
|
+
"platforms": {
|
|
6
|
+
"macos-aarch64": {
|
|
7
|
+
"size": 1787248,
|
|
8
|
+
"hash": "blake3",
|
|
9
|
+
"digest": "8d9942032585ea8ee805937634238d9aee7b210069f4703c88fbe568e26fb78a",
|
|
10
|
+
"format": "tar.gz",
|
|
11
|
+
"path": "ripgrep-14.1.1-aarch64-apple-darwin/rg",
|
|
12
|
+
"providers": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-aarch64-apple-darwin.tar.gz"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"linux-aarch64": {
|
|
19
|
+
"size": 2047405,
|
|
20
|
+
"hash": "blake3",
|
|
21
|
+
"digest": "0b670b8fa0a3df2762af2fc82cc4932f684ca4c02dbd1260d4f3133fd4b2a515",
|
|
22
|
+
"format": "tar.gz",
|
|
23
|
+
"path": "ripgrep-14.1.1-aarch64-unknown-linux-gnu/rg",
|
|
24
|
+
"providers": [
|
|
25
|
+
{
|
|
26
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-aarch64-unknown-linux-gnu.tar.gz"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"macos-x86_64": {
|
|
31
|
+
"size": 2082672,
|
|
32
|
+
"hash": "blake3",
|
|
33
|
+
"digest": "e9b862fc8da3127f92791f0ff6a799504154ca9d36c98bf3e60a81c6b1f7289e",
|
|
34
|
+
"format": "tar.gz",
|
|
35
|
+
"path": "ripgrep-14.1.1-x86_64-apple-darwin/rg",
|
|
36
|
+
"providers": [
|
|
37
|
+
{
|
|
38
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-apple-darwin.tar.gz"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"linux-x86_64": {
|
|
43
|
+
"size": 2566310,
|
|
44
|
+
"hash": "blake3",
|
|
45
|
+
"digest": "f73cca4e54d78c31f832c7f6e2c0b4db8b04fa3eaa747915727d570893dbee76",
|
|
46
|
+
"format": "tar.gz",
|
|
47
|
+
"path": "ripgrep-14.1.1-x86_64-unknown-linux-musl/rg",
|
|
48
|
+
"providers": [
|
|
49
|
+
{
|
|
50
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-unknown-linux-musl.tar.gz"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"windows-x86_64": {
|
|
55
|
+
"size": 2058893,
|
|
56
|
+
"hash": "blake3",
|
|
57
|
+
"digest": "a8ce1a6fed4f8093ee997e57f33254e94b2cd18e26358b09db599c89882eadbd",
|
|
58
|
+
"format": "zip",
|
|
59
|
+
"path": "ripgrep-14.1.1-x86_64-pc-windows-msvc/rg.exe",
|
|
60
|
+
"providers": [
|
|
61
|
+
{
|
|
62
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-pc-windows-msvc.zip"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"windows-aarch64": {
|
|
67
|
+
"size": 1667740,
|
|
68
|
+
"hash": "blake3",
|
|
69
|
+
"digest": "47b971a8c4fca1d23a4e7c19bd4d88465ebc395598458133139406d3bf85f3fa",
|
|
70
|
+
"format": "zip",
|
|
71
|
+
"path": "rg.exe",
|
|
72
|
+
"providers": [
|
|
73
|
+
{
|
|
74
|
+
"url": "https://github.com/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-13/ripgrep-v13.0.0-13-aarch64-pc-windows-msvc.zip"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@esimplicity/prima-code",
|
|
3
|
+
"version": "1.0.0-dev",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"bin": {
|
|
6
|
+
"prima": "bin/prima.js"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=16"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"vendor"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/esimplicityinc/prima-code.git",
|
|
19
|
+
"directory": "codex-cli"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|