fraude-code 0.1.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.
- package/README.md +68 -0
- package/dist/index.js +179297 -0
- package/package.json +88 -0
- package/src/agent/agent.ts +475 -0
- package/src/agent/contextManager.ts +141 -0
- package/src/agent/index.ts +14 -0
- package/src/agent/pendingChanges.ts +270 -0
- package/src/agent/prompts/AskPrompt.txt +10 -0
- package/src/agent/prompts/FastPrompt.txt +40 -0
- package/src/agent/prompts/PlannerPrompt.txt +51 -0
- package/src/agent/prompts/ReviewerPrompt.txt +57 -0
- package/src/agent/prompts/WorkerPrompt.txt +33 -0
- package/src/agent/subagents/askAgent.ts +37 -0
- package/src/agent/subagents/extractionAgent.ts +123 -0
- package/src/agent/subagents/fastAgent.ts +45 -0
- package/src/agent/subagents/managerAgent.ts +36 -0
- package/src/agent/subagents/relationAgent.ts +76 -0
- package/src/agent/subagents/researchSubAgent.ts +79 -0
- package/src/agent/subagents/reviewerSubAgent.ts +42 -0
- package/src/agent/subagents/workerSubAgent.ts +42 -0
- package/src/agent/tools/bashTool.ts +94 -0
- package/src/agent/tools/descriptions/bash.txt +47 -0
- package/src/agent/tools/descriptions/edit.txt +7 -0
- package/src/agent/tools/descriptions/glob.txt +4 -0
- package/src/agent/tools/descriptions/grep.txt +8 -0
- package/src/agent/tools/descriptions/lsp.txt +20 -0
- package/src/agent/tools/descriptions/plan.txt +3 -0
- package/src/agent/tools/descriptions/read.txt +9 -0
- package/src/agent/tools/descriptions/todo.txt +12 -0
- package/src/agent/tools/descriptions/write.txt +8 -0
- package/src/agent/tools/editTool.ts +44 -0
- package/src/agent/tools/globTool.ts +59 -0
- package/src/agent/tools/grepTool.ts +343 -0
- package/src/agent/tools/lspTool.ts +429 -0
- package/src/agent/tools/planTool.ts +118 -0
- package/src/agent/tools/readTool.ts +78 -0
- package/src/agent/tools/rememberTool.ts +91 -0
- package/src/agent/tools/testRunnerTool.ts +77 -0
- package/src/agent/tools/testTool.ts +44 -0
- package/src/agent/tools/todoTool.ts +224 -0
- package/src/agent/tools/writeTool.ts +33 -0
- package/src/commands/COMMANDS.ts +38 -0
- package/src/commands/cerebras/auth.ts +27 -0
- package/src/commands/cerebras/index.ts +31 -0
- package/src/commands/forget.ts +29 -0
- package/src/commands/google/auth.ts +24 -0
- package/src/commands/google/index.ts +31 -0
- package/src/commands/groq/add_model.ts +60 -0
- package/src/commands/groq/auth.ts +24 -0
- package/src/commands/groq/index.ts +33 -0
- package/src/commands/index.ts +65 -0
- package/src/commands/knowledge.ts +92 -0
- package/src/commands/log.ts +32 -0
- package/src/commands/mistral/auth.ts +27 -0
- package/src/commands/mistral/index.ts +31 -0
- package/src/commands/model/index.ts +145 -0
- package/src/commands/models/index.ts +16 -0
- package/src/commands/ollama/index.ts +29 -0
- package/src/commands/openrouter/add_model.ts +64 -0
- package/src/commands/openrouter/auth.ts +24 -0
- package/src/commands/openrouter/index.ts +33 -0
- package/src/commands/remember.ts +48 -0
- package/src/commands/serve.ts +31 -0
- package/src/commands/session/index.ts +21 -0
- package/src/commands/usage.ts +15 -0
- package/src/commands/visualize.ts +773 -0
- package/src/components/App.tsx +55 -0
- package/src/components/IntroComponent.tsx +70 -0
- package/src/components/LoaderComponent.tsx +68 -0
- package/src/components/OutputRenderer.tsx +88 -0
- package/src/components/SettingsRenderer.tsx +23 -0
- package/src/components/input/CommandSuggestions.tsx +41 -0
- package/src/components/input/FileSuggestions.tsx +61 -0
- package/src/components/input/InputBox.tsx +371 -0
- package/src/components/output/CheckpointView.tsx +13 -0
- package/src/components/output/CommandView.tsx +13 -0
- package/src/components/output/CommentView.tsx +12 -0
- package/src/components/output/ConfirmationView.tsx +179 -0
- package/src/components/output/ContextUsage.tsx +62 -0
- package/src/components/output/DiffView.tsx +202 -0
- package/src/components/output/ErrorView.tsx +14 -0
- package/src/components/output/InteractiveServerView.tsx +69 -0
- package/src/components/output/KnowledgeView.tsx +220 -0
- package/src/components/output/MarkdownView.tsx +15 -0
- package/src/components/output/ModelSelectView.tsx +71 -0
- package/src/components/output/ReasoningView.tsx +21 -0
- package/src/components/output/ToolCallView.tsx +45 -0
- package/src/components/settings/ModelList.tsx +250 -0
- package/src/components/settings/TokenUsage.tsx +274 -0
- package/src/config/schema.ts +19 -0
- package/src/config/settings.ts +229 -0
- package/src/index.tsx +100 -0
- package/src/parsers/tree-sitter-python.wasm +0 -0
- package/src/providers/providers.ts +71 -0
- package/src/services/PluginLoader.ts +123 -0
- package/src/services/cerebras.ts +69 -0
- package/src/services/embeddingService.ts +229 -0
- package/src/services/google.ts +65 -0
- package/src/services/graphSerializer.ts +248 -0
- package/src/services/groq.ts +23 -0
- package/src/services/knowledgeOrchestrator.ts +286 -0
- package/src/services/mistral.ts +79 -0
- package/src/services/ollama.ts +109 -0
- package/src/services/openrouter.ts +23 -0
- package/src/services/symbolExtractor.ts +277 -0
- package/src/store/useFraudeStore.ts +123 -0
- package/src/store/useSettingsStore.ts +38 -0
- package/src/theme.ts +26 -0
- package/src/types/Agent.ts +147 -0
- package/src/types/CommandDefinition.ts +8 -0
- package/src/types/Model.ts +94 -0
- package/src/types/OutputItem.ts +24 -0
- package/src/types/PluginContext.ts +55 -0
- package/src/types/TokenUsage.ts +5 -0
- package/src/types/assets.d.ts +4 -0
- package/src/utils/agentCognition.ts +1152 -0
- package/src/utils/fileSuggestions.ts +111 -0
- package/src/utils/index.ts +17 -0
- package/src/utils/initFraude.ts +8 -0
- package/src/utils/logger.ts +24 -0
- package/src/utils/lspClient.ts +1415 -0
- package/src/utils/paths.ts +24 -0
- package/src/utils/queryHandler.ts +227 -0
- package/src/utils/router.ts +278 -0
- package/src/utils/streamHandler.ts +132 -0
- package/src/utils/treeSitterQueries.ts +125 -0
- package/tsconfig.json +33 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export interface FileSuggestion {
|
|
5
|
+
path: string;
|
|
6
|
+
type: "file" | "dir";
|
|
7
|
+
childCount?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Cache for file list to avoid re-scanning on every keystroke
|
|
11
|
+
let fileCache: FileSuggestion[] | null = null;
|
|
12
|
+
let lastScanTime = 0;
|
|
13
|
+
const SCAN_INTERVAL = 10000; // 10 seconds
|
|
14
|
+
const MAX_FILES = 50000; // Increased limit for large repos
|
|
15
|
+
|
|
16
|
+
const IGNORED_DIRS = new Set([
|
|
17
|
+
"node_modules",
|
|
18
|
+
".git",
|
|
19
|
+
".next",
|
|
20
|
+
"dist",
|
|
21
|
+
".bun",
|
|
22
|
+
"coverage",
|
|
23
|
+
"build",
|
|
24
|
+
".cache",
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export async function getFileSuggestions(
|
|
28
|
+
cwd: string,
|
|
29
|
+
): Promise<FileSuggestion[]> {
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
if (fileCache && now - lastScanTime < SCAN_INTERVAL) {
|
|
32
|
+
return fileCache;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const results: FileSuggestion[] = [];
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
await scanDirectory(cwd, "", results);
|
|
39
|
+
fileCache = results;
|
|
40
|
+
lastScanTime = now;
|
|
41
|
+
return results;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error("Error scanning files:", error);
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Returns the number of items in the directory scanned
|
|
49
|
+
async function scanDirectory(
|
|
50
|
+
basePath: string,
|
|
51
|
+
relativePath: string,
|
|
52
|
+
results: FileSuggestion[],
|
|
53
|
+
): Promise<number> {
|
|
54
|
+
if (results.length >= MAX_FILES) return 0;
|
|
55
|
+
|
|
56
|
+
const currentDir = path.join(basePath, relativePath);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
60
|
+
|
|
61
|
+
// Filter out ignored items immediately
|
|
62
|
+
const validEntries = entries.filter(
|
|
63
|
+
(entry) => !IGNORED_DIRS.has(entry.name),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
for (const entry of validEntries) {
|
|
67
|
+
if (results.length >= MAX_FILES) break;
|
|
68
|
+
|
|
69
|
+
const entryName = entry.name;
|
|
70
|
+
const entryRelativePath = relativePath
|
|
71
|
+
? path.join(relativePath, entryName)
|
|
72
|
+
: entryName;
|
|
73
|
+
|
|
74
|
+
if (entry.isDirectory()) {
|
|
75
|
+
const suggestion: FileSuggestion = {
|
|
76
|
+
path: entryRelativePath,
|
|
77
|
+
type: "dir",
|
|
78
|
+
childCount: 0, // Will be updated after recursion
|
|
79
|
+
};
|
|
80
|
+
results.push(suggestion);
|
|
81
|
+
|
|
82
|
+
// Recursively scan and get the count
|
|
83
|
+
const count = await scanDirectory(basePath, entryRelativePath, results);
|
|
84
|
+
suggestion.childCount = count;
|
|
85
|
+
} else {
|
|
86
|
+
results.push({
|
|
87
|
+
path: entryRelativePath,
|
|
88
|
+
type: "file",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return validEntries.length;
|
|
94
|
+
} catch (err) {
|
|
95
|
+
// Permission denied or other error
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function filterFiles(
|
|
101
|
+
files: FileSuggestion[],
|
|
102
|
+
input: string,
|
|
103
|
+
): FileSuggestion[] {
|
|
104
|
+
if (!input) return [];
|
|
105
|
+
|
|
106
|
+
// Input might be "@src/u" -> we want to match "src/utils"
|
|
107
|
+
const query = input.startsWith("@") ? input.slice(1) : input;
|
|
108
|
+
const lowerQuery = query.toLowerCase();
|
|
109
|
+
|
|
110
|
+
return files.filter((f) => f.path.toLowerCase().includes(lowerQuery));
|
|
111
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { homedir } from "os";
|
|
2
|
+
|
|
3
|
+
export const shortenPath = (path: string) => {
|
|
4
|
+
const home = homedir();
|
|
5
|
+
if (path.startsWith(home)) {
|
|
6
|
+
return path.replace(home, "~");
|
|
7
|
+
}
|
|
8
|
+
return path;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const projectPath = (path: string) => {
|
|
12
|
+
const base = process.cwd();
|
|
13
|
+
if (path.startsWith(base)) {
|
|
14
|
+
return path.replace(base, "@");
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { getConfigDir } from "./paths";
|
|
4
|
+
|
|
5
|
+
export const getLogPath = () => {
|
|
6
|
+
const configDir = getConfigDir("fraude-code");
|
|
7
|
+
if (!fs.existsSync(configDir)) {
|
|
8
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
return path.join(configDir, "debug.log");
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const log = (...args: any[]) => {
|
|
14
|
+
fs.appendFileSync(
|
|
15
|
+
getLogPath(),
|
|
16
|
+
`[${new Date().toISOString()}] ${args.join(" ")}\n`,
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const resetLog = () => {
|
|
21
|
+
fs.writeFileSync(getLogPath(), "");
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default log;
|