@constraint/cli 0.3.4 → 0.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constraint/cli",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Install, publish, and report Agent Skills with Constraint",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -35,7 +35,7 @@ import {
35
35
  uploadSkill,
36
36
  } from './skills.js';
37
37
 
38
- const VERSION = '0.3.4';
38
+ const VERSION = '0.3.5';
39
39
 
40
40
  const HELP = `Constraint Skills CLI
41
41
 
package/src/config.js CHANGED
@@ -28,6 +28,9 @@ export async function loadConfig() {
28
28
  return {
29
29
  apiUrl: (process.env.CONSTRAINT_API_URL || saved.apiUrl || DEFAULT_API_URL).replace(/\/$/, ''),
30
30
  agents: Array.isArray(saved.agents) ? saved.agents : Array.isArray(saved.clients) ? saved.clients : [],
31
+ companion_hashes: saved.companion_hashes && typeof saved.companion_hashes === 'object'
32
+ ? saved.companion_hashes
33
+ : {},
31
34
  };
32
35
  }
33
36
 
package/src/setup.js CHANGED
@@ -42,6 +42,13 @@ async function companionFiles() {
42
42
  return readSkillDirectory(path.resolve(here, '..', 'skills', 'constraint-skills'));
43
43
  }
44
44
 
45
+ export function expectedCompanionHash(config, selected, currentHash) {
46
+ const direct = config.companion_hashes?.[selected] || null;
47
+ if (direct) return direct;
48
+ const recorded = Object.values(config.companion_hashes || {});
49
+ return currentHash && recorded.includes(currentHash) ? currentHash : null;
50
+ }
51
+
45
52
  async function instructionPlan(selected, paths) {
46
53
  let existing = '';
47
54
  let mode = 0o644;
@@ -59,7 +66,6 @@ async function skillPlan(selected, paths) {
59
66
  const files = await companionFiles();
60
67
  const bundledHash = packageDigest(files);
61
68
  const config = await loadConfig();
62
- const expectedHash = config.companion_hashes?.[selected] || null;
63
69
  const target = path.join(paths.skills, 'constraint-skills');
64
70
  let currentHash = null;
65
71
  try {
@@ -67,6 +73,7 @@ async function skillPlan(selected, paths) {
67
73
  } catch (error) {
68
74
  if (error && error.code !== 'ENOENT') throw error;
69
75
  }
76
+ const expectedHash = expectedCompanionHash(config, selected, currentHash);
70
77
  const action = currentHash === bundledHash
71
78
  ? 'current'
72
79
  : currentHash === null
@@ -109,8 +116,9 @@ export async function installCompanionSkill(agent) {
109
116
  const config = await loadConfig();
110
117
  config.companion_hashes ||= {};
111
118
  const target = path.join(paths.skills, 'constraint-skills');
119
+ const plan = await skillPlan(selected, paths);
112
120
  const result = await writeSkillDirectory(target, files, {
113
- expectedHash: config.companion_hashes[selected] || null,
121
+ expectedHash: plan.expectedHash,
114
122
  });
115
123
  config.companion_hashes[selected] = result.hash;
116
124
  await recordConfiguredAgent(selected, config);