@dmsdc-ai/aigentry-telepty 0.3.3 → 0.4.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/README.md +67 -1
  3. package/cli.js +161 -54
  4. package/cross-machine.js +132 -0
  5. package/daemon.js +355 -5
  6. package/host-spec.js +60 -0
  7. package/mcp-server/index.mjs +24 -3
  8. package/package.json +30 -5
  9. package/session-state.js +23 -0
  10. package/skill-installer.js +42 -6
  11. package/skills/telepty/SKILL.md +1 -1
  12. package/skills/telepty-allow/SKILL.md +1 -1
  13. package/skills/telepty-attach/SKILL.md +1 -1
  14. package/skills/telepty-broadcast/SKILL.md +1 -1
  15. package/skills/telepty-daemon/SKILL.md +1 -1
  16. package/skills/telepty-inject/SKILL.md +76 -4
  17. package/skills/telepty-list/SKILL.md +1 -1
  18. package/skills/telepty-listen/SKILL.md +1 -1
  19. package/skills/telepty-rename/SKILL.md +1 -1
  20. package/skills/telepty-session/SKILL.md +1 -1
  21. package/src/init/print-snippet.js +114 -0
  22. package/src/init/snippets/agents.md +15 -0
  23. package/src/init/snippets/claude.md +15 -0
  24. package/src/init/snippets/gemini.md +15 -0
  25. package/src/prompt-symbol-registry.js +43 -1
  26. package/.claude/commands/telepty-allow.md +0 -58
  27. package/.claude/commands/telepty-attach.md +0 -22
  28. package/.claude/commands/telepty-inject.md +0 -72
  29. package/.claude/commands/telepty-list.md +0 -22
  30. package/.claude/commands/telepty-manual-test.md +0 -73
  31. package/.claude/commands/telepty-start.md +0 -25
  32. package/.claude/commands/telepty-test.md +0 -25
  33. package/.claude/commands/telepty.md +0 -82
  34. package/AGENTS.md +0 -74
  35. package/BOUNDARY.md +0 -31
  36. package/BUS_EVENT_SCHEMA.md +0 -206
  37. package/CLAUDE.md +0 -100
  38. package/GEMINI.md +0 -10
  39. package/URGENT_ISSUES.resolved.md +0 -1
  40. package/docs/superpowers/specs/2026-04-26-inject-submit-enter-reliability.md +0 -447
  41. package/docs/superpowers/specs/2026-04-26-prompt-symbol-render-gate.md +0 -571
  42. package/docs/superpowers/specs/2026-04-26-submit-gate-fixes-v2.md +0 -608
  43. package/docs/superpowers/specs/2026-05-02-submit-force-and-retry.md +0 -139
  44. package/protocol/mailbox.md +0 -244
  45. package/specs/codex-inject-spec.md +0 -201
  46. package/specs/enforce-report-spec.md +0 -237
  47. package/templates/AGENTS.md +0 -71
package/CHANGELOG.md CHANGED
@@ -2,6 +2,188 @@
2
2
 
3
3
  All notable changes to `@dmsdc-ai/aigentry-telepty` are documented here.
4
4
 
