sapper-iq 1.3.1 ā 1.3.2
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/package.json +1 -1
- package/sapper-ui.mjs +6 -2
- package/sapper.mjs +33 -6
package/package.json
CHANGED
package/sapper-ui.mjs
CHANGED
|
@@ -1917,10 +1917,14 @@ window.sendIndexToChat = function() {
|
|
|
1917
1917
|
paths.forEach(function(p){
|
|
1918
1918
|
if (state.indexSet[p] && state.indexSet[p].isDir) dirs.push(p); else files.push(p);
|
|
1919
1919
|
});
|
|
1920
|
+
// Helper: quote paths that contain spaces, leave plain otherwise.
|
|
1921
|
+
function quoteIfNeeded(p) {
|
|
1922
|
+
return /\\s/.test(p) ? '"' + p.replace(/"/g, '\\\\"') + '"' : p;
|
|
1923
|
+
}
|
|
1920
1924
|
// 1) /scan each folder (each sent as its own command + Enter)
|
|
1921
|
-
dirs.forEach(function(d){ sendPasteToTerm('/scan ' + d); });
|
|
1925
|
+
dirs.forEach(function(d){ sendPasteToTerm('/scan ' + quoteIfNeeded(d)); });
|
|
1922
1926
|
// 2) Build attachments token for files
|
|
1923
|
-
var atTokens = files.map(function(f){ return '@' + f; }).join(' ');
|
|
1927
|
+
var atTokens = files.map(function(f){ return '@' + quoteIfNeeded(f); }).join(' ');
|
|
1924
1928
|
var comment = (document.getElementById('idxComment') || {}).value || '';
|
|
1925
1929
|
comment = comment.trim();
|
|
1926
1930
|
if (comment) {
|
package/sapper.mjs
CHANGED
|
@@ -8364,10 +8364,33 @@ async function runSapper() {
|
|
|
8364
8364
|
continue;
|
|
8365
8365
|
}
|
|
8366
8366
|
|
|
8367
|
-
// Handle codebase scan command
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8367
|
+
// Handle codebase scan command ā accepts an optional path argument
|
|
8368
|
+
// (single quoted path or single bare path; spaces are allowed in bare paths)
|
|
8369
|
+
if (input.toLowerCase() === '/scan' || input.toLowerCase().startsWith('/scan ')) {
|
|
8370
|
+
let scanTarget = '.';
|
|
8371
|
+
const rest = input.slice(5).trim();
|
|
8372
|
+
if (rest) {
|
|
8373
|
+
// Strip surrounding quotes if present
|
|
8374
|
+
if ((rest.startsWith('"') && rest.endsWith('"')) ||
|
|
8375
|
+
(rest.startsWith("'") && rest.endsWith("'"))) {
|
|
8376
|
+
scanTarget = rest.slice(1, -1);
|
|
8377
|
+
} else {
|
|
8378
|
+
scanTarget = rest;
|
|
8379
|
+
}
|
|
8380
|
+
}
|
|
8381
|
+
if (!fs.existsSync(scanTarget)) {
|
|
8382
|
+
console.log(chalk.red(`Path not found: ${scanTarget}`));
|
|
8383
|
+
continue;
|
|
8384
|
+
}
|
|
8385
|
+
const scanStat = fs.statSync(scanTarget);
|
|
8386
|
+
if (!scanStat.isDirectory()) {
|
|
8387
|
+
console.log(chalk.red(`Not a directory: ${scanTarget}`));
|
|
8388
|
+
continue;
|
|
8389
|
+
}
|
|
8390
|
+
console.log(uiCleanMode()
|
|
8391
|
+
? chalk.cyan(`\nScanning ${scanTarget}...`)
|
|
8392
|
+
: chalk.cyan(`\nš Scanning ${scanTarget}...`));
|
|
8393
|
+
const scanResult = scanCodebase(scanTarget);
|
|
8371
8394
|
|
|
8372
8395
|
if (scanResult.files.length === 0) {
|
|
8373
8396
|
console.log(chalk.yellow('No code files found in current directory.'));
|
|
@@ -8477,13 +8500,17 @@ async function runSapper() {
|
|
|
8477
8500
|
// Continue to AI response (don't use 'continue' here)
|
|
8478
8501
|
} else {
|
|
8479
8502
|
// Process @file attachments in prompt (e.g., "analyze @package.json" or "fix @src/index.js")
|
|
8503
|
+
// Supports three forms:
|
|
8504
|
+
// @path/no/spaces ā plain bare path
|
|
8505
|
+
// @"path with spaces/file.md" ā double-quoted path
|
|
8506
|
+
// @'path with spaces/file.md' ā single-quoted path
|
|
8480
8507
|
let processedInput = input.startsWith('//') ? input.slice(1) : input;
|
|
8481
8508
|
const fileAttachments = [];
|
|
8482
|
-
const attachRegex = /@([\w.\/\-_]+)/g;
|
|
8509
|
+
const attachRegex = /@(?:"([^"]+)"|'([^']+)'|([\w.\/\-_]+))/g;
|
|
8483
8510
|
let attachMatch;
|
|
8484
8511
|
|
|
8485
8512
|
while ((attachMatch = attachRegex.exec(input)) !== null) {
|
|
8486
|
-
const filePath = attachMatch[1];
|
|
8513
|
+
const filePath = attachMatch[1] || attachMatch[2] || attachMatch[3];
|
|
8487
8514
|
try {
|
|
8488
8515
|
if (fs.existsSync(filePath)) {
|
|
8489
8516
|
// Check .sapperignore
|