@taj-special/dravix-code 1.1.26 → 1.1.28
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/dist/cli/repl.js +7 -7
- package/dist/services/context.js +30 -1
- package/package.json +1 -1
package/dist/cli/repl.js
CHANGED
|
@@ -2122,10 +2122,15 @@ export async function startRepl(cwd) {
|
|
|
2122
2122
|
|
|
2123
2123
|
## CRITICAL RULES — Follow these on every response
|
|
2124
2124
|
|
|
2125
|
+
### Act decisively
|
|
2126
|
+
- Use judgment and execute immediately when intent is clear.
|
|
2127
|
+
- Do NOT ask unnecessary clarifying questions — just do the task.
|
|
2128
|
+
- Make reasonable assumptions and proceed. State the assumption briefly if needed.
|
|
2129
|
+
|
|
2125
2130
|
### Creating files
|
|
2126
2131
|
- NEVER show code in code blocks when the user asks to create files or a project.
|
|
2127
2132
|
- ALWAYS use <write_file path="filename"> tags to create actual files.
|
|
2128
|
-
- Code blocks are for short explanations only — they do NOT create files.
|
|
2133
|
+
- Code blocks are for short inline explanations only — they do NOT create files.
|
|
2129
2134
|
- Output ALL required files in ONE response using <write_file> tags.
|
|
2130
2135
|
|
|
2131
2136
|
### File operations
|
|
@@ -2136,12 +2141,7 @@ export async function startRepl(cwd) {
|
|
|
2136
2141
|
|
|
2137
2142
|
### Scope
|
|
2138
2143
|
- Only touch files the user explicitly mentioned or that are clearly required by the task.
|
|
2139
|
-
-
|
|
2140
|
-
- Do NOT restructure, rename, or "improve" anything that wasn't asked.
|
|
2141
|
-
|
|
2142
|
-
### When unsure
|
|
2143
|
-
- Ask ONE short clarifying question before writing any code.
|
|
2144
|
-
- Better to ask than to guess wrong and destroy existing work.`;
|
|
2144
|
+
- Do NOT restructure, rename, or "improve" anything that wasn't asked.`;
|
|
2145
2145
|
const buildSystemMsg = (dir) => ({
|
|
2146
2146
|
role: 'system',
|
|
2147
2147
|
content: SYSTEM_PROMPT + SAFE_FILE_RULES + '\n\nProject context:\n' + buildContext(dir),
|
package/dist/services/context.js
CHANGED
|
@@ -115,6 +115,29 @@ export function extractRelevantSections(fileContent, userMessage, contextLines =
|
|
|
115
115
|
out.push(`[Use <read_file lines="N-M"/> to read any section not shown above]`);
|
|
116
116
|
return out.join('\n');
|
|
117
117
|
}
|
|
118
|
+
// Detect top-level subdirectories that look like separate standalone projects
|
|
119
|
+
function detectSeparateProjects(root, files) {
|
|
120
|
+
const topDirFiles = new Map();
|
|
121
|
+
for (const f of files) {
|
|
122
|
+
const slash = f.indexOf('/');
|
|
123
|
+
if (slash === -1)
|
|
124
|
+
continue;
|
|
125
|
+
const dir = f.slice(0, slash);
|
|
126
|
+
if (!topDirFiles.has(dir))
|
|
127
|
+
topDirFiles.set(dir, []);
|
|
128
|
+
topDirFiles.get(dir).push(path.basename(f).toLowerCase());
|
|
129
|
+
}
|
|
130
|
+
const PROJECT_FILES = new Set([
|
|
131
|
+
'package.json', 'composer.json', 'config.php', 'index.php', 'index.js',
|
|
132
|
+
'index.ts', 'main.py', 'app.py', 'bot.php', 'main.go', 'pom.xml',
|
|
133
|
+
]);
|
|
134
|
+
const projectDirs = [];
|
|
135
|
+
for (const [dir, dirFiles] of topDirFiles) {
|
|
136
|
+
if (dirFiles.some(f => PROJECT_FILES.has(f)))
|
|
137
|
+
projectDirs.push(dir);
|
|
138
|
+
}
|
|
139
|
+
return projectDirs;
|
|
140
|
+
}
|
|
118
141
|
export function buildContext(root) {
|
|
119
142
|
const files = getProjectFiles(root);
|
|
120
143
|
const git = getGitStatus(root);
|
|
@@ -122,11 +145,17 @@ export function buildContext(root) {
|
|
|
122
145
|
const shell = process.platform === 'win32' ? 'Windows — PowerShell'
|
|
123
146
|
: process.platform === 'darwin' ? 'macOS — bash/zsh'
|
|
124
147
|
: 'Linux — bash';
|
|
148
|
+
const separateProjects = detectSeparateProjects(root, files);
|
|
149
|
+
const parentDirWarning = separateProjects.length >= 2
|
|
150
|
+
? `\n⚠ PARENT DIRECTORY — contains ${separateProjects.length} separate projects: ${separateProjects.join(', ')}\n` +
|
|
151
|
+
`RULE: NEVER modify files inside existing project folders (${separateProjects.join(', ')}) unless the user explicitly asks to work on that specific project.\n` +
|
|
152
|
+
`When creating a NEW project, ALWAYS create a NEW dedicated subfolder.`
|
|
153
|
+
: '';
|
|
125
154
|
return `Project: ${projectName}
|
|
126
155
|
Working dir: ${root}
|
|
127
156
|
OS: ${shell}
|
|
128
157
|
Git status:
|
|
129
158
|
${git || '(clean)'}
|
|
130
159
|
Files:
|
|
131
|
-
${files.length > 0 ? files.join('\n') : '(empty project)'}`;
|
|
160
|
+
${files.length > 0 ? files.join('\n') : '(empty project)'}${parentDirWarning}`;
|
|
132
161
|
}
|