5
+ ## [0.4.0] — 2026-05-15
6
+
7
+ ### Added — Phase 1 sidecar supervisor spike (M1–M5)
8
+
9
+ Out-of-process Rust supervisor (`crates/telepty-supervisor-{core,bin}`)
10
+ incubating the future spawn/kill/IPC backend for `daemon.js`. Five
11
+ milestones complete; **incubating only — not on the request path** in
12
+ 0.4.0. Daemon (`daemon.js`) and CLI (`cli.js`) routing is unchanged.
13
+
14
+ - **M1** — spawn + observe (commit `07cd2e7`).
15
+ - **M2** — graceful + forced kill gate, manifest cleanup invariant A8
16
+ (commit `ec00412`).
17
+ - **M3** — IPC + wire contract conformance, NDJSON UDS frames + golden
18
+ fixtures (commit `76cde35`).
19
+ - **M4** — cross-OS POSIX parity + reproducible RSS measurement, GitHub
20
+ Actions matrix (`.github/workflows/phase1-spike-ci.yml`); RSS PASS at
21
+ 2.9–3.0 MiB / supervisor on macOS arm64 (commit `eb04c73`).
22
+ - **M5** — manual integration bridge (`scripts/bridge-phase1.js`, 194
23
+ LOC Node stdlib only) — four parity scenarios A/B/C/D, exit 0 iff all
24
+ PASS; one-line Rust correctness fix (emit `shutdown_drain` before IPC
25
+ shutdown so connected clients receive the frame) (commit `be091e0`).
26
+
27
+ Phase 1 LOC ceiling 1500 honored (Rust src/ tokei = 1240, 260 LOC
28
+ headroom unused). Test suite: 23/23 (lib unit 12 + wire_golden 6 +
29
+ ipc_protocol 5). Spec: `docs/specs/2026-05-10-supervisor-c3-kill-gate-spec.md`.
30
+ Plan: `docs/plans/2026-05-12-phase1-sidecar-spike-plan.md`.
31
+
32
+ ### Fixed
33
+
34
+ - **#18** — Bootstrap inject queue race. Welcome-banner bypass via
35
+ positive-override `is_ready` so queued injects flush in the correct
36
+ order without colliding with the banner (commit `744ad6a`).
37
+ - **#16** — REPORT-based idle status detection. Replaces heuristic
38
+ prompt-symbol detection with explicit REPORT-frame anchoring
39
+ (commit `3ed1e83`).
40
+
41
+ ### Build
42
+
43
+ - `package.json` — added `files` whitelist (22 entries) to constrain
44
+ npm-published surface to actual runtime distribution. Tarball
45
+ reduction: 228 MB → 123 kB (1850×). The Rust spike artifacts
46
+ (`target/`, `crates/`, `Cargo.lock/Cargo.toml`, `rust-toolchain.toml`)
47
+ ship in git but **not** to npm (commit `a0baf84`).
48
+
49
+ ### Docs
50
+
51
+ - MD audit wave-2 fix: `CLAUDE.md` converted to `@AGENTS.md` stub
52
+ (101 → 27 lines), `AGENTS.md` gained Session Environment section
53
+ (`$TELEPTY_SESSION_ID`, `$TELEPTY_AVAILABLE`) and disclosed
54
+ cross-repo ADR location for `2026-05-05-telepty-devkit-boundary §6.2.1`.
55
+ Score delta `AGENTS.md` 80 → 87, `CLAUDE.md` 66 → 87 (commit `74a6374`,
56
+ full report `docs/reports/2026-05-14-md-audit.md`).
57
+
58
+ ### Notes
59
+
60
+ - **Snyk SAST deferred for this release** — see follow-up task #130.
61
+ Waiver basis (Rule 32-A track B):
62
+ - M1–M5 spike code is Rust and is **excluded from the npm tarball** by
63
+ the new `files` whitelist — first-party code shipped to consumers is
64
+ JS only.
65
+ - The shipped JS files are unchanged or only minimally changed since
66
+ `0.3.5` (cli.js +51 / daemon.js +360 / src/prompt-symbol-registry.js
67
+ +44 / new session-state.js — additive, no breaks per Phase 1 audit).
68
+ - Dependency-side coverage exists via `npm audit` (10 pre-existing
69
+ vulns documented; not introduced by this release).
70
+ - Per CLAUDE.md user-instruction "Snyk At Inception" scope = *new
71
+ first-party code shipped* — 0 net-new shipped JS code in this
72
+ release, so the at-inception rule does not bind here. Follow-up
73
+ task #130 will land the standing SAST gate as a release-script
74
+ primitive (so future releases scan automatically without per-run
75
+ auth steps).
76
+
77
+ ## [0.3.5] — 2026-05-05
78
+
79
+ ### Added — `telepty init --print-snippet` (Issue #8)
80
+
81
+ New subcommand that emits the canonical telepty-baseline snippet to stdout for
82
+ graceful integration into per-CLI agent files. **Mechanism only** — telepty
83
+ emits the versioned snippet text; downstream tooling (`aigentry-devkit
84
+ scaffold --integrate-telepty`) owns idempotent insertion into
85
+ `~/CLAUDE.md` / `~/AGENTS.md` / `~/GEMINI.md`. Boundary contract per ADR
86
+ `2026-05-05-telepty-devkit-boundary` (commit `e4b072b`).
87
+
88
+ ```
89
+ telepty init --print-snippet [--target {claude|agents|gemini|all}] [--format {markdown|json}]
90
+ ```
91
+
92
+ - **argv-only**: never consumes stdin (safe in scripted pipelines).
93
+ - **zero file I/O**: pure stdout emission; nothing read from or written to disk.
94
+ - **deterministic**: byte-identical output for a given (target, format) pair —
95
+ fixtures can be hashed for verification.
96
+ - **LF-only bodies**: no CRLF leakage on cross-platform consumers.
97
+ - **stderr clean**: success path emits no warnings.
98
+
99
+ Spec: `docs/specs/2026-05-05-issue-8-telepty-init.md` (commit `8d2dc94`).
100
+ Implementation: `f5c6bad`. Protocol SSOT: `aigentry-ssot/contracts/telepty-snippet-v1.md`
101
+ (commit `f4ff0cd`). 15 conformance fixtures shipped at `tests/snippet-protocol/v1/`
102
+ covering markdown envelopes (claude, agents, gemini, all), JSON records,
103
+ shell-hazard guards, deterministic LF output, default targeting, unsupported-target
104
+ rejection, internal-failure exit codes, stdin-pipe ignore, devkit-free invocation,
105
+ and the snippet golden fixtures themselves.
106
+
107
+ ### Docs — G7/G8/G9 M0 audit gate closure (commit `d7b8b21`)
108
+
109
+ Per ADR `2026-05-05-telepty-devkit-boundary` §3.1.2 (devkit owns content
110
+ placement; telepty owns mechanism), three gates closed:
111
+
112
+ - **G7 — `README.md`**: removed reference to the rejected `telepty install
113
+ hooks` subcommand. Per ADR §3.1.2, that responsibility lives in devkit.
114
+ - **G8 — `AGENTS.md`**: added Legacy exception subsection documenting the
115
+ remaining devkit-shaped legacy surface.
116
+ - **G9 — `skill-installer.js`**: top-of-file LEGACY header per ADR §6.2.1
117
+ marking the module as legacy-track (devkit migration pending).
118
+
119
+ ### Internal
120
+
121
+ - Cross-LLM review pattern applied: Codex implemented the `init` subcommand
122
+ + fixtures; Claude reviewed and ACCEPTed (commit `d06e1e9`).
123
+ - `test/enforce-report.test.js` version assertion bumped to track release
124
+ (commit `d0f4495`).
125
+
126
+ ### Tests
127
+
128
+ - `test/init.test.js` — full coverage of the new subcommand (snippet
129
+ emission, target/format permutations, stdin-ignore, error exits, devkit-free
130
+ invocation).
131
+ - `tests/snippet-protocol/v1/` — golden fixtures for protocol conformance;
132
+ `npm test` runs `git diff --exit-code` against them so any drift fails CI.
133
+
134
+ ### Invariants preserved
135
+
136
+ - Daemon code unchanged. No new dependencies. No `bin` field changes.
137
+ - Existing CLI subcommands (`allow`, `inject`, `list`, `tui`, `daemon`, …)
138
+ unchanged.
139
+ - Cross-host inject path (0.3.4) unchanged.
140
+
141
+ ## [0.3.4] — 2026-05-05
142
+
143
+ ### Added — Cross-host inject (`<id>@<host>` syntax)
144
+
145
+ Enables `telepty inject <id>@<host> "msg"` to deliver to a remote daemon
146
+ without SSH wrapping, by resolving `<host>` against the peer registry and
147
+ issuing direct HTTP `POST /api/sessions/<id>/inject`. Closes the gap that
148
+ forced operators to either pre-shell into the host or pipe through SSH.
149
+
150
+ - **`connect-http` peer mode** (commit `a92cacc`) — new HTTP-only peer
151
+ registration path that does not require a reverse PTY tunnel; suitable
152
+ for daemons reachable via Tailscale / private DNS.
153
+ - **`TELEPTY_HOST` env parser fix** (commit `a92cacc`) — `<id>@<host>` now
154
+ parses correctly when the host segment contains a port or non-default
155
+ scheme; prior parser dropped the host portion silently.
156
+ - **Peer registry HTTP-only mode** — registry entries can be marked
157
+ HTTP-only so the daemon does not attempt PTY fan-out for them.
158
+
159
+ ### Added — Skill installer auto-detect (`486bc1e`)
160
+
161
+ `telepty install` now auto-detects which AI CLIs are present
162
+ (`claude`, `codex`, `gemini`) and only installs the corresponding skill
163
+ files. Reduces noisy "skipped" log lines and prevents stub installs
164
+ on machines that don't have the target CLI yet.
165
+
166
+ ### Fixed — Node 18 ESM regression (`fc7ff9a`)
167
+
168
+ Pinned `uuid@9` (was floating to v10, which is ESM-only and caused
169
+ `ERR_REQUIRE_ESM` under Node 18 CommonJS consumers).
170
+
171
+ ### Docs
172
+
173
+ - Cross-host inject `<id>@<host>` syntax documented (commit `c8b9bbb`).
174
+ - `[context-ref]` inject protocol standardized across docs (commit `8986a96`).
175
+ - REPORT pattern + orchestrator-id runtime resolution documented in skills
176
+ (commit `658f712`).
177
+ - Korean trigger keywords added to skill `SKILL.md` descriptions for
178
+ cross-locale activation (commit `57f46e1`).
179
+
180
+ ### Note — never published to npm
181
+
182
+ `0.3.4` was version-bumped locally but never reached the registry; this
183
+ entry is added retrospectively alongside the `0.3.5` publish so the
184
+ changelog history matches the git log. Registry consumers go directly
185
+ from `0.3.3` → `0.3.5`.
186
+
5
187
  ## [0.3.3] — 2026-05-02
