@astrosheep/square 0.3.78 → 0.3.80

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.
Files changed (70) hide show
  1. package/dist/attention-presentation.d.ts +2 -0
  2. package/dist/attention-presentation.js +39 -4
  3. package/dist/automatic-session.js +1 -1
  4. package/dist/boundary-presentation.js +4 -7
  5. package/dist/claude-mod.js +1 -1
  6. package/dist/cli/catch-presentation.d.ts +2 -2
  7. package/dist/cli/catch-presentation.js +3 -3
  8. package/dist/cli/context.d.ts +11 -1
  9. package/dist/cli/context.js +14 -3
  10. package/dist/cli/express-presentation.d.ts +6 -5
  11. package/dist/cli/express-presentation.js +42 -43
  12. package/dist/cli/maintenance-commands.js +6 -6
  13. package/dist/cli/mcp-server-command.js +1 -1
  14. package/dist/cli/observation-commands.d.ts +4 -4
  15. package/dist/cli/observation-commands.js +20 -16
  16. package/dist/cli/program.d.ts +1 -1
  17. package/dist/cli/program.js +5 -5
  18. package/dist/cli/square-commands.js +35 -23
  19. package/dist/decisions.d.ts +3 -5
  20. package/dist/decisions.js +10 -9
  21. package/dist/delivery.d.ts +1 -1
  22. package/dist/help.js +15 -2
  23. package/dist/inbox.js +3 -3
  24. package/dist/index.d.ts +1 -2
  25. package/dist/index.js +1 -2
  26. package/dist/ledger-maintenance.d.ts +1 -1
  27. package/dist/ledger-maintenance.js +1 -1
  28. package/dist/list.d.ts +3 -3
  29. package/dist/list.js +1 -1
  30. package/dist/mcp.d.ts +2 -2
  31. package/dist/mcp.js +12 -7
  32. package/dist/mention-parse.d.ts +2 -8
  33. package/dist/mention-parse.js +6 -9
  34. package/dist/model.d.ts +2 -2
  35. package/dist/notifications.js +24 -8
  36. package/dist/participant-host.js +5 -0
  37. package/dist/plugins/opencode/index.js +1 -1
  38. package/dist/square-actions.d.ts +22 -9
  39. package/dist/square-actions.js +26 -19
  40. package/dist/square-api.d.ts +43 -0
  41. package/dist/square-api.js +471 -0
  42. package/dist/square-facade.d.ts +123 -203
  43. package/dist/square-tools.d.ts +4 -3
  44. package/dist/square-tools.js +21 -15
  45. package/dist/stream.d.ts +2 -2
  46. package/dist/views.d.ts +16 -12
  47. package/dist/views.js +13 -27
  48. package/guides/application-demand-optimization.md +5 -0
  49. package/guides/application-facade-delivery-evidence.md +7 -2
  50. package/guides/mcp-connection-lifetime.md +2 -2
  51. package/guides/mcp.md +1 -1
  52. package/guides/operation-cancellation.md +2 -0
  53. package/guides/primitive-catch-consolidation.md +5 -0
  54. package/guides/primitive-history-consolidation.md +5 -0
  55. package/guides/primitive-status-consolidation.md +5 -0
  56. package/guides/primitive-storage-consolidation.md +5 -0
  57. package/guides/row-storage-design.md +1 -1
  58. package/guides/square-api.md +107 -0
  59. package/package.json +1 -1
  60. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  61. package/plugins/claude/skills/square/SKILL.md +4 -4
  62. package/plugins/codex/.codex-plugin/plugin.json +1 -1
  63. package/plugins/opencode/index.ts +1 -1
  64. package/plugins/paseo/client/markdown.tsx +16 -6
  65. package/plugins/pi/square-pi.js +7 -6
  66. package/skills/square/SKILL.md +4 -4
  67. package/dist/square-application.d.ts +0 -38
  68. package/dist/square-application.js +0 -683
  69. package/guides/application-boundary.md +0 -32
  70. package/guides/application-facade-design.md +0 -98
