agent-council 0.1.0 → 0.2.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.
@@ -18,8 +18,8 @@ several agents run it concurrently against the same coverage data.
18
18
 
19
19
  This prompt never asks the user anything, so it runs the same interactively or
20
20
  headless. Never stop to wait for input: when a precondition fails, stop with an
21
- error message instead. The invocation may name a different report location
22
- (e.g. "write the report to `tmp/reports`") or coverage file location.
21
+ error message instead. The invocation may name a different coverage file
22
+ location.
23
23
 
24
24
  ### Preconditions
25
25
 
@@ -47,16 +47,16 @@ Before you begin the analysis:
47
47
  - Get every coverage number from cov-loupe. Do not read `coverage.json`
48
48
  directly, and do not estimate coverage by reading tests. Aggregating
49
49
  cov-loupe's per-line output into area totals is expected (see Step 4).
50
- - Prefer the cov-loupe MCP server. If it is unavailable, use the CLI
51
- (`cov-loupe`, or `bundle exec cov-loupe` if it is in the Gemfile; run
52
- `cov-loupe --help` for usage), adding `-m cli -fJ` for JSON output. Say in
53
- the report which one you used.
50
+ - Use the cov-loupe CLI (`cov-loupe`, or `bundle exec cov-loupe` if it is in
51
+ the Gemfile; run `cov-loupe --help` for usage), adding `-m cli -fJ` for JSON
52
+ output.
54
53
  - Use source and test files only to define the logical areas and to judge the
55
54
  importance of uncovered code.
56
55
  - Do not run the test suite, and do not modify source files, test files, or
57
56
  coverage output. Other agents may be running this analysis concurrently
58
- against the same data. This is a read-only analysis; the only file you
59
- write is the report.
57
+ against the same data. This is a read-only analysis: write no
58
+ files except in a temporary directory of your own outside the
59
+ project (see Step 4).
60
60
  - Before recommending tests for uncovered code, check whether it is
61
61
  intentionally excluded or untested: SimpleCov filters and `# :nocov:`
62
62
  markers, and any project documentation or code comments explaining why.
@@ -66,7 +66,8 @@ Before you begin the analysis:
66
66
  The user must run the full, passing test suite before this analysis. Verify
67
67
  what you can, and if any check below fails, stop with an error that names the
68
68
  failed check, gives the coverage file's path, size, and modification time (if
69
- it exists), and tells the user to rerun the full suite. Do not write a report.
69
+ it exists), and tells the user to rerun the full suite. Give only that
70
+ error, not a report.
70
71
 
71
72
  1. Find the SimpleCov configuration (`.simplecov`, `spec/spec_helper.rb`,
72
73
  `test/test_helper.rb`, or wherever the project starts SimpleCov) and the
@@ -76,10 +77,9 @@ it exists), and tells the user to rerun the full suite. Do not write a report.
76
77
  UTC) from the file system (e.g. `ls -l` or `stat`); this metadata is not
77
78
  coverage data, so reading it is allowed.
78
79
  2. Run the project totals with the tracked globs from Step 2
79
- (`project_coverage_totals` / `cov-loupe -m cli -fJ -g '<globs>' totals`)
80
- and the file list with the same globs (`project_coverage` /
81
- `cov-loupe -m cli -fJ -g '<globs>' list`). `timestamp_status` must be `ok`,
82
- and `newer_files`, `deleted_files`, `length_mismatch_files`,
80
+ (`cov-loupe -m cli -fJ -g '<globs>' totals`) and the file list with the
81
+ same globs (`cov-loupe -m cli -fJ -g '<globs>' list`). `timestamp_status`
82
+ must be `ok`, and `newer_files`, `deleted_files`, `length_mismatch_files`,
83
83
  `unreadable_files`, and `skipped_files` must all be empty. These show
84
84
  whether source files changed after the run.
85
85
  3. No test, fixture, or configuration file may be newer than the coverage
@@ -102,7 +102,7 @@ staleness failure; it is a finding for Step 2.
102
102
  1. Get overall totals with no globs, then with tracked globs matching the
103
103
  code SimpleCov is meant to measure (from its `track_files` and filter
104
104
  settings; typically `lib/**/*.rb`, or `app/**/*.rb,lib/**/*.rb` for Rails).
