sam-coder-cli 1.0.67 → 1.0.68

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.
Files changed (2) hide show
  1. package/bin/agi-cli.js +35 -4
  2. package/package.json +1 -1
package/bin/agi-cli.js CHANGED
@@ -529,10 +529,17 @@ const agentUtils = {
529
529
  async searchFiles(input) {
530
530
  try {
531
531
  const isString = typeof input === 'string';
532
- const pattern = isString ? input : input?.pattern;
533
- const basePathRaw = isString ? null : (input?.path || null);
532
+ let pattern = isString ? input : input?.pattern;
533
+ let basePathRaw = isString ? null : (input?.path || null);
534
534
  const recursive = isString ? true : (input?.recursive !== false);
535
535
 
536
+ // Handle wildcards embedded in the path (e.g., C:\\foo\\bar\\*)
537
+ const hasWildcard = (p) => typeof p === 'string' && /[\*\?]/.test(p);
538
+ if (!pattern && hasWildcard(basePathRaw)) {
539
+ pattern = path.basename(basePathRaw);
540
+ basePathRaw = path.dirname(basePathRaw);
541
+ }
542
+
536
543
  const basePath = basePathRaw
537
544
  ? (path.isAbsolute(basePathRaw) ? basePathRaw : path.join(process.cwd(), basePathRaw))
538
545
  : process.cwd();
@@ -542,12 +549,36 @@ const agentUtils = {
542
549
  const matchByPattern = (name) => {
543
550
  if (!pattern) return true; // if no pattern, match all
544
551
  const escaped = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
545
- const regex = new RegExp('^' + escaped.replace(/\*/g, '.*') + '$');
552
+ const regex = new RegExp('^' + escaped.replace(/\*/g, '.*').replace(/\?/g, '.') + '$');
546
553
  return regex.test(name);
547
554
  };
548
555
 
556
+ // If base path is a file, test it directly
557
+ try {
558
+ const stat = await fs.stat(basePath);
559
+ if (stat.isFile()) {
560
+ if (matchByPattern(path.basename(basePath))) {
561
+ results.push(basePath);
562
+ }
563
+ return results.length > 0
564
+ ? `Found ${results.length} files:\n${results.join('\n')}`
565
+ : 'No files found';
566
+ }
567
+ } catch (e) {
568
+ if (e && e.code === 'ENOENT') {
569
+ return 'No files found';
570
+ }
571
+ // Non-ENOENT errors are handled by traversal below
572
+ }
573
+
549
574
  const search = async (dir) => {
550
- const entries = await fs.readdir(dir, { withFileTypes: true });
575
+ let entries;
576
+ try {
577
+ entries = await fs.readdir(dir, { withFileTypes: true });
578
+ } catch (e) {
579
+ if (e && e.code === 'ENOENT') return; // directory missing
580
+ throw e;
581
+ }
551
582
  for (const entry of entries) {
552
583
  const fullPath = path.join(dir, entry.name);
553
584
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sam-coder-cli",
3
- "version": "1.0.67",
3
+ "version": "1.0.68",
4
4
  "description": "SAM-CODER: An animated command-line AI assistant with agency capabilities.",
5
5
  "main": "bin/agi-cli.js",
6
6
  "bin": {