@dreb/coding-agent 2.30.1 → 2.31.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.
package/README.md CHANGED
@@ -288,6 +288,17 @@ dreb loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
288
288
 
289
289
  Use for project instructions, conventions, common commands. All matching files are concatenated.
290
290
 
291
+ ### Nested context auto-load
292
+
293
+ 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
+
295
+ - Triggers on path-bearing tools (`read`, `edit`, `write`, `grep`, `find`, `ls`) and on `bash` commands that begin with `cd <dir>`.
296
+ - 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.
297
+ - 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.
298
+ - Disable with `context.autoLoadNested: false` in settings, or toggle "Auto-load nested context" in `/settings`.
299
+
300
+ **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.
301
+
291
302
  ### System Prompt
292
303
 
293
304
  Replace the default system prompt with `.dreb/SYSTEM.md` (project) or `~/.dreb/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
@@ -185,6 +185,14 @@ export declare class AgentSession {
185
185
  private _customTools;
186
186
  private _baseToolDefinitions;
187
187
  private _cwd;
188
+ /**
189
+ * Per-session realpaths of context files already loaded (seeded lazily from the
190
+ * session-start context set). Ensures each nested AGENTS.md/CLAUDE.md is injected
191
+ * at most once. `undefined` until first use.
192
+ */
193
+ private _nestedContextLoaded;
194
+ /** Negative cache of target directories already scanned for nested context. */
195
+ private _nestedContextScannedDirs;
188
196
  private _extensionRunnerRef?;
189
197
  private _initialActiveToolNames?;
190
198
  private _baseToolsOverride?;
@@ -223,6 +231,14 @@ export declare class AgentSession {
223
231
  * happens here instead of in wrappers.
224
232
  */
225
233
  private _installAgentToolHooks;
234
+ /**
235
+ * Compute a nested-context injection block for a tool call, or `null` when nothing
236
+ * should be injected. Resolves the directory the tool operates in, walks up to a
237
+ * sensible ceiling collecting not-yet-loaded AGENTS.md/CLAUDE.md files, and formats
238
+ * them. Each directory is scanned at most once (negative cache) and each file is
239
+ * injected at most once per session (realpath dedup). Gated by `context.autoLoadNested`.
240
+ */
241
+ private _computeNestedContextBlock;
226
242
  /**
227
243
  * Install guardrails for background agent interactions:
228
244
  * - Layer B: Sentinel monitor — steer if the parent model generates suspicious tokens