@vatio-ai/cli 0.72.0 → 0.73.0

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.
@@ -57,7 +57,7 @@ export async function flags(config, args) {
57
57
  const markdown = await fetchMarkdown(config, "/flags.md", "the flags");
58
58
  if (!save) {
59
59
  process.stdout.write(markdown);
60
- printSkillsHint();
60
+ await printSkillsHint();
61
61
  return;
62
62
  }
63
63
 
@@ -65,7 +65,7 @@ export async function flags(config, args) {
65
65
  mkdirSync(dirname(target), { recursive: true });
66
66
  writeFileSync(target, markdown);
67
67
  console.log(`Wrote ${target}. Hand it to your coding agent; re-run \`vatio flags --save\` to refresh.`);
68
- printSkillsHint();
68
+ await printSkillsHint();
69
69
  }
70
70
 
71
71
  // Each tool's calls, error rate, timeouts and p50/p95 latency over a period,
@@ -114,7 +114,7 @@ export async function evalCommand(config, args) {
114
114
 
115
115
  const total = runs.reduce((sum, run) => sum + run.cases, 0);
116
116
  console.error(`vatio: replaying ${total} case${total === 1 ? "" : "s"} on ${environment}…`);
117
- printSkillsHint();
117
+ await printSkillsHint();
118
118
  if (noWait) {
119
119
  for (const run of runs) console.log(`Run ${run.id} (${run.agent}): vatio eval --show ${run.id}`);
120
120
  return;
@@ -1,15 +1,19 @@
1
- // "The Vatio skills are not installed here", after the commands of the
2
- // improve loop. Without them Claude Code has no /vatio:vatio-improve, and the
3
- // developer pastes the daily mail's prompt into a session that cannot run it.
1
+ // "The Vatio skills are not installed here" -- or are older than the published
2
+ // ones -- after the commands of the improve loop. Without them Claude Code has
3
+ // no /vatio:vatio-improve, and with old ones it works the reports the way the
4
+ // skill said months ago.
4
5
  //
5
6
  // Installed means either copy: the Claude Code plugin (installed_plugins.json
6
- // names vatio@<marketplace>), or the files `npx @vatio-ai/skills` puts in a
7
- // project's .claude/skills or .agents/skills -- in this directory or one above
8
- // it, or in ~/.claude/skills.
7
+ // names vatio@<marketplace>, with its version), or the files
8
+ // `npx @vatio-ai/skills` puts in a project's .claude/skills or .agents/skills
9
+ // -- in this directory or one above it, or in ~/.claude/skills -- with the
10
+ // .vatio-skills-version it leaves beside each. A copy without that file
11
+ // predates it, so it is older than any version that writes one.
9
12
  //
10
13
  // Unlike the update notice it prints when stderr is not a terminal too: the
11
14
  // reader is as often the coding agent running the command as a person. At
12
- // most once a day per directory, and never in CI.
15
+ // most once a day per directory, and never in CI. The registry is asked for
16
+ // the latest skills at most once a day.
13
17
 
14
18
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
15
19
  import { homedir } from "node:os";
@@ -19,65 +23,145 @@ import { configHome } from "./config.mjs";
19
23
  import { paint } from "./support.mjs";
20
24
 
21
25
  const SKILL = "vatio-improve";
26
+ const VERSION_FILE = ".vatio-skills-version";
27
+ const LATEST_URL = "https://registry.npmjs.org/@vatio-ai/skills/latest";
22
28
  const SHOW_EVERY_MS = 24 * 60 * 60 * 1000;
29
+ const CHECK_EVERY_MS = 24 * 60 * 60 * 1000;
30
+ const FETCH_TIMEOUT_MS = 1_500;
23
31
 
24
- export function printSkillsHint(startDir = process.cwd()) {
32
+ export async function printSkillsHint(startDir = process.cwd()) {
25
33
  if (process.env.CI || process.env.VATIO_NO_SKILLS_HINT) return;
26
- if (skillsInstalled(startDir)) return;
27
34
 
28
35
  const path = join(configHome(), "skills-hint.json");
29
36
  const key = resolve(startDir);
30
- const state = readState(path);
37
+ const state = readJson(path);
31
38
  const last = Date.parse(state[key] ?? "");
32
39
  if (!Number.isNaN(last) && Date.now() - last < SHOW_EVERY_MS) return;
33
40
 
34
- process.stderr.write(
35
- `\n${paint("yellow", "The Vatio skills are not installed here, so Claude Code has no /vatio:vatio-improve.")}\n` +
36
- "To install them, run in this project: npx @vatio-ai/skills\n"
37
- );
38
- writeState(path, { ...state, [key]: new Date().toISOString() });
41
+ const lines = hintLines(findSkills(startDir), await latestSkillsVersion());
42
+ if (lines.length === 0) return;
43
+
44
+ process.stderr.write(`\n${lines.map((line, i) => (i === 0 ? paint("yellow", line) : line)).join("\n")}\n`);
45
+ writeJson(path, { ...state, [key]: new Date().toISOString() });
39
46
  }
40
47
 
41
- export function skillsInstalled(startDir) {
48
+ export function hintLines(found, latest) {
49
+ if (found.length === 0) {
50
+ return [
51
+ "The Vatio skills are not installed here, so Claude Code has no /vatio:vatio-improve.",
52
+ "To install them, run in this project: npx @vatio-ai/skills"
53
+ ];
54
+ }
55
+ if (!latest) return [];
56
+
57
+ const lines = [];
58
+ const plugin = found.find((install) => install.kind === "plugin");
59
+ if (plugin?.version && isOlder(plugin.version, latest)) {
60
+ lines.push(
61
+ `The Vatio plugin for Claude Code is ${plugin.version}; ${latest} is out.`,
62
+ "To update it, run: claude plugin update vatio@vatio (or turn on auto-update in /plugin → Marketplaces → vatio)"
63
+ );
64
+ }
65
+ const copy = found.find((install) => install.kind === "copy");
66
+ if (copy && (!copy.version || isOlder(copy.version, latest))) {
67
+ lines.push(
68
+ `The Vatio skills copied into this project are ${copy.version ?? "older than 1.7.0"}; ${latest} is out.`,
69
+ "To update them, run in this project: npx @vatio-ai/skills"
70
+ );
71
+ }
72
+ return lines;
73
+ }
74
+
75
+ // Every copy Claude Code or another coding agent may load, nearest first.
76
+ export function findSkills(startDir) {
42
77
  const claudeHome = String(process.env.CLAUDE_CONFIG_DIR ?? "").trim() || join(homedir(), ".claude");
43
- if (pluginInstalled(join(claudeHome, "plugins", "installed_plugins.json"))) return true;
44
- if (hasSkill(claudeHome)) return true;
78
+ const found = [];
79
+ const plugin = pluginVersion(join(claudeHome, "plugins", "installed_plugins.json"));
80
+ if (plugin !== undefined) found.push({ kind: "plugin", version: plugin });
45
81
 
46
82
  let dir = resolve(startDir);
47
83
  for (;;) {
48
- if (hasSkill(join(dir, ".claude")) || hasSkill(join(dir, ".agents"))) return true;
84
+ for (const base of [join(dir, ".claude"), join(dir, ".agents")]) {
85
+ if (hasSkill(base)) found.push({ kind: "copy", version: copyVersion(base) });
86
+ }
49
87
  const parent = dirname(dir);
50
- if (parent === dir) return false;
88
+ if (parent === dir) break;
51
89
  dir = parent;
52
90
  }
91
+ if (hasSkill(claudeHome)) found.push({ kind: "copy", version: copyVersion(claudeHome) });
92
+ return found;
93
+ }
94
+
95
+ export function skillsInstalled(startDir) {
96
+ return findSkills(startDir).length > 0;
53
97
  }
54
98
 
55
99
  function hasSkill(base) {
56
100
  return existsSync(join(base, "skills", SKILL, "SKILL.md"));
57
101
  }
58
102
 
59
- function pluginInstalled(path) {
103
+ function copyVersion(base) {
104
+ try {
105
+ return readFileSync(join(base, "skills", SKILL, VERSION_FILE), "utf8").trim() || null;
106
+ } catch {
107
+ return null;
108
+ }
109
+ }
110
+
111
+ // undefined when no vatio plugin is installed, null when one is but its
112
+ // version is not where it was: the file's format is Claude Code's, not ours.
113
+ function pluginVersion(path) {
60
114
  try {
61
115
  const plugins = JSON.parse(readFileSync(path, "utf8"))?.plugins ?? {};
62
- return Object.keys(plugins).some((name) => name.startsWith("vatio@"));
116
+ const name = Object.keys(plugins).find((candidate) => candidate.startsWith("vatio@"));
117
+ if (!name) return undefined;
118
+ const installs = Array.isArray(plugins[name]) ? plugins[name] : [ plugins[name] ];
119
+ const versions = installs.map((install) => install?.version).filter((v) => typeof v === "string");
120
+ return versions.sort((a, b) => (isOlder(a, b) ? 1 : -1))[0] ?? null;
121
+ } catch {
122
+ return undefined;
123
+ }
124
+ }
125
+
126
+ async function latestSkillsVersion() {
127
+ const path = join(configHome(), "skills-check.json");
128
+ const cached = readJson(path);
129
+ if (typeof cached.latest === "string" && Date.now() - Date.parse(cached.checked_at ?? "") < CHECK_EVERY_MS) {
130
+ return cached.latest;
131
+ }
132
+ try {
133
+ const response = await fetch(LATEST_URL, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
134
+ const latest = response.ok ? (await response.json())?.version : null;
135
+ if (typeof latest !== "string") return cached.latest ?? null;
136
+ writeJson(path, { checked_at: new Date().toISOString(), latest });
137
+ return latest;
63
138
  } catch {
64
- return false;
139
+ return cached.latest ?? null;
140
+ }
141
+ }
142
+
143
+ function isOlder(version, than) {
144
+ const parse = (v) => String(v).split(".").map((part) => Number.parseInt(part, 10) || 0);
145
+ const [a, b] = [parse(version), parse(than)];
146
+ for (let i = 0; i < 3; i++) {
147
+ if ((a[i] ?? 0) !== (b[i] ?? 0)) return (a[i] ?? 0) < (b[i] ?? 0);
65
148
  }
149
+ return false;
66
150
  }
67
151
 
68
- function readState(path) {
152
+ function readJson(path) {
69
153
  try {
70
- const state = JSON.parse(readFileSync(path, "utf8"));
71
- return state && typeof state === "object" ? state : {};
154
+ const value = JSON.parse(readFileSync(path, "utf8"));
155
+ return value && typeof value === "object" ? value : {};
72
156
  } catch {
73
157
  return {};
74
158
  }
75
159
  }
76
160
 
77
- function writeState(path, state) {
161
+ function writeJson(path, value) {
78
162
  try {
79
163
  mkdirSync(dirname(path), { recursive: true });
80
- writeFileSync(path, JSON.stringify(state, null, 2) + "\n");
164
+ writeFileSync(path, JSON.stringify(value, null, 2) + "\n");
81
165
  } catch {
82
166
  // A hint that cannot remember it was shown shows again tomorrow.
83
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.72.0",
3
+ "version": "0.73.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",