sentinelayer-cli 0.1.2 → 0.4.4

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 (129) hide show
  1. package/README.md +998 -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 +63 -54
  6. package/src/agents/jules/config/definition.js +209 -209
  7. package/src/agents/jules/config/system-prompt.js +175 -175
  8. package/src/agents/jules/error-intake.js +51 -51
  9. package/src/agents/jules/fix-cycle.js +377 -377
  10. package/src/agents/jules/loop.js +367 -367
  11. package/src/agents/jules/pulse.js +327 -319
  12. package/src/agents/jules/stream.js +186 -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 +308 -308
  18. package/src/agents/jules/tools/auth-audit.js +557 -222
  19. package/src/agents/jules/tools/dispatch.js +327 -327
  20. package/src/agents/jules/tools/file-edit.js +180 -180
  21. package/src/agents/jules/tools/file-read.js +100 -100
  22. package/src/agents/jules/tools/frontend-analyze.js +570 -570
  23. package/src/agents/jules/tools/glob.js +168 -168
  24. package/src/agents/jules/tools/grep.js +228 -228
  25. package/src/agents/jules/tools/index.js +29 -29
  26. package/src/agents/jules/tools/path-guards.js +161 -161
  27. package/src/agents/jules/tools/runtime-audit.js +503 -493
  28. package/src/agents/jules/tools/shell.js +383 -383
  29. package/src/agents/jules/tools/url-policy.js +100 -0
  30. package/src/ai/aidenid.js +972 -945
  31. package/src/ai/client.js +508 -508
  32. package/src/ai/domain-target-store.js +268 -268
  33. package/src/ai/identity-store.js +270 -270
  34. package/src/ai/site-store.js +145 -145
  35. package/src/audit/agents/architecture.js +180 -180
  36. package/src/audit/agents/compliance.js +179 -179
  37. package/src/audit/agents/documentation.js +165 -165
  38. package/src/audit/agents/performance.js +145 -145
  39. package/src/audit/agents/security.js +215 -215
  40. package/src/audit/agents/testing.js +172 -172
  41. package/src/audit/orchestrator.js +557 -557
  42. package/src/audit/package.js +204 -204
  43. package/src/audit/registry.js +284 -284
  44. package/src/audit/replay.js +103 -103
  45. package/src/auth/gate.js +45 -11
  46. package/src/auth/http.js +270 -113
  47. package/src/auth/service.js +891 -848
  48. package/src/auth/session-store.js +359 -345
  49. package/src/cli.js +252 -252
  50. package/src/commands/ai/identity-lifecycle.js +1338 -1337
  51. package/src/commands/ai/provision-governance.js +1272 -1246
  52. package/src/commands/ai/shared.js +147 -147
  53. package/src/commands/ai.js +11 -11
  54. package/src/commands/apply.js +12 -12
  55. package/src/commands/audit.js +1166 -1166
  56. package/src/commands/auth.js +375 -366
  57. package/src/commands/chat.js +191 -191
  58. package/src/commands/config.js +184 -184
  59. package/src/commands/cost.js +311 -311
  60. package/src/commands/daemon/core.js +850 -850
  61. package/src/commands/daemon/extended.js +1048 -1048
  62. package/src/commands/daemon/shared.js +213 -213
  63. package/src/commands/daemon.js +11 -11
  64. package/src/commands/guide.js +174 -174
  65. package/src/commands/ingest.js +58 -58
  66. package/src/commands/init.js +55 -55
  67. package/src/commands/legacy-args.js +10 -10
  68. package/src/commands/mcp.js +461 -404
  69. package/src/commands/omargate.js +15 -15
  70. package/src/commands/persona.js +20 -20
  71. package/src/commands/plugin.js +260 -260
  72. package/src/commands/policy.js +132 -132
  73. package/src/commands/prompt.js +238 -238
  74. package/src/commands/review.js +704 -704
  75. package/src/commands/scan.js +866 -788
  76. package/src/commands/spec.js +716 -716
  77. package/src/commands/swarm.js +651 -651
  78. package/src/commands/telemetry.js +202 -202
  79. package/src/commands/watch.js +510 -510
  80. package/src/config/agent-dictionary.js +182 -182
  81. package/src/config/io.js +56 -56
  82. package/src/config/paths.js +18 -18
  83. package/src/config/schema.js +55 -55
  84. package/src/config/service.js +184 -184
  85. package/src/cost/budget.js +235 -235
  86. package/src/cost/history.js +188 -188
  87. package/src/cost/tracker.js +171 -171
  88. package/src/daemon/artifact-lineage.js +534 -534
  89. package/src/daemon/assignment-ledger.js +770 -770
  90. package/src/daemon/ast-parser-layer.js +258 -258
  91. package/src/daemon/budget-governor.js +633 -633
  92. package/src/daemon/callgraph-overlay.js +646 -646
  93. package/src/daemon/error-worker.js +626 -626
  94. package/src/daemon/hybrid-mapper.js +929 -929
  95. package/src/daemon/jira-lifecycle.js +632 -632
  96. package/src/daemon/operator-control.js +657 -657
  97. package/src/daemon/reliability-lane.js +471 -471
  98. package/src/daemon/watchdog.js +971 -971
  99. package/src/guide/generator.js +316 -316
  100. package/src/ingest/engine.js +918 -918
  101. package/src/legacy-cli.js +2592 -2435
  102. package/src/mcp/registry.js +695 -695
  103. package/src/memory/blackboard.js +301 -301
  104. package/src/memory/retrieval.js +581 -581
  105. package/src/plugin/manifest.js +553 -553
  106. package/src/policy/packs.js +144 -144
  107. package/src/prompt/generator.js +118 -106
  108. package/src/review/ai-review.js +669 -669
  109. package/src/review/local-review.js +1295 -1284
  110. package/src/review/replay.js +235 -235
  111. package/src/review/report.js +664 -664
  112. package/src/review/spec-binding.js +487 -487
  113. package/src/scaffold/generator.js +67 -0
  114. package/src/scaffold/templates.js +150 -0
  115. package/src/scan/generator.js +418 -351
  116. package/src/scan/gh-secrets.js +107 -0
  117. package/src/spec/generator.js +519 -519
  118. package/src/spec/regenerate.js +237 -237
  119. package/src/spec/templates.js +91 -91
  120. package/src/swarm/dashboard.js +247 -247
  121. package/src/swarm/factory.js +363 -363
  122. package/src/swarm/pentest.js +934 -934
  123. package/src/swarm/registry.js +419 -419
  124. package/src/swarm/report.js +158 -158
  125. package/src/swarm/runtime.js +576 -576
  126. package/src/swarm/scenario-dsl.js +272 -272
  127. package/src/telemetry/ledger.js +302 -302
  128. package/src/telemetry/sync.js +107 -61
  129. package/src/ui/markdown.js +220 -220
@@ -1,186 +1,186 @@
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
+
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,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";