|
5 | 5 | Context-aware prompt enhancer CLI. |
6 | 6 |
|
7 | 7 | Retrieves relevant code context from the Context-Engine MCP server and enhances |
8 | | -your prompts with it. Perfect for piping to LLMs or getting quick context. |
| 8 | +your prompts with it using a local LLM decoder. Works with both questions and |
| 9 | +commands/instructions. Outputs at least two detailed paragraphs. |
9 | 10 |
|
10 | 11 | Usage: |
11 | | - ctx "how does hybrid search work?" |
12 | | - ctx --language python "explain the caching logic" |
13 | | - ctx --under scripts/ "how is the watcher implemented?" |
14 | | - ctx --limit 3 "authentication onboarding flow" |
| 12 | + ctx "how does hybrid search work?" # Question → enhanced question |
| 13 | + ctx "refactor the caching logic" # Command → enhanced instructions |
| 14 | + ctx --language python "explain the indexer" # Filter by language |
| 15 | + ctx --detail "add error handling to ctx.py" # Include code snippets |
15 | 16 |
|
16 | 17 | Examples: |
17 | | - # Enhance prompt with context |
| 18 | + # Enhance questions with context |
18 | 19 | ctx "how does the indexer work?" |
| 20 | + # Output: Two detailed question paragraphs with file/line references |
| 21 | +
|
| 22 | + # Enhance commands with specific details |
| 23 | + ctx "refactor ctx.py to improve modularity" |
| 24 | + # Output: Two detailed instruction paragraphs with concrete steps |
| 25 | +
|
| 26 | + # Detail mode: include short code snippets (slower but richer) |
| 27 | + ctx --detail "explain the caching logic" |
19 | 28 |
|
20 | 29 | # Pipe to LLM |
21 | 30 | ctx "fix the bug in watcher.py" | llm |
|
24 | 33 | ctx --language python --under scripts/ "caching implementation" |
25 | 34 |
|
26 | 35 | Environment: |
27 | | - MCP_INDEXER_URL - MCP indexer endpoint (default: http://localhost:8003/mcp) |
28 | | - CTX_LIMIT - Default result limit (default: 5) |
29 | | - CTX_CONTEXT_LINES - Context lines for snippets (default: 0) |
| 36 | + MCP_INDEXER_URL - MCP indexer endpoint (default: http://localhost:8003/mcp) |
| 37 | + CTX_LIMIT - Default result limit (default: 5) |
| 38 | + CTX_CONTEXT_LINES - Context lines for snippets (default: 0) |
| 39 | + CTX_REWRITE_MAX_TOKENS - Max tokens for LLM rewrite (default: 320) |
| 40 | + DECODER_URL - Override decoder endpoint |
| 41 | + USE_GPU_DECODER - Use GPU decoder on port 8081 (default: 0) |
30 | 42 | """ |
31 | 43 |
|
32 | 44 | import sys |
@@ -454,17 +466,26 @@ def build_final_output( |
454 | 466 |
|
455 | 467 | def main(): |
456 | 468 | parser = argparse.ArgumentParser( |
457 | | - description="Context-aware prompt enhancer for Context-Engine", |
| 469 | + description="Context-aware prompt enhancer - rewrites questions and commands with codebase context", |
458 | 470 | formatter_class=argparse.RawDescriptionHelpFormatter, |
459 | 471 | epilog=""" |
460 | 472 | Examples: |
| 473 | + # Questions: enhanced with specific details |
461 | 474 | ctx "how does hybrid search work?" |
| 475 | +
|
| 476 | + # Commands: enhanced with concrete implementation steps |
| 477 | + ctx "refactor ctx.py to improve modularity" |
| 478 | +
|
| 479 | + # Detail mode: include code snippets (slower but richer) |
| 480 | + ctx --detail "explain the caching logic" |
| 481 | +
|
| 482 | + # Pipe to LLM or clipboard |
462 | 483 | ctx --cmd llm "explain the caching logic" |
463 | 484 | ctx --cmd pbcopy --language python "fix bug in watcher" |
464 | 485 | """ |
465 | 486 | ) |
466 | 487 |
|
467 | | - parser.add_argument("query", help="Your question or prompt") |
| 488 | + parser.add_argument("query", help="Your question or command to enhance") |
468 | 489 |
|
469 | 490 | # Command execution |
470 | 491 | parser.add_argument("--cmd", "-c", help="Command to pipe enhanced prompt to (e.g., llm, pbcopy)") |
@@ -492,7 +513,7 @@ def main(): |
492 | 513 |
|
493 | 514 | # Detail mode |
494 | 515 | parser.add_argument("--detail", action="store_true", |
495 | | - help="Include short code snippets in the retrieved context for richer rewrites (slower)") |
| 516 | + help="Include short code snippets for richer rewrites (slower but more specific; auto-clamps to limit=4, per_path=1)") |
496 | 517 |
|
497 | 518 | args = parser.parse_args() |
498 | 519 |
|
|
0 commit comments