105
- Passing `tracked_globs` makes cov-loupe report tracked files that have
105
+ Passing tracked globs (`-g`) makes cov-loupe report tracked files that have
106
106
  **no** coverage data at all (`missing_tracked_files`, `without_coverage`);
107
107
  these are files never loaded by the suite and are often the biggest real
108
108
  gap.
@@ -161,16 +161,15 @@ and more tokens than a file-level rollup; that is the point.
161
161
  ## Step 4: Compute coverage per area
162
162
 
163
163
  1. For each file touched by an area, get per-line data with
164
- `file_coverage_detailed` / `cov-loupe -m cli -fJ detailed <path>`. Each row
165
- gives a line number, its hit count, and whether it is covered; lines that
166
- are not coverable (comments, blank lines, `end`) do not appear.
164
+ `cov-loupe -m cli -fJ detailed <path>`. Each row gives a line number, its
165
+ hit count, and whether it is covered; lines that are not coverable
166
+ (comments, blank lines, `end`) do not appear.
167
167
  2. For each area, sum the covered and coverable lines that fall in its line
168
168
  ranges, and compute the percentage. Also record the number of code units
169
169
  in the area and its weakest units (e.g. the least-covered methods).
170
170
  3. Get a broader area's numbers by summing its children's line counts, never
171
171
  by averaging child percentages.
172
172
  4. For an area made of whole files, cross-check your sums against
173
- `project_coverage_totals` with `tracked_globs` /
174
173
  `cov-loupe -m cli -fJ -g '<globs>' totals`; they must match exactly.
175
174
  5. Confirm that the line totals for the partition level from Step 3 add up to
176
175
  the project's covered and total lines for the same overall globs. If they
@@ -192,8 +191,8 @@ report.
192
191
 
193
192
  For each selected file or area:
194
193
 
195
- 1. Get the uncovered lines (`file_uncovered_lines` /
196
- `cov-loupe -m cli -fJ uncovered <path>`); use `file_coverage_detailed` or
194
+ 1. Get the uncovered lines (`cov-loupe -m cli -fJ uncovered <path>`); use
195
+ `cov-loupe -m cli -fJ detailed <path>` or
197
196
  `cov-loupe -m cli -s uncovered -n 2 uncovered <path>` to see the source in
198
197
  context.
199
198
  2. Characterize each cluster of uncovered lines: error/rescue path, edge-case
@@ -242,24 +241,12 @@ Keep this qualitative and evidence-based; cite test files and line numbers.
242
241
 
243
242
  ## Report
244
243
 
245
- Write your analysis in the project root (or in the directory the invocation
246
- names) as a Markdown file whose name is:
247
- - today's date in UTC `%Y-%m-%d-%H-%M` format +
248
- - '-test-coverage-analysis-' +
249
- - your name (e.g. 'codex', 'claude', 'gemini') +
250
- - the `.md` extension.
251
-
252
- If a file with that name already exists (another agent finished in the same
253
- minute), append `-2`, `-3`, and so on before the extension. Never overwrite an
254
- existing report.
255
-
256
- The file should have the following structure:
244
+ The report should have the following structure:
257
245
 
258
246
  ---
259
247
 
260
248
  ### Executive Summary
261
- - Commit cited, cov-loupe interface used (MCP or CLI), and the results of the
262
- Step 1 checks.
249
+ - Commit cited and the results of the Step 1 checks.
263
250
  - The coverage file's path (relative to the project root), size, and
264
251
  modification time (UTC), so readers can tell which test run the report
265
252
  describes.
@@ -335,12 +322,12 @@ table, give each task a ready-to-use prompt the user can give an AI assistant
335
322
  to implement it, keyed by its number.
336
323
 
337
324
  ### Appendix: Commands Run
338
- Every cov-loupe call (MCP tool name and arguments, or CLI command) and
325
+ Every cov-loupe command and
339
326
  freshness check used to produce the numbers, plus any aggregation script, so the
340
327
  report can be reproduced.
341
328
 
342
329
  ---
343
330
 
344
- End your final message with the report's path and the one-line verdict, or,
345
- if you stopped early, with the error. A headless caller can then find the
331
+ End the report by repeating the one-line verdict, or, if you stopped early,
332
+ give only the error. A headless caller can then find the
346
333
  outcome without parsing the rest of your output.
