phewsh 0.15.37 → 0.15.38

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/phewsh.js CHANGED
@@ -144,8 +144,20 @@ function checkForUpdates() {
144
144
  newer[1] !== current[1] ? newer[1] > current[1] :
145
145
  newer[2] > current[2];
146
146
  if (isNewer) {
147
- console.log(g(`\n Update available: ${pkg.version} ${data.version}`));
148
- console.log(g(` Run: phewsh update\n`));
147
+ // Auto-update is opt-in (phewsh update auto on). When on, we update
148
+ // in the background — never blocking this session, never prompting —
149
+ // so the NEXT launch is current. When off, we just point the way.
150
+ let auto = false;
151
+ try { auto = require('../commands/update').autoUpdateEnabled(); } catch { /* default off */ }
152
+ if (auto) {
153
+ let started = false;
154
+ try { started = require('../commands/update').backgroundUpdate(pkg.name); } catch { /* best-effort */ }
155
+ if (started) console.log(g(`\n ↻ Updating phewsh ${pkg.version} → ${data.version} in the background — next launch uses it.\n`));
156
+ else console.log(g(`\n Update available: ${pkg.version} → ${data.version}\n Run: phewsh update\n`));
157
+ } else {
158
+ console.log(g(`\n Update available: ${pkg.version} → ${data.version}`));
159
+ console.log(g(` Run: phewsh update ${'\x1b[2m'}(or 'phewsh update auto on' to always stay current)${'\x1b[0m'}\n`));
160
+ }
149
161
  }
150
162
  }
151
163
  })
@@ -1,10 +1,17 @@
1
1
  // phewsh update — update the CLI to the latest published version.
2
2
  //
3
3
  // Usage:
4
- // phewsh update Check npm and install the latest version
5
- // phewsh update --check Just compare versions, don't install
4
+ // phewsh update Check npm and install the latest version
5
+ // phewsh update --check Just compare versions, don't install
6
+ // phewsh update auto on Always auto-update in the background on launch
7
+ // phewsh update auto off Back to notify-only (the default)
6
8
 
7
9
  const { spawn } = require('child_process');
10
+ const path = require('path');
11
+ const os = require('os');
12
+ const configFile = require('../lib/config-file');
13
+
14
+ const CONFIG_PATH = path.join(os.homedir(), '.phewsh', 'config.json');
8
15
 
9
16
  const b = (s) => `\x1b[1m${s}\x1b[0m`;
10
17
  const w = (s) => `\x1b[97m${s}\x1b[0m`;
@@ -12,6 +19,31 @@ const g = (s) => `\x1b[38;5;247m${s}\x1b[0m`;
12
19
  const green = (s) => `\x1b[32m${s}\x1b[0m`;
13
20
  const yellow = (s) => `\x1b[33m${s}\x1b[0m`;
14
21
 
22
+ // Read/write the autoUpdate preference. Default: false (notify-only) — we never
23
+ // mutate a user's global binary without their say-so (the ambient ethos).
24
+ function autoUpdateEnabled() {
25
+ const c = configFile.loadConfig(CONFIG_PATH, {}) || {};
26
+ return c.autoUpdate === true;
27
+ }
28
+ function setAutoUpdate(on) {
29
+ const c = configFile.loadConfig(CONFIG_PATH, {}) || {};
30
+ c.autoUpdate = !!on;
31
+ configFile.saveConfig(CONFIG_PATH, c);
32
+ }
33
+
34
+ // Background, non-blocking update — used on launch when autoUpdate is on. Never
35
+ // waits, never prompts; if it fails (e.g. needs sudo) the next launch retries
36
+ // and the notify line still shows. Detached so it outlives this process.
37
+ function backgroundUpdate(pkgName) {
38
+ try {
39
+ const child = spawn('npm', ['install', '-g', `${pkgName}@latest`], {
40
+ stdio: 'ignore', detached: true,
41
+ });
42
+ child.unref();
43
+ return true;
44
+ } catch { return false; }
45
+ }
46
+
15
47
  function isNewer(latest, current) {
16
48
  const l = latest.split('.').map(Number);
17
49
  const c = current.split('.').map(Number);
@@ -19,9 +51,27 @@ function isNewer(latest, current) {
19
51
  }
20
52
 
21
53
  async function main() {
22
- const checkOnly = process.argv.includes('--check');
23
54
  const pkg = require('../package.json');
24
55
 
56
+ // `phewsh update auto on|off` — toggle background auto-update on launch.
57
+ if (process.argv[3] === 'auto') {
58
+ const choice = (process.argv[4] || '').toLowerCase();
59
+ console.log('');
60
+ if (choice === 'on') {
61
+ setAutoUpdate(true);
62
+ console.log(` ${green('✓')} ${w('Auto-update on.')} ${g('phewsh will update itself in the background when a new version ships.')}`);
63
+ } else if (choice === 'off') {
64
+ setAutoUpdate(false);
65
+ console.log(` ${green('✓')} ${w('Auto-update off.')} ${g('Back to notify-only — run')} ${w('phewsh update')} ${g('when you want it.')}`);
66
+ } else {
67
+ console.log(` ${g('Auto-update is')} ${autoUpdateEnabled() ? green('on') : yellow('off')}${g('.')} ${g('Toggle:')} ${w('phewsh update auto on')} ${g('/')} ${w('phewsh update auto off')}`);
68
+ }
69
+ console.log('');
70
+ return;
71
+ }
72
+
73
+ const checkOnly = process.argv.includes('--check');
74
+
25
75
  console.log('');
26
76
  console.log(` ${b(w('phewsh update'))}`);
27
77
  console.log('');
@@ -77,3 +127,5 @@ async function main() {
77
127
  }
78
128
 
79
129
  module.exports = main;
130
+ module.exports.autoUpdateEnabled = autoUpdateEnabled;
131
+ module.exports.backgroundUpdate = backgroundUpdate;
package/lib/suggest.js CHANGED
@@ -118,14 +118,17 @@ function suggestAll(s = {}) {
118
118
  });
119
119
  }
120
120
 
121
- // 5. Ambient off — continuity that costs nothing once turned on.
122
- if (hasIntentDir && !ambientOn && installedHarnesses.includes('claude-code')) {
121
+ // 5. Ambient off — the highest-leverage thing a new user can turn on. Once
122
+ // on, every AI tool here inherits the brief + 😮‍💨🤫 signature without ever
123
+ // launching phewsh. Fires for any installed harness now (not just Claude
124
+ // Code), since non-Claude tools get it via their synced + global base files.
125
+ if (!ambientOn && installedHarnesses.length > 0) {
123
126
  out.push({
124
127
  id: 'enable-ambient',
125
- priority: 50,
126
- message: `Ambient is off — Claude Code sessions here won't get the brief unless you launch phewsh.`,
127
- command: 'phewsh ambient',
128
- why: 'Installs a silent SessionStart hook so continuity travels even when you forget phewsh.',
128
+ priority: 78,
129
+ message: `Ambient is off — turn it on so every AI tool here gets the phewsh brief + 😮‍💨🤫 signature, even when you don't launch phewsh.`,
130
+ command: 'phewsh ambient on',
131
+ why: 'One reversible setup: a Claude Code hook + a marked block in each tool\'s context file. Undo anytime with `phewsh ambient off`.',
129
132
  });
130
133
  }
131
134
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phewsh",
3
- "version": "0.15.37",
3
+ "version": "0.15.38",
4
4
  "description": "Turn intent into action. Structure your thinking, execute your next step.",
5
5
  "bin": {
6
6
  "phewsh": "bin/phewsh.js"