Skip to content

Commit 1134a2f

Browse files
authored
[codex] Update skills for Tool API v3 (#5)
* Update skills for Tool API v3 * Remove legacy chat alias guidance * Address skills review findings * Clarify Tool API v3 error contract * Align artifact batch documentation
1 parent fea0bd6 commit 1134a2f

20 files changed

Lines changed: 797 additions & 1386 deletions

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "codealive",
33
"description": "CodeAlive context engine for semantic code search and AI-powered codebase Q&A. Enables AI coding agents to understand entire codebases beyond just open files — search across all indexed repositories, trace cross-service dependencies, discover usage patterns, and get synthesized answers to architectural questions. Includes a lightweight code exploration subagent, authentication hooks, and multiple search modes (fast lexical, semantic, and deep cross-cutting). Works standalone or alongside the CodeAlive MCP server for direct tool access via the Model Context Protocol.",
4-
"version": "2.1.0",
4+
"version": "3.0.0",
55
"author": {
66
"name": "CodeAlive AI",
77
"email": "hello@codealive.ai"

agents/codealive-context-explorer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ When unsure, start with `search.py` — it covers more ground; pivot to `grep.py
8989
- Use only local `Grep`/`Glob` when the question is about an external repo or a cross-repo concept.
9090
- Trust the `description` field of search results as ground truth — always fetch or read the real source.
9191
- Run a single empty search and conclude "nothing found" — try at least 2 different query phrasings before giving up.
92-
- Run `chat.py`. Only do so when the user explicitly asks (e.g. "use chat", "use codebase_consultant").
92+
- Run `chat.py`. Only do so when the user explicitly asks (e.g. "use chat", "call the chat tool").
9393

9494
## Output Format
9595

skills/codealive-context-engine/SKILL.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,25 @@ Do NOT retry the failed script until setup completes successfully.
4040
| **List Data Sources** | `datasources.py` | Instant | Free | Discovering indexed repos and workspaces. With `--query "task"`, runs an AI relevance filter (low cost, not instant) returning only the relevant sources |
4141
| **Semantic Search** | `search.py` | Fast | Low | Default discovery — finds code by meaning (concepts, behavior, architecture) |
4242
| **Grep Search** | `grep.py` | Fast | Low | Finds code containing a specific string or regex (identifiers, literals, patterns) |
43-
| **Fetch Artifacts** | `fetch.py` | Fast | Low | Retrieving full content; function-like artifacts also include up to 3 outgoing/incoming calls as a preview |
44-
| **Artifact Relationships** | `relationships.py` | Fast | Low | Full call graph (past the fetch preview's 3-cap), inheritance, or symbol references for one artifact |
45-
| **Chat with Codebase** | `chat.py` | Slow | High | **Not recommended.** Call ONLY when the user explicitly asks (e.g. "use chat"). |
43+
| **Repository Ontology** | `ontology.py` | Fast | Low | High-level orientation for exactly one repository |
44+
| **File Tree** | `tree.py` | Fast | Free | Bounded repository tree inspection |
45+
| **Read File** | `read_file.py` | Fast | Free | Read one repository-relative file path, optionally with a line range |
46+
| **Fetch Artifacts** | `fetch.py` | Fast | Free | Retrieve full content for search result identifiers |
47+
| **Artifact Relationships** | `relationships.py` | Fast | Free | Full call graph, inheritance, or symbol references for one artifact |
48+
| **ArtifactQuery Schema** | `schema.py` | Fast | Free | Inspect supported metadata query entities, fields, and examples |
49+
| **Artifact Metadata Query** | `metadata.py` | Fast | Low | Read-only aggregate/query analytics across indexed repositories |
50+
| **Chat with Codebase** | `chat.py` | Slow | High | Stateless synthesized Q&A. Call ONLY when the user explicitly asks. |
4651

4752
**Cost guidance:** `semantic_search` and `grep_search` are the default starting point — fast and cheap. Use `fetch_artifacts` to load full source and `get_artifact_relationships` to trace call graphs. All four tools are low-cost.
4853

49-
**Chat is not recommended:** `chat.py` invokes an LLM on the server side, can take up to 30 seconds, and is significantly more expensive per call. Do NOT call it unless the user has explicitly requested it (e.g. "use chat", "use codebase_consultant", "call the chat tool"). Phrases like "ask CodeAlive" or "search CodeAlive" do NOT qualify — they refer to search tools.
54+
**Chat is not recommended:** `chat.py` invokes an LLM on the server side, can take substantially longer than retrieval, and is significantly more expensive per call. It is stateless in v3: include prior findings, artifact identifiers, assumptions, scope, and constraints in each question. Do NOT call it unless the user has explicitly requested it (e.g. "use chat", "call the chat tool"). Phrases like "ask CodeAlive" or "search CodeAlive" do NOT qualify — they refer to search tools.
5055

51-
**Highest-confidence guidance:** If your agent supports subagents and the task needs maximum reliability or depth, prefer a subagent-driven workflow that combines `search.py`, `grep.py`, `fetch.py`, `relationships.py`, and local file reads.
56+
**Repairable tool errors:** Treat a returned `<tool_error>` as a failed call,
57+
not as an empty successful result. Follow its `<try>` guidance, repair the
58+
arguments, and retry only when the `<retry>` field permits it. Tool API v3
59+
always preserves the same error in `obj.error` for JSON-mode automation.
60+
61+
**Highest-confidence guidance:** If your agent supports subagents and the task needs maximum reliability or depth, prefer a subagent-driven workflow that combines `ontology.py`, `search.py`, `grep.py`, `fetch.py`, `tree.py`/`read_file.py`, `relationships.py`, `metadata.py`, and local file reads.
5262

5363
**Three-step workflow (search → triage → load real content):**
5464
1. **Search** — find relevant code locations with descriptions and identifiers
@@ -144,11 +154,11 @@ python scripts/relationships.py "my-org/backend::src/svc.py::Service" --profile
144154
### 5. Chat with codebase (not recommended — only if user explicitly asks)
145155

146156
```bash
147-
python scripts/chat.py "Explain the authentication flow" my-backend
148-
python scripts/chat.py "What about security considerations?" --continue CONV_ID
157+
python scripts/chat.py "Explain the authentication flow. Prior context: none." my-backend
158+
python scripts/chat.py "Given these prior findings and identifiers: ..., what about security considerations?" my-backend
149159
```
150160

151-
**Do not call chat unless the user explicitly asks for it.** Use search, grep, fetch, and relationships for all other tasks.
161+
**Do not call chat unless the user explicitly asks for it.** v3 chat is stateless and has no `conversation_id`; include all needed context in each question. Use ontology, search, grep, fetch/read, relationships, and metadata queries for all other tasks.
152162

153163
## Tool Reference
154164

@@ -223,7 +233,7 @@ python scripts/fetch.py <identifier1> [identifier2...] [--data-source NAME_OR_ID
223233

224234
| Constraint | Value |
225235
|-----------|-------|
226-
| Max identifiers per request | 20 |
236+
| Max identifiers per request | 50 |
227237
| Identifiers source | `identifier` field from search results |
228238
| Identifier format | `{owner/repo}::{path}::{symbol}` (symbols), `{owner/repo}::{path}` (files) |
229239
| `--data-source NAME_OR_ID` | Optional. Data source Name or Id (from a result's `Source:` line) to disambiguate an identifier indexed in more than one data source |
@@ -295,23 +305,17 @@ don't match the artifact's real logic.
295305

296306
### `chat.py` — Chat with Codebase (not recommended)
297307

298-
**Do NOT call unless the user explicitly asks** (e.g. "use chat", "use codebase_consultant", "call the chat tool"). Phrases like "ask CodeAlive" or "search CodeAlive" refer to search tools, not chat.
308+
**Do NOT call unless the user explicitly asks** (e.g. "use chat", "call the chat tool"). Phrases like "ask CodeAlive" or "search CodeAlive" refer to search tools, not chat.
299309

300-
Sends your question to an AI consultant that has full context of the indexed codebase. Returns synthesized, ready-to-use answers. Supports conversation continuity for follow-ups.
310+
Sends your self-contained question to an AI consultant that has full context of the selected indexed codebase. Returns synthesized, ready-to-use answers.
301311

302-
**This is slow and expensive** — runs an LLM on the server side, up to 30 seconds per call. For all standard tasks (finding code, understanding architecture, debugging), use `search.py`, `grep.py`, `fetch.py`, and `relationships.py` instead.
312+
**This is slow and expensive** — runs an LLM on the server side and can take substantially longer than retrieval. It is stateless in v3, so include prior findings, identifiers, assumptions, scope, and constraints in each question. For all standard tasks (finding code, understanding architecture, debugging), use ontology, search, grep, fetch/read, relationships, and metadata queries instead.
303313

304314
```bash
305315
python scripts/chat.py <question> <data_sources...> [options]
306316
```
307317

308-
| Option | Description |
309-
|--------|-------------|
310-
| `--continue <id>` | Continue a previous conversation (saves context and cost) |
311-
312-
**Conversation continuity:** Every successful response includes a `conversation_id` (a 24-character hex Mongo ObjectId, e.g. `69fceb3e7b2a6a7efdd18180`) and a `message_id` of the same format. Pass `--continue <conversation_id>` for follow-up questions — this preserves context and is cheaper than starting fresh.
313-
314-
Format guarantee: any value not matching `^[0-9a-fA-F]{24}$` is rejected client-side before the request is sent.
318+
There is no public `conversation_id` in v3. For follow-ups, restate the relevant context in the next `question`.
315319

316320
## Data Sources
317321

skills/codealive-context-engine/scripts/chat.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Usage:
99
python chat.py "How does authentication work?" my-repo
1010
python chat.py "Explain the database schema" workspace:backend-team
11-
python chat.py "What's the best way to add caching?" --continue CONV_ID
11+
python chat.py "What's the best way to add caching? Prior context: ..." my-repo
1212
1313
Examples:
1414
# Ask about current project
@@ -20,15 +20,14 @@
2020
# Ask about dependencies/libraries
2121
python chat.py "How does lodash debounce work internally?" lodash
2222
23-
# Continue previous conversation
24-
python chat.py "What about error handling?" --continue 69fceb3e7b2a6a7efdd18180
23+
# v3 chat is stateless: include prior findings and constraints in every question.
24+
python chat.py "Given prior finding X, what about error handling?" my-backend
2525
2626
# Cross-project learning
2727
python chat.py "Show me authentication patterns across our org" workspace:all-backend
2828
"""
2929

3030
import sys
31-
import json
3231
from pathlib import Path
3332

3433
# Add lib directory to path
@@ -41,63 +40,51 @@ def main():
4140
"""CLI interface for codebase consultant."""
4241
if len(sys.argv) < 2:
4342
print("Error: Missing required arguments.", file=sys.stderr)
44-
print("Usage: python chat.py <question> <data_source> [data_source2...] [--continue <conversation_id>]", file=sys.stderr)
43+
print("Usage: python chat.py <question> <data_source> [data_source2...]", file=sys.stderr)
4544
sys.exit(1)
4645

4746
if sys.argv[1] == "--help":
4847
print(__doc__)
4948
sys.exit(0)
5049

5150
question = sys.argv[1]
52-
conversation_id = None
5351
data_sources = []
5452

5553
# Parse arguments
5654
i = 2
5755
while i < len(sys.argv):
5856
arg = sys.argv[i]
59-
if arg == "--continue" and i + 1 < len(sys.argv):
60-
conversation_id = sys.argv[i + 1]
61-
i += 2
62-
elif arg == "--conversation-id" and i + 1 < len(sys.argv):
63-
conversation_id = sys.argv[i + 1]
64-
i += 2
57+
if arg in {"--continue", "--conversation-id"}:
58+
print("Error: chat is stateless in v3; include prior context in the question instead.", file=sys.stderr)
59+
sys.exit(1)
6560
else:
6661
data_sources.append(arg)
6762
i += 1
6863

69-
if not conversation_id and not data_sources:
70-
print("Error: Either data sources or --continue <conversation_id> is required.", file=sys.stderr)
64+
if not data_sources:
65+
print("Error: At least one data source is required.", file=sys.stderr)
7166
print("Run datasources.py to see available sources.", file=sys.stderr)
7267
sys.exit(1)
7368

7469
try:
7570
client = CodeAliveClient()
7671

7772
print(f"💬 Question: {question}", file=sys.stderr)
78-
if conversation_id:
79-
print(f"🔄 Continuing conversation: {conversation_id}", file=sys.stderr)
80-
else:
81-
print(f"📚 Analyzing: {', '.join(data_sources)}", file=sys.stderr)
73+
print(f"📚 Analyzing: {', '.join(data_sources)}", file=sys.stderr)
74+
print("ℹ️ v3 chat is stateless; each question must include needed prior context.", file=sys.stderr)
8275
print(file=sys.stderr)
8376
print("🤔 Thinking...", file=sys.stderr)
8477
print(file=sys.stderr)
8578

8679
result = client.chat(
8780
question=question,
88-
data_sources=data_sources if data_sources else None,
89-
conversation_id=conversation_id
81+
data_sources=data_sources,
9082
)
9183

9284
print("="*80)
93-
print(result["answer"])
85+
print(result)
9486
print("="*80)
9587

96-
if result.get("conversation_id"):
97-
print()
98-
print(f"💾 Conversation ID: {result['conversation_id']}")
99-
print(f" Use --continue {result['conversation_id']} to ask follow-up questions")
100-
10188
except Exception as e:
10289
print(f"❌ Error: {e}", file=sys.stderr)
10390
sys.exit(1)

skills/codealive-context-engine/scripts/datasources.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def format_datasources(datasources: list, as_json: bool = False, message: str =
112112

113113
def main():
114114
"""CLI interface for listing data sources."""
115-
alive_only = True
115+
ready_only = True
116116
as_json = False
117117
query = None
118118

@@ -121,7 +121,7 @@ def main():
121121
while i < len(args):
122122
arg = args[i]
123123
if arg == "--all":
124-
alive_only = False
124+
ready_only = False
125125
elif arg == "--json":
126126
as_json = True
127127
elif arg == "--query":
@@ -137,14 +137,15 @@ def main():
137137

138138
try:
139139
client = CodeAliveClient()
140-
result = client.get_datasources(alive_only=alive_only, query=query)
141-
if isinstance(result, dict):
142-
datasources = result.get("dataSources", [])
143-
message = result.get("message", "")
140+
result = client.get_datasources(
141+
ready_only=ready_only,
142+
query=query,
143+
output_format="json" if as_json else "agentic",
144+
)
145+
if as_json:
146+
print(json.dumps(result, indent=2))
144147
else:
145-
datasources = result
146-
message = ""
147-
print(format_datasources(datasources, as_json, message))
148+
print(result)
148149

149150
except Exception as e:
150151
print(f"❌ Error: {e}", file=sys.stderr)

0 commit comments

Comments
 (0)