@astrosheep/square 0.3.3 → 0.3.5

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/dist/watch.js CHANGED
@@ -2,11 +2,13 @@ import { setTimeout as sleep } from 'node:timers/promises';
2
2
  import { loadSquare } from './artifact.js';
3
3
  import { SquareError, nameKey, } from './model.js';
4
4
  import { deriveDeliveryModel } from './delivery.js';
5
- import { SLEEP_MS, STALE_MS, WATCH_HEARTBEAT_MS, WATCH_STALE_MS, countSays, currentHold, doneNames, freshWatchLease, hasQuorum, inSquareCount, markDeliveredMentions, nowMs, readCursor, touchPresenceCursor, withSquareLock, writeSquareDoc, } from './runtime.js';
5
+ import { SLEEP_MS, STALE_MS, WATCH_HEARTBEAT_MS, WATCH_STALE_MS, countSays, currentHold, doneNames, freshWatchLease, hasQuorum, inSquareCount, markDeliveredMentions, nowMs, readCursor, touchPresenceCursor, } from './runtime.js';
6
+ import { withSquareLock, writeSquareDoc } from './square-store.js';
6
7
  import { renderWatchForceTakeover, renderWatchAlreadyActive, renderWatchInterrupted, renderWatchOutput, renderWatchReplaced, renderWatchStatus, participantCommandPrefix, withPathOutput, withWatchNextOutput, } from './presentation.js';
7
8
  import { ackPeerDelta, filteredPeerActivities, filteredRoomChanges, indexedDelta, matchesFeedFilter, peerPublicActs, peerRoomChanges, } from './activity-feed.js';
8
9
  import { coreParticipants, resolveKnownName } from './decisions.js';
9
10
  import { hasAutomaticDeliveryIdentity } from './registry.js';
11
+ import { execute } from './square-application.js';
10
12
  /** Notification receipts are stronger than the public-feed cursor, which self activity may advance. */
11
13
  function catchDelta(doc, name) {
12
14
  const items = indexedDelta(doc.acts, readCursor(doc, name));
@@ -95,29 +97,25 @@ function writeWatchOutput(squarePath, name, stdout, status, idleMs) {
95
97
  process.stdout.write(withWatchNextOutput(squarePath, [stdout.trimEnd(), fallback].filter(Boolean).join('\n\n'), headerOpts));
96
98
  }
97
99
  async function beginWatch(squarePath, name, opts) {
98
- return withSquareLock(squarePath, () => {
99
- const doc = loadSquare(squarePath);
100
- const at = nowMs();
101
- const active = freshWatchLease(doc, name, at);
102
- if (active !== undefined && !(opts.force ?? false))
103
- return { type: 'active', lease: active };
104
- const id = leaseId();
105
- setLease(doc, name, id, at, opts);
106
- touchPresenceCursor(doc, name, at, 'watch');
107
- writeSquareDoc(squarePath, doc);
108
- return { type: 'started', leaseId: id, replaced: active !== undefined, heartbeatAt: at };
100
+ const at = nowMs();
101
+ const id = leaseId();
102
+ const committed = await execute(squarePath, {
103
+ type: 'lease',
104
+ name,
105
+ leaseId: id,
106
+ at,
107
+ expiresAt: at + WATCH_STALE_MS,
108
+ force: opts.force,
109
+ filter: leaseFilter(opts),
109
110
  });
111
+ if (committed.result.type === 'active')
112
+ return committed.result;
113
+ return { type: 'started', leaseId: id, replaced: committed.result.replaced, heartbeatAt: at };
110
114
  }
111
115
  async function endWatch(squarePath, name, id) {
112
116
  if (id === undefined)
113
117
  return;
114
- await withSquareLock(squarePath, () => {
115
- const doc = loadSquare(squarePath);
116
- if (doc.runtime.leases[name]?.leaseId !== id)
117
- return;
118
- delete doc.runtime.leases[name];
119
- writeSquareDoc(squarePath, doc);
120
- });
118
+ await execute(squarePath, { type: 'release-lease', name, leaseId: id });
121
119
  }
122
120
  function installWatchInterruptHandler(squarePath, name, currentLeaseId) {
123
121
  const onInterrupt = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/square",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Multi-agent brainstorming through a shared file. Agents join, talk, watch, and mark themselves done.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,6 +18,8 @@
18
18
  "scripts": {
19
19
  "clean": "node --input-type=module -e \"import fs from 'node:fs'; fs.rmSync('dist',{recursive:true,force:true})\"",
20
20
  "build": "npm run clean && tsc && node --input-type=module -e \"import fs from 'node:fs'; fs.chmodSync('dist/square.js',0o755)\"",
21
+ "verify-release": "node test/release.test.js",
22
+ "prepublishOnly": "npm run build && npm run verify-release",
21
23
  "test": "npm run build && node --test test/*.test.js"
22
24
  },
23
25
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "square",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Native Claude Code turn-boundary delivery for Square participants",
5
5
  "author": {
6
6
  "name": "Square"