scai 0.1.174 → 0.1.175

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.
@@ -347,6 +347,7 @@ export class MainAgent {
347
347
  .filter(filePath => !!filePath && !filePath.startsWith("__research__/") && fs.existsSync(filePath))
348
348
  .sort((a, b) => rankPath(a) - rankPath(b))
349
349
  .slice(0, 16);
350
+ this.ensureWorkingFilesLoaded(plannedPaths, "Planned for execution");
350
351
  let seededCount = 0;
351
352
  const seeded = [];
352
353
  for (const filePath of plannedPaths) {
@@ -409,6 +410,15 @@ export class MainAgent {
409
410
  const routing = this.context.analysis.routingDecision;
410
411
  if (!routing)
411
412
  return;
413
+ const intentCategory = (this.context.analysis.intent?.intentCategory ?? "").toLowerCase();
414
+ const isEditLikeIntent = intentCategory === "codingtask" ||
415
+ intentCategory === "refactortask" ||
416
+ intentCategory === "request" ||
417
+ intentCategory === "docsandcomments";
418
+ const canWrite = this.context.executionControl?.constraints?.allowFileWrites ?? false;
419
+ if (!isEditLikeIntent || !canWrite) {
420
+ return;
421
+ }
412
422
  const selectedFiles = this.context.analysis.focus?.selectedFiles ?? [];
413
423
  if (selectedFiles.length === 0)
414
424
  return;
@@ -1293,6 +1303,7 @@ export class MainAgent {
1293
1303
  this.persistTaskDataForRun();
1294
1304
  }
1295
1305
  startTaskStep(taskStep, stepCount) {
1306
+ this.ensureWorkingFilesLoaded([taskStep.filePath], "Current task step");
1296
1307
  this.context.task.currentStep = taskStep;
1297
1308
  taskStep.taskId = this.taskId;
1298
1309
  taskStep.stepIndex = stepCount;
@@ -1433,6 +1444,41 @@ export class MainAgent {
1433
1444
  console.log(`[USER OUTPUT] ${message}`);
1434
1445
  });
1435
1446
  }
1447
+ /**
1448
+ * Ensures workingFiles has file capsules with code for the given paths.
1449
+ * Example: planned verify-relevant files are hydrated before transform starts.
1450
+ */
1451
+ ensureWorkingFilesLoaded(paths, reason) {
1452
+ var _a;
1453
+ (_a = this.context).workingFiles || (_a.workingFiles = []);
1454
+ const indexByPath = new Map(this.context.workingFiles.map(file => [file.path, file]));
1455
+ for (const filePath of paths) {
1456
+ if (!filePath || filePath.startsWith("__research__/"))
1457
+ continue;
1458
+ if (!fs.existsSync(filePath))
1459
+ continue;
1460
+ const existing = indexByPath.get(filePath);
1461
+ if (existing && typeof existing.code === "string" && existing.code.length > 0) {
1462
+ continue;
1463
+ }
1464
+ let code;
1465
+ try {
1466
+ code = fs.readFileSync(filePath, "utf-8");
1467
+ }
1468
+ catch {
1469
+ code = undefined;
1470
+ }
1471
+ if (existing) {
1472
+ existing.code = code;
1473
+ existing.selectionReason || (existing.selectionReason = reason);
1474
+ }
1475
+ else {
1476
+ const capsule = { path: filePath, code, selectionReason: reason };
1477
+ this.context.workingFiles.push(capsule);
1478
+ indexByPath.set(filePath, capsule);
1479
+ }
1480
+ }
1481
+ }
1436
1482
  }
1437
1483
  function scoreCandidateFiles(filePaths, relatedFileScores, retrievalQuery) {
1438
1484
  const explicitRefs = extractFileReferences(retrievalQuery, { lowercase: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scai",
3
- "version": "0.1.174",
3
+ "version": "0.1.175",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "scai": "./dist/index.js"