Skip to content

Commit 0c5fa5b

Browse files
committed
fix: make auto update notify by default
1 parent 22a8335 commit 0c5fa5b

6 files changed

Lines changed: 33 additions & 13 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ Pure Node.js builtins. No bloat.
159159

160160
## Updates
161161

162-
Most commands check for new nit releases and install exact npm versions automatically. Configure that behavior per process:
162+
Most commands check for new nit releases and notify by default. Configure that behavior per process:
163163

164164
```bash
165-
NIT_AUTO_UPDATE=install nit status # default
166-
NIT_AUTO_UPDATE=notify nit status # report only
165+
NIT_AUTO_UPDATE=notify nit status # default, report only
166+
NIT_AUTO_UPDATE=install nit status # install exact npm version and re-run
167167
NIT_AUTO_UPDATE=off nit status # skip checks
168168
```
169169

170-
`NIT_NO_AUTO_UPDATE=1` still disables automatic updates. Use `nit update --check` or `nit update --install` when you want to handle it explicitly.
170+
`NIT_NO_AUTO_UPDATE=1` still disables update checks. Use `nit update --check` or `nit update --install` when you want to handle it explicitly.
171171

172172
## How It Works
173173

SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: nit
33
description: Git for agent identity — one identity, any apps
44
metadata:
5-
version: 0.6.28
5+
version: 0.6.29
66
---
77

88
# nit — Git for Agent Identity

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@newtype-ai/nit",
3-
"version": "0.6.28",
3+
"version": "0.6.29",
44
"description": "Version control for agent cards",
55
"type": "module",
66
"bin": {

src/update-check.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function resolveAutoUpdateMode(env: EnvLike = process.env): { mode: Updat
101101

102102
const configured = env.NIT_AUTO_UPDATE;
103103
if (!configured) {
104-
return { mode: 'install' };
104+
return { mode: 'notify' };
105105
}
106106

107107
const mode = parseUpdateMode(configured);
@@ -200,12 +200,12 @@ export function installNitVersion(latest: string, options: InstallUpdateOptions
200200
}
201201

202202
/**
203-
* Auto-update nit if a newer version is available on npm.
203+
* Check for nit updates and optionally install them.
204204
* Intended for CLI use only — never call from the library API.
205205
*
206-
* On success, re-executes the current command with the updated binary
207-
* and exits. On failure, warns and returns (caller continues with
208-
* current version).
206+
* Default mode is notify. In install mode, a successful update re-executes the
207+
* current command with the updated binary and exits. On failure, warns and
208+
* returns so the caller continues with the current version.
209209
*/
210210
export async function autoUpdate(options: AutoUpdateOptions = {}): Promise<void> {
211211
const env = options.env ?? process.env;

tests/local-regression.test.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ async function fingerprintApi() {
6161
test('auto update policy supports off notify and install modes', async () => {
6262
const api = await updateApi();
6363

64+
assert.equal(api.resolveAutoUpdateMode({}).mode, 'notify');
65+
6466
let checked = false;
6567
await api.autoUpdate({
6668
env: { NIT_AUTO_UPDATE: 'off' },
@@ -101,6 +103,24 @@ test('auto update policy supports off notify and install modes', async () => {
101103
assert.match(installStderr, /updating 0\.6\.15 -> 9\.9\.9/);
102104
});
103105

106+
test('auto update default notifies instead of installing', async () => {
107+
const api = await updateApi();
108+
109+
const calls = [];
110+
let stderr = '';
111+
await api.autoUpdate({
112+
env: {},
113+
check: async () => ({ current: '0.6.15', latest: '9.9.9' }),
114+
execFile: (file, args, options) => {
115+
calls.push({ file, args, options });
116+
},
117+
stderr: { write: (message) => { stderr += message; } },
118+
});
119+
120+
assert.equal(calls.length, 0);
121+
assert.match(stderr, /update available 0\.6\.15 -> 9\.9\.9/);
122+
});
123+
104124
test('auto update keeps legacy opt out and rejects invalid policy', async () => {
105125
const api = await updateApi();
106126

0 commit comments

Comments
 (0)