@grknbyk/agent-wire 0.9.2 → 0.10.0

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
@@ -129,6 +129,7 @@ again.
129
129
  | `agent-wire ask <name>` | Name who is waiting and how many; open nothing |
130
130
  | `agent-wire read <name>` | Put the messages themselves into every prompt |
131
131
  | `agent-wire off <name>` | Say nothing about this channel in this session |
132
+ | `agent-wire update` | Install the newest published version, npm cache and all |
132
133
 
133
134
  ## Tools your agent gets
134
135
 
@@ -21,6 +21,7 @@ const USAGE = `agent-wire — message other AI coding agents through Slack
21
21
  agent-wire read <name> put the messages themselves into every prompt
22
22
  agent-wire off <name> say nothing about it in this session
23
23
  agent-wire version print the installed version, which is what a bug report needs
24
+ agent-wire update install the newest published version, cache and all
24
25
 
25
26
  The three modes belong to one session, identified by the client's session id when
26
27
  it publishes one and by the working directory otherwise. The token, the nickname
@@ -117,13 +118,64 @@ const showStatus = async () => (await import('../src/status.mjs')).runStatus();
117
118
  // Everybody types one of these three before they report anything, so all three
118
119
  // answer. package.json is read here rather than imported at the top because
119
120
  // `drain` runs on every prompt and never needs it.
120
- async function showVersion() {
121
+ const PACKAGE_NAME = '@grknbyk/agent-wire';
122
+
123
+ const packageJson = async () => {
121
124
  const { readFileSync } = await import('node:fs');
122
125
  const { fileURLToPath } = await import('node:url');
123
126
  const { dirname, join } = await import('node:path');
127
+ return JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8'));
128
+ };
129
+
130
+ // `npm i -g` came back with the previous version three times in one afternoon,
131
+ // on two machines: npm answers from its own cache and the tag it already has.
132
+ // Clearing first and naming @latest is the difference, and it is not something
133
+ // anybody should have to remember twice.
134
+ async function update() {
135
+ const { execSync } = await import('node:child_process');
136
+ const here = (await packageJson()).version;
137
+ // One string rather than a command and an array: npm is npm.cmd on Windows,
138
+ // which needs a shell, and passing an args array through one is deprecated.
139
+ const run = (line, quiet) => execSync(`npm ${line}`, { encoding: 'utf8', stdio: quiet ? 'pipe' : 'inherit' });
140
+
141
+ let latest;
142
+ try {
143
+ latest = run(`view ${PACKAGE_NAME} version`, true).trim();
144
+ } catch {
145
+ console.log('could not reach the npm registry — check the network, then try again');
146
+ return 1;
147
+ }
148
+
149
+ // It goes into a shell line next, and it came off the network. A version is
150
+ // a version; anything else is not something to run.
151
+ if (!/^[\w.+-]+$/.test(latest)) {
152
+ console.log(`npm answered with something that is not a version: ${JSON.stringify(latest)}`);
153
+ return 1;
154
+ }
124
155
 
125
- const packageJson = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
126
- console.log(JSON.parse(readFileSync(packageJson, 'utf8')).version);
156
+ if (latest === here) {
157
+ console.log(`${here} is the latest.`);
158
+ return 0;
159
+ }
160
+
161
+ console.log(`${here} installed, ${latest} published. Updating.`);
162
+ try {
163
+ run('cache clean --force', true);
164
+ run(`i -g ${PACKAGE_NAME}@${latest}`);
165
+ } catch {
166
+ console.log(`\nnpm refused. On macOS that is usually /usr/local owned by root — give npm a`);
167
+ console.log('prefix you own rather than using sudo, which leaves root-owned files behind:');
168
+ console.log(' npm config set prefix ~/.npm-global');
169
+ console.log(' export PATH="$HOME/.npm-global/bin:$PATH"');
170
+ return 1;
171
+ }
172
+
173
+ console.log(`\nNow on ${latest}. Run \`agent-wire doctor\` to check nothing came loose.`);
174
+ return 0;
175
+ }
176
+
177
+ async function showVersion() {
178
+ console.log((await packageJson()).version);
127
179
  return 0;
128
180
  }
129
181
 
@@ -139,6 +191,7 @@ const commands = {
139
191
  // `on` was the only way to undo `off` before there were three modes, and it
140
192
  // meant "announce it without opening it". That is ask.
141
193
  on: () => switchChannel(process.argv[3], 'ask'),
194
+ update,
142
195
  version: showVersion,
143
196
  '--version': showVersion,
144
197
  '-v': showVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grknbyk/agent-wire",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "Let AI coding agents message each other through a shared Slack channel, over MCP.",
5
5
  "type": "module",
6
6
  "license": "MIT",