data/exe/agent-council CHANGED
@@ -3,7 +3,11 @@
3
3
 
4
4
  # agent-council — executable entry point. All code lives in lib/:
5
5
  # lib/agent_council.rb orchestration (AgentCouncil)
6
+ # lib/agent_council/harnesses.rb harnesses by name (AgentCouncil::Harnesses)
7
+ # lib/agent_council/harnesses/scaffold.rb read-only scaffolding every harness appends
6
8
  # lib/agent_council/harnesses/pi_harness.rb pi-specific behavior (AgentCouncil::Harnesses::PiHarness)
9
+ # lib/agent_council/harnesses/claude_code_harness.rb
10
+ # Claude Code-specific behavior (ClaudeCodeHarness)
7
11
  #
8
12
  # Usage, options, and AGENT_COUNCIL_OPTS: agent-council -h, and the README.
9
13
 
@@ -0,0 +1,205 @@
1
+ # frozen_string_literal: true
2
+
3
+ # AgentCouncil::Harnesses::ClaudeCodeHarness — all knowledge specific to
4
+ # the Claude Code harness: how to invoke the claude CLI for one agent,
5
+ # with its tool allowlist and the shared read-only scaffolding, and how to
6
+ # read its stream-json output afterward.
7
+ #
8
+ # AgentCouncil is harness-agnostic and finds this module through
9
+ # AgentCouncil::Harnesses (lib/agent_council/harnesses.rb), by its NAME.
10
+ # Authentication and billing are left to Claude Code: an agent bills however
11
+ # claude would at the user's terminal.
12
+
13
+ require 'json'
14
+ require_relative 'scaffold'
15
+
16
+ module AgentCouncil
17
+ module Harnesses
18
+ module ClaudeCodeHarness
19
+ NAME = 'claude'
20
+
21
+ # Analysis toolset (Claude Code's built-in tool names): Edit, Write, and
22
+ # the rest are absent. Bash, a full shell, stays for investigation;
23
+ # only the scaffolding text asks the model to use it read-only.
24
+ TOOLS = 'Read,Grep,Glob,Bash'
25
+
26
+ # Invocation for one agent. The substantive prompt is not part of
27
+ # argv; it is piped to stdin. provider is not passed: Claude Code
28
+ # takes none, so an entry's provider only labels the agent (e.g.
29
+ # bedrock, for a claude set up to use it).
30
+ module_function def argv(_provider, model)
31
+ [
32
+ NAME,
33
+ '-p', # non-interactive: process prompt and exit
34
+ '--output-format', 'stream-json', # JSONL event stream on stdout
35
+ '--verbose', # required by stream-json with -p
36
+ '--no-session-persistence', # ephemeral: no session saved
37
+ '--tools', TOOLS, # the only built-in tools available
38
+ '--allowedTools', TOOLS, # ...and pre-approved, since -p can't ask
39
+ '--permission-mode', 'manual', # the same for every user, whatever their defaultMode
40
+ '--strict-mcp-config', # with no --mcp-config: no MCP servers
41
+ '--model', model,
42
+ '--append-system-prompt', Harnesses.scaffold_text
43
+ ]
44
+ end
45
+
46
+ # --- event stream reading ---
47
+
48
+ # The events of a stream-json stream, in order. Unparseable lines and
49
+ # non-objects are skipped.
50
+ module_function def events(jsonl)
51
+ jsonl.each_line.filter_map do |line|
52
+ event =
53
+ begin
54
+ JSON.parse(line)
55
+ rescue JSON::ParserError
56
+ nil
57
+ end
58
+ event if event.is_a?(Hash)
59
+ end
60
+ end
61
+
62
+ # The agent's result event: the last one, which ends the stream. nil if
63
+ # there is none, e.g. for an agent that was killed.
64
+ module_function def result_event(jsonl)
65
+ events(jsonl).reverse_each.detect { |event| event['type'] == 'result' }
66
+ end
67
+
68
+ # The messages of the stream's assistant events, in order (several per
69
+ # model request, one per content block).
70
+ module_function def assistant_messages(jsonl)
71
+ events(jsonl).filter_map do |event|
72
+ message = event['message'] if event['type'] == 'assistant'
73
+ message if message.is_a?(Hash)
74
+ end
75
+ end
76
+
77
+ # The final response: the result event's text, for an agent that didn't
78
+ # fail.
79
+ module_function def final_response(jsonl)
80
+ result = result_event(jsonl)
81
+ return nil unless result && result['is_error'] != true
82
+
83
+ text = result['result']
84
+ text.is_a?(String) ? text : nil
85
+ end
86
+
87
+ # Our usage keys, each mapped to Claude Code's name for it. Its input
88
+ # excludes cache reads and writes, as pi's does.
89
+ USAGE_KEYS = { 'input' => 'input_tokens', 'output' => 'output_tokens',
90
+ 'cache_read' => 'cache_read_input_tokens',
91
+ 'cache_write' => 'cache_creation_input_tokens' }.freeze
92
+
93
+ # Token usage as AgentCouncil expects it (see Harnesses), from the
94
+ # result event alone: it totals all the agent's requests, while the assistant
95
+ # events' usage is per-message snapshots that undercount output. nil
96
+ # when the stream has no result event (as for an agent whose claude was
97
+ # killed: no usage beats an undercount) or reports no usage (as when
98
+ # the agent never reached a model).
99
+ module_function def usage(jsonl)
100
+ result = result_event(jsonl)
101
+ usage = result && result['usage']
102
+ return nil unless usage.is_a?(Hash)
103
+
104
+ totals = USAGE_KEYS.transform_values { |key| count(usage[key]) }
105
+ return nil if totals.values.all?(&:zero?)
106
+
107
+ cost = count(result['total_cost_usd'])
108
+ cost.positive? ? totals.merge('cost' => cost.round(6)) : totals
109
+ end
110
+
111
+ module_function def count(value)
112
+ value.is_a?(Numeric) && value.positive? ? value : 0
113
+ end
114
+
115
+ # Why the agent produced no usable report, or nil. A failed agent has a
116
+ # result event with is_error true (its subtype is usually still
117
+ # "success", so it isn't checked); one that isn't flagged but has no
118
+ # text is reported as such, since the report is that text. The reason
119
+ # is its errors, if any (e.g. the turn limit, with no result text),
120
+ # otherwise its result text (e.g. "Not logged in · Please run
121
+ # /login").
122
+ module_function def error_message(jsonl)
123
+ result = result_event(jsonl)
124
+ return 'the stream has no result event' unless result
125
+ return error_reason(result) || 'the agent failed and gave no reason' if result['is_error'] == true
126
+
127
+ text = result['result']
128
+ 'the result event has no text' unless text.is_a?(String) && !text.strip.empty?
129
+ end
130
+
131
+ # The reason a failed agent's result event gives, or nil if it gives none.
132
+ module_function def error_reason(result)
133
+ errors = Array(result['errors']).grep(String).map(&:strip).reject(&:empty?)
134
+ return errors.join('; ') unless errors.empty?
135
+
136
+ text = result['result']
137
+ text if text.is_a?(String) && !text.strip.empty?
138
+ end
139
+
140
+ # Why an agent that exited nonzero failed. Claude Code explains a failure
141
+ # in a result event with is_error true, and its stderr is then
142
+ # usually empty, so that reason, if it gives one, comes first.
143
+ # Otherwise stderr is likelier to say why (e.g. for a crash) than
144
+ # whatever else the stream shows (e.g. a result with no text), which
145
+ # is the last resort. Returned whole: the caller puts it on one line
146
+ # and shortens it (see Harnesses).
147
+ module_function def exit_detail(stdout, stderr)
148
+ result = result_event(stdout)
149
+ reason = error_reason(result) if result && result['is_error'] == true
150
+ return reason if reason
151
+
152
+ stderr_line = stderr.lines.map(&:strip).reject(&:empty?).first
153
+ return stderr_line if stderr_line
154
+
155
+ (error_message(stdout) if result) || 'no error output'
156
+ end
157
+
158
+ # Warnings about an agent, succeeded or not: the tool calls Claude Code
159
+ # refused, which -p mode can't ask about. The agent usually still
160
+ # succeeds (the model saw the refusal and answered without that
161
+ # call), but its report may be missing what the call would have
162
+ # found; an agent that fails (say, out of turns) may have failed
163
+ # because of them.
164
+ module_function def warnings(jsonl)
165
+ result = result_event(jsonl)
166
+ denials = result && result['permission_denials']
167
+ return [] unless denials.is_a?(Array) && !denials.empty?
168
+
169
+ calls = denials.map { |denial| denied_call(denial) }.uniq
170
+ listed = calls.first(MAX_LISTED_CALLS).map do |tool, target|
171
+ target ? "#{tool} (#{shorten(target)})" : tool
172
+ end
173
+ listed << "and #{calls.size - listed.size} more" if calls.size > listed.size
174
+ ["Claude Code refused #{denials.size} tool call#{'s' unless denials.size == 1}: #{listed.join('; ')}"]
175
+ end
176
+
177
+ # Distinct refused calls named in a warning, so an agent refused many
178
+ # times still gets a warning of a readable length.
179
+ MAX_LISTED_CALLS = 5
180
+
181
+ # The tool_input keys that say what a refused call was for, in order
182
+ # of preference: Bash's command, Read's file_path, then Grep's and
183
+ # Glob's pattern and path.
184
+ TARGET_KEYS = %w[command file_path pattern path].freeze
185
+
186
+ # A refused tool call as [tool, target]: its tool and what it was for,
187
+ # such as a Bash command or the file a Read asked for, on one line,
188
+ # or nil if the call gives none. Compared whole, so calls that differ
189
+ # only past where a warning shortens them still count as different.
190
+ module_function def denied_call(denial)
191
+ return ['unknown tool', nil] unless denial.is_a?(Hash)
192
+
193
+ tool = denial['tool_name'].is_a?(String) ? denial['tool_name'] : 'unknown tool'
194
+ input = denial['tool_input']
195
+ target = TARGET_KEYS.map { |key| input[key] }.grep(String).first if input.is_a?(Hash)
196
+ target = target&.gsub(/\s+/, ' ')&.strip
197
+ [tool, (target unless target.nil? || target.empty?)]
198
+ end
199
+
200
+ module_function def shorten(target)
201
+ target.length > 80 ? "#{target[0, 80]}..." : target
202
+ end
203
+ end
204
+ end
205
+ end
@@ -1,16 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # AgentCouncil::Harnesses::PiHarness — all knowledge specific to the pi
4
- # coding-agent harness: how to invoke the pi CLI for one model run, the
5
- # tool allowlist, and read-only scaffolding delivered with it, and how to
6
- # read pi's JSONL event stream afterward.
4
+ # coding-agent harness: how to invoke the pi CLI for one agent, with
5
+ # its tool allowlist and the shared read-only scaffolding, and how to read
6
+ # pi's JSONL event stream afterward.
7
7
  #
