@amanm/openpaw 0.1.2 → 0.2.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 CHANGED
@@ -18,10 +18,11 @@ OpenPaw is a Bun + TypeScript local agent runtime with:
18
18
  Global install (recommended for end users):
19
19
 
20
20
  ```bash
21
- npm i -g openpaw
21
+ npm i -g @amanm/openpaw
22
22
  ```
23
23
 
24
- The first `openpaw` run checks for Bun. If Bun is missing on macOS/Linux, OpenPaw prompts to install it automatically.
24
+ After install you can run `openpaw` (and `opaw`) commands directly.
25
+ The first run checks for Bun. If Bun is missing on macOS/Linux, OpenPaw prompts to install it automatically.
25
26
 
26
27
  Windows note: Bun auto-install is not performed yet. Install Bun manually from `https://bun.sh/docs/installation`.
27
28
 
@@ -41,6 +42,8 @@ Main commands:
41
42
 
42
43
  - `openpaw onboard`
43
44
  Interactive onboarding (provider URL, API key, model, optional Telegram token, personality)
45
+ - `openpaw update`
46
+ Update to the latest published version (uses Bun or npm based on your global install)
44
47
  - `openpaw tui`
45
48
  Start local terminal chat UI
46
49
  - `openpaw gateway dev`
package/cli/openpaw.tsx CHANGED
@@ -4,6 +4,8 @@ import { startGateway } from "../gateway";
4
4
  import { runOpenPawTui } from "./tui";
5
5
  import { handleOnboard } from "./onboard";
6
6
  import { handleReset } from "./reset";
