Repository navigation
feat: prompt presets and permissions - #160
Merged
Merged
Conversation
moshloop
enabled auto-merge (rebase)
November 10, 2026 10:27
|
Important Review skippedToo many files! This PR contains 591 files, which is 491 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files.
|
Gavel summary
Totals: 0 passed · 0 failed · 0 skipped · - |
Claude-Session-Id: 01a15cb6-ff42-75a0-8c3a-712b63716008
Gavel-Issue-Id: 9723fa02-92e0-4ae0-ae6f-1815602e2cba Claude-Session-Id: 01a15ea7-403c-7d71-854f-08688a7af676
Claude-Session-Id: 01a15e89-a154-70d0-beff-58fa5d2ba7b1
Claude-Session-Id: 01a161f3-946a-7f80-8de1-6443c175cde5
Add the Captain Formation brand kit: horizontal, stacked, symbol, and wordmark masters, dark and one-colour variants, a small-size drawing, and web and social icons. Lettering is outlined vector geometry, so no font installation is required. Web handover files are provided for manual integration; application code is unchanged. PNG exports follow the existing *.png ignore rule. Trademark clearance and print approval remain outstanding.
… review prompts Presets gain an integer order (default 0) that sorts layers ahead of scope precedence, so the Lint preset can apply after prompt and request layers. The Lint preset replaces output schemas with a violations contract that gavel lint prompt renders as lint results. Five read-only document review prompts ship in pkg/ai/prompt/builtin, and local prompts with the same name shadow them. Adds permissions explain and permissions convert commands. JSON/YAML null on schema fields now clears them explicitly. With saved defaults, a missing token budget stays unset so the runtime applies its own default.
Add a portable access level (--access read-only|full, permissions.access) that compiles per runtime into native posture: tool denies on claude, a read-only sandbox that never asks on codex, and plan mode on gemini. Add `captain permissions explain` to show the compiled posture per runtime, and `captain permissions convert` to rewrite a permissions block into the portable form, refusing any conversion that would loosen access. Ship the document review prompts as a read-only built-in source. A user copy in the config prompts directory shadows a built-in of the same name instead of making the name ambiguous. Expose --preset, --no-presets, --runtime-profile and --vars on prompt commands, and route prompt runs through a shared PromptInvocation so the CLI and HTTP paths resolve prompts the same way. BREAKING CHANGE: an unset max-tokens no longer defaults to a built-in 4096. It is left to the runtime's own default (0 = runtime default), so output length can change for prompts with no saved or frontmatter value.
Ship reviewer prompts that Captain resolves by name through the new prompt.Builtin embed FS, so users can lint internal and public high-level and low-level specs and RFP proposals without copying prompt files into their repositories. Each prompt is read-only, runs with a 30-turn budget, and reports violations against a fixed rule catalog. Shared rule ids (req/, doc/) keep findings consistent across document types, and audience-specific ids cover internal and public concerns.
Authors can state read-only workspace access once with permissions.access. CompileAccess lowers it to each runtime's native dialect: per-tool denies on claude, a read-only sandbox with approval never on codex, and the plan approval mode on gemini. Layers resolve in order through ResolveAccessState, so a later layer can lift a read-only intent to full. A runtime that cannot reach the posture is refused rather than silently loosened, for example codex with the sandbox off or looser raw cmux flags. Fallback candidates are compiled and validated as they will run, so an unreachable fallback fails before the primary does. ConvertToAccess rewrites dialect-specific denies or sandboxes into the portable form only when the result is equivalent or tighter. Fallback substitution keeps the original runtime before crossing providers, so an agent is not moved to API mode and left without its tools. SpecLayer gains an Order field that sorts before scope. The YAML marshaller no longer re-emits raw opaque fields. BREAKING CHANGE: saved-spec resolution no longer defaults budget.maxTokens to 4096. The runtime now chooses the value, so callers that relied on 4096 must set it explicitly.
… worktree workspaces Wrap every provider candidate, primary and fallbacks, in an access decorator so permissions.access read-only is compiled for the runtime that candidate actually runs on. A fallback in another family now receives its own dialect instead of the primary's. Explicitly supplied directories that are linked worktrees are recorded in the run workspace before the first turn, so active runs show their workspace while running. Detached HEAD is recorded as no branch. Active runs started before this change are reconciled without altering their execution state. Runtime presets gain a sort_order column and a Lint built-in preset is added. Config home resolution moves to captainconfig.Home.
Codex execpolicy rules run matching commands outside the sandbox, even under a read-only sandbox with approval never. A user rule such as prefix_rule(["git","add"], decision="allow") could let a read-only run write the git index. `codex exec` can skip rules with --ignore-rules, but the app-server and TUI cannot. Read-only runs for those modes now start in a captain-managed CODEX_HOME under captain's config directory. It links only auth.json, config.toml and AGENTS.md from the user's home, so it carries no rules. Runs refuse a project .codex/rules layer that allows commands, because the isolated home cannot hide project rules. Session discovery now also scans the isolated home so its rollouts remain visible. BREAKING CHANGE: read-only runs fail when project execpolicy rules allow commands, and when the isolated home contains a rules directory.
…to the run's thread Execpolicy allow rules could run commands outside the sandbox even under read-only, so read-only runs now start in an isolated CODEX_HOME and pass --ignore-rules. A codex process cannot change CODEX_HOME, so a session refuses a turn that needs a different home. Notifications from sub-agent threads are dropped so they no longer replace the run's session id or end its turn.
…ead-only runs Claude's tool denies do not follow sub-agents, teams, peer messages, crons or worktrees the agent creates, so read-only runs could still write through them. Those tools are now denied, while read-only listing tools stay allowed. Codex execpolicy allow rules run commands outside the read-only sandbox. `codex exec` now passes --ignore-rules, and the app-server and cmux TUI start in an isolated CODEX_HOME without user rules. BREAKING CHANGE: read-only codex runs are refused when project rules in the tree allow a command, and read-only Claude runs lose the newly listed tools.
Append the prompt source search paths to human-readable output of prompt list, so users can see where prompts are loaded from. JSON, YAML, and file exports are unchanged. Replace the shared help for prompt subcommands with command-specific help that includes descriptions, examples, and usage. The root prompt help gains a Help and output section covering color, NO_COLOR, --json, and agent-session Markdown. The help text now states that permissions.tools 'ask' is not enforced by native tool filters and that per-call approval goes through the broker. The sample prompt's Edit tool policy changes from ask to allow to match this.
Read-only codex runs write rollouts under captain's isolated CODEX_HOME, which the monitor did not watch or accept, so those transcripts were never ingested. Watch day directories and resolve threads across both codex session roots. Accept transcript paths under any provider root, and validate ingest paths against all of them.
Bring the docs site in line with the current prompt runtime and CLI. - Add a Prompt CLI page covering discovery, authoring, render/run/observe, and help and color behavior. - Document portable permissions.access (read-only/full), how it compiles per runtime, and the codex execpolicy handling. - Replace runtimeProfile with presets and --preset, and add the Lint built-in preset. - Update approvals for the broker's OnRunState hook and Deadline, and the read-only escalation rules. - Add reference pages for Sandboxes, Configuration, Serve, Sessions, and Fixtures, and move them out of the placeholder section. - Rewrite the Gavel TODO docs around the PostgreSQL-backed lifecycle, durable plans, and fixture verification. - Correct the prompt API path to /api/v1/prompt and the prompt schema examples to typed variables and model/mode fields. BREAKING CHANGE: runtimeProfile and --runtime-profile are deprecated and ignored; use presets in frontmatter or --preset instead.
Shorten the root README to an overview, quick start, prompt authoring, verification, and a command map. Detailed reference material (fixtures, sandbox credentials, git-agent deployment, whoami and configure details) moves to the docs site. Update the runtimeprofiles README to the preset model. RequestedProfile, PinnedProfile, DefaultProfile, the prompt runtimeProfile field and --runtime-profile are deprecated in favor of RequestedPresets, frontmatter presets and --preset. Mark the unified approval callback plans as historical design records that point to the current approvals guide. Fix the DeepSeek attachment example to pass the prompt with -p, matching the current CLI.
Move the promptfile lint command into the rootcmd package; main.go referenced a symbol from a sibling file, breaking the standalone entrypoint spec. Also discard the unused String() result flagged by go vet in the version spec.
… catalog Expose native provider configuration, reusable resource definitions and Captain portable and backend configuration alongside the execution schemas. Each catalog document gains a stable id and kind. Execution modes and existing URLs are unchanged. Add a stateless POST /api/captain/ai/adapter-schemas/validate endpoint. It compiles local references only and returns instancePath and schemaPath errors without resolving, executing or persisting anything. Generated OpenAI agent request types move to OpenAIAgentOptions* names, and union fields keep their JSON marshaling. Form annotations (help links, enum labels and icons, typed JSON editors) are generated from pinned sources by hack/adapterresources. BREAKING CHANGE: GET adapter-schemas now also returns resource documents. Clients must key on id and kind rather than assuming a provider/mode pair. Go types ThreadStart, ThreadResume and TurnStart are renamed to OpenAIAgentOptionsThreadStart, OpenAIAgentOptionsThreadResume and OpenAIAgentOptionsTurnStart. Claude-Session-Id: b00416a9-facd-49f8-9bc6-cd4ef7eba6b4
…w UI Add POST /api/captain/ai/adapter-schemas/validate to check a preview value against an embedded schema without executing or saving it. The schema page gains form, JSON, and YAML views with local drafts, resource search, and provenance links. Catalog entries now include id and kind, and mode is optional for portable resources. BREAKING CHANGE: unknown provider/mode routes under /adapter-schemas now show an error instead of falling back to the first schema. Claude-Session-Id: b00416a9-facd-49f8-9bc6-cd4ef7eba6b4
Prompts can now declare a `tools` mapping in frontmatter. Each tool runs its `exec` script with the tool input as JSON on stdin and returns stdout to the model, or parsed JSON when an output schema is set. Captain previously rejected dotprompt's list of registered tool names, so prompts had no way to ship their own tools. Scripts run through the commons-db shell runner and inherit the run's setup (dotenv, env vars, connections), with per-tool values layered on top. Timeouts kill the whole process group. Retry supports backoff and exit-code filters. The readonly and destructive hints set the default permission, and toolPolicy still governs tools by name. Inline tools are validated at parse and lint time: names, exec, hint conflicts, schemas, and a warning for retried destructive tools. Runs that would bypass the runner (chat launch, supplied providers) refuse them instead of silently dropping them. Also included: symlinked prompt directories in local sources, self-contained draft renders, and CLI completion for fallback models, presets, sandboxes, and permission modes. Claude-Session-Id: b00416a9-facd-49f8-9bc6-cd4ef7eba6b4
… launch API Chat turns (mode "chat") settle their runs without ending their sessions: the chat outlives a turn and awaits the next message, so migration 84 keeps its sessions running and idle between turns. The chat writes their terminal lifecycle itself when it ends (cancelled if stopped, failed on error, otherwise as its last run ended), so a follower can hold one stream open across turns. Add LaunchPrompt, AwaitPromptRun and StopPromptRun so Go callers can start an async prompt run, await its summary and stop it through the same broker the HTTP handler uses. PromptInvocation.Tools exposes caller tools to the agent on every runtime; runtimes that cannot expose them (CLI-only, chat, observe) are rejected instead of silently dropping them. Local prompt sources now resolve read-only symlinked prompt files and immediate linked directories, reporting broken links and cycles. Transcript messages are projected through the shared session.ConversationalMessages in ingestion, session read and live follow, so all three assign the same ids and a follow resumes after the read's newest message. BREAKING CHANGE: a chat's sessions no longer go terminal after each turn; they stay running and idle until the chat ends, so clients that treated a settled chat turn as session completion must wait for the chat's end. Claude-Session-Id: b00416a9-facd-49f8-9bc6-cd4ef7eba6b4
… SDK folds them into one result Previously a turn counted prompts and expected one SDK result per prompt. The SDK folds prompts steered mid-turn into the running turn and reports them together in user_message_uuids, so a single result can settle several prompts and the count never reached zero. Each prompt now carries a uuid and is tracked until a result names it. The turn ends on the idle that follows once every prompt it sent is settled. A steer the bridge rejects is withdrawn, so it cannot hold the turn open. An SDK query-loop error aborts the turn immediately. Bridge protocol is bumped to v5 (prompt uuid, consumed uuids on turn/completed). The logging middleware also logs rejected replies at debug level, since parse errors name only the first bad byte. Claude-Session-Id: b00416a9-facd-49f8-9bc6-cd4ef7eba6b4
…t rendering Document prompt lookup locations in root and prompt list help, and render unsaved drafts without a saved id. Linked prompts are now read-only: update, delete, and create-in-place refuse them and symlinked destinations. Caller tools are appended to every runtime variant, failing fast on runtimes that cannot expose them. `prompt run --vars` derives its schema from the prompt's input schema and defaults. BREAKING CHANGE: updating or deleting a prompt reached through a symlink now fails instead of writing through it. Claude-Session-Id: b00416a9-facd-49f8-9bc6-cd4ef7eba6b4
Add history.FindTranscripts, an mtime-filtered discovery over Claude and codex transcripts that stats files without opening them. Backfill now scans transcripts modified since 24h before the newest ingested one, with a full scan when nothing is ingested yet or the parser version changed, and runs the auto-review header read only on files within that window. Claude-Session-Id: 7bdc450f-69f4-481d-a1b9-591c3eee5f2b
…ive summary Prompt runs only exposed their session id in the run frame and log, so task views could not link a run to its session or show its state. Tasks and run-owning groups now carry a captain SessionRef with a summary folded from the run stream: model, context window, tool-call count and the latest part. A registered session source lets /tasks/stream relay a named session's entries and state without each client opening its own follow. PermissionCatalogHandler is exported so hosts can mount the catalog, and AIPromptOptions.Spec lets in-process callers layer a typed request beneath explicit flags.
Promote Claude Fable 5.2 as the preferred Fable model and keep 5.1 available as a non-preferred predecessor with its existing pricing. Add Gemini Pro Latest and align DeepSeek context windows to the 1,048,576-token limit. Update conformance and resolution expectations to the new registry defaults.
Stored and live verification reports now render in a per-iteration Verification tab instead of a standalone panel under the transcript. Live reports replace only their matching iteration, so earlier stored results stay visible. Rebuilt webapp dist assets to match. Claude-Session-Id: 01a1cb54-9717-7c83-9636-a73169d81f9e
…s to v1.64.1 Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
moshloop
force-pushed
the
feat/transcripts-modified-since
branch
from
November 12, 2026 07:56
fac550a to
80cfe9a
Compare
…ed lookup source Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
…r tests keep parallel workers and logs Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
…, static tables and Markdown escaping Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
… lists join items with one Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
…enial, native genkit constraints, Lint preset, provider-root messages and RemoteExecOptions Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
Gavel summary
Totals: 7472 passed · 0 failed · 16 skipped · 11m59s |
… runnable golangci-lint Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
… leaves unescaped Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
…te directory at the read Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
The presentation contract requires a title and x-help link on every node; the hand-authored bash/api schema had neither, which the embedded-catalog spec reports once the catalog loads again. Register bash's docs with the execution annotator so regeneration keeps them.
…m to the schemas branch resourceSchemas() read pkg/adapters/resources/anthropic.json, a 1.3 MB snapshot that .gitignore keeps out of the repository, so Schemas() failed and every catalog, validation and serve spec failed on CI. Native provider resources (OpenAI, Anthropic, Google) are no longer committed or embedded. A new Adapter schemas workflow captures the pinned sources (Claude Agent SDK declarations via ts-json-schema-generator, Codex and Gemini release schemas), applies the declarative JSON Patch layer in hack/adapterresources/patches, projects the catalog via adapters.NativeResourceSchemas, checks it with the adapterresources-tagged specs, and on main publishes it to the orphan schemas branch. The web UI loads native resources from raw.githubusercontent.com/flanksource/captain/schemas/adapters/native-resources.json beside the embedded catalog, reporting the URL when that fails. Validation carries a published document's schema; external refs are never loaded.
…end git options before it Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
… into feat/transcripts-modified-since-schemas
…not a bare EOF Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
…in so Close does not fail on a never-used connection Claude-Session-Id: 754971f0-98ba-4fb1-bae2-399104179627
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.