8
- # AgentCouncil is harness-agnostic and refers to this module only via
9
- # AgentCouncil::HARNESS. A second harness (claude, codex, ...) would be
10
- # another module under AgentCouncil::Harnesses shaped like this one —
11
- # this is deliberately a plain namespace, not an adapter framework.
8
+ # AgentCouncil is harness-agnostic and finds this module through
9
+ # AgentCouncil::Harnesses (lib/agent_council/harnesses.rb), by its NAME.
12
10
 
13
11
  require 'json'
12
+ require_relative 'scaffold'
14
13
 
15
14
  module AgentCouncil
16
15
  module Harnesses
@@ -23,54 +22,23 @@ module AgentCouncil
23
22
  # scaffolding text asks the model to use it read-only.
24
23
  TOOLS = 'read,grep,find,ls,bash'
25
24
 
26
- # Invocation for one model run. The substantive prompt is not part of argv;
25
+ # Invocation for one agent. The substantive prompt is not part of argv;
27
26
  # it is piped to stdin (byte-identical for every analyst; the
28
27
  # consolidator gets its own).
29
- module_function def argv(provider, model, scratch_dir)
28
+ module_function def argv(provider, model)
30
29
  [
31
30
  NAME,
32
31
  '-p', # non-interactive: process prompt and exit
33
32
  '--mode', 'json', # JSONL event stream on stdout
34
- '--no-session', # ephemeral: no session state between runs
33
+ '--no-session', # ephemeral: no session state between agents
34
+ '--no-mcp', # built-in MCP off: configured servers don't start
35
35
  '--tools', TOOLS,
36
36
  '--provider', provider,
37
37
  '--model', model,
38
- '--append-system-prompt', scaffold_text(scratch_dir)
38
+ '--append-system-prompt', Harnesses.scaffold_text
39
39
  ]
