@taj-special/dravix-code 1.1.26 → 1.1.27

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.
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taj-special/dravix-code",
3
- "version": "1.1.26",
3
+ "version": "1.1.27",
4
4
  "description": "AI-powered coding assistant CLI — Dravix Code",
5
5
  "type": "module",
6
6
  "bin": {