ace-llm 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.ace-defaults/llm/config.yml +31 -0
  3. data/.ace-defaults/llm/presets/claude/prompt.yml +5 -0
  4. data/.ace-defaults/llm/presets/claude/ro.yml +6 -0
  5. data/.ace-defaults/llm/presets/claude/rw.yml +4 -0
  6. data/.ace-defaults/llm/presets/claude/yolo.yml +3 -0
  7. data/.ace-defaults/llm/presets/codex/ro.yml +5 -0
  8. data/.ace-defaults/llm/presets/codex/rw.yml +3 -0
  9. data/.ace-defaults/llm/presets/codex/yolo.yml +3 -0
  10. data/.ace-defaults/llm/presets/gemini/ro.yml +4 -0
  11. data/.ace-defaults/llm/presets/gemini/rw.yml +4 -0
  12. data/.ace-defaults/llm/presets/gemini/yolo.yml +4 -0
  13. data/.ace-defaults/llm/presets/opencode/ro.yml +1 -0
  14. data/.ace-defaults/llm/presets/opencode/rw.yml +1 -0
  15. data/.ace-defaults/llm/presets/opencode/yolo.yml +3 -0
  16. data/.ace-defaults/llm/presets/pi/ro.yml +1 -0
  17. data/.ace-defaults/llm/presets/pi/rw.yml +1 -0
  18. data/.ace-defaults/llm/presets/pi/yolo.yml +1 -0
  19. data/.ace-defaults/llm/providers/anthropic.yml +34 -0
  20. data/.ace-defaults/llm/providers/google.yml +36 -0
  21. data/.ace-defaults/llm/providers/groq.yml +29 -0
  22. data/.ace-defaults/llm/providers/lmstudio.yml +24 -0
  23. data/.ace-defaults/llm/providers/mistral.yml +33 -0
  24. data/.ace-defaults/llm/providers/openai.yml +33 -0
  25. data/.ace-defaults/llm/providers/openrouter.yml +45 -0
  26. data/.ace-defaults/llm/providers/togetherai.yml +26 -0
  27. data/.ace-defaults/llm/providers/xai.yml +30 -0
  28. data/.ace-defaults/llm/providers/zai.yml +18 -0
  29. data/.ace-defaults/llm/thinking/claude/high.yml +3 -0
  30. data/.ace-defaults/llm/thinking/claude/low.yml +3 -0
  31. data/.ace-defaults/llm/thinking/claude/medium.yml +3 -0
  32. data/.ace-defaults/llm/thinking/claude/xhigh.yml +3 -0
  33. data/.ace-defaults/llm/thinking/codex/high.yml +3 -0
  34. data/.ace-defaults/llm/thinking/codex/low.yml +3 -0
  35. data/.ace-defaults/llm/thinking/codex/medium.yml +3 -0
  36. data/.ace-defaults/llm/thinking/codex/xhigh.yml +3 -0
  37. data/.ace-defaults/nav/protocols/guide-sources/ace-llm.yml +10 -0
  38. data/CHANGELOG.md +641 -0
  39. data/LICENSE +21 -0
  40. data/README.md +42 -0
  41. data/Rakefile +14 -0
  42. data/exe/ace-llm +25 -0
  43. data/handbook/guides/llm-query-tool-reference.g.md +683 -0
  44. data/handbook/templates/agent/plan-mode.template.md +48 -0
  45. data/lib/ace/llm/atoms/env_reader.rb +155 -0
  46. data/lib/ace/llm/atoms/error_classifier.rb +200 -0
  47. data/lib/ace/llm/atoms/http_client.rb +162 -0
  48. data/lib/ace/llm/atoms/provider_config_validator.rb +260 -0
  49. data/lib/ace/llm/atoms/xdg_directory_resolver.rb +189 -0
  50. data/lib/ace/llm/cli/commands/query.rb +280 -0
  51. data/lib/ace/llm/cli.rb +24 -0
  52. data/lib/ace/llm/configuration.rb +180 -0
  53. data/lib/ace/llm/models/fallback_config.rb +216 -0
  54. data/lib/ace/llm/molecules/client_registry.rb +336 -0
  55. data/lib/ace/llm/molecules/config_loader.rb +39 -0
  56. data/lib/ace/llm/molecules/fallback_orchestrator.rb +218 -0
  57. data/lib/ace/llm/molecules/file_io_handler.rb +158 -0
  58. data/lib/ace/llm/molecules/format_handlers.rb +183 -0
  59. data/lib/ace/llm/molecules/llm_alias_resolver.rb +50 -0
  60. data/lib/ace/llm/molecules/openai_compatible_params.rb +21 -0
  61. data/lib/ace/llm/molecules/preset_loader.rb +99 -0
  62. data/lib/ace/llm/molecules/provider_loader.rb +198 -0
  63. data/lib/ace/llm/molecules/provider_model_parser.rb +172 -0
  64. data/lib/ace/llm/molecules/thinking_level_loader.rb +83 -0
  65. data/lib/ace/llm/organisms/anthropic_client.rb +213 -0
  66. data/lib/ace/llm/organisms/base_client.rb +264 -0
  67. data/lib/ace/llm/organisms/google_client.rb +187 -0
  68. data/lib/ace/llm/organisms/groq_client.rb +197 -0
  69. data/lib/ace/llm/organisms/lmstudio_client.rb +146 -0
  70. data/lib/ace/llm/organisms/mistral_client.rb +180 -0
  71. data/lib/ace/llm/organisms/openai_client.rb +195 -0
  72. data/lib/ace/llm/organisms/openrouter_client.rb +216 -0
  73. data/lib/ace/llm/organisms/togetherai_client.rb +184 -0
  74. data/lib/ace/llm/organisms/xai_client.rb +213 -0
  75. data/lib/ace/llm/organisms/zai_client.rb +149 -0
  76. data/lib/ace/llm/query_interface.rb +455 -0
  77. data/lib/ace/llm/version.rb +7 -0
  78. data/lib/ace/llm.rb +61 -0
  79. metadata +318 -0
