ai-consultants 2.21.1 → 2.23.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.
package/.env.example ADDED
@@ -0,0 +1,428 @@
1
+ # =============================================================================
2
+ # AI Consultants - Environment Variables
3
+ # =============================================================================
4
+ # Copy this file to .env and customize as needed.
5
+ # All variables have sensible defaults - only override what you need.
6
+ #
7
+ # IMPORTANT: At least 2 consultants must be enabled for the system to work.
8
+ #
9
+ # Export variables before running, or source this file:
10
+ # source .env && ./scripts/consult_all.sh "Your question"
11
+ #
12
+ # For detailed setup instructions, see: docs/SETUP.md
13
+
14
+ # =============================================================================
15
+ # API KEYS & AUTHENTICATION
16
+ # =============================================================================
17
+ # Each CLI tool requires its own authentication. Set the appropriate API keys
18
+ # or use the CLI's built-in auth flow.
19
+
20
+ # Google Gemini API key (only needed for API mode; the agy CLI uses OAuth)
21
+ # Get yours at: https://makersuite.google.com/app/apikey
22
+ # CLI mode uses the Antigravity CLI (agy); sign in by running `agy` once.
23
+ # GEMINI_API_KEY=your-google-api-key
24
+
25
+ # OpenAI API Key (required for Codex)
26
+ # Get yours at: https://platform.openai.com/api-keys
27
+ # OPENAI_API_KEY=sk-your-openai-api-key
28
+
29
+ # Mistral API Key
30
+ # Get yours at: https://console.mistral.ai/api-keys/
31
+ # MISTRAL_API_KEY=your-mistral-api-key
32
+
33
+ # Anthropic API Key (for Claude API mode or synthesis)
34
+ # Get yours at: https://console.anthropic.com/settings/keys
35
+ # ANTHROPIC_API_KEY=sk-ant-your-anthropic-api-key
36
+
37
+
38
+ # =============================================================================
39
+ # API-BASED CONSULTANT KEYS
40
+ # =============================================================================
41
+ # These are required for the API-based consultants (Qwen3, GLM, Grok, DeepSeek)
42
+
43
+ # Qwen3 (Alibaba DashScope) - The Analyst
44
+ # Get yours at: https://dashscope.console.aliyun.com/
45
+ # QWEN3_API_KEY=your_dashscope_api_key
46
+
47
+ # GLM (Zhipu AI) - The Methodologist
48
+ # Get yours at: https://open.z.ai/
49
+ # GLM_API_KEY=your_zhipu_api_key
50
+
51
+ # Grok (xAI) - The Provocateur
52
+ # Get yours at: https://console.x.ai/
53
+ # GROK_API_KEY=your_xai_api_key
54
+
55
+ # DeepSeek - The Code Specialist
56
+ # Get yours at: https://platform.deepseek.com/
57
+ # DEEPSEEK_API_KEY=your_deepseek_api_key
58
+
59
+ # MiniMax - The Pragmatic Optimizer (v2.10)
60
+ # Get yours at: https://platform.minimax.io/user-center/basic-information/interface-key
61
+ # MINIMAX_API_KEY=your_minimax_api_key
62
+
63
+ # =============================================================================
64
+ # ENABLED CONSULTANTS
65
+ # =============================================================================
66
+ # Set to "false" to disable a consultant you haven't configured.
67
+ # MINIMUM 2 consultants must be enabled for comparison/voting to work.
68
+
69
+ # CLI-based consultants (default: enabled)
70
+ ENABLE_GEMINI=true
71
+ ENABLE_CODEX=true
72
+ ENABLE_MISTRAL=true
73
+ ENABLE_CURSOR=true
74
+ ENABLE_KIMI=true
75
+ ENABLE_QWEN3=true
76
+ ENABLE_MINIMAX=true
77
+ ENABLE_CLAUDE=true
78
+
79
+ # API-only consultants (default: disabled - require API keys)
80
+ ENABLE_GLM=false
81
+ ENABLE_GROK=false
82
+ ENABLE_DEEPSEEK=false
83
+
84
+ # =============================================================================
85
+ # CLI/API MODE SWITCHING (v2.6+)
86
+ # =============================================================================
87
+ # 6 agents support switching: Gemini, Codex, Claude, Mistral, Qwen3, MiniMax
88
+ # When API mode is enabled, CLI mode is automatically disabled.
89
+
90
+ # GEMINI_USE_API is auto-resolved when left UNSET (v2.15.1): API mode if
91
+ # GEMINI_API_KEY is present (no CLI install / OAuth needed — best for npm/npx),
92
+ # else the agy CLI. Leave it commented to keep auto-resolution; uncomment only
93
+ # to force a specific mode (an explicit value disables auto-detection).
94
+ # GEMINI_USE_API=false # Force Google AI API (true) or agy CLI (false)
95
+ # Leave the following commented to keep CLI-first auto-resolution (CLI wins
96
+ # when installed; API is the fallback for a key with no CLI). Uncomment only
97
+ # to force a specific transport for that agent.
98
+ # CODEX_USE_API=false # Use OpenAI API instead of codex CLI
99
+ # CLAUDE_USE_API=false # Use Anthropic API instead of claude CLI
100
+ # MISTRAL_USE_API=false # Use Mistral API instead of vibe CLI
101
+ # QWEN3_USE_API=false # Use qwen CLI (default) or DashScope API (v2.7)
102
+ # MINIMAX_USE_API=false # Unset = API for legacy key users, otherwise mmx CLI
103
+
104
+ # API endpoints (override if using custom endpoints)
105
+ # GEMINI_API_URL=https://generativelanguage.googleapis.com/v1beta/models
106
+ # CODEX_API_URL=https://api.openai.com/v1/chat/completions
107
+ # CLAUDE_API_URL=https://api.anthropic.com/v1/messages
108
+ # MISTRAL_API_URL=https://api.mistral.ai/v1/chat/completions
109
+ # QWEN3_API_URL=https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation
110
+
111
+ # =============================================================================
112
+ # MODEL CONFIGURATION (June 2026 premium defaults)
113
+ # =============================================================================
114
+
115
+ # Gemini - The Architect (CLI mode via Antigravity CLI: agy)
116
+ GEMINI_MODEL="Gemini 3.1 Pro (High)"
117
+ GEMINI_TIMEOUT=180
118
+ GEMINI_CMD=agy
119
+ # API-mode model ID (only used when GEMINI_USE_API=true)
120
+ GEMINI_API_MODEL=gemini-3.1-pro-preview
121
+
122
+ # Codex - The Pragmatist
123
+ CODEX_MODEL=gpt-5.5
124
+ CODEX_TIMEOUT=180
125
+ CODEX_CMD=codex
126
+
127
+ # Mistral Vibe - The Devil's Advocate
128
+ MISTRAL_MODEL=mistral-large-3
129
+ MISTRAL_TIMEOUT=180
130
+ MISTRAL_CMD=vibe
131
+
132
+ # Cursor - The Integrator
133
+ CURSOR_MODEL=composer-2.5
134
+ CURSOR_TIMEOUT=180
135
+ CURSOR_CMD=agent
136
+
137
+ # Kimi - The Eastern Sage (K3 via Kimi Code CLI)
138
+ KIMI_MODEL=kimi-code/k3
139
+ KIMI_TIMEOUT=180
140
+ KIMI_CMD=kimi
141
+
142
+ # Claude - The Synthesizer
143
+ CLAUDE_MODEL=claude-opus-4-8
144
+ CLAUDE_TIMEOUT=240
145
+ CLAUDE_CMD=claude
146
+
147
+ # Qwen3 - The Analyst (CLI/API switchable v2.7)
148
+ QWEN3_MODEL=qwen3.7-max
149
+ QWEN3_TIMEOUT=180
150
+ QWEN3_CMD=qwen
151
+
152
+ # =============================================================================
153
+ # API-BASED CONSULTANT CONFIGURATION
154
+ # =============================================================================
155
+
156
+ # GLM - The Methodologist
157
+ GLM_MODEL=glm-5.2
158
+ GLM_TIMEOUT=180
159
+ GLM_API_URL=https://api.z.ai/api/coding/paas/v4/chat/completions
160
+
161
+ # Grok - The Provocateur
162
+ GROK_MODEL=grok-4.5
163
+ GROK_TIMEOUT=180
164
+ GROK_API_URL=https://api.x.ai/v1/chat/completions
165
+
166
+ # DeepSeek - The Code Specialist
167
+ DEEPSEEK_MODEL=deepseek-v4-pro
168
+ DEEPSEEK_TIMEOUT=180
169
+ DEEPSEEK_API_URL=https://api.deepseek.com/v1/chat/completions
170
+
171
+ # MiniMax - The Pragmatic Optimizer (CLI via mmx by default, v2.21; API opt-in)
172
+ MINIMAX_CMD=mmx
173
+ MINIMAX_MODEL=MiniMax-M2.7
174
+ MINIMAX_TIMEOUT=180
175
+ MINIMAX_API_URL=https://api.minimax.io/v1/chat/completions
176
+
177
+ # Response formats for API-based consultants
178
+ QWEN3_FORMAT=qwen
179
+ GLM_FORMAT=openai
180
+ GROK_FORMAT=openai
181
+ DEEPSEEK_FORMAT=openai
182
+ MINIMAX_FORMAT=openai
183
+
184
+ # =============================================================================
185
+ # FEATURES v2.8
186
+ # =============================================================================
187
+
188
+ # Defaults used when --preset / --strategy are omitted
189
+ DEFAULT_PRESET=balanced
190
+ DEFAULT_STRATEGY=majority
191
+
192
+ # The invoking integration normally sets this per run for self-exclusion.
193
+ INVOKING_AGENT=unknown
194
+
195
+ # Personas: specialized roles for each consultant
196
+ ENABLE_PERSONA=true
197
+
198
+ # Auto-synthesis: automatic synthesis of all responses
199
+ ENABLE_SYNTHESIS=true
200
+ SYNTHESIS_CMD=claude
201
+ # Optional synthesis-specific model. Empty delegates model selection to the CLI.
202
+ SYNTHESIS_MODEL=
203
+ SYNTHESIS_EXTRACT_FIELDS=true
204
+ SYNTH_MAX=10
205
+
206
+ # Multi-Agent Debate (MAD): cross-critique rounds
207
+ ENABLE_DEBATE=false
208
+ DEBATE_ROUNDS=1 # 1 = no debate, 2-3 = with cross-critique
209
+
210
+ # Peer Review: anonymous evaluation
211
+ ENABLE_PEER_REVIEW=false
212
+ PEER_REVIEW_MIN_RESPONSES=3
213
+ REVIEWS_PER_CONSULTANT=3
214
+
215
+ # Panic Mode: auto-rigor when uncertainty detected
216
+ ENABLE_PANIC_MODE=auto
217
+ PANIC_CONFIDENCE_THRESHOLD=5
218
+ PANIC_EXTRA_DEBATE_ROUNDS=1
219
+ PANIC_KEYWORDS="uncertain|maybe|not sure|possibly|unclear|depends|hard to say|difficult to determine"
220
+
221
+ # Dynamic orchestration: choose how the panel deliberates
222
+ # auto | fixed | quick | converge | adversarial | tournament | exhaustive
223
+ ORCHESTRATION_MODE=auto
224
+ CONVERGENCE_MAX_ROUNDS=4
225
+ CONVERGENCE_TARGET_CONSENSUS=75
226
+ CONVERGENCE_STALL_EPSILON=5
227
+ ENABLE_ADVERSARIAL_VERIFY=true
228
+
229
+ # Debate optimization: avoid extra rounds when the panel already agrees
230
+ ENABLE_DEBATE_OPTIMIZATION=true
231
+ DEBATE_CONFIDENCE_SPREAD_THRESHOLD=2
232
+ DEBATE_USE_SUMMARIES=true
233
+
234
+ # Health gate and quorum: validate the live panel before spending on a full run
235
+ ENABLE_HEALTH_GATE=false # Adds one small ping per selected consultant
236
+ HEALTH_GATE_TIMEOUT=30
237
+ QUORUM_MIN=2
238
+ QUORUM_ACTION=warn # warn or stop
239
+
240
+ # =============================================================================
241
+ # SEMANTIC CACHING (v2.3)
242
+ # =============================================================================
243
+
244
+ ENABLE_SEMANTIC_CACHE=true
245
+ CACHE_TTL_HOURS=24
246
+ # CACHE_DIR=/custom/cache/path
247
+
248
+ # API retry and rate-limit controls
249
+ API_BASE_BACKOFF=2
250
+ API_MAX_BACKOFF=60
251
+ API_RATE_LIMIT=30
252
+
253
+ # Optional response limits by question category
254
+ ENABLE_RESPONSE_LIMITS=false
255
+ MAX_RESPONSE_TOKENS_BY_CATEGORY=QUICK_SYNTAX:200,CODE_REVIEW:800,BUG_DEBUG:800,ARCHITECTURE:1000,SECURITY:1000,DATABASE:600,GENERAL:500
256
+
257
+ # =============================================================================
258
+ # BUDGET ENFORCEMENT (v2.4, opt-in)
259
+ # =============================================================================
260
+
261
+ ENABLE_BUDGET_LIMIT=false
262
+ BUDGET_ACTION=warn # warn or stop
263
+ MAX_SESSION_COST=1.00
264
+
265
+ # =============================================================================
266
+ # SMART ROUTING
267
+ # =============================================================================
268
+
269
+ # Question classification (required for smart routing)
270
+ ENABLE_CLASSIFICATION=true
271
+ CLASSIFICATION_MODE=pattern # pattern (fast) or llm (accurate)
272
+
273
+ # Smart routing: select consultants based on question category
274
+ ENABLE_SMART_ROUTING=false
275
+ MIN_AFFINITY=7 # Minimum affinity score (1-10) to include
276
+
277
+ # Cost-aware routing (v2.3)
278
+ ENABLE_COST_AWARE_ROUTING=false
279
+ USE_ECONOMIC_MODELS_FOR_SIMPLE=true
280
+ COMPLEXITY_THRESHOLD_SIMPLE=3
281
+ COMPLEXITY_THRESHOLD_MEDIUM=6
282
+ FALLBACK_CONFIDENCE_THRESHOLD=7
283
+
284
+ # Capability-aware routing & voting (v2.20, opt-in): weight votes and rank the
285
+ # panel by each consultant's capability on the quality axis a question stresses
286
+ # (intelligence or taste, per references/affinity.json 'category_axis'). cost is
287
+ # a composition/budget axis only, never a vote weight.
288
+ ENABLE_CAPABILITY_WEIGHTING=false # capability-weighted voting
289
+ ENABLE_CAPABILITY_ROUTING=false # capability-aware panel composition
290
+ CAPABILITY_WEIGHT_STRENGTH=10 # higher = gentler nudge: weight = conf*(S+cap)/S
291
+ CAPABILITY_DEFAULT=5 # fallback capability for a missing consultant/axis
292
+
293
+ # Stance-based semantic consensus (v2.21, opt-in): the panel picks from a shared
294
+ # enumerated stance set so agreement is scored by exact match instead of lexical
295
+ # similarity. Adds ~1 LLM call per run; degrades to the lexical cluster on any
296
+ # failure, so it is always safe to enable.
297
+ ENABLE_STANCE_CONSENSUS=false
298
+ STANCE_MAX_OPTIONS=5 # max stance options generated per question
299
+ STANCE_TIMEOUT=60 # seconds for the stance-generation call (guards a hang)
300
+
301
+ # =============================================================================
302
+ # COST MANAGEMENT
303
+ # =============================================================================
304
+
305
+ ENABLE_COST_TRACKING=true
306
+ WARN_AT_COST=0.50 # Warning threshold (USD)
307
+ ENABLE_RELIABILITY_TRACKING=true
308
+ # COST_TRACKING_FILE=/custom/data/costs.json
309
+ # RELIABILITY_FILE=/custom/data/reliability.json
310
+ # COST_RATES_FILE=/custom/config/cost_rates.json
311
+
312
+ # =============================================================================
313
+ # SESSION MANAGEMENT
314
+ # =============================================================================
315
+
316
+ SESSION_CLEANUP_DAYS=7 # Auto-cleanup sessions older than N days
317
+ # SESSION_DIR=/custom/state/sessions
318
+
319
+ # =============================================================================
320
+ # INTERACTIVE MODE
321
+ # =============================================================================
322
+
323
+ ENABLE_PROGRESS_BARS=true # Show progress bars during consultation
324
+ ENABLE_EARLY_TERMINATION=true # Allow Ctrl+C to stop with partial results
325
+
326
+ # =============================================================================
327
+ # PRE-FLIGHT CHECKS
328
+ # =============================================================================
329
+
330
+ ENABLE_PREFLIGHT=false # Run health check before each consultation
331
+ PREFLIGHT_QUICK=true # Quick mode: CLI check only, skip API test
332
+
333
+ # =============================================================================
334
+ # RETRY & TIMEOUT
335
+ # =============================================================================
336
+
337
+ MAX_RETRIES=2 # Max retry attempts on failure
338
+ RETRY_DELAY_SECONDS=5 # Pause between retries
339
+ LAUNCH_STAGGER_MAX_SECONDS=2
340
+
341
+ # Output directory base
342
+ # DEFAULT_OUTPUT_DIR_BASE=/custom/cache/consultations
343
+
344
+ # Live doctor probe timeout
345
+ DOCTOR_LIVE_TIMEOUT=45
346
+
347
+ # =============================================================================
348
+ # CONTEXT HANDOFF & TOKEN OPTIMIZATION
349
+ # =============================================================================
350
+
351
+ TOKEN_OPTIMIZATION_MODE=ast
352
+ MAX_CONTEXT_FILE_BYTES=8000
353
+ ENABLE_AST_EXTRACTION=true
354
+ ENABLE_SYMBOL_COMPRESSION=false
355
+ ENABLE_SEMANTIC_CHUNKING=true
356
+ CHUNK_MAX_TOKENS=500
357
+ CHUNK_OVERLAP_LINES=5
358
+ CHUNK_PRIORITY_KEYWORDS=main,export,public,api,handler,controller
359
+ INCLUDE_DOCSTRINGS=true
360
+ INCLUDE_CRITICAL_COMMENTS=true
361
+ MAX_BODY_SUMMARY_LINES=3
362
+ MIN_IDENTIFIER_LENGTH=8
363
+ PRESERVE_EXPORTS=true
364
+ USE_COMPACT_PROMPTS=true
365
+ FORCE_PROJECT_TREE=false
366
+ ENABLE_SELECTIVE_CONTEXT=false
367
+ MAX_FILES_PER_CONSULTANT=5
368
+
369
+ # =============================================================================
370
+ # REPORTING & STORAGE
371
+ # =============================================================================
372
+
373
+ ENABLE_COMPACT_REPORT=true
374
+ REPORT_MAX_JSON_LINES=50
375
+ # RATE_LIMIT_DIR=/custom/cache/ratelimit
376
+ # CHUNK_TEMP_DIR=/custom/cache/chunks
377
+
378
+ # =============================================================================
379
+ # CUSTOM ROUTING & PERSONAS
380
+ # =============================================================================
381
+
382
+ # AFFINITY_FILE=/path/to/affinity.json
383
+
384
+ # Each consultant supports _PERSONA_ID (1-21), _PERSONA (custom prompt), and
385
+ # _PERSONA_NAME (custom display name). Uncomment only the overrides you need.
386
+ # GEMINI_PERSONA_ID=1
387
+ # CODEX_PERSONA_ID=2
388
+ # MISTRAL_PERSONA_ID=3
389
+ # CURSOR_PERSONA_ID=5
390
+ # KIMI_PERSONA_ID=20
391
+ # CLAUDE_PERSONA_ID=18
392
+ # QWEN3_PERSONA_ID=6
393
+ # GLM_PERSONA_ID=7
394
+ # GROK_PERSONA_ID=8
395
+ # DEEPSEEK_PERSONA_ID=17
396
+ # MINIMAX_PERSONA_ID=21
397
+ # GEMINI_PERSONA=Custom persona instructions
398
+ # GEMINI_PERSONA_NAME=Custom persona name
399
+ # CODEX_PERSONA=Custom persona instructions
400
+ # CODEX_PERSONA_NAME=Custom persona name
401
+ # MISTRAL_PERSONA=Custom persona instructions
402
+ # MISTRAL_PERSONA_NAME=Custom persona name
403
+ # CURSOR_PERSONA=Custom persona instructions
404
+ # CURSOR_PERSONA_NAME=Custom persona name
405
+ # KIMI_PERSONA=Custom persona instructions
406
+ # KIMI_PERSONA_NAME=Custom persona name
407
+ # CLAUDE_PERSONA=Custom persona instructions
408
+ # CLAUDE_PERSONA_NAME=Custom persona name
409
+ # QWEN3_PERSONA=Custom persona instructions
410
+ # QWEN3_PERSONA_NAME=Custom persona name
411
+ # GLM_PERSONA=Custom persona instructions
412
+ # GLM_PERSONA_NAME=Custom persona name
413
+ # GROK_PERSONA=Custom persona instructions
414
+ # GROK_PERSONA_NAME=Custom persona name
415
+ # DEEPSEEK_PERSONA=Custom persona instructions
416
+ # DEEPSEEK_PERSONA_NAME=Custom persona name
417
+ # MINIMAX_PERSONA=Custom persona instructions
418
+ # MINIMAX_PERSONA_NAME=Custom persona name
419
+
420
+ # Calibration judge commands
421
+ TASTE_JUDGE_CMD=
422
+ JUDGE_CLI=claude
423
+
424
+ # =============================================================================
425
+ # LOGGING
426
+ # =============================================================================
427
+
428
+ LOG_LEVEL=INFO # DEBUG, INFO, WARN, ERROR
package/CLAUDE.md CHANGED
@@ -6,7 +6,7 @@ AI Consultants is a multi-model AI deliberation system that queries up to 11 AI
6
6
 
