@agentsignalnet/claude-plugin 0.2.81 → 0.2.82

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentsignal",
3
3
  "displayName": "AgentSignal",
4
- "version": "0.2.81",
4
+ "version": "0.2.82",
5
5
  "description": "Page a human from inside Claude Code, or become an addressable agent that other agents can reach.",
6
6
  "author": {
7
7
  "name": "Data Group AI",
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Open the AgentSignal website
3
+ argument-hint: "[docs, or pricing, or whatever part of it]"
4
+ ---
5
+
6
+ Open <https://agentsignal.net> for the person at this keyboard.
7
+
8
+ `$1` names a part of the site rather than a path. Map it to one of these and
9
+ open that; anything unrecognised goes to the front page rather than to a URL
10
+ guessed from the word, because a 404 is a worse answer than the home page.
11
+
12
+ - nothing given — `https://agentsignal.net`
13
+ - `docs` — `https://agentsignal.net/docs`
14
+ - `marketplace`, `install`, `plugin` — `https://agentsignal.net/marketplace`
15
+
16
+ OPEN IT IF THIS CLIENT CAN, and print the link either way. A terminal client
17
+ that cannot open a browser has done nothing useful by reporting success, and a
18
+ link is the thing they can act on. One line, the URL in it, and stop.
19
+
20
+ Do not fetch the page and read it back. This command exists to put a browser in
21
+ front of a person; summarising the site to somebody who asked to look at it is
22
+ answering a question they did not ask, and the fetched copy is a worse version
23
+ of what their browser is about to render.
24
+
25
+ WHAT THIS IS NOT. Not a way to reach the dashboard, and worth saying because
26
+ the names collide: `/agentsignal:dashboard` runs the LOCAL one, on 127.0.0.1,
27
+ which reads this machine's channel with this machine's key. The website is the
28
+ product — signing in, the team page, billing, docs. Somebody who wants to watch
29
+ their agents talk wants the other command.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsignalnet/claude-plugin",
3
- "version": "0.2.81",
3
+ "version": "0.2.82",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,7 +33,10 @@
33
33
  * reading it half-written would see truncated JSON and conclude, wrongly, that
34
34
  * there is nothing waiting. Rename is atomic on the same filesystem.
35
35
  */
36
- import { readFileSync, writeFileSync, renameSync, mkdirSync, existsSync, statSync, unlinkSync } from 'node:fs';
36
+ import {
37
+ readFileSync, writeFileSync, renameSync, mkdirSync, existsSync, statSync, unlinkSync,
38
+ readdirSync, rmSync,
39
+ } from 'node:fs';
37
40
  import { fileURLToPath } from 'node:url';
38
41
  import { join, dirname } from 'node:path';
39
42
  import { stateDirs, writeDir, identities as storedIdentities } from './state.mjs';
@@ -512,6 +515,89 @@ const me = {
512
515
  };
513
516
 
514
517
 
518
+ /**
519
+ * SWEEP THE OLD VERSIONS OUT OF THE PLUGIN CACHE.
520
+ *
521
+ * `claude plugin update` copies the new version into a directory of its own and
522
+ * leaves every previous one where it is. On this machine that had reached 26 of
523
+ * them. The disk is not the problem -- seven megabytes -- and old code that
524
+ * still RUNS is:
525
+ *
526
+ * A version directory is a working plugin root. A session that loads one starts
527
+ * ITS daemon, from ITS copy of this file. Both halves of that were seen on the
528
+ * machine this was written on: a 0.2.79 watcher alive under a 0.2.81 install,
529
+ * and before it a 0.2.76 dashboard. Worse for anyone still carrying a root from
530
+ * before 0.2.22, which cannot see the shared lock at all and so starts a second
531
+ * watcher silently -- no superseding line, nothing in any log, just every
532
+ * urgent message arriving twice. Updating does not reach that root. Nothing did.
533
+ *
534
+ * So the update removes them, from the one place that runs on every machine on
535
+ * every session: here.
536
+ *
537
+ * FOUR GUARDS, because this deletes directories.
538
+ *
539
+ * 1. Only the cache layout. The parent must be an `agentsignal` directory of
540
+ * version-named siblings. A checkout root has no such parent and is left
541
+ * completely alone -- deleting a developer's working tree because it
542
+ * shipped this file would be an unforgettable way to learn that.
543
+ * 2. Only names that are versions. Anything not `1.2.3` is not ours to judge.
544
+ * 3. Only OLDER than the one running. Never the current root, and never a
545
+ * newer one -- a rollback in progress is somebody's deliberate act.
546
+ * 4. Never one a live process is inside. Checked against the running
547
+ * watchers, because deleting the files under a daemon that is mid-poll is
548
+ * a crash rather than a cleanup.
549
+ *
550
+ * Best effort throughout. A cache that will not tidy itself is untidy; a
551
+ * watcher that refuses to start because it could not tidy is broken.
552
+ */
553
+ function sweepOldVersions() {
554
+ try {
555
+ const here = dirname(dirname(fileURLToPath(import.meta.url))); // .../<version>
556
+ const parent = dirname(here); // .../agentsignal
557
+ const mine = here.slice(parent.length + 1);
558
+
559
+ const version = /^(\d+)\.(\d+)\.(\d+)$/;
560
+ const asNumbers = (name) => version.exec(name)?.slice(1).map(Number);
561
+ const ours = asNumbers(mine);
562
+ // Guard 1 and 2: if this root is not itself version-named, this is a
563
+ // checkout or something unfamiliar, and nothing here is ours to remove.
564
+ if (!ours) return;
565
+
566
+ const older = (them) => {
567
+ for (let i = 0; i < 3; i += 1) {
568
+ if (them[i] !== ours[i]) return them[i] < ours[i];
569
+ }
570
+ return false; // equal is the current one, which guard 3 keeps
571
+ };
572
+
573
+ // Guard 4: anything a living watcher is running from stays, whatever its
574
+ // version says.
575
+ const inUse = new Set(
576
+ livingWatchers(lockRoot)
577
+ .map((w) => w.script)
578
+ .filter(Boolean)
579
+ .map((script) => dirname(dirname(script))),
580
+ );
581
+
582
+ let swept = 0;
583
+ for (const name of readdirSync(parent)) {
584
+ const theirs = asNumbers(name);
585
+ if (!theirs || !older(theirs)) continue;
586
+ const path = join(parent, name);
587
+ if (inUse.has(path)) continue;
588
+ try {
589
+ rmSync(path, { recursive: true, force: true });
590
+ swept += 1;
591
+ } catch {
592
+ /* a permission, a file open elsewhere: leave it and carry on */
593
+ }
594
+ }
595
+ if (swept > 0) say(`swept ${swept} superseded plugin version${swept === 1 ? '' : 's'}`);
596
+ } catch {
597
+ /* Tidying is not the job. Failing to tidy must not stop the watching. */
598
+ }
599
+ }
600
+
515
601
  /** Wait for a process to actually go, rather than assuming a signal worked. */
516
602
  async function waitForExit(pid, ms) {
517
603
  const deadline = Date.now() + ms;
@@ -657,6 +743,8 @@ for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP']) {
657
743
  });
658
744
  }
659
745
 
746
+ sweepOldVersions();
747
+
660
748
  const watching = identities();
661
749
  say(
662
750
  `started (pid ${process.pid}) watching ${baseUrl} every ${intervalMs / 1000}s; ` +