@punkcode/cli 0.1.3 → 0.1.5
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 +4 -0
- package/dist/cli.js +24 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,10 @@ Your machine will appear in the punk app — you can now send prompts to Claude
|
|
|
38
38
|
| `punk connect` | Connect this machine to punk |
|
|
39
39
|
| `punk logout` | Log out and clear stored credentials |
|
|
40
40
|
|
|
41
|
+
## Cloud Deployment
|
|
42
|
+
|
|
43
|
+
Run Punk on a cloud server with Ollama cloud models (no Anthropic API key required). See the [Cloud Deployment Guide](docs/cloud-deployment.md).
|
|
44
|
+
|
|
41
45
|
## Updating
|
|
42
46
|
|
|
43
47
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -43,6 +43,7 @@ function runClaude(options, callbacks) {
|
|
|
43
43
|
prompt: options.images?.length ? promptWithImages(options.prompt, options.images, options.sessionId || "") : options.prompt,
|
|
44
44
|
options: {
|
|
45
45
|
permissionMode: opts.permissionMode || "default",
|
|
46
|
+
settingSources: ["user", "project"],
|
|
46
47
|
...isBypass && { allowDangerouslySkipPermissions: true },
|
|
47
48
|
...opts.model && { model: opts.model },
|
|
48
49
|
...opts.allowedTools && { allowedTools: opts.allowedTools },
|
|
@@ -179,11 +180,14 @@ function getOrCreateDeviceId() {
|
|
|
179
180
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
180
181
|
return id;
|
|
181
182
|
}
|
|
182
|
-
function collectDeviceInfo(deviceId) {
|
|
183
|
+
function collectDeviceInfo(deviceId, customName) {
|
|
184
|
+
if (customName) {
|
|
185
|
+
saveConfigField("deviceName", customName);
|
|
186
|
+
}
|
|
183
187
|
const cpus = os.cpus();
|
|
184
188
|
return {
|
|
185
189
|
deviceId,
|
|
186
|
-
name: getDeviceName(),
|
|
190
|
+
name: customName || getDeviceName(),
|
|
187
191
|
platform: process.platform,
|
|
188
192
|
arch: process.arch,
|
|
189
193
|
username: os.userInfo().username,
|
|
@@ -197,6 +201,11 @@ function collectDeviceInfo(deviceId) {
|
|
|
197
201
|
};
|
|
198
202
|
}
|
|
199
203
|
function getDeviceName() {
|
|
204
|
+
try {
|
|
205
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
|
|
206
|
+
if (config.deviceName) return config.deviceName;
|
|
207
|
+
} catch {
|
|
208
|
+
}
|
|
200
209
|
if (process.platform === "darwin") {
|
|
201
210
|
try {
|
|
202
211
|
const { stdout } = execaSync("scutil", ["--get", "ComputerName"], { timeout: 3e3 });
|
|
@@ -207,6 +216,16 @@ function getDeviceName() {
|
|
|
207
216
|
}
|
|
208
217
|
return os.hostname();
|
|
209
218
|
}
|
|
219
|
+
function saveConfigField(key, value) {
|
|
220
|
+
fs.mkdirSync(PUNK_DIR, { recursive: true });
|
|
221
|
+
let config = {};
|
|
222
|
+
try {
|
|
223
|
+
config = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
|
|
224
|
+
} catch {
|
|
225
|
+
}
|
|
226
|
+
config[key] = value;
|
|
227
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
228
|
+
}
|
|
210
229
|
function parseBattery() {
|
|
211
230
|
try {
|
|
212
231
|
if (process.platform === "darwin") {
|
|
@@ -777,7 +796,7 @@ async function connect(server, options) {
|
|
|
777
796
|
const activeSessions = /* @__PURE__ */ new Map();
|
|
778
797
|
socket.on("connect", () => {
|
|
779
798
|
logger.info("Connected");
|
|
780
|
-
const deviceInfo = collectDeviceInfo(deviceId);
|
|
799
|
+
const deviceInfo = collectDeviceInfo(deviceId, options.name);
|
|
781
800
|
socket.emit("register", deviceInfo, (response) => {
|
|
782
801
|
if (response.success) {
|
|
783
802
|
logger.info({ deviceId }, "Registered");
|
|
@@ -825,7 +844,7 @@ async function connect(server, options) {
|
|
|
825
844
|
});
|
|
826
845
|
socket.on("reconnect", (attemptNumber) => {
|
|
827
846
|
logger.info({ attemptNumber }, "Reconnected");
|
|
828
|
-
socket.emit("register", collectDeviceInfo(deviceId));
|
|
847
|
+
socket.emit("register", collectDeviceInfo(deviceId, options.name));
|
|
829
848
|
});
|
|
830
849
|
socket.on("connect_error", (err) => {
|
|
831
850
|
logger.error({ err }, "Connection error");
|
|
@@ -1021,7 +1040,7 @@ function logout() {
|
|
|
1021
1040
|
|
|
1022
1041
|
// src/commands/index.ts
|
|
1023
1042
|
function registerCommands(program2) {
|
|
1024
|
-
program2.command("connect").argument("[server]", "Backend server URL", "https://api.punkcode.dev").description("Connect to backend server").option("-t, --token <token>", "Authentication token").option("-d, --device-id <deviceId>", "Device identifier (defaults to hostname)").action(connect);
|
|
1043
|
+
program2.command("connect").argument("[server]", "Backend server URL", "https://api.punkcode.dev").description("Connect to backend server").option("-t, --token <token>", "Authentication token").option("-d, --device-id <deviceId>", "Device identifier (defaults to hostname)").option("-n, --name <name>", "Custom device display name").action(connect);
|
|
1025
1044
|
program2.command("login").description("Log in with your email and password").action(login);
|
|
1026
1045
|
program2.command("logout").description("Log out and clear stored credentials").action(logout);
|
|
1027
1046
|
}
|