7
+ import { handleUpdate } from "./update";
8
+ import { getOpenPawVersion } from "./version";
7
9
  import {
8
10
  getGatewayDaemonStatus,
9
11
  readGatewayDaemonLog,
@@ -11,7 +13,7 @@ import {
11
13
  stopGatewayDaemon,
12
14
  } from "../gateway/daemon-manager";
13
15
 
14
- program.version("0.1.0").description("OpenPaw");
16
+ program.version(getOpenPawVersion()).description("OpenPaw");
15
17
 
16
18
  program
17
19
  .command("reset")
@@ -32,6 +34,18 @@ program
32
34
  .description("Go through the onboarding setup")
33
35
  .action(handleOnboard);
34
36
 
37
+ program
38
+ .command("update")
39
+ .description("Update OpenPaw to the latest published release")
40
+ .action(() => {
41
+ try {
42
+ handleUpdate();
43
+ } catch (e) {
44
+ console.error(e instanceof Error ? e.message : e);
45
+ process.exitCode = 1;
46
+ }
47
+ });
48
+
35
49
  const gateway = program.command("gateway").description("Run messaging channel adapters (shared agent runtime)");
36
50
 
37
51
  gateway
package/cli/update.ts ADDED
@@ -0,0 +1,114 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { spawnSync } from "node:child_process";
3
+ import { fileURLToPath } from "node:url";
4
+ import { dirname, join } from "node:path";
5
+
6
+ /** Minimal package metadata used for self-update command resolution. */
7
+ type OpenPawPackageMeta = {
8
+ name?: string;
9
+ };
10
+
11
+ /** Supported global package managers for self-update behavior. */
12
+ type GlobalPackageManager = "bun" | "npm";
13
+
14
+ /**
15
+ * Reads package metadata from the shipped `package.json` next to the project root.
16
+ */
17
+ function readPackageMeta(): OpenPawPackageMeta {
18
+ const cliDir = dirname(fileURLToPath(import.meta.url));
19
+ const packageJsonPath = join(cliDir, "..", "package.json");
20
+ const raw = readFileSync(packageJsonPath, "utf8");
21
+ return JSON.parse(raw) as OpenPawPackageMeta;
22
+ }
23
+
24
+ /**
25
+ * Resolves the npm package id to update. Falls back to `@amanm/openpaw` if metadata is missing.
26
+ */
27
+ function resolvePackageName(): string {
28
+ const meta = readPackageMeta();
29
+ const name = meta.name?.trim();
30
+ return name && name.length > 0 ? name : "@amanm/openpaw";
31
+ }
32
+
33
+ /**
34
+ * Ensures npm is available on PATH for update operations.
35
+ */
36
+ function ensureNpmAvailable(): void {
37
+ const check = spawnSync("npm", ["--version"], { stdio: "ignore" });
38
+ if (check.status !== 0) {
39
+ throw new Error("npm is required for `openpaw update` but was not found on PATH.");
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Ensures Bun is available on PATH for update operations.
45
+ */
46
+ function ensureBunAvailable(): void {
47
+ const check = spawnSync("bun", ["--version"], { stdio: "ignore" });
48
+ if (check.status !== 0) {
49
+ throw new Error("Bun is required for `openpaw update` in Bun-global mode but was not found.");
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Returns command output lines for a shell command or an empty string on failure.
55
+ */
56
+ function readCommandStdout(command: string, args: string[]): string {
57
+ const out = spawnSync(command, args, { encoding: "utf8" });
58
+ if (out.status !== 0) {
59
+ return "";
60
+ }
61
+ return String(out.stdout ?? "").trim();
62
+ }
63
+
64
+ /**
65
+ * Determines whether the current global `openpaw` command resolves from Bun or npm global bin.
66
+ */
67
+ function detectGlobalPackageManager(): GlobalPackageManager {
68
+ const commandPath = readCommandStdout("bash", ["-lc", "command -v openpaw || command -v opaw || true"]);
69
+ const bunGlobalBin = readCommandStdout("bun", ["pm", "bin", "-g"]);
70
+ const npmGlobalBin = readCommandStdout("npm", ["bin", "-g"]);
71
+
72
+ if (commandPath && bunGlobalBin && commandPath.startsWith(bunGlobalBin)) {
73
+ return "bun";
74
+ }
75
+ if (commandPath && npmGlobalBin && commandPath.startsWith(npmGlobalBin)) {
76
+ return "npm";
77
+ }
78
+
79
+ // Default to npm for broader compatibility if install origin cannot be inferred.
80
+ return "npm";
81
+ }
82
+
83
+ /**
84
+ * Updates this globally-installed package to the latest published version with the matching package manager.
85
+ */
86
+ export function handleUpdate(): void {
87
+ const packageName = resolvePackageName();
88
+ const target = `${packageName}@latest`;
89
+ const manager = detectGlobalPackageManager();
90
+
91
+ if (manager === "bun") {
92
+ ensureBunAvailable();
93
+ console.log(`Updating ${target} using Bun global install ...`);
94
+ const run = spawnSync("bun", ["install", "-g", target], {
95
+ stdio: "inherit",
96
+ });
97
+ if (run.status !== 0) {
98
+ throw new Error(`Update failed for ${target} using Bun.`);
99
+ }
100
+ console.log(`Updated ${packageName} to latest via Bun.`);
101
+ return;
102
+ }
103
+
104
+ ensureNpmAvailable();
105
+ console.log(`Updating ${target} using npm global install ...`);
106
+ const run = spawnSync("npm", ["install", "-g", target], {
107
+ stdio: "inherit",
108
+ });
109
+ if (run.status !== 0) {
110
+ throw new Error(`Update failed for ${target} using npm.`);
111
+ }
112
+
113
+ console.log(`Updated ${packageName} to latest via npm.`);
114
+ }
package/cli/version.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ /** Partial package metadata needed for CLI version reporting. */
6
+ type OpenPawPackageMeta = {
7
+ version?: string;
8
+ };
9
+
10
+ /**
11
+ * Reads package metadata from the repository/package root.
12
+ */
13
+ function readPackageMeta(): OpenPawPackageMeta {
14
+ const cliDir = dirname(fileURLToPath(import.meta.url));
15
+ const packageJsonPath = join(cliDir, "..", "package.json");
16
+ const raw = readFileSync(packageJsonPath, "utf8");
17
+ return JSON.parse(raw) as OpenPawPackageMeta;
18
+ }
19
+
20
+ /**
21
+ * Returns the CLI version from package metadata, with a safe fallback.
22
+ */
23
+ export function getOpenPawVersion(): string {
24
+ try {
25
+ const version = readPackageMeta().version?.trim();
26
+ return version && version.length > 0 ? version : "0.0.0";
27
+ } catch {
28
+ return "0.0.0";
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@amanm/openpaw",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "Local Bun + TypeScript agent runtime with TUI and messaging gateway adapters.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/amanmprojects/openpaw"
7
+ "url": "git+https://github.com/amanmprojects/openpaw.git"
8
8
  },
9
9
  "homepage": "https://github.com/amanmprojects/openpaw",
10
10
  "bugs": {
@@ -13,7 +13,8 @@
13
13
  "license": "MIT",
14
14
  "type": "module",
15
15
  "bin": {
16
- "openpaw": "bin/openpaw.cjs"
16
+ "openpaw": "bin/openpaw.cjs",
17
+ "opaw": "bin/openpaw.cjs"
17
18
  },
18
19
  "scripts": {
19
20
  "openpaw": "bun run ./cli/openpaw.tsx",