@pipemd-core/pipemd 1.0.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to PipeMD.
4
4
 
5
+ ## [1.1.0] — 2026-05-23
6
+
7
+ ### Added
8
+
9
+ - **`pmd link` — Cross-machine crew federation** — connects PipeMD daemons across machines and Docker containers so crew sessions (agent coordination data) are shared in real time
10
+ - `pmd-linkd` relay server — one per machine, aggregates crew sessions from all local daemons, syncs with remote relays
11
+ - `POST /crew` endpoint — daemons push local sessions, receive merged remote sessions for their group
12
+ - `POST /sync` endpoint — relay-to-relay bidirectional sync of all groups, bearer token auth
13
+ - `GET /status` endpoint — monitoring: group counts, peer connection status
14
+ - `GET /health` endpoint — liveness check
15
+ - Named groups — coordination scopes that route sessions to the right project daemon (default: repo directory name, configurable via `link.group` or `PMD_GROUP` env var)
16
+ - Daemon relay client — embedded in each daemon, auto-starts when `PMD_RELAY` or `link.relay` is configured
17
+ - Remote session merge — `listSessions()` returns local + remote sessions; `renderCrewBlock()` tags remote agents with `· remote: <hostname>`
18
+ - Cross-machine conflict detection — `findConflicts()` detects file claim conflicts across machines
19
+ - Session expiry — remote sessions not refreshed within 15s are evicted from the relay's in-memory store
20
+ - Docker support — container daemons connect to relay via `PMD_RELAY=http://relay:9741` (Docker DNS)
21
+ - Zero new dependencies — pure Node.js `http` module
22
+
23
+ ### Test Suite
24
+
25
+ - 121 assertions, 0 failures across 10 suites
26
+ - `test:unit` (19) — reverseInject + link relay unit tests
27
+ - `test:link` (17) — relay lifecycle, cross-origin exchange, group isolation, conflict detection, token auth
28
+ - All existing suites unchanged: e2e (36), bidir (27), arch (63), compose (17), crew (92), scripts (79), inject (47)
29
+
5
30
  ## [1.0.0] — 2026-05-21
6
31
 
7
32
  ### Added
@@ -0,0 +1,73 @@
1
+ # Contributing to PipeMD
2
+
3
+ PipeMD is strict TypeScript, **ESM-only** (imports use `.js` extensions, `NodeNext` resolution), built with `tsup`, and targets Node.js 18+.
4
+
5
+ ## Build & Test
6
+
7
+ ```bash
8
+ pnpm install
9
+ pnpm build # Production build → dist/
10
+ pnpm dev # Watch mode — rebuilds on change
11
+ tsc --noEmit # Type-check only
12
+
13
+ pnpm test # Full suite: unit → e2e → bidir → scripts → arch → compose → crew
14
+ pnpm test:unit # reverseInject logic (pure Node, no build needed)
15
+ pnpm test:crew # Crew coordination lifecycle (needs build)
16
+ ```
17
+
18
+ There is no test framework: unit tests use `node:assert`, e2e tests are Bash scripts with custom assertion helpers in `tests/`.
19
+
20
+ ## Source Layout
21
+
22
+ ```
23
+ src/
24
+ ├── index.ts # CLI entry — Commander program, registers all commands
25
+ ├── config.ts # PipeConfig type + DEFAULT_CONFIG
26
+ ├── commands/ # One file per command: init, start, stop, restart,
27
+ │ # status, run, refresh, doctor, uninstall, crew
28
+ └── core/
29
+ ├── daemon.ts # Daemon loop — pipe mode (mkfifo) + legacy mode (chokidar)
30
+ ├── injector.ts # Renders <!-- pmd: --> blocks; reverseInject write-back
31
+ ├── cache.ts # Per-source render cache with TTL + invalidation
32
+ ├── injection-types.ts # Injection config schema, types, defaults
33
+ ├── injection-engine.ts # Rules engine — resolves sources, dedup, truncation
34
+ ├── dedup.ts # Per-session dedup — skips unchanged content
35
+ ├── detect.ts # Ecosystem auto-detection (Node, Python, Rust, …)
36
+ ├── detectHarness.ts # AI-harness detection (Claude Code, OpenCode, …)
37
+ ├── crew.ts # Crew ledger, conflict detection, block rendering
38
+ ├── hooks.ts # Per-harness hook installers (crew + injection)
39
+ ├── actions.ts # start/stop/cleanup logic
40
+ └── logger.ts # File logger → .pipemd/daemon.log
41
+
42
+ scripts/ # Bundled Bash library, by ecosystem & category
43
+ templates/ # Per-ecosystem Markdown templates
44
+ tests/ # e2e-*.sh suites + test-reverse-inject.mjs + fixtures/
45
+ ```
46
+
47
+ ## The Render Pipeline
48
+
49
+ 1. `daemon.ts` reads `.pipemd/template.md` and finds `<!-- pmd: name -->` tags.
50
+ 2. `injector.ts` runs each tag's command (from `config.commands`) concurrently via `Promise.allSettled`, with a 10s timeout per command.
51
+ 3. Rendered blocks replace the tags; `base.md` is prepended with the `<!-- pmd-context -->` separator.
52
+ 4. The composed Markdown is served on the named pipe (or written in legacy mode) to every harness's context file.
53
+ 5. AI edits flow back: `reverseInject` de-renders `pmd` blocks and persists edits to `base.md` / `template.md`.
54
+
55
+ ## Smart Injection Pipeline (Active/Expert Mode)
56
+
57
+ 1. Harness hook fires (e.g., Claude Code `PreToolUse:Edit` on `src/foo.ts`)
58
+ 2. Hook calls `pmd inject --trigger before-edit --file src/foo.ts`
59
+ 3. Injection engine loads rules from `injection.yml`
60
+ 4. For each matching rule, runs the source resolver (crew-locks, file-errors, git-context…)
61
+ 5. Each resolver reads from the render cache (sub-5ms)
62
+ 6. Dedup layer checks: skip if content unchanged since last injection
63
+ 7. Payloads printed to stdout → agent sees them as hook output
64
+ 8. For after-edit triggers: async validation (eslint + tsc) runs in background, cached for next call
65
+
66
+ ## Safety & Edge Cases
67
+
68
+ - **10-Second Timeouts:** No runaway commands hanging the AI. Stalled scripts get killed.
69
+ - **Isolated Rendering:** Built on `Promise.allSettled`. A failing script renders an error in-place; the rest of the document loads fine.
70
+ - **EPIPE Catching:** If an agent closes the stream mid-read, PipeMD catches the disconnect without crashing.
71
+ - **Stale PID Recovery:** `pmd start` detects dead processes, cleans up old pipes, and starts fresh.
72
+
73
+ PRs welcome. See `CLAUDE.md` for conventions and gotchas.