ft-scout 3.0.5 → 3.0.6
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 +11 -4
- package/bin/src/commands/agent.d.ts.map +1 -0
- package/bin/src/commands/agent.js +200 -0
- package/bin/src/commands/agent.js.map +1 -0
- package/bin/src/commands/chat.d.ts.map +1 -1
- package/bin/src/commands/chat.js +7 -1
- package/bin/src/commands/chat.js.map +1 -1
- package/bin/src/commands/fix.d.ts.map +1 -1
- package/bin/src/commands/fix.js +111 -74
- package/bin/src/commands/fix.js.map +1 -1
- package/bin/src/engine/git.d.ts.map +1 -1
- package/bin/src/engine/llm.d.ts.map +1 -1
- package/bin/src/engine/llm.js +128 -41
- package/bin/src/engine/llm.js.map +1 -1
- package/bin/src/index.js +21 -4
- package/bin/src/index.js.map +1 -1
- package/bin/src/utils/branding.js +1 -1
- package/bin/src/utils/config.d.ts.map +1 -1
- package/bin/src/utils/config.js +41 -0
- package/bin/src/utils/config.js.map +1 -1
- package/package.json +48 -48
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**FrontTerrain (`scout`)** — The Agentic AI Engineering & Onboarding Co-Pilot for Codebases.
|
|
4
4
|
|
|
5
|
-
Scout works like GitHub Copilot directly inside your terminal — fixing bugs, creating new source code files, executing shell commands with AI failure diagnostics, scanning codebases, and interactive
|
|
5
|
+
Scout works like GitHub Copilot directly inside your terminal — executing autonomous multi-step agentic loops, fixing bugs, creating new source code files, executing shell commands with AI failure diagnostics, scanning codebases, and running interactive AI chat.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -23,16 +23,21 @@ Once installed, use `scout` or `ft` in any project directory:
|
|
|
23
23
|
### 🤖 Agentic AI Actions
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
+
# 🤖 Autonomous Multi-Step AI Agent (Modifies code, verifies tests/build, and self-heals failures)
|
|
27
|
+
scout agent "Add email input validation and ensure npm test passes"
|
|
28
|
+
scout task "Fix typescript build errors in src/utils" -v "npm run build"
|
|
29
|
+
scout goal "Refactor database query logic" -y
|
|
30
|
+
|
|
26
31
|
# ✨ Generate and create a new source code file
|
|
27
32
|
scout create src/utils/math.ts "Create helper functions for sum, average, and array chunking"
|
|
28
33
|
scout gen src/components/Header.tsx "Create a responsive React navigation header"
|
|
29
34
|
|
|
30
35
|
# 🛠️ Auto-fix code using AI based on prompt, target file, or scan issue ID
|
|
31
36
|
scout fix "Fix null pointer check in calculateTotal function"
|
|
32
|
-
scout fix -f src/sampleBug.ts "Handle optional prices defensively"
|
|
37
|
+
scout fix -f src/sampleBug.ts "Handle optional prices defensively" -y
|
|
33
38
|
scout fix -i 1
|
|
34
39
|
|
|
35
|
-
# ⚡ Run terminal/shell commands with automated AI error diagnosis
|
|
40
|
+
# ⚡ Run terminal/shell commands with automated AI error diagnosis & self-healing
|
|
36
41
|
scout run npm test
|
|
37
42
|
scout exec tsc
|
|
38
43
|
scout run python main.py
|
|
@@ -91,10 +96,12 @@ scout upgrade
|
|
|
91
96
|
|
|
92
97
|
## ✨ Key Capabilities
|
|
93
98
|
|
|
99
|
+
- 🤖 **Autonomous Multi-Step AI Agent (`scout agent` / `scout task` / `scout goal`)**: Set a high-level engineering goal. Scout identifies target files, applies code changes, executes automated build/test verification scripts, and self-heals any compiler or test errors in a continuous autonomous loop.
|
|
94
100
|
- ✨ **AI File Generation (`scout create`)**: Specify a file path and a requirement prompt. Scout generates clean, production-ready code, creates missing directories, and provides an interactive review prompt (**Keep** vs **Revert**).
|
|
95
101
|
- 🛠️ **Prompt-Driven Auto-Fix (`scout fix`)**: Fix bugs and refactor code across single or multiple files. Scout analyzes the root cause, applies code edits, displays a technical explanation, and backs up original code.
|
|
96
102
|
- ⚡ **Terminal Execution & Failure Diagnosis (`scout run`)**: Run tests, builds, or scripts directly. If execution fails, Scout analyzes stdout/stderr logs with AI, pinpoints the root cause, and offers to auto-fix the failing code automatically.
|
|
97
|
-
-
|
|
103
|
+
- 💬 **Agentic Copilot Chat (`scout chat`)**: An interactive terminal session with Slash Commands (`/agent`, `/create`, `/fix`, `/run`, `/read`, `/scan`, `/undo`, `/help`) and natural language tool execution.
|
|
104
|
+
- ⚡ **Non-Interactive / CI Auto-Confirm (`-y`, `--yes`)**: Skip interactive prompts and auto-confirm changes when running inside CI pipelines or scripts.
|
|
98
105
|
- ↩️ **Safety & Instant Revert (`scout undo`)**: Every code modification or file creation is logged in `.ft/history.json` with file backups, allowing instant restoration anytime.
|
|
99
106
|
- 🌐 **Multilingual Teardowns & Web Search (`scout search`)**: Access live internet documentation and generate breakdowns in 20+ languages.
|
|
100
107
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["agent.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B;AAED,wBAAsB,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,iBAwP3E"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { spinner, text, isCancel, select } from '@clack/prompts';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { simpleGit } from 'simple-git';
|
|
6
|
+
import { generateMultiCodeFix, identifyTargetFiles, analyzeCommandError } from '../engine/llm.js';
|
|
7
|
+
import { loadContext, recordHistoryAction, getDirectoryFiles } from '../utils/config.js';
|
|
8
|
+
import { renderMarkdown, safeNote } from '../utils/markdown.js';
|
|
9
|
+
import { normalizeLanguage } from '../utils/language.js';
|
|
10
|
+
import { createPullRequest } from '../engine/git.js';
|
|
11
|
+
import { handleUndo } from './undo.js';
|
|
12
|
+
import { exec } from 'child_process';
|
|
13
|
+
import { promisify } from 'util';
|
|
14
|
+
const execAsync = promisify(exec);
|
|
15
|
+
export async function handleAgent(goalInput, options) {
|
|
16
|
+
const existingContext = loadContext();
|
|
17
|
+
const targetLang = normalizeLanguage(options?.lang) || normalizeLanguage(existingContext?.language);
|
|
18
|
+
const cwd = process.cwd();
|
|
19
|
+
const filesList = getDirectoryFiles(cwd);
|
|
20
|
+
const projectName = existingContext?.projectName || path.basename(cwd) || 'Codebase';
|
|
21
|
+
let finalGoal = goalInput || options?.goal;
|
|
22
|
+
if (!finalGoal || !finalGoal.trim()) {
|
|
23
|
+
const userGoalInput = await text({
|
|
24
|
+
message: chalk.bold('What high-level goal or task should Scout autonomously solve?'),
|
|
25
|
+
placeholder: 'e.g. Add validation for email input and ensure npm test passes',
|
|
26
|
+
validate: (val) => (!val || !val.trim() ? 'Please state your goal' : undefined),
|
|
27
|
+
});
|
|
28
|
+
if (isCancel(userGoalInput)) {
|
|
29
|
+
safeNote(chalk.yellow('Agent task cancelled.'), '🤖 Scout Agent');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
finalGoal = userGoalInput.trim();
|
|
33
|
+
}
|
|
34
|
+
const s = spinner();
|
|
35
|
+
s.start(`🤖 Scout Agent initializing autonomous workflow for: "${finalGoal}"...`);
|
|
36
|
+
// Step 1: File Identification
|
|
37
|
+
const targetFiles = await identifyTargetFiles(finalGoal, projectName, filesList, targetLang, options?.native);
|
|
38
|
+
if (targetFiles.length === 0) {
|
|
39
|
+
s.stop(chalk.yellow('No target files identified for this goal.'));
|
|
40
|
+
safeNote(chalk.yellow(`Scout could not identify specific files needing modification for goal: "${finalGoal}".\nPlease refine your request or specify target files.`), '⚠️ Agent File Selection');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
s.message(`Target files identified: ${targetFiles.join(', ')}`);
|
|
44
|
+
const targetFilesMap = {};
|
|
45
|
+
const backups = [];
|
|
46
|
+
const normKey = (p) => p.replace(/\\/g, '/').replace(/^\.\//, '').trim();
|
|
47
|
+
for (const tf of targetFiles) {
|
|
48
|
+
const fullPath = path.resolve(cwd, tf);
|
|
49
|
+
if (fs.existsSync(fullPath)) {
|
|
50
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
51
|
+
targetFilesMap[normKey(tf)] = content;
|
|
52
|
+
backups.push({ filePath: normKey(tf), originalContent: content });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Step 2: Code Modification
|
|
56
|
+
s.message('Applying initial code modifications...');
|
|
57
|
+
let fixResult = await generateMultiCodeFix(finalGoal, projectName, filesList, targetFilesMap, targetLang, options?.native, (completed, total, file) => {
|
|
58
|
+
s.message(`Modifying files (${completed}/${total}): ${file}...`);
|
|
59
|
+
});
|
|
60
|
+
const modifiedFiles = [];
|
|
61
|
+
for (const item of fixResult.files) {
|
|
62
|
+
if (item.fixedCode !== undefined) {
|
|
63
|
+
const k = normKey(item.targetFile);
|
|
64
|
+
const fullPath = path.resolve(cwd, k);
|
|
65
|
+
const orig = targetFilesMap[k] ?? '';
|
|
66
|
+
const normalizedFixed = item.fixedCode.replace(/\r\n/g, '\n').trim();
|
|
67
|
+
const normalizedOrig = orig.replace(/\r\n/g, '\n').trim();
|
|
68
|
+
if (normalizedFixed !== normalizedOrig) {
|
|
69
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
70
|
+
fs.writeFileSync(fullPath, item.fixedCode, 'utf-8');
|
|
71
|
+
modifiedFiles.push(k);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Step 3: Autonomous Verification & Self-Healing Loop
|
|
76
|
+
let verifyCommand = options?.verifyCmd;
|
|
77
|
+
if (!verifyCommand) {
|
|
78
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
79
|
+
if (fs.existsSync(pkgPath)) {
|
|
80
|
+
try {
|
|
81
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
82
|
+
if (pkg.scripts?.test && pkg.scripts.test !== 'echo "Error: no test specified" && exit 1') {
|
|
83
|
+
verifyCommand = 'npm test';
|
|
84
|
+
}
|
|
85
|
+
else if (pkg.scripts?.build) {
|
|
86
|
+
verifyCommand = 'npm run build';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch { }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let verificationSuccess = true;
|
|
93
|
+
let attempts = 0;
|
|
94
|
+
const maxAttempts = options?.maxRetries || 3;
|
|
95
|
+
if (verifyCommand) {
|
|
96
|
+
s.message(`Running verification command: \`${verifyCommand}\`...`);
|
|
97
|
+
while (attempts < maxAttempts) {
|
|
98
|
+
attempts++;
|
|
99
|
+
try {
|
|
100
|
+
await execAsync(verifyCommand, { cwd });
|
|
101
|
+
verificationSuccess = true;
|
|
102
|
+
s.message(`Verification command \`${verifyCommand}\` passed!`);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
catch (cmdErr) {
|
|
106
|
+
verificationSuccess = false;
|
|
107
|
+
const output = (cmdErr.stdout || '') + '\n' + (cmdErr.stderr || '');
|
|
108
|
+
s.message(`Attempt ${attempts}/${maxAttempts}: Command failed. Diagnosing & self-healing...`);
|
|
109
|
+
const diagnosis = await analyzeCommandError(verifyCommand, cmdErr.code || 1, output, projectName, filesList, targetLang, options?.native);
|
|
110
|
+
const fileToFix = diagnosis.targetFileToFix || targetFiles[0] || filesList[0] || '';
|
|
111
|
+
if (fileToFix && fs.existsSync(path.resolve(cwd, fileToFix))) {
|
|
112
|
+
const currentContent = fs.readFileSync(path.resolve(cwd, fileToFix), 'utf-8');
|
|
113
|
+
const healPrompt = `Fix error running \`${verifyCommand}\`: ${diagnosis.rootCause}. Suggestion: ${diagnosis.suggestedFix}`;
|
|
114
|
+
const healedRes = await generateMultiCodeFix(healPrompt, projectName, filesList, { [fileToFix]: currentContent }, targetLang, options?.native);
|
|
115
|
+
if (healedRes.files[0]?.fixedCode) {
|
|
116
|
+
fs.writeFileSync(path.resolve(cwd, fileToFix), healedRes.files[0].fixedCode, 'utf-8');
|
|
117
|
+
if (!modifiedFiles.includes(fileToFix))
|
|
118
|
+
modifiedFiles.push(fileToFix);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const git = simpleGit();
|
|
125
|
+
const isRepo = await git.checkIsRepo();
|
|
126
|
+
let currentBranch = 'main';
|
|
127
|
+
if (isRepo) {
|
|
128
|
+
try {
|
|
129
|
+
const branchSummary = await git.branch();
|
|
130
|
+
currentBranch = branchSummary.current || 'main';
|
|
131
|
+
}
|
|
132
|
+
catch { }
|
|
133
|
+
}
|
|
134
|
+
if (modifiedFiles.length > 0) {
|
|
135
|
+
recordHistoryAction({
|
|
136
|
+
command: `scout agent "${finalGoal}"`,
|
|
137
|
+
description: `Scout agent completed goal on ${modifiedFiles.length} file(s)`,
|
|
138
|
+
previousBranch: currentBranch,
|
|
139
|
+
affectedFiles: modifiedFiles,
|
|
140
|
+
backups,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
s.stop(chalk.green(`🤖 Scout Agent workflow completed for: "${finalGoal}"!`));
|
|
144
|
+
const teardownMd = `
|
|
145
|
+
### 🎯 Agent Goal
|
|
146
|
+
${finalGoal}
|
|
147
|
+
|
|
148
|
+
### 📄 Modified File(s)
|
|
149
|
+
${modifiedFiles.map((f) => ` • \`${f}\``).join('\n') || ' • None'}
|
|
150
|
+
|
|
151
|
+
### 🔴 Problem Identified
|
|
152
|
+
${fixResult.problem}
|
|
153
|
+
|
|
154
|
+
### 🛠️ Solution Applied
|
|
155
|
+
${fixResult.howFixed}
|
|
156
|
+
|
|
157
|
+
### ✅ Verification Status
|
|
158
|
+
${verifyCommand ? (verificationSuccess ? `\`${verifyCommand}\` PASSED 🎉` : `\`${verifyCommand}\` FAILED (max retries reached) ⚠️`) : 'No automated verification script detected'}
|
|
159
|
+
`.trim();
|
|
160
|
+
safeNote(renderMarkdown(teardownMd), '🤖 Scout Agent Autonomous Teardown');
|
|
161
|
+
if (modifiedFiles.length === 0)
|
|
162
|
+
return;
|
|
163
|
+
if (options?.yes || !process.stdout.isTTY) {
|
|
164
|
+
safeNote(`${chalk.green('✓')} Agent changes retained on ${modifiedFiles.length} file(s) (Branch: ${chalk.bold.green(currentBranch)}).\n` +
|
|
165
|
+
`💡 ${chalk.dim('You can revert anytime by running:')} ${chalk.cyan('scout undo')}`, '✅ Agent Fix Confirmed');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const actionChoice = await select({
|
|
169
|
+
message: chalk.bold('Review Scout Agent result. What would you like to do?'),
|
|
170
|
+
options: [
|
|
171
|
+
{ value: 'keep', label: '✅ Keep Changes', hint: `Retain agent changes on current branch (${currentBranch})` },
|
|
172
|
+
{ value: 'pr', label: '🔀 Create Pull Request', hint: 'Push fix to a new branch & open a Pull Request' },
|
|
173
|
+
{ value: 'revert', label: '↩️ Revert Changes', hint: 'Restore original code immediately' },
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
if (actionChoice === 'revert') {
|
|
177
|
+
const revSpinner = spinner();
|
|
178
|
+
revSpinner.start('Reverting Agent changes...');
|
|
179
|
+
await handleUndo();
|
|
180
|
+
revSpinner.stop('Changes reverted successfully.');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (actionChoice === 'pr') {
|
|
184
|
+
const prSpinner = spinner();
|
|
185
|
+
prSpinner.start('Creating Pull Request...');
|
|
186
|
+
const prRes = await createPullRequest({
|
|
187
|
+
branchPrefix: 'agent',
|
|
188
|
+
title: finalGoal,
|
|
189
|
+
affectedFiles: modifiedFiles,
|
|
190
|
+
commitMessage: `feat: ${finalGoal}`,
|
|
191
|
+
});
|
|
192
|
+
prSpinner.stop('Pull Request workflow processed.');
|
|
193
|
+
safeNote(`${chalk.green('✓')} ${prRes.message}\n` +
|
|
194
|
+
`💡 ${chalk.dim('You remain on active branch:')} ${chalk.cyan(currentBranch)}`, '🔀 Pull Request Status');
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
safeNote(`${chalk.green('✓')} Agent changes retained on ${modifiedFiles.length} file(s) (Branch: ${chalk.bold.green(currentBranch)}).\n` +
|
|
198
|
+
`💡 ${chalk.dim('You can revert these changes anytime by running:')} ${chalk.cyan('scout undo')}`, '✅ Agent Workflow Finished');
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,EAAmB,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;A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,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,iBAiM5F"}
|
package/bin/src/commands/chat.js
CHANGED
|
@@ -9,6 +9,7 @@ import { normalizeLanguage } from '../utils/language.js';
|
|
|
9
9
|
import { handleCreate } from './create.js';
|
|
10
10
|
import { handleFix } from './fix.js';
|
|
11
11
|
import { handleRunCommand } from './runCommand.js';
|
|
12
|
+
import { handleAgent } from './agent.js';
|
|
12
13
|
import { handleScan } from './scan.js';
|
|
13
14
|
import { handleUndo } from './undo.js';
|
|
14
15
|
function getDirectoryFiles(dir, baseDir = dir, maxFiles = 150) {
|
|
@@ -54,6 +55,7 @@ export async function handleChat(options) {
|
|
|
54
55
|
${chalk.bold.cyan('Interactive Agentic AI Chat Session Active')} ${targetLang ? `(${targetLang})` : ''}
|
|
55
56
|
|
|
56
57
|
${chalk.bold('Slash Commands Available:')}
|
|
58
|
+
${chalk.cyan('/agent <goal>')} - Run autonomous agent self-healing loop
|
|
57
59
|
${chalk.cyan('/create <file> <prompt>')} - Create a new source file
|
|
58
60
|
${chalk.cyan('/fix [file] [prompt]')} - Auto-fix code in file or codebase
|
|
59
61
|
${chalk.cyan('/run <command>')} - Execute terminal/shell command
|
|
@@ -68,7 +70,7 @@ ${chalk.bold('Slash Commands Available:')}
|
|
|
68
70
|
while (true) {
|
|
69
71
|
const query = await text({
|
|
70
72
|
message: chalk.bold('You:'),
|
|
71
|
-
placeholder: 'Ask question, run slash command (/create, /fix, /run...), or request code generation...',
|
|
73
|
+
placeholder: 'Ask question, run slash command (/agent, /create, /fix, /run...), or request code generation...',
|
|
72
74
|
validate: (value) => (!value || !value.trim() ? 'Message cannot be empty' : undefined),
|
|
73
75
|
});
|
|
74
76
|
if (isCancel(query)) {
|
|
@@ -89,6 +91,10 @@ ${chalk.bold('Slash Commands Available:')}
|
|
|
89
91
|
safeNote(welcomeBanner, '🤖 Slash Command Help');
|
|
90
92
|
continue;
|
|
91
93
|
}
|
|
94
|
+
if (slashCmd === '/agent' || slashCmd === '/task' || slashCmd === '/goal') {
|
|
95
|
+
await handleAgent(restArg, { lang: targetLang, native: options?.native });
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
92
98
|
if (slashCmd === '/create') {
|
|
93
99
|
const fileParts = restArg.split(' ');
|
|
94
100
|
const targetPath = fileParts[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,SAAS,iBAAiB,CAAC,GAAW,EAAE,OAAO,GAAW,GAAG,EAAE,QAAQ,GAAW,GAAG;IACnF,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACjC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,OAAO,CAAC,M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AAC;
|
|
1
|
+
{"version":3,"file":"fix.d.ts","sourceRoot":"","sources":["fix.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,EAAE,MAAM,EAAE,GAClB,MAAM,EAAE,CAwGV;AAED,wBAAsB,SAAS,CAAC,OAAO,CAAC,EAAE,UAAU,iBA2QnD"}
|
package/bin/src/commands/fix.js
CHANGED
|
@@ -5,96 +5,94 @@ import { spinner, text, select, isCancel } from '@clack/prompts';
|
|
|
5
5
|
import { simpleGit } from 'simple-git';
|
|
6
6
|
import { loadScanReport } from './scan.js';
|
|
7
7
|
import { safeNote, renderMarkdown } from '../utils/markdown.js';
|
|
8
|
-
import { recordHistoryAction, loadContext } from '../utils/config.js';
|
|
8
|
+
import { recordHistoryAction, loadContext, getDirectoryFiles } from '../utils/config.js';
|
|
9
9
|
import { generateMultiCodeFix, identifyTargetFiles } from '../engine/llm.js';
|
|
10
10
|
import { createPullRequest } from '../engine/git.js';
|
|
11
11
|
import { handleUndo } from './undo.js';
|
|
12
12
|
import { normalizeLanguage } from '../utils/language.js';
|
|
13
|
-
function getDirectoryFiles(dir, baseDir = dir, maxFiles = 150) {
|
|
14
|
-
let results = [];
|
|
15
|
-
try {
|
|
16
|
-
const list = fs.readdirSync(dir);
|
|
17
|
-
for (const file of list) {
|
|
18
|
-
if (results.length >= maxFiles)
|
|
19
|
-
break;
|
|
20
|
-
if (['node_modules', '.git', '.ft', 'dist', 'build', '.next', 'coverage'].includes(file))
|
|
21
|
-
continue;
|
|
22
|
-
const filePath = path.join(dir, file);
|
|
23
|
-
const stat = fs.statSync(filePath);
|
|
24
|
-
if (stat && stat.isDirectory()) {
|
|
25
|
-
results = results.concat(getDirectoryFiles(filePath, baseDir, maxFiles - results.length));
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
const relativePath = path.relative(baseDir, filePath).replace(/\\/g, '/');
|
|
29
|
-
results.push(relativePath);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch { }
|
|
34
|
-
return results;
|
|
35
|
-
}
|
|
36
13
|
export function findTargetFilesFromPrompt(userPrompt, specifiedFile, filesList) {
|
|
14
|
+
const norm = (p) => p.replace(/\\/g, '/').toLowerCase().trim();
|
|
37
15
|
if (specifiedFile && specifiedFile.trim()) {
|
|
38
16
|
const raw = specifiedFile.trim();
|
|
39
|
-
const
|
|
17
|
+
const splitItems = raw.split(',').map((s) => s.trim()).filter(Boolean);
|
|
40
18
|
const matchedFromFlag = [];
|
|
41
|
-
for (const item of
|
|
42
|
-
const
|
|
19
|
+
for (const item of splitItems) {
|
|
20
|
+
const normItem = norm(item);
|
|
21
|
+
// Explicit extension-only pattern (e.g. *.ts, .ts, *.html, .html, or extension keyword like 'html' when no file matches)
|
|
22
|
+
const isExplicitExtPattern = item.startsWith('*') ||
|
|
23
|
+
item.startsWith('.') ||
|
|
24
|
+
(item.length <= 10 && !item.includes('/') && !item.includes('\\') && !filesList.some((f) => norm(f) === normItem || path.basename(norm(f)) === normItem));
|
|
25
|
+
if (isExplicitExtPattern) {
|
|
26
|
+
const cleanExt = normItem.replace(/^(\*|\.)+/, '');
|
|
27
|
+
if (cleanExt) {
|
|
28
|
+
const extFiles = filesList.filter((f) => norm(f).endsWith(`.${cleanExt}`));
|
|
29
|
+
matchedFromFlag.push(...extFiles);
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
// Exact relative path match
|
|
34
|
+
const exact = filesList.find((f) => norm(f) === normItem);
|
|
43
35
|
if (exact) {
|
|
44
36
|
matchedFromFlag.push(exact);
|
|
45
37
|
continue;
|
|
46
38
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
// Path suffix match (e.g. 'engine/llm.ts' matching 'bin/src/engine/llm.ts')
|
|
40
|
+
const suffixMatches = filesList.filter((f) => norm(f).endsWith('/' + normItem));
|
|
41
|
+
if (suffixMatches.length > 0) {
|
|
42
|
+
matchedFromFlag.push(...suffixMatches);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
// Basename match (e.g. 'llm.ts' matching 'bin/src/engine/llm.ts')
|
|
46
|
+
const baseMatches = filesList.filter((f) => path.basename(norm(f)) === path.basename(normItem));
|
|
47
|
+
if (baseMatches.length > 0) {
|
|
48
|
+
matchedFromFlag.push(...baseMatches);
|
|
49
|
+
continue;
|
|
52
50
|
}
|
|
51
|
+
// Specified file is a specific filepath that doesn't exist in filesList yet
|
|
52
|
+
matchedFromFlag.push(item);
|
|
53
53
|
}
|
|
54
54
|
if (matchedFromFlag.length > 0) {
|
|
55
55
|
return Array.from(new Set(matchedFromFlag));
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
const rawWords = userPrompt.split(/\s+/).map((w) => w.replace(/["'(),;:!]/g, '').trim());
|
|
59
|
+
const cleanPromptWords = rawWords.map((w) => w.toLowerCase());
|
|
58
60
|
const lowerPrompt = userPrompt.toLowerCase();
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
// 1. Direct filename / path match in prompt (Takes precedence over extension matching)
|
|
62
|
+
const matchedByName = [];
|
|
63
|
+
// Direct disk existence check for any file path mentioned in user prompt
|
|
64
|
+
for (const word of rawWords) {
|
|
65
|
+
if (word && word.includes('.')) {
|
|
66
|
+
const fullP = path.resolve(process.cwd(), word);
|
|
67
|
+
if (fs.existsSync(fullP) && fs.statSync(fullP).isFile()) {
|
|
68
|
+
const relP = path.relative(process.cwd(), fullP).replace(/\\/g, '/');
|
|
69
|
+
matchedByName.push(relP);
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
|
-
const knownExtensions = ['html', 'htm', 'css', 'js', 'ts', 'jsx', 'tsx', 'json', 'py', 'dart', 'vue', 'svelte', 'md', 'yaml', 'yml', 'sql'];
|
|
70
|
-
for (const ext of knownExtensions) {
|
|
71
|
-
if (lowerPrompt.includes(`.${ext}`) ||
|
|
72
|
-
lowerPrompt.includes(`${ext} file`) ||
|
|
73
|
-
lowerPrompt.includes(`${ext} files`) ||
|
|
74
|
-
lowerPrompt.includes(`*.${ext}`)) {
|
|
75
|
-
detectedExts.add(`.${ext}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (detectedExts.size > 0) {
|
|
79
|
-
const matchedByExt = [];
|
|
80
|
-
for (const ext of detectedExts) {
|
|
81
|
-
const extFiles = filesList.filter((f) => f.toLowerCase().endsWith(ext));
|
|
82
|
-
matchedByExt.push(...extFiles);
|
|
83
|
-
}
|
|
84
|
-
if (matchedByExt.length > 0) {
|
|
85
|
-
return Array.from(new Set(matchedByExt));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const matchedByName = [];
|
|
89
73
|
for (const f of filesList) {
|
|
90
|
-
const
|
|
91
|
-
|
|
74
|
+
const normF = norm(f);
|
|
75
|
+
const base = path.basename(normF);
|
|
76
|
+
if (lowerPrompt.includes(normF) ||
|
|
77
|
+
cleanPromptWords.includes(normF) ||
|
|
78
|
+
(base.includes('.') && (lowerPrompt.includes(base) || cleanPromptWords.includes(base)))) {
|
|
92
79
|
matchedByName.push(f);
|
|
93
80
|
}
|
|
94
81
|
}
|
|
95
82
|
if (matchedByName.length > 0) {
|
|
96
83
|
return Array.from(new Set(matchedByName));
|
|
97
84
|
}
|
|
85
|
+
// 2. Extension matching if prompt requests bulk/extension operation (e.g. ".html files", "html files", "*.ts", "in all .css files", "from .html files")
|
|
86
|
+
const bulkExtMatch = lowerPrompt.match(/(?:all|\*|in|from|for|across|every)?\s*(?:\*|\.)?([a-zA-Z0-9]{1,10})\s+files?\b|\*\.([a-zA-Z0-9]{1,10})/i);
|
|
87
|
+
if (bulkExtMatch) {
|
|
88
|
+
const ext = (bulkExtMatch[1] || bulkExtMatch[2])?.toLowerCase();
|
|
89
|
+
if (ext) {
|
|
90
|
+
const extFiles = filesList.filter((f) => norm(f).endsWith(`.${ext}`));
|
|
91
|
+
if (extFiles.length > 0) {
|
|
92
|
+
return Array.from(new Set(extFiles));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
98
96
|
return [];
|
|
99
97
|
}
|
|
100
98
|
export async function handleFix(options) {
|
|
@@ -147,7 +145,27 @@ export async function handleFix(options) {
|
|
|
147
145
|
}
|
|
148
146
|
}
|
|
149
147
|
if (targetFiles.length === 0) {
|
|
150
|
-
|
|
148
|
+
let possibleNewFile = undefined;
|
|
149
|
+
if (specifiedTargetFile && specifiedTargetFile.trim()) {
|
|
150
|
+
const clean = specifiedTargetFile.trim();
|
|
151
|
+
if (!clean.startsWith('.') && !clean.startsWith('*') && clean.includes('.')) {
|
|
152
|
+
possibleNewFile = clean;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const words = finalPrompt.split(/\s+/);
|
|
157
|
+
const fileCandidate = words.find((w) => {
|
|
158
|
+
const clean = w.replace(/["'(),;:]/g, '');
|
|
159
|
+
// Must contain a dot, must NOT start with dot or asterisk (e.g. not .html or *.ts),
|
|
160
|
+
// must have a valid filename before the extension (e.g. "index.html"),
|
|
161
|
+
// and must have a valid extension length (1-6 chars)
|
|
162
|
+
const match = clean.match(/^([a-zA-Z0-9_\-\/\\]+)\.([a-zA-Z0-9]{1,6})$/);
|
|
163
|
+
return match && match[1] && match[1].length > 0 && match[2] !== undefined;
|
|
164
|
+
});
|
|
165
|
+
if (fileCandidate) {
|
|
166
|
+
possibleNewFile = fileCandidate.replace(/["'(),;:]/g, '');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
151
169
|
if (possibleNewFile && !fs.existsSync(path.resolve(cwd, possibleNewFile))) {
|
|
152
170
|
const { handleCreate } = await import('./create.js');
|
|
153
171
|
safeNote(chalk.cyan(`Target file \`${possibleNewFile}\` does not exist yet. Switching to Scout File Creation...`), '✨ Creating New File');
|
|
@@ -161,13 +179,14 @@ export async function handleFix(options) {
|
|
|
161
179
|
}
|
|
162
180
|
const targetFilesMap = {};
|
|
163
181
|
const backups = [];
|
|
182
|
+
const normKey = (p) => p.replace(/\\/g, '/').replace(/^\.\//, '').trim();
|
|
164
183
|
for (const tf of targetFiles) {
|
|
165
184
|
const fullPath = path.resolve(cwd, tf);
|
|
166
185
|
if (fs.existsSync(fullPath)) {
|
|
167
186
|
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
168
|
-
targetFilesMap[tf] = content;
|
|
187
|
+
targetFilesMap[normKey(tf)] = content;
|
|
169
188
|
backups.push({
|
|
170
|
-
filePath: tf,
|
|
189
|
+
filePath: normKey(tf),
|
|
171
190
|
originalContent: content,
|
|
172
191
|
});
|
|
173
192
|
}
|
|
@@ -190,7 +209,9 @@ export async function handleFix(options) {
|
|
|
190
209
|
s.start(`Scout is analyzing problem & auto-fixing ${targetFiles.length} file${targetFiles.length > 1 ? 's' : ''}...`);
|
|
191
210
|
let fixResult;
|
|
192
211
|
try {
|
|
193
|
-
fixResult = await generateMultiCodeFix(finalPrompt, projectName, filesList, targetFilesMap, targetLang, options?.native)
|
|
212
|
+
fixResult = await generateMultiCodeFix(finalPrompt, projectName, filesList, targetFilesMap, targetLang, options?.native, (completed, total, currentFile) => {
|
|
213
|
+
s.message(`Scout auto-fixing files (${completed}/${total}): ${currentFile}...`);
|
|
214
|
+
});
|
|
194
215
|
}
|
|
195
216
|
catch (err) {
|
|
196
217
|
s.stop(chalk.red('Failed to generate AI code fix.'));
|
|
@@ -200,17 +221,28 @@ export async function handleFix(options) {
|
|
|
200
221
|
const modifiedFiles = [];
|
|
201
222
|
for (const item of fixResult.files) {
|
|
202
223
|
if (item.fixedCode !== undefined) {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
224
|
+
const k = normKey(item.targetFile);
|
|
225
|
+
const fullPath = path.resolve(cwd, k);
|
|
226
|
+
const originalContent = targetFilesMap[k] ?? '';
|
|
227
|
+
const normalizedFixed = item.fixedCode.replace(/\r\n/g, '\n').trim();
|
|
228
|
+
const normalizedOrig = originalContent.replace(/\r\n/g, '\n').trim();
|
|
229
|
+
if (normalizedFixed !== normalizedOrig) {
|
|
230
|
+
try {
|
|
231
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
232
|
+
fs.writeFileSync(fullPath, item.fixedCode, 'utf-8');
|
|
233
|
+
modifiedFiles.push(k);
|
|
234
|
+
}
|
|
235
|
+
catch (writeErr) {
|
|
236
|
+
console.error(`Failed to write fix to ${k}:`, writeErr?.message);
|
|
237
|
+
}
|
|
211
238
|
}
|
|
212
239
|
}
|
|
213
240
|
}
|
|
241
|
+
if (modifiedFiles.length === 0) {
|
|
242
|
+
s.stop(chalk.yellow('No code modifications were required.'));
|
|
243
|
+
safeNote(chalk.yellow(`Scout analyzed ${targetFiles.length} file(s), but no code changes were needed for prompt: "${finalPrompt}".\n(The target issue or pattern was not present in the analyzed files).`), 'ℹ️ No Code Changes Made');
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
214
246
|
recordHistoryAction({
|
|
215
247
|
command: `ft fix "${finalPrompt}"`,
|
|
216
248
|
description: `Scout auto-fixed ${modifiedFiles.length} file(s): ${modifiedFiles.join(', ')}`,
|
|
@@ -242,13 +274,18 @@ ${fixResult.howFixed}
|
|
|
242
274
|
{ value: 'revert', label: '↩️ Revert Changes', hint: 'Restore original code immediately' },
|
|
243
275
|
],
|
|
244
276
|
});
|
|
245
|
-
if (
|
|
277
|
+
if (actionChoice === 'revert') {
|
|
246
278
|
const revSpinner = spinner();
|
|
247
279
|
revSpinner.start('Reverting Scout\'s changes...');
|
|
248
280
|
await handleUndo();
|
|
249
281
|
revSpinner.stop('Changes reverted successfully.');
|
|
250
282
|
return;
|
|
251
283
|
}
|
|
284
|
+
if (isCancel(actionChoice)) {
|
|
285
|
+
safeNote(`${chalk.green('✓')} Auto-fix retained on ${modifiedFiles.length} file(s) (Branch: ${chalk.bold.green(currentBranch)}).\n` +
|
|
286
|
+
`💡 ${chalk.dim('You can revert these changes anytime by running:')} ${chalk.cyan('scout undo')}`, '✅ Fix Retained');
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
252
289
|
if (actionChoice === 'pr') {
|
|
253
290
|
const prSpinner = spinner();
|
|
254
291
|
prSpinner.start('Creating Pull Request...');
|