@@ -0,0 +1,683 @@
1
+ ---
2
+ doc-type: guide
3
+ title: LLM Query Tool Reference Guide
4
+ purpose: Documentation for ace-llm/handbook/guides/llm-query-tool-reference.g.md
5
+ ace-docs:
6
+ last-updated: 2026-03-12
7
+ last-checked: 2026-03-21
8
+ ---
9
+
10
+ # LLM Query Tool Reference Guide
11
+
12
+ ## Purpose
13
+
14
+ This guide provides comprehensive documentation for the `llm-query` tool, covering all available parameters, usage patterns, provider-specific considerations, and best practices. This reference ensures that team members understand the full capabilities of the tool and can use it effectively in workflows.
15
+
16
+ ## Tool Overview
17
+
18
+ The `llm-query` tool is a unified CLI interface for querying multiple LLM providers. It consolidates provider-specific logic into a single command with consistent parameter syntax across all supported providers.
19
+
20
+ ### Basic Syntax
21
+
22
+ ```bash
23
+ llm-query PROVIDER_MODEL PROMPT [OPTIONS]
24
+ ```
25
+
26
+ ### Quick Examples
27
+
28
+ ```bash
29
+ # Basic query
30
+ llm-query google:gemini-2.5-flash "What is Ruby programming language?"
31
+
32
+ # With system prompt and output
33
+ llm-query anthropic:claude-sonnet-4-20250514 "Review this code" \
34
+ --system system.md \
35
+ --output review.md \
36
+ --timeout 300
37
+
38
+ # Using alias with file input
39
+ llm-query gflash prompt.txt --format json --output response.json
40
+ ```
41
+
42
+ ## Parameter Reference
43
+
44
+ ### Required Arguments
45
+
46
+ #### `PROVIDER_MODEL`
47
+
48
+ Specifies the LLM provider and model to use.
49
+
50
+ **Format Options:**
51
+
52
+ - `provider:model` - Full specification (e.g., `google:gemini-2.5-flash`)
53
+ - `provider` - Provider only, uses default model (e.g., `google`)
54
+ - `alias` - Predefined alias (e.g., `gflash`)
55
+
56
+ **Supported Providers:**
57
+
58
+ - `google` - Google Gemini models
59
+ - `anthropic` - Anthropic Claude models
60
+ - `openai` - OpenAI GPT models
61
+ - `mistral` - Mistral AI models
62
+ - `togetherai` - Together AI models
63
+ - `lmstudio` - Local LM Studio models
64
+
65
+ #### `PROMPT`
66
+
67
+ The prompt text or file path to process.
68
+
69
+ **Input Types:**
70
+
71
+ - **Direct text**: `"What is Ruby programming language?"`
72
+ - **File path**: `prompt.txt` (auto-detected based on file existence)
73
+ - **Stdin**: Use `-` to read from stdin
74
+
75
+ ### Optional Parameters
76
+
77
+ #### `--system` / System Instructions
78
+
79
+ Specify system instructions/prompts separately from user prompts.
80
+
81
+ **Format:** `--system VALUE`
82
+ **Type:** String
83
+ **Input Types:**
84
+
85
+ - **Direct text**: `--system "You are a helpful assistant"`
86
+ - **File path**: `--system system.md` (auto-detected)
87
+
88
+ **Usage:**
89
+
90
+ ```bash
91
+ # Direct system prompt
92
+ llm-query google:gemini-2.5-pro "Explain quantum computing" \
93
+ --system "You are a physics professor. Be precise and educational."
94
+
95
+ # System prompt from file
96
+ llm-query anthropic:claude-sonnet-4-20250514 "Review this code" \
97
+ --system tmpl://review-code/system
98
+ ```
99
+
100
+ #### `--output` / `-o` / File Output
101
+
102
+ Direct output to a file with automatic format detection.
103
+
104
+ **Format:** `--output FILEPATH` or `-o FILEPATH`
105
+ **Type:** String
106
+ **Benefits:**
107
+
108
+ - Captures cost information and usage metrics
109
+ - Enables cost tracking and optimization
110
+ - Prevents output truncation issues
111
+ - Supports format inference from file extension
112
+
113
+ **Usage:**
114
+
115
+ ```bash
116
+ # Auto-detect format from extension
117
+ llm-query gflash "Generate README" --output README.md
118
+
119
+ # Explicit format override
120
+ llm-query csonet "Data analysis" --output report.txt --format json
121
+ ```
122
+
123
+ #### `--format` / Output Format
124
+
125
+ Override output format (normally inferred from file extension).
126
+
127
+ **Format:** `--format VALUE`
128
+ **Type:** String
129
+ **Values:** `text`, `json`, `markdown`
130
+ **Default:** Inferred from file extension or `text`
131
+
132
+ **Usage:**
133
+
134
+ ```bash
135
+ # Force JSON output despite .txt extension
136
+ llm-query openai:gpt-4o "Generate data" --output data.txt --format json
137
+
138
+ # Explicit markdown formatting
139
+ llm-query google "Write tutorial" --format markdown
140
+ ```
141
+
142
+ #### `--temperature` / Creativity Control
143
+
144
+ Control randomness/creativity in responses.
145
+
146
+ **Format:** `--temperature VALUE`
147
+ **Type:** Float
148
+ **Range:** 0.0 - 2.0
149
+ **Default:** Provider-specific (typically 0.7)
150
+
151
+ **Guidelines:**
152
+
153
+ - `0.0-0.3` - Deterministic, factual responses
154
+ - `0.4-0.7` - Balanced creativity and consistency
155
+ - `0.8-1.0` - Creative writing, brainstorming
156
+ - `1.1-2.0` - Highly creative, experimental
157
+
158
+ **Usage:**
159
+
160
+ ```bash
161
+ # Deterministic code review
162
+ llm-query anthropic:claude-sonnet-4-20250514 "Review code" --temperature 0.2
163
+
164
+ # Creative writing
165
+ llm-query google:gemini-2.5-pro "Write a story" --temperature 1.2
166
+ ```
167
+
168
+ #### `--max-tokens` / Output Length Control
169
+
170
+ Limit maximum output tokens.
171
+
172
+ **Format:** `--max-tokens VALUE`
173
+ **Type:** Integer
174
+ **Default:** Provider-specific
175
+
176
+ **Provider Limits:**
177
+
178
+ - Google Gemini: 8,192 tokens (default)
179
+ - Anthropic Claude: 4,096 tokens (default)
180
+ - OpenAI GPT: Model-dependent
181
+
182
+ **Usage:**
183
+
184
+ ```bash
185
+ # Short summary
186
+ llm-query gflash "Summarize this document" --max-tokens 150
187
+
188
+ # Long-form content
189
+ llm-query copus "Write detailed analysis" --max-tokens 4096
190
+ ```
191
+
192
+ #### `--timeout` / Request Timeout
193
+
194
+ Set request timeout in seconds.
195
+
196
+ **Format:** `--timeout VALUE`
197
+ **Type:** Integer
198
+ **Default:** Provider-specific
199
+ **Recommended:** 300-500 seconds for large content
200
+
201
+ **Usage:**
202
+
203
+ ```bash
204
+ # Extended timeout for large documents
205
+ llm-query anthropic:claude-sonnet-4-20250514 "$(cat large-doc.md)" \
206
+ --timeout 500 \
207
+ --output analysis.md
208
+
209
+ # Quick timeout for simple queries
210
+ llm-query gflash "Quick question" --timeout 30
211
+ ```
212
+
213
+ #### `--debug` / `-d` / Debug Output
214
+
215
+ Enable verbose debug information.
216
+
217
+ **Format:** `--debug` or `-d`
218
+ **Type:** Boolean
219
+ **Default:** `false`
220
+
221
+ **Debug Information:**
222
+
223
+ - API request/response details
224
+ - Error stack traces
225
+ - Parameter validation details
226
+ - Provider-specific debugging
227
+
228
+ **Usage:**
229
+
230
+ ```bash
231
+ # Debug API issues
232
+ llm-query google:gemini-2.5-flash "Test query" --debug
233
+
234
+ # Debug with output file
235
+ llm-query csonet "Analysis" --output result.md --debug
236
+ ```
237
+
238
+ #### `--force` / `-f` / Force Overwrite
239
+
240
+ Force overwrite existing output files without confirmation.
241
+
242
+ **Format:** `--force` or `-f`
243
+ **Type:** Boolean
244
+ **Default:** `false`
245
+
246
+ **Use Cases:**
247
+
248
+ - CI/CD automation (non-interactive environments)
249
+ - Batch processing workflows
250
+ - Overwriting previous analysis results
251
+
252
+ **Usage:**
253
+
254
+ ```bash
255
+ # Automation-friendly
256
+ llm-query anthropic:claude-sonnet-4-20250514 "Update analysis" \
257
+ --output existing-report.md \
258
+ --force
259
+
260
+ # Interactive workflow (prompts for confirmation)
261
+ llm-query gflash "New content" --output existing.md
262
+ ```
263
+
264
+ ## Provider-Specific Features
265
+
266
+ ### Google Gemini
267
+
268
+ **Provider ID:** `google`
269
+ **API Key:** `GOOGLE_API_KEY` environment variable
270
+ **Aliases:**
271
+
272
+ - `gflash` → `google:gemini-2.5-flash`
273
+ - `gpro` → `google:gemini-2.5-pro`
274
+
275
+ **Available Models:**
276
+
277
+ - `gemini-2.5-flash` - Fast, efficient model
278
+ - `gemini-2.5-pro` - High-capability model
279
+
280
+ **Capabilities:**
281
+
282
+ - Large context windows
283
+ - Multimodal support (text)
284
+ - Fast response times
285
+
286
+ **Usage:**
287
+
288
+ ```bash
289
+ # Using full specification
290
+ llm-query google:gemini-2.5-flash "Quick question"
291
+
292
+ # Using provider default
293
+ llm-query google "Question with default model"
294
+
295
+ # Using alias
296
+ llm-query gflash "Fast response needed"
297
+ ```
298
+
299
+ ### Anthropic Claude
300
+
301
+ **Provider ID:** `anthropic`
302
+ **API Key:** `ANTHROPIC_API_KEY` environment variable
303
+ **Aliases:**
304
+
305
+ - `csonet` → `anthropic:claude-sonnet-4-20250514`
306
+ - `copus` → `anthropic:claude-4-0-opus-latest`
307
+
308
+ **Available Models:**
309
+
310
+ - `claude-sonnet-4-20250514` - Balanced performance
311
+ - `claude-4-0-opus-latest` - Highest capability
312
+
313
+ **Capabilities:**
314
+
315
+ - Superior reasoning and analysis
316
+ - Excellent code understanding
317
+ - Strong safety alignment
318
+
319
+ **Usage:**
320
+
321
+ ```bash
322
+ # High-quality analysis
323
+ llm-query anthropic:claude-sonnet-4-20250514 "Analyze this code"
324
+
325
+ # Using alias for convenience
326
+ llm-query csonet "Complex reasoning task"
327
+ ```
328
+
329
+ ### OpenAI GPT
330
+
331
+ **Provider ID:** `openai`
332
+ **API Key:** `OPENAI_API_KEY` environment variable
333
+ **Aliases:**
334
+
335
+ - `o4mini` → `openai:gpt-4o-mini`
336
+
337
+ **Available Models:**
338
+
339
+ - `gpt-4o` - Latest high-capability model
340
+ - `gpt-4o-mini` - Efficient model
341
+ - `gpt-3.5-turbo` - Fast, cost-effective
342
+
343
+ **Capabilities:**
344
+
345
+ - Strong general knowledge
346
+ - Good creative writing
347
+ - Reliable performance
348
+
349
+ ### Other Providers
350
+
351
+ **Mistral AI:** `mistral`
352
+ **Together AI:** `togetherai`
353
+ **LM Studio:** `lmstudio` (local models)
354
+
355
+ Each provider follows the same parameter patterns with provider-specific defaults.
356
+
357
+ ## Usage Patterns
358
+
359
+ ### Pattern 1: Basic Query
360
+
361
+ **Use Case:** Simple question-answer interactions
362
+
363
+ ```bash
364
+ llm-query gflash "What is the capital of France?"
365
+ ```
366
+
367
+ ### Pattern 2: System Prompt with File Input
368
+
369
+ **Use Case:** Structured analysis with context
370
+
371
+ ```bash
372
+ llm-query anthropic:claude-sonnet-4-20250514 "$(cat document.md)" \
373
+ --system "You are a technical reviewer. Focus on accuracy and clarity." \
374
+ --output review.md
375
+ ```
376
+
377
+ ### Pattern 3: Code Review Workflow
378
+
379
+ **Use Case:** Systematic code analysis
380
+
381
+ ```bash
382
+ llm-query csonet "$(git diff HEAD~1..HEAD)" \
383
+ --system tmpl://review-code/system \
384
+ --timeout 500 \
385
+ --output code-review.md
386
+ ```
387
+
388
+ ### Pattern 4: Batch Processing
389
+
390
+ **Use Case:** Processing multiple files
391
+
392
+ ```bash
393
+ for file in docs/*.md; do
394
+ llm-query gpro "$(cat "$file")" \
395
+ --system "Summarize this document in 2-3 sentences." \
396
+ --output "summaries/$(basename "$file" .md)-summary.md" \
397
+ --force
398
+ done
399
+ ```
400
+
401
+ ### Pattern 5: Creative Writing
402
+
403
+ **Use Case:** Content generation
404
+
405
+ ```bash
406
+ llm-query google:gemini-2.5-pro "Write a technical blog post about Docker" \
407
+ --temperature 0.8 \
408
+ --max-tokens 2000 \
409
+ --output blog-post.md
410
+ ```
411
+
412
+ ### Pattern 6: Data Analysis
413
+
414
+ **Use Case:** Structured data processing
415
+
416
+ ```bash
417
+ llm-query openai:gpt-4o "$(cat data.json)" \
418
+ --system "Analyze this data and provide insights in JSON format." \
419
+ --format json \
420
+ --output analysis.json
421
+ ```
422
+
423
+ ## Best Practices
424
+
425
+ ### System Prompt Separation
426
+
427
+ **Always use `--system` flag for system instructions:**
428
+
429
+ ```bash
430
+ # ✅ CORRECT: Separate system and user prompts
431
+ llm-query csonet "Review this function" \
432
+ --system "You are a senior developer. Focus on best practices."
433
+
434
+ # ❌ AVOID: Embedding system instructions in user prompt
435
+ llm-query csonet "You are a senior developer. Review this function..."
436
+ ```
437
+
438
+ **Benefits:**
439
+
440
+ - Cleaner prompt structure
441
+ - Better model understanding
442
+ - Consistent results
443
+ - Easier prompt management
444
+
445
+ ### Output and Cost Tracking
446
+
447
+ **Use `--output` flag for important results:**
448
+
449
+ ```bash
450
+ # ✅ CORRECT: Direct file output with cost tracking
451
+ llm-query gpro "Generate report" \
452
+ --output report.md \
453
+ --timeout 300
454
+
455
+ # ❌ SUBOPTIMAL: Manual redirection loses cost information
456
+ llm-query gpro "Generate report" > report.md
457
+ ```
458
+
459
+ **Benefits:**
460
+
461
+ - Cost information captured
462
+ - Usage metrics available
463
+ - No output truncation
464
+ - Better error handling
465
+
466
+ ### Timeout Management
467
+
468
+ **Set appropriate timeouts for content size:**
469
+
470
+ ```bash
471
+ # Large documents need extended timeouts
472
+ llm-query anthropic:claude-sonnet-4-20250514 "$(cat large-handbook.md)" \
473
+ --timeout 500 \
474
+ --output analysis.md
475
+
476
+ # Quick queries can use shorter timeouts
477
+ llm-query gflash "Simple question" --timeout 30
478
+ ```
479
+
480
+ ### Provider Selection
481
+
482
+ **Choose providers based on task requirements:**
483
+
484
+ - **Analysis/Reasoning:** `anthropic:claude-sonnet-4-20250514`
485
+ - **Fast responses:** `google:gemini-2.5-flash`
486
+ - **Creative writing:** `google:gemini-2.5-pro`
487
+ - **General purpose:** `openai:gpt-4o`
488
+
489
+ ### Error Handling
490
+
491
+ **Use `--debug` flag for troubleshooting:**
492
+
493
+ ```bash
494
+ # Debug API issues
495
+ llm-query provider:model "query" --debug --output result.md
496
+ ```
497
+
498
+ **Use `--force` in automation:**
499
+
500
+ ```bash
501
+ # Prevent interactive prompts in CI/CD
502
+ llm-query csonet "Analysis" --output report.md --force
503
+ ```
504
+
505
+ ## Troubleshooting
506
+
507
+ ### Common Issues
508
+
509
+ #### Authentication Errors
510
+
511
+ **Symptoms:**
512
+
513
+ - `401 Unauthorized` responses
514
+ - "Invalid API key" messages
515
+ - Authentication failures
516
+
517
+ **Solutions:**
518
+
519
+ 1. Verify environment variables are set:
520
+
521
+ ```bash
522
+ echo $GOOGLE_API_KEY
523
+ echo $ANTHROPIC_API_KEY
524
+ echo $OPENAI_API_KEY
525
+ ```
526
+
527
+ 2. Check API key format and permissions
528
+ 3. Test with simple query first
529
+ 4. Review provider documentation for key requirements
530
+
531
+ #### Rate Limiting
532
+
533
+ **Symptoms:**
534
+
535
+ - `429 Too Many Requests` responses
536
+ - "Rate limit exceeded" messages
537
+ - Slow response times
538
+
539
+ **Solutions:**
540
+
541
+ 1. Implement delays between requests
542
+ 2. Use different providers for load distribution
543
+ 3. Check API quotas and limits
544
+ 4. Use lighter models for high-frequency requests
545
+
546
+ #### Timeout Issues
547
+
548
+ **Symptoms:**
549
+
550
+ - Operations hang or timeout
551
+ - Large content processing failures
552
+ - Context length exceeded errors
553
+
554
+ **Solutions:**
555
+
556
+ 1. Increase timeout for large content:
557
+
558
+ ```bash
559
+ llm-query provider:model "large-content" --timeout 600
560
+ ```
561
+
562
+ 2. Split large content into smaller chunks
563
+ 3. Use summarization for oversized inputs
564
+ 4. Switch to higher-capacity models
565
+
566
+ #### File Output Issues
567
+
568
+ **Symptoms:**
569
+
570
+ - Cannot write to output file
571
+ - Permission denied errors
572
+ - File overwrite prompts
573
+
574
+ **Solutions:**
575
+
576
+ 1. Check directory permissions
577
+ 2. Use `--force` flag in automation
578
+ 3. Verify output directory exists
579
+ 4. Use absolute file paths
580
+
581
+ #### Provider Availability
582
+
583
+ **Symptoms:**
584
+
585
+ - Unknown provider errors
586
+ - Model not available messages
587
+ - Connection failures
588
+
589
+ **Solutions:**
590
+
591
+ 1. Check provider status pages
592
+ 2. Verify model names and availability
593
+ 3. Use alternative providers as fallbacks
594
+ 4. Check network connectivity
595
+
596
+ ### Debugging Commands
597
+
598
+ **Get available providers and models:**
599
+
600
+ ```bash
601
+ llm-query --help
602
+ ```
603
+
604
+ **Test authentication:**
605
+
606
+ ```bash
607
+ llm-query google "test" --debug
608
+ ```
609
+
610
+ **Validate provider:model combinations:**
611
+
612
+ ```bash
613
+ llm-query google:gemini-2.5-flash "validation test"
614
+ ```
615
+
616
+ ## Workflow Integration
617
+
618
+ ### Review Code Workflow
619
+
620
+ The `llm-query` tool is used extensively in the review-code workflow:
621
+
622
+ **File:** `wfi://review/run`
623
+
624
+ **Usage Pattern:**
625
+
626
+ ```bash
627
+ # Multi-Model LLM Execution (lines 331, 344)
628
+ llm-query google:gemini-2.5-pro \
629
+ "$(cat "${SESSION_DIR}/prompt.md")" \
630
+ --system "${SYSTEM_PROMPT_PATH}" \
631
+ --timeout 500 \
632
+ --output "${SESSION_DIR}/cr-report-gpro.md"
633
+
634
+ llm-query anthropic:claude-3-opus-20240229 \
635
+ "$(cat "${SESSION_DIR}/prompt.md")" \
636
+ --system "${SYSTEM_PROMPT_PATH}" \
637
+ --timeout 500 \
638
+ --output "${SESSION_DIR}/cr-report-opus.md"
639
+ ```
640
+
641
+ ### Handbook Review Command
642
+
643
+ **Canonical source:** `ace-handbook/handbook/skills/`
644
+
645
+ Provider integrations may project these canonical skill definitions into folders such as
646
+ `.claude/skills/`, but the source of truth lives under package `handbook/skills/` directories.
647
+
648
+ **Usage Pattern:**
649
+
650
+ ```bash
651
+ # Pre-configured system prompt and parameters
652
+ system-prompt: dev-local/handbook/tpl/review/system.prompt.md
653
+ timeout: 500 seconds
654
+ output: Direct file output with cost tracking
655
+ ```
656
+
657
+ ### Template Files
658
+
659
+ **System Prompt Templates:**
660
+
661
+ - `tmpl://review-code/system`
662
+ - `tmpl://review-test/system`
663
+ - `tmpl://review-docs/system`
664
+
665
+ **Usage in Workflows:**
666
+
667
+ ```bash
668
+ SYSTEM_PROMPT_PATH="tmpl://review-docs/system"
669
+ llm-query csonet "content" --system "${SYSTEM_PROMPT_PATH}"
670
+ ```
671
+
672
+ ## Related Documentation
673
+
674
+ - **Tool Source:** `llm-query`
675
+
676
+ - **Usage Examples:** `dev-tools/README.md`
677
+
678
+ ## Version Information
679
+
680
+ This documentation covers the llm-query tool as of the current dev-tools implementation. For the latest features and updates, refer to the tool's help output:
681
+ ```bash
682
+ llm-query --help
683
+ ```
@@ -0,0 +1,48 @@
1
+ ---
2
+ doc-type: template
3
+ title: Plan Mode Contract
4
+ purpose: Documentation for ace-llm/handbook/templates/agent/plan-mode.template.md
5
+ ace-docs:
6
+ last-updated: 2026-03-04
7
+ last-checked: 2026-03-21
8
+ ---
9
+
10
+ # Plan Mode Contract
11
+
12
+ <important_instruction>
13
+ PLAN MODE ONLY.
14
+
15
+ - Do not execute implementation work.
16
+ - Do not modify files.
17
+ - Do not request write approvals, permissions, or escalation.
18
+ - Use read-only discovery only when gathering context.
19
+ - If uncertain, choose planning-only behavior.
20
+ </important_instruction>
21
+
22
+ <required_output>
23
+ Return only a comprehensive implementation plan artifact.
24
+
25
+ - Include concrete file paths and verification commands.
26
+ - Keep content decision-complete for implementation handoff.
27
+ - Do not include command-execution handoff text.
28
+ - Output must include these exact markdown headings:
29
+ - `## Task Summary`
30
+ - `## Execution Context`
31
+ - `## Technical Approach`
32
+ - `## File Modifications`
33
+ - `## Plan Checklist`
34
+ - `## Test Plan` *(required for code tasks; omit for documentation/workflow-only tasks)*
35
+ - `## Risk Assessment`
36
+ - `## Freshness Summary`
37
+ - Never output permission/escalation requests, approval prompts, or status-only acknowledgements.
38
+ - Never output shell-command-only responses without the required plan sections.
39
+ </required_output>
40
+
41
+ <self_check>
42
+ Before responding, verify all of the following:
43
+
44
+ - No mutating action was taken.
45
+ - No permission/escalation request appears in output.
46
+ - Output is a plan artifact, not execution guidance.
47
+ - All required headings are present exactly once (## Test Plan only for code tasks).
48
+ </self_check>