@petersr/claude-p 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.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/bin/claude-p.cjs +5 -0
- package/lib/launch.cjs +31 -0
- package/lib/resolve.cjs +45 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Peter Severin Rasmussen
|
|
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,30 @@
|
|
|
1
|
+
# @petersr/claude-p
|
|
2
|
+
|
|
3
|
+
A `claude -p` drop-in backed by your interactive Claude Code subscription, not
|
|
4
|
+
the Agent SDK credit path. This package installs a prebuilt `claude-p` binary
|
|
5
|
+
for your platform.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i -g @petersr/claude-p
|
|
9
|
+
|
|
10
|
+
claude-p "summarise CHANGELOG.md"
|
|
11
|
+
echo "what does this script do?" | claude-p
|
|
12
|
+
claude-p --output-format json "write a haiku about Go modules"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`claude-p` drives interactive Claude Code in a pty (via
|
|
16
|
+
[pupptyeer](https://github.com/PeterSR/pupptyeer)) and reads the answer from
|
|
17
|
+
claude's own persisted transcript. It needs the official `claude` CLI installed
|
|
18
|
+
and logged in.
|
|
19
|
+
|
|
20
|
+
For the full CLI surface, daemon mode (`--pupptyeer-daemon`, persistent
|
|
21
|
+
multi-turn sessions), the Go library, and the MCP bridge, see the
|
|
22
|
+
[project README](https://github.com/PeterSR/claude-p#readme).
|
|
23
|
+
|
|
24
|
+
## How it resolves the binary
|
|
25
|
+
|
|
26
|
+
The matching `@petersr/claude-p-<os>-<arch>` package is pulled in as an optional
|
|
27
|
+
dependency and the launcher execs its bundled binary. Prefer the raw binary?
|
|
28
|
+
Grab one from [GitHub Releases](https://github.com/PeterSR/claude-p/releases).
|
|
29
|
+
|
|
30
|
+
MIT licensed.
|
package/bin/claude-p.cjs
ADDED
package/lib/launch.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const { resolveBinary } = require("./resolve.cjs");
|
|
5
|
+
|
|
6
|
+
// Resolve the named bundled binary, exec it with this process's args, and
|
|
7
|
+
// propagate its exit status (or terminating signal). Used by the bin shim.
|
|
8
|
+
function launch(name) {
|
|
9
|
+
let bin;
|
|
10
|
+
try {
|
|
11
|
+
bin = resolveBinary(name);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
console.error(err.message);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
18
|
+
|
|
19
|
+
if (result.error) {
|
|
20
|
+
console.error(`claude-p: failed to launch ${bin}: ${result.error.message}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
if (result.signal) {
|
|
24
|
+
// Re-raise the signal so callers see the child's termination cause.
|
|
25
|
+
process.kill(process.pid, result.signal);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { launch };
|
package/lib/resolve.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Map this Node process's platform to the per-platform npm package that ships
|
|
4
|
+
// its prebuilt binary. Keep this table in step with ../../platforms.mjs (this
|
|
5
|
+
// copy stays plain CommonJS so the wrapper needs no build step).
|
|
6
|
+
const SUPPORTED = {
|
|
7
|
+
"linux-x64": "@petersr/claude-p-linux-x64",
|
|
8
|
+
"linux-arm64": "@petersr/claude-p-linux-arm64",
|
|
9
|
+
"darwin-x64": "@petersr/claude-p-darwin-x64",
|
|
10
|
+
"darwin-arm64": "@petersr/claude-p-darwin-arm64",
|
|
11
|
+
"win32-x64": "@petersr/claude-p-win32-x64",
|
|
12
|
+
"win32-arm64": "@petersr/claude-p-win32-arm64",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function platformKey() {
|
|
16
|
+
return `${process.platform}-${process.arch}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Resolve the absolute path to the bundled "claude-p" binary inside the
|
|
20
|
+
// matching platform package. Throws with an actionable message if the platform
|
|
21
|
+
// is unsupported or its package is absent.
|
|
22
|
+
function resolveBinary(name) {
|
|
23
|
+
const key = platformKey();
|
|
24
|
+
const pkg = SUPPORTED[key];
|
|
25
|
+
if (!pkg) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`claude-p: unsupported platform "${key}". Supported: ${Object.keys(SUPPORTED).join(", ")}.\n` +
|
|
28
|
+
`Build from source instead: https://github.com/PeterSR/claude-p`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
32
|
+
try {
|
|
33
|
+
return require.resolve(`${pkg}/bin/${name}${ext}`);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`claude-p: the platform package "${pkg}" is not installed.\n` +
|
|
37
|
+
`It should install automatically as an optional dependency of "@petersr/claude-p".\n` +
|
|
38
|
+
`If you used --no-optional or --omit=optional, reinstall without it, or run:\n` +
|
|
39
|
+
` npm i ${pkg}\n` +
|
|
40
|
+
`Underlying error: ${err && err.message ? err.message : err}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { resolveBinary, platformKey, SUPPORTED };
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@petersr/claude-p",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A claude -p drop-in backed by your interactive Claude Code subscription. Installs a prebuilt binary for your platform.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"claude-p": "bin/claude-p.cjs"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"lib",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"claude",
|
|
16
|
+
"claude-code",
|
|
17
|
+
"claude-p",
|
|
18
|
+
"cli",
|
|
19
|
+
"agent",
|
|
20
|
+
"anthropic"
|
|
21
|
+
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/PeterSR/claude-p.git",
|
|
25
|
+
"directory": "npm/claude-p"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/PeterSR/claude-p#readme",
|
|
28
|
+
"bugs": "https://github.com/PeterSR/claude-p/issues",
|
|
29
|
+
"author": "PeterSR",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"optionalDependencies": {
|
|
35
|
+
"@petersr/claude-p-linux-x64": "0.1.0",
|
|
36
|
+
"@petersr/claude-p-linux-arm64": "0.1.0",
|
|
37
|
+
"@petersr/claude-p-darwin-x64": "0.1.0",
|
|
38
|
+
"@petersr/claude-p-darwin-arm64": "0.1.0",
|
|
39
|
+
"@petersr/claude-p-win32-x64": "0.1.0",
|
|
40
|
+
"@petersr/claude-p-win32-arm64": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|