@@ -1,32 +0,0 @@
1
- # Application boundary
2
-
3
- Square has three layers around an activity operation:
4
-
5
- - **Domain** (`decisions.ts`, `catch-decisions.ts`, and projections) applies
6
- SquareState rules and perception without transport or CLI concerns.
7
- - **Application** (`square-application.ts`) receives an explicit caller
8
- snapshot, resolves defaults and ambiguity, coordinates facade operations,
9
- owns resources, applies express wait/no-wait policy, and returns structured
10
- data. It never reads ambient process state from inside an application call.
11
- - **Transport and presentation** (the CLI today, Pi and MCP later) parse input,
12
- read stdin, render sensory output, build recovery commands, and choose process
13
- exit behavior.
14
-
15
- The application boundary exposes only neutral `HostLedgerPort` behavior. Ledger
16
- layout, storage scopes, and hook reconciliation remain adapter concerns and are
17
- intentionally absent. Exact lifecycle cleanup remains owned by the ledger/registry
18
- adapter used by the facade.
19
-
20
- The CLI now delegates join/reconnect/takeover gates and cleanup, express admission
21
- and retry/no-wait behavior, catch/history, listener operations, lifecycle actions,
22
- and status/participant projections to the application layer. It retains only
23
- transport-specific details: argv validation, stdin body resolution, ANSI and
24
- sensory rendering, continuation/recovery commands, watch leases and signals,
25
- and process exit codes. Advanced history display context (`--at`, `-A`, `-B`,
26
- `-C`) remains a presentation concern while the ordinary archive/filter/cursor
27
- path uses the application history operation.
28
-
29
- Application operations accept the final `OperationControl` coordinate as their
30
- last control argument and forward it to facade operations. This is deliberately
31
- separate from the transport's rendering and does not create a second cancellation
32
- model.
@@ -1,98 +0,0 @@
1
- # One Square application boundary
2
-
3
- **Status: implemented; deliverer verification and measurement are recorded in the delivery evidence. Independent review remains separate.**
4
- Baseline: `52b58eb9f901f0458302e6120cd83b1079f8ba1c`. Delivery evidence and the exact size recipe live in [application-facade-delivery-evidence](application-facade-delivery-evidence.md).
5
-
6
- ## Decision in brief
7
-
8
- - `square-application.ts` is the sole runtime application owner. It captures the operation context, resolves location/participant, opens and closes resources, applies common defaults (reentry, quiet-wait, default wake transport, history page size), coordinates private actions, and composes projections.
9
- - `square-facade.ts` stays type-only: it declares the operation contracts, the `{data, projection}` outcome, projection contracts and the SDK resource types. It is the source of every public contract name; the owner re-exports its types.
10
- - CLI and MCP are transport adapters. Neither opens storage, reads private projections, executes admission/wait policy nor derives domain states from display text.
11
- - SDK resource handles and the application share the same semantic owners (`prepareExpression`, `landExpression`, `catchOwned`); the handles do not round-trip through the application outcome/projection contract.
12
- - `square-wiring.ts`, root `activity.ts` and root `watch.ts` are deleted. No forwarding stub, legacy factory or return-shape mode remains.
13
- - The SDK resource API and its documented defaults are preserved, but they are a resource surface over the same owner functions, not a second implementation.
14
-
15
- ## The application contract
16
-
17
- Root factory (named, single):
18
-
19
- ```ts
20
- export function createSquareApplication(context: SquareApplicationContext): SquareApplication;
21
- ```
22
-
23
- Context (`cwd`, captured `env`, optional `squarePath`, `participant`, `clock`, `hostLedger`, `wakeTransport`) is snapshotted at creation. Location resolution uses the context and its `SQUARE_LOCATION`; participant selection is explicit context, then captured `SQUARE_PARTICIPANT_NAME`, then one unambiguous current-session binding from the selected/injected ledger. Explicit values win. A history read never discovers, joins or claims a participant just to select a default limit.
24
-
25
- Every operation returns one composed outcome:
26
-
27
- ```ts
28
- export interface ApplicationOutcome<Data, Projection> {
29
- readonly data: Data; // canonical structured result (the MCP wire fields are a subset)
30
- readonly projection: Projection; // extra domain/presentation facts, never terminal copy
31
- }
32
- ```
33
-
34
- `SquareApplication` exposes `now()`, `build`, `join`, `express`, `catch`, `history`, `listen`, `ignore`, `listening`, `hold`, `resume`, `done`, `status`, `participants`, `diagnose`, `migrate`, `discover`, `inbox`, `recovery` and `stream(options, control?)` (an abortable `AsyncIterable`, not a process writer). Read-only operations accept the same `OperationControl` (`signal` + typed progress).
35
-
36
- This outcome contract **replaces** the previous factory return values; it is not source-compatible with them, and it does not select semantics or shapes by transport. In-repo consumers migrate together. There is no second factory, no overload that chooses a return shape, and no compatibility shim. The application result contract is recorded in the delivery evidence so it cannot be mistaken for the earlier factory contract.
37
-
38
- Array-bearing results use object envelopes (`{activities}`, `{participants}`, `{listening}`), never arrays carrying hidden metadata. `data` never contains an artifact, transaction callback, SQL, lock or lease capability.
39
-
40
- `ApplicationFailureDetail` supplements, never contradicts, authoritative `facts.activityUnsent`; the owner classifies express effects as before-attempt, proven-unsent (authoritative admission refusal), landed (committed activity + ID) or unknown (execution failure without refusal/result evidence).
41
-
42
- ## Committed facts and projection sources
43
-
44
- - Express takes its minimal count/header facts from the authoritative commit's own observation. It does not issue a later context read that could erase a successful say, and it does not build a second pending feed that would be discarded. The outcome `data` is the committed activity, `waited` and optional `replyAuthorNotHere`; the projection adds the pre-attempt directed feed, the reentry fact and delivery.
45
- - Catch settles raw records, say ordinals and count/terminal facts inside the same receipt transaction as selection and marking seen. There is no duplicate post-receipt raw re-read: the application outcome adds the optional focused `catchPresence` read instead, and its unavailability is an explicit fact (`enrichmentUnavailable`).
46
-
47
- ## SDK resources and preserved defaults
48
-
49
- - `Square` and its participant handles live in `square-application.ts`; `index.ts` exports `Square` from there, not from a forwarding shim.
50
- - SDK handles call the shared semantic owners directly, not through an application outcome/projection roundtrip:
51
- - `Participant.express` = `prepareExpression` (reentry/caller resolution) + the shared `landExpression` retry/commit owner. It returns the established `ExpressResult` (including `delivery`) and drops the projection.
52
- - `Participant.catch` = the shared `catchOwned` lease/wait/selection/sweep owner. It unwraps the receipt data into `CatchResult` (`activities`, `consumedThrough`, `idleExpired`, `remaining`).
53
- - Listener, lifecycle and history methods call their shared owners directly; `snapshot().delivered` stays a detached receipt predicate.
54
- - Retained supported `Square` methods: `at`, `build`, `inMemory`, `join`, `takeover`, `doneOwnedSession`, `implicitJoin`, `participants`, `snapshot`, `history`, `recognize`, `close`, `endOwnedSession`, `retireEndedSessionRoutes`. The unused `joinWithActivity`, `takeoverWithActivity`, `joinFacts` and `standingCount` glue is deleted.
55
- - Preserved defaults are explicit at the SDK/application boundary, not a difference in transport defaults:
56
- - `Square.history()` keeps its current **unbounded** archive default.
57
- - `Participant.history()` keeps its current **recent-ten** default.
58
- - Application, CLI and MCP ordinary history default to **ten**, independent of participant selection.
59
- - In-memory resources stay in-memory: they do not invent file/native wake routes or build a default transport merely to express.
60
-
61
- ## Module deletion map
62
-
63
- | Path | New ownership | Disposition |
64
- | --- | --- | --- |
65
- | `square-wiring.ts` | `square-application.ts` | **Deleted.** `Square`/participant handles flattened into the owner; no re-export stub. |
66
- | `activity.ts` | `app.express` + `cli/express-presentation.ts` | **Deleted.** Caller resolution, implicit join, attempt/uncertainty policy and default-transport construction moved to the owner; only draft/retry/render helpers survive in the CLI. |
67
- | `watch.ts` | `app.catch` + `cli/catch-presentation.ts` | **Deleted.** Lease/heartbeat/revision loop and terminal policy moved to the owner; one renderer of returned classifications remains. |
68
- | `square-application.ts` | — | **Owner.** Shared `prepareExpression`/`landExpression`/`catchOwned` semantic owners are the single implementation for application and SDK. No application -> SDK -> application chain; unused SDK glue (`joinWithActivity`, `takeoverWithActivity`, `joinFacts`, `standingCount`) deleted, supported methods retained. |
69
- | `square-facade.ts` | — | Type-only contracts, `ApplicationOutcome`, projection/SDK contracts, explicit legacy name aliases. |
70
- | `square-actions.ts` | `square-actions.ts` | Private mutation/ownership fences/delivery integration; called only by the owner. |
71
- | `decisions.ts`, `catch-decisions.ts`, `wakes.ts` | unchanged files | Private implementations used by the owner. |
72
- | `views.ts` | unchanged file | Private selected-row reads. `activityPresentation`, `standingCount`, `joinFacts` and `watchPresentation` retired; focused `recoveryObservation` and `catchPresence` added. Public projection types live in the facade. |
73
- | `list.ts`, `stream.ts` | unchanged files | Internal data-returning discovery/observation; no process writers or argv recovery. |
74
- | CLI operation paths (build, join, express, catch, history, listen/ignore/listening, hold/resume/done, status, participants, inbox, discover, doctor, migrate) | corresponding `app.*` | Direct storage opens, private projection imports, admission policy and duplicated wait loops removed. |
75
- | `mcp.ts` | `app.*` | `publicResult`/stored-activity conversion deleted; serialize `outcome.data` only. |
76
- | `index.ts` | owner + facade | Root `Square` from the owner; all facade contracts via one type-only star plus the supported legacy aliases. |
77
- | `automatic-session.ts`, `claude-mod.ts`, `plugins/opencode/index.ts` | owner | Mechanical import migration only; native lifecycle protocols unchanged. |
78
-
79
- ## Architecture edges
80
-
81
- - **Adapter boundary.** CLI/MCP reach storage, actions, decisions, views, wakes, list, stream, diagnosis/migration, inbox and notification execution only through `square-application.ts`. Private concern helpers retain their existing typed ports and internal dependencies; they are not callable from adapter execution paths.
82
- - **Facade.** `square-facade.ts` defines contracts; it must not derive contracts from `ReturnType`/`Awaited<ReturnType>` of private functions, and public activity IDs are formatted/parsed only by the existing core implementation.
83
- - **CLI (`cli/**`).** Owns argv/stdin, scoped help, shell quoting, sensory rendering/recovery, drafts, stdout/stderr, exit codes, SIGINT -> `AbortSignal` and stream backpressure. It maps returned classifications to copy/exit status, and preserves query argv in continuation commands; it cannot derive admission, commit certainty, terminal states or pagination eligibility from display text. File path display and draft-file I/O are allowed; opening an artifact or resolving ownership is not path formatting.
84
- - **Tools (`square-tools.ts`).** Owns shared Zod input schemas, descriptions and typed argument-to-facade calls for MCP and Pi. No session, environment, connection lifetime or business policy lives here.
85
- - **MCP (`mcp.ts`).** Owns registration, request-local `location`/`as`/metadata session mapping, signal forwarding, JSON-RPC envelopes and stdio lifecycle. Request environment derivation stays immutable; no shared `process.env` writes and no invented session identity.
86
- - **Claude mod (`plugins/claude/hooks/register.js`).** Owns the pending MCP call's identity association, publishing before `next(e)` and removing its exact token in `finally` through the existing native helper. `claude-mcp-context.ts` stores only transient transport coordinates, outside Square domain/artifact state. The bundled MCP adapter reads them using Claude's tool-use metadata; model-visible schemas contain no identity fields.
87
- - **Pi (`plugins/pi/square-pi.js`).** Registers the same operations as native codemode tools. Each call derives its identity and cwd from the live Pi context and uses the facade's per-operation connection lifetime. JSON schemas come from the shared Zod definitions; Pi has no separate parameter contract.
88
- - **Closed exceptions.** Harness install/uninstall/doctor, scoped help/version, meta commands and native hook input/output keep their existing protocol owners; that exception does not cover join, expression, catch, history, status, participants, build, stream, discovery, inbox, artifact doctor or migrate. Native changes stay limited to the required owner import migration.
89
- - **Storage/native scope.** SQLite schema/framing, artifact version, migration protocol, receipt model, ownership CAS, notification cancellation suppression and delivery eligibility rules are unchanged. Transactions stay synchronous and typed. The journaled amendment permits only build/create signal propagation through the existing adapter/storage/artifact retries and transactions, and captured-env propagation through default Codex wake construction/executable selection. A committed build is returned despite later cancellation; temporary-file cleanup does not reuse the aborted signal.
90
-
91
- ## Shared behavior (all four land together)
92
-
93
- 1. Application express reenters a roster-known departed participant through the same join/ownership path; a never-joined caller is refused. Takeover is never implicit.
94
- 2. Application idle catch is one shared leased quiet wait (hold/heartbeat/replacement/terminal); omitted/zero idle is immediate; exact `id` stays immediate/idempotent and conflicts with idle/filter/limit/replace; a non-replaced current lease returns `already-active`.
95
- 3. The default wake transport resolves lazily from the captured env, selected/injected ledger and clock, cached only for that application's lifetime; an injected transport prevents default construction.
96
- 4. Application, CLI and MCP history default to ten; SDK `Square`/`Participant` defaults above are preserved.
97
-
98
- Only these four deliberate common behavior changes, plus the additive explicit idle terminal statuses, alter existing behavior. All other SDK/CLI/MCP contracts, error codes and wire meanings are preserved.