From 67d1f4a49c86a571bd9cbc01130806ee02ddb1a9 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 14 Jul 2025 01:29:30 -0700 Subject: [PATCH] Add file search functionality with @ trigger in user input --- package-lock.json | 441 +++++++++++++++++++++++++++++++++++++--- package.json | 2 + src/ui/FileSearchUI.tsx | 202 ++++++++++++++++++ src/ui/TUIChat.tsx | 22 +- src/ui/UserInput.tsx | 114 ++++++++++- test-file.txt | 1 + 6 files changed, 746 insertions(+), 36 deletions(-) create mode 100644 src/ui/FileSearchUI.tsx create mode 100644 test-file.txt diff --git a/package-lock.json b/package-lock.json index 93e9eafa3..33d397a5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/cli", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/cli", - "version": "1.1.0", + "version": "1.2.0", "license": "Apache-2.0", "dependencies": { "@continuedev/openai-adapters": "^1.0.18", @@ -18,6 +18,7 @@ "chalk": "^5.4.1", "diff": "^7.0.0", "dotenv": "^16.5.0", + "glob": "^11.0.3", "ignore-walk": "^7.0.0", "ink": "^6.0.1", "minimatch": "^10.0.3", @@ -35,6 +36,7 @@ "@semantic-release/github": "^11.0.3", "@semantic-release/npm": "^12.0.2", "@types/diff": "^7.0.2", + "@types/glob": "^8.1.0", "@types/ignore-walk": "^4.0.3", "@types/jest": "^29.5.14", "@types/readline-sync": "^1.4.8", @@ -1259,6 +1261,102 @@ "node": "20 || >=22" } }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "license": "MIT" + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -1572,6 +1670,41 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/@jest/reporters/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@jest/reporters/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -2744,6 +2877,17 @@ "@types/send": "*" } }, + "node_modules/@types/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", @@ -2850,6 +2994,13 @@ "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", "license": "MIT" }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.15.3", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.3.tgz", @@ -3100,7 +3251,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -3971,7 +4121,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -3984,7 +4133,6 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, "license": "MIT" }, "node_modules/combined-stream": { @@ -4584,6 +4732,12 @@ "readable-stream": "^2.0.2" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "license": "MIT" + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -4630,7 +4784,6 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, "license": "MIT" }, "node_modules/emojilib": { @@ -5341,6 +5494,34 @@ } } }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/form-data": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", @@ -5624,22 +5805,23 @@ } }, "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", "license": "ISC", "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" }, "engines": { - "node": "*" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -5658,18 +5840,6 @@ "node": ">= 6" } }, - "node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -6418,7 +6588,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -6673,6 +6842,21 @@ "node": ">=8" } }, + "node_modules/jackspeak": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", + "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/jake": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz", @@ -7000,6 +7184,41 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/jest-config/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/jest-config/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/jest-diff": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", @@ -7527,6 +7746,41 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/jest-runtime/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/jest-runtime/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/jest-snapshot": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", @@ -8310,6 +8564,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -11430,6 +11693,12 @@ "node": ">=6" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "license": "BlueOak-1.0.0" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -11552,6 +11821,31 @@ "dev": true, "license": "MIT" }, + "node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.1.0.tgz", + "integrity": "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==", + "license": "ISC", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/path-to-regexp": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", @@ -13087,7 +13381,21 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", @@ -13102,7 +13410,19 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" @@ -13274,6 +13594,28 @@ "node": ">=8" } }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/test-exclude/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -13927,6 +14269,39 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/wrap-ansi/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", diff --git a/package.json b/package.json index 29121180b..bd62af295 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "chalk": "^5.4.1", "diff": "^7.0.0", "dotenv": "^16.5.0", + "glob": "^11.0.3", "ignore-walk": "^7.0.0", "ink": "^6.0.1", "minimatch": "^10.0.3", @@ -54,6 +55,7 @@ "@semantic-release/github": "^11.0.3", "@semantic-release/npm": "^12.0.2", "@types/diff": "^7.0.2", + "@types/glob": "^8.1.0", "@types/ignore-walk": "^4.0.3", "@types/jest": "^29.5.14", "@types/readline-sync": "^1.4.8", diff --git a/src/ui/FileSearchUI.tsx b/src/ui/FileSearchUI.tsx new file mode 100644 index 000000000..49d4e4974 --- /dev/null +++ b/src/ui/FileSearchUI.tsx @@ -0,0 +1,202 @@ +import { Box, Text } from "ink"; +import React, { useEffect, useState } from "react"; +import { glob } from "glob"; + +interface FileSearchUIProps { + filter: string; + selectedIndex: number; + onSelect: (filePath: string) => void; + onFilesUpdated?: (files: FileItem[]) => void; +} + +interface FileItem { + path: string; + displayName: string; +} + +const FileSearchUI: React.FC = ({ + filter, + selectedIndex, + onSelect, + onFilesUpdated, +}) => { + const [files, setFiles] = useState([]); + const [isLoading, setIsLoading] = useState(false); + + useEffect(() => { + const searchFiles = async () => { + setIsLoading(true); + try { + // Search for files matching the filter + const patterns = [ + "**/*.{ts,tsx,js,jsx,py,java,cpp,c,h,hpp,cs,go,rs,rb,php,swift,kt,scala,clj,hs,ml,sh,md,json,yaml,yml,xml,html,css,scss,sass,less,sql,r,m,mm,pl,lua,dart,jl,ex,exs,elm,fs,fsx,ml,mli,v,sv,vhd,vhdl,asm,s,S,f,f90,f95,f03,f08,for,ftn,fpp,F,F90,F95,F03,F08,FOR,FTN,FPP,ada,adb,ads,pas,pp,inc,lpr,dpr,dfm,fmx,lfm,lrs,lpi,lpk,lps,lrt,cfg,conf,config,toml,ini,properties,env,dockerfile,Dockerfile,makefile,Makefile,CMakeLists.txt,BUILD,WORKSPACE,bzl,bazel,gradle,pom.xml,package.json,Cargo.toml,requirements.txt,setup.py,pyproject.toml,composer.json,Gemfile,Podfile,Package.swift,project.pbxproj,*.xcodeproj,*.xcworkspace,*.sln,*.csproj,*.vbproj,*.fsproj,*.vcxproj,*.vcproj,*.dsp,*.dsw,*.pro,*.pri,*.qbs,*.cmake,*.am,*.in,*.m4,*.ac,*.mk,*.mak,*.ninja,*.gyp,*.gypi,*.gn,*.gni,*.bp,*.mm,*.pch,*.plist,*.entitlements,*.storyboard,*.xib,*.nib,*.strings,*.stringsdict,*.lproj,*.bundle,*.framework,*.dylib,*.so,*.dll,*.lib,*.a,*.o,*.obj,*.exe,*.app,*.deb,*.rpm,*.dmg,*.pkg,*.msi,*.tar.gz,*.tgz,*.tar.bz2,*.tbz2,*.tar.xz,*.txz,*.zip,*.7z,*.rar,*.iso,*.img,*.bin,*.hex,*.elf,*.out,*.com,*.bat,*.cmd,*.ps1,*.psm1,*.psd1,*.ps1xml,*.pssc,*.psrc,*.cdxml}", + "**/*.txt", + "**/*.log", + "**/README*", + "**/LICENSE*", + "**/CHANGELOG*", + "**/CONTRIBUTING*", + "**/.gitignore", + "**/.env*", + ]; + + const allFiles: string[] = []; + + for (const pattern of patterns) { + const matches = await glob(pattern, { + ignore: [ + "**/node_modules/**", + "**/dist/**", + "**/build/**", + "**/out/**", + "**/target/**", + "**/.git/**", + "**/.vscode/**", + "**/.idea/**", + "**/coverage/**", + "**/*.min.js", + "**/*.min.css", + "**/*.bundle.js", + "**/*.bundle.css", + "**/.DS_Store", + "**/Thumbs.db", + "**/*.log", + "**/*.tmp", + "**/*.temp", + "**/*.swp", + "**/*.swo", + "**/*.bak", + "**/*.orig", + "**/*.rej", + "**/*.pyc", + "**/*.pyo", + "**/*.class", + "**/*.o", + "**/*.obj", + "**/*.exe", + "**/*.dll", + "**/*.so", + "**/*.dylib", + "**/*.a", + "**/*.lib", + "**/*.jar", + "**/*.war", + "**/*.ear", + "**/*.zip", + "**/*.tar.gz", + "**/*.tgz", + "**/*.rar", + "**/*.7z", + ], + dot: true, + absolute: false, + }); + allFiles.push(...matches); + } + + // Remove duplicates and sort + const uniqueFiles = [...new Set(allFiles)]; + + const fileItems: FileItem[] = uniqueFiles.map((path) => ({ + path, + displayName: path.split('/').pop() || path, + })); + + // Filter files based on the current filter + const filteredFiles = fileItems + .filter((file) => { + if (filter.length === 0) { + return true; // Show all files when no filter + } + const lowerFilter = filter.toLowerCase(); + return ( + file.displayName.toLowerCase().includes(lowerFilter) || + file.path.toLowerCase().includes(lowerFilter) + ); + }) + .sort((a, b) => { + if (filter.length === 0) { + // When no filter, sort by file name + return a.displayName.localeCompare(b.displayName); + } + + const lowerFilter = filter.toLowerCase(); + + // Prioritize exact matches in file name + const aNameMatch = a.displayName.toLowerCase().includes(lowerFilter); + const bNameMatch = b.displayName.toLowerCase().includes(lowerFilter); + + if (aNameMatch && !bNameMatch) return -1; + if (!aNameMatch && bNameMatch) return 1; + + // Then prioritize files that start with the filter + const aStartsWith = a.displayName.toLowerCase().startsWith(lowerFilter); + const bStartsWith = b.displayName.toLowerCase().startsWith(lowerFilter); + + if (aStartsWith && !bStartsWith) return -1; + if (!aStartsWith && bStartsWith) return 1; + + // Finally, sort by file name + return a.displayName.localeCompare(b.displayName); + }) + .slice(0, 10); // Limit to 10 results for screen space + + setFiles(filteredFiles); + if (onFilesUpdated) { + onFilesUpdated(filteredFiles); + } + } catch (error) { + console.error("Error searching files:", error); + setFiles([]); + if (onFilesUpdated) { + onFilesUpdated([]); + } + } finally { + setIsLoading(false); + } + }; + + searchFiles(); + }, [filter, onFilesUpdated]); + + if (isLoading) { + return ( + + Searching files... + + ); + } + + if (files.length === 0) { + return ( + + No matching files found + + ); + } + + return ( + + {files.map((file, index) => { + const isSelected = index === selectedIndex; + + return ( + + + {" "} + @{file.displayName} + + + ); + })} + + + + Use ↑/↓ to navigate, Enter to select, Tab to complete + + + + ); +}; + +export default FileSearchUI; \ No newline at end of file diff --git a/src/ui/TUIChat.tsx b/src/ui/TUIChat.tsx index f05c4567a..607c99a0e 100644 --- a/src/ui/TUIChat.tsx +++ b/src/ui/TUIChat.tsx @@ -48,6 +48,7 @@ const TUIChat: React.FC = ({ const [inputMode, setInputMode] = useState(true); const [abortController, setAbortController] = useState(null); + const [attachedFiles, setAttachedFiles] = useState>([]); const { exit } = useApp(); // Handle initial prompt @@ -104,9 +105,22 @@ const TUIChat: React.FC = ({ } // Add user message to history and display + let messageContent = message; + + // Prepend attached files to the message + if (attachedFiles.length > 0) { + const fileContents = attachedFiles.map(file => + `\n\n\n${file.content}\n` + ).join(''); + messageContent = `${message}${fileContents}`; + + // Clear attached files after sending + setAttachedFiles([]); + } + const newUserMessage: ChatCompletionMessageParam = { role: "user", - content: message, + content: messageContent, }; const newHistory = [...chatHistory, newUserMessage]; setChatHistory(newHistory); @@ -257,6 +271,10 @@ const TUIChat: React.FC = ({ } }; + const handleFileAttached = (filePath: string, content: string) => { + setAttachedFiles(prev => [...prev, { path: filePath, content }]); + }; + const renderMessage = (message: DisplayMessage, index: number) => { const isUser = message.role === "user"; const isSystem = message.role === "system"; @@ -335,6 +353,7 @@ const TUIChat: React.FC = ({ )} + {/* Input area - always at bottom */} = ({ inputMode={inputMode} onInterrupt={handleInterrupt} assistant={assistant.config} + onFileAttached={handleFileAttached} /> ● Continue CLI diff --git a/src/ui/UserInput.tsx b/src/ui/UserInput.tsx index ab7a7d435..93a0287b1 100644 --- a/src/ui/UserInput.tsx +++ b/src/ui/UserInput.tsx @@ -2,6 +2,7 @@ import { type AssistantConfig } from "@continuedev/sdk"; import { Box, Text, useApp, useInput } from "ink"; import React, { useState } from "react"; import SlashCommandUI from "./SlashCommandUI.js"; +import FileSearchUI from "./FileSearchUI.js"; import { TextBuffer } from "./TextBuffer.js"; import { InputHistory } from "../util/inputHistory.js"; @@ -11,6 +12,7 @@ interface UserInputProps { inputMode: boolean; onInterrupt?: () => void; assistant: AssistantConfig; + onFileAttached?: (filePath: string, content: string) => void; } const UserInput: React.FC = ({ @@ -19,6 +21,7 @@ const UserInput: React.FC = ({ inputMode, onInterrupt, assistant, + onFileAttached, }) => { const [textBuffer] = useState(() => new TextBuffer()); const [inputHistory] = useState(() => new InputHistory()); @@ -27,6 +30,10 @@ const UserInput: React.FC = ({ const [showSlashCommands, setShowSlashCommands] = useState(false); const [slashCommandFilter, setSlashCommandFilter] = useState(""); const [selectedCommandIndex, setSelectedCommandIndex] = useState(0); + const [showFileSearch, setShowFileSearch] = useState(false); + const [fileSearchFilter, setFileSearchFilter] = useState(""); + const [selectedFileIndex, setSelectedFileIndex] = useState(0); + const [currentFiles, setCurrentFiles] = useState>([]); const { exit } = useApp(); // Get all available slash commands @@ -66,6 +73,7 @@ const UserInput: React.FC = ({ setShowSlashCommands(true); setSlashCommandFilter(afterSlash); setSelectedCommandIndex(0); + setShowFileSearch(false); } else { setShowSlashCommands(false); } @@ -74,6 +82,30 @@ const UserInput: React.FC = ({ } }; + // Update file search UI state based on input + const updateFileSearchState = (text: string, cursor: number) => { + // Check if we're in a file search context + const beforeCursor = text.slice(0, cursor); + const lastAtIndex = beforeCursor.lastIndexOf("@"); + + if (lastAtIndex !== -1) { + // Check if there's any whitespace between the last @ and cursor + const afterAt = beforeCursor.slice(lastAtIndex + 1); + + if (!afterAt.includes(" ") && !afterAt.includes("\n")) { + // We're in a file search context + setShowFileSearch(true); + setFileSearchFilter(afterAt); + setSelectedFileIndex(0); + setShowSlashCommands(false); + } else { + setShowFileSearch(false); + } + } else { + setShowFileSearch(false); + } + }; + // Get filtered commands for navigation - using the same sorting logic as SlashCommandUI const getFilteredCommands = () => { const allCommands = getSlashCommands(); @@ -113,6 +145,39 @@ const UserInput: React.FC = ({ } }; + // Handle file selection + const selectFile = async (filePath: string) => { + const beforeCursor = inputText.slice(0, cursorPosition); + const lastAtIndex = beforeCursor.lastIndexOf("@"); + + if (lastAtIndex !== -1) { + const beforeAt = inputText.slice(0, lastAtIndex); + const afterCursor = inputText.slice(cursorPosition); + + // Replace the partial file reference with the full file name + const fileName = filePath.split('/').pop() || filePath; + const newText = beforeAt + "@" + fileName + " " + afterCursor; + const newCursorPos = lastAtIndex + 1 + fileName.length + 1; + + textBuffer.setText(newText); + textBuffer.setCursor(newCursorPos); + setInputText(newText); + setCursorPosition(newCursorPos); + setShowFileSearch(false); + + // Read the file content and notify parent component + if (onFileAttached) { + try { + const fs = await import("fs/promises"); + const content = await fs.readFile(filePath, "utf-8"); + onFileAttached(filePath, content); + } catch (error) { + console.error(`Error reading file ${filePath}:`, error); + } + } + } + }; + useInput((input, key) => { if (key.ctrl && (input === "c" || input === "d")) { exit(); @@ -131,6 +196,12 @@ const UserInput: React.FC = ({ return; } + // Handle escape key to close file search UI + if (key.escape && showFileSearch && inputMode) { + setShowFileSearch(false); + return; + } + if (!inputMode) { return; } @@ -168,8 +239,35 @@ const UserInput: React.FC = ({ } } - // Handle input history navigation (only when not in slash command mode) - if (!showSlashCommands) { + // Handle file search navigation + if (showFileSearch) { + if (key.upArrow) { + setSelectedFileIndex((prev) => (prev > 0 ? prev - 1 : Math.max(0, Math.min(currentFiles.length - 1, 9)))); + return; + } + + if (key.downArrow) { + setSelectedFileIndex((prev) => (prev < Math.min(currentFiles.length - 1, 9) ? prev + 1 : 0)); + return; + } + + if (key.return && !key.shift) { + if (currentFiles.length > 0 && selectedFileIndex < currentFiles.length) { + selectFile(currentFiles[selectedFileIndex].path); + } + return; + } + + if (key.tab) { + if (currentFiles.length > 0 && selectedFileIndex < currentFiles.length) { + selectFile(currentFiles[selectedFileIndex].path); + } + return; + } + } + + // Handle input history navigation (only when not in slash command or file search mode) + if (!showSlashCommands && !showFileSearch) { if (key.upArrow) { const historyEntry = inputHistory.navigateUp(inputText); if (historyEntry !== null) { @@ -216,6 +314,7 @@ const UserInput: React.FC = ({ setInputText(newText); setCursorPosition(newCursor); updateSlashCommandState(newText, newCursor); + updateFileSearchState(newText, newCursor); } return; } @@ -230,6 +329,7 @@ const UserInput: React.FC = ({ setInputText(newText); setCursorPosition(newCursor); updateSlashCommandState(newText, newCursor); + updateFileSearchState(newText, newCursor); // Reset history navigation when user starts typing inputHistory.resetNavigation(); @@ -328,6 +428,16 @@ const UserInput: React.FC = ({ onSelect={selectSlashCommand} /> )} + + {/* File search UI */} + {showFileSearch && inputMode && ( + + )} ); }; diff --git a/test-file.txt b/test-file.txt new file mode 100644 index 000000000..7077ff350 --- /dev/null +++ b/test-file.txt @@ -0,0 +1 @@ +This is a test file to verify the @ file search functionality works correctly. \ No newline at end of file