ace-tool
Semantic codebase search, code indexing, and prompt enhancement via standalone CLI. Use when: (1) Semantic code search with natural language queries, (2) Code indexing for remote codebase retrieval, (3) Prompt enhancement with codebase context, (4) Before grep/find/glob operation
Install
npx skills add https://github.com/Dianel555/DSkills/tree/main/skills/ace-tool
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install dianel555-dskills@llmmart
git clone https://github.com/Dianel555/DSkills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole dianel555/dskills collection as a plugin from our marketplace. Git is the plain clone.
README
ACE-Tool CLI
Semantic code search, incremental code indexing, and AI-powered prompt enhancement. MCP-independent CLI for codebase navigation and requirement clarification.
Features
- Code Indexing: Incremental scan, hash (SHA-256), and upload whole files to the ACE service
- Remote Search: Semantic codebase retrieval via
POST /agents/codebase-retrievalwith local fallback - Prompt Enhancement: AI-powered prompt refinement with interactive web UI
- Cloud Context Injection: All endpoints (old, new, third-party) inject retrieval context when
--project-rootis provided - Multiple Backends: Support for Augment (
new/old), Claude, OpenAI, Gemini, and Codex APIs - Search Context Injection: Optional codebase context injection for third-party endpoints via XML tags
.aceignoreSupport: Project-level exclusions in addition to root and nested.gitignorerules- Local Fallback: Uses keyword-based search when remote retrieval is unavailable or returns no results
Installation
pip install httpx tenacity "pathspec>=1.1.1,<2"
Quick Start
Authentication Setup
Recommended: Use session.json (compatible with auggie CLI)
# If you have auggie CLI installed, just login:
auggie login
# This creates ~/.augment/session.json with your credentials
Alternative: Environment Variable (for CI/CD)
export AUGMENT_SESSION_AUTH='{"accessToken":"your-token","tenantURL":"https://api.example.com/"}'
Legacy Method (deprecated but still supported)
export ACE_API_URL="https://your-api-endpoint.com"
export ACE_API_TOKEN="your-token-here"
Basic Usage
# Index project (scan, hash, upload code blobs)
python scripts/ace_cli.py index -p .
# Search codebase (remote retrieval if API configured, else local fallback)
python scripts/ace_cli.py search_context -p . -q "user authentication handler"
# Enhance prompt (opens interactive web UI)
python scripts/ace_cli.py enhance_prompt -p "implement login feature" --project-root .
# Enhance prompt (non-interactive, JSON output)
python scripts/ace_cli.py enhance_prompt --no-interactive -p "implement login feature" --project-root .
# Enhance with codex endpoint
python scripts/ace_cli.py --endpoint codex enhance_prompt -p "implement feature"
# Show configuration (check auth_source to verify authentication method)
python scripts/ace_cli.py get_config
CLI Commands
Indexing
| Command | Description |
|---|---|
index -p <path> |
Index project: scan, hash, and upload whole files |
Search Operations
| Command | Description |
|---|---|
search_context -p <path> -q <query> |
Search codebase with natural language |
Enhancement Operations
| Command | Description |
|---|---|
enhance_prompt -p <prompt> |
Enhance prompt (interactive UI) |
enhance_prompt --no-interactive -p <prompt> |
Enhance prompt (JSON output) |
enhance_prompt -H <history> -p <prompt> |
Enhance with conversation history |
enhance_prompt --project-root <path> -p <prompt> |
Enhance with cloud code context |
Configuration
| Command | Description |
|---|---|
get_config |
Show current configuration |
Global Options
python scripts/ace_cli.py [OPTIONS] <command>
Options:
--endpoint TYPE API endpoint: new, old, claude, openai, gemini, codex
--api-url URL Override API base URL
--token TOKEN Override API token
Endpoint Architecture
Supported Endpoints
| Endpoint | API Path | Default Model | Type | Status |
|---|---|---|---|---|
new |
/prompt-enhancer |
claude-sonnet-4-5 |
Augment | ⚠️ Currently unavailable |
old |
/chat-stream (SSE) |
claude-sonnet-4-5 |
Augment | ⚠️ Currently unavailable |
claude |
/v1/messages |
sonnet-4-6-20250929 |
Third-party | ✅ Available |
openai |
/v1/chat/completions |
gpt-5.4 |
Third-party | ✅ Available |
gemini |
/v1beta/models/{model}:generateContent |
gemini-3-flash-preview |
Third-party | ✅ Available |
codex |
/v1/responses |
gpt-5.4 |
Third-party | ✅ Available |
Note: The official Augment endpoints (
newandold) are currently experiencing service issues. Please use third-party endpoints (Claude, OpenAI, Gemini, or Codex) for prompt enhancement features.
Endpoint Resolution
Priority order (highest wins):
PROMPT_ENHANCER_ENDPOINTenv varACE_ENHANCER_ENDPOINTenv var (legacy fallback)--endpointCLI flag- Default:
new
Codex Endpoint
The codex endpoint routes to OpenAI's Responses API (/v1/responses). It uses the input/output array format instead of the Chat Completions messages format. Response parsing handles output_text content parts, final_answer phase priority, and refusal detection.
export PROMPT_ENHANCER_ENDPOINT=codex
export PROMPT_ENHANCER_BASE_URL=https://api.openai.com
export PROMPT_ENHANCER_TOKEN=sk-...
python scripts/ace_cli.py enhance_prompt -p "implement feature"
URL Construction
All HTTP calls use build_api_url(base_url, path) which handles version prefix deduplication (e.g., https://api.example.com/v1 + /v1/messages → https://api.example.com/v1/messages, not .../v1/v1/messages).
Configuration
Authentication
ACE-Tool supports multiple authentication methods with the following priority:
- Constructor parameters (highest priority, programmatic use only)
~/.augment/session.json(recommended, created byauggie login)AUGMENT_SESSION_AUTH(CI/CD and headless environments)- Legacy
ACE_API_*(deprecated, backward compatibility only)
Method 1: session.json (Recommended)
Use auggie login to create ~/.augment/session.json:
{
"accessToken": "your-token-here",
"tenantURL": "https://api.example.com/",
"scopes": ["email"]
}
Method 2: AUGMENT_SESSION_AUTH (CI/CD)
export AUGMENT_SESSION_AUTH='{"accessToken":"your-token","tenantURL":"https://api.example.com/"}'
Method 3: Legacy Environment Variables (Deprecated)
export ACE_API_URL=https://your-augment-api.com
export ACE_API_TOKEN=your-augment-token
⚠️ Note: ACE_API_URL and ACE_API_TOKEN are deprecated but still supported for backward compatibility. New projects should use session.json or AUGMENT_SESSION_AUTH.
Verify Configuration
Use get_config to check current authentication source:
python scripts/ace_cli.py get_config
# Output includes: "auth_source": "session.json" | "AUGMENT_SESSION_AUTH" | "ACE_API_TOKEN" | "none"
Environment Variables
| Variable | Description |
|---|---|
AUGMENT_SESSION_AUTH |
JSON string with accessToken and tenantURL (new format, recommended for CI/CD) |
ACE_API_URL |
⚠️ Deprecated - Augment API base URL (use session.json or AUGMENT_SESSION_AUTH instead) |
ACE_API_TOKEN |
⚠️ Deprecated - Augment API token (use session.json or AUGMENT_SESSION_AUTH instead) |
PROMPT_ENHANCER_ENDPOINT |
Endpoint type override (takes precedence over ACE_ENHANCER_ENDPOINT) |
ACE_ENHANCER_ENDPOINT |
Legacy endpoint override (fallback) |
PROMPT_ENHANCER_BASE_URL |
Third-party API base URL |
PROMPT_ENHANCER_TOKEN |
Third-party API key |
PROMPT_ENHANCER_MODEL |
Model override for third-party endpoints |
PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT |
Enable search context injection (1, true, yes, on) |
ACE_UPLOAD_READ_TIMEOUT_SECONDS |
Upload response read inactivity timeout in seconds (default: 300) |
ACE_UPLOAD_BATCH_COUNT |
Maximum blobs per batch (default/maximum: 30) |
ACE_UPLOAD_BATCH_BYTES |
Maximum UTF-8 content bytes per batch (default/maximum: 1048576) |
For slow synchronous embedding, increase the read timeout and/or reduce batch size. The byte budget measures file content only, excluding JSON and HTTP overhead; each blob must fit within it. Settings must be positive and finite. Read/write and other uncertain transport errors, or HTTP 408, 429, and 5xx responses, trigger /agents/blob-status polling before any retransmission. Previously uncertain blobs receive a 5-second grace period when status is unknown; pending blobs are polled up to 180 seconds. These are not strict wall-clock limits because HTTPX read timeouts measure inactivity. If status remains uncertain or unavailable, the client automatically retries up to three potentially sent attempts per blob, tracked across process restarts. The server may still be processing an earlier request, so duplicate server work is possible. Exhausted attempts, authentication failures, and unsafe recovery state produce explicit errors; no manual prompt is shown.
.env File
Create .env in the project root (see .env.example):
# Recommended: Use ~/.augment/session.json (created by `auggie login`)
# or set AUGMENT_SESSION_AUTH for CI/CD
# Legacy format (deprecated)
# ACE_API_URL=https://your-augment-api.com
# ACE_API_TOKEN=your-augment-token
PROMPT_ENHANCER_ENDPOINT=new
# Third-party API (optional)
# PROMPT_ENHANCER_BASE_URL=https://api.anthropic.com
# PROMPT_ENHANCER_TOKEN=your-api-key
# PROMPT_ENHANCER_MODEL=sonnet-4-6-20250929
# Search context injection (optional, for third-party endpoints)
# PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT=1
Search Context Injection
When PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT is enabled and a third-party endpoint is used, the system:
- Searches the codebase via ACE API using the original prompt as query
- Normalizes the result (placeholder if empty, truncates at 12,000 chars)
- Wraps search results in
<codebase_context>XML tags - Wraps the original prompt in
<original_request>XML tags - Sends the combined prompt to the third-party LLM
Requirements:
--project-rootmust be provided (raisesValueErrorotherwise)ACE_API_URLandACE_API_TOKENmust be configured
This is separate from the cloud retrieval context that Augment endpoints (new/old) inject automatically via --project-root.
.aceignore
Project-root and nested .gitignore files apply with Git's directory-relative pattern precedence. A project-root .aceignore uses the same glob syntax as an independent, additional exclusion filter: its negations can override earlier .aceignore rules but cannot re-include files excluded by .gitignore. Both filters also apply to local fallback; an ignored parent directory cannot be re-included by a child pattern.
# .aceignore example
test_fixtures/
*.generated.ts
large_data/
node_modules/
.*/
logs/
tests/
Indexing Details
The index command performs incremental indexing:
- Scan: Walks project files filtered by extension whitelist, binary blacklist,
.gitignore+.aceignorepatterns (with glob support), andEXCLUDE_PATTERNS - Hash:
SHA-256(path_bytes + content_bytes)per blob - Files: Uploads each file up to 128 KiB with its original path; any chunking is performed by the service.
- Cache: Incremental via
mtime + sizecheck; stored as.ace-tool/index.json.gz. Legacy chunk-based caches are rebuilt once. - Hierarchy: The supplied project root is the index and upload boundary. Each root keeps its own cache; indexing a parent does not delete child caches.
- Boundary: Symbolic links, junctions and other reparse points below the root are never followed, and the index cache is read and written through a verified handle. Only real files inside the root are read and uploaded; a link, an out-of-boundary path or an oversized cache is skipped or rebuilt rather than followed.
- Recovery and concurrency: A per-project OS lock serializes cooperating processes through cache publication.
.ace-tool/upload-journal.jsonstores blob hashes, hashed service origins and API path prefixes, and attempt state before uploads, but no file contents or tokens. API URL paths must contain only non-secret prefixes: credentials belong in the separate token configuration, not in URLs. Configured tokens in URL paths are rejected, but arbitrary secrets in paths cannot be detected automatically. Blobs are checked with current credentials before upload; confirmed ready blobs are reused, while unresolved blobs are retried within the persistent attempt budget. Acknowledged entries are compacted from the journal; uncertain entries and their attempt counts are retained. If the 64 MiB journal cannot accommodate unresolved entries, uploads stop with an explicit error. The persistent.ace-tool.lockmarker rejects mixed Windows and POSIX/WSL access to the same project root; use a separate root for each platform. - Readiness: Indexing, search and project-scoped prompt enhancement poll
POST /agents/blob-statusbefore using blobs, with a 3-minute polling deadline and per-request network timeouts. Unsupported or invalid status responses are errors, not empty search results. - Retrieval timeout: Remote retrieval allows up to 2 minutes per network read, with a 15-second connection timeout; readiness has a separate 3-minute deadline.
- Empty results: Empty remote retrieval (including OCE's header-only response) falls back to local keyword matching. Local prompt context contains matching file paths, not semantic code snippets.
- Self-heal: Unknown blobs trigger one full rescan, with status checks before re-uploading missing blobs, followed by a readiness check; a subsequent unknown-blob error is reported.
- Upload: Batch upload (≤30 blobs, ≤1 MiB of content per batch) to
POST /batch-upload. Confirmed connection failures are retried; 401/403 abort. Ambiguous results are checked through blob status and may be retried automatically within the persistent budget; 429 waits for the boundedRetry-Afterdelay before reconciliation. A successful upload response must confirm every expected SHA-256 blob name. - Failure: An upload failure raises an error and leaves the previous cache on disk unchanged; stale entries are not returned as successful results.
- Encoding: Multi-encoding detection chain (
utf-8 → gbk → gb18030 → cp1252)
Output Format
All CLI output is JSON:
// Index result
{"total_blobs": 42, "last_indexed": 1234567890.0, "project_root": "."}
// Search result (remote)
{"results": "formatted retrieval text...", "query": "...", "mode": "remote", "blob_count": 42}
// Search result (local fallback)
{"results": [{"file": "src/auth.py", "score": 5}], "query": "...", "mode": "local_fallback"}
// Enhancement result
{"enhanced_prompt": "..."}
// Configuration
{"base_url": "...", "endpoint": "new", "endpoint_effective": "new", "endpoint_env_ready": true, "token_configured": true, "third_party_configured": false, "search_context_injection": false}
// Error
{"error": "message", "status_code": 401}
Project Structure
skills/ace-tool/
├── SKILL.md # Agent instructions
├── README.md # Developer documentation
└── scripts/
├── .env.example # Environment template
├── __init__.py
├── __main__.py # Module entry point
├── ace_cli.py # CLI entry point
├── client.py # API client (search, enhance, retrieval, all endpoints)
├── indexer.py # Code indexer (scan, hash, upload, .aceignore)
├── templates.py # Prompt templates and constants
├── utils.py # Utilities (encoding detection, content sanitization)
└── web_ui.py # Interactive web UI
Acknowledgments
- Based on missdeer/ace-tool-rs
Skill manifest
ACE-Tool - Semantic Code Search & Prompt Enhancement
High-performance semantic search, code indexing, and AI-powered prompt enhancement. Standalone CLI (no MCP dependency).
Execution Methods
# Prerequisites: pip install httpx tenacity "pathspec>=1.1.1,<2"
# Environment: ACE_API_URL, ACE_API_TOKEN (optional for local fallback)
# Index project for remote search (upload code blobs to ACE service)
python scripts/ace_cli.py index -p /path/to/project
# Search codebase with natural language (remote if API configured, else local fallback)
python scripts/ace_cli.py search_context -p /path/to/project -q "function that handles authentication"
# Enhance prompt (interactive mode - default, opens browser)
python scripts/ace_cli.py enhance_prompt -p "implement login feature" -H "User: what auth method?\nAssistant: JWT"
# Enhance prompt (non-interactive, JSON output)
python scripts/ace_cli.py enhance_prompt --no-interactive -p "implement login feature"
# Enhance prompt with project context (enables cloud retrieval for all endpoints)
python scripts/ace_cli.py enhance_prompt -p "implement login feature" --project-root /path/to/project
# Enhance prompt with specific endpoint
python scripts/ace_cli.py --endpoint claude enhance_prompt -p "implement login feature"
# Enhance prompt with codex endpoint
python scripts/ace_cli.py --endpoint codex enhance_prompt -p "implement feature"
# Check configuration
python scripts/ace_cli.py get_config
Tool Routing Policy
Prefer ACE-Tool Over Built-in Tools
| Task | Avoid | Use ACE-Tool CLI |
|---|---|---|
| Find function by purpose | grep "def func" |
search_context -q "function that..." |
| Locate feature code | find . -name "*.py" |
search_context -q "feature description" |
| Clarify requirements | Manual analysis | enhance_prompt -p "requirement" |
| Understand code flow | Multiple grep/read | search_context -q "flow description" |
| Index codebase | N/A | index -p <project_root> |
When to Use Built-in Tools
- Exact string matching (known identifiers)
- File path patterns (known naming conventions)
- Simple text replacement
Command Reference
index
Index project files for remote codebase retrieval. Scans, hashes, and uploads whole files (up to 128 KiB) with their original paths to the ACE batch-upload API; chunking is left to the service. Uses incremental indexing with gzip JSON cache at .ace-tool/index.json.gz; legacy chunk-based caches are rebuilt once. Respects both .gitignore and .aceignore patterns. The supplied project root is the index and upload boundary; each root keeps its own cache, and indexing a parent does not delete child caches. Symbolic links, junctions and other reparse points below the root are never followed, so only real files inside the root are read and uploaded; an unreadable or out-of-boundary path is skipped instead of falling back to a plain path read. The backend must confirm upload hashes and support the OCE-compatible /agents/blob-status endpoint; indexing, search, and scoped enhancement wait for readiness and report a timeout or unsupported status explicitly. Unknown blobs trigger one rebuild and re-upload.
python scripts/ace_cli.py index -p <project_root>
Options:
-p, --project-root Project root path (required)
search_context
Search codebase using natural language descriptions. Routes to remote API (POST /agents/codebase-retrieval) when configured, with local keyword fallback for remote errors or empty results. Upload and readiness failures remain explicit errors. Local fallback supplies matching file paths, not semantic code snippets.
python scripts/ace_cli.py search_context -p <project_root> -q <query>
Options:
-p, --project-root Project root path (required)
-q, --query Natural language query (required)
enhance_prompt
Enhance prompts with codebase context and conversation history. All endpoints inject cloud retrieval context when --project-root is provided. Third-party endpoints additionally support search context injection via PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT.
python scripts/ace_cli.py [--endpoint TYPE] enhance_prompt -p <prompt> [options]
Global Options:
--endpoint Endpoint type: new, old, claude, openai, gemini, codex (default: new)
--api-url Override API base URL
--token Override API token
Command Options:
-p, --prompt Original prompt (required)
-H, --history Conversation history: "User: xxx\nAssistant: yyy"
--history-file File containing conversation history
--project-root Project root path (enables cloud retrieval context)
--no-interactive Disable web UI, output JSON directly
--no-browser Don't auto-open browser, just print URL
--port Port for web server (default: 8765)
get_config
Show current configuration status including endpoint resolution, env readiness, authentication source, and search context injection state.
python scripts/ace_cli.py get_config
Output fields:
base_url- Currently configured API base URLendpoint- Active enhancer endpoint (new/old/claude/openai/gemini/codex)endpoint_effective- Resolved endpoint after env variable resolutionendpoint_env_ready- Whether required endpoint configuration is completetoken_configured- Whether authentication token is setthird_party_configured- Whether third-party endpoint config is completeauth_source- Authentication source:constructor|session.json|AUGMENT_SESSION_AUTH|ACE_API_TOKEN|nonesearch_context_injection- Whether search context injection is enabled
Interactive Enhancement
Default mode opens web UI with actions:
| Button | Action |
|---|---|
| Regenerate | Discard current, generate new enhancement from original prompt |
| Refine | Iteratively improve current version, preserving your edits |
| Use Original | Return the original prompt without enhancement |
| Send Enhanced | Confirm and use the current enhanced prompt |
| Cancel | Abort the enhancement process |
Keyboard Shortcuts: Ctrl+Enter Send | Esc Cancel
Endpoint Architecture
Supported Endpoints
| Endpoint | API Path | Default Model | Auth Header | Status |
|---|---|---|---|---|
new |
/prompt-enhancer |
claude-sonnet-4-5 |
Bearer ACE_API_TOKEN |
⚠️ Currently unavailable |
old |
/chat-stream (SSE) |
claude-sonnet-4-5 |
Bearer ACE_API_TOKEN |
⚠️ Currently unavailable |
claude |
/v1/messages |
sonnet-4-6-20250929 |
x-api-key |
✅ Available |
openai |
/v1/chat/completions |
gpt-5.4 |
Bearer PROMPT_ENHANCER_TOKEN |
✅ Available |
gemini |
/v1beta/models/{model}:generateContent |
gemini-3-flash-preview |
x-goog-api-key |
✅ Available |
codex |
/v1/responses |
gpt-5.4 |
Bearer PROMPT_ENHANCER_TOKEN |
✅ Available |
Note: The official Augment endpoints (
newandold) are currently experiencing service issues. Use third-party endpoints for prompt enhancement.
Endpoint Resolution Order
PROMPT_ENHANCER_ENDPOINT > ACE_ENHANCER_ENDPOINT (legacy) > --endpoint CLI flag > new (default)
Third-Party Endpoints
claude, openai, gemini, codex are third-party endpoints. They require:
PROMPT_ENHANCER_BASE_URL— API base URLPROMPT_ENHANCER_TOKEN— API key/tokenPROMPT_ENHANCER_MODEL— (optional) override default model
Missing configuration raises ValueError immediately (hard error, no silent fallback).
URL Construction
All HTTP calls use build_api_url(base_url, path) which handles /v1/, /v1beta/ version prefix deduplication. No hardcoded f-string URL construction.
Environment Variables
Authentication (Priority Order)
ACE-Tool supports multiple authentication methods with the following priority:
- Constructor parameters (highest priority, programmatic use only)
~/.augment/session.json(recommended, created byauggie login)AUGMENT_SESSION_AUTH(CI/CD and headless environments)- Legacy
ACE_API_*(deprecated, backward compatibility only)
| Variable | Description |
|---|---|
AUGMENT_SESSION_AUTH |
JSON string with accessToken and tenantURL (new format, recommended for CI/CD) |
ACE_API_URL |
⚠️ Deprecated - ACE API base URL (use session.json or AUGMENT_SESSION_AUTH instead) |
ACE_API_TOKEN |
⚠️ Deprecated - ACE API authentication token (use session.json or AUGMENT_SESSION_AUTH instead) |
Recommended: Use ~/.augment/session.json
Create this file via auggie login, or manually with this format:
{
"accessToken": "your-token-here",
"tenantURL": "https://api.example.com/",
"scopes": ["email"]
}
For CI/CD: Use AUGMENT_SESSION_AUTH environment variable
export AUGMENT_SESSION_AUTH='{"accessToken":"token","tenantURL":"https://api.example.com/"}'
Migration Guide: Legacy to New Format
If currently using ACE_API_URL and ACE_API_TOKEN:
- Option A (Recommended): Use
auggie loginto create~/.augment/session.json - Option B: Convert to
AUGMENT_SESSION_AUTH:export AUGMENT_SESSION_AUTH='{"accessToken":"YOUR_ACE_API_TOKEN","tenantURL":"YOUR_ACE_API_URL"}' - Remove old variables (optional, they'll be ignored if new format exists)
Legacy variables continue to work for backward compatibility but are not recommended for new setups.
Endpoint Configuration
| Variable | Description |
|---|---|
PROMPT_ENHANCER_ENDPOINT |
Endpoint override: new, old, claude, openai, gemini, codex |
ACE_ENHANCER_ENDPOINT |
Legacy endpoint override (fallback if PROMPT_ENHANCER_ENDPOINT not set) |
PROMPT_ENHANCER_BASE_URL |
Third-party API base URL (for claude/openai/gemini/codex endpoints) |
PROMPT_ENHANCER_TOKEN |
Third-party API token |
PROMPT_ENHANCER_MODEL |
Override default model for third-party endpoints |
PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT |
Enable search context injection for third-party endpoints (1, true, yes, on) |
ACE_UPLOAD_READ_TIMEOUT_SECONDS |
Upload response read inactivity timeout in seconds (default: 300) |
ACE_UPLOAD_BATCH_COUNT |
Maximum blobs per batch (default/maximum: 30) |
ACE_UPLOAD_BATCH_BYTES |
Maximum UTF-8 content bytes per batch (default/maximum: 1048576) |
Settings are positive and finite. The byte budget counts content only, excluding JSON/HTTP overhead, and each blob must fit within it. Read/write and other uncertain transport errors, or HTTP 408, 429, and 5xx responses, trigger /agents/blob-status polling before retransmission. Previously uncertain blobs receive a 5-second grace period when status is unknown; pending blobs are polled up to 180 seconds. These are not strict wall-clock limits because HTTPX read timeouts measure inactivity. When status remains uncertain or unavailable, unresolved blobs are retried automatically up to three potentially sent attempts per blob across process restarts. The server may still be processing an earlier request, so this does not guarantee exactly-once server work. Exhausted attempts, authentication failures, and unsafe recovery state produce explicit errors.
A per-project OS lock serializes cooperating processes through index publication. .ace-tool/upload-journal.json stores blob hashes, hashed service origins and API path prefixes, and attempt state, not file contents or tokens. URL paths must contain only non-secret API prefixes; configure credentials separately. Configured tokens in paths are rejected, but arbitrary path secrets cannot be detected automatically. Blobs are checked with current credentials before upload and ready blobs are reused. Acknowledged entries are compacted; uncertain entries and their attempt counts are retained. Uploads fail explicitly if unresolved entries exceed the 64 MiB journal limit. The persistent .ace-tool.lock marker rejects mixed Windows and POSIX/WSL access to the same project root; use a separate root for each platform.
Search Context Injection
When PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT is enabled and a third-party endpoint is used, the system automatically:
- Performs a remote codebase search via ACE API using the original prompt as query
- Normalizes the result (placeholder if empty, truncate at 12000 chars if too long)
- Wraps the search results in
<codebase_context>XML tags - Wraps the original prompt in
<original_request>XML tags - Sends the combined prompt to the third-party LLM
Requires --project-root and valid ACE_API_URL/ACE_API_TOKEN. Raises ValueError if project_root is missing when injection is enabled.
.aceignore
Project-root and nested .gitignore files apply with Git's directory-relative pattern precedence. A project-root .aceignore uses the same glob syntax as an independent, additional exclusion filter: its negations can override earlier .aceignore rules but cannot re-include files excluded by .gitignore. Both filters also apply to local fallback; an ignored parent directory cannot be re-included by a child pattern.
# .aceignore example
test_fixtures/
*.generated.ts
large_data/
node_modules/
.*/
logs/
tests/
Workflow
Phase 0: Index Project (once or after major changes)
index -p . # Upload code blobs to ACE
Phase 1: Semantic Search
search_context -p . -q "database connection pooling" # Remote retrieval or local fallback
Phase 2: Prompt Enhancement
enhance_prompt -p "optimize query performance" --project-root . # With cloud context
# Review and refine enhanced prompt
# Use Regenerate/Refine as needed
# Send Enhanced to confirm
Error Handling
{"error": "error message", "status_code": 401}
| Error | Recovery |
|---|---|
| No API configured | Uses local fallback for search_context; returns original for enhance |
| Token invalid (401) | Check API token (logged at ERROR level) |
| Access denied (403) | Token may be disabled (logged at ERROR level) |
| Upload failure | Report an error; keep the previous cache on disk without returning its stale blobs |
| Connection timeout | Retries up to 3 times with exponential backoff |
| No results | Broaden search query |
| Third-party not configured | ValueError raised immediately (no silent fallback) |
| Search context missing project_root | ValueError raised when injection enabled without --project-root |
Anti-Patterns
| Prohibited | Correct |
|---|---|
| Grep before semantic search | Use search_context first |
| Skip prompt enhancement | Use enhance_prompt for complex tasks |
| Ignore conversation history | Include history in enhance_prompt |
| Use exact match for conceptual search | Use natural language query |
| Always use non-interactive mode | Use interactive mode for review |
Skip --project-root for enhance |
Include it for cloud-based code context |
Files (dskills)
-
scripts
-
ace_cli.py 5.5 KB
Loading… -
client.py 35.5 KB
Loading… -
indexer.py 30 KB
Loading… -
secure_fs.py 24.8 KB
Loading… -
templates.py 5.1 KB
Loading… -
upload_recovery.py 12.8 KB
Loading… -
utils.py 6.9 KB
Loading… -
web_ui.py 21.3 KB
Loading… -
__init__.py 630 B
Loading… -
__main__.py 125 B
Loading…
-
-
tests
-
conftest.py 113 B
Loading… -
test_auth_upgrade.py 7.8 KB
Loading… -
test_cli.py 3.4 KB
Loading… -
test_client_auth_integration.py 4.9 KB
Loading… -
test_client_endpoints.py 4.1 KB
Loading… -
test_codex_endpoint.py 3.2 KB
Loading… -
test_empty_retrieval_fallback.py 3.5 KB
Loading… -
test_gitignore_behavior.py 6.8 KB
Loading… -
test_indexer_boundary.py 18.1 KB
Loading… -
test_indexer_ignore.py 1.8 KB
Loading… -
test_index_readiness.py 12.6 KB
Loading… -
test_reasoning_effort.py 3.9 KB
Loading… -
test_retry_budget.py 869 B
Loading… -
test_search_context.py 4.4 KB
Loading… -
test_upload_acknowledgement.py 6.4 KB
Loading… -
test_upload_recovery.py 36 KB
Loading… -
test_upload_timeout.py 14.3 KB
Loading… -
test_url_and_400error.py 15.5 KB
Loading… -
test_whole_file_indexing.py 2.9 KB
Loading… -
__init__.py 0 B
Loading…
-
-
.env.example 2.9 KB · in bundle
-
README.md 15.4 KB
# ACE-Tool CLI Semantic code search, incremental code indexing, and AI-powered prompt enhancement. MCP-independent CLI for codebase navigation and requirement clarification. ## Features - **Code Indexing**: Incremental scan, hash (SHA-256), and upload whole files to the ACE service - **Remote Search**: Semantic codebase retrieval via `POST /agents/codebase-retrieval` with local fallback - **Prompt Enhancement**: AI-powered prompt refinement with interactive web UI - **Cloud Context Injection**: All endpoints (old, new, third-party) inject retrieval context when `--project-root` is provided - **Multiple Backends**: Support for Augment (`new`/`old`), Claude, OpenAI, Gemini, and Codex APIs - **Search Context Injection**: Optional codebase context injection for third-party endpoints via XML tags - **`.aceignore` Support**: Project-level exclusions in addition to root and nested `.gitignore` rules - **Local Fallback**: Uses keyword-based search when remote retrieval is unavailable or returns no results ## Installation ```bash pip install httpx tenacity "pathspec>=1.1.1,<2" ``` ## Quick Start ### Authentication Setup **Recommended: Use session.json (compatible with auggie CLI)** ```bash # If you have auggie CLI installed, just login: auggie login # This creates ~/.augment/session.json with your credentials ``` **Alternative: Environment Variable (for CI/CD)** ```bash export AUGMENT_SESSION_AUTH='{"accessToken":"your-token","tenantURL":"https://api.example.com/"}' ``` **Legacy Method (deprecated but still supported)** ```bash export ACE_API_URL="https://your-api-endpoint.com" export ACE_API_TOKEN="your-token-here" ``` ### Basic Usage ```bash # Index project (scan, hash, upload code blobs) python scripts/ace_cli.py index -p . # Search codebase (remote retrieval if API configured, else local fallback) python scripts/ace_cli.py search_context -p . -q "user authentication handler" # Enhance prompt (opens interactive web UI) python scripts/ace_cli.py enhance_prompt -p "implement login feature" --project-root . # Enhance prompt (non-interactive, JSON output) python scripts/ace_cli.py enhance_prompt --no-interactive -p "implement login feature" --project-root . # Enhance with codex endpoint python scripts/ace_cli.py --endpoint codex enhance_prompt -p "implement feature" # Show configuration (check auth_source to verify authentication method) python scripts/ace_cli.py get_config ``` ## CLI Commands ### Indexing | Command | Description | |---------|-------------| | `index -p <path>` | Index project: scan, hash, and upload whole files | ### Search Operations | Command | Description | |---------|-------------| | `search_context -p <path> -q <query>` | Search codebase with natural language | ### Enhancement Operations | Command | Description | |---------|-------------| | `enhance_prompt -p <prompt>` | Enhance prompt (interactive UI) | | `enhance_prompt --no-interactive -p <prompt>` | Enhance prompt (JSON output) | | `enhance_prompt -H <history> -p <prompt>` | Enhance with conversation history | | `enhance_prompt --project-root <path> -p <prompt>` | Enhance with cloud code context | ### Configuration | Command | Description | |---------|-------------| | `get_config` | Show current configuration | ## Global Options ```bash python scripts/ace_cli.py [OPTIONS] <command> Options: --endpoint TYPE API endpoint: new, old, claude, openai, gemini, codex --api-url URL Override API base URL --token TOKEN Override API token ``` ## Endpoint Architecture ### Supported Endpoints | Endpoint | API Path | Default Model | Type | Status | |----------|----------|---------------|------|--------| | `new` | `/prompt-enhancer` | `claude-sonnet-4-5` | Augment | ⚠️ Currently unavailable | | `old` | `/chat-stream` (SSE) | `claude-sonnet-4-5` | Augment | ⚠️ Currently unavailable | | `claude` | `/v1/messages` | `sonnet-4-6-20250929` | Third-party | ✅ Available | | `openai` | `/v1/chat/completions` | `gpt-5.4` | Third-party | ✅ Available | | `gemini` | `/v1beta/models/{model}:generateContent` | `gemini-3-flash-preview` | Third-party | ✅ Available | | `codex` | `/v1/responses` | `gpt-5.4` | Third-party | ✅ Available | > **Note**: The official Augment endpoints (`new` and `old`) are currently experiencing service issues. Please use third-party endpoints (Claude, OpenAI, Gemini, or Codex) for prompt enhancement features. ### Endpoint Resolution Priority order (highest wins): 1. `PROMPT_ENHANCER_ENDPOINT` env var 2. `ACE_ENHANCER_ENDPOINT` env var (legacy fallback) 3. `--endpoint` CLI flag 4. Default: `new` ### Codex Endpoint The `codex` endpoint routes to OpenAI's Responses API (`/v1/responses`). It uses the `input`/`output` array format instead of the Chat Completions `messages` format. Response parsing handles `output_text` content parts, `final_answer` phase priority, and refusal detection. ```bash export PROMPT_ENHANCER_ENDPOINT=codex export PROMPT_ENHANCER_BASE_URL=https://api.openai.com export PROMPT_ENHANCER_TOKEN=sk-... python scripts/ace_cli.py enhance_prompt -p "implement feature" ``` ### URL Construction All HTTP calls use `build_api_url(base_url, path)` which handles version prefix deduplication (e.g., `https://api.example.com/v1` + `/v1/messages` → `https://api.example.com/v1/messages`, not `.../v1/v1/messages`). ## Configuration ### Authentication ACE-Tool supports multiple authentication methods with the following priority: 1. **Constructor parameters** (highest priority, programmatic use only) 2. **`~/.augment/session.json`** (recommended, created by `auggie login`) 3. **`AUGMENT_SESSION_AUTH`** (CI/CD and headless environments) 4. **Legacy `ACE_API_*`** (deprecated, backward compatibility only) **Method 1: session.json (Recommended)** Use `auggie login` to create `~/.augment/session.json`: ```json { "accessToken": "your-token-here", "tenantURL": "https://api.example.com/", "scopes": ["email"] } ``` **Method 2: AUGMENT_SESSION_AUTH (CI/CD)** ```bash export AUGMENT_SESSION_AUTH='{"accessToken":"your-token","tenantURL":"https://api.example.com/"}' ``` **Method 3: Legacy Environment Variables (Deprecated)** ```bash export ACE_API_URL=https://your-augment-api.com export ACE_API_TOKEN=your-augment-token ``` ⚠️ **Note**: `ACE_API_URL` and `ACE_API_TOKEN` are deprecated but still supported for backward compatibility. New projects should use `session.json` or `AUGMENT_SESSION_AUTH`. **Verify Configuration** Use `get_config` to check current authentication source: ```bash python scripts/ace_cli.py get_config # Output includes: "auth_source": "session.json" | "AUGMENT_SESSION_AUTH" | "ACE_API_TOKEN" | "none" ``` ### Environment Variables | Variable | Description | |----------|-------------| | `AUGMENT_SESSION_AUTH` | JSON string with `accessToken` and `tenantURL` (new format, recommended for CI/CD) | | `ACE_API_URL` | ⚠️ **Deprecated** - Augment API base URL (use session.json or AUGMENT_SESSION_AUTH instead) | | `ACE_API_TOKEN` | ⚠️ **Deprecated** - Augment API token (use session.json or AUGMENT_SESSION_AUTH instead) | | `PROMPT_ENHANCER_ENDPOINT` | Endpoint type override (takes precedence over `ACE_ENHANCER_ENDPOINT`) | | `ACE_ENHANCER_ENDPOINT` | Legacy endpoint override (fallback) | | `PROMPT_ENHANCER_BASE_URL` | Third-party API base URL | | `PROMPT_ENHANCER_TOKEN` | Third-party API key | | `PROMPT_ENHANCER_MODEL` | Model override for third-party endpoints | | `PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT` | Enable search context injection (`1`, `true`, `yes`, `on`) | | `ACE_UPLOAD_READ_TIMEOUT_SECONDS` | Upload response read inactivity timeout in seconds (default: 300) | | `ACE_UPLOAD_BATCH_COUNT` | Maximum blobs per batch (default/maximum: 30) | | `ACE_UPLOAD_BATCH_BYTES` | Maximum UTF-8 content bytes per batch (default/maximum: 1048576) | For slow synchronous embedding, increase the read timeout and/or reduce batch size. The byte budget measures file content only, excluding JSON and HTTP overhead; each blob must fit within it. Settings must be positive and finite. Read/write and other uncertain transport errors, or HTTP 408, 429, and 5xx responses, trigger `/agents/blob-status` polling before any retransmission. Previously uncertain blobs receive a 5-second grace period when status is unknown; pending blobs are polled up to 180 seconds. These are not strict wall-clock limits because HTTPX read timeouts measure inactivity. If status remains uncertain or unavailable, the client automatically retries up to three potentially sent attempts per blob, tracked across process restarts. The server may still be processing an earlier request, so duplicate server work is possible. Exhausted attempts, authentication failures, and unsafe recovery state produce explicit errors; no manual prompt is shown. ### .env File Create `.env` in the project root (see `.env.example`): ```bash # Recommended: Use ~/.augment/session.json (created by `auggie login`) # or set AUGMENT_SESSION_AUTH for CI/CD # Legacy format (deprecated) # ACE_API_URL=https://your-augment-api.com # ACE_API_TOKEN=your-augment-token PROMPT_ENHANCER_ENDPOINT=new # Third-party API (optional) # PROMPT_ENHANCER_BASE_URL=https://api.anthropic.com # PROMPT_ENHANCER_TOKEN=your-api-key # PROMPT_ENHANCER_MODEL=sonnet-4-6-20250929 # Search context injection (optional, for third-party endpoints) # PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT=1 ``` ## Search Context Injection When `PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT` is enabled and a third-party endpoint is used, the system: 1. Searches the codebase via ACE API using the original prompt as query 2. Normalizes the result (placeholder if empty, truncates at 12,000 chars) 3. Wraps search results in `<codebase_context>` XML tags 4. Wraps the original prompt in `<original_request>` XML tags 5. Sends the combined prompt to the third-party LLM Requirements: - `--project-root` must be provided (raises `ValueError` otherwise) - `ACE_API_URL` and `ACE_API_TOKEN` must be configured This is separate from the cloud retrieval context that Augment endpoints (`new`/`old`) inject automatically via `--project-root`. ## .aceignore Project-root and nested `.gitignore` files apply with Git's directory-relative pattern precedence. A project-root `.aceignore` uses the same glob syntax as an independent, additional exclusion filter: its negations can override earlier `.aceignore` rules but cannot re-include files excluded by `.gitignore`. Both filters also apply to local fallback; an ignored parent directory cannot be re-included by a child pattern. ``` # .aceignore example test_fixtures/ *.generated.ts large_data/ node_modules/ .*/ logs/ tests/ ``` ## Indexing Details The `index` command performs incremental indexing: - **Scan**: Walks project files filtered by extension whitelist, binary blacklist, `.gitignore` + `.aceignore` patterns (with glob support), and `EXCLUDE_PATTERNS` - **Hash**: `SHA-256(path_bytes + content_bytes)` per blob - **Files**: Uploads each file up to 128 KiB with its original path; any chunking is performed by the service. - **Cache**: Incremental via `mtime + size` check; stored as `.ace-tool/index.json.gz`. Legacy chunk-based caches are rebuilt once. - **Hierarchy**: The supplied project root is the index and upload boundary. Each root keeps its own cache; indexing a parent does not delete child caches. - **Boundary**: Symbolic links, junctions and other reparse points below the root are never followed, and the index cache is read and written through a verified handle. Only real files inside the root are read and uploaded; a link, an out-of-boundary path or an oversized cache is skipped or rebuilt rather than followed. - **Recovery and concurrency**: A per-project OS lock serializes cooperating processes through cache publication. `.ace-tool/upload-journal.json` stores blob hashes, hashed service origins and API path prefixes, and attempt state before uploads, but no file contents or tokens. API URL paths must contain only non-secret prefixes: credentials belong in the separate token configuration, not in URLs. Configured tokens in URL paths are rejected, but arbitrary secrets in paths cannot be detected automatically. Blobs are checked with current credentials before upload; confirmed ready blobs are reused, while unresolved blobs are retried within the persistent attempt budget. Acknowledged entries are compacted from the journal; uncertain entries and their attempt counts are retained. If the 64 MiB journal cannot accommodate unresolved entries, uploads stop with an explicit error. The persistent `.ace-tool.lock` marker rejects mixed Windows and POSIX/WSL access to the same project root; use a separate root for each platform. - **Readiness**: Indexing, search and project-scoped prompt enhancement poll `POST /agents/blob-status` before using blobs, with a 3-minute polling deadline and per-request network timeouts. Unsupported or invalid status responses are errors, not empty search results. - **Retrieval timeout**: Remote retrieval allows up to 2 minutes per network read, with a 15-second connection timeout; readiness has a separate 3-minute deadline. - **Empty results**: Empty remote retrieval (including OCE's header-only response) falls back to local keyword matching. Local prompt context contains matching file paths, not semantic code snippets. - **Self-heal**: Unknown blobs trigger one full rescan, with status checks before re-uploading missing blobs, followed by a readiness check; a subsequent unknown-blob error is reported. - **Upload**: Batch upload (≤30 blobs, ≤1 MiB of content per batch) to `POST /batch-upload`. Confirmed connection failures are retried; 401/403 abort. Ambiguous results are checked through blob status and may be retried automatically within the persistent budget; 429 waits for the bounded `Retry-After` delay before reconciliation. A successful upload response must confirm every expected SHA-256 blob name. - **Failure**: An upload failure raises an error and leaves the previous cache on disk unchanged; stale entries are not returned as successful results. - **Encoding**: Multi-encoding detection chain (`utf-8 → gbk → gb18030 → cp1252`) ## Output Format All CLI output is JSON: ```json // Index result {"total_blobs": 42, "last_indexed": 1234567890.0, "project_root": "."} // Search result (remote) {"results": "formatted retrieval text...", "query": "...", "mode": "remote", "blob_count": 42} // Search result (local fallback) {"results": [{"file": "src/auth.py", "score": 5}], "query": "...", "mode": "local_fallback"} // Enhancement result {"enhanced_prompt": "..."} // Configuration {"base_url": "...", "endpoint": "new", "endpoint_effective": "new", "endpoint_env_ready": true, "token_configured": true, "third_party_configured": false, "search_context_injection": false} // Error {"error": "message", "status_code": 401} ``` ## Project Structure ``` skills/ace-tool/ ├── SKILL.md # Agent instructions ├── README.md # Developer documentation └── scripts/ ├── .env.example # Environment template ├── __init__.py ├── __main__.py # Module entry point ├── ace_cli.py # CLI entry point ├── client.py # API client (search, enhance, retrieval, all endpoints) ├── indexer.py # Code indexer (scan, hash, upload, .aceignore) ├── templates.py # Prompt templates and constants ├── utils.py # Utilities (encoding detection, content sanitization) └── web_ui.py # Interactive web UI ``` ## Acknowledgments - Based on [missdeer/ace-tool-rs](https://github.com/missdeer/ace-tool-rs) -
ruff.toml 656 B
Loading… -
SKILL.md 15.4 KB
--- name: ace-tool description: | Semantic codebase search, code indexing, and prompt enhancement via standalone CLI. Use when: (1) Semantic code search with natural language queries, (2) Code indexing for remote codebase retrieval, (3) Prompt enhancement with codebase context, (4) Before grep/find/glob operations for better accuracy, (5) Complex requirements clarification, (6) Large codebase navigation. Triggers: "search context", "enhance prompt", "find code that", "index project", "clarify requirements". IMPORTANT: Always use ace-tool BEFORE grep/find/glob for semantic-level code location. --- # ACE-Tool - Semantic Code Search & Prompt Enhancement High-performance semantic search, code indexing, and AI-powered prompt enhancement. Standalone CLI (no MCP dependency). ## Execution Methods ```bash # Prerequisites: pip install httpx tenacity "pathspec>=1.1.1,<2" # Environment: ACE_API_URL, ACE_API_TOKEN (optional for local fallback) # Index project for remote search (upload code blobs to ACE service) python scripts/ace_cli.py index -p /path/to/project # Search codebase with natural language (remote if API configured, else local fallback) python scripts/ace_cli.py search_context -p /path/to/project -q "function that handles authentication" # Enhance prompt (interactive mode - default, opens browser) python scripts/ace_cli.py enhance_prompt -p "implement login feature" -H "User: what auth method?\nAssistant: JWT" # Enhance prompt (non-interactive, JSON output) python scripts/ace_cli.py enhance_prompt --no-interactive -p "implement login feature" # Enhance prompt with project context (enables cloud retrieval for all endpoints) python scripts/ace_cli.py enhance_prompt -p "implement login feature" --project-root /path/to/project # Enhance prompt with specific endpoint python scripts/ace_cli.py --endpoint claude enhance_prompt -p "implement login feature" # Enhance prompt with codex endpoint python scripts/ace_cli.py --endpoint codex enhance_prompt -p "implement feature" # Check configuration python scripts/ace_cli.py get_config ``` ## Tool Routing Policy ### Prefer ACE-Tool Over Built-in Tools | Task | Avoid | Use ACE-Tool CLI | |------|-------|------------------| | Find function by purpose | `grep "def func"` | `search_context -q "function that..."` | | Locate feature code | `find . -name "*.py"` | `search_context -q "feature description"` | | Clarify requirements | Manual analysis | `enhance_prompt -p "requirement"` | | Understand code flow | Multiple grep/read | `search_context -q "flow description"` | | Index codebase | N/A | `index -p <project_root>` | ### When to Use Built-in Tools - Exact string matching (known identifiers) - File path patterns (known naming conventions) - Simple text replacement ## Command Reference ### index Index project files for remote codebase retrieval. Scans, hashes, and uploads whole files (up to 128 KiB) with their original paths to the ACE batch-upload API; chunking is left to the service. Uses incremental indexing with gzip JSON cache at `.ace-tool/index.json.gz`; legacy chunk-based caches are rebuilt once. Respects both `.gitignore` and `.aceignore` patterns. The supplied project root is the index and upload boundary; each root keeps its own cache, and indexing a parent does not delete child caches. Symbolic links, junctions and other reparse points below the root are never followed, so only real files inside the root are read and uploaded; an unreadable or out-of-boundary path is skipped instead of falling back to a plain path read. The backend must confirm upload hashes and support the OCE-compatible `/agents/blob-status` endpoint; indexing, search, and scoped enhancement wait for readiness and report a timeout or unsupported status explicitly. Unknown blobs trigger one rebuild and re-upload. ```bash python scripts/ace_cli.py index -p <project_root> Options: -p, --project-root Project root path (required) ``` ### search_context Search codebase using natural language descriptions. Routes to remote API (`POST /agents/codebase-retrieval`) when configured, with local keyword fallback for remote errors or empty results. Upload and readiness failures remain explicit errors. Local fallback supplies matching file paths, not semantic code snippets. ```bash python scripts/ace_cli.py search_context -p <project_root> -q <query> Options: -p, --project-root Project root path (required) -q, --query Natural language query (required) ``` ### enhance_prompt Enhance prompts with codebase context and conversation history. All endpoints inject cloud retrieval context when `--project-root` is provided. Third-party endpoints additionally support search context injection via `PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT`. ```bash python scripts/ace_cli.py [--endpoint TYPE] enhance_prompt -p <prompt> [options] Global Options: --endpoint Endpoint type: new, old, claude, openai, gemini, codex (default: new) --api-url Override API base URL --token Override API token Command Options: -p, --prompt Original prompt (required) -H, --history Conversation history: "User: xxx\nAssistant: yyy" --history-file File containing conversation history --project-root Project root path (enables cloud retrieval context) --no-interactive Disable web UI, output JSON directly --no-browser Don't auto-open browser, just print URL --port Port for web server (default: 8765) ``` ### get_config Show current configuration status including endpoint resolution, env readiness, authentication source, and search context injection state. ```bash python scripts/ace_cli.py get_config ``` **Output fields:** - `base_url` - Currently configured API base URL - `endpoint` - Active enhancer endpoint (new/old/claude/openai/gemini/codex) - `endpoint_effective` - Resolved endpoint after env variable resolution - `endpoint_env_ready` - Whether required endpoint configuration is complete - `token_configured` - Whether authentication token is set - `third_party_configured` - Whether third-party endpoint config is complete - `auth_source` - Authentication source: `constructor` | `session.json` | `AUGMENT_SESSION_AUTH` | `ACE_API_TOKEN` | `none` - `search_context_injection` - Whether search context injection is enabled ## Interactive Enhancement Default mode opens web UI with actions: | Button | Action | |--------|--------| | **Regenerate** | Discard current, generate new enhancement from original prompt | | **Refine** | Iteratively improve current version, preserving your edits | | **Use Original** | Return the original prompt without enhancement | | **Send Enhanced** | Confirm and use the current enhanced prompt | | **Cancel** | Abort the enhancement process | **Keyboard Shortcuts:** `Ctrl+Enter` Send | `Esc` Cancel ## Endpoint Architecture ### Supported Endpoints | Endpoint | API Path | Default Model | Auth Header | Status | |----------|----------|---------------|-------------|--------| | `new` | `/prompt-enhancer` | `claude-sonnet-4-5` | `Bearer ACE_API_TOKEN` | ⚠️ Currently unavailable | | `old` | `/chat-stream` (SSE) | `claude-sonnet-4-5` | `Bearer ACE_API_TOKEN` | ⚠️ Currently unavailable | | `claude` | `/v1/messages` | `sonnet-4-6-20250929` | `x-api-key` | ✅ Available | | `openai` | `/v1/chat/completions` | `gpt-5.4` | `Bearer PROMPT_ENHANCER_TOKEN` | ✅ Available | | `gemini` | `/v1beta/models/{model}:generateContent` | `gemini-3-flash-preview` | `x-goog-api-key` | ✅ Available | | `codex` | `/v1/responses` | `gpt-5.4` | `Bearer PROMPT_ENHANCER_TOKEN` | ✅ Available | > **Note**: The official Augment endpoints (`new` and `old`) are currently experiencing service issues. Use third-party endpoints for prompt enhancement. ### Endpoint Resolution Order `PROMPT_ENHANCER_ENDPOINT` > `ACE_ENHANCER_ENDPOINT` (legacy) > `--endpoint` CLI flag > `new` (default) ### Third-Party Endpoints `claude`, `openai`, `gemini`, `codex` are third-party endpoints. They require: - `PROMPT_ENHANCER_BASE_URL` — API base URL - `PROMPT_ENHANCER_TOKEN` — API key/token - `PROMPT_ENHANCER_MODEL` — (optional) override default model Missing configuration raises `ValueError` immediately (hard error, no silent fallback). ### URL Construction All HTTP calls use `build_api_url(base_url, path)` which handles `/v1/`, `/v1beta/` version prefix deduplication. No hardcoded f-string URL construction. ## Environment Variables ### Authentication (Priority Order) ACE-Tool supports multiple authentication methods with the following priority: 1. **Constructor parameters** (highest priority, programmatic use only) 2. **`~/.augment/session.json`** (recommended, created by `auggie login`) 3. **`AUGMENT_SESSION_AUTH`** (CI/CD and headless environments) 4. **Legacy `ACE_API_*`** (deprecated, backward compatibility only) | Variable | Description | |----------|-------------| | `AUGMENT_SESSION_AUTH` | JSON string with `accessToken` and `tenantURL` (new format, recommended for CI/CD) | | `ACE_API_URL` | ⚠️ **Deprecated** - ACE API base URL (use session.json or AUGMENT_SESSION_AUTH instead) | | `ACE_API_TOKEN` | ⚠️ **Deprecated** - ACE API authentication token (use session.json or AUGMENT_SESSION_AUTH instead) | **Recommended: Use `~/.augment/session.json`** Create this file via `auggie login`, or manually with this format: ```json { "accessToken": "your-token-here", "tenantURL": "https://api.example.com/", "scopes": ["email"] } ``` **For CI/CD: Use `AUGMENT_SESSION_AUTH` environment variable** ```bash export AUGMENT_SESSION_AUTH='{"accessToken":"token","tenantURL":"https://api.example.com/"}' ``` **Migration Guide: Legacy to New Format** If currently using `ACE_API_URL` and `ACE_API_TOKEN`: 1. **Option A** (Recommended): Use `auggie login` to create `~/.augment/session.json` 2. **Option B**: Convert to `AUGMENT_SESSION_AUTH`: ```bash export AUGMENT_SESSION_AUTH='{"accessToken":"YOUR_ACE_API_TOKEN","tenantURL":"YOUR_ACE_API_URL"}' ``` 3. Remove old variables (optional, they'll be ignored if new format exists) Legacy variables continue to work for backward compatibility but are not recommended for new setups. ### Endpoint Configuration | Variable | Description | |----------|-------------| | `PROMPT_ENHANCER_ENDPOINT` | Endpoint override: `new`, `old`, `claude`, `openai`, `gemini`, `codex` | | `ACE_ENHANCER_ENDPOINT` | Legacy endpoint override (fallback if `PROMPT_ENHANCER_ENDPOINT` not set) | | `PROMPT_ENHANCER_BASE_URL` | Third-party API base URL (for claude/openai/gemini/codex endpoints) | | `PROMPT_ENHANCER_TOKEN` | Third-party API token | | `PROMPT_ENHANCER_MODEL` | Override default model for third-party endpoints | | `PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT` | Enable search context injection for third-party endpoints (`1`, `true`, `yes`, `on`) | | `ACE_UPLOAD_READ_TIMEOUT_SECONDS` | Upload response read inactivity timeout in seconds (default: 300) | | `ACE_UPLOAD_BATCH_COUNT` | Maximum blobs per batch (default/maximum: 30) | | `ACE_UPLOAD_BATCH_BYTES` | Maximum UTF-8 content bytes per batch (default/maximum: 1048576) | Settings are positive and finite. The byte budget counts content only, excluding JSON/HTTP overhead, and each blob must fit within it. Read/write and other uncertain transport errors, or HTTP 408, 429, and 5xx responses, trigger `/agents/blob-status` polling before retransmission. Previously uncertain blobs receive a 5-second grace period when status is unknown; pending blobs are polled up to 180 seconds. These are not strict wall-clock limits because HTTPX read timeouts measure inactivity. When status remains uncertain or unavailable, unresolved blobs are retried automatically up to three potentially sent attempts per blob across process restarts. The server may still be processing an earlier request, so this does not guarantee exactly-once server work. Exhausted attempts, authentication failures, and unsafe recovery state produce explicit errors. A per-project OS lock serializes cooperating processes through index publication. `.ace-tool/upload-journal.json` stores blob hashes, hashed service origins and API path prefixes, and attempt state, not file contents or tokens. URL paths must contain only non-secret API prefixes; configure credentials separately. Configured tokens in paths are rejected, but arbitrary path secrets cannot be detected automatically. Blobs are checked with current credentials before upload and ready blobs are reused. Acknowledged entries are compacted; uncertain entries and their attempt counts are retained. Uploads fail explicitly if unresolved entries exceed the 64 MiB journal limit. The persistent `.ace-tool.lock` marker rejects mixed Windows and POSIX/WSL access to the same project root; use a separate root for each platform. ## Search Context Injection When `PROMPT_ENHANCER_INCLUDE_SEARCH_CONTEXT` is enabled and a third-party endpoint is used, the system automatically: 1. Performs a remote codebase search via ACE API using the original prompt as query 2. Normalizes the result (placeholder if empty, truncate at 12000 chars if too long) 3. Wraps the search results in `<codebase_context>` XML tags 4. Wraps the original prompt in `<original_request>` XML tags 5. Sends the combined prompt to the third-party LLM Requires `--project-root` and valid `ACE_API_URL`/`ACE_API_TOKEN`. Raises `ValueError` if `project_root` is missing when injection is enabled. ## .aceignore Project-root and nested `.gitignore` files apply with Git's directory-relative pattern precedence. A project-root `.aceignore` uses the same glob syntax as an independent, additional exclusion filter: its negations can override earlier `.aceignore` rules but cannot re-include files excluded by `.gitignore`. Both filters also apply to local fallback; an ignored parent directory cannot be re-included by a child pattern. ``` # .aceignore example test_fixtures/ *.generated.ts large_data/ node_modules/ .*/ logs/ tests/ ``` ## Workflow ### Phase 0: Index Project (once or after major changes) ```bash index -p . # Upload code blobs to ACE ``` ### Phase 1: Semantic Search ```bash search_context -p . -q "database connection pooling" # Remote retrieval or local fallback ``` ### Phase 2: Prompt Enhancement ```bash enhance_prompt -p "optimize query performance" --project-root . # With cloud context # Review and refine enhanced prompt # Use Regenerate/Refine as needed # Send Enhanced to confirm ``` ## Error Handling ```json {"error": "error message", "status_code": 401} ``` | Error | Recovery | |-------|----------| | No API configured | Uses local fallback for search_context; returns original for enhance | | Token invalid (401) | Check API token (logged at ERROR level) | | Access denied (403) | Token may be disabled (logged at ERROR level) | | Upload failure | Report an error; keep the previous cache on disk without returning its stale blobs | | Connection timeout | Retries up to 3 times with exponential backoff | | No results | Broaden search query | | Third-party not configured | `ValueError` raised immediately (no silent fallback) | | Search context missing project_root | `ValueError` raised when injection enabled without `--project-root` | ## Anti-Patterns | Prohibited | Correct | |------------|---------| | Grep before semantic search | Use `search_context` first | | Skip prompt enhancement | Use `enhance_prompt` for complex tasks | | Ignore conversation history | Include history in `enhance_prompt` | | Use exact match for conceptual search | Use natural language query | | Always use non-interactive mode | Use interactive mode for review | | Skip `--project-root` for enhance | Include it for cloud-based code context |
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.