@codexa/cli 8.6.11 → 8.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/discover.ts +106 -29
- package/package.json +1 -1
package/commands/discover.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { getDb } from "../db/connection";
|
|
|
2
2
|
import { initSchema } from "../db/schema";
|
|
3
3
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
4
4
|
import { join } from "path";
|
|
5
|
+
import { spawnSync } from "child_process";
|
|
5
6
|
import {
|
|
6
7
|
detectUniversal,
|
|
7
8
|
detectStackLegacy,
|
|
@@ -996,6 +997,26 @@ export function discoverExportPatterns(): void {
|
|
|
996
997
|
export function ensureDeepExploreAgent(): void {
|
|
997
998
|
const agentPath = join(process.cwd(), ".claude", "agents", "deep-explore.md");
|
|
998
999
|
|
|
1000
|
+
// Check grepai availability
|
|
1001
|
+
const grepaiCheck = spawnSync("grepai", ["--version"], { encoding: "utf-8" });
|
|
1002
|
+
if (grepaiCheck.error || grepaiCheck.status !== 0) {
|
|
1003
|
+
console.warn("\n⚠ grepai nao encontrado no PATH.");
|
|
1004
|
+
console.warn(" O agente deep-explore depende de grepai para busca semantica.");
|
|
1005
|
+
console.warn(" Instale com: go install github.com/your-org/grepai@latest");
|
|
1006
|
+
console.warn(" Sem grepai, o deep-explore usara apenas Grep (menos eficaz).\n");
|
|
1007
|
+
} else {
|
|
1008
|
+
// Check if grepai index exists for this project
|
|
1009
|
+
const grepaiDir = join(process.cwd(), ".grepai");
|
|
1010
|
+
if (!existsSync(grepaiDir)) {
|
|
1011
|
+
console.warn("\n⚠ grepai index nao encontrado neste projeto.");
|
|
1012
|
+
console.warn(" Execute: grepai index");
|
|
1013
|
+
console.warn(" Sem o index, grepai search nao retornara resultados.\n");
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// Ensure grepai permissions in target project settings
|
|
1018
|
+
ensureGrepaiPermissions();
|
|
1019
|
+
|
|
999
1020
|
if (existsSync(agentPath)) return;
|
|
1000
1021
|
|
|
1001
1022
|
const agentsDir = join(process.cwd(), ".claude", "agents");
|
|
@@ -1011,28 +1032,38 @@ color: cyan
|
|
|
1011
1032
|
model: haiku
|
|
1012
1033
|
---
|
|
1013
1034
|
|
|
1014
|
-
##
|
|
1035
|
+
## CRITICAL: You MUST use grepai
|
|
1036
|
+
|
|
1037
|
+
**YOUR FIRST ACTION must be a \\\`grepai search\\\` command via Bash.** This is non-negotiable.
|
|
1038
|
+
|
|
1039
|
+
You are a semantic code exploration agent. Your primary tool is \\\`grepai\\\` — an AI-powered semantic search engine. It finds code by INTENT and MEANING, not literal text matching.
|
|
1040
|
+
|
|
1041
|
+
**RULE: Every exploration MUST start with \\\`grepai search\\\`. If you use Grep or find BEFORE grepai, you have FAILED your task.**
|
|
1015
1042
|
|
|
1016
|
-
|
|
1043
|
+
---
|
|
1044
|
+
|
|
1045
|
+
### Step 1: ALWAYS run grepai search FIRST
|
|
1017
1046
|
|
|
1018
|
-
|
|
1047
|
+
\\\`\\\`\\\`bash
|
|
1048
|
+
grepai search "your query here" --json --compact
|
|
1049
|
+
\\\`\\\`\\\`
|
|
1019
1050
|
|
|
1020
|
-
|
|
1051
|
+
- Queries MUST be in English
|
|
1052
|
+
- Use \\\`--compact\\\` to save tokens
|
|
1053
|
+
- Use natural language: "authentication flow", "error handling middleware", "how payments are processed"
|
|
1021
1054
|
|
|
1022
|
-
|
|
1055
|
+
Examples:
|
|
1023
1056
|
|
|
1024
|
-
|
|
1025
|
-
# Use English queries for best results (--compact saves ~80% tokens)
|
|
1057
|
+
\\\`\\\`\\\`bash
|
|
1026
1058
|
grepai search "authentication flow" --json --compact
|
|
1027
1059
|
grepai search "error handling middleware" --json --compact
|
|
1028
1060
|
grepai search "database connection management" --json --compact
|
|
1029
|
-
|
|
1061
|
+
grepai search "state management pattern" --json --compact
|
|
1062
|
+
\\\`\\\`\\\`
|
|
1030
1063
|
|
|
1031
|
-
|
|
1064
|
+
### Step 2: Use grepai trace for relationships
|
|
1032
1065
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
\`\`\`bash
|
|
1066
|
+
\\\`\\\`\\\`bash
|
|
1036
1067
|
# Find all functions that call a symbol
|
|
1037
1068
|
grepai trace callers "HandleRequest" --json
|
|
1038
1069
|
|
|
@@ -1041,32 +1072,78 @@ grepai trace callees "ProcessOrder" --json
|
|
|
1041
1072
|
|
|
1042
1073
|
# Build complete call graph
|
|
1043
1074
|
grepai trace graph "ValidateToken" --depth 3 --json
|
|
1044
|
-
|
|
1075
|
+
\\\`\\\`\\\`
|
|
1076
|
+
|
|
1077
|
+
### Step 3: Read files identified by grepai
|
|
1045
1078
|
|
|
1046
|
-
Use
|
|
1079
|
+
Use \\\`Read\\\` to examine files that grepai found relevant.
|
|
1080
|
+
|
|
1081
|
+
### Step 4: Grep ONLY for exact literals (optional)
|
|
1082
|
+
|
|
1083
|
+
Use Grep ONLY if you need exact string match (variable name, import path). Never use Grep for exploration — grepai is always better for that.
|
|
1084
|
+
|
|
1085
|
+
---
|
|
1047
1086
|
|
|
1048
|
-
|
|
1049
|
-
- Understand the call hierarchy
|
|
1050
|
-
- Analyze the impact of changes to a function
|
|
1051
|
-
- Map dependencies between components
|
|
1087
|
+
### FORBIDDEN
|
|
1052
1088
|
|
|
1053
|
-
|
|
1089
|
+
- **DO NOT** use \\\`find\\\` or \\\`ls\\\` to explore code — use \\\`grepai search\\\`
|
|
1090
|
+
- **DO NOT** use \\\`Grep\\\` for semantic exploration — use \\\`grepai search\\\`
|
|
1091
|
+
- **DO NOT** skip grepai and go straight to Read/Grep
|
|
1092
|
+
- **DO NOT** write custom exploration logic when grepai can answer it
|
|
1054
1093
|
|
|
1055
|
-
|
|
1094
|
+
### If grepai fails
|
|
1056
1095
|
|
|
1057
|
-
|
|
1058
|
-
- grepai is not available or returns errors
|
|
1059
|
-
- You need file path patterns
|
|
1096
|
+
If \\\`grepai search\\\` returns an error (command not found, index missing), report this in your response:
|
|
1060
1097
|
|
|
1061
|
-
|
|
1098
|
+
\\\`\\\`\\\`json
|
|
1099
|
+
{"status": "blocked", "blockers": ["grepai not available: <error message>"]}
|
|
1100
|
+
\\\`\\\`\\\`
|
|
1062
1101
|
|
|
1063
|
-
|
|
1064
|
-
2. Use \`grepai trace\` to understand function relationships and call graphs
|
|
1065
|
-
3. Use \`Read\` to examine promising files in detail
|
|
1066
|
-
4. Use Grep only for exact string searches if needed
|
|
1067
|
-
5. Synthesize findings into a clear summary
|
|
1102
|
+
Do NOT silently fall back to Grep. The orchestrator needs to know grepai is not working.
|
|
1068
1103
|
`;
|
|
1069
1104
|
|
|
1070
1105
|
writeFileSync(agentPath, content);
|
|
1071
1106
|
console.log("✓ Agent deep-explore instalado em .claude/agents/deep-explore.md");
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// Ensure grepai Bash permissions exist in the target project's .claude/settings.local.json
|
|
1110
|
+
function ensureGrepaiPermissions(): void {
|
|
1111
|
+
const settingsPath = join(process.cwd(), ".claude", "settings.local.json");
|
|
1112
|
+
const claudeDir = join(process.cwd(), ".claude");
|
|
1113
|
+
|
|
1114
|
+
if (!existsSync(claudeDir)) {
|
|
1115
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
const requiredPermissions = [
|
|
1119
|
+
"Bash(grepai search:*)",
|
|
1120
|
+
"Bash(grepai trace:*)",
|
|
1121
|
+
"Bash(grepai:*)",
|
|
1122
|
+
];
|
|
1123
|
+
|
|
1124
|
+
let settings: { permissions?: { allow?: string[] } } = {};
|
|
1125
|
+
|
|
1126
|
+
if (existsSync(settingsPath)) {
|
|
1127
|
+
try {
|
|
1128
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
1129
|
+
} catch {
|
|
1130
|
+
settings = {};
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
if (!settings.permissions) settings.permissions = {};
|
|
1135
|
+
if (!settings.permissions.allow) settings.permissions.allow = [];
|
|
1136
|
+
|
|
1137
|
+
let added = false;
|
|
1138
|
+
for (const perm of requiredPermissions) {
|
|
1139
|
+
if (!settings.permissions.allow.includes(perm)) {
|
|
1140
|
+
settings.permissions.allow.push(perm);
|
|
1141
|
+
added = true;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
if (added) {
|
|
1146
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
1147
|
+
console.log("✓ Permissoes de grepai adicionadas em .claude/settings.local.json");
|
|
1148
|
+
}
|
|
1072
1149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codexa/cli",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.13",
|
|
4
4
|
"description": "Orchestrated workflow system for Claude Code - manages feature development through parallel subagents with structured phases, gates, and quality enforcement.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|