@dreb/coding-agent 2.40.2 → 2.41.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.
Files changed (45) hide show
  1. package/README.md +20 -7
  2. package/dist/core/agent-session.d.ts +2 -1
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +8 -4
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/context-trust.d.ts +44 -0
  7. package/dist/core/context-trust.d.ts.map +1 -0
  8. package/dist/core/context-trust.js +117 -0
  9. package/dist/core/context-trust.js.map +1 -0
  10. package/dist/core/nested-context.d.ts +4 -3
  11. package/dist/core/nested-context.d.ts.map +1 -1
  12. package/dist/core/nested-context.js +34 -9
  13. package/dist/core/nested-context.js.map +1 -1
  14. package/dist/core/resource-loader.d.ts +3 -1
  15. package/dist/core/resource-loader.d.ts.map +1 -1
  16. package/dist/core/resource-loader.js +29 -11
  17. package/dist/core/resource-loader.js.map +1 -1
  18. package/dist/core/settings-manager.d.ts +36 -2
  19. package/dist/core/settings-manager.d.ts.map +1 -1
  20. package/dist/core/settings-manager.js +157 -6
  21. package/dist/core/settings-manager.js.map +1 -1
  22. package/dist/modes/index.d.ts +1 -1
  23. package/dist/modes/index.d.ts.map +1 -1
  24. package/dist/modes/index.js.map +1 -1
  25. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  26. package/dist/modes/interactive/components/settings-selector.js +2 -2
  27. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  28. package/dist/modes/rpc/index.d.ts +1 -1
  29. package/dist/modes/rpc/index.d.ts.map +1 -1
  30. package/dist/modes/rpc/index.js.map +1 -1
  31. package/dist/modes/rpc/rpc-client.d.ts +9 -1
  32. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  33. package/dist/modes/rpc/rpc-client.js +20 -0
  34. package/dist/modes/rpc/rpc-client.js.map +1 -1
  35. package/dist/modes/rpc/rpc-mode.d.ts +38 -5
  36. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  37. package/dist/modes/rpc/rpc-mode.js +266 -61
  38. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  39. package/dist/modes/rpc/rpc-types.d.ts +73 -2
  40. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  41. package/dist/modes/rpc/rpc-types.js.map +1 -1
  42. package/docs/dashboard.md +10 -2
  43. package/docs/rpc.md +159 -8
  44. package/docs/settings.md +32 -5
  45. package/package.json +1 -1
package/README.md CHANGED
@@ -289,16 +289,29 @@ dreb loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
289
289
 
290
290
  Use for project instructions, conventions, common commands. All matching files are concatenated.
291
291
 
292
- ### Nested context auto-load
292
+ ### Nested context trust
293
293
 
294
- The startup scan only walks **upward** from cwd, so an `AGENTS.md`/`CLAUDE.md` that lives in a **subdirectory** (e.g. a monorepo subpackage) is not loaded until the agent actually works there. When `context.autoLoadNested` is enabled (default), the first time any tool operates in a directory, dreb loads that directory's context files and appends them to the tool result explaining why the load happened and headering each file with its source path.
294
+ At startup, dreb **always** performs a separate upward scan from its launch cwd and loads matching `AGENTS.md`/`CLAUDE.md` files there and in parent directories. That initial scan is not lazy nested loading and is **not** controlled by the settings below. A context file in a subdirectory or in a different repo an agent later visitsis considered only when a tool operates there.
295
295
 
296
- - Triggers on path-bearing tools (`read`, `edit`, `write`, `grep`, `find`, `ls`) and on `bash` commands that begin with `cd <dir>`.
297
- - Walks up from the target directory to a sensible ceiling: the session cwd (for in-tree targets), otherwise the outermost git repo root, otherwise the outermost directory containing a context file.
298
- - Each file is injected at most once per session, and files already loaded at startup are never repeated. Applies to subagents too — including subagents that work in a different repo than the parent.
299
- - Disable with `context.autoLoadNested: false` in settings, or toggle "Auto-load nested context" in `/settings`.
296
+ Lazy nested/out-of-cwd context loading is **off by default**. Configure explicit global trusted roots in `~/.dreb/agent/settings.json`:
300
297
 
301
- **Security caution:** when working across untrusted or third-party repositories, their `AGENTS.md`/`CLAUDE.md` files may be auto-injected into the agent's context, which is a prompt-injection consideration. Auto-loaded content is secret-scrubbed before injection, but extension `tool_result` transforms do not see it because nested context is injected after those transforms for cache safety.
298
+ ```json
299
+ {
300
+ "context": {
301
+ "trustedFolders": ["~/src/my-company", "/srv/controlled-repos"]
302
+ }
303
+ }
304
+ ```
305
+
306
+ A trusted root permits lazy loading for that existing directory and all of its descendants. dreb resolves both the root and each tool target through canonical native `realpath` at decision time: relative, missing, non-directory, and broken-symlink roots fail closed; duplicate and nested roots are deduplicated/subsumed. A lexical descendant that symlinks outside the canonical root is therefore **not** trusted. Project `.dreb/settings.json` cannot add, override, or otherwise widen this policy.
307
+
308
+ - Lazy loading triggers on path-bearing tools (`read`, `edit`, `write`, `grep`, `find`, `ls`) and on `bash` commands that begin with `cd <dir>`.
309
+ - It walks from the target toward the applicable ceiling. A trusted root is a hard ceiling; otherwise the session cwd is used for in-tree targets, then the outermost git repo root, then the outermost directory containing a context file.
310
+ - Each file is injected at most once per session, including files from the initial upward scan. The paths are realpath-deduplicated. If a triggering `read` or full `cat`/`bat` already returns a context file in full, dreb marks it loaded without adding a duplicate block.
311
+ - Auto-loaded text is secret-scrubbed and appended **after** extension `tool_result` transforms, so those transforms intentionally do not see it.
312
+ - Main agents and subagents make the same global trust decision. Global trust changes are observed by active processes for **future** lazy loads; already injected content cannot be removed from their conversation.
313
+
314
+ **Expert trust-all override — prompt-injection warning:** setting `context.autoLoadNested: true` in the **global** `~/.dreb/agent/settings.json` allows lazy loading from any resolvable tool target. This can inject instructions from untrusted or third-party repositories. It is global-only; a project `.dreb/settings.json` cannot enable it. Leave it off and trust only folders you control whenever possible. The Files view shows the effective trust for the directory being viewed and lets you trust a folder or untrust the actual granting root; untrusting an inherited folder removes that root's trust for all of its descendants.
302
315
 
303
316
  ### System Prompt
304
317
 
@@ -253,7 +253,8 @@ export declare class AgentSession {
253
253
  * should be injected. Resolves the directory the tool operates in, walks up to a
254
254
  * sensible ceiling collecting not-yet-loaded AGENTS.md/CLAUDE.md files, and formats
255
255
  * them. Each directory is scanned at most once (negative cache) and each file is
256
- * injected at most once per session (realpath dedup). Gated by `context.autoLoadNested`.
256
+ * injected at most once per session (realpath dedup). Every decision consumes the
257
+ * refreshed global-only trust policy; absent settings managers fail closed.
257
258
  */
258
259
  private _computeNestedContextBlock;
259
260
  /**