palmier 0.3.0 → 0.3.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.
@@ -9,7 +9,7 @@ import { spawnCommand } from "./spawn-command.js";
9
9
  import { getAgent } from "./agents/agent.js";
10
10
  import { validateSession } from "./session-store.js";
11
11
  import { publishHostEvent } from "./events.js";
12
- import { getUpdateAvailable, performUpdate } from "./update-checker.js";
12
+ import { currentVersion, getLatestVersion, performUpdate } from "./update-checker.js";
13
13
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
14
  const PLAN_GENERATION_PROMPT = fs.readFileSync(path.join(__dirname, "commands", "plan-generation.md"), "utf-8");
15
15
  /**
@@ -107,7 +107,8 @@ export function createRpcHandler(config, nc) {
107
107
  return {
108
108
  tasks: tasks.map((task) => flattenTask(task)),
109
109
  agents: config.agents ?? [],
110
- update_available: getUpdateAvailable(),
110
+ version: currentVersion,
111
+ latest_version: getLatestVersion(),
111
112
  };
112
113
  }
113
114
  case "task.create": {
@@ -1,11 +1,12 @@
1
+ export declare const currentVersion: string;
1
2
  /**
2
- * Check the npm registry for a newer version of palmier.
3
+ * Check the npm registry for the latest version of palmier.
3
4
  */
4
5
  export declare function checkForUpdate(): Promise<void>;
5
6
  /**
6
- * Get the available update version, or null if up to date.
7
+ * Get the latest version from npm, or null if not yet checked.
7
8
  */
8
- export declare function getUpdateAvailable(): string | null;
9
+ export declare function getLatestVersion(): string | null;
9
10
  /**
10
11
  * Run the update and restart the daemon.
11
12
  * Returns an error message if the update fails.
@@ -5,27 +5,12 @@ import { spawnCommand } from "./spawn-command.js";
5
5
  import { getPlatform } from "./platform/index.js";
6
6
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
7
  const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8"));
8
- const currentVersion = pkg.version;
8
+ export const currentVersion = pkg.version;
9
9
  let latestVersion = null;
10
10
  let lastCheckTime = 0;
11
11
  const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
12
12
  /**
13
- * Compare two semver strings (major.minor.patch).
14
- * Returns true if b is newer than a.
15
- */
16
- function isNewer(a, b) {
17
- const pa = a.split(".").map(Number);
18
- const pb = b.split(".").map(Number);
19
- for (let i = 0; i < 3; i++) {
20
- if ((pb[i] ?? 0) > (pa[i] ?? 0))
21
- return true;
22
- if ((pb[i] ?? 0) < (pa[i] ?? 0))
23
- return false;
24
- }
25
- return false;
26
- }
27
- /**
28
- * Check the npm registry for a newer version of palmier.
13
+ * Check the npm registry for the latest version of palmier.
29
14
  */
30
15
  export async function checkForUpdate() {
31
16
  const now = Date.now();
@@ -39,12 +24,9 @@ export async function checkForUpdate() {
39
24
  if (!res.ok)
40
25
  return;
41
26
  const data = (await res.json());
42
- if (data.version && isNewer(currentVersion, data.version)) {
27
+ if (data.version) {
43
28
  latestVersion = data.version;
44
- console.log(`[update] New version available: ${data.version} (current: ${currentVersion})`);
45
- }
46
- else {
47
- latestVersion = null;
29
+ console.log(`[update] Latest version: ${data.version} (current: ${currentVersion})`);
48
30
  }
49
31
  }
50
32
  catch {
@@ -52,9 +34,9 @@ export async function checkForUpdate() {
52
34
  }
53
35
  }
54
36
  /**
55
- * Get the available update version, or null if up to date.
37
+ * Get the latest version from npm, or null if not yet checked.
56
38
  */
57
- export function getUpdateAvailable() {
39
+ export function getLatestVersion() {
58
40
  return latestVersion;
59
41
  }
60
42
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "palmier",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Palmier host CLI - provisions, executes tasks, and serves NATS RPC",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hongxu Cai",
@@ -10,7 +10,7 @@ import { spawnCommand } from "./spawn-command.js";
10
10
  import { getAgent } from "./agents/agent.js";
11
11
  import { validateSession } from "./session-store.js";
12
12
  import { publishHostEvent } from "./events.js";
13
- import { getUpdateAvailable, performUpdate } from "./update-checker.js";
13
+ import { currentVersion, getLatestVersion, performUpdate } from "./update-checker.js";
14
14
  import type { HostConfig, ParsedTask, RpcMessage } from "./types.js";
15
15
 
16
16
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -122,7 +122,8 @@ export function createRpcHandler(config: HostConfig, nc?: NatsConnection) {
122
122
  return {
123
123
  tasks: tasks.map((task) => flattenTask(task)),
124
124
  agents: config.agents ?? [],
125
- update_available: getUpdateAvailable(),
125
+ version: currentVersion,
126
+ latest_version: getLatestVersion(),
126
127
  };
127
128
  }
128
129
 
@@ -6,28 +6,14 @@ import { getPlatform } from "./platform/index.js";
6
6
 
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
  const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8")) as { version: string };
9
- const currentVersion = pkg.version;
9
+ export const currentVersion = pkg.version;
10
10
 
11
11
  let latestVersion: string | null = null;
12
12
  let lastCheckTime = 0;
13
13
  const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
14
14
 
15
15
  /**
16
- * Compare two semver strings (major.minor.patch).
17
- * Returns true if b is newer than a.
18
- */
19
- function isNewer(a: string, b: string): boolean {
20
- const pa = a.split(".").map(Number);
21
- const pb = b.split(".").map(Number);
22
- for (let i = 0; i < 3; i++) {
23
- if ((pb[i] ?? 0) > (pa[i] ?? 0)) return true;
24
- if ((pb[i] ?? 0) < (pa[i] ?? 0)) return false;
25
- }
26
- return false;
27
- }
28
-
29
- /**
30
- * Check the npm registry for a newer version of palmier.
16
+ * Check the npm registry for the latest version of palmier.
31
17
  */
32
18
  export async function checkForUpdate(): Promise<void> {
33
19
  const now = Date.now();
@@ -40,11 +26,9 @@ export async function checkForUpdate(): Promise<void> {
40
26
  });
41
27
  if (!res.ok) return;
42
28
  const data = (await res.json()) as { version?: string };
43
- if (data.version && isNewer(currentVersion, data.version)) {
29
+ if (data.version) {
44
30
  latestVersion = data.version;
45
- console.log(`[update] New version available: ${data.version} (current: ${currentVersion})`);
46
- } else {
47
- latestVersion = null;
31
+ console.log(`[update] Latest version: ${data.version} (current: ${currentVersion})`);
48
32
  }
49
33
  } catch {
50
34
  // Network errors are expected (offline, etc.)
@@ -52,9 +36,9 @@ export async function checkForUpdate(): Promise<void> {
52
36
  }
53
37
 
54
38
  /**
55
- * Get the available update version, or null if up to date.
39
+ * Get the latest version from npm, or null if not yet checked.
56
40
  */
57
- export function getUpdateAvailable(): string | null {
41
+ export function getLatestVersion(): string | null {
58
42
  return latestVersion;
59
43
  }
60
44