7
7
  **Self-Exclusion**: The invoking agent is automatically excluded from the panel to prevent self-consultation. Claude Code won't query Claude, Codex CLI won't query Codex, etc.
8
8
 
9
- **Version**: 2.21.1
9
+ **Version**: 2.23.0
10
10
 
11
11
  ## Distribution
12
12
 
@@ -64,8 +64,7 @@ ai-consultants/
64
64
  │ ├── costs.sh # Cost tracking + response limits
65
65
  │ ├── cache.sh # Semantic caching (v2.3)
66
66
  │ ├── api_query.sh # API mode query execution (v2.6)
67
- │ ├── progress.sh # Progress bars
68
- │ └── reflection.sh # Self-reflection + judge step
67
+ │ └── progress.sh # Progress bars
69
68
  ├── references/
70
69
  │ ├── configuration.md # Full configuration reference
71
70
  │ └── details.md # Presets, strategies, best practices
@@ -194,7 +193,7 @@ Functions in `lib/common.sh`:
194
193
  ### Configuration Presets
195
194
  ```bash
196
195
  # Quality Tier Presets (v2.5)
197
- ./scripts/consult_all.sh --preset max_quality "question" # All + premium models + debate
196
+ ./scripts/consult_all.sh --preset max_quality "question" # 8 of 11 consultants + premium models + peer review
198
197
  ./scripts/consult_all.sh --preset medium "question" # 4 consultants + standard models
199
198
  ./scripts/consult_all.sh --preset fast "question" # 2 consultants + economy models
200
199
 
@@ -252,12 +251,6 @@ Process:
252
251
  3. Aggregate peer scores to identify strongest arguments
253
252
  4. De-anonymize in final report
254
253
 
255
- ### Judge Step (Overconfidence Detection)
256
- Functions in `lib/reflection.sh`:
257
- - `judge_response()` - Evaluates single response for overconfidence
258
- - `heuristic_overconfidence_check()` - Fast fallback without LLM
259
- - `judge_all_responses()` - Batch evaluation
260
-
261
254
  ## v2.9 Features
262
255
 
263
256
  ### Kimi CLI Support
@@ -410,7 +403,7 @@ get_model_for_tier "claude" "economy" # → claude-haiku-4-5
410
403
  Three new presets leverage the model tiers:
411
404
 
412
405
  ```bash
