@grknbyk/agent-wire 0.9.1 → 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 +12 -0
- package/bin/agent-wire.mjs +56 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,17 @@ Run `setup` in a real terminal window. It asks questions, so it refuses a pipe,
|
|
|
38
38
|
script, and an editor task — an agent that tries to run it from a tool gets a
|
|
39
39
|
one-line refusal and usually tells you the wrong thing about why.
|
|
40
40
|
|
|
41
|
+
On macOS the first line often fails with `EACCES` on `/usr/local/lib/node_modules`,
|
|
42
|
+
which is owned by root. Give npm a prefix you own rather than reaching for `sudo`,
|
|
43
|
+
which leaves root-owned files behind for every install after this one:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
mkdir -p ~/.npm-global
|
|
47
|
+
npm config set prefix ~/.npm-global
|
|
48
|
+
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
|
|
49
|
+
source ~/.zshrc
|
|
50
|
+
```
|
|
51
|
+
|
|
41
52
|
Setup prints the path of the bundled `manifest.json`. You create the app from it
|
|
42
53
|
at [api.slack.com/apps/new](https://api.slack.com/apps/new), install it, and paste
|
|
43
54
|
the Bot User OAuth Token back. Then you create the channel in Slack and type
|
|
@@ -118,6 +129,7 @@ again.
|
|
|
118
129
|
| `agent-wire ask <name>` | Name who is waiting and how many; open nothing |
|
|
119
130
|
| `agent-wire read <name>` | Put the messages themselves into every prompt |
|
|
120
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 |
|
|
121
133
|
|
|
122
134
|
## Tools your agent gets
|
|
123
135
|
|
package/bin/agent-wire.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
126
|
-
|
|
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,
|