@chronova/pi-plugin 1.4.0 → 1.4.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
@@ -50,7 +50,7 @@ chronova-cli \
50
50
  --entity <absolute-file-path> \
51
51
  --entity-type file \
52
52
  --project-folder <project-directory> \
53
- --plugin "oh-my-pi/1.0.0 chronova-pi-plugin/1.0.0" \
53
+ --plugin "oh-my-pi/<omp-version> chronova-pi-plugin/<plugin-version>" \
54
54
  --category "ai coding" \
55
55
  --write \ # for write operations
56
56
  --ai-line-changes <net-lines> # additions - deletions
package/dist/heartbeat.js CHANGED
@@ -1,9 +1,21 @@
1
1
  import { execFile } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
2
3
  import * as path from "node:path";
4
+ import { VERSION as OMP_VERSION } from "@oh-my-pi/pi-coding-agent";
3
5
  import { logger } from "./logger.js";
4
6
  import { shouldSendHeartbeat, updateLastHeartbeat } from "./state.js";
5
- const PLUGIN_VERSION = "1.0.0";
6
7
  const CLI_PATH = path.join(process.env.HOME ?? "/home/dev", ".local/bin/chronova-cli");
8
+ /**
9
+ * Plugin version, read from the sibling package.json at module load.
10
+ * Resolves correctly from both src/ (run by omp) and dist/ (compiled).
11
+ */
12
+ const PLUGIN_VERSION = readPluginVersion();
13
+ function readPluginVersion() {
14
+ const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
15
+ return typeof pkg.version === "string" ? pkg.version : "0.0.0";
16
+ }
17
+ /** User-Agent style string sent to chronova-cli via --plugin. */
18
+ const PLUGIN_ARG = `oh-my-pi/${OMP_VERSION} chronova-pi-plugin/${PLUGIN_VERSION}`;
7
19
  /**
8
20
  * Send a heartbeat via chronova-cli. Fire-and-forget — never blocks
9
21
  * the agent loop. Resolves after the process is spawned (not after it exits).
@@ -13,19 +25,7 @@ export function sendHeartbeat(payload) {
13
25
  logger.debug("Heartbeat rate-limited, skipping", { projectFolder: payload.projectFolder });
14
26
  return;
15
27
  }
16
- const args = [
17
- "--entity", payload.entity,
18
- "--entity-type", "file",
19
- "--project-folder", payload.projectFolder,
20
- "--plugin", `oh-my-pi/1.0.0 chronova-pi-plugin/${PLUGIN_VERSION}`,
21
- "--category", "ai coding",
22
- ];
23
- if (payload.isWrite) {
24
- args.push("--write");
25
- }
26
- if (payload.aiLineChanges !== 0) {
27
- args.push("--ai-line-changes", String(payload.aiLineChanges));
28
- }
28
+ const args = buildHeartbeatArgs(payload);
29
29
  logger.debug("Spawning chronova-cli", { args });
30
30
  const child = execFile(CLI_PATH, args, (err, stdout, stderr) => {
31
31
  if (err) {
@@ -51,19 +51,7 @@ export function sendHeartbeatForce(payload) {
51
51
  // Always true with force, but keep the guard for type safety
52
52
  return;
53
53
  }
54
- const args = [
55
- "--entity", payload.entity,
56
- "--entity-type", "file",
57
- "--project-folder", payload.projectFolder,
58
- "--plugin", `oh-my-pi/1.0.0 chronova-pi-plugin/${PLUGIN_VERSION}`,
59
- "--category", "ai coding",
60
- ];
61
- if (payload.isWrite) {
62
- args.push("--write");
63
- }
64
- if (payload.aiLineChanges !== 0) {
65
- args.push("--ai-line-changes", String(payload.aiLineChanges));
66
- }
54
+ const args = buildHeartbeatArgs(payload);
67
55
  logger.debug("Spawning chronova-cli (forced)", { args });
68
56
  const child = execFile(CLI_PATH, args, (err, stdout, stderr) => {
69
57
  if (err) {
@@ -77,3 +65,23 @@ export function sendHeartbeatForce(payload) {
77
65
  child.unref();
78
66
  updateLastHeartbeat(payload.projectFolder);
79
67
  }
68
+ /**
69
+ * Build the chronova-cli argv for a heartbeat payload.
70
+ * Shared by sendHeartbeat and sendHeartbeatForce.
71
+ */
72
+ function buildHeartbeatArgs(payload) {
73
+ const args = [
74
+ "--entity", payload.entity,
75
+ "--entity-type", "file",
76
+ "--project-folder", payload.projectFolder,
77
+ "--plugin", PLUGIN_ARG,
78
+ "--category", "ai coding",
79
+ ];
80
+ if (payload.isWrite) {
81
+ args.push("--write");
82
+ }
83
+ if (payload.aiLineChanges !== 0) {
84
+ args.push("--ai-line-changes", String(payload.aiLineChanges));
85
+ }
86
+ return args;
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chronova/pi-plugin",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Chronova heartbeat tracking extension for oh-my-pi — sends coding activity to your Chronova dashboard via chronova-cli",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",