diff --git a/internal/author/install.go b/internal/author/install.go index bd5ee9e7..4e6b545c 100644 --- a/internal/author/install.go +++ b/internal/author/install.go @@ -10,7 +10,7 @@ import ( "path/filepath" ) -var skillFiles = []string{"SKILL.md", "references/orchestration.md", "references/work.md", "references/queue.md", "references/debugging.md", "references/delivery.md", "references/format.md", "references/notifications.md", "references/operations.md", "references/transfer.md", "references/verification.md", "references/control.md", "references/harnesses.md", "references/access.md", "references/schedules.md", "references/practices.md"} +var skillFiles = []string{"SKILL.md", "references/orchestration.md", "references/work.md", "references/queue.md", "references/debugging.md", "references/delivery.md", "references/format.md", "references/notifications.md", "references/operations.md", "references/transfer.md", "references/verification.md", "references/control.md", "references/harnesses.md", "references/access.md", "references/schedules.md", "references/practices.md", "references/chat.md"} func SkillDirectory() (string, error) { dir := os.Getenv("XDG_CONFIG_HOME") diff --git a/internal/author/skill/SKILL.md b/internal/author/skill/SKILL.md index 9eaf5027..6d9d975e 100644 --- a/internal/author/skill/SKILL.md +++ b/internal/author/skill/SKILL.md @@ -21,11 +21,16 @@ background command (one per run, or one loop over several ids) so the session is notified the moment the run ends, then read its result with `pipelines inspect --json` and act on it: land, retry, or fix and report. Do not poll with repeated `pipelines runs` calls, and do not tell the user a run -is done, or will be reported, without a wait covering it. +is done, or will be reported, without a wait covering it. `wait` keeps blocking +while a run is `waiting` on a human stage (`pipelines decide`, user's choice only). -A failed run keeps its worktree and commits. Read `pipelines inspect --json` -before deciding: resume the failed stage (`pipelines retry `), fix directly, -or continue from the preserved branch. +A run started from a repository's main checkout runs in its own worktree +(`-runs/...`, branch `pipelines/run-...`); a failed run keeps that tree and +its commits. Read `pipelines inspect --json` before deciding: resume the +failed stage (`pipelines retry `; `--stage`/`--visit`, `--input-file`, +`--mode=restart` from entry), fix directly, or continue from the preserved +branch. Only `failed` runs can be retried; `interrupted` (server stopped +mid-run) and `canceled` runs need a new run or direct work on their branch. ## Use an existing pipeline @@ -64,6 +69,18 @@ Claude-only, allowlisted MCP access. Prefer read-only tools; unattended stages deny every MCP tool not listed. The name is the Claude Code display name (mapped internally to `mcp____`). +The server keeps a versioned skill library: `pipelines skills list`, `skills show +NAME [--version N]`, and `skills import FOLDER` (root `SKILL.md` with +`name`/`description` frontmatter plus `references/`, `scripts/`, `assets/`; import +only when asked). Stage use: `references/format.md`. + +## In a Pipelines chat + +A chat's agent has a `pipelines` MCP server: `show_file`, `show_image`, +`show_html`, `show_diff` (show the operator changes, e.g. before a pull request) +and `notify` (phone, only when the operator must look now). Show instead of +telling the operator a path. Details, limits, chat RPCs: `references/chat.md`. + ## References Read only what the task needs. Rows marked operator only are for setting up or @@ -79,6 +96,7 @@ debugging the server; skip them when authoring. | Failures | `references/debugging.md` | | Delivery and installation | `references/delivery.md` | | Notifications | `references/notifications.md` | +| Chat tools, sent references, questions, chat RPCs | `references/chat.md` | | Saved run schedules (never in a definition) | `references/schedules.md` | | Transfer and versions | `references/transfer.md` | | Queue and work items | `references/work.md`, `references/queue.md` | diff --git a/internal/author/skill/references/access.md b/internal/author/skill/references/access.md index 7197e2d9..b181d874 100644 --- a/internal/author/skill/references/access.md +++ b/internal/author/skill/references/access.md @@ -1,26 +1,32 @@ # Hosting, access and deployment -The browser client is `web/serve.mjs`: static files plus a `/connect` WebSocket -proxy and `/artifacts/` proxy to the Pipelines server. Plain `node serve.mjs` is -enough for local work. +The front door is `web/serve.mjs`: sign-in, the Flutter web app built from +`app/`, and a same-origin proxy to the Pipelines server for `/connect`, +`/files`, `/artifacts/` and `/chat-uploads`; it also serves app updates at +`/updates/`. The native apps go through it too. ## Password gate `serve.mjs` refuses pages, assets, artifacts and `/connect` without a signed session cookie. The password and signing secret live outside the repository: -`~/.config/pipelines/web-auth.json` (mode `600`), e.g. - -```json -{ "password": "…", "secret": "…" } -``` +`~/.config/pipelines/web-auth.json` (mode `600`, `PIPELINES_WEB_AUTH_FILE`) +holds an scrypt `password_hash`, the cookie `secret` and a `generation`; a +plaintext `password` written there is hashed on load and signs everyone out. The sign-in page is `/login`; **Remember me** keeps a 30-day cookie, otherwise the cookie lives until the browser closes. Wrong passwords are throttled. Tests that start their own `serve.mjs` set `PIPELINES_WEB_AUTH=disabled`; never put that in a service. -Changing the password: edit the file, then restart the web service. +Change the password with `./password` from the source checkout (signs every +device out; `--revoke-all` keeps the password); Settings → Sign-in security → +Sign out everywhere revokes sessions without a restart. + +The proxy reaches the server with `X-Pipelines-Token` from the private +`~/.config/pipelines/server-token` (`PIPELINES_SERVER_TOKEN_FILE`), which the +installer creates; local CLI calls and server-launched stages and chats read +the same file. It is separate from the web password. ## Bind and exposure diff --git a/internal/author/skill/references/chat.md b/internal/author/skill/references/chat.md new file mode 100644 index 00000000..bbff00f7 --- /dev/null +++ b/internal/author/skill/references/chat.md @@ -0,0 +1,56 @@ +# Working in a Pipelines chat + +A Pipelines chat runs on OpenCode, Claude Code or Codex. The operator reads it in +the Pipelines app (desktop, web or phone), often not at this machine's terminal. + +## Pipelines tools (`pipelines` MCP server) + +Each call adds a persisted item to the transcript and returns one short line; a +refusal comes back as an error with the reason. Paths must resolve inside the +operator's home (absolute, `~/...`, or relative to the chat's directory). + +| Tool | Arguments | Use for | +| --- | --- | --- | +| `show_file` | `path`, `title?` | Any file the operator should see: images inline, other files as a preview card. Use instead of naming a path. | +| `show_image` | `url_or_path`, `title?`, `alt?` | A home `image/*` file or an `https://` URL (no credentials, at most 2048 chars). | +| `show_html` | `html`, `title?`, `height_hint?` (120-600) | Self-contained HTML/SVG: diagrams, charts, tables. Sandboxed: no JavaScript, no network; inline CSS/SVG, `
`, `:hover`. Refused above 512 KiB. | +| `show_diff` | `path?`, `base?`, `committed_only?`, `title?` | A Git diff card when the operator asks to see the changes, or before submitting a pull request. No `base`: uncommitted work (staged, unstaged, untracked) against HEAD. `base` (e.g. `main`): everything since the merge base, which is what a PR contains, plus uncommitted work unless `committed_only`. Pipelines runs Git; do not paste the diff. | +| `notify` | `title`, `message`, `priority?` | A phone push that opens this chat. Only when the operator must look now (long task done, blocked on them). 5 per minute per chat; undelivered sends report why. | + +`show_diff` lists at most 300 files; a file patch over 256 KiB or a total over +1 MiB is shown partially and says so; binaries have no patch; renames show as +delete plus add. `base` is a plain revision name. Tools are absent when the +harness could not register them (logged); then name paths instead. + +## References sent into the chat + +The operator can send a run, a pipeline or a run artifact to a chat. It arrives +in the composer draft as text naming the run id, title, pipeline/version and, +for an artifact, stage, visit and a readable URL. Treat it as a pointer: read +`pipelines inspect RUN_ID --json` (or `pipelines show NAME --version N`) for the +authoritative record before acting. + +## Questions and approvals + +Claude Code questions appear as a form. The operator may pick an option, answer +in their own words, or dismiss it; a dismissal arrives as a denial saying they +will reply in the chat, so wait for that message. Question text, descriptions +and option descriptions render Markdown. + +## Chat protocol (via `pipelines rpc -`) + +Only when the user asks to drive another chat. Envelopes carry `type` and `id`: + +- `chat_sessions`: the operator's chats (`id`, `directory`, `title`, `backend`). +- `chat_prompt` with `chat_prompt: {session_id, text, send_at?}`: sends a + prompt (at most 64 KiB). A busy chat queues it durably, in order, across + restarts. `send_at` (epoch milliseconds, future) holds it until that time; + prompts queued after it wait behind it. +- `chat_unqueue` with `chat_unqueue: {session_id, operation_id}` removes a + prompt not yet delivered. +- `chat_interrupt` with `chat_query: {session_id}` stops the current turn; + `chat_stop_tasks` (same body) stops background tasks without interrupting it. + +Chat sessions are separate from pipeline run sessions; `pipelines chat-adopt +SESSION_ID [--harness opencode|claude|codex]` brings an existing harness session +into the chat list. Do not keep using an adopted session elsewhere. diff --git a/internal/author/skill/references/debugging.md b/internal/author/skill/references/debugging.md index 8bb8cd49..eadff6ad 100644 --- a/internal/author/skill/references/debugging.md +++ b/internal/author/skill/references/debugging.md @@ -10,10 +10,12 @@ 4. Verify the repair with a focused regression; run broader checks once relevant inputs settle. Do not raise retry/time budgets to hide a reproducible defect. -Use `pipelines help retry` to discover the installed options. When supported, -select a recorded stage/visit, bounded input correction and explicit compatible -version of the same pipeline. Verify actual retained stage input, not merely -successful admission. Do not silently restart from entry. +`pipelines retry ID` resumes the failed stage; `--stage KEY [--visit N]` picks a +recorded stage, `--input-file FILE|-` merges a bounded JSON correction, +`--version N` a published version of the same pipeline, `--mode=restart` starts +at entry (say so). Only `failed` runs retry; an `interrupted` run (server stopped +mid-stage) or a `canceled` one needs a new run or direct work on its preserved +branch. Verify the retry's actual stage input, not merely its admission. A clean preparation stage succeeds without an empty commit. A `land` stage with a delivery gate succeeds with a clean checked candidate; the server lands afterward. diff --git a/internal/author/skill/references/operations.md b/internal/author/skill/references/operations.md index 4599adb7..f9330feb 100644 --- a/internal/author/skill/references/operations.md +++ b/internal/author/skill/references/operations.md @@ -1,9 +1,10 @@ # System, storage and run evidence Pipelines turns a reusable process into sequential stages with explicit handoffs, -outcome routing and retained evidence. A Go CLI/TUI connects to an execution server; -the server owns execution and SQLite history, OpenCode owns model/tool sessions, -and optional ntfy delivery supplies notifications. It is technology-neutral, not a +outcome routing and retained evidence. A Go CLI/TUI and the Pipelines app connect +to an execution server; the server owns execution and SQLite history, the stage's +harness (OpenCode, Claude Code or Pi) owns model/tool sessions, operator chats +run on OpenCode, Claude Code or Codex, and optional ntfy delivers notifications. It is technology-neutral, not a parallel/distributed task engine or a guarantee that model reports are correct. ## Lifecycle and location @@ -16,12 +17,14 @@ brand-new database is seeded with them an editable prefilled name or customized first. Editing a bundled repository template changes no installed or published definition; only explicit authoring then submission creates a new immutable version. -- Retire an unused pipeline with `pipelines archive NAME --yes` (no deletion exists): +- Retire an unused pipeline with `pipelines archive NAME --yes` (pipelines cannot be deleted): it leaves lists and cannot run, its history stays, its name stays reserved, and enabled schedules must be paused first; `unarchive` and `list --archived` undo/show it. - A run pins its exact definition version, initial input and resolved directory. - The client invocation directory is the default, but files/tools execute on the - server. Docker needs that directory mounted at the same absolute path. A remote + The client invocation directory is the default (`--workspace`), but files/tools + execute on the server. From a repository's main checkout the run gets its own + worktree and branch (`references/format.md`, Run worktrees); a linked worktree + and every retry use their directory as is. Docker needs that directory mounted at the same absolute path. A remote client does not upload its repository or make host credentials available remotely. - Host and Docker OpenCode credentials are separate. Preserve setup-selected model inheritance; do not select a provider just because its ID appears in an example. @@ -35,12 +38,14 @@ brand-new database is seeded with them owning active run is an orphan and still refuses new work until interrupted. Reusing that active run's request key reattaches idempotently. `type=human` decision stages exist and pause the run (see `references/format.md`); - there are no parallel branches. Optional worktrees, full backup/restore, + there are no parallel branches. Full backup/restore, automatic database sync and independent verifier stage types are future ideas, not existing capabilities. Do not invent them in definitions. - Services are native or Docker-based. With an existing Docker installation do not - start a competing native server. Server APIs are unauthenticated: trusted networks - only; never recommend public exposure. Tool scope is not a universal OS sandbox. + start a competing native server. The server API has no login: it accepts only + loopback Host/no-Origin requests plus, when configured, the private + `server-token` file's header; expose only the authenticated web proxy + (`references/access.md`), never the server itself. Tool scope is not a universal OS sandbox. ## Where data lives @@ -63,7 +68,9 @@ Use the authoritative `CLI_PREFIX` from the prompt: text, a bare status word (`queued`/`running`/`succeeded`/`failed`/`canceled`/ `interrupted`) selecting those runs, or a lone date expression (`today`, `yesterday`, `this week` — Monday 00:00 local — or `YYYY-MM-DD`) selecting the - runs created in that window; anything else stays free text. `--type` is the only + runs created in that window; anything else stays free text. Runner-internal + files (`input.md`, `memory.md`, `history.md`, `output.md`, `session.html`, + `private/`) match only with `--debug-files`. `--type` is the only narrowing mechanism and takes one of `pipeline`, `version`, `run`, `step`, `field`, `artifact`; an unknown kind is an error. Ranking is exact name (3) > name substring (2) > body text (1), equal tiers by recency, and every hit @@ -217,31 +224,27 @@ landed. ### Session export -- When an OpenCode-harness model stage finishes, the server exports its real - session read-only (v1 `opencode export `, v2 `opencode session export `) - and writes exactly one file, `session.html`, into the same turn artifacts - directory; it lists and serves like any other artifact. -- The `session.md` export is retired: nothing writes it any more and it is never - presented. A run recorded before the HTML-only change still lists `session.md` - among its stored artifacts (dated evidence kept on disk, not deleted); every - listing — app, TUI, web spike — hides it rather than showing it beside the html. -- The source read is capped at 8 MiB and the rendered file at 8 MiB, matching the - ordinary per-artifact file bound; a cut source or a cut rendered file carries a - visible truncation banner at both ends and `session_export.truncated: true`, and - a truncated export is never called whole. -- The step records `session_export` (`session_id`, `backend`, `source`, the html - file name, `html_bytes`, `messages`, `truncated`, `diagnostic`) in - `inspect RUN_ID --json`. A record written before the change still carried - `markdown` and `markdown_bytes`; readers ignore those fields. -- A failed export, or a Pi stage with no native export path, records a diagnostic - (Pi: `source: "unavailable"`) and never fails the run or changes the stage result. - An existing `session.html` is never overwritten. +- When a model stage finishes, the server exports its real harness session + (OpenCode, Claude or Pi) read-only into one `session.html` in the turn artifacts + directory; it lists and serves like any other artifact. Older runs may still + list a retired `session.md`, which clients hide. +- Source and rendered file are capped at 8 MiB each; a cut export carries a + visible banner and `session_export.truncated: true` and is never called whole. +- The step records `session_export` (`session_id`, `backend`, `source`, html file + name, `html_bytes`, `messages`, `truncated`, `diagnostic`) in `inspect --json`. + Incomplete exports retry automatically up to three times after the run settles + (`session_export_recovery`); `pipelines repair-session-export RUN_ID SEQUENCE` + writes a versioned repair file without replacing originals. +- A failed or empty export records a diagnostic and never fails the run or + changes the stage result. An existing `session.html` is never overwritten. ### Operator-only retention -Run history and its artifacts are never pruned automatically. The operator-only -`pipelines retention report` (strictly read-only) and `pipelines retention apply` -(removal after explicit approval) are the only commands that remove them; no +Run history and its artifacts are never pruned automatically. Only explicit +commands remove them: `pipelines runs rm ID...` (finished runs, after +confirmation; active runs and runs an unfinished retry depends on are refused) and +the operator-only `pipelines retention report` (strictly read-only) and +`pipelines retention apply` (removal after explicit approval); no server startup, scheduler, `list_runs`, `stats`, `runs` or `inspect` path calls retention, and there is no background goroutine, timer or startup hook. A policy selects by rolling UTC age (`--older-than`), newest-N count (`--keep`), or their @@ -264,8 +267,13 @@ assistant message with the same bounded readback as the final result, so a small final result is visible behind large prior tool content. Inspect the retained session itself when a preview is bounded or omitted; never assume a complete tool history from a preview. -Retry is allowed for a failed run after cleanup stops: a fresh run/session starts -at entry with the original input/directory/pinned version/edit scope. Previous +Retry is allowed only for a `failed` run after cleanup stops (`interrupted` and +`canceled` runs need a new run). It creates a new linked run with the original +input, directory, pinned version, edit scope and overrides. The default `resume` +mode restarts the failed stage (or `--stage`/`--visit`) with the completed +prefix's handoff and `public/` files; `--mode=restart` starts at entry; +`--input-file` merges a bounded JSON correction into the selected stage's input; +`--version N` picks another published version of the same pipeline. Previous side effects remain and can happen again. Never describe retry or cancellation as rollback, or resume/replay admitted tool work just to recover formatting.