deepflow 0.1.16 → 0.1.18

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/install.js CHANGED
@@ -137,9 +137,9 @@ async function main() {
137
137
  fs.unlinkSync(cacheFile);
138
138
  }
139
139
 
140
- // Configure statusline (global only)
140
+ // Configure hooks (global only)
141
141
  if (level === 'global') {
142
- await configureStatusline(CLAUDE_DIR);
142
+ await configureHooks(CLAUDE_DIR);
143
143
  }
144
144
 
145
145
  console.log('');
@@ -192,9 +192,10 @@ function copyDir(src, dest) {
192
192
  }
193
193
  }
194
194
 
195
- async function configureStatusline(claudeDir) {
195
+ async function configureHooks(claudeDir) {
196
196
  const settingsPath = path.join(claudeDir, 'settings.json');
197
- const hookCmd = `node "${path.join(claudeDir, 'hooks', 'df-statusline.js')}"`;
197
+ const statuslineCmd = `node "${path.join(claudeDir, 'hooks', 'df-statusline.js')}"`;
198
+ const updateCheckCmd = `node "${path.join(claudeDir, 'hooks', 'df-check-update.js')}"`;
198
199
 
199
200
  let settings = {};
200
201
 
@@ -204,25 +205,48 @@ async function configureStatusline(claudeDir) {
204
205
  } catch (e) {
205
206
  settings = {};
206
207
  }
208
+ }
207
209
 
208
- if (settings.statusLine) {
209
- const answer = await ask(
210
- ` ${c.yellow}!${c.reset} Existing statusLine found. Replace with deepflow? [y/N] `
211
- );
212
- if (answer.toLowerCase() !== 'y') {
213
- console.log(` ${c.yellow}!${c.reset} Skipped statusline configuration`);
214
- return;
215
- }
210
+ // Configure statusline
211
+ if (settings.statusLine) {
212
+ const answer = await ask(
213
+ ` ${c.yellow}!${c.reset} Existing statusLine found. Replace with deepflow? [y/N] `
214
+ );
215
+ if (answer.toLowerCase() === 'y') {
216
+ settings.statusLine = { type: 'command', command: statuslineCmd };
217
+ log('Statusline configured');
218
+ } else {
219
+ console.log(` ${c.yellow}!${c.reset} Skipped statusline configuration`);
216
220
  }
221
+ } else {
222
+ settings.statusLine = { type: 'command', command: statuslineCmd };
223
+ log('Statusline configured');
224
+ }
225
+
226
+ // Configure SessionStart hook for update checking
227
+ if (!settings.hooks) {
228
+ settings.hooks = {};
229
+ }
230
+ if (!settings.hooks.SessionStart) {
231
+ settings.hooks.SessionStart = [];
217
232
  }
218
233
 
219
- settings.statusLine = {
220
- type: 'command',
221
- command: hookCmd
222
- };
234
+ // Remove any existing deepflow update check hooks
235
+ settings.hooks.SessionStart = settings.hooks.SessionStart.filter(hook => {
236
+ const cmd = hook.hooks?.[0]?.command || '';
237
+ return !cmd.includes('df-check-update');
238
+ });
239
+
240
+ // Add update check hook
241
+ settings.hooks.SessionStart.push({
242
+ hooks: [{
243
+ type: 'command',
244
+ command: updateCheckCmd
245
+ }]
246
+ });
247
+ log('SessionStart hook configured');
223
248
 
224
249
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
225
- log('Statusline configured');
226
250
  }
227
251
 
228
252
  function ask(question) {
@@ -317,10 +341,39 @@ async function uninstall() {
317
341
  }
318
342
  }
319
343
 
320
- // Clear update cache
321
- const cacheFile = path.join(GLOBAL_DIR, 'cache', 'df-update-check.json');
322
- if (fs.existsSync(cacheFile)) {
323
- fs.unlinkSync(cacheFile);
344
+ // Clear update cache and trigger file
345
+ const cacheDir = path.join(GLOBAL_DIR, 'cache');
346
+ for (const file of ['df-update-check.json', 'df-trigger-time']) {
347
+ const filePath = path.join(cacheDir, file);
348
+ if (fs.existsSync(filePath)) {
349
+ fs.unlinkSync(filePath);
350
+ }
351
+ }
352
+
353
+ // Remove SessionStart hook from settings
354
+ if (level === 'global') {
355
+ const settingsPath = path.join(CLAUDE_DIR, 'settings.json');
356
+ if (fs.existsSync(settingsPath)) {
357
+ try {
358
+ const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
359
+ if (settings.hooks?.SessionStart) {
360
+ settings.hooks.SessionStart = settings.hooks.SessionStart.filter(hook => {
361
+ const cmd = hook.hooks?.[0]?.command || '';
362
+ return !cmd.includes('df-check-update');
363
+ });
364
+ if (settings.hooks.SessionStart.length === 0) {
365
+ delete settings.hooks.SessionStart;
366
+ }
367
+ if (Object.keys(settings.hooks).length === 0) {
368
+ delete settings.hooks;
369
+ }
370
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
371
+ console.log(` ${c.green}✓${c.reset} Removed SessionStart hook`);
372
+ }
373
+ } catch (e) {
374
+ // Fail silently
375
+ }
376
+ }
324
377
  }
325
378
 
326
379
  console.log('');
@@ -97,31 +97,9 @@ function buildContextMeter(contextWindow) {
97
97
  return `${color}${bar}${colors.reset} ${percentage}%`;
98
98
  }
99
99
 
100
- const TRIGGER_THROTTLE = 60 * 1000; // 60 seconds between triggers
101
-
102
100
  function checkForUpdate() {
103
- const cacheDir = path.join(os.homedir(), '.claude', 'cache');
104
- const cachePath = path.join(cacheDir, 'df-update-check.json');
105
- const triggerPath = path.join(cacheDir, 'df-trigger-time');
106
-
107
- // Trigger background check if not triggered recently (throttle rapid refreshes)
108
- try {
109
- let shouldTrigger = true;
110
- if (fs.existsSync(triggerPath)) {
111
- const lastTrigger = parseInt(fs.readFileSync(triggerPath, 'utf8'), 10);
112
- shouldTrigger = Date.now() - lastTrigger > TRIGGER_THROTTLE;
113
- }
114
- if (shouldTrigger) {
115
- fs.mkdirSync(cacheDir, { recursive: true });
116
- fs.writeFileSync(triggerPath, String(Date.now()));
117
- triggerUpdateCheck();
118
- }
119
- } catch (e) {
120
- // Fail silently
121
- }
122
-
123
- // Return cached result
124
101
  try {
102
+ const cachePath = path.join(os.homedir(), '.claude', 'cache', 'df-update-check.json');
125
103
  if (fs.existsSync(cachePath)) {
126
104
  return JSON.parse(fs.readFileSync(cachePath, 'utf8'));
127
105
  }
@@ -131,22 +109,6 @@ function checkForUpdate() {
131
109
  return null;
132
110
  }
133
111
 
134
- function triggerUpdateCheck() {
135
- try {
136
- const checkerPath = path.join(os.homedir(), '.claude', 'hooks', 'df-check-update.js');
137
- if (fs.existsSync(checkerPath)) {
138
- const { spawn } = require('child_process');
139
- const child = spawn(process.execPath, [checkerPath], {
140
- detached: true,
141
- stdio: 'ignore'
142
- });
143
- child.unref();
144
- }
145
- } catch (e) {
146
- // Fail silently
147
- }
148
- }
149
-
150
112
  function writeContextUsage(percentage) {
151
113
  try {
152
114
  const deepflowDir = path.join(process.cwd(), '.deepflow');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepflow",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Stay in flow state - lightweight spec-driven task orchestration for Claude Code",
5
5
  "keywords": [
6
6
  "claude",
@@ -17,6 +17,6 @@ npx deepflow --uninstall
17
17
  ## Check Version
18
18
 
19
19
  ```bash
20
- cat ~/.claude/deepflow/VERSION # installed
21
- npm view deepflow version # latest
20
+ cat ~/.claude/cache/df-update-check.json # cached version info
21
+ npm view deepflow version # latest on npm
22
22
  ```