refacil-sdd-ai 4.0.7 → 4.0.9

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.js CHANGED
@@ -105,11 +105,31 @@ function repoIsInitialized() {
105
105
  );
106
106
  }
107
107
 
108
+ function semverGt(a, b) {
109
+ if (!a || !b) return false;
110
+ const pa = a.split('.').map(Number);
111
+ const pb = b.split('.').map(Number);
112
+ for (let i = 0; i < 3; i++) {
113
+ if ((pa[i] || 0) > (pb[i] || 0)) return true;
114
+ if ((pa[i] || 0) < (pb[i] || 0)) return false;
115
+ }
116
+ return false;
117
+ }
118
+
108
119
  function syncRepoSkillsIfStale(globalVersion) {
109
120
  if (!repoIsInitialized()) return null;
110
121
  const repoVersion = readRepoVersion(projectRoot);
111
122
  if (repoVersion === globalVersion) return null;
112
123
 
124
+ // El repo tiene skills más nuevas que el paquete instalado — no degradar
125
+ if (semverGt(repoVersion, globalVersion)) {
126
+ process.stderr.write(
127
+ `[refacil-sdd-ai] El repo usa la metodologia v${repoVersion} pero el paquete global es v${globalVersion}. ` +
128
+ `Ejecuta: npm update -g refacil-sdd-ai\n`,
129
+ );
130
+ return null;
131
+ }
132
+
113
133
  const { execSync } = require('child_process');
114
134
  const localCli = path.join(packageRoot, 'bin', 'cli.js');
115
135
  try {
@@ -127,7 +147,7 @@ function syncRepoSkillsIfStale(globalVersion) {
127
147
 
128
148
  function checkUpdate() {
129
149
  const { execSync } = require('child_process');
130
- const localVersion = getPackageVersion(packageRoot);
150
+ let localVersion = getPackageVersion(packageRoot);
131
151
 
132
152
  try {
133
153
  syncCompactGuidance(projectRoot, packageRoot);
@@ -137,6 +157,30 @@ function checkUpdate() {
137
157
 
138
158
  cleanLegacySettingsHooks(projectRoot);
139
159
 
160
+ // Paso 1: actualizar el paquete global si hay version nueva en npm
161
+ try {
162
+ const latest = execSync('npm view refacil-sdd-ai version', {
163
+ encoding: 'utf8',
164
+ timeout: 10000,
165
+ stdio: ['pipe', 'pipe', 'pipe'],
166
+ }).trim();
167
+
168
+ if (latest && semverGt(latest, localVersion)) {
169
+ try {
170
+ execSync('npm update -g refacil-sdd-ai', { encoding: 'utf8', timeout: 60000, stdio: ['pipe', 'pipe', 'pipe'] });
171
+ localVersion = latest;
172
+ } catch (_) {
173
+ console.log(
174
+ `[refacil-sdd-ai] Hay una nueva version disponible (v${localVersion} -> v${latest}) pero la actualizacion automatica fallo. ` +
175
+ `Ejecuta manualmente: npm update -g refacil-sdd-ai && refacil-sdd-ai update`,
176
+ );
177
+ }
178
+ }
179
+ } catch (_) {
180
+ // Silent: sin internet o registry no disponible
181
+ }
182
+
183
+ // Paso 2: sincronizar skills del repo con el paquete (ya actualizado)
140
184
  const syncResult = syncRepoSkillsIfStale(localVersion);
141
185
  if (syncResult && !syncResult.failed) {
142
186
  const fromLabel = syncResult.from ? `v${syncResult.from}` : 'version desconocida';
@@ -151,32 +195,6 @@ function checkUpdate() {
151
195
  'pero la sincronizacion automatica fallo. Ejecuta manualmente: refacil-sdd-ai update',
152
196
  );
153
197
  }
154
-
155
- try {
156
- const latest = execSync('npm view refacil-sdd-ai version', {
157
- encoding: 'utf8',
158
- timeout: 10000,
159
- stdio: ['pipe', 'pipe', 'pipe'],
160
- }).trim();
161
-
162
- if (!latest || latest === localVersion) return;
163
-
164
- try {
165
- execSync('npm update -g refacil-sdd-ai', { encoding: 'utf8', timeout: 60000, stdio: ['pipe', 'pipe', 'pipe'] });
166
- execSync('refacil-sdd-ai update', { encoding: 'utf8', timeout: 30000, stdio: ['pipe', 'pipe', 'pipe'] });
167
- writeRepoVersion(projectRoot, latest);
168
- console.log(
169
- `[refacil-sdd-ai] La metodologia SDD-AI se actualizo automaticamente de v${localVersion} a v${latest}. Skills y hooks sincronizados.`,
170
- );
171
- } catch (_) {
172
- console.log(
173
- `[refacil-sdd-ai] Hay una nueva version disponible (v${localVersion} -> v${latest}) pero la actualizacion automatica fallo. ` +
174
- `Informa al usuario que ejecute manualmente: npm update -g refacil-sdd-ai && refacil-sdd-ai update`,
175
- );
176
- }
177
- } catch (_) {
178
- // Silent: sin internet o registry no disponible
179
- }
180
198
  }
181
199
 
182
200
  // --- Check review (PreToolUse hook) ---
package/lib/hooks.js CHANGED
@@ -24,6 +24,7 @@ function writeCursorHooksJson(projectRoot, config) {
24
24
  }
25
25
 
26
26
  function installCursorHooks(projectRoot) {
27
+ cleanLegacySettingsHooks(projectRoot);
27
28
  const config = readCursorHooksJson(projectRoot);
28
29
  let changed = false;
29
30
 
@@ -195,7 +196,7 @@ function cleanLegacySettingsHooks(projectRoot) {
195
196
  const sddMarkers = ['_sdd', '_sdd_compact', '_sdd_review', '_sdd_notify'];
196
197
  const evts = ['SessionStart', 'PreToolUse', 'UserPromptSubmit', 'beforeSubmitPrompt', 'Stop', 'afterAgentResponse'];
197
198
 
198
- for (const ideDir of ['.cursor', '.claude']) {
199
+ for (const ideDir of ['.cursor']) {
199
200
  const settingsPath = path.join(projectRoot, ideDir, 'settings.json');
200
201
  if (!fs.existsSync(settingsPath)) continue;
201
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "refacil-sdd-ai",
3
- "version": "4.0.7",
3
+ "version": "4.0.9",
4
4
  "description": "SDD-AI: Specification-Driven Development with AI — metodologia de desarrollo con IA usando OpenSpec, Claude Code y Cursor",
5
5
  "bin": {
6
6
  "refacil-sdd-ai": "./bin/cli.js"
@@ -99,7 +99,7 @@ Conjunto requerido de commands: `.claude/commands/opsx/` → `apply.md`, `archiv
99
99
  Eliminar el archivo de flag si existe (puede estar en `.claude/` o `.cursor/`):
100
100
 
101
101
  ```bash
102
- rm -f .claude/.refacil-pending-update .cursor/.refacil-pending-update
102
+ rm -f .refacil-pending-update
103
103
  ```
104
104
 
105
105
  ## Paso 5: Resumen