40
40
  end
41
41
 
42
- # Scaffolding appended to pi's system prompt. Identical for every agent
43
- # except the scratch dir path.
44
- module_function def scaffold_text(scratch_dir)
45
- <<~TEXT
46
- You are one of the independent agents agent-council runs on this
47
- repository. This is a strictly read-only analysis task.
48
-
49
- Rules:
50
- - Do not modify, create, rename, or delete any project source or
51
- configuration file. Do not change git state, install or remove
52
- software, modify user or system configuration, or start persistent
53
- services.
54
- - Do not run test suites, builds, coverage tools, application servers,
55
- or database tasks unless the user's prompt explicitly permits it:
56
- other agents may be running concurrently and such commands can collide
57
- through shared state (databases, ports, Docker, fixed temp paths).
58
- Where the prompt permits them, direct their temporary output to the
59
- scratch directory below, and still skip any that need shared
60
- services (databases, servers, fixed ports, Docker). Otherwise, if
61
- running such a command would materially improve your analysis,
62
- describe what you would run and why instead of running it.
63
- - You may run clearly read-only commands: reading, searching, and
64
- listing files; inspecting git history and status; inspecting
65
- dependency and configuration information.
66
- - If you need scratch space for temporary artifacts, use this
67
- disposable directory that is unique to your run: #{scratch_dir}
68
- - Deliver your complete analysis as your final message text. Do not
69
- write the report to a file; the orchestrator captures your final
70
- message directly.
71
- TEXT
72
- end
73
-
74
42
  # --- event stream reading ---