413
- # Maximum quality - all premium models + debate + reflection
406
+ # Maximum quality - all premium models + debate + peer review
414
407
  ./scripts/consult_all.sh --preset max_quality "critical architecture decision"
415
408
 
416
409
  # Balanced quality - standard models, 4 consultants, light debate
@@ -802,6 +795,27 @@ curl -fsSL https://raw.githubusercontent.com/matteoscurati/ai-consultants/main/s
802
795
 
803
796
  ## Changelog
804
797
 
798
+ ### v2.23.0
799
+ - **`lib/reflection.sh` deleted (452 lines) and `ENABLE_REFLECTION` / `REFLECTION_CYCLES` removed.** The module was never sourced — `grep -rn 'reflection\.sh' scripts/` matched only the file's own header — so the generate-critique-refine loop had never executed. The two flags were declared at `config.sh` and exported by four presets (`high-stakes`, `max_quality`, `fast`, `_disable_all_consultants`) with no consumer anywhere. It had also aged past the codebase: `_exec_consultant` hardcoded a Gemini/Codex/Mistral case (3 of 11 consultants; the rest hit `*) return 1`) and its Gemini branch still used the pre-`agy` CLI syntax retired in v2.15.0 — so wiring it up as written would have produced partial reflection with a broken Gemini path. Removed rather than implemented because v2.16's `converge`/`adversarial` shapes already run critique-refine off measured consensus rather than a fixed cycle count. Worth noting for archaeology: the module was *maintained* in at least three review passes (v2.15.1 de-fencing, the `--model` parity change, the v2.10.9 `((var++))` sweep) — effort spent on code that never ran.
800
+ - **The release gate had been red since 2.22.0 and nobody could see it.** `scripts/release.sh:26` sources `lib/common.sh` → `config.sh` → `load_user_config` *before* `npm test` at line 194, so `_apply_env_file`'s `export "$key=$value"` put the maintainer's entire `~/.config/ai-consultants/.env` into the test environment. Two suites were not hermetic against that, and the first aborted the run before the second could surface:
801
+ - **`test_user_config.sh`** — `test_xdg_fallback` (Test 6) unsets `AI_CONSULTANTS_CONFIG_DIR` in the suite's own shell (required, to assert the XDG branch) and `_reset_state` never restored it, so the unset leaked into all 22 later tests, which then read the *real* user config. Fixed by re-exporting an empty temp dir in `_reset_state`, making isolation order-independent; tests that legitimately override the dir per-invocation are unaffected. Plus the whole `*_USE_API` set unset at suite top (the guard `test_configure.sh` already carried), and `ENABLE_KIMI`/`GROK_API_URL` (Test 27) and `GEMINI_MODEL`/`PANIC_KEYWORDS` (Test 28) unset inside their subshells — those assert on *real* var names and `load_user_config` lets the environment win over the file by design, so with `config.sh` pre-sourced the file under test was never consulted.
802
+ - **`test_configure.sh`** — `run_clean_configure` scrubbed the nine API keys but no settings, while `configure`'s `has_explicit_value` reads any ambient value as a deliberate pin. An exported `DEFAULT_PRESET` therefore overrode the value Tests 6 and 10 had just written into the file they assert on. The scrub set is now derived from `configure --show-parameters` — configure's own contract — with a hard failure if that list comes back empty, so the scrub can never silently degrade to a no-op. **Verified pre-existing**: the same two assertions fail at `2ac18d4` (the v2.22.0 release commit) under the same conditions, via a throwaway worktree.
803
+ - **`test_functions.sh` was under-reporting failures across the whole file.** `run_tests` scores a test by its exit status — that of its LAST command — so a failing assertion followed by a passing one printed `FAIL`, incremented nothing, and let the suite exit 0. 8 of the 13 test functions run more than one assertion and none accumulated a result. The five `assert_*` helpers now set `_ASSERT_FAILED` on every failure path and `run_tests` fails a test when either that flag or the exit status is non-zero. **Caught by trying to make the new pin fail**: the first version of `test_known_feature_flags_in_sync` printed `FAIL: ... Actual: PHANTOM_FEATURE` while the suite still reported "All tests passed". Verified against a pre-existing test by breaking the first of three assertions in `test_case_conversion` — previously green, now correctly red.
804
+ - **`KNOWN_FEATURE_FLAGS` synced (9 → 27) and pinned.** `_discover_custom_api_agents` (`consult_all.sh:48`) walks `env` and enrolls any `ENABLE_X=true` as a consultant when `X_API_URL` is set and `X` is absent from the registry, so the 18 missing flags — `PEER_REVIEW`, `HEALTH_GATE`, `SEMANTIC_CACHE`, … — were latent phantom consultants. Measured drift: 18 missing, 0 stale. `test_known_feature_flags_in_sync` derives the expected set from `config.sh`'s top-level `ENABLE_*` declarations minus `KNOWN_CLI_AGENTS`/`KNOWN_API_AGENTS` and asserts both directions, so the next added flag fails the build. (Checked that the `^ENABLE_` grep misses nothing declared only inside functions — the sole extra hit was `AGENTNAME`, from the convention's doc comment.)
805
+ - **Preset tables were documenting a mode that stopped being the default in v2.16.** Found by the `/code-review max` pass on the removal branch: renaming the README column from "Reflection" to "Peer Review" turned a code-enforced "No" into a false claim, because `_disable_all_consultants` exported `ENABLE_REFLECTION=false` — the line this release deletes — whereas nothing ever clears `ENABLE_PEER_REVIEW`. Combined with `consult_all.sh:285` force-enabling peer review for the adversarial shape, `--preset medium` on a SECURITY question runs a full billed peer-review round the table promised it would not. The Debate column was stale for the same reason (`DEBATE_ROUNDS` is only read under `ORCHESTRATION_MODE=fixed`). Both tables now state only what the preset pins, with the planner's role called out. Also corrected `max_quality`'s "All consultants" → 8 of 11, which contradicted the README table in the same commit.
806
+
807
+ ### v2.22.0
808
+ - Added the public `ai-consultants configure` / `config` subcommand. Automatic mode detects every current consultant, uses CLI-first transport selection with API fallback when credentials are available, persists to the XDG user config directory, preserves custom values and secrets while refreshing availability-derived `ENABLE_*` flags, backs up rewrites, and keeps files at mode 600.
809
+ - Replaced the stale 1,092-line v2.0 configurator with a compact implementation whose accepted parameter surface is derived from `.env.example`. `--set KEY=VALUE` supports repeatable automation and participates in detection, `--interactive` reviews credentials/transports/panel selection, `--advanced` reviews every parameter, `--show-parameters` exposes the contract, and side-effect-free `--dry-run` redacts secrets.
810
+ - Added `test_configure.sh` (60 assertions) covering public routing, runtime-wide template parity, full-roster detection, API fallback, override precedence/empty values, transport provenance, advanced defaults, export preservation, dry-run isolation/redaction, symlink refusal, backups/permissions, and rejection of removed settings. The npm-pack smoke path now includes `.env.example` and exercises both `init` and `configure` from the installed tarball.
811
+ - **Three interactive/provenance bugs fixed before the subcommand ever shipped** (found in review; none reached a tagged release):
812
+ - **`--interactive` aborted on the first Enter.** `prompt_value` ended both branches with `[[ -n "$reply" ]] && set_value …`. An empty reply — the documented "press Enter to keep" path — made that `&&` list return 1, and since it was the function's last command, `prompt_value` returned 1; under `set -e` the plain call site in the `for` loop killed the script (exit 1, nothing written). Now an explicit `if` block, so an empty reply returns 0.
813
+ - **`--advanced` silently wrote garbage.** `done < <(list_parameters)` redirects fd 0 for the *whole loop body*, so `prompt_value`'s nested `read -r -p` consumed the parameter list instead of the terminal — each prompt took the *next parameter's name* as the user's answer (observed: `AFFINITY_FILE` ← `ANTHROPIC_API_KEY`). Fixed with the standard fd-separation idiom (`read … <&3` / `done 3< <(…)`).
814
+ - **`init` then `configure` disabled four consultants.** `init` copies `.env.example` verbatim, and the template carried uncommented `CODEX_USE_API=false` / `CLAUDE_USE_API` / `MISTRAL_USE_API` / `QWEN3_USE_API`. `has_explicit_value` reads any unmarked value as a user pin, so `configure_switchable` took the explicit-`false` branch: with no CLI and a valid API key the consultant was disabled outright instead of resolving to API. Fixed in the *template*, not the provenance logic — the four switches are now commented out, matching the convention `GEMINI_USE_API`/`MINIMAX_USE_API` already established (commented = auto-resolve, uncommented = force). CLI-first is unaffected: an installed CLI still wins over a present key.
815
+ - **Backup names are now collision-proof.** `${OUTPUT_FILE}.backup.$(date +%Y%m%d_%H%M%S)` is only second-precise, so two runs inside one second resolved to the same path and the second `cp` clobbered the first backup — losing the user's *original* config while keeping a machine-generated one. Now `mktemp "…backup.<ts>.XXXXXX"`, which claims the name atomically (also making concurrent runs safe). Note the collision is unreachable from a sequential test — a real run takes ~1-8s, longer than the granularity — so the regression test stubs `date` on `PATH` to freeze the clock; the backup line is the only `date` caller in this path.
816
+ - **`test_configure.sh` made hermetic against an ambient config environment — `scripts/release.sh` could not run its own gate.** `config.sh` auto-resolves `GEMINI_USE_API`/`MINIMAX_USE_API` and **exports** them; `configure.sh::has_explicit_value` treats any ambient value as a deliberate user pin. `release.sh` sources `lib/common.sh` (→ `config.sh`) *before* running `npm test`, so the gate inherited pinned transports: Tests 4 and 11 failed under `release.sh` while passing from a clean shell — a "flaky" result that was in fact deterministic per-environment. The suite now `unset`s the whole switchable `*_USE_API` set at the top (one place, covering all 10 configure invocations; only the two auto-resolved ones actually leak today, but the set is cleared so a future auto-resolution — as MiniMax gained in v2.21 — cannot silently reopen it). Same class as the v2.21.0 `test_user_config.sh` fix. Verified green both from a clean shell and under `source lib/common.sh; npm test`. Latent since `test_configure.sh` was introduced; it never affected the shipped runtime, only the release gate.
817
+ - Deprecated `setup_wizard.sh` to a compatibility forwarder. Corrected `GOOGLE_API_KEY` to `GEMINI_API_KEY`, removed legacy `/tmp` overrides from the starter template, completed advanced settings/persona coverage, and fixed safe parsing of unquoted `.env` inline comments.
818
+
805
819
  ### v2.21.1
