@wrongstack/core 0.308.5 → 0.308.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.
@@ -1655,6 +1655,7 @@ var BUNDLED_AGENT_SKILLS = [
1655
1655
  var skillSet = (...names) => names;
1656
1656
  var ROLE_SKILL_SETS = {
1657
1657
  explore: skillSet("research-web", "node-modern", "typescript-strict"),
1658
+ "explore-companion": skillSet("node-modern", "typescript-strict"),
1658
1659
  search: skillSet("bug-hunter", "typescript-strict", "research-web"),
1659
1660
  research: skillSet("research-web", "tech-stack", "security-scanner", "api-design"),
1660
1661
  analyst: skillSet("sdd", "api-design", "testing", "security-scanner"),
@@ -19,6 +19,7 @@ export type BundledAgentSkill = (typeof BUNDLED_AGENT_SKILLS)[number];
19
19
  */
20
20
  export declare const ROLE_SKILL_SETS: {
21
21
  readonly explore: ("api-design" | "audit-log" | "bug-hunter" | "chimera" | "data-governance" | "docker-deploy" | "git-flow" | "mnemosyne" | "multi-agent" | "node-modern" | "observability" | "output-standards" | "plugin-author" | "prompt-engineering" | "react-modern" | "refactor-planner" | "research-web" | "sdd" | "security-scanner" | "skill-creator" | "tech-stack" | "testing" | "typescript-strict" | "wrongstack-mailbox")[];
22
+ readonly 'explore-companion': ("api-design" | "audit-log" | "bug-hunter" | "chimera" | "data-governance" | "docker-deploy" | "git-flow" | "mnemosyne" | "multi-agent" | "node-modern" | "observability" | "output-standards" | "plugin-author" | "prompt-engineering" | "react-modern" | "refactor-planner" | "research-web" | "sdd" | "security-scanner" | "skill-creator" | "tech-stack" | "testing" | "typescript-strict" | "wrongstack-mailbox")[];
22
23
  readonly search: ("api-design" | "audit-log" | "bug-hunter" | "chimera" | "data-governance" | "docker-deploy" | "git-flow" | "mnemosyne" | "multi-agent" | "node-modern" | "observability" | "output-standards" | "plugin-author" | "prompt-engineering" | "react-modern" | "refactor-planner" | "research-web" | "sdd" | "security-scanner" | "skill-creator" | "tech-stack" | "testing" | "typescript-strict" | "wrongstack-mailbox")[];
23
24
  readonly research: ("api-design" | "audit-log" | "bug-hunter" | "chimera" | "data-governance" | "docker-deploy" | "git-flow" | "mnemosyne" | "multi-agent" | "node-modern" | "observability" | "output-standards" | "plugin-author" | "prompt-engineering" | "react-modern" | "refactor-planner" | "research-web" | "sdd" | "security-scanner" | "skill-creator" | "tech-stack" | "testing" | "typescript-strict" | "wrongstack-mailbox")[];
24
25
  readonly analyst: ("api-design" | "audit-log" | "bug-hunter" | "chimera" | "data-governance" | "docker-deploy" | "git-flow" | "mnemosyne" | "multi-agent" | "node-modern" | "observability" | "output-standards" | "plugin-author" | "prompt-engineering" | "react-modern" | "refactor-planner" | "research-web" | "sdd" | "security-scanner" | "skill-creator" | "tech-stack" | "testing" | "typescript-strict" | "wrongstack-mailbox")[];
@@ -0,0 +1,191 @@
1
+ /**
2
+ * ExploreCompanion — state-triggered background codebase explorer.
3
+ *
4
+ * Runs behind a leader agent executing the main task. It watches the live
5
+ * EventBus for signals of the leader's IN-PROGRESS state and converts them
6
+ * into narrow, read-only exploration probes assigned to a resident
7
+ * `explore-companion` subagent (see docs/architecture/explore-companion-
8
+ * subagent.md). The companion never blocks the leader: probes are
9
+ * fire-and-forget (`onProbe` → spawn/assign), and findings travel back via
10
+ * mailbox `result`/`btw` messages that the mailbox loop folds into the
11
+ * leader's context before its next step.
12
+ *
13
+ * Watched signals (each independently toggleable):
14
+ * - edit on an unread file — the leader edits a path it never read;
15
+ * - zero-hit search — a search/grep returned no results;
16
+ * - unfamiliar read — the leader reads a path not yet probed;
17
+ * - todo flip — a leader todo transitions to in_progress
18
+ * (requires `leaderAgentId`);
19
+ * - error symbol — an `error` event names a file/symbol token;
20
+ * - mailbox ask — an `ask`/`assign` message from the leader addressed
21
+ * to the companion.
22
+ *
23
+ * Design lineage: BrainMonitor (watch bus → cooldown → engage, session
24
+ * filter, single engagement in flight, host-intent start/stop/reconfigure)
25
+ * generalized from "steer the leader" to "assign exploration probes".
26
+ *
27
+ * Non-interference guarantees (also pinned by tests):
28
+ * - never blocks the leader — onProbe is called without awaiting the
29
+ * resident's task completion;
30
+ * - one probe in flight, a capped pending queue with drop-oldest;
31
+ * - per-subject cooldown so a busy leader cannot stack probes on the
32
+ * same file/symbol;
33
+ * - subagent events are filtered out via the leader-session check;
34
+ * - probe failures are swallowed — the leader's work never breaks
35
+ * because the companion's spawn/assign rejected a probe.
36
+ *
37
+ * @module explore-companion
38
+ */
39
+ import type { EventBus } from '../kernel/events.js';
40
+ import { type Mailbox } from './mailbox-types.js';
41
+ /** Which observed work-state signal produced a probe. */
42
+ export type ExploreProbeSource = 'edit_unread_file' | 'search_zero_hits' | 'unfamiliar_read' | 'todo_in_progress' | 'error_symbol' | 'mailbox_ask';
43
+ /** A narrow exploration task scoped to the leader's current work. */
44
+ export interface ExploreProbe {
45
+ id: string;
46
+ /** Human-readable question for the companion agent. */
47
+ probe: string;
48
+ /** Optional file/symbol hint so the companion starts index-first. */
49
+ hint?: {
50
+ file?: string;
51
+ symbol?: string;
52
+ } | undefined;
53
+ /** What the leader was doing when the trigger fired. */
54
+ context?: string | undefined;
55
+ source: ExploreProbeSource;
56
+ /**
57
+ * Dedupe key (`file:<path>`, `search:<query>`, `token:<symbol>`,
58
+ * `todo:<id>`, `mail:<id>`). Probes with a subject probed within
59
+ * `cooldownMs` are skipped.
60
+ */
61
+ subject: string;
62
+ createdAt: number;
63
+ }
64
+ /** Per-signal kill switches. Omitted = enabled. */
65
+ export interface ExploreCompanionSignalToggles {
66
+ editUnreadFile?: boolean | undefined;
67
+ searchZeroHits?: boolean | undefined;
68
+ unfamiliarRead?: boolean | undefined;
69
+ todoInProgress?: boolean | undefined;
70
+ errorSymbol?: boolean | undefined;
71
+ mailboxAsk?: boolean | undefined;
72
+ }
73
+ export interface ExploreCompanionOptions {
74
+ /** Live bus the leader's tool/error/todo events fire on. */
75
+ events: EventBus;
76
+ /** Project mailbox the companion polls for explicit asks and acks them. */
77
+ mailbox: Mailbox;
78
+ /**
79
+ * Leader session id used to filter out subagent events. The companion
80
+ * subscribes to global events (tool.executed, error, session.agents_updated)
81
+ * which fire for BOTH the leader and subagents. When set, any event whose
82
+ * `sessionId` differs from this value is skipped. Events without a
83
+ * `sessionId` field always pass through (backward compatibility). Pass a
84
+ * lazy getter when the session id may change at runtime.
85
+ */
86
+ leaderSessionId: string | (() => string | undefined);
87
+ /**
88
+ * Leader agent id whose todo list is diffed for the todo-in-progress
89
+ * signal. Optional: when absent, the todo signal engages nothing (the
90
+ * `session.agents_updated` snapshot lists leader + subagents and only the
91
+ * leader's own todo flips should trigger probes).
92
+ */
93
+ leaderAgentId?: string | (() => string | undefined) | undefined;
94
+ /**
95
+ * Assign (or spawn) a probe on the resident companion. Called without
96
+ * awaiting the resident's task completion — the leader is never blocked.
97
+ */
98
+ onProbe: (probe: ExploreProbe) => Promise<{
99
+ subagentId: string;
100
+ taskId: string;
101
+ }>;
102
+ /** Mailbox identity of the companion; used to poll + ack asks. Default 'explore-companion'. */
103
+ companionAgentId?: string | undefined;
104
+ /** Minimum gap between probes on the same subject (ms). Default 120_000. */
105
+ cooldownMs?: number | undefined;
106
+ /** Cap on the pending probe queue; oldest dropped when full. Default 8. */
107
+ maxPending?: number | undefined;
108
+ /** Mailbox poll interval for explicit asks (ms). Default 5_000. */
109
+ pollIntervalMs?: number | undefined;
110
+ /** Master kill switch. Default true; false makes `start()` a no-op. */
111
+ enabled?: boolean | undefined;
112
+ /** Per-signal kill switches. Omitted signals stay enabled. */
113
+ signals?: ExploreCompanionSignalToggles | undefined;
114
+ /**
115
+ * Tool names whose successful execution counts as a file edit for the
116
+ * edit-unread-file signal. Replaces the built-in set; matched
117
+ * case-insensitively. Same contract as BrainMonitor.fileEditTools.
118
+ */
119
+ fileEditTools?: readonly string[] | undefined;
120
+ /**
121
+ * Tool names whose successful zero-result run fires the zero-hit signal.
122
+ * Replaces the built-in set; matched case-insensitively.
123
+ */
124
+ searchTools?: readonly string[] | undefined;
125
+ /** Injectable clock for tests. Default Date.now. */
126
+ now?: (() => number) | undefined;
127
+ }
128
+ /** The subset re-applicable to a running companion via `reconfigure()`. */
129
+ export type ExploreCompanionTunables = Partial<Pick<ExploreCompanionOptions, 'cooldownMs' | 'maxPending' | 'pollIntervalMs' | 'enabled' | 'signals' | 'fileEditTools' | 'searchTools' | 'companionAgentId'>>;
130
+ /** Mailbox identity the companion polls/acks under by default. */
131
+ export declare const DEFAULT_EXPLORE_COMPANION_AGENT_ID = "explore-companion";
132
+ /** Default per-subject probe cooldown (120s, same as BrainMonitor). */
133
+ export declare const DEFAULT_PROBE_COOLDOWN_MS = 120000;
134
+ /** Default pending probe queue cap. */
135
+ export declare const DEFAULT_MAX_PENDING_PROBES = 8;
136
+ /** Default mailbox poll interval for explicit asks. */
137
+ export declare const DEFAULT_MAILBOX_POLL_INTERVAL_MS = 5000;
138
+ /** Tools whose successful execution mutates a file we can treat as an edit. */
139
+ export declare const DEFAULT_EXPLORE_EDIT_TOOLS: readonly string[];
140
+ /** Tools whose successful zero-result run is a "search came up empty" signal. */
141
+ export declare const DEFAULT_EXPLORE_SEARCH_TOOLS: readonly string[];
142
+ /**
143
+ * Render a probe into the JSON task contract the `explore-companion` prompt
144
+ * accepts: `{ "probe", "hint", "context" }`. Hosts use this to build the
145
+ * subagent task text from a structured probe.
146
+ */
147
+ export declare function buildProbeTaskText(probe: ExploreProbe): string;
148
+ export declare class ExploreCompanion {
149
+ private readonly opts;
150
+ private readonly unsubscribers;
151
+ /** Paths the leader has read (readSet) — feeds edit-unread + unfamiliar-read. */
152
+ private readonly readSet;
153
+ /** subject → last probe time; cooldown gate. Survives detach/reconfigure. */
154
+ private readonly probedAt;
155
+ /** todo id → last observed status, per leader agent. */
156
+ private readonly todoSeen;
157
+ private readonly pending;
158
+ private inFlight;
159
+ private pollTimer;
160
+ private running;
161
+ private hostStarted;
162
+ private cfg;
163
+ constructor(opts: ExploreCompanionOptions);
164
+ private resolveConfig;
165
+ /** Resolve the leader's own session id for event filtering. */
166
+ private resolveLeaderSessionId;
167
+ /** Resolve the leader's agent id for todo diffing (optional signal). */
168
+ private resolveLeaderAgentId;
169
+ /** Re-apply tunables to a (possibly running) companion. */
170
+ reconfigure(next: ExploreCompanionTunables): boolean;
171
+ /** Begin watching. Idempotent; a disabled companion records intent only. */
172
+ start(): void;
173
+ /** Stop watching and drop the host's intent to watch. */
174
+ stop(): void;
175
+ /** True while the watchers are attached. */
176
+ isRunning(): boolean;
177
+ /** Number of probes queued but not yet dispatched (for status surfaces). */
178
+ pendingCount(): number;
179
+ private attach;
180
+ /** Tear down watchers without touching host intent. Cooldowns survive. */
181
+ private detach;
182
+ private trackToolExecuted;
183
+ private trackAgentTodos;
184
+ private trackError;
185
+ private pollMailbox;
186
+ private cooldownOk;
187
+ private now;
188
+ private engage;
189
+ private drain;
190
+ }
191
+ //# sourceMappingURL=explore-companion.d.ts.map
@@ -24,6 +24,20 @@ export declare const REFACTOR_PLANNER_AGENT: SubagentConfig;
24
24
  * Use for: CI checks, pre-release audits, dependency vulnerability scanning.
25
25
  */
26
26
  export declare const SECURITY_SCANNER_AGENT: SubagentConfig;
27
+ /**
28
+ * Explore Companion — state-triggered background codebase explorer.
29
+ * Runs behind a leader agent: triggered by the in-progress state of the
30
+ * work (unread-file edits, zero-hit searches, todo flips, explicit asks),
31
+ * scans the codebase read-only, and feeds findings back via mailbox
32
+ * `result`/`btw` + `submit_result`. See
33
+ * docs/architecture/explore-companion-subagent.md.
34
+ *
35
+ * Operational role — deliberately NOT in ALL_AGENT_DEFINITIONS (like
36
+ * `shadow-agent`), so the free-form dispatcher never routes to it and the
37
+ * 75-definition catalog count stays intact. Probes are assigned, never
38
+ * awaited; idle reaping comes from the FLEET_ROSTER_BUDGETS entry.
39
+ */
40
+ export declare const EXPLORE_COMPANION_AGENT: SubagentConfig;
27
41
  /** Generic template used directly or cloned into project-specific roles. */
28
42
  export declare const GENERIC_AGENT: SubagentConfig;
29
43
  export declare const FLEET_ROSTER: Record<string, SubagentConfig>;
@@ -9,6 +9,7 @@ export { BrainTraceRecorder, type BrainTraceRecorderOptions } from './brain-trac
9
9
  export { type BugFinding, type CollabBudgetConfig, type CollabBudgetOverrides, type CollabBudgetWarningPayload, type CollabDebugReport, CollabSession, type CollabSessionOptions, type CriticConcern, type CriticEvaluation, type DirectorAlert, DirectorAlertLevel, type DirectorCancelCollabPayload, type RefactorPhase, type RefactorPlan, type SharedFileEntry, type SharedFileSnapshot, } from './collab-debug.js';
10
10
  export { assessCommitSafety, type CommitSafetyOptions, type CommitSafetyReport, } from './commit-safety.js';
11
11
  export { type CreateDelegateToolOptions, createDelegateTool, type DelegateHost, } from './delegate-tool.js';
12
+ export { buildProbeTaskText, DEFAULT_EXPLORE_COMPANION_AGENT_ID, DEFAULT_EXPLORE_EDIT_TOOLS, DEFAULT_EXPLORE_SEARCH_TOOLS, DEFAULT_MAILBOX_POLL_INTERVAL_MS, DEFAULT_MAX_PENDING_PROBES, DEFAULT_PROBE_COOLDOWN_MS, ExploreCompanion, type ExploreCompanionOptions, type ExploreCompanionSignalToggles, type ExploreCompanionTunables, type ExploreProbe, type ExploreProbeSource, } from './explore-companion.js';
12
13
  export { DEPENDENCY_FILE_PATTERNS, type DependencyWatcherConfig, type DepWatchEntry, makeDependencyWatcherConfig, } from './dep-watcher.js';
13
14
  export { attachDepWatcherBridge, type DepWatcherBridgeOptions, } from './dep-watcher-bridge.js';
14
15
  export { Director, FleetCostCapError, FleetSpawnBudgetError, FleetTokenCapError, type TaskResultNotification, } from './director.js';