75
43
 
76
44
  # The assistant message from a single pi JSONL line, or nil if the line
@@ -126,7 +94,7 @@ module AgentCouncil
126
94
  # Token usage summed over all assistant messages (each is a separate
127
95
  # model request), as AgentCouncil expects it: integer 'input', 'output',
128
96
  # 'cache_read', and 'cache_write', plus 'cost' in US dollars when pi
129
- # priced the run. nil when the stream reports no usage, as some
97
+ # priced the usage. nil when the stream reports no usage, as some
130
98
  # providers don't.
131
99
  module_function def usage(jsonl)
132
100
  usages = assistant_messages(jsonl).map { |m| m['usage'] }.grep(Hash)
@@ -146,7 +114,7 @@ module AgentCouncil
146
114
  # instead; this catches one that is missing or blank.
147
115
  UNUSABLE_STOP_REASONS = %w[length aborted error].freeze
148
116
 
149
- # Why the run produced no usable report, or nil. Pi exits 0 even when the
117
+ # Why the agent produced no usable report, or nil. Pi exits 0 even when the
150
118
  # provider rejects the request or the output hits its token limit, so this
151
119
  # is how such failures are surfaced. Two messages are checked: the final
152
120
  # one (an error in an earlier turn that a later turn recovered from is not
@@ -164,6 +132,16 @@ module AgentCouncil
164
132
  message = candidates.detect { |m| UNUSABLE_STOP_REASONS.include?(m['stopReason']) }
165
133
  message && "stopped early (stopReason: #{message['stopReason']})"
166
134
  end
135
+
136
+ # Why an agent that exited nonzero failed: pi explains it on stderr.
137
+ module_function def exit_detail(_stdout, stderr)
138
+ stderr.lines.map(&:strip).reject(&:empty?).first || 'no error output'
139
+ end
140
+
141
+ # Warnings about an agent that succeeded; pi's stream has none to give.
142
+ module_function def warnings(_jsonl)
143
+ []
144
+ end
167
145
  end
168
146
  end
