Merge pull request #16 from continuedev/at-input
Add file search functionality with @ trigger in user input
This commit is contained in:
commit
96248251e2
6 changed files with 744 additions and 34 deletions
437
package-lock.json
generated
437
package-lock.json
generated
|
|
@ -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",
|
||||
|
|
@ -37,6 +38,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",
|
||||
|
|
@ -1261,6 +1263,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",
|
||||
|
|
@ -1574,6 +1672,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",
|
||||
|
|
@ -2746,6 +2879,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",
|
||||
|
|
@ -2852,6 +2996,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",
|
||||
|
|
@ -3102,7 +3253,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"
|
||||
|
|
@ -3973,7 +4123,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"
|
||||
|
|
@ -3986,7 +4135,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": {
|
||||
|
|
@ -4586,6 +4734,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",
|
||||
|
|
@ -4632,7 +4786,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": {
|
||||
|
|
@ -5343,6 +5496,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",
|
||||
|
|
@ -5626,22 +5807,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"
|
||||
|
|
@ -5660,18 +5842,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",
|
||||
|
|
@ -6420,7 +6590,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"
|
||||
|
|
@ -6675,6 +6844,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",
|
||||
|
|
@ -7002,6 +7186,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",
|
||||
|
|
@ -7529,6 +7748,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",
|
||||
|
|
@ -8312,6 +8566,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",
|
||||
|
|
@ -11432,6 +11695,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",
|
||||
|
|
@ -11554,6 +11823,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",
|
||||
|
|
@ -13089,7 +13383,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",
|
||||
|
|
@ -13104,7 +13412,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"
|
||||
|
|
@ -13276,6 +13596,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",
|
||||
|
|
|
|||
|
|
@ -41,6 +41,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",
|
||||
|
|
@ -56,6 +57,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",
|
||||
|
|
|
|||
202
src/ui/FileSearchUI.tsx
Normal file
202
src/ui/FileSearchUI.tsx
Normal file
|
|
@ -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<FileSearchUIProps> = ({
|
||||
filter,
|
||||
selectedIndex,
|
||||
onSelect,
|
||||
onFilesUpdated,
|
||||
}) => {
|
||||
const [files, setFiles] = useState<FileItem[]>([]);
|
||||
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 (
|
||||
<Box paddingX={1} marginX={1} marginBottom={1}>
|
||||
<Text color="gray">Searching files...</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (files.length === 0) {
|
||||
return (
|
||||
<Box paddingX={1} marginX={1} marginBottom={1}>
|
||||
<Text color="gray">No matching files found</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box paddingX={1} marginX={1} marginBottom={1} flexDirection="column">
|
||||
{files.map((file, index) => {
|
||||
const isSelected = index === selectedIndex;
|
||||
|
||||
return (
|
||||
<Box key={file.path}>
|
||||
<Text color="white" bold={isSelected}>
|
||||
{" "}
|
||||
<Text color="green">@{file.displayName}</Text>
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text color="gray" dimColor>
|
||||
Use ↑/↓ to navigate, Enter to select, Tab to complete
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default FileSearchUI;
|
||||
|
|
@ -78,6 +78,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
const [inputMode, setInputMode] = useState(true);
|
||||
const [abortController, setAbortController] =
|
||||
useState<AbortController | null>(null);
|
||||
const [attachedFiles, setAttachedFiles] = useState<Array<{path: string; content: string}>>([]);
|
||||
const { exit } = useApp();
|
||||
|
||||
// Handle initial prompt
|
||||
|
|
@ -134,9 +135,22 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
}
|
||||
|
||||
// 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<file path="${file.path}">\n${file.content}\n</file>`
|
||||
).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);
|
||||
|
|
@ -290,6 +304,10 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
}
|
||||
};
|
||||
|
||||
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";
|
||||
|
|
@ -368,6 +386,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
</Box>
|
||||
)}
|
||||
|
||||
|
||||
{/* Input area - always at bottom */}
|
||||
<UserInput
|
||||
onSubmit={handleUserMessage}
|
||||
|
|
@ -375,6 +394,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
inputMode={inputMode}
|
||||
onInterrupt={handleInterrupt}
|
||||
assistant={assistant.config}
|
||||
onFileAttached={handleFileAttached}
|
||||
/>
|
||||
<Box marginRight={2} justifyContent="flex-end">
|
||||
<Text color="gray">● Continue CLI</Text>
|
||||
|
|
|
|||
|
|
@ -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<UserInputProps> = ({
|
||||
|
|
@ -19,6 +21,7 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
inputMode,
|
||||
onInterrupt,
|
||||
assistant,
|
||||
onFileAttached,
|
||||
}) => {
|
||||
const [textBuffer] = useState(() => new TextBuffer());
|
||||
const [inputHistory] = useState(() => new InputHistory());
|
||||
|
|
@ -27,6 +30,10 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
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<Array<{path: string; displayName: string}>>([]);
|
||||
const { exit } = useApp();
|
||||
|
||||
// Get all available slash commands
|
||||
|
|
@ -66,6 +73,7 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
setShowSlashCommands(true);
|
||||
setSlashCommandFilter(afterSlash);
|
||||
setSelectedCommandIndex(0);
|
||||
setShowFileSearch(false);
|
||||
} else {
|
||||
setShowSlashCommands(false);
|
||||
}
|
||||
|
|
@ -74,6 +82,30 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
}
|
||||
};
|
||||
|
||||
// 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<UserInputProps> = ({
|
|||
}
|
||||
};
|
||||
|
||||
// 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<UserInputProps> = ({
|
|||
return;
|
||||
}
|
||||
|
||||
// Handle escape key to close file search UI
|
||||
if (key.escape && showFileSearch && inputMode) {
|
||||
setShowFileSearch(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow typing during streaming, but block submission
|
||||
if (!inputMode) {
|
||||
// Block only Enter key submission during streaming
|
||||
|
|
@ -173,8 +244,35 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
|
@ -222,6 +320,7 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
setInputText(newText);
|
||||
setCursorPosition(newCursor);
|
||||
updateSlashCommandState(newText, newCursor);
|
||||
updateFileSearchState(newText, newCursor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -236,6 +335,7 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
setInputText(newText);
|
||||
setCursorPosition(newCursor);
|
||||
updateSlashCommandState(newText, newCursor);
|
||||
updateFileSearchState(newText, newCursor);
|
||||
|
||||
// Reset history navigation when user starts typing
|
||||
inputHistory.resetNavigation();
|
||||
|
|
@ -334,6 +434,16 @@ const UserInput: React.FC<UserInputProps> = ({
|
|||
onSelect={selectSlashCommand}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* File search UI */}
|
||||
{showFileSearch && inputMode && (
|
||||
<FileSearchUI
|
||||
filter={fileSearchFilter}
|
||||
selectedIndex={selectedFileIndex}
|
||||
onSelect={selectFile}
|
||||
onFilesUpdated={setCurrentFiles}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
1
test-file.txt
Normal file
1
test-file.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
This is a test file to verify the @ file search functionality works correctly.
|
||||
Loading…
Add table
Reference in a new issue