ur-agent 1.68.18 → 1.69.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.
@@ -1,175 +0,0 @@
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 at one canonical model-aware threshold; `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
- The effective context window always stays positive, including for small local
114
- models. By default proactive compaction reserves a scaled output buffer (up to
115
- 20,000 tokens) plus a 13,000-token compact/manual safety band. The global
116
- `compaction.autoThreshold` setting can instead select 50–95% of the effective
117
- window while retaining a 3,000-token manual reserve;
118
- `UR_AUTOCOMPACT_PCT_OVERRIDE` is the explicit environment override. Trigger
119
- logic, prompt notifications, `/context`, and the SDK all use this same
120
- threshold and estimated live usage, including messages added after the last
121
- provider response.
122
-
123
- When proactive auto-compaction is active, the prompt notification and
124
- `/context` show a clamped approximate 0–100% value remaining until the actual
125
- trigger, with separate warning and final-error bands. The estimate uses the
126
- same live token counter, while the query may conservatively improve it by
127
- snipping or pruning immediately before the trigger. Reactive-compaction and
128
- context-collapse modes own their thresholds and therefore do not display a
129
- misleading proactive countdown. A successful compaction suppresses the stale
130
- pre-compact warning.
131
-
132
- Full, partial, and session-memory compaction restore the authoritative live
133
- task state after the boundary. Task V2 snapshots retain exact IDs, statuses,
134
- owners, and dependency edges; legacy TodoWrite snapshots retain order and
135
- status. The snapshot is bounded to 64 actionable-first records and an
136
- estimated 6,000-token budget. If more exist, the model is required to call
137
- `TaskList` before task mutation rather than guessing omitted IDs. Compact
138
- boundaries also permanently consume the task-gate's initial trivial-call
139
- allowance so compaction cannot reopen an implementation bypass.
140
-
141
- ## Repo wiki & map
142
-
143
- ```
144
- /wiki generate # .ur/wiki/: overview, architecture, dependency map (from DNA + code index)
145
- /wiki install-hook # refresh automatically after every merge
146
- /wiki map # regenerate .ur/repo-map.md
147
- ```
148
- When `.ur/repo-map.md` exists and is fresh (less than seven days), a byte-capped
149
- repo map is injected into the system prompt automatically (zero tokens until
150
- generated).
151
-
152
- ## Project DNA & indexes
153
-
154
- ```
155
- /dna # detect language, package manager, build/test/lint → .ur/dna
156
- /index # build workspace file index (.ur/index)
157
- /code-index build # semantic embeddings index — CodeSearch auto-enables once built
158
- /code-index watch # keep it fresh
159
- /code-index search "debounce input"
160
- ```
161
- `/project` and `/workspace` display the recorded DNA + workspace facts.
162
-
163
- ## What gets injected into the system prompt
164
-
165
- The interactive and print entrypoints both assemble the prompt through
166
- `src/constants/prompts.ts` plus the context helpers. A normal root prompt
167
- includes UR.md/UR.local.md instructions, auto-memory as described above, the
168
- active working-mode discipline, output style, enabled-tool guidance, and
169
- environment information. Read-only `Explore` and `Plan` subagents omit the
170
- UR.md hierarchy when the default-on `tengu_slim_subagent_agentmd` runtime gate
171
- is active and the caller did not explicitly supply user context. Project DNA
172
- is not injected directly; it can appear through a fresh generated repo map.
173
- `--bare` replaces the root prompt with a minimal prompt and drops automatic
174
- memory, hooks, and most extras. The internal `--dump-system-prompt` diagnostic
175
- exists only in ant builds.
@@ -1,211 +0,0 @@
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
- ```