6
188
 
7
189
  ### Added — `inject --submit-force` + idempotent client retry (spec: `docs/superpowers/specs/2026-05-02-submit-force-and-retry.md`)
package/README.md CHANGED
@@ -72,13 +72,31 @@ telepty broadcast "status report"
72
72
 
73
73
  telepty auto-discovers sessions across your Tailnet. All commands (`list`, `attach`, `inject`, `rename`, `multicast`, `broadcast`) work seamlessly across machines.
74
74
 
75
- When the same session ID exists on multiple hosts, disambiguate with `session_id@host`:
75
+ ### `<id>@<host>` syntax
76
+
77
+ To target a specific host (when the same session ID exists on multiple hosts,
78
+ or when there is no Tailnet auto-discovery), append `@<host>` to the session
79
+ ID. `<host>` can be a hostname, LAN IP, or Tailnet name.
76
80
 
77
81
  ```bash
82
+ # Hostname / Tailnet name
78
83
  telepty inject my-session@macbook "hello"
79
84
  telepty attach worker@server-01
85
+
86
+ # LAN IP — useful when no Tailnet is configured
87
+ telepty inject orchestrator-claude@172.28.4.165 "ping"
88
+ telepty read-screen build-runner@10.0.0.42 --lines 50
80
89
  ```