169
147
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # AgentCouncil::Harnesses.scaffold_text — the read-only scaffolding every
4
+ # harness appends to its agents' system prompt. In its own file so each
5
+ # harness module can require it without the harness registry
6
+ # (lib/agent_council/harnesses.rb), which requires the harness modules.
7
+
8
+ module AgentCouncil
9
+ module Harnesses
10
+ # Scaffolding appended to every harness's system prompt, identical for
11
+ # every agent. It names the scratch dir as $TMPDIR, not by path: Claude
12
+ # Code's sandbox makes the dir itself read-only and points TMPDIR at a
13
+ # writable dir inside it.
14
+ module_function def scaffold_text
15
+ <<~TEXT
16
+ You are one of the independent agents agent-council runs on this
17
+ repository. This is a strictly read-only analysis task.
18
+
19
+ Rules:
20
+ - Do not modify, create, rename, or delete any project source or
21
+ configuration file. Do not change git state, install or remove
22
+ software, modify user or system configuration, or start persistent
23
+ services.
24
+ - Do not run test suites, builds, coverage tools, application servers,
25
+ or database tasks unless the user's prompt explicitly permits it:
26
+ other agents may be running concurrently and such commands can collide
27
+ through shared state (databases, ports, Docker, fixed temp paths).
28
+ Where the prompt permits them, direct their temporary output to
29
+ $TMPDIR (see below), and still skip any that need shared
30
+ services (databases, servers, fixed ports, Docker). Otherwise, if
31
+ running such a command would materially improve your analysis,
32
+ describe what you would run and why instead of running it.
33
+ - You may run clearly read-only commands: reading, searching, and
34
+ listing files; inspecting git history and status; inspecting
35
+ dependency and configuration information.
36
+ - If you need scratch space for temporary artifacts, use $TMPDIR: it
37
+ is a disposable directory unique to you.
38
+ - Deliver your complete analysis as your final message text. Do not
39
+ write the report to a file; the orchestrator captures your final
40
+ message directly.
41
+ TEXT
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # AgentCouncil::Harnesses — the harnesses agents can run under, by the name
4
+ # a config entry gives in its 'harness' key. What they share, the read-only
5
+ # scaffolding, is in harnesses/scaffold.rb.
6
+ #
7
+ # Each harness is a plain module shaped like PiHarness (NAME, argv, usage,
8
+ # error_message, exit_detail, warnings, final_response,
9
+ # assistant_messages), not an adapter framework; AgentCouncil looks one up
10
+ # per agent with module_for. NAME is both the config value and the
11
+ # executable argv runs, which the startup check looks for on PATH. The
12
+ # scaffolding sends agents to $TMPDIR, which run_agent sets to the
13
+ # scratch dir, so a harness must pass TMPDIR through to its tools. It also
14
+ # goes into report filenames unsanitized, so it must be one
15
+ # AgentCouncil.sanitize leaves unchanged (the specs check this).
16
+ #
17
+ # exit_detail (stdout, stderr) says why an agent that exited nonzero failed;
18
+ # the caller puts it, and error_message's reason, on one line cut to 300
19
+ # characters (AgentCouncil.failure_reason), so a harness returns the
20
+ # reason whole. warnings returns an Array of messages (empty for none)
21
+ # about an agent, failed or not; the caller prints and records them all, so a
22
+ # harness keeps them few and short.
23
+ #
24
+ # usage returns the agent's token usage as AgentCouncil records it, summed
25
+ # over all its requests: integer 'input' (excluding cached input), 'output',
26
+ # 'cache_read', and 'cache_write', plus 'cost' in US dollars when the
27
+ # harness priced the usage; or nil when the harness reports no usage.
28
+
29
+ require_relative 'harnesses/pi_harness'
30
+ require_relative 'harnesses/claude_code_harness'
31
+
32
+ module AgentCouncil
33
+ module Harnesses
34
+ BY_NAME = [PiHarness, ClaudeCodeHarness].to_h { |harness| [harness::NAME, harness] }.freeze
35
+
36
+ # The harness of a report or run.json entry without a 'harness' key:
37
+ # agent-council writes one in each, so these are hand-edited or older
38
+ # than 0.1.0, when every agent ran under pi.
39
+ # A config entry must name its harness (see AgentCouncil.entry_error).
40
+ DEFAULT_NAME = PiHarness::NAME
41
+
42
+ # The harness name a config entry, report front matter, or run.json
43
+ # entry gives, or DEFAULT_NAME when it gives no string one. Config
44
+ # entries are validated first (see AgentCouncil.entry_error), so only
45
+ # unvalidated ones, such as a hand-edited report's front matter or an
46
+ # older run's, are read as pi.
47
+ module_function def name_of(entry)
48
+ harness = entry['harness'] if entry.is_a?(Hash)
49
+ harness.is_a?(String) ? harness : DEFAULT_NAME
50
+ end
51
+
52
+ # The harness module for an entry; KeyError for an unknown name, which
53
+ # config validation rules out before any agent runs.
54
+ module_function def module_for(entry)
55
+ BY_NAME.fetch(name_of(entry))
56
+ end
57
+ end
58
+ end
@@ -38,7 +38,7 @@ module AgentCouncil
38
38
  RPC_REQUEST_ID = 'list-models'
