wogiflow 1.9.5 → 1.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wogiflow",
3
- "version": "1.9.5",
3
+ "version": "1.9.6",
4
4
  "description": "AI-powered development workflow management system with multi-model support",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -1,12 +1,16 @@
1
1
  /**
2
2
  * flow-version-check.js
3
3
  *
4
- * Proactive Claude Code version compatibility check.
5
- * Called at session start, but only checks once per install/update
6
- * to avoid nagging on every session.
4
+ * Version compatibility and update checks.
5
+ * Called at session start with two independent checks:
7
6
  *
8
- * - Hard minimum (2.1.23): Hooks don't work below this always warn
9
- * - Soft gates (2.1.50+, 2.1.72+): Degrade gracefully, no warning
7
+ * 1. Claude Code compatibility: checks once per install/update
8
+ * - Hard minimum (2.1.23): Hooks don't work below this — always warn
9
+ * - Soft gates (2.1.50+, 2.1.72+): Degrade gracefully, no warning
10
+ *
11
+ * 2. WogiFlow npm update: checks once per 24h
12
+ * - Fetches latest version from npm registry
13
+ * - Warns if local version is outdated
10
14
  */
11
15
 
12
16
  const fs = require('fs');
@@ -135,4 +139,107 @@ function checkClaudeCodeVersionOnce() {
135
139
  return null;
136
140
  }
137
141
 
138
- module.exports = { checkClaudeCodeVersionOnce, getClaudeCodeVersion };
142
+ // --- WogiFlow npm update check ---
143
+
144
+ const UPDATE_CHECK_PATH = path.join(PATHS.state, '.update-check.json');
145
+ const UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
146
+
147
+ /**
148
+ * Get the installed WogiFlow version from package.json.
149
+ * @returns {string} Version string or 'unknown'
150
+ */
151
+ function getLocalWogiFlowVersion() {
152
+ try {
153
+ const pkgPath = path.join(__dirname, '..', 'package.json');
154
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
155
+ return pkg.version || 'unknown';
156
+ } catch (err) {
157
+ return 'unknown';
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Fetch the latest WogiFlow version from the npm registry.
163
+ * Uses a short timeout to avoid blocking session start.
164
+ * @returns {string|null} Latest version or null on failure
165
+ */
166
+ function fetchLatestNpmVersion() {
167
+ try {
168
+ const output = execSync(
169
+ 'npm view wogiflow version 2>/dev/null || echo ""',
170
+ { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'], timeout: 10000 }
171
+ ).trim();
172
+ const match = output.match(/^(\d+\.\d+\.\d+)$/);
173
+ return match ? match[1] : null;
174
+ } catch (err) {
175
+ return null;
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Compare two semver strings. Returns true if remote is newer than local.
181
+ * @param {string} local - e.g. "1.9.4"
182
+ * @param {string} remote - e.g. "1.9.5"
183
+ * @returns {boolean}
184
+ */
185
+ function isNewerVersion(local, remote) {
186
+ const [lMaj, lMin, lPat] = local.split('.').map(Number);
187
+ const [rMaj, rMin, rPat] = remote.split('.').map(Number);
188
+ if (rMaj !== lMaj) return rMaj > lMaj;
189
+ if (rMin !== lMin) return rMin > lMin;
190
+ return rPat > lPat;
191
+ }
192
+
193
+ /**
194
+ * Check if a newer WogiFlow version is available on npm.
195
+ * Checks at most once per 24 hours to avoid unnecessary network calls.
196
+ *
197
+ * @returns {string|null} Warning message if outdated, null otherwise
198
+ */
199
+ function checkWogiFlowUpdateOnce() {
200
+ const localVersion = getLocalWogiFlowVersion();
201
+ if (localVersion === 'unknown') return null;
202
+
203
+ // Check cached result
204
+ try {
205
+ const cached = fs.readFileSync(UPDATE_CHECK_PATH, 'utf-8');
206
+ const data = JSON.parse(cached);
207
+ const age = Date.now() - new Date(data.checkedAt).getTime();
208
+ if (age < UPDATE_CHECK_TTL_MS && data.localVersion === localVersion) {
209
+ // Still within TTL and same local version — return cached result
210
+ if (data.latestVersion && isNewerVersion(localVersion, data.latestVersion)) {
211
+ return `WogiFlow ${localVersion} is outdated. Latest: ${data.latestVersion}. Update with: npm install -D wogiflow@latest`;
212
+ }
213
+ return null;
214
+ }
215
+ } catch (err) {
216
+ // No cache or invalid — proceed with fresh check
217
+ }
218
+
219
+ // Fetch from npm
220
+ const latestVersion = fetchLatestNpmVersion();
221
+
222
+ // Cache the result (even if null — prevents retrying on every session)
223
+ try {
224
+ fs.mkdirSync(path.dirname(UPDATE_CHECK_PATH), { recursive: true });
225
+ fs.writeFileSync(UPDATE_CHECK_PATH, JSON.stringify({
226
+ localVersion,
227
+ latestVersion: latestVersion || null,
228
+ checkedAt: new Date().toISOString()
229
+ }, null, 2));
230
+ } catch (err) {
231
+ if (process.env.DEBUG) {
232
+ console.error(`[version-check] Failed to cache update check: ${err.message}`);
233
+ }
234
+ }
235
+
236
+ if (!latestVersion) return null;
237
+
238
+ if (isNewerVersion(localVersion, latestVersion)) {
239
+ return `WogiFlow ${localVersion} is outdated. Latest: ${latestVersion}. Update with: npm install -D wogiflow@latest`;
240
+ }
241
+
242
+ return null;
243
+ }
244
+
245
+ module.exports = { checkClaudeCodeVersionOnce, getClaudeCodeVersion, checkWogiFlowUpdateOnce };
@@ -82,12 +82,15 @@ async function main() {
82
82
  }
83
83
  }
84
84
 
85
- // --- Version compatibility check (runs once per install/update) ---
86
- // Only warns if Claude Code is below the hard minimum (2.1.23) where hooks don't work.
85
+ // --- Version compatibility checks ---
86
+ // 1. Claude Code: warns if below hard minimum (2.1.23) where hooks don't work
87
+ // 2. WogiFlow npm: warns if a newer version is available (checks once per 24h)
87
88
  let versionWarning = null;
89
+ let updateWarning = null;
88
90
  try {
89
- const { checkClaudeCodeVersionOnce } = require('../../../flow-version-check');
91
+ const { checkClaudeCodeVersionOnce, checkWogiFlowUpdateOnce } = require('../../../flow-version-check');
90
92
  versionWarning = checkClaudeCodeVersionOnce();
93
+ updateWarning = checkWogiFlowUpdateOnce();
91
94
  } catch (err) {
92
95
  if (process.env.DEBUG) {
93
96
  console.error(`[session-start] Version check failed: ${err.message}`);
@@ -285,6 +288,11 @@ async function main() {
285
288
  coreResult.context.versionWarning = versionWarning;
286
289
  }
287
290
 
291
+ // Inject WogiFlow update warning (if any)
292
+ if (updateWarning && coreResult && coreResult.context) {
293
+ coreResult.context.updateWarning = updateWarning;
294
+ }
295
+
288
296
  // Inject drift detection results (if any)
289
297
  if (driftDetected && coreResult && coreResult.context) {
290
298
  if (driftMarkerMissing) {