ur-agent 1.65.6 → 1.65.7
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 +52 -0
- package/README.md +5 -4
- package/dist/cli.js +5432 -3076
- package/dist/sdk/index.cjs +189 -0
- package/dist/sdk/index.d.ts +68 -0
- package/dist/sdk/index.js +149 -0
- package/docs/VALIDATION.md +1 -1
- package/documentation/app.js +91 -0
- package/documentation/index.html +1 -1
- package/extensions/jetbrains-ur/build.gradle.kts +1 -1
- package/extensions/vscode-ur-inline-diffs/package.json +1 -1
- package/package.json +13 -2
- package/technical/01-architecture.md +146 -0
- package/technical/02-cli-reference.md +227 -0
- package/technical/03-slash-commands.md +318 -0
- package/technical/04-tools.md +119 -0
- package/technical/05-providers-and-models.md +192 -0
- package/technical/06-configuration.md +407 -0
- package/technical/07-memory-and-context.md +147 -0
- package/technical/08-skills-plugins-workflows.md +211 -0
- package/technical/09-multi-agent.md +249 -0
- package/technical/10-headless-automation-eval.md +441 -0
- package/technical/11-integrations.md +156 -0
- package/technical/12-security-sandbox-stability.md +271 -0
- package/technical/13-research.md +129 -0
- package/technical/14-sessions.md +177 -0
- package/technical/README.md +43 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# 07 — Memory & Context Management
|
|
2
|
+
|
|
3
|
+
Source of truth: `src/memdir/`, `src/services/{SessionMemory,extractMemories,compact,contextCollapse}/`,
|
|
4
|
+
`src/commands/{memory,remember,forget,memory-retention,semantic-memory,knowledge,context-pack,compact,context}`.
|
|
5
|
+
|
|
6
|
+
## Layered memory model
|
|
7
|
+
|
|
8
|
+
| Layer | Location | Written by | Loaded |
|
|
9
|
+
|---|---|---|---|
|
|
10
|
+
| Project instructions | `UR.md` (repo root, committed) | user or `/init` | normal, non-`--bare` root sessions |
|
|
11
|
+
| Local project instructions | `UR.local.md` (gitignored) | user | normal, non-`--bare` root sessions |
|
|
12
|
+
| Auto-memory (memdir) | the project-scoped auto-memory path under `~/.ur` (`autoMemoryDirectory` setting; `UR_CODE_REMOTE_MEMORY_DIR` in containers) | the main agent, while working, when the injected memory instructions call for a durable note | either the bounded `MEMORY.md` index or selected topic attachments, depending on the relevance-recall gate |
|
|
13
|
+
| Team memory | shared team paths (`teamMemPaths.ts`, `TEAMMEM` build gate) | team sync service | source-only in this repository's standard npm build |
|
|
14
|
+
| Session transcripts | `~/.ur/projects/<slug>/` | automatic | via `/resume`, past-session search |
|
|
15
|
+
|
|
16
|
+
### Auto-memory (memdir)
|
|
17
|
+
- On by default; disable via `UR_CODE_DISABLE_AUTO_MEMORY=1`, `--bare`, or
|
|
18
|
+
`autoMemoryEnabled: false` (project-level opt-out supported).
|
|
19
|
+
- The stable path loads the byte/line-capped `MEMORY.md` index. When the
|
|
20
|
+
`tengu_moth_copse` runtime gate is enabled, UR instead performs a
|
|
21
|
+
non-blocking recall: a lexical header prefilter narrows candidates, a small
|
|
22
|
+
model selects at most three, and each selected file is truncated and
|
|
23
|
+
session-byte-capped before attachment. A failed or late selector never blocks
|
|
24
|
+
the main turn.
|
|
25
|
+
- Topic files use frontmatter (`name`, `description`,
|
|
26
|
+
`type: user|feedback|project|reference`); `MEMORY.md` is their index.
|
|
27
|
+
- The normal npm build asks the main agent to maintain these files directly.
|
|
28
|
+
The separate turn-end `extractMemories` implementation is behind the
|
|
29
|
+
compile-time `EXTRACT_MEMORIES` feature and is not bundled by
|
|
30
|
+
`scripts/bundle.mjs`; setting an environment variable alone cannot enable
|
|
31
|
+
that background extractor.
|
|
32
|
+
- `/memory` opens memory files for editing. There is no special `#` prompt
|
|
33
|
+
prefix for writing a note.
|
|
34
|
+
- `/remember <text>` writes the legacy project note and also promotes the note
|
|
35
|
+
into auto-memory when enabled. `/forget <text>` removes matching legacy
|
|
36
|
+
notes, their deterministic promoted topic files, and the corresponding index
|
|
37
|
+
links. Persistence failures are reported as failures or partial results,
|
|
38
|
+
rather than as successful saves. The project-note JSONL text is non-empty
|
|
39
|
+
and capped at 64 KiB; its `.ur/memory/` path must remain a regular directory
|
|
40
|
+
inside the canonical workspace, and symlinked collection files are rejected.
|
|
41
|
+
|
|
42
|
+
### Explicit memory commands
|
|
43
|
+
```
|
|
44
|
+
/remember we never bump major versions on Fridays # save a fact
|
|
45
|
+
/forget Fridays # remove matching notes
|
|
46
|
+
/memory # edit files interactively
|
|
47
|
+
/memory-retention set --ttl-days 90 --max-entries 500 --decay-days 14
|
|
48
|
+
/memory-retention prune # apply the policy now
|
|
49
|
+
```
|
|
50
|
+
The bundled `/remember` skill (no args) reviews auto-memory and proposes promotions to
|
|
51
|
+
UR.md / UR.local.md and detects stale/duplicate/conflicting entries.
|
|
52
|
+
|
|
53
|
+
### Automatic learning
|
|
54
|
+
- On by default; disable via `UR_CODE_DISABLE_AUTO_LEARNING=1` or
|
|
55
|
+
`automaticLearningEnabled: false`.
|
|
56
|
+
- ci-loop, arena, escalation, test-first, and cloud-task outcomes are folded into
|
|
57
|
+
`.ur/learning/stats.json` as local JSON. This automatic path uses no model
|
|
58
|
+
calls and no prompt tokens.
|
|
59
|
+
- Learned success rates bias auto model routing and escalation only when there
|
|
60
|
+
is enough evidence; otherwise static routing is unchanged.
|
|
61
|
+
|
|
62
|
+
### Lexical memory index
|
|
63
|
+
```
|
|
64
|
+
/semantic-memory build # build a local lexical index
|
|
65
|
+
/semantic-memory search "how do we rotate tokens"
|
|
66
|
+
/semantic-memory status
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Despite the historical command name, this implementation does not call an
|
|
70
|
+
embedding model. It tokenizes paragraphs from `UR.md`, `README.md`,
|
|
71
|
+
`.ur/memory/`, and `.ur/docs/`, then ranks by query-token overlap. Use
|
|
72
|
+
`/knowledge build --embeddings` or `/code-index build` when dense embedding
|
|
73
|
+
retrieval is required.
|
|
74
|
+
|
|
75
|
+
### Knowledge base (`/knowledge`, alias `/kb`) — curated, with provenance
|
|
76
|
+
```
|
|
77
|
+
/knowledge add src/auth/jwt.ts --note "token flow" --label auth
|
|
78
|
+
/knowledge build --embeddings --embed-model nomic-embed-text
|
|
79
|
+
/knowledge search "refresh rotation"
|
|
80
|
+
/knowledge prune --older-than 60
|
|
81
|
+
/knowledge status
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Context pack (`/context-pack`, aliases `/ctx-pack`, `/project-manifest`)
|
|
85
|
+
Repo-architecture summary + task memory + compressed project context in `.ur/context/`:
|
|
86
|
+
```
|
|
87
|
+
/context-pack scan
|
|
88
|
+
/context-pack remember --type decision --text "we chose fastify over express"
|
|
89
|
+
/context-pack memory verify
|
|
90
|
+
/context-pack memory quarantine
|
|
91
|
+
/context-pack memory rollback --to <entry-id>
|
|
92
|
+
/context-pack compress
|
|
93
|
+
/context-pack status
|
|
94
|
+
```
|
|
95
|
+
Types: `decision | constraint | command | diff | note | architecture |
|
|
96
|
+
preference | attempt | accepted | rejected`. New entries contain UUIDs,
|
|
97
|
+
source provenance, content digests, and a SHA-256 previous-entry chain. Appends
|
|
98
|
+
are locked, private, no-follow, and fsynced; reads fail closed. Quarantine and
|
|
99
|
+
rollback preserve a private copy of the full original before replacement.
|
|
100
|
+
|
|
101
|
+
## Context window management
|
|
102
|
+
|
|
103
|
+
| Feature | How |
|
|
104
|
+
|---|---|
|
|
105
|
+
| Visualize usage | `/context` (colored grid); `/files` is an ant-only command and is absent from the standard npm CLI |
|
|
106
|
+
| Manual compaction | `/compact [focus instructions]` |
|
|
107
|
+
| Auto-compaction | `src/services/compact` — triggers near the limit; `DISABLE_AUTO_COMPACT` env disables; PreCompact/PostCompact hooks fire |
|
|
108
|
+
| Context collapse | `src/services/contextCollapse` and `CtxInspect` are behind the compile-time `CONTEXT_COLLAPSE` feature, which the standard npm bundle does not include |
|
|
109
|
+
| Micro-compaction | session-memory compact (`sessionMemoryCompact.ts`): force on with `ENABLE_UR_CODE_SM_COMPACT=1`, force off with `DISABLE_UR_CODE_SM_COMPACT=1`; otherwise both `tengu_session_memory` and `tengu_sm_compact` runtime gates must be on |
|
|
110
|
+
| Clear | `/clear` (aliases `/reset`, `/new`) |
|
|
111
|
+
| Read caps | Read tool truncates large files/lines; `/read`, `/analyze`, `/summarize` for deliberate loads |
|
|
112
|
+
|
|
113
|
+
## Repo wiki & map
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
/wiki generate # .ur/wiki/: overview, architecture, dependency map (from DNA + code index)
|
|
117
|
+
/wiki install-hook # refresh automatically after every merge
|
|
118
|
+
/wiki map # regenerate .ur/repo-map.md
|
|
119
|
+
```
|
|
120
|
+
When `.ur/repo-map.md` exists and is fresh (less than seven days), a byte-capped
|
|
121
|
+
repo map is injected into the system prompt automatically (zero tokens until
|
|
122
|
+
generated).
|
|
123
|
+
|
|
124
|
+
## Project DNA & indexes
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
/dna # detect language, package manager, build/test/lint → .ur/dna
|
|
128
|
+
/index # build workspace file index (.ur/index)
|
|
129
|
+
/code-index build # semantic embeddings index — CodeSearch auto-enables once built
|
|
130
|
+
/code-index watch # keep it fresh
|
|
131
|
+
/code-index search "debounce input"
|
|
132
|
+
```
|
|
133
|
+
`/project` and `/workspace` display the recorded DNA + workspace facts.
|
|
134
|
+
|
|
135
|
+
## What gets injected into the system prompt
|
|
136
|
+
|
|
137
|
+
The interactive and print entrypoints both assemble the prompt through
|
|
138
|
+
`src/constants/prompts.ts` plus the context helpers. A normal root prompt
|
|
139
|
+
includes UR.md/UR.local.md instructions, auto-memory as described above, the
|
|
140
|
+
active working-mode discipline, output style, enabled-tool guidance, and
|
|
141
|
+
environment information. Read-only `Explore` and `Plan` subagents omit the
|
|
142
|
+
UR.md hierarchy when the default-on `tengu_slim_subagent_agentmd` runtime gate
|
|
143
|
+
is active and the caller did not explicitly supply user context. Project DNA
|
|
144
|
+
is not injected directly; it can appear through a fresh generated repo map.
|
|
145
|
+
`--bare` replaces the root prompt with a minimal prompt and drops automatic
|
|
146
|
+
memory, hooks, and most extras. The internal `--dump-system-prompt` diagnostic
|
|
147
|
+
exists only in ant builds.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# 08 — Skills, Plugins & Workflows
|
|
2
|
+
|
|
3
|
+
Source of truth: `src/skills/`, `src/utils/plugins/`, `src/plugins/`,
|
|
4
|
+
`src/services/agents/{workflows,patterns}.ts`, `src/tools/WorkflowTool/`.
|
|
5
|
+
|
|
6
|
+
## Skills
|
|
7
|
+
|
|
8
|
+
Two skill formats coexist:
|
|
9
|
+
|
|
10
|
+
### 1. Prompt skills (SKILL.md)
|
|
11
|
+
Directory format `skill-name/SKILL.md` with Agent Skills-compatible YAML
|
|
12
|
+
frontmatter (`name`, `description`, optional `license`, `compatibility`,
|
|
13
|
+
`metadata`, `allowed-tools`). Loaded from:
|
|
14
|
+
- project: `.ur/skills/<name>/SKILL.md`
|
|
15
|
+
- user: `~/.ur/skills/<name>/SKILL.md`
|
|
16
|
+
- cross-client project/user: `.agents/skills/<name>/SKILL.md` and
|
|
17
|
+
`~/.agents/skills/<name>/SKILL.md`
|
|
18
|
+
- plugins and MCP servers (MCP skills never execute embedded shell blocks)
|
|
19
|
+
- bundled skills compiled into the binary (`src/skills/bundled/`, list in doc 03 §13)
|
|
20
|
+
|
|
21
|
+
Resolution is deterministic: nearer project roots beat parent roots, project
|
|
22
|
+
beats user, and native `.ur` beats cross-client `.agents` at the same scope.
|
|
23
|
+
|
|
24
|
+
Body supports `${UR_SKILL_DIR}` (skill directory path) and `${UR_SESSION_ID}`
|
|
25
|
+
substitution, plus the exclamation-backtick inline form and
|
|
26
|
+
exclamation-labelled fenced shell blocks for any loaded non-MCP prompt skill.
|
|
27
|
+
Those commands still pass through the normal
|
|
28
|
+
shell-tool permission checks and the skill's `allowed-tools` rules. Remote MCP
|
|
29
|
+
skills never execute embedded shell; “local” here is not a cryptographic trust
|
|
30
|
+
claim.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
/create-skill release-notes "draft release notes from git log" --project
|
|
34
|
+
# → .ur/skills/release-notes/SKILL.md, then invoke with:
|
|
35
|
+
/release-notes v2.1
|
|
36
|
+
```
|
|
37
|
+
`/skills` opens the prompt-skill browser; the model can also self-invoke prompt
|
|
38
|
+
skills through the `Skill` tool. `/skill` is intentionally separate and runs
|
|
39
|
+
the executable `skill.yaml` workflows below. Neither slash token aliases the
|
|
40
|
+
other.
|
|
41
|
+
`/skillify` (bundled) converts the current session's workflow into a skill.
|
|
42
|
+
|
|
43
|
+
For a file-backed `SKILL.md`, UR attempts to compute deterministic content-tree
|
|
44
|
+
and permission digests and validates names, directory identity, field
|
|
45
|
+
types/lengths, and metadata; signed skills cannot contain symlinks. Trust
|
|
46
|
+
commands:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
ur skill verify <name-or-directory> [--require-trusted] [--json]
|
|
50
|
+
ur skill keygen <key-id> [--out <private-key.pem>]
|
|
51
|
+
ur skill sign <name-or-directory> --key <private-key.pem> --key-id <key-id>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Ed25519 manifests embed the public key and signed digests. Trusted keys live in
|
|
55
|
+
a private store (override its file with `UR_SKILL_TRUSTED_KEYS_FILE`). In the
|
|
56
|
+
default mode, provenance-inspection and Agent Skills validation failures are
|
|
57
|
+
logged and an otherwise readable skill may still load.
|
|
58
|
+
`UR_SKILLS_STRICT_SPEC=true` rejects invalid or uninspectable skills;
|
|
59
|
+
`UR_SKILLS_REQUIRE_TRUSTED_SIGNATURE=true` requires a verified trusted
|
|
60
|
+
signature at load. When provenance was successfully recorded, UR re-hashes the
|
|
61
|
+
file tree immediately before invocation to detect changes after discovery.
|
|
62
|
+
The corresponding `ur skill` trust flags are declared by the shipped CLI, not
|
|
63
|
+
only by the local command parser.
|
|
64
|
+
|
|
65
|
+
### 2. Executable skills (skill.yaml) — skills as workflows
|
|
66
|
+
`skill.yaml` is searched through the same project/user native and cross-client
|
|
67
|
+
skill roots (`.ur/skills` and `.agents/skills`).
|
|
68
|
+
`src/skills/skillSpec.ts` compiles it into a `WorkflowSpec`:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
version: 1
|
|
72
|
+
name: deploy-checklist
|
|
73
|
+
description: Gate a deploy behind checks
|
|
74
|
+
allowedTools: [Bash, Read]
|
|
75
|
+
steps:
|
|
76
|
+
- id: tests
|
|
77
|
+
name: Run tests
|
|
78
|
+
agent: general-purpose
|
|
79
|
+
prompt: Run the full test suite and report failures.
|
|
80
|
+
- id: approve
|
|
81
|
+
name: Human sign-off
|
|
82
|
+
agent: general-purpose
|
|
83
|
+
prompt: Summarize risk.
|
|
84
|
+
dependsOn: [tests]
|
|
85
|
+
gate: approval
|
|
86
|
+
checkpoint: true
|
|
87
|
+
```
|
|
88
|
+
The directory may include `instructions.md`, `scripts/`, `templates/`, and
|
|
89
|
+
`checklists/` referenced via `${UR_SKILL_DIR}`. `allowedTools` is validated,
|
|
90
|
+
copied to every compiled workflow step, and passed to the child `ur -p` process
|
|
91
|
+
as its exact `--tools` pool; it is not merely descriptive metadata. Each
|
|
92
|
+
step's `agent` is also forwarded as `ur --agent <name>`, so the selected
|
|
93
|
+
built-in or project-defined agent governs that child session.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
/skill list · /skill show deploy-checklist · /skill run deploy-checklist
|
|
97
|
+
/skill approve deploy-checklist approve
|
|
98
|
+
/skill run deploy-checklist --resume · /skill reset deploy-checklist
|
|
99
|
+
/skill init <name>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
An approval-gated step is held before its model/tool execution. Approval is
|
|
103
|
+
accepted only for the currently held step, stored as a single-use token, and
|
|
104
|
+
consumed by `run --resume`. A run that fails, is blocked, or is held returns a
|
|
105
|
+
nonzero command status.
|
|
106
|
+
|
|
107
|
+
The `ur skill verify|sign|keygen` supply-chain commands above operate on
|
|
108
|
+
Agent Skills directories containing `SKILL.md`. Executable `skill.yaml`
|
|
109
|
+
workflows are parsed and schema-validated, but that execution path does not
|
|
110
|
+
currently require or verify the `SKILL.md` Ed25519 manifest. Do not treat
|
|
111
|
+
signing a neighboring prompt skill as a signature over `skill.yaml`.
|
|
112
|
+
|
|
113
|
+
All skill, plugin, workflow, and built-in invocation tokens pass through the
|
|
114
|
+
same registry normalizer. Earlier sources retain priority, duplicate canonical
|
|
115
|
+
tokens are omitted, and a later command loses only aliases already claimed by
|
|
116
|
+
another command.
|
|
117
|
+
|
|
118
|
+
## Workflows (`/workflow`, aliases `/wf`, `/workflows`)
|
|
119
|
+
|
|
120
|
+
Declarative, checkpointed DAGs of agent steps (`src/services/agents/workflows.ts`).
|
|
121
|
+
Each step: `id`, `name`, `agent` (subagent type), `prompt`, `dependsOn`,
|
|
122
|
+
optional `allowedTools`, `gate: approval|verification`,
|
|
123
|
+
`verificationMode: enforcing|advisory`, and `checkpoint: true`. Stored under
|
|
124
|
+
`.ur/workflows/`.
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
/workflow init release # scaffold
|
|
128
|
+
/workflow validate release # cycle/agent checks
|
|
129
|
+
/workflow graph release --ascii # Mermaid or ASCII rendering
|
|
130
|
+
/workflow plan release # topological dry-run
|
|
131
|
+
/workflow run release # execute until completion, failure, or a gate hold
|
|
132
|
+
/workflow approve release step-id # approve the currently held approval step
|
|
133
|
+
/workflow run release --resume # consume approval/resume persisted progress
|
|
134
|
+
/workflow next release # show the next ready step
|
|
135
|
+
/workflow done release step-id # manually complete an ungated step only
|
|
136
|
+
/workflow reset release
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Progress and exact step outputs are persisted after every completed step for
|
|
140
|
+
crash recovery, within a 32 KiB per-step and 256 KiB per-run output budget.
|
|
141
|
+
Oversized outputs are not silently truncated: the completed step remains done
|
|
142
|
+
and is never replayed, while an output-dependent successor fails closed on
|
|
143
|
+
resume and tells the operator to reset for an intentional rerun. Legacy state
|
|
144
|
+
without captured outputs follows the same rule. Resumed completed steps are
|
|
145
|
+
reported as done with zero executions in the resumed run, not as skipped.
|
|
146
|
+
`checkpoint: true` additionally creates a semantic checkpoint record.
|
|
147
|
+
Parallel waves use all-settled accounting: if one branch fails, every sibling
|
|
148
|
+
that already ran is still recorded and successful siblings remain completed;
|
|
149
|
+
only dependent, unstarted steps are reported as skipped.
|
|
150
|
+
Verification gates require exactly one standalone non-error `VERDICT: PASS`
|
|
151
|
+
line; inline, missing, or multiple verdicts, `FAIL`, `PARTIAL`, and runner
|
|
152
|
+
errors fail closed unless that step explicitly
|
|
153
|
+
sets `verificationMode: advisory`. Non-completed CLI runs return nonzero.
|
|
154
|
+
The declared `agent` is passed to each child session through `--agent`; the
|
|
155
|
+
built-in `worker` alias falls back to `general-purpose`, while a project
|
|
156
|
+
definition named `worker` takes precedence.
|
|
157
|
+
Workflow execution is foreground in this build. Historical
|
|
158
|
+
`LocalWorkflowTask` records remain renderable, but no runtime constructor or
|
|
159
|
+
stop operation advertises them as live background tasks.
|
|
160
|
+
|
|
161
|
+
## Collaboration patterns (`/pattern`)
|
|
162
|
+
|
|
163
|
+
Prebuilt multi-agent topologies (`src/services/agents/patterns.ts`):
|
|
164
|
+
`peer` (plan-execute-express-review), `doe` (data-oriented ensemble), `concurrent`,
|
|
165
|
+
`handoff`, `debate`, `parallel`.
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
/pattern list
|
|
169
|
+
/pattern show peer
|
|
170
|
+
/pattern run debate "adopt tRPC or keep REST?" --execute
|
|
171
|
+
/pattern install peer --save # materialize as an editable workflow
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Plugins
|
|
175
|
+
|
|
176
|
+
Plugin manifests + marketplaces (`src/utils/plugins/`, `.ur-plugin/marketplace.json`
|
|
177
|
+
format). Plugins can contribute: commands, skills, agents, hooks, MCP servers, output
|
|
178
|
+
styles.
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
ur plugin marketplace add github.com/acme/ur-plugins # or a local path
|
|
182
|
+
ur plugin marketplace list / update / remove <name>
|
|
183
|
+
ur plugin install fmt@acme -s project # scopes: user | project | local
|
|
184
|
+
ur plugin list --json --available
|
|
185
|
+
ur plugin enable fmt / disable fmt / disable -a
|
|
186
|
+
ur plugin update fmt
|
|
187
|
+
ur plugin validate ./my-plugin # manifest validation
|
|
188
|
+
ur plugin doctor --path ./plugins # diagnose
|
|
189
|
+
/plugin # interactive Ink UI (alias /plugins, /marketplace)
|
|
190
|
+
/reload-plugins # activate pending changes in-session
|
|
191
|
+
ur --plugin-dir ./dev-plugin # session-only plugin load
|
|
192
|
+
```
|
|
193
|
+
Settings: `enabledPlugins`, `pluginConfigs`, `extraKnownMarketplaces`,
|
|
194
|
+
`strictKnownMarketplaces`, `blockedMarketplaces`, `strictPluginOnlyCustomization`.
|
|
195
|
+
|
|
196
|
+
## Local helper tools (`/toolsmith`)
|
|
197
|
+
|
|
198
|
+
Scaffolds a small custom tool under `.ur/tools/<name>/` in python/bash/node/go/rust; UR
|
|
199
|
+
runs it with approval like any command:
|
|
200
|
+
```
|
|
201
|
+
/toolsmith csv-differ python
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Automations (`/automation`)
|
|
205
|
+
|
|
206
|
+
Project-local scheduled prompts (`.ur/automations/`), separate from skills:
|
|
207
|
+
```
|
|
208
|
+
/automation create nightly-tests --schedule "0 3 * * *" --prompt "run tests; open an issue on failure"
|
|
209
|
+
/automation run-due # execute anything due now
|
|
210
|
+
ur automation install --platform launchd --interval 300 # host scheduler integration
|
|
211
|
+
```
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# 09 — Multi-Agent Orchestration
|
|
2
|
+
|
|
3
|
+
Source of truth: `src/tools/AgentTool/`, `src/services/agents/`, `src/commands/{agents,bg,crew,arena,pattern,task,worktree,route,escalate}`,
|
|
4
|
+
`src/coordinator/coordinatorMode.ts`, `src/tools/Team*Tool/`.
|
|
5
|
+
|
|
6
|
+
## Subagents (the `Agent` tool)
|
|
7
|
+
|
|
8
|
+
The main agent can spawn subagents. Built-in agent types
|
|
9
|
+
(`src/tools/AgentTool/built-in/`):
|
|
10
|
+
|
|
11
|
+
| Type | Purpose |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `general-purpose` | catch-all multi-step worker (all tools) |
|
|
14
|
+
| `worker` | stable workflow/crew alias for `general-purpose`; a project-defined `worker` overrides it |
|
|
15
|
+
| `verification` | verifies a change actually works (used by `/verify`) |
|
|
16
|
+
| `statusline-setup` | configures the status line |
|
|
17
|
+
| `ur-code-guide` | answers UR/SDK/API questions |
|
|
18
|
+
| `Explore`, `Plan` | read-only search and planning agents, available only in builds compiled with `BUILTIN_EXPLORE_PLAN_AGENTS` and when their runtime gate is enabled; the standard npm bundle does not compile that feature |
|
|
19
|
+
|
|
20
|
+
Custom agents:
|
|
21
|
+
- `/agents` — interactive management UI.
|
|
22
|
+
- Definition files loaded from agents directories (project + user), validated by
|
|
23
|
+
`AgentJsonSchema`: `description` (required), `prompt` (required), `tools`,
|
|
24
|
+
`disallowedTools`, `model` (or `inherit`), `effort`, `permissionMode`,
|
|
25
|
+
`mcpServers`, `hooks`, `maxTurns`, `skills`, `initialPrompt`, `memory`,
|
|
26
|
+
`background`, and worktree `isolation`.
|
|
27
|
+
- CLI: `ur --agents '{"reviewer":{"description":"…","prompt":"…"}}'` and
|
|
28
|
+
`ur --agent reviewer` to run a whole session as that agent.
|
|
29
|
+
- `/agent-templates install <name>` installs reusable templates;
|
|
30
|
+
`/role-mode install architect|code|debug|ask` installs the four classic role modes as
|
|
31
|
+
scoped agents.
|
|
32
|
+
|
|
33
|
+
When present, read-only `Explore`/`Plan` agents omit the UR.md hierarchy only
|
|
34
|
+
when the default-on `tengu_slim_subagent_agentmd` gate remains enabled and the
|
|
35
|
+
caller did not explicitly provide user context (token saving; see
|
|
36
|
+
`loadAgentsDir.ts`).
|
|
37
|
+
|
|
38
|
+
Inspection: `/agent-inspect` reconstructs a per-subagent timeline (spawns, prompts,
|
|
39
|
+
results, verdicts, tools, tokens) from the session or a transcript file.
|
|
40
|
+
|
|
41
|
+
## Fan-out limits (`src/tools/AgentTool/fanOutLimits.ts`)
|
|
42
|
+
|
|
43
|
+
These limits apply specifically to nested, in-process launches through the
|
|
44
|
+
`Agent` tool. Both are checked in `runAgent` before that child starts, so a
|
|
45
|
+
refusal is free.
|
|
46
|
+
|
|
47
|
+
| Limit | Default | Hard ceiling | Setting |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| Nesting depth | 3 | 10 | `agents.maxDepth` |
|
|
50
|
+
| Concurrent agents | 20 | 100 | `agents.maxConcurrent` |
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{ "agents": { "maxConcurrent": 40, "maxDepth": 4 } }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Out-of-range, negative and non-numeric values clamp rather than disabling the
|
|
57
|
+
governor — a settings file cannot switch it off. Exceeding a limit throws with
|
|
58
|
+
a message naming both the limit and the setting that raises it. Slot ownership
|
|
59
|
+
enters a single `try/finally` immediately after registration. Failures during
|
|
60
|
+
context loading, hooks, skill or MCP setup, cache callbacks, query execution,
|
|
61
|
+
cancellation, and normal completion all release it exactly once; partial setup
|
|
62
|
+
resources are cleaned conditionally.
|
|
63
|
+
|
|
64
|
+
Depth is derived from the live registry rather than passed down: a child's
|
|
65
|
+
depth is its parent's plus one, and an agent whose parent is unknown counts as
|
|
66
|
+
a root.
|
|
67
|
+
|
|
68
|
+
`/crew`, `/arena`, `/bg fanout`, and `/exec` launch subprocess/worktree
|
|
69
|
+
orchestrators and do **not** register in this `Agent`-tool governor. They have
|
|
70
|
+
their own concurrency limits (`crew` clamps fixed and dynamic pools to 1–32;
|
|
71
|
+
`bg fanout` and `exec` also clamp their public counts) and their own model/token
|
|
72
|
+
cost. Detached background agents are separate processes with separate
|
|
73
|
+
in-process registries.
|
|
74
|
+
|
|
75
|
+
## Running several workers at once
|
|
76
|
+
|
|
77
|
+
Four ways to parallelise, differing mainly in whether workers share your
|
|
78
|
+
checkout:
|
|
79
|
+
|
|
80
|
+
| Command | Shape | Isolation flag |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| `ur exec "a" "b" --concurrency 3` | different prompts in parallel | `--worktree` |
|
|
83
|
+
| `ur crew run <name> --workers 4` | one goal split across a task board | `--worktrees` |
|
|
84
|
+
| `ur arena "<task>" --agents 3` | same task, N attempts, judge picks | isolated by default |
|
|
85
|
+
| `ur bg fanout "<task>" --agents 4` | detached, survives the session | `--worktree` |
|
|
86
|
+
|
|
87
|
+
Pass the isolation flag whenever workers might touch the same files. Without
|
|
88
|
+
it every worker edits the same checkout concurrently and they overwrite each
|
|
89
|
+
other. Agents are much heavier than test workers — each is a full model session
|
|
90
|
+
with its own token spend — so 4–6 is usually the practical ceiling on a laptop
|
|
91
|
+
regardless of the configured limit.
|
|
92
|
+
|
|
93
|
+
Isolation does not imply integration. `/crew --worktrees` creates a fresh
|
|
94
|
+
worktree for every task attempt and leaves a passing attempt at its recorded
|
|
95
|
+
path for lead/human review; it does not merge, cherry-pick, or apply those
|
|
96
|
+
changes to the starting checkout. A dependent crew task receives its
|
|
97
|
+
prerequisite's text result, but its fresh worktree does not inherit the
|
|
98
|
+
prerequisite worktree's unmerged file changes. Design dependent code edits
|
|
99
|
+
accordingly. `/exec --worktree` instead gives all steps of one top-level prompt
|
|
100
|
+
the same plan worktree (doc 10).
|
|
101
|
+
|
|
102
|
+
## Shared task-list correctness
|
|
103
|
+
|
|
104
|
+
Interactive sessions use the canonical Task V2 tools. Print/headless sessions
|
|
105
|
+
use legacy `TodoWrite` by default, or Task V2 when
|
|
106
|
+
`UR_CODE_ENABLE_TASKS=1`. Both feed the same mutation gate:
|
|
107
|
+
|
|
108
|
+
- Task IDs are ordered numerically (`1, 2, 10`), with non-numeric external IDs
|
|
109
|
+
sorted stably after numeric IDs.
|
|
110
|
+
- Dependencies block transition or claim until prerequisites are complete.
|
|
111
|
+
- Actionable `pending` or `in_progress` entries open the gate; completed and
|
|
112
|
+
internal entries do not.
|
|
113
|
+
- Reads remain unrestricted. Ordinary mutations have a default allowance of
|
|
114
|
+
three preceding tool calls, counted by tool call rather than message.
|
|
115
|
+
Delegation and child mutations always require an actionable parent task.
|
|
116
|
+
- An unreadable task store fails closed. Task create/update/list/get tools stay
|
|
117
|
+
exempt so the agent can repair the plan.
|
|
118
|
+
- Configure the behavior at
|
|
119
|
+
`tasks.requireBeforeChanges.{enabled,freeReads}`.
|
|
120
|
+
|
|
121
|
+
The prompt contract tells the model to update each task after observing its
|
|
122
|
+
tool result. Runtime dependencies and mutation gating enforce ordering and
|
|
123
|
+
plan presence; they cannot prove that an arbitrary natural-language task is
|
|
124
|
+
semantically complete. Workflows and crews add stricter verdict rules where a
|
|
125
|
+
machine-checkable execution boundary exists.
|
|
126
|
+
|
|
127
|
+
## Task routing
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
/route "why does login 500 intermittently?" # → recommends subagent + pattern
|
|
131
|
+
/model-route "port to Rust" --strategy strong # → recommends model (doc 05)
|
|
132
|
+
/escalate run "hard problem" --oracle gpt-5.5 # fast model + oracle escalation (doc 05)
|
|
133
|
+
```
|
|
134
|
+
`src/services/agents/intentRouter.ts` does the task classification;
|
|
135
|
+
`decomposer.ts` splits goals into tasks; `delegation.ts` hands tasks to workers.
|
|
136
|
+
|
|
137
|
+
## Background agents (`/bg`, `ur bg`)
|
|
138
|
+
|
|
139
|
+
Detached local agents managed by `src/services/agents/backgroundRunner.ts`:
|
|
140
|
+
```
|
|
141
|
+
/bg run "upgrade eslint to v9" --worktree # isolated local worktree
|
|
142
|
+
/bg run "upgrade eslint to v9" --worktree --pr # explicit opt-in PR creation
|
|
143
|
+
/bg fanout "fix all TODO(sec) comments" --agents 4
|
|
144
|
+
/bg list · /bg status <id> · /bg logs <id> · /bg attach <id> · /bg kill <id>
|
|
145
|
+
```
|
|
146
|
+
The standard CLI exposes the same operations through `ur bg ...`. The separate
|
|
147
|
+
process-session fast path (`ur --bg -p`, then top-level `ur ps|logs|attach|kill`)
|
|
148
|
+
requires the `BG_SESSIONS` build feature and is not present in the normal npm
|
|
149
|
+
bundle.
|
|
150
|
+
|
|
151
|
+
## Crews (`/crew`) — shared task board
|
|
152
|
+
|
|
153
|
+
A lead agent decomposes a goal into a task board; worker subagents claim and execute tasks
|
|
154
|
+
(`src/services/agents/crew.ts`):
|
|
155
|
+
```
|
|
156
|
+
/crew create cleanup --goal "remove dead code and fix lints" --decompose
|
|
157
|
+
/crew plan cleanup --goal "remove dead code and fix lints" --decompose
|
|
158
|
+
/crew add cleanup --task "delete unused exports in src/utils"
|
|
159
|
+
/crew run cleanup --workers 3 --worktrees
|
|
160
|
+
/crew run cleanup --dynamic --max-workers 8 # scale workers to the board (own 1–32 cap)
|
|
161
|
+
/crew show cleanup · /crew reset cleanup --max-attempts 2 · /crew delete cleanup
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
A task succeeds only when the worker process is non-error and returns exactly
|
|
165
|
+
one standalone `VERDICT: PASS` line; inline, missing, or multiple verdicts,
|
|
166
|
+
`PARTIAL`, and `FAIL` are failures. Automatic
|
|
167
|
+
retries are bounded (hard cap five), cancellation-aware, and allowed only for
|
|
168
|
+
dry runs or fresh worktree attempts. Shared-checkout failures are not replayed
|
|
169
|
+
because their mutations are ambiguous. `--resume` and `reset` reopen only safe
|
|
170
|
+
isolated attempts that still have budget; ambiguous claimed tasks are marked
|
|
171
|
+
failed. Dynamic mode exits rather than spinning when claimed tasks prevent
|
|
172
|
+
further progress. Fixed `--workers` and dynamic `--max-workers` are clamped to
|
|
173
|
+
1–32 independently of the in-process `Agent`-tool governor. A board that is
|
|
174
|
+
not completely done returns nonzero.
|
|
175
|
+
|
|
176
|
+
## Arena (`/arena`) — best-of-N with a judge
|
|
177
|
+
|
|
178
|
+
N agents attempt the same task in isolated worktrees, a deterministic judge compares the
|
|
179
|
+
diffs, and a passing winner can be applied (`src/services/agents/arena.ts`). Worktree
|
|
180
|
+
creation failure fails that candidate; it never falls back to concurrent writes in cwd.
|
|
181
|
+
Only non-error `PASS` candidates with a non-empty, non-blocking diff can win:
|
|
182
|
+
```
|
|
183
|
+
/arena "make the image pipeline 2x faster" --agents 3 --max-turns 30
|
|
184
|
+
/arena "…" --apply # apply the winning diff
|
|
185
|
+
/arena "…" --keep # keep losing worktrees for inspection
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Worktree-per-task sessions
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
ur -w feature-x # session in a fresh git worktree (+ --tmux for panes)
|
|
192
|
+
/task start rate-limiter --worktree --base main
|
|
193
|
+
/task run <id> · /task status <id> · /task list
|
|
194
|
+
/task pr <id> --create --draft --base main
|
|
195
|
+
/worktree list · /worktree status · /worktree clean
|
|
196
|
+
```
|
|
197
|
+
`EnterWorktree` / `ExitWorktree` tools let the model move itself into isolation mid-turn
|
|
198
|
+
(worktree mode). Worktree settings: `worktree.symlinkDirectories`, `worktree.sparsePaths`.
|
|
199
|
+
`task start --worktree` creates only local isolated state; it never pushes or
|
|
200
|
+
opens a PR. Publishing begins only with the explicit `task pr --create`
|
|
201
|
+
command.
|
|
202
|
+
|
|
203
|
+
Bundled worktree skills (`/debug-v2`, `/refactor`, `/security-review`,
|
|
204
|
+
`/dockerize`, `/paper-implementation`, `/latex-paper`, `/benchmark`, `/batch`)
|
|
205
|
+
carry instructions to leave changes local, run focused checks while working,
|
|
206
|
+
ask before the final full verification suite, and avoid commit/push/PR actions
|
|
207
|
+
unless the user separately requests publishing. These are model instructions,
|
|
208
|
+
not a separate OS enforcement boundary. `agentSkillRunner.createPr` defaults
|
|
209
|
+
to false.
|
|
210
|
+
|
|
211
|
+
## Teams / swarm mode (feature-gated)
|
|
212
|
+
|
|
213
|
+
- The standard external build can opt into in-process teams with
|
|
214
|
+
`UR_CODE_EXPERIMENTAL_AGENT_TEAMS=1`, subject to the
|
|
215
|
+
`tengu_amber_flint` runtime kill switch. This enables `TeamCreate`,
|
|
216
|
+
`TeamDelete`, `SendMessage`, `InProcessTeammateTask`, and the
|
|
217
|
+
`TeammateIdle` hook. `--agent-teams` is registered only in ant builds, so it
|
|
218
|
+
is not a supported external CLI flag.
|
|
219
|
+
- Coordinator mode (`UR_CODE_COORDINATOR_MODE=1`) is additionally behind the
|
|
220
|
+
compile-time `COORDINATOR_MODE` feature. The standard npm bundle does not
|
|
221
|
+
include it; setting the environment variable there has no effect.
|
|
222
|
+
- `/peers` and `ListPeers` are behind the compile-time `UDS_INBOX` feature and
|
|
223
|
+
are likewise absent from the standard npm bundle.
|
|
224
|
+
- Team-memory synchronization is separately behind the compile-time `TEAMMEM`
|
|
225
|
+
feature; enabling teams does not make that source-only memory service appear.
|
|
226
|
+
|
|
227
|
+
## Goals — long-horizon persistence (`/goal`)
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
/goal add v2-launch --objective "ship v2" --workflow release
|
|
231
|
+
/goal list · /goal show v2-launch · /goal note v2-launch "auth blocked on infra"
|
|
232
|
+
/goal resume v2-launch # run the linked workflow now from its saved checkpoint
|
|
233
|
+
/goal pause|done|abandon|delete v2-launch
|
|
234
|
+
```
|
|
235
|
+
`resume` executes the linked workflow through child sessions from the current
|
|
236
|
+
command; it does not open a new main interactive session. A stored `--pattern`
|
|
237
|
+
is descriptive metadata today and is not executed by `goal resume`, which
|
|
238
|
+
requires a linked workflow.
|
|
239
|
+
|
|
240
|
+
## Verification layer (`src/services/verifier/`)
|
|
241
|
+
|
|
242
|
+
The main query loop has a verifier with done detection, loop detection, project
|
|
243
|
+
quality gates (`projectGates.ts`, installed by
|
|
244
|
+
`/test-first install --install-gates`), and optional subagent nudges.
|
|
245
|
+
`verifier.askBeforeGates` controls prompting. Workflow verification gates,
|
|
246
|
+
crew verdicts, arena judging, and exec evidence checks are separate
|
|
247
|
+
orchestrator-specific mechanisms; they should not be conflated with this query
|
|
248
|
+
verifier. Proof helpers in `verificationProofs.ts` are consumed by the
|
|
249
|
+
spec/kernel verification paths and related evidence reporting.
|