806
820
  - **Kimi upgraded to K3.** `KIMI_MODEL` now defaults to `kimi-code/k3`; premium, standard, and economy tiers all resolve to the same K3 alias.
807
821
  - **Model selection is now real, not metadata-only.** `query_kimi.sh` passes `--model "$KIMI_MODEL"` to the CLI, overriding a stale user-level Kimi default. A dedicated offline regression test captures the CLI arguments and validates response metadata; a live K3 smoke test returned a structured response with confidence 10.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # AI Consultants v2.21.1
1
+ # AI Consultants v2.23.0
2
2
 
3
3
  > **A harness for every question.** A panel of up to 11 frontier models that writes its own playbook per question — fan out, debate to convergence, cross-examine under adversarial review, or run a tournament — and checks its work before it reaches you.
4
4
 
5
- [![Version](https://img.shields.io/badge/version-2.21.1-blue.svg)](https://github.com/matteoscurati/ai-consultants)
5
+ [![Version](https://img.shields.io/badge/version-2.23.0-blue.svg)](https://github.com/matteoscurati/ai-consultants)
6
6
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7
7
  [![Claude Code Skill](https://img.shields.io/badge/Claude%20Code-Skill-orange.svg)](https://docs.anthropic.com/en/docs/claude-code/skills)
8
8
  [![GitHub stars](https://img.shields.io/github/stars/matteoscurati/ai-consultants?style=social)](https://github.com/matteoscurati/ai-consultants)
@@ -428,11 +428,19 @@ Choose the right balance of quality, speed, and cost with model quality tiers.
428
428
 
429
429
  ### Tier Presets
430
430
 
431
- | Preset | Tier | Agents | Debate | Reflection | Use Case |
432
- |--------|------|--------|--------|------------|----------|
433
- | `max_quality` | Premium | 8 | 3 rounds | 2 cycles + peer review | Critical decisions |
434
- | `medium` | Standard | 4 | 1 round | No | General questions |
435
- | `fast` | Economy | 2 | No | No | Quick checks |
431
+ | Preset | Tier | Agents | Use Case |
432
+ |--------|------|--------|----------|
433
+ | `max_quality` | Premium | 8 of 11 | Critical decisions |
434
+ | `medium` | Standard | 4 | General questions |
435
+ | `fast` | Economy | 2 | Quick checks |
436
+
437
+ **Deliberation depth is not fixed by the preset.** Under the default
438
+ `ORCHESTRATION_MODE=auto` the planner picks the shape per question, so the
439
+ `DEBATE_ROUNDS` a preset pins applies only under `ORCHESTRATION_MODE=fixed`,
440
+ and a `SECURITY`-classified question runs the adversarial shape — including a
441
+ peer-review round — whatever preset you chose. `max_quality` additionally
442
+ enables peer review outright; `medium` and `fast` do not *clear* it, so an
443
+ enabled peer review carries into them.
436
444
 
437
445
  ### Models by Tier
438
446
 
@@ -479,8 +487,8 @@ Choose how many consultants to use:
479
487
 
480
488
  | Preset | Consultants | Tier | Use Case |
481
489
  |--------|-------------|------|----------|
482
- | `max_quality` | 8 + debate + reflection | Premium | Critical decisions |
483
- | `medium` | 4 + light debate | Standard | General questions |
490
+ | `max_quality` | 8 of 11 (+ peer review) | Premium | Critical decisions |
491
+ | `medium` | 4 | Standard | General questions |
484
492
  | `fast` | 2 | Economy | Quick checks |
485
493
  | `minimal` | 2 (Gemini + Codex) | Default | Quick questions, low cost |
486
494
  | `balanced` | 4 (+ Mistral + Cursor) | Default | Standard consultations |
@@ -513,13 +521,42 @@ Control how responses are combined:
513
521
 
514
522
  ### Environment Variables
515
523
 
516
- **Most users only need:**
524
+ **Automatic configuration (recommended):**
517
525
 
518
526
  ```bash
519
- ai-consultants init # creates ~/.config/ai-consultants/{config.sh,.env}
520
- $EDITOR ~/.config/ai-consultants/.env
527
+ # Detect installed CLIs and available API keys, then write the persistent config
528
+ ai-consultants configure
529
+
530
+ # Review the consultant selection and transports interactively
531
+ ai-consultants configure --interactive
532
+
533
+ # Set any persistent parameter without opening an editor
534
+ ai-consultants configure \
535
+ --set DEFAULT_PRESET=balanced \
536
+ --set ENABLE_DEBATE=true \
537
+ --set ORCHESTRATION_MODE=converge
538
+
539
+ # Inspect the complete machine-readable parameter surface
540
+ ai-consultants configure --show-parameters
521
541
  ```
522
542
 
543
+ The configurator covers every persistent setting in `scripts/config.sh`, plus
544
+ credentials, persona overrides, transport controls, advanced context knobs, and
545
+ calibration commands. Existing custom values and secrets are preserved, while
546
+ `ENABLE_*` flags are refreshed from detected availability (and can be pinned
547
+ with `--set`). Rewrites create a private timestamped backup. Use `--advanced` to
548
+ review every parameter or `--dry-run` to preview a redacted result.
549
+ Auto-selected `*_USE_API` values are marked `# ai-consultants:auto`, allowing a
550
+ later run to adapt when a CLI or credential changes. Environment variables,
551
+ `--set`, and unmarked values remain explicit user choices.
552
+
553
+ Enter credentials through `--interactive`/`--advanced` or export them before the
554
+ run; avoid passing API keys through `--set`, where the shell may retain them in
555
+ history or expose them in the process list.
556
+
557
+ For a manual starter template instead, run `ai-consultants init` and edit
558
+ `~/.config/ai-consultants/.env`.
559
+
523
560
  For ad-hoc overrides without persisting, the most common knobs:
524
561
 
525
562
  ```bash
@@ -688,6 +725,18 @@ Each consultation generates:
688
725
 
689
726
  ## Changelog
690
727
 
728
+ ### v2.23.0
729
+
730
+ - **`ENABLE_REFLECTION` and `REFLECTION_CYCLES` removed.** The self-reflection module they controlled was never called by anything, so the settings had never affected a consultation — v2.16's `converge` and `adversarial` shapes already run critique-refine off measured consensus. **If you set either key**, remove it: `configure --set ENABLE_REFLECTION=...` now exits non-zero, and both keys are dropped when an existing `.env` is rewritten.
731
+ - **The release gate works again.** Two test suites failed deterministically against any real user configuration, so no release since 2.22.0 could pass its own `npm test`.
732
+ - **`npm test` no longer swallows failures.** A failing assertion followed by a passing one inside the same test function was counted as a pass, across 8 of 13 test functions.
733
+ - **Feature flags can no longer be enrolled as consultants.** A registry that told feature flags apart from custom API agents was 18 entries out of date; it is now complete and pinned by a test.
734
+ - **Preset tables corrected** — they described a debate and peer-review depth the code has not enforced since v2.16, and called `high-stakes`/`max_quality` "all consultants" when they enable 5 and 8 of 11. See the [v2.23.0 release note](docs/releases/v2.23.0.md).
735
+
736
+ ### v2.22.0
737
+
738
+ - **`ai-consultants configure`**: a public automatic configurator. It detects your installed CLIs and API keys, picks CLI-first transports, and writes a private XDG config while preserving your existing settings and secrets. Drive it with repeatable `--set KEY=VALUE`, review it with `--interactive` / `--advanced`, or preview it with `--dry-run`. See the [v2.22.0 release note](docs/releases/v2.22.0.md).
739
+
691
740
  ### v2.21.1
692
741
 
693
742
  - **Kimi K3**: Kimi now defaults to `kimi-code/k3`, and the adapter passes the model explicitly with `--model`.
@@ -759,7 +808,7 @@ Each consultation generates:
759
808
 
760
809
  - **Claude consultant**: New consultant with "The Synthesizer" persona
761
810
  - **Self-exclusion**: Invoking agent automatically excluded from panel
762
- - **Presets**: Quick configuration with `--preset minimal/balanced/high-stakes/local`
811
+ - **Presets**: Quick configuration with `--preset minimal/balanced/high-stakes/security`
763
812
  - **Doctor command**: Diagnostic and auto-fix tool
764
813
  - **Synthesis strategies**: `--strategy majority/risk_averse/security_first/compare_only`
765
814
  - **Confidence intervals**: Statistical confidence ranges (e.g., "8 +/- 1.2")
package/SKILL.md CHANGED
@@ -5,10 +5,10 @@ license: MIT
5
5
  compatibility: Requires bash, jq, and at least 2 AI CLI tools (agy, codex, vibe, etc.). macOS and Linux.
6
6
  metadata:
7
7
  author: matteoscurati
8
- version: 2.21.1
8
+ version: 2.23.0
9
9
  ---
10
10
 
11
- # AI Consultants v2.21.1 - AI Expert Panel
11
+ # AI Consultants v2.23.0 - AI Expert Panel
12
12
 
13
13
  **A harness for every question.** Convene a panel of AI "consultants" for coding questions — and let the engine pick *how* they deliberate: a quick read, a convergence loop, an adversarial refutation gate, a tournament, or an exhaustive sweep. Each consultant has a **configurable persona** that shapes its analysis.
14
14
 
@@ -100,13 +100,16 @@ Query is classified, then sent to consultants in parallel. Responses are scored,
100
100
  All settings use environment variables. Key toggles:
101
101
 
102
102
  ```bash
103
+ ai-consultants configure # Auto-detect CLIs/API keys and persist all settings
103
104
  ENABLE_DEBATE=true # Multi-agent debate
104
105
  ENABLE_SYNTHESIS=true # Automatic synthesis
105
106
  ENABLE_PANIC_MODE=auto # Auto-rigor for uncertainty
106
107
  ENABLE_BUDGET_LIMIT=false # Budget enforcement (v2.4)
107
108
  ```
108
109
 
109
- Enable opt-in consultants: `ENABLE_KIMI`, `ENABLE_QWEN3`, `ENABLE_CLAUDE`, `ENABLE_MINIMAX`.
110
+ Use `ai-consultants configure --show-parameters` for the exact accepted keys,
111
+ `--set KEY=VALUE` for repeatable automation, or `--advanced` to review all of
112
+ them interactively.
110
113
 
111
114
  CLI/API switching: `GEMINI_USE_API`, `CODEX_USE_API`, `CLAUDE_USE_API`, `MISTRAL_USE_API`, `QWEN3_USE_API`.
112
115