@wrongstack/core 0.31.1 → 0.32.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.
@@ -194,6 +194,20 @@ interface CollabSessionOptions {
194
194
  prebuiltSnapshot?: SharedFileSnapshot;
195
195
  /** Max time to wait for the session to resolve (ms). Default: 10 min. */
196
196
  timeoutMs?: number;
197
+ /**
198
+ * Maximum number of files to include in the snapshot.
199
+ * - If set explicitly: use this value (hard override).
200
+ * - If `contextWindow` is set: calculate dynamically from estimated token budget.
201
+ * - If neither: use `DEFAULT_MAX_TARGET_FILES` (30).
202
+ */
203
+ maxTargetFiles?: number;
204
+ /**
205
+ * Context window size (in tokens) of the model running the subagents.
206
+ * When provided and `maxTargetFiles` is not set, the limit is computed
207
+ * dynamically: `floor((contextWindow * 0.4) / AVG_TOKENS_PER_FILE)`.
208
+ * If not provided, `DEFAULT_MAX_TARGET_FILES` is used as the fallback.
209
+ */
210
+ contextWindow?: number;
197
211
  /**
198
212
  * Budget overrides per role. When provided, these override the hard-coded
199
213
  * defaults so the Director can enforce fleet-wide budget policy.
@@ -240,6 +254,11 @@ declare class CollabSession extends EventEmitter {
240
254
  * all three collab agents.
241
255
  */
242
256
  getSubagentIds(): ReadonlyMap<string, string>;
257
+ /**
258
+ * Returns the effective file limit for this session.
259
+ * Priority: explicit `maxTargetFiles` > dynamic from `contextWindow` > `DEFAULT_MAX_TARGET_FILES`.
260
+ */
261
+ effectiveFileLimit(): number;
243
262
  buildSnapshot(): Promise<SharedFileSnapshot>;
244
263
  /**
245
264
  * Cancel the session. Emits director.cancel_collab on the FleetBus so all
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/core",
3
- "version": "0.31.1",
3
+ "version": "0.32.0",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack core: kernel, types, defaults, and shared utilities for the WrongStack CLI agent.",
6
6
  "repository": {
@@ -130,4 +130,60 @@ Subagents share **nothing** — no memory, no session state, no variable scope.
130
130
  - `bug-hunter` — parallel file audits
131
131
  - `security-scanner` — parallel security scans
132
132
  - `refactor-planner` — parallel module analysis
133
- - `audit-log` — aggregating multiple session analyses
133
+ - `audit-log` — aggregating multiple session analyses
134
+
135
+ ---
136
+
137
+ ## collab_debug — Three-Agent Parallel Code Review
138
+
139
+ `collab_debug` runs **BugHunter + RefactorPlanner + Critic** simultaneously on the same file snapshot. All three agents receive the full target context, so the number of files must be kept small.
140
+
141
+ ### Target size limit: dynamic, defaults to 30
142
+
143
+ The file limit is computed in this priority order:
144
+
145
+ 1. **`maxTargetFiles`** — explicit override if provided
146
+ 2. **`contextWindow`** — dynamic calculation: `floor((contextWindow × 0.4) / 2000)`
147
+ 3. **`DEFAULT_MAX_TARGET_FILES = 30`** — fallback when neither is set
148
+
149
+ Each of the three agents gets the entire file snapshot as context. With 3 agents × N files, large targets cause:
150
+ - **Token overflow** — context window exhausted
151
+ - **Timeout failures** — session times out before agents finish
152
+ - **Budget exhaustion** — each agent burns through iterations with no progress
153
+
154
+ | contextWindow (tokens) | Calculated limit | Interpretation |
155
+ |---|---|---|
156
+ | 200_000 (large model) | 40 files | ~20-30 recommended |
157
+ | 100_000 (typical) | 20 files | ✅ Comfortable |
158
+ | 32_768 (small) | 6 files | ⚠️ Very limited |
159
+ | not provided | 30 files (default) | Safe baseline |
160
+
161
+ The session throws a clear error if the resolved file count exceeds the effective limit.
162
+
163
+ ### Correct usage
164
+
165
+ ```js
166
+ // ✅ Good — single package, limited files
167
+ collab_debug(["packages/core/src/agents/**/*.ts"])
168
+
169
+ // ✅ Dynamic — limit computed from contextWindow
170
+ collab_debug({
171
+ // ✅ Explicit — override limit directly
172
+ collab_debug({
173
+ targetPaths: ["packages/core/src/**/*.ts"],
174
+ maxTargetFiles: 15,
175
+ })
176
+
177
+ // ✅ Dynamic — limit computed from contextWindow
178
+ collab_debug({
179
+ targetPaths: ["packages/core/src/**/*.ts"],
180
+ contextWindow: 100_000, // → limit = floor(100000 * 0.4 / 2000) = 20
181
+ })
182
+
183
+ // ❌ Bad — entire monorepo
184
+ collab_debug(["packages/**/src/**/*.ts"])
185
+ ```
186
+
187
+ ### For large codebases
188
+
189
+ Run **package-by-package** or **module-by-module** sessions. Target only the area under review, not the whole repo.