transitions-refine 0.3.4 → 0.3.6

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/bin/cli.mjs CHANGED
@@ -24,6 +24,13 @@ import { homedir } from "node:os";
24
24
  const PKG_ROOT = fileURLToPath(new URL("..", import.meta.url));
25
25
  const CWD = process.cwd();
26
26
  const HOME = process.env.HOME || homedir();
27
+ const PKG_VERSION = (() => {
28
+ try {
29
+ return JSON.parse(readFileSync(join(PKG_ROOT, "package.json"), "utf8")).version || "0";
30
+ } catch {
31
+ return "0";
32
+ }
33
+ })();
27
34
 
28
35
  const MARK_START = "<!-- timeline-inject:start -->";
29
36
  const MARK_END = "<!-- timeline-inject:end -->";
@@ -81,14 +88,27 @@ function escapeRe(s) {
81
88
 
82
89
  // Copy a whole skill directory from the package into the user's project so the
83
90
  // in-IDE agent (/refine live) and any spawned cursor-agent can read it.
91
+ //
92
+ // Crucially this REFRESHES a stale copy on upgrade. An older installed skill can
93
+ // shadow newer job handling — e.g. a pre-scan `refine-live` skill that doesn't
94
+ // know how to answer kind:"scan" jobs, so scan jobs time out and the panel hangs
95
+ // on "Agent is scanning…". We stamp the package version into the skill dir and
96
+ // re-copy whenever it's missing or mismatched (so we don't clobber every run).
84
97
  function dropSkill(name) {
85
98
  const src = join(PKG_ROOT, ".agents/skills", name);
86
99
  const destDir = join(CWD, ".agents/skills", name);
87
100
  if (!existsSync(src)) return false;
88
- if (existsSync(destDir)) return "exists";
101
+ const marker = join(destDir, ".refine-version");
102
+ const existed = existsSync(destDir);
103
+ if (existed) {
104
+ let installed = null;
105
+ try { installed = readFileSync(marker, "utf8").trim(); } catch {}
106
+ if (installed === PKG_VERSION) return "exists";
107
+ }
89
108
  mkdirSync(dirname(destDir), { recursive: true });
90
- cpSync(src, destDir, { recursive: true });
91
- return true;
109
+ cpSync(src, destDir, { recursive: true, force: true });
110
+ try { writeFileSync(marker, PKG_VERSION + "\n"); } catch {}
111
+ return existed ? "updated" : true;
92
112
  }
93
113
 
94
114
  // ── agent CLI (for the persistent LLM path) ──────────────────────────────────
@@ -162,7 +182,8 @@ function cmdLive(args) {
162
182
  for (const name of ["refine-live", "transitions-dev"]) {
163
183
  const r = dropSkill(name);
164
184
  if (r === true) log(`✓ added .agents/skills/${name}`);
165
- else if (r === "exists") log(`✓ ${name} skill already present`);
185
+ else if (r === "updated") log(`✓ updated .agents/skills/${name} (now v${PKG_VERSION})`);
186
+ else if (r === "exists") log(`✓ ${name} skill already present (v${PKG_VERSION})`);
166
187
  }
167
188
 
168
189
  // 2.5) ensure an agent CLI so the relay can answer LLM jobs itself — this is