81
90
 
91
+ **Requirements**:
92
+ - The remote daemon must be reachable on port **3848** from the calling host
93
+ (LAN routing, firewall rules, or Tailscale).
94
+ - No SSH or `sshd` is required on either side — the call hits the remote
95
+ daemon's HTTP API directly. This is the recommended path for laptop
96
+ daemons that don't run sshd.
97
+ - The `@<host>` qualifier works for `inject`, `attach`, `read-screen`,
98
+ `enter`, `multicast`, and `rename`.
99
+
82
100
  ## How It Works
83
101
 
84
102
  ```
@@ -92,6 +110,54 @@ CLI (telepty) ──> HTTP/WS ──> Daemon (:3848)
92
110
  - **`inject`** delivers text via the fastest available path: kitty terminal API, WebSocket, or UDS (Unix Domain Socket for embedded integrations)
93
111
  - **`submit`** is handled separately from text injection for reliability across all AI CLIs
94
112
 
113
+ ## `[context-ref]` Protocol — long payloads via shared file
114
+
115
+ When a sender uses `telepty inject --ref <file> <target> "<message>"`, telepty
116
+ stores the payload in a shared file under `~/.telepty/shared/<sha256>.md` and
117
+ injects only a short pointer prompt of the form:
118
+
119
+ ```
120
+ [context-ref] Read ~/.telepty/shared/<sha256>.md and use it as the source of truth for this task.
121
+ <inline message>
122
+ ```
123
+
124
+ This avoids prompt rot in the receiving session (and in the orchestrator's
125
+ window when the reply is small).
126
+
127
+ ### Receiver contract
128
+
129
+ The receiving AI session is expected to:
130
+ 1. Detect the `[context-ref]` prefix on the first line.
131
+ 2. Read the file at the absolute path.
132
+ 3. Treat the file contents as the **authoritative payload** for the task — the
133
+ inline message is supplementary (topic / hint), not the source of truth.
134
+
135
+ ### Storage location
136
+
137
+ - File path: `~/.telepty/shared/<sha256>.md` (sha256 of payload body)
138
+ - Created with mode `0600`; readable only by the local user
139
+ - Persists across sessions; not garbage-collected automatically (run
140
+ `telepty clean --shared` to prune)
141
+
142
+ ### When to use `--ref`
143
+
144
+ - Payload exceeds ~1KB or contains structured content (code, logs, tables).
145
+ - You want the receiver to load the payload deterministically rather than
146
+ paraphrase it from the inject prompt.
147
+ - You're orchestrating a multi-hop conversation where the orchestrator should
148
+ not see the full payload in its own context window.
149
+
150
+ ### Integration scope
151
+
152
+ Per-agent receiver integrations (auto-loading the file via Claude Code
153
+ `UserPromptSubmit` hooks, Codex `AGENTS.md` directives, etc.) are **out of
154
+ scope for telepty core** — they live in the agent's own configuration.
155
+ Per-CLI hook installation lives in devkit: run `aigentry scaffold
156
+ install-hooks {claude|codex|gemini}` after installing
157
+ `@dmsdc-ai/aigentry-devkit`. (Older drafts proposed a receiver-side
158
+ `telepty install` subcommand for this; that direction is rejected per ADR
159
+ 2026-05-05-telepty-devkit-boundary §3.1.2 / §3.4 row 2.)
160
+
95
161
  ## Inject Delivery Paths
96
162
 
97
163
  | Priority | Method | When |