39
39
 
40
40
  module_function def fetch_models
41
- Open3.popen3('pi', '--mode', 'rpc', '--no-session') do |stdin, stdout, stderr, wait_thr|
41
+ Open3.popen3('pi', '--mode', 'rpc', '--no-session', '--no-mcp') do |stdin, stdout, stderr, wait_thr|
42
42
  # pi's output is UTF-8, whatever the locale.
43
43
  [stdout, stderr].each { |io| io.set_encoding(Encoding::UTF_8) }
44
44
  # Drain stderr concurrently so a chatty pi can't block on a full pipe,
@@ -1,8 +1,8 @@
1
1
  # Report format
2
2
 
3
3
  Your response will be saved as a standalone Markdown report. A metadata
4
- table (role, agent, query, harness, provider, model, timestamp, duration)
5
- is prepended to it
4
+ table (role, agent, query, harness, provider, model, timestamp, duration,
5
+ usage, and any warnings) is prepended to it
6
6
  automatically, so:
7
7
 
8
8
  - Do not add a document title or any top-level (`#`) heading.
@@ -5,8 +5,8 @@ Every analyst received the identical prompt (included below as "Original
5
5
  prompt"), followed by formatting instructions for its report. Their reports follow under "Analyst reports", each headed "Report
6
6
  from" its source label (`#<agent number> <provider> / <model>`), with a
7
7
  "Harness:" line below it. Agents that produced no report are listed last,
8
- under "Agents without a report", each with the reason shown there (its
9
- failure, when known).
8
+ under "Agents without a report", each with its harness and the reason
9
+ shown there (its failure, when known, and any warnings about that agent).
10
10
 
11
11
  Produce a consolidated report in two parts, with exactly these sections in
12
12
  this order. The first part is the findings; the second describes the
@@ -30,8 +30,10 @@ Issues raised by exactly one analyst, attributed to its source.
30
30
 
31
31
  - Assess whether each is plausible.
32
32
  - Group findings by agent; for each group:
33
- - output a heading with the agent number, harness, provider, and model
34
- name (the harness is shown under each report's heading)
33
+ - output a heading with the agent number, harness, provider, and model,
34
+ as `#<agent number> <harness> / <provider> / <model>` (e.g. `#1 claude /
35
+ anthropic / claude-opus-5-5`); the harness is on the "Harness:" line
36
+ under each report's heading
35
37
 
36
38
  ## Contradictions
37
39
 
@@ -47,18 +49,20 @@ result.
47
49
 
48
50
  ## Agent Consultants
49
51
 
50
- A list of provider/model agents consulted. For each agent listed under
52
+ A list of the agents consulted, by harness, provider, and model. For each agent listed under
51
53
  "Agents without a report", say it produced no report and give the reason
52
54
  shown there; do not infer failures any other way. If a report shows its
53
- agent could not properly do the task, say so too.
55
+ agent could not properly do the task, say so too, including when its
56
+ metadata table lists warnings, such as tool calls its harness refused.
54
57
 
55
58
  ## Agent performance
56
59
 
57
60
  A brief review of each agent that produced a report: how deep its research
58
61
  went (e.g. did it read code, run commands, verify claims) and how much it
59
62
  added to the review (unique or confirmed findings vs. noise or errors).
60
- For each agent, print a header line with agent number, duration, harness, provider,
61
- and model. Then print a single text string below it with the performance information.
63
+ For each agent, print a header line with its agent number, harness, provider,
64
+ and model, as in the Unique findings headings, followed by its duration. Then
65
+ print a single text string below it with the performance information.
62
66
 
63
67
  Rules:
64
68
  - Begin directly with the "## Findings" section; do not add a
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AgentCouncil
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end