sentinelayer-cli 0.6.2 → 0.8.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 (159) hide show
  1. package/README.md +996 -996
  2. package/bin/create-sentinelayer.js +5 -5
  3. package/bin/sentinelayer-cli.js +4 -4
  4. package/bin/sl.js +5 -5
  5. package/package.json +64 -63
  6. package/src/agents/jules/config/definition.js +160 -160
  7. package/src/agents/jules/config/system-prompt.js +182 -182
  8. package/src/agents/jules/error-intake.js +51 -51
  9. package/src/agents/jules/fix-cycle.js +17 -17
  10. package/src/agents/jules/loop.js +457 -450
  11. package/src/agents/jules/pulse.js +10 -10
  12. package/src/agents/jules/stream.js +187 -186
  13. package/src/agents/jules/swarm/file-scanner.js +74 -74
  14. package/src/agents/jules/swarm/index.js +11 -11
  15. package/src/agents/jules/swarm/orchestrator.js +362 -362
  16. package/src/agents/jules/swarm/pattern-hunter.js +123 -123
  17. package/src/agents/jules/swarm/sub-agent.js +311 -309
  18. package/src/agents/jules/tools/aidenid-email.js +189 -189
  19. package/src/agents/jules/tools/auth-audit.js +1699 -1691
  20. package/src/agents/jules/tools/dispatch.js +340 -335
  21. package/src/agents/jules/tools/file-edit.js +2 -2
  22. package/src/agents/jules/tools/file-read.js +2 -2
  23. package/src/agents/jules/tools/frontend-analyze.js +570 -570
  24. package/src/agents/jules/tools/glob.js +2 -2
  25. package/src/agents/jules/tools/grep.js +2 -2
  26. package/src/agents/jules/tools/index.js +29 -29
  27. package/src/agents/jules/tools/path-guards.js +2 -2
  28. package/src/agents/jules/tools/runtime-audit.js +507 -507
  29. package/src/agents/jules/tools/shell.js +2 -2
  30. package/src/agents/jules/tools/url-policy.js +100 -100
  31. package/src/agents/persona-visuals.js +64 -61
  32. package/src/agents/shared-tools/dispatch-core.js +320 -315
  33. package/src/agents/shared-tools/file-edit.js +180 -180
  34. package/src/agents/shared-tools/file-read.js +100 -100
  35. package/src/agents/shared-tools/glob.js +168 -168
  36. package/src/agents/shared-tools/grep.js +228 -228
  37. package/src/agents/shared-tools/index.js +46 -46
  38. package/src/agents/shared-tools/path-guards.js +161 -161
  39. package/src/agents/shared-tools/shell.js +383 -383
  40. package/src/ai/aidenid.js +1021 -1009
  41. package/src/ai/client.js +553 -553
  42. package/src/ai/domain-target-store.js +268 -268
  43. package/src/ai/identity-store.js +270 -270
  44. package/src/ai/proxy.js +137 -137
  45. package/src/ai/site-store.js +145 -145
  46. package/src/audit/agents/architecture.js +180 -180
  47. package/src/audit/agents/compliance.js +179 -179
  48. package/src/audit/agents/documentation.js +165 -165
  49. package/src/audit/agents/performance.js +145 -145
  50. package/src/audit/agents/security.js +215 -215
  51. package/src/audit/agents/testing.js +172 -172
  52. package/src/audit/orchestrator.js +557 -557
  53. package/src/audit/package.js +204 -204
  54. package/src/audit/registry.js +284 -284
  55. package/src/audit/replay.js +103 -103
  56. package/src/auth/gate.js +400 -371
  57. package/src/auth/http.js +681 -611
  58. package/src/auth/service.js +1106 -1106
  59. package/src/auth/session-store.js +813 -813
  60. package/src/cli.js +257 -252
  61. package/src/commands/ai/identity-lifecycle.js +1338 -1338
  62. package/src/commands/ai/provision-governance.js +1272 -1272
  63. package/src/commands/ai/shared.js +147 -147
  64. package/src/commands/ai.js +11 -11
  65. package/src/commands/apply.js +12 -12
  66. package/src/commands/audit.js +1171 -1166
  67. package/src/commands/auth.js +419 -419
  68. package/src/commands/chat.js +191 -191
  69. package/src/commands/config.js +184 -184
  70. package/src/commands/cost.js +311 -311
  71. package/src/commands/daemon/core.js +850 -850
  72. package/src/commands/daemon/extended.js +1048 -1048
  73. package/src/commands/daemon/shared.js +213 -213
  74. package/src/commands/daemon.js +11 -11
  75. package/src/commands/guide.js +174 -174
  76. package/src/commands/ingest.js +58 -58
  77. package/src/commands/init.js +55 -55
  78. package/src/commands/legacy-args.js +10 -10
  79. package/src/commands/mcp.js +461 -461
  80. package/src/commands/omargate.js +29 -29
  81. package/src/commands/persona.js +20 -20
  82. package/src/commands/plugin.js +260 -260
  83. package/src/commands/policy.js +132 -132
  84. package/src/commands/prompt.js +238 -238
  85. package/src/commands/review.js +704 -704
  86. package/src/commands/scan.js +872 -872
  87. package/src/commands/session.js +590 -0
  88. package/src/commands/spec.js +778 -716
  89. package/src/commands/swarm.js +651 -651
  90. package/src/commands/telemetry.js +202 -202
  91. package/src/commands/watch.js +511 -511
  92. package/src/config/agent-dictionary.js +182 -182
  93. package/src/config/io.js +56 -56
  94. package/src/config/paths.js +18 -18
  95. package/src/config/schema.js +55 -55
  96. package/src/config/service.js +184 -184
  97. package/src/cost/budget.js +235 -235
  98. package/src/cost/history.js +188 -188
  99. package/src/cost/tracker.js +171 -171
  100. package/src/daemon/artifact-lineage.js +534 -534
  101. package/src/daemon/assignment-ledger.js +966 -770
  102. package/src/daemon/ast-parser-layer.js +258 -258
  103. package/src/daemon/budget-governor.js +633 -633
  104. package/src/daemon/callgraph-overlay.js +646 -646
  105. package/src/daemon/error-worker.js +1209 -626
  106. package/src/daemon/fix-cycle.js +384 -377
  107. package/src/daemon/hybrid-mapper.js +929 -929
  108. package/src/daemon/ingest-refresh.js +10 -9
  109. package/src/daemon/jira-lifecycle.js +767 -632
  110. package/src/daemon/operator-control.js +657 -657
  111. package/src/daemon/pulse.js +327 -327
  112. package/src/daemon/reliability-lane.js +471 -471
  113. package/src/daemon/scope-engine.js +1068 -0
  114. package/src/daemon/watchdog.js +971 -971
  115. package/src/events/schema.js +190 -0
  116. package/src/guide/generator.js +316 -316
  117. package/src/ingest/engine.js +918 -918
  118. package/src/interactive/index.js +97 -97
  119. package/src/legacy-cli.js +3161 -2994
  120. package/src/mcp/registry.js +695 -695
  121. package/src/memory/blackboard.js +301 -301
  122. package/src/memory/retrieval.js +581 -581
  123. package/src/plugin/manifest.js +553 -553
  124. package/src/policy/packs.js +144 -144
  125. package/src/prompt/generator.js +136 -118
  126. package/src/review/ai-review.js +679 -679
  127. package/src/review/local-review.js +1351 -1305
  128. package/src/review/omargate-interactive.js +68 -68
  129. package/src/review/omargate-orchestrator.js +404 -300
  130. package/src/review/persona-prompts.js +296 -296
  131. package/src/review/replay.js +235 -235
  132. package/src/review/report.js +664 -664
  133. package/src/review/scan-modes.js +48 -42
  134. package/src/review/spec-binding.js +487 -487
  135. package/src/scaffold/generator.js +67 -67
  136. package/src/scaffold/templates.js +150 -150
  137. package/src/scan/generator.js +418 -418
  138. package/src/scan/gh-secrets.js +107 -107
  139. package/src/session/agent-registry.js +352 -0
  140. package/src/session/daemon.js +801 -0
  141. package/src/session/paths.js +33 -0
  142. package/src/session/runtime-bridge.js +739 -0
  143. package/src/session/store.js +388 -0
  144. package/src/session/stream.js +325 -0
  145. package/src/spec/generator.js +619 -519
  146. package/src/spec/regenerate.js +237 -237
  147. package/src/spec/templates.js +91 -91
  148. package/src/swarm/dashboard.js +247 -247
  149. package/src/swarm/factory.js +363 -363
  150. package/src/swarm/pentest.js +934 -934
  151. package/src/swarm/registry.js +419 -419
  152. package/src/swarm/report.js +158 -158
  153. package/src/swarm/runtime.js +576 -576
  154. package/src/swarm/scenario-dsl.js +272 -272
  155. package/src/telemetry/ledger.js +302 -302
  156. package/src/telemetry/session-tracker.js +234 -234
  157. package/src/telemetry/sync.js +203 -203
  158. package/src/ui/command-hints.js +13 -13
  159. package/src/ui/markdown.js +220 -220
