@peer-agent/cli 0.0.1-beta.49 → 0.0.2-beta.1

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/README.md CHANGED
@@ -32,6 +32,18 @@ Requires **Node.js 20+**.
32
32
 
33
33
  Version is pinned to the npm package version (e.g. `@peer-agent/cli@0.0.1-beta.38` downloads the `v0.0.1-beta.38` GitHub Release asset).
34
34
 
35
+ ## Automatic updates
36
+
37
+ On an interactive launch, `peer` checks GitHub Releases in the background at most once every 24 hours. The check never blocks startup, is skipped in CI and non-TTY sessions, and silently preserves the current version when the network is unavailable.
38
+
39
+ Stable versions follow stable Releases; beta versions follow prerelease Releases. When a newer matching version is available, the TUI asks for confirmation before changing anything:
40
+
41
+ - npm installs upgrade with `npm install --global @peer-agent/cli@<version>`
42
+ - pnpm installs upgrade with `pnpm add --global @peer-agent/cli@<version>`
43
+ - direct GitHub Release installs download the matching archive and replace `peer` plus `peer-credential-helper` using staged files and rollback backups
44
+
45
+ Press **Y** or **Enter** to confirm, or **N** / **Esc** to dismiss. Restart `peer` after a successful update. Automatic checks can be disabled with `PEER_AGENT_NO_UPDATE_CHECK=1`; manual reinstall commands continue to work.
46
+
35
47
  ## Supported platforms (today)
36
48
 
37
49
  | Platform | Archive | Notes |
@@ -45,6 +57,7 @@ Version is pinned to the npm package version (e.g. `@peer-agent/cli@0.0.1-beta.3
45
57
  |----------|--------|
46
58
  | `PEER_AGENT_SKIP_DOWNLOAD=1` | Skip binary download (CI publish / offline) |
47
59
  | `PEER_AGENT_FORCE_DOWNLOAD=1` | Force download even inside the monorepo checkout |
60
+ | `PEER_AGENT_NO_UPDATE_CHECK=1` | Disable automatic background update checks |
48
61
  | `PEER_AGENT_RELEASE_BASE` | Override GitHub Releases base URL (tests / mirrors) |
49
62
 
50
63
  ## Monorepo developers
package/bin/peer.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * peer-credential-helper must live next to peer (same vendor/ directory).
5
5
  */
6
6
  import { spawn } from 'node:child_process';
7
- import { existsSync } from 'node:fs';
7
+ import { existsSync, readFileSync } from 'node:fs';
8
8
  import { dirname, join } from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
10
 
@@ -36,9 +36,19 @@ if (!existsSync(binary) || !existsSync(helper)) {
36
36
  process.exit(1);
37
37
  }
38
38
 
39
+ let installSource = 'npm';
40
+ try {
41
+ const metadata = JSON.parse(
42
+ readFileSync(join(vendor, '.peer-agent-install.json'), 'utf8'),
43
+ );
44
+ if (metadata.source === 'pnpm') installSource = 'pnpm';
45
+ } catch {
46
+ // Older installs predate source metadata; npm is the conservative default.
47
+ }
48
+
39
49
  const child = spawn(binary, process.argv.slice(2), {
40
50
  stdio: 'inherit',
41
- env: process.env,
51
+ env: { ...process.env, PEER_AGENT_INSTALL_SOURCE: installSource },
42
52
  windowsHide: true,
43
53
  });
44
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/cli",
3
- "version": "0.0.1-beta.49",
3
+ "version": "0.0.2-beta.1",
4
4
  "description": "Peer Agent CLI — install via npm; downloads the platform peer binary from GitHub Releases.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -3,7 +3,7 @@
3
3
  * postinstall — download peer + peer-credential-helper for the current platform
4
4
  * from the matching GitHub Release (package version == release tag without v).
5
5
  */
6
- import { existsSync, readFileSync } from 'node:fs';
6
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
7
7
  import { dirname, join } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { installBinary } from '../lib/install-binary.mjs';
@@ -31,6 +31,12 @@ try {
31
31
  root,
32
32
  log: (msg) => console.log(msg),
33
33
  });
34
+ const userAgent = process.env.npm_config_user_agent ?? '';
35
+ const packageManager = userAgent.startsWith('pnpm/') ? 'pnpm' : 'npm';
36
+ writeFileSync(
37
+ join(root, 'vendor', '.peer-agent-install.json'),
38
+ `${JSON.stringify({ source: packageManager, packageName: pkg.name })}\n`,
39
+ );
34
40
  } catch (error) {
35
41
  const message = error instanceof Error ? error.message : String(error);
36
42
  console.error(`[@peer-agent/cli] postinstall failed: ${message}`);