@@ -1,10 +1,10 @@
1
- // Re-export from platform daemon. Pulse is not Jules-specific.
2
- export {
3
- detectStuckState,
4
- determineRecoveryAction,
5
- routeErrorToPersona,
6
- buildAlertPayload,
7
- buildHealthSummary,
8
- sendAlert,
9
- STUCK_THRESHOLDS,
10
- } from "../../daemon/pulse.js";
1
+ // Re-export from platform daemon. Pulse is not Jules-specific.
2
+ export {
3
+ detectStuckState,
4
+ determineRecoveryAction,
5
+ routeErrorToPersona,
6
+ buildAlertPayload,
7
+ buildHealthSummary,
8
+ sendAlert,
9
+ STUCK_THRESHOLDS,
10
+ } from "../../daemon/pulse.js";
@@ -1,186 +1,187 @@
1
- import { PERSONA_VISUALS, resolvePersonaVisual } from "./config/definition.js";
2
-
3
- /**
4
- * Jules Tanaka — Streaming Event Formatter
5
- *
6
- * Formats NDJSON events for external agent consumption and terminal display.
7
- * Universal envelope: every event carries agent identity, usage snapshot, timestamp.
8
- */
9
-
10
- const SCHEMA_VERSION = 1;
11
-
12
- /**
13
- * Build an NDJSON event envelope.
14
- *
15
- * @param {string} event - Event type (agent_start, tool_call, finding, heartbeat, etc.)
16
- * @param {object} agentIdentity - { id, persona, color?, avatar? }
17
- * @param {object} payload - Event-specific data
18
- * @param {object} [usage] - Running usage totals
19
- * @param {string} [runId] - Run identifier
20
- * @returns {object} Complete event envelope
21
- */
22
- export function buildStreamEvent(event, agentIdentity, payload, usage, runId) {
23
- const visual = resolvePersonaVisual(agentIdentity?.id) || {};
24
- return {
25
- stream: "sl_event",
26
- version: SCHEMA_VERSION,
27
- command: "audit.deep",
28
- runId: runId || null,
29
- timestamp: new Date().toISOString(),
30
- agent: {
31
- id: agentIdentity?.id || "unknown",
32
- persona: agentIdentity?.persona || visual.fullName || "unknown",
33
- color: agentIdentity?.color || visual.color || "white",
34
- avatar: agentIdentity?.avatar || visual.avatar || "",
35
- },
36
- event,
37
- payload: payload || {},
38
- usage: usage || {},
39
- };
40
- }
41
-
42
- /**
43
- * Create a streaming emitter bound to a specific agent and run.
44
- *
45
- * @param {object} config
46
- * @param {object} config.agentIdentity - { id, persona }
47
- * @param {string} config.runId
48
- * @param {function} [config.onEvent] - Callback for each event
49
- * @param {boolean} [config.stdoutNdjson] - Also write to stdout as NDJSON
50
- * @returns {{ emit(event, payload, usage), close() }}
51
- */
52
- export function createStreamEmitter({ agentIdentity, runId, onEvent, stdoutNdjson = false }) {
53
- let closed = false;
54
- const usageRef = { costUsd: 0, outputTokens: 0, toolCalls: 0, durationMs: 0 };
55
-
56
- return {
57
- /**
58
- * Emit a streaming event.
59
- */
60
- emit(event, payload, usage) {
61
- if (closed) return;
62
- const merged = { ...usageRef, ...usage };
63
- Object.assign(usageRef, merged);
64
- const evt = buildStreamEvent(event, agentIdentity, payload, merged, runId);
65
- if (onEvent) onEvent(evt);
66
- if (stdoutNdjson) console.log(JSON.stringify(evt));
67
- return evt;
68
- },
69
-
70
- /**
71
- * Update accumulated usage without emitting.
72
- */
73
- updateUsage(delta) {
74
- if (delta.costUsd !== undefined) usageRef.costUsd = delta.costUsd;
75
- if (delta.outputTokens !== undefined) usageRef.outputTokens = delta.outputTokens;
76
- if (delta.toolCalls !== undefined) usageRef.toolCalls = delta.toolCalls;
77
- if (delta.durationMs !== undefined) usageRef.durationMs = delta.durationMs;
78
- },
79
-
80
- /**
81
- * Mark emitter as closed (no more events).
82
- */
83
- close() {
84
- closed = true;
85
- },
86
-
87
- /**
88
- * Get current usage snapshot.
89
- */
90
- getUsage() {
91
- return { ...usageRef };
92
- },
93
- };
94
- }
95
-
96
- /**
97
- * Format a terminal display line for a persona event (non-JSON mode).
98
- *
99
- * @param {object} evt - Stream event
100
- * @returns {string} Formatted line for stderr
101
- */
102
- export function formatTerminalLine(evt) {
103
- const agent = evt.agent || {};
104
- const avatar = agent.avatar || "";
105
- const name = agent.persona || agent.id || "Agent";
106
- const p = evt.payload || {};
107
-
108
- switch (evt.event) {
109
- case "agent_start":
110
- return `${avatar} ${name} starting (mode: ${p.mode || "primary"})...`;
111
-
112
- case "progress":
113
- return `${avatar} ${name}: ${p.message || p.phase || "working..."}`;
114
-
115
- case "tool_call":
116
- return `${avatar} ${name} [${p.tool}] ${formatToolInput(p.input)}`;
117
-
118
- case "tool_result":
119
- return `${avatar} ${name} [${p.tool}] ${p.durationMs || 0}ms ${p.success === false ? "FAILED" : "ok"}`;
120
-
121
- case "finding": {
122
- const sev = p.severity || "P3";
123
- const sevColor = sev === "P0" ? "!!!" : sev === "P1" ? "!!" : sev === "P2" ? "!" : "";
124
- return `${avatar} [${sev}${sevColor}] ${p.file || ""}:${p.line || ""} ${p.title || ""}`;
125
- }
126
-
127
- case "reasoning":
128
- return `${avatar} ${name}: ${(p.summary || "").slice(0, 120)}`;
129
-
130
- case "heartbeat": {
131
- const h = p;
132
- const budgetPct = h.budgetRemaining?.pct?.toFixed(0) || "?";
133
- return `${avatar} ${name} [${h.turnsCompleted || 0}/${h.turnsMax || "?"} turns, ${budgetPct}% budget, ${h.findingsSoFar || 0} findings]`;
134
- }
135
-
136
- case "budget_warning":
137
- return `${avatar} ${name} BUDGET WARNING: ${(p.warnings || []).map(w => w.code).join(", ")}`;
138
-
139
- case "budget_stop":
140
- return `${avatar} ${name} BUDGET STOP: ${(p.reasons || []).map(r => r.code || r).join(", ")}`;
141
-
142
- case "swarm_start":
143
- return `${avatar} ${name} spawning sub-agents (${p.scannerCount || 0} scanners, ${p.hunterCount || 0} hunters)...`;
144
-
145
- case "swarm_complete":
146
- return `${avatar} ${name} swarm complete: ${p.totalFindings || 0} findings from ${p.totalAgents || 0} agents ($${(p.totalCostUsd || 0).toFixed(2)})`;
147
-
148
- case "phase_start":
149
- return `${avatar} ${name} phase: ${p.phase || "unknown"}`;
150
-
151
- case "agent_complete": {
152
- const s = p;
153
- return `${avatar} ${name} complete: ${s.total || 0} findings (P0=${s.P0 || 0} P1=${s.P1 || 0} P2=${s.P2 || 0}) $${(s.costUsd || 0).toFixed(2)} ${s.durationMs ? (s.durationMs / 1000).toFixed(1) + "s" : ""}`;
154
- }
155
-
156
- case "agent_abort":
157
- return `${avatar} ${name} ABORTED: ${p.reason || "unknown"}`;
158
-
159
- default:
160
- return `${avatar} ${name} [${evt.event}]`;
161
- }
162
- }
163
-
164
- function formatToolInput(input) {
165
- if (!input) return "";
166
- if (input.file_path) return input.file_path;
167
- if (input.pattern) return `/${input.pattern}/`;
168
- if (input.operation) return input.operation;
169
- if (input.command) return input.command.slice(0, 60);
170
- return "";
171
- }
172
-
173
- /**
174
- * List all valid event types.
175
- */
176
- export const EVENT_TYPES = Object.freeze([
177
- "agent_start", "agent_complete", "agent_abort", "agent_error",
178
- "progress", "heartbeat",
179
- "tool_call", "tool_result",
180
- "finding", "reasoning",
181
- "budget_warning", "budget_stop",
182
- "swarm_start", "swarm_complete",
183
- "phase_start", "phase_complete",
184
- "convergence_expansion", "coverage_gap",
185
- "llm_error",
186
- ]);
1
+ import { PERSONA_VISUALS, resolvePersonaVisual } from "./config/definition.js";
2
+ import { createAgentEvent } from "../../events/schema.js";
3
+
4
+ /**
5
+ * Jules Tanaka — Streaming Event Formatter
6
+ *
7
+ * Formats NDJSON events for external agent consumption and terminal display.
8
+ * Universal envelope: every event carries agent identity, usage snapshot, timestamp.
9
+ */
10
+
11
+ const SCHEMA_VERSION = 1;
12
+
13
+ /**
14
+ * Build an NDJSON event envelope.
15
+ *
16
+ * @param {string} event - Event type (agent_start, tool_call, finding, heartbeat, etc.)
17
+ * @param {object} agentIdentity - { id, persona, color?, avatar? }
18
+ * @param {object} payload - Event-specific data
19
+ * @param {object} [usage] - Running usage totals
20
+ * @param {string} [runId] - Run identifier
21
+ * @returns {object} Complete event envelope
22
+ */
23
+ export function buildStreamEvent(event, agentIdentity, payload, usage, runId) {
24
+ const visual = resolvePersonaVisual(agentIdentity?.id) || {};
25
+ return {
26
+ ...createAgentEvent({
27
+ event,
28
+ agent: {
29
+ id: agentIdentity?.id || "unknown",
30
+ persona: agentIdentity?.persona || visual.fullName || "unknown",
31
+ color: agentIdentity?.color || visual.color || "white",
32
+ avatar: agentIdentity?.avatar || visual.avatar || "",
33
+ },
34
+ payload: payload || {},
35
+ usage: usage || {},
36
+ runId: runId || undefined,
37
+ }),
38
+ version: SCHEMA_VERSION,
39
+ command: "audit.deep",
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Create a streaming emitter bound to a specific agent and run.
45
+ *
46
+ * @param {object} config
47
+ * @param {object} config.agentIdentity - { id, persona }
48
+ * @param {string} config.runId
49
+ * @param {function} [config.onEvent] - Callback for each event
50
+ * @param {boolean} [config.stdoutNdjson] - Also write to stdout as NDJSON
51
+ * @returns {{ emit(event, payload, usage), close() }}
52
+ */
53
+ export function createStreamEmitter({ agentIdentity, runId, onEvent, stdoutNdjson = false }) {
54
+ let closed = false;
55
+ const usageRef = { costUsd: 0, outputTokens: 0, toolCalls: 0, durationMs: 0 };
56
+
57
+ return {
58
+ /**
59
+ * Emit a streaming event.
60
+ */
61
+ emit(event, payload, usage) {
62
+ if (closed) return;
63
+ const merged = { ...usageRef, ...usage };
64
+ Object.assign(usageRef, merged);
65
+ const evt = buildStreamEvent(event, agentIdentity, payload, merged, runId);
66
+ if (onEvent) onEvent(evt);
67
+ if (stdoutNdjson) console.log(JSON.stringify(evt));
68
+ return evt;
69
+ },
70
+
71
+ /**
72
+ * Update accumulated usage without emitting.
73
+ */
74
+ updateUsage(delta) {
75
+ if (delta.costUsd !== undefined) usageRef.costUsd = delta.costUsd;
76
+ if (delta.outputTokens !== undefined) usageRef.outputTokens = delta.outputTokens;
77
+ if (delta.toolCalls !== undefined) usageRef.toolCalls = delta.toolCalls;
78
+ if (delta.durationMs !== undefined) usageRef.durationMs = delta.durationMs;
79
+ },
80
+
81
+ /**
82
+ * Mark emitter as closed (no more events).
83
+ */
84
+ close() {
85
+ closed = true;
86
+ },
87
+
88
+ /**
89
+ * Get current usage snapshot.
90
+ */
91
+ getUsage() {
92
+ return { ...usageRef };
93
+ },
94
+ };
95
+ }
96
+
97
+ /**
98
+ * Format a terminal display line for a persona event (non-JSON mode).
99
+ *
100
+ * @param {object} evt - Stream event
101
+ * @returns {string} Formatted line for stderr
102
+ */
103
+ export function formatTerminalLine(evt) {
104
+ const agent = evt.agent || {};
105
+ const avatar = agent.avatar || "";
106
+ const name = agent.persona || agent.id || "Agent";
107
+ const p = evt.payload || {};
108
+
109
+ switch (evt.event) {
110
+ case "agent_start":
111
+ return `${avatar} ${name} starting (mode: ${p.mode || "primary"})...`;
112
+
113
+ case "progress":
114
+ return `${avatar} ${name}: ${p.message || p.phase || "working..."}`;
115
+
116
+ case "tool_call":
117
+ return `${avatar} ${name} [${p.tool}] ${formatToolInput(p.input)}`;
118
+
119
+ case "tool_result":
120
+ return `${avatar} ${name} [${p.tool}] ${p.durationMs || 0}ms ${p.success === false ? "FAILED" : "ok"}`;
121
+
122
+ case "finding": {
123
+ const sev = p.severity || "P3";
124
+ const sevColor = sev === "P0" ? "!!!" : sev === "P1" ? "!!" : sev === "P2" ? "!" : "";
125
+ return `${avatar} [${sev}${sevColor}] ${p.file || ""}:${p.line || ""} ${p.title || ""}`;
126
+ }
127
+
128
+ case "reasoning":
129
+ return `${avatar} ${name}: ${(p.summary || "").slice(0, 120)}`;
130
+
131
+ case "heartbeat": {
132
+ const h = p;
133
+ const budgetPct = h.budgetRemaining?.pct?.toFixed(0) || "?";
134
+ return `${avatar} ${name} [${h.turnsCompleted || 0}/${h.turnsMax || "?"} turns, ${budgetPct}% budget, ${h.findingsSoFar || 0} findings]`;
135
+ }
136
+
137
+ case "budget_warning":
138
+ return `${avatar} ${name} BUDGET WARNING: ${(p.warnings || []).map(w => w.code).join(", ")}`;
139
+
140
+ case "budget_stop":
141
+ return `${avatar} ${name} BUDGET STOP: ${(p.reasons || []).map(r => r.code || r).join(", ")}`;
142
+
143
+ case "swarm_start":
144
+ return `${avatar} ${name} spawning sub-agents (${p.scannerCount || 0} scanners, ${p.hunterCount || 0} hunters)...`;
145
+
146
+ case "swarm_complete":
147
+ return `${avatar} ${name} swarm complete: ${p.totalFindings || 0} findings from ${p.totalAgents || 0} agents ($${(p.totalCostUsd || 0).toFixed(2)})`;
148
+
149
+ case "phase_start":
150
+ return `${avatar} ${name} phase: ${p.phase || "unknown"}`;
151
+
152
+ case "agent_complete": {
153
+ const s = p;
154
+ return `${avatar} ${name} complete: ${s.total || 0} findings (P0=${s.P0 || 0} P1=${s.P1 || 0} P2=${s.P2 || 0}) $${(s.costUsd || 0).toFixed(2)} ${s.durationMs ? (s.durationMs / 1000).toFixed(1) + "s" : ""}`;
155
+ }
156
+
157
+ case "agent_abort":
158
+ return `${avatar} ${name} ABORTED: ${p.reason || "unknown"}`;
159
+
160
+ default:
161
+ return `${avatar} ${name} [${evt.event}]`;
162
+ }
163
+ }
164
+
165
+ function formatToolInput(input) {
166
+ if (!input) return "";
167
+ if (input.file_path) return input.file_path;
168
+ if (input.pattern) return `/${input.pattern}/`;
169
+ if (input.operation) return input.operation;
170
+ if (input.command) return input.command.slice(0, 60);
171
+ return "";
172
+ }
173
+
174
+ /**
175
+ * List all valid event types.
176
+ */
177
+ export const EVENT_TYPES = Object.freeze([
178
+ "agent_start", "agent_complete", "agent_abort", "agent_error",
179
+ "progress", "heartbeat",
180
+ "tool_call", "tool_result",
181
+ "finding", "reasoning",
182
+ "budget_warning", "budget_stop",
183
+ "swarm_start", "swarm_complete",
184
+ "phase_start", "phase_complete",
185
+ "convergence_expansion", "coverage_gap",
186
+ "llm_error",
187
+ ]);
@@ -1,74 +1,74 @@
1
- import { JulesSubAgent } from "./sub-agent.js";
2
-
3
- const FILE_SCANNER_PROMPT = `You are a FileScanner sub-agent working for Jules Tanaka (SentinelLayer Frontend Specialist).
4
-
5
- Your job: Read each file in your scope and extract a structured summary.
6
-
7
- For each file, extract:
8
- - componentName: the primary exported component/function name
9
- - useStateCount: number of useState calls
10
- - useEffectCount: number of useEffect calls
11
- - imports: list of imported modules (just the module names)
12
- - exports: list of exported names
13
- - loc: approximate line count
14
- - riskSignals: array of any of these detected patterns:
15
- - "dangerouslySetInnerHTML" if found
16
- - "eval" if found
17
- - "window_access_in_render" if window/document/localStorage used outside useEffect
18
- - "missing_cleanup" if useEffect has subscription/timer without return
19
- - "god_component" if useState count >= 16
20
- - "large_file" if LOC > 500
21
-
22
- Use the FileRead tool to read each file. Use Grep if you need to search for patterns.
23
-
24
- Return your findings as a JSON array in a \`\`\`json code block:
25
- [
26
- {
27
- "file": "path/to/file.tsx",
28
- "componentName": "Dashboard",
29
- "useStateCount": 3,
30
- "useEffectCount": 2,
31
- "imports": ["react", "zustand", "./Header"],
32
- "exports": ["Dashboard"],
33
- "loc": 150,
34
- "riskSignals": [],
35
- "discoveredDependencies": ["./utils/formatDate", "../hooks/useAuth"]
36
- }
37
- ]
38
-
39
- The discoveredDependencies field is critical: list any imports that point to files NOT in your assigned scope. These will be used to expand the audit coverage.
40
-
41
- Be thorough but concise. Do not explain findings — just extract data.`;
42
-
43
- /**
44
- * Create a FileScanner sub-agent for a batch of files.
45
- *
46
- * @param {object} config
47
- * @param {string} config.id - Unique ID (e.g., "scanner-dashboard")
48
- * @param {string[]} config.files - Files to scan
49
- * @param {object} config.budget - Budget slice
50
- * @param {object} config.blackboard - Shared blackboard
51
- * @param {object} [config.provider] - LLM provider overrides
52
- * @param {AbortController} [config.parentAbort]
53
- * @param {function} [config.onEvent]
54
- */
55
- export function createFileScanner(config) {
56
- return new JulesSubAgent({
57
- id: config.id || `scanner-${Date.now()}`,
58
- role: "FileScanner",
59
- systemPrompt: FILE_SCANNER_PROMPT,
60
- allowedTools: ["FileRead", "Grep", "Glob"],
61
- scope: { files: config.files },
62
- budget: config.budget || {
63
- maxCostUsd: 0.5,
64
- maxOutputTokens: 3000,
65
- maxRuntimeMs: 60000,
66
- maxToolCalls: config.files.length * 2 + 5,
67
- },
68
- blackboard: config.blackboard,
69
- maxTurns: Math.min(config.files.length + 3, 15),
70
- provider: config.provider,
71
- parentAbort: config.parentAbort,
72
- onEvent: config.onEvent,
73
- });
74
- }
1
+ import { JulesSubAgent } from "./sub-agent.js";
2
+
3
+ const FILE_SCANNER_PROMPT = `You are a FileScanner sub-agent working for Jules Tanaka (SentinelLayer Frontend Specialist).
4
+
5
+ Your job: Read each file in your scope and extract a structured summary.
6
+
7
+ For each file, extract:
8
+ - componentName: the primary exported component/function name
9
+ - useStateCount: number of useState calls
10
+ - useEffectCount: number of useEffect calls
11
+ - imports: list of imported modules (just the module names)
12
+ - exports: list of exported names
13
+ - loc: approximate line count
14
+ - riskSignals: array of any of these detected patterns:
15
+ - "dangerouslySetInnerHTML" if found
16
+ - "eval" if found
17
+ - "window_access_in_render" if window/document/localStorage used outside useEffect
18
+ - "missing_cleanup" if useEffect has subscription/timer without return
19
+ - "god_component" if useState count >= 16
20
+ - "large_file" if LOC > 500
21
+
22
+ Use the FileRead tool to read each file. Use Grep if you need to search for patterns.
23
+
24
+ Return your findings as a JSON array in a \`\`\`json code block:
25
+ [
26
+ {
27
+ "file": "path/to/file.tsx",
28
+ "componentName": "Dashboard",
29
+ "useStateCount": 3,
30
+ "useEffectCount": 2,
31
+ "imports": ["react", "zustand", "./Header"],
32
+ "exports": ["Dashboard"],
33
+ "loc": 150,
34
+ "riskSignals": [],
35
+ "discoveredDependencies": ["./utils/formatDate", "../hooks/useAuth"]
36
+ }
37
+ ]
38
+
39
+ The discoveredDependencies field is critical: list any imports that point to files NOT in your assigned scope. These will be used to expand the audit coverage.
40
+
41
+ Be thorough but concise. Do not explain findings — just extract data.`;
42
+
43
+ /**
44
+ * Create a FileScanner sub-agent for a batch of files.
45
+ *
46
+ * @param {object} config
47
+ * @param {string} config.id - Unique ID (e.g., "scanner-dashboard")
48
+ * @param {string[]} config.files - Files to scan
49
+ * @param {object} config.budget - Budget slice
50
+ * @param {object} config.blackboard - Shared blackboard
51
+ * @param {object} [config.provider] - LLM provider overrides
52
+ * @param {AbortController} [config.parentAbort]
53
+ * @param {function} [config.onEvent]
54
+ */
55
+ export function createFileScanner(config) {
56
+ return new JulesSubAgent({
57
+ id: config.id || `scanner-${Date.now()}`,
58
+ role: "FileScanner",
59
+ systemPrompt: FILE_SCANNER_PROMPT,
60
+ allowedTools: ["FileRead", "Grep", "Glob"],
61
+ scope: { files: config.files },
62
+ budget: config.budget || {
63
+ maxCostUsd: 0.5,
64
+ maxOutputTokens: 3000,
65
+ maxRuntimeMs: 60000,
66
+ maxToolCalls: config.files.length * 2 + 5,
67
+ },
68
+ blackboard: config.blackboard,
69
+ maxTurns: Math.min(config.files.length + 3, 15),
70
+ provider: config.provider,
71
+ parentAbort: config.parentAbort,
72
+ onEvent: config.onEvent,
73
+ });
74
+ }
@@ -1,11 +1,11 @@
1
- /**
2
- * Jules Tanaka — Sub-Agent Swarm
3
- *
4
- * Parallel isolated agents for frontend audit work.
5
- * Each sub-agent: own conversation, own budget, shared blackboard.
6
- */
7
-
8
- export { JulesSubAgent, runSubAgentBatch, SubAgentError } from "./sub-agent.js";
9
- export { createFileScanner } from "./file-scanner.js";
10
- export { createPatternHunter, HUNT_TYPES } from "./pattern-hunter.js";
11
- export { shouldSpawnSubAgents, runJulesSwarm } from "./orchestrator.js";
1
+ /**
2
+ * Jules Tanaka — Sub-Agent Swarm
3
+ *
4
+ * Parallel isolated agents for frontend audit work.
5
+ * Each sub-agent: own conversation, own budget, shared blackboard.
6
+ */
7
+
8
+ export { JulesSubAgent, runSubAgentBatch, SubAgentError } from "./sub-agent.js";
9
+ export { createFileScanner } from "./file-scanner.js";
10
+ export { createPatternHunter, HUNT_TYPES } from "./pattern-hunter.js";
11
+ export { shouldSpawnSubAgents, runJulesSwarm } from "./orchestrator.js";