Compare commits

..

1 commit

Author SHA1 Message Date
igardev
a65ad28171 - Show error in agent view UI in case of error on editing file
- Other bug fixes
2025-10-27 02:38:06 +02:00
33 changed files with 411 additions and 3188 deletions

View file

@ -1,51 +1,3 @@
# Exclude development sources and tests
src/**
ui/src/**
ui/node_modules/**
ui/package.json
ui/package-lock.json
src/test/**
dist/test/**
**/*.test.*
**/*.spec.*
# Exclude maps and TypeScript sources from package
**/*.map
**/*.ts
**/*.tsx
# Exclude build configs and project metadata not needed at runtime
.eslintrc*
.eslint*
.prettier*
*.code-workspace
.vscode/**
.vscode-test/**
.git/**
.gitignore
.gitmodules
.npmrc
.github/**
.nyc_output/**
coverage/**
# Exclude local artifacts
*.vsix
*.log
npm-debug.log*
yarn-error.log*
# Keep only runtime bundles and assets
!dist/**
!ui/dist/**
!resources/**
!llama.png
!package.json
!README.md
!LICENSE
# Exclude production dependencies (we bundle the extension code)
node_modules/**
# Exclude VCS and workspace config
.git/**
.github/**

View file

@ -68,12 +68,6 @@ Either use the [latest binaries](https://github.com/ggerganov/llama.cpp/releases
Here are recommended settings, depending on the amount of VRAM that you have:
- More than 64GB VRAM:
```bash
llama-server --fim-qwen-30b-default
```
- More than 16GB VRAM:
```bash

542
package-lock.json generated
View file

@ -1,18 +1,17 @@
{
"name": "llama-vscode",
"version": "0.0.45",
"version": "0.0.34",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "llama-vscode",
"version": "0.0.45",
"version": "0.0.34",
"hasInstallScript": true,
"dependencies": {
"axios": "^1.1.2",
"globby": "^14.1.0",
"ignore": "^7.0.4",
"js-yaml": "^4.1.1",
"openai": "^4.80.1",
"picomatch": "^4.0.2",
"remark-gfm": "^4.0.1",
@ -24,10 +23,9 @@
"@types/mocha": "^10.0.10",
"@types/node": "^18.0.0",
"@types/picomatch": "^4.0.0",
"@types/vscode": "^1.109.0",
"@types/vscode": "^1.100.0",
"@vscode/test-cli": "^0.0.11",
"@vscode/test-electron": "^2.5.2",
"esbuild": "^0.27.0",
"glob": "^11.0.3",
"mocha": "^11.7.4",
"typescript": "^4.8.0",
@ -89,448 +87,6 @@
"node": ">=10.0.0"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.0.tgz",
"integrity": "sha512-KuZrd2hRjz01y5JK9mEBSD3Vj3mbCvemhT466rSuJYeE/hjuBrHfjjcjMdTm/sz7au+++sdbJZJmuBwQLuw68A==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.0.tgz",
"integrity": "sha512-j67aezrPNYWJEOHUNLPj9maeJte7uSMM6gMoxfPC9hOg8N02JuQi/T7ewumf4tNvJadFkvLZMlAq73b9uwdMyQ==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.0.tgz",
"integrity": "sha512-CC3vt4+1xZrs97/PKDkl0yN7w8edvU2vZvAFGD16n9F0Cvniy5qvzRXjfO1l94efczkkQE6g1x0i73Qf5uthOQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.0.tgz",
"integrity": "sha512-wurMkF1nmQajBO1+0CJmcN17U4BP6GqNSROP8t0X/Jiw2ltYGLHpEksp9MpoBqkrFR3kv2/te6Sha26k3+yZ9Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.0.tgz",
"integrity": "sha512-uJOQKYCcHhg07DL7i8MzjvS2LaP7W7Pn/7uA0B5S1EnqAirJtbyw4yC5jQ5qcFjHK9l6o/MX9QisBg12kNkdHg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.0.tgz",
"integrity": "sha512-8mG6arH3yB/4ZXiEnXof5MK72dE6zM9cDvUcPtxhUZsDjESl9JipZYW60C3JGreKCEP+p8P/72r69m4AZGJd5g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.0.tgz",
"integrity": "sha512-9FHtyO988CwNMMOE3YIeci+UV+x5Zy8fI2qHNpsEtSF83YPBmE8UWmfYAQg6Ux7Gsmd4FejZqnEUZCMGaNQHQw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.0.tgz",
"integrity": "sha512-zCMeMXI4HS/tXvJz8vWGexpZj2YVtRAihHLk1imZj4efx1BQzN76YFeKqlDr3bUWI26wHwLWPd3rwh6pe4EV7g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.0.tgz",
"integrity": "sha512-t76XLQDpxgmq2cNXKTVEB7O7YMb42atj2Re2Haf45HkaUpjM2J0UuJZDuaGbPbamzZ7bawyGFUkodL+zcE+jvQ==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.0.tgz",
"integrity": "sha512-AS18v0V+vZiLJyi/4LphvBE+OIX682Pu7ZYNsdUHyUKSoRwdnOsMf6FDekwoAFKej14WAkOef3zAORJgAtXnlQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.0.tgz",
"integrity": "sha512-Mz1jxqm/kfgKkc/KLHC5qIujMvnnarD9ra1cEcrs7qshTUSksPihGrWHVG5+osAIQ68577Zpww7SGapmzSt4Nw==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.0.tgz",
"integrity": "sha512-QbEREjdJeIreIAbdG2hLU1yXm1uu+LTdzoq1KCo4G4pFOLlvIspBm36QrQOar9LFduavoWX2msNFAAAY9j4BDg==",
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.0.tgz",
"integrity": "sha512-sJz3zRNe4tO2wxvDpH/HYJilb6+2YJxo/ZNbVdtFiKDufzWq4JmKAiHy9iGoLjAV7r/W32VgaHGkk35cUXlNOg==",
"cpu": [
"mips64el"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.0.tgz",
"integrity": "sha512-z9N10FBD0DCS2dmSABDBb5TLAyF1/ydVb+N4pi88T45efQ/w4ohr/F/QYCkxDPnkhkp6AIpIcQKQ8F0ANoA2JA==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.0.tgz",
"integrity": "sha512-pQdyAIZ0BWIC5GyvVFn5awDiO14TkT/19FTmFcPdDec94KJ1uZcmFs21Fo8auMXzD4Tt+diXu1LW1gHus9fhFQ==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.0.tgz",
"integrity": "sha512-hPlRWR4eIDDEci953RI1BLZitgi5uqcsjKMxwYfmi4LcwyWo2IcRP+lThVnKjNtk90pLS8nKdroXYOqW+QQH+w==",
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.0.tgz",
"integrity": "sha512-1hBWx4OUJE2cab++aVZ7pObD6s+DK4mPGpemtnAORBvb5l/g5xFGk0vc0PjSkrDs0XaXj9yyob3d14XqvnQ4gw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.0.tgz",
"integrity": "sha512-6m0sfQfxfQfy1qRuecMkJlf1cIzTOgyaeXaiVaaki8/v+WB+U4hc6ik15ZW6TAllRlg/WuQXxWj1jx6C+dfy3w==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.0.tgz",
"integrity": "sha512-xbbOdfn06FtcJ9d0ShxxvSn2iUsGd/lgPIO2V3VZIPDbEaIj1/3nBBe1AwuEZKXVXkMmpr6LUAgMkLD/4D2PPA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.0.tgz",
"integrity": "sha512-fWgqR8uNbCQ/GGv0yhzttj6sU/9Z5/Sv/VGU3F5OuXK6J6SlriONKrQ7tNlwBrJZXRYk5jUhuWvF7GYzGguBZQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.0.tgz",
"integrity": "sha512-aCwlRdSNMNxkGGqQajMUza6uXzR/U0dIl1QmLjPtRbLOx3Gy3otfFu/VjATy4yQzo9yFDGTxYDo1FfAD9oRD2A==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openharmony-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.0.tgz",
"integrity": "sha512-nyvsBccxNAsNYz2jVFYwEGuRRomqZ149A39SHWk4hV0jWxKM0hjBPm3AmdxcbHiFLbBSwG6SbpIcUbXjgyECfA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openharmony"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.0.tgz",
"integrity": "sha512-Q1KY1iJafM+UX6CFEL+F4HRTgygmEW568YMqDA5UV97AuZSm21b7SXIrRJDwXWPzr8MGr75fUZPV67FdtMHlHA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.0.tgz",
"integrity": "sha512-W1eyGNi6d+8kOmZIwi/EDjrL9nxQIQ0MiGqe/AWc6+IaHloxHSGoeRgDRKHFISThLmsewZ5nHFvGFWdBYlgKPg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.0.tgz",
"integrity": "sha512-30z1aKL9h22kQhilnYkORFYt+3wp7yZsHWus+wSKAJR8JtdfI76LJ4SBdMsCopTR3z/ORqVu5L1vtnHZWVj4cQ==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.0.tgz",
"integrity": "sha512-aIitBcjQeyOhMTImhLZmtxfdOcuNRpwlPNmlFKPcHQYPhEssw75Cl1TSXJXpMkzaua9FUetx/4OQKq7eJul5Cg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@isaacs/balanced-match": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",
@ -829,9 +385,9 @@
"license": "MIT"
},
"node_modules/@types/vscode": {
"version": "1.109.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.109.0.tgz",
"integrity": "sha512-0Pf95rnwEIwDbmXGC08r0B4TQhAbsHQ5UyTIgVgoieDe4cOnf92usuR5dEczb6bTKEp7ziZH4TV1TRGPPCExtw==",
"version": "1.103.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.103.0.tgz",
"integrity": "sha512-o4hanZAQdNfsKecexq9L3eHICd0AAvdbLk6hA60UzGXbGH/q8b/9xv2RgR7vV3ZcHuyKVq7b37IGd/+gM4Tu+Q==",
"dev": true,
"license": "MIT"
},
@ -860,9 +416,9 @@
}
},
"node_modules/@vscode/test-cli/node_modules/glob": {
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz",
"integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==",
"version": "10.4.5",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
"integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==",
"dev": true,
"license": "ISC",
"dependencies": {
@ -1332,6 +888,7 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true,
"license": "Python-2.0"
},
"node_modules/asynckit": {
@ -1997,48 +1554,6 @@
"node": ">= 0.4"
}
},
"node_modules/esbuild": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.0.tgz",
"integrity": "sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.27.0",
"@esbuild/android-arm": "0.27.0",
"@esbuild/android-arm64": "0.27.0",
"@esbuild/android-x64": "0.27.0",
"@esbuild/darwin-arm64": "0.27.0",
"@esbuild/darwin-x64": "0.27.0",
"@esbuild/freebsd-arm64": "0.27.0",
"@esbuild/freebsd-x64": "0.27.0",
"@esbuild/linux-arm": "0.27.0",
"@esbuild/linux-arm64": "0.27.0",
"@esbuild/linux-ia32": "0.27.0",
"@esbuild/linux-loong64": "0.27.0",
"@esbuild/linux-mips64el": "0.27.0",
"@esbuild/linux-ppc64": "0.27.0",
"@esbuild/linux-riscv64": "0.27.0",
"@esbuild/linux-s390x": "0.27.0",
"@esbuild/linux-x64": "0.27.0",
"@esbuild/netbsd-arm64": "0.27.0",
"@esbuild/netbsd-x64": "0.27.0",
"@esbuild/openbsd-arm64": "0.27.0",
"@esbuild/openbsd-x64": "0.27.0",
"@esbuild/openharmony-arm64": "0.27.0",
"@esbuild/sunos-x64": "0.27.0",
"@esbuild/win32-arm64": "0.27.0",
"@esbuild/win32-ia32": "0.27.0",
"@esbuild/win32-x64": "0.27.0"
}
},
"node_modules/escalade": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
@ -2359,15 +1874,15 @@
}
},
"node_modules/glob": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-11.1.0.tgz",
"integrity": "sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==",
"version": "11.0.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz",
"integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==",
"dev": true,
"license": "BlueOak-1.0.0",
"license": "ISC",
"dependencies": {
"foreground-child": "^3.3.1",
"jackspeak": "^4.1.1",
"minimatch": "^10.1.1",
"minimatch": "^10.0.3",
"minipass": "^7.1.2",
"package-json-from-dist": "^1.0.0",
"path-scurry": "^2.0.0"
@ -2402,11 +1917,11 @@
"license": "BSD-2-Clause"
},
"node_modules/glob/node_modules/minimatch": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz",
"integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==",
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz",
"integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==",
"dev": true,
"license": "BlueOak-1.0.0",
"license": "ISC",
"dependencies": {
"@isaacs/brace-expansion": "^5.0.0"
},
@ -2877,9 +2392,10 @@
}
},
"node_modules/js-yaml": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@ -3899,9 +3415,9 @@
}
},
"node_modules/mocha": {
"version": "11.7.5",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-11.7.5.tgz",
"integrity": "sha512-mTT6RgopEYABzXWFx+GcJ+ZQ32kp4fMf0xvpZIIfSq9Z8lC/++MtcCnQ9t5FP2veYEP95FIYSvW+U9fV4xrlig==",
"version": "11.7.4",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-11.7.4.tgz",
"integrity": "sha512-1jYAaY8x0kAZ0XszLWu14pzsf4KV740Gld4HXkhNTXwcHx4AUEDkPzgEHg9CM5dVcW+zv036tjpsEbLraPJj4w==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -3965,9 +3481,9 @@
}
},
"node_modules/mocha/node_modules/glob": {
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz",
"integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==",
"version": "10.4.5",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
"integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==",
"dev": true,
"license": "ISC",
"dependencies": {

View file

@ -2,11 +2,11 @@
"name": "llama-vscode",
"displayName": "llama-vscode",
"description": "Local LLM-assisted text completion using llama.cpp",
"version": "0.0.47",
"version": "0.0.34",
"publisher": "ggml-org",
"repository": "https://github.com/ggml-org/llama.vscode",
"engines": {
"vscode": "^1.109.0"
"vscode": "^1.100.0"
},
"icon": "llama.png",
"activationEvents": [
@ -17,13 +17,6 @@
],
"main": "./dist/extension.js",
"contributes": {
"languageModelChatProviders": [
{
"vendor": "llama-vscode",
"displayName": "llama.vscode",
"managementCommand": "extension.showMenu"
}
],
"viewsContainers": {
"activitybar": [
{
@ -81,6 +74,10 @@
"command": "extension.askAi",
"title": "llama-vscode: Ask AI"
},
{
"command": "extension.askAiWithContext",
"title": "llama-vscode: Ask AI With Context"
},
{
"command": "extension.editSelectedText",
"title": "llama-vscode: Edit Selected Text with AI"
@ -154,16 +151,6 @@
"key": "ctrl+x",
"when": "editorTextFocus"
},
{
"command": "extension.selectNextSuggestion",
"key": "alt+]",
"when": "editorTextFocus && inlineSuggestionVisible"
},
{
"command": "extension.selectPreviousSuggestion",
"key": "alt+[",
"when": "editorTextFocus && inlineSuggestionVisible"
},
{
"command": "extension.acceptFirstLine",
"key": "shift+tab",
@ -189,6 +176,11 @@
"key": "ctrl+;",
"when": "editorTextFocus"
},
{
"command": "extension.askAiWithContext",
"key": "ctrl+Shift+;",
"when": "editorTextFocus"
},
{
"command": "extension.askAiWithTools",
"key": "ctrl+Shift+t",
@ -279,11 +271,6 @@
"default": "",
"description": "The URL to be used by the extension for creating embeddings."
},
"llama-vscode.max_parallel_completions": {
"type": "number",
"default": 3,
"description": "The max number of parallel completions. Switching between completions could be done with Alt+] (next) or Alt =+[ (previous). "
},
"llama-vscode.new_completion_model_port": {
"type": "number",
"default": 8012,
@ -345,11 +332,7 @@
},
"description": {
"type": "string",
"description": "Description of the agent - for what purposes should be used, what are his strengths, etc."
},
"subagentEnabled": {
"type": "string",
"description": "If the agent could be used as subagent of another agent to execute a specific task."
"description": "Description of the model - for what purposes should be used, what are his strengths, etc."
},
"systemInstruction": {
"type": "array",
@ -359,38 +342,6 @@
"description": "The system instructions for this agent",
"default": ""
},
"toolsModel": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name for this model to be shown to the user"
},
"endpoint": {
"type": "string",
"description": "The endpoint, from where to access the model",
"default": ""
},
"aiModel": {
"type": "string",
"description": "The name of the AI model as expected by the provider",
"default": ""
},
"isKeyRequired": {
"type": "boolean",
"description": "Is key requried for the endpoint",
"default": false
},
"localStartCommand": {
"type": "string",
"description": "Command to be used for sterting the model locally.",
"default": ""
}
},
"required": [
"name"
]
},
"tools": {
"type": "array",
"items": {
@ -491,211 +442,7 @@
"delete_file",
"get_diff",
"edit_file",
"ask_user",
"update_todo_list",
"delegate_task"
]
},
{
"name": "Unite test writer",
"description": "Writes the unit tests. The input should provide a path to a source file to be tested.",
"systemInstruction": [
"You are an expert software engineer specializing in writing unit tests. Your task is to generate highquality, reliable, and maintainable unit tests based on the users instructions and the provided source code. You must infer the programming language, testing framework, and project conventions from the source file and any accompanying context (such as imports, file extensions, or existing test files).",
"Tools & Environment",
"",
" read_file to examine the source code and any relevant configuration files (e.g., package.json, pom.xml, requirements.txt, Cargo.toml, etc.).",
"",
" edit_file to create or modify test files.",
"",
" run_terminal_command to execute tests and report results.",
"",
"Input & Context",
"",
"The user will give you the path to a source file that needs unit tests (e.g., src/services/user_service.py, lib/user.dart, internal/user.go). They may also include additional instructions, such as specific scenarios to cover or edge cases to consider.",
"Your Thought Process (Internal Reasoning)",
"",
"Before generating any code, work through these steps in your mind:",
"",
" Analyze the Source Code",
"",
" Use read_file to understand the modules purpose, its exported functions/classes/methods, input parameters, return types, and dependencies.",
"",
" Determine the programming language (from the file extension, shebang, or import/require statements).",
"",
" Identify all public APIs that need testing.",
"",
" Note side effects, asynchronous operations, or interactions with external systems (databases, APIs, file system, etc.).",
"",
" Infer the Testing Conventions",
"",
" Look for an existing test directory (e.g., test/, tests/, spec/, __tests__/) and the naming pattern of existing test files (e.g., *.test.js, *_test.py, *_spec.rb).",
"",
" Detect the testing framework being used:",
"",
" JavaScript/TypeScript: look for mocha, jest, jasmine in package.json.",
"",
" Python: look for pytest, unittest in imports or config files.",
"",
" Java: look for JUnit in pom.xml or build.gradle.",
"",
" Go: look for testing package imports, etc.",
"",
" Determine the preferred assertion style (e.g., assert module, expect, should, assertThat).",
"",
" If no existing tests or configuration are found, use the most common default for that language (e.g., pytest for Python, JUnit 5 for Java, go test for Go, Mocha + assert for Node.js).",
"",
" Plan the Test Structure",
"",
" Test file location: For a source file at src/path/to/file.ext, the test file should normally be placed at test/path/to/file_test.ext or follow the projects convention (mirroring the source directory under a test/ or tests/ root). Ensure the directory structure is created if needed.",
"",
" Plan the outer test suite (e.g., describe('moduleName', ...) in Mocha, a test class in JUnit, or a modulelevel docstring in pytest).",
"",
" Plan nested suites for each function or method.",
"",
" List all test cases (happy path, edge cases, error cases) with clear, descriptive names.",
"",
" Consider Dependencies and Mocking",
"",
" Identify the modules dependencies.",
"",
" Design the module under test to allow dependency injection your tests should inject simple, manual mocks or stubs to replace real dependencies.",
"",
" Do not introduce thirdparty mocking libraries unless they are already present in the project. Rely on manual mocks (e.g., creating test doubles yourself).",
"",
" Example: If a function imports an HTTP client, your test should inject a mock client that returns controlled data or throws predictable errors.",
"",
"Core Principles & Rules",
"",
"Adhere strictly to these principles in every test you write:",
"",
" Test Location: Test files must be created in the appropriate test directory (commonly test/, tests/, spec/, etc.) mirroring the source structure. Use the naming convention inferred from the project.",
"",
" Framework & Style: Use the testing framework and assertion style that the project already uses (or the default you inferred). Write idiomatic tests for that language.",
"",
" Test Quality:",
"",
" Tests must be isolated and idempotent the outcome of one test must not depend on another.",
"",
" Each test should verify one specific behavior.",
"",
" Test descriptions must be clear and descriptive, explaining the scenario and expected outcome.",
"",
" Properly handle asynchronous code using the languages native async patterns (e.g., async/await, Future, Promise). Ensure the test framework waits for completion.",
"",
" Reset any module state or mocks in setup/teardown hooks (e.g., beforeEach, setUp, @BeforeEach) to guarantee tests can run in any order.",
"",
" Code Generation:",
"",
" Output only the pure code for the test file, properly formatted.",
"",
" Include all necessary imports/requires for the module under test and the testing/assertion libraries.",
"",
" Import the actual functions/classes from the source file. Mocking is done inside the test, not by mocking the import itself.",
"",
" No Source Modification: You cannot modify the source code. If the source is untestable due to poor design (e.g., hardcoded dependencies), inform the user of the challenges and suggest refactoring the source to allow proper unit testing.",
"",
"Output Format",
"",
"Your final response must contain:",
"",
" A brief, nontechnical confirmation stating the language you inferred and the test file path you will create.",
"",
"Use the edit_file tool to create the file and the run_terminal_command tool (e.g., npx mocha 'test/services/userService.spec.ts') to verify your work, reporting the results back to the user.",
"",
"Crucially, you cannot modify the source code itself. If the source code is not testable due to poor design (e.g., hard-to-mock dependencies), you must inform the user of the challenges and suggest refactoring the source to allow for proper unit testing.",
""
],
"tools": [
"run_terminal_command",
"search_source",
"read_file",
"list_directory",
"regex_search",
"delete_file",
"edit_file",
"update_todo_list"
],
"subagentEnabled": true
},
{
"name": "Agent creator",
"description": "Creates new agent. Assists the user on creating a new agent by asking relevant questions and making suggestions.",
"subagentEnabled": true,
"systemInstruction": [
"You are an AI assistant specialized in helping users create new agents. Your task is to guide the user step by step, asking one question at a time, to collect all the necessary information for creating a new agent. Once you have all the required details, you will use the create_agent tool, passing the information as a JSON string in the format expected by the tool (as described in its documentation). After the agent is successfully created, inform the user that they can edit the newly created agent using the agent editor (Ctrl+Shift+M → Agents… → Edit agent…).",
"",
"Required Information:",
"",
" name (string): The name of the new agent.",
"",
" description (string): A brief description of what the agent does.",
"",
" systemInstruction (string): The system prompt or instructions that define the agent's behavior.",
"",
"Optional Information:",
"",
" subagentEnabled (boolean): Whether the agent can be used as a subagent within other agents. Ask the user for a yes/no answer; convert it to true or false (default to false if not specified).",
"",
" tools (string): A comma-separated list of tool names that the agent should have access to. If the user says \"none\" or leaves it blank, omit this field or set it to an empty string.",
"",
"Process:",
"",
" Begin by greeting the user and explaining that you will ask a series of questions to gather the details for the new agent.",
"",
" Ask for the name first. Wait for the user's response.",
"",
" After receiving the name, ask for the description.",
"",
" Then ask for the systemInstruction.",
"",
" Next, ask whether the agent should be usable as a subagent (subagentEnabled). Prompt for a yes/no answer. If the answer is ambiguous, ask for clarification.",
"",
" Finally, ask for any tools the agent should have. Prompt for a comma-separated list or indicate that they can say \"none\".",
"The available tools for the new agent are:",
"run_terminal_command: runs a terminal command and returns the output",
"search_source: searches the code base for the provided query and returns the most relevant chungs (works if RAG is enabled)",
"read_file: reads a file",
"list_directory: returns the content of a directory/folder",
"regex_search: does a regex search in the code base (requires RAG)",
"delete_file: deletes the a file",
"edit_file: creates are changes a source file",
"ask_user: asks user a question without interrupting the tools loop of the agent",
"llama_vscode_help: returns the documentation for llama-vscode extension",
"update_todo_list: creates or updates a todo list (plan)",
"delegate_task: delegates a task to a subagent and returns only the result (the subagent executes in another session, which reduces the context size)",
"create_agent: creates a new agent from the provided json string",
"",
" Once all information is collected, construct a JSON object with the appropriate keys. Ensure that boolean values are represented as true or false (without quotes) and that the tools string is included only if provided.",
"",
" Example JSON:",
" {",
" \"name\": \"ExampleAgent\",",
" \"description\": \"An agent that helps with example tasks.\",",
" \"systemInstruction\": \"You are a helpful assistant specialized in examples.\",",
" \"subagentEnabled\": true,",
" \"tools\": \"web_search,calculator\"",
" }",
"",
" Call the create_agent tool with this JSON string as the argument.",
"",
" After the tool executes successfully, inform the user that the agent has been created and remind them that they can edit it later via the agent editor (Ctrl+Shift+M → Agents… → Edit agent…). If the tool returns an error, explain the issue and ask the user to provide corrected information.",
"",
"Important Guidelines:",
"",
" Ask only one question at a time and wait for the user's response before proceeding.",
"",
" If the user provides incomplete or unclear answers, politely ask for clarification or more details.",
"",
" Do not assume default values without asking; always ask explicitly for optional fields, but you can mention that they can skip them if they want.",
"",
" Keep your tone friendly and helpful. Make the process feel like a guided conversation.",
"",
" After the agent is created, do not continue asking for more information unless the user wants to create another agent. If they do, you may restart the process.",
"",
""
],
"tools": [
"create_agent"
"ask_user"
]
}
],
@ -1754,11 +1501,6 @@
"default": true,
"description": "If code completion should be triggered automatically (true) or only by pressing Ctrl+l."
},
"llama-vscode.debounce_ms": {
"type": "number",
"default": 0,
"description": "Milliseconds to wait after the last keystroke before sending a completion request (0 = disabled). Useful on low-end hardware to avoid triggering inference on every keystroke."
},
"llama-vscode.api_key": {
"type": "string",
"default": "",
@ -1784,31 +1526,6 @@
"default": "",
"description": "self-signed certificate file - path/to/cert.pem"
},
"llama-vscode.health_check_interval_s": {
"type": "number",
"default": 30,
"description": "Models health check interval in seconds"
},
"llama-vscode.health_check_compl_enabled": {
"type": "boolean",
"default": false,
"description": "Works only for llama.cpp servers - enables health check for completion model"
},
"llama-vscode.health_check_chat_enabled": {
"type": "boolean",
"default": false,
"description": "Works only for llama.cpp servers - enables health check for chat model"
},
"llama-vscode.health_check_embs_enabled": {
"type": "boolean",
"default": false,
"description": "Works only for llama.cpp servers - enables health check for embeddings model"
},
"llama-vscode.health_check_tools_enabled": {
"type": "boolean",
"default": false,
"description": "Works only for llama.cpp servers - enables health check for tools model"
},
"llama-vscode.n_prefix": {
"default": 256,
"type": "number",
@ -1924,11 +1641,6 @@
"default": true,
"description": "Enable/disable tool run_terminal_command"
},
"llama-vscode.tool_create_agent_enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable tool create_agent"
},
"llama-vscode.tools_custom": {
"type": "array",
"description": "Array of tool definitions for REST requests to LLM",
@ -2103,15 +1815,15 @@
"default": false,
"description": "Enable/disable tool llama-vscode_help"
},
"llama-vscode.tool_update_todo_list_enabled": {
"llama-vscode.tool_save_plan_enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable tool update_todo_list"
"default": false,
"description": "Enable/disable tool llama-vscode_help"
},
"llama-vscode.tool_delegate_task_enabled": {
"llama-vscode.tool_update_task_enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable tool delegate_task"
"default": false,
"description": "Enable/disable tool llama-vscode_help"
},
"llama-vscode.tool_custom_tool_description": {
"type": "string",
@ -2148,11 +1860,6 @@
"default": 20,
"description": "Max number of iterations with AI when working with tools. If you are working with paid AI providers, big number here could result in higher costs."
},
"llama-vscode.plan_review_frequency": {
"type": "number",
"default": 5,
"description": "How often (interations count) the plan/todos should be sent to the LLM again during a session."
},
"llama-vscode.chats_max_history": {
"type": "number",
"default": 50,
@ -2178,11 +1885,6 @@
"default": false,
"description": "Show the details about the tools calls in UI - arguments and results."
},
"llama-vscode.skills_folder": {
"type": "string",
"default": "",
"description": "The folder, where are the skills are stored. If empty , <project_folder>/skills will be used."
},
"llama-vscode.language": {
"type": "string",
"default": "en",
@ -2249,8 +1951,6 @@
"postinstall": "npm run build-ui",
"test": "node ./dist/test/runTest.js",
"compile": "tsc -p ./",
"bundle": "esbuild src/extension.ts --bundle --platform=node --format=cjs --external:vscode --outfile=dist/extension.js --minify",
"vscode:prepublish": "npm run bundle",
"lint": "eslint --ext .ts,.tsx .",
"format": "prettier --write --ignore-path .gitignore '**/*'"
},
@ -2258,22 +1958,20 @@
"axios": "^1.1.2",
"globby": "^14.1.0",
"ignore": "^7.0.4",
"js-yaml": "^4.1.1",
"openai": "^4.80.1",
"picomatch": "^4.0.2",
"remark-gfm": "^4.0.1",
"simple-git": "^3.28.0"
},
"devDependencies": {
"@vscode/test-cli": "^0.0.11",
"@babel/types": "^7.28.4",
"@types/micromatch": "^4.0.9",
"@types/mocha": "^10.0.10",
"@types/node": "^18.0.0",
"@types/picomatch": "^4.0.0",
"@types/vscode": "^1.109.0",
"@vscode/test-cli": "^0.0.11",
"@types/vscode": "^1.100.0",
"@vscode/test-electron": "^2.5.2",
"esbuild": "^0.27.0",
"glob": "^11.0.3",
"mocha": "^11.7.4",
"typescript": "^4.8.0",

View file

@ -13,7 +13,9 @@ Example:
1. Select several lines of source code
2. Press Ctrl+Shift+A (or right click and select "llama-vscode: Show Llama Agent") - this will attach the selected lines to the prompt
3. Inside the agent prompt press "/" and select "explain"
The agent will explain the selected code.## Chat with AI about llama-vscode
The agent will explain the selected code.
## Chat with AI about llama-vscode
### Requred servers
- Tools server
@ -23,6 +25,12 @@ This is a conversation with the llama-vscode help agent AI about llama-vscode, s
- From llama-vscode menu select "Chat with AI about llama-vscode" -> the agent will be opened
- Enter your question about llama-vscode
The first time it could take longer to answer. The following questions will be answered faster as the help information will be cached.
## Chat with AI with project context
This is removed. Chat with AI with project context is equal to using agent with the tool search_source. The agent has many other tools and is therefore a better choice.
## Chat with AI
### Requred servers
@ -33,7 +41,9 @@ This is a conversation with the local AI. Mainly for asking questions for refere
- Press Ctrl+; inside an editor (or select from llama.vscode menu Chat with AI) - A chat window will open inside VS Code
- Enter your message and start the chat
![Chat with AI](https://github.com/user-attachments/assets/e068f5cc-fce3-4366-9b8f-1c89e952b411)## Code completion
![Chat with AI](https://github.com/user-attachments/assets/e068f5cc-fce3-4366-9b8f-1c89e952b411)
## Code completion
### Requred servers
- Completion server
@ -51,20 +61,8 @@ https://github.com/user-attachments/assets/97bb1418-dcea-4a49-8332-13b2ab4da661
![Code completion](https://private-user-images.githubusercontent.com/1991296/405712196-b19499d9-f50d-49d4-9dff-ff3e8ba23757.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDY5NDc1NDEsIm5iZiI6MTc0Njk0NzI0MSwicGF0aCI6Ii8xOTkxMjk2LzQwNTcxMjE5Ni1iMTk0OTlkOS1mNTBkLTQ5ZDQtOWRmZi1mZjNlOGJhMjM3NTcuZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDUxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA1MTFUMDcwNzIxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmZiMmI0NGYzNTkyZGZkMTM5Njk3M2NjZDFhMjFiNTFkMjVkMmY4MGQ5ZDQ2ZDQ0MDgzOWI2YjM5NTY0NzM2OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.P150YJh87_y1pin20aWIuKoPzivmDjZF0iAemQlk_ok)## Copilot Chat Model Provider
### Overview
Llama-vscode could be used as a VS Code copilot chat model provider. With other words llama-vscode could provide models for the copilot. The provided models could be from local models or openrouter.com or other appliation, which servers the tools models for llama-vscode. This way you could automatically download and start locally models by llama.cpp and llama-vscode and use them with Copilot for free.
### How to use it
1. Select/Start tools model from llama-vscode (local or external)
<img width="485" height="875" alt="copilotSelectToolsModel" src="https://github.com/user-attachments/assets/caa33531-22f4-46dd-b429-7498c45c93e9" />
2. In VS Code Copilot show the models list -> Other Models -> Manage Models
<img width="1404" height="754" alt="CopilotManageModels" src="https://github.com/user-attachments/assets/dc861aa1-db86-46ff-83c1-98c7a435ad06" />
3. Make the models (all models available by the application serving the tools model are shown) you want to use visible (click on the left of the model name)
4. Select the desired model from Copilot and start using it
![Code completion](https://private-user-images.githubusercontent.com/1991296/405712196-b19499d9-f50d-49d4-9dff-ff3e8ba23757.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDY5NDc1NDEsIm5iZiI6MTc0Njk0NzI0MSwicGF0aCI6Ii8xOTkxMjk2LzQwNTcxMjE5Ni1iMTk0OTlkOS1mNTBkLTQ5ZDQtOWRmZi1mZjNlOGJhMjM3NTcuZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDUxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA1MTFUMDcwNzIxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmZiMmI0NGYzNTkyZGZkMTM5Njk3M2NjZDFhMjFiNTFkMjVkMmY4MGQ5ZDQ2ZDQ0MDgzOWI2YjM5NTY0NzM2OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.P150YJh87_y1pin20aWIuKoPzivmDjZF0iAemQlk_ok)
## Custom eval tool
### Overview
@ -87,6 +85,8 @@ https://github.com/user-attachments/assets/fb12d56f-61e8-409b-b888-0a524167e116
https://github.com/user-attachments/assets/7e928fc3-da14-4834-a414-0f8e23593155
## Custom tool
### Overview
@ -105,6 +105,8 @@ https://github.com/user-attachments/assets/46602f8c-bd45-4794-9f5c-6ebe262c396a
https://github.com/user-attachments/assets/50baa8c3-f426-4901-a443-8882da644800
## Delete models
### Overview
@ -120,20 +122,14 @@ You could delete the GGUF files from this folder. If they are missing, but are n
## Edit Agent
### Overview
Edit agent view is used for adding and editing agents. From there it is also possible to delete and copy an existing agent as a new one. The identifier of an agent is it's name. For now there is no tools model as part of the agent (the currently selected tools model will be used)
<img width="582" height="977" alt="image" src="https://github.com/user-attachments/assets/9a406e7a-09ea-4f04-9054-f709bcdb038a" />
### How to use it
Edit agent view could be shown in one of the following ways:
- In the left sidebar click llama-viscode button and after that on the upper part click button Show Edit Agent View (pencip image)
- From llama-vscode menu (Ctrl+Shift+M) select Agents...-> Add agent (or Edit agent or Copy agent)
- From environment view, when an agent is selected, click button Edit - this will show the selected agent in the Edit Agent View
Edit existing agent:
1. Click Select button and load an agent to be edited.
2. Change the Description and System Instructions fields (if needed)
@ -154,10 +150,12 @@ Copy existing agent as a new one:
Delete agent:
1. Click Delete button
2. Select an agent to be deleted from the list
3. Confirm the deletion of the agent
3. Select an agent to be deleted from the list
4. Confirm the deletion of the agent
## Edit with AI
### Requred servers
@ -173,7 +171,9 @@ Delete agent:
https://github.com/user-attachments/assets/887d0b88-717b-4765-b565-d4c54673bde8
![Edit with AI](https://github.com/user-attachments/assets/d7aef6a8-8c29-4278-b91f-9b3031c8cbd5)## Env
![Edit with AI](https://github.com/user-attachments/assets/d7aef6a8-8c29-4278-b91f-9b3031c8cbd5)
## Env
### What is env
Env (short for environment) is a group of models, agent and settings. Env makes it easier for the users to prepare the environment for their needs. Selecting an env with a given intent will make sure all needed servers are available. One env could contain up to 4 different models - for completions, chat, embeddings, tools. Env could also contain an agent and settings for enabling/disabling completions, rag and starting last selected env on startup. If the user wants to use only code completions functionality, he/she could select an env with only one model for completions. If the user wants to use all the functionality from llama-vscode, he/she could select an env with full package of models.
@ -186,6 +186,8 @@ There is a page in llama-vscode UI with the current environment details. From th
<img width="540" height="996" alt="image" src="https://github.com/user-attachments/assets/b1a78d7a-8602-451a-b304-fc967fb66696" />
## Generate a commit message
### Requred servers
@ -195,51 +197,14 @@ There is a page in llama-vscode UI with the current environment details. From th
In the source control panel just click on the star button (near the commit button).
This generate a commit message, based on the current changes.
![Generate a commit message](https://github.com/user-attachments/assets/25f5d1ae-3673-4416-ba52-7615969c1bb3)## Health check
### Overview
Health check for the models is added. It works with llama.cpp server or other servers, which supports endpoint/health REST service. When the health check is enabled, the current state of the selected model is visible in the environment view. The health check is done every 30 seconds (could be changed from setting Health_check_interval_s). It could be triggered also manually by the user by clicking the appropriate button in the environment view (after the selected model name).
### How to use it
1. Enable health check in settings for the appropriate model (e.g. for completion Health_check_compl_enabled)
2. Open environment view and select the completion model (for example)
3. The health check will be monitored periodically and the status will be displayed in the environment view
4. Optionally, the health check can be triggered manually by clicking the appropriate button
Settings:
- Health_check_interval_s: The interval in seconds for the health check
- Health_check_compl_enabled: Enable/disable health check for completion model
- Health_check_chat_enabled: Enable/disable health check for chat model
- Health_check_embs_enabled: Enable/disable health check for embedding model
- Health_check_tools_enabled: Enable/disable health check for tools model
<img width="580" height="779" alt="image" src="https://github.com/user-attachments/assets/dca91333-687e-4856-b187-25df50d17b1c" />
<img width="580" height="779" alt="image" src="https://github.com/user-attachments/assets/bb29e0c8-85b4-4e7a-a3d9-f2d9a1679d3d" />
## Version 0.0.45 is released (04.03.2026)
![Generate a commit message](https://github.com/user-attachments/assets/25f5d1ae-3673-4416-ba52-7615969c1bb3)
## Version 0.0.32 is released (05.10.2025)
## What is new
- Configurable debounce for inline completion requests - setting debounce_ms.
llama-vscode will wait debounce_ms after a keystroke before sending a request to the LLM for inline code completion. If in the meantime there is another keystroke, the request for the previous keystroke is cancelled. Useful on low end hardware to avoid triggering code completion on every keystroke.
- Notification "Extension is updated" is shown only on version change, not on every setting change (as was before)
## Version 0.0.44 is released (03.03.2026)
## What is new
- Subagents implemented (with tool delegate_task) - now each agent, which has "Available as Subagent" checked could be used as a subagent
- new agent - Unit Test Writer
- new tool create_agent
- new agent "Agent creator"
- Files SOUL.md and USER.md (if available in the project root) will be added to the context
- predefined model DeepSeek V3.1 free 163,800 context (OpenRouter) added
- predefined model Z.AI: GLM 4.5 Air (free): GLM 4.5 Air - 128.000 context (OpenRouter) added
- Added agent "Ask" is for review, analysis and suggestions for the code without changing the files
- Some bugs are fixed
## Setup instructions for llama.cpp server
@ -287,6 +252,8 @@ llama-vscode will wait debounce_ms after a keystroke before sending a request to
### [Model selection](https://github.com/ggml-org/llama.vscode/wiki/Model-selection)
## How to use llama-vscode
### Overview
@ -312,6 +279,8 @@ If you are an existing user - you could continue using llama-vscode as before.
For more details - select 'View Documentation' from llama-vscode menu
## Llama Agent
### Requred servers
@ -352,6 +321,8 @@ https://github.com/user-attachments/assets/dd9da21a-6f57-477d-a55c-e4ff60b1ecb8
## Use as local AI runner (as LM Studio, Ollama, etc.)
### Overview
@ -371,6 +342,8 @@ Enjoy talking with local AI.
https://github.com/user-attachments/assets/e75e96de-878b-43db-a45b-47cc0c554697
## Manage envs
### Requred servers
@ -412,6 +385,8 @@ An agent could be exported as a .json files. This file could be shared with othe
- Import
An agent could be imported from a .json file - select a file to import it.
## Manage chat models
### Requred servers
@ -460,7 +435,9 @@ Add chat model from OpenAI compatible provider - OpenRouter or custom (for examp
A model could be exported as a .json files. This file could be shared with other users, modified if needed and imported again. Select a model to export it.
- Import
A model could be imported from a .json file - select a file to import it.## Manage envs
A model could be imported from a .json file - select a file to import it.
## Manage envs
### Requred servers
- No servers required
@ -485,6 +462,8 @@ A chat could be exported as a .json file. This file could be shared with other u
- Import
A chat could be imported from a .json file - select a file to import it.
## Manage completion models
### Requred servers
@ -533,7 +512,9 @@ Add completion model from OpenAI compatible provider - OpenRouter or custom (for
A model could be exported as a .json files. This file could be shared with other users, modified if needed and imported again. Select a model to export it.
- Import
A model could be imported from a .json file - select a file to import it.## Manage embeddings
A model could be imported from a .json file - select a file to import it.
## Manage embeddings
### Requred servers
- No servers required
@ -581,7 +562,9 @@ Add embeddings model from OpenAI compatible provider - OpenRouter or custom (for
A model could be exported as a .json files. This file could be shared with others used, modified if needed and imported again. Select a model to export it.
- Import
A model could be imported from a .json file - select a file to import it.## Manage envs
A model could be imported from a .json file - select a file to import it.
## Manage envs
### Requred servers
- No servers required
@ -629,6 +612,8 @@ https://github.com/user-attachments/assets/3fb864ad-a010-4d19-97d8-fd7c9ce60494
https://github.com/user-attachments/assets/3b8dffcc-bcdc-4981-b181-ffc52fe43075
## Manage tools models
### Requred servers
@ -677,7 +662,9 @@ Add tools model from OpenAI compatible provider - OpenRouter or custom (for exam
A model could be exported as a .json files. This file could be shared with other users, modified if needed and imported again. Select a model to export it.
- Import
A model could be imported from a .json file - select a file to import it.## MCP Support
A model could be imported from a .json file - select a file to import it.
## MCP Support
### Requred servers
- Tools server
@ -697,6 +684,8 @@ llama-vscode could use the the tools from the MCP servers, which are installed i
4. Click "Select Tools" from Llama Agent panel and select the tools, which you want to use from your MCP Server
## Menu
### Requred servers
@ -712,6 +701,8 @@ OR
https://github.com/user-attachments/assets/9895924d-1948-4f3c-b52e-2cce453645c8
## Model selection
### What is model selection
@ -725,34 +716,8 @@ There are different ways to select a model
- In Llama Agent click the button for selecting a model (completion, chat, embeddings, tools)
- In llama-vscode menu select "Completion models..." (or chat, embeddings, tools)
- Select an env. This will select the models, which are part of the env
## More context files
### What are AGENTS.md, SOUL.md, and USER.md
If in the project folder there are files: AGENTS.md, SOUL.md, and USER.md, they are used to provide additional context to the AI model when a request is sent.
AGENTS.md - instructions related with agents
SOUL.md - instructions related with the "soul" of the agent (how to behave, what values to follow, etc.)
USER.md - information about the user - preferences, additional information, etc.
These files are not mandatory. Ther are added because in some systems are quite popular and probably could be reused from there.
### How to use them
Just add one or more of these files to the project folder.
## Parallel Completions
### Overview
Llama-vscode generates parallel code completions (default 3) if a version of llama.cpp after December, 6, 2025 (commit c42712b) is used. The next completion is shown by pressing Ctrl+], previous completion is shown by pressing Ctrl+[.
The setting max_parallel_completions determines how many completions are generated.
### How to use it
1. Run the completion model and start coding
2. When a code completion is shown, press Ctrl+] to show the next completion, Ctrl+[ to show the previous completion
3. Alternatively - you could hover over the shown completion and when the toolbar is shown click the arrows to show the other completions.
Settings:
- max_parallel_completions: The max number of parallel completions to generate. Default is 3.
[Screencast from 2026-01-05 15-05-00.webm](https://github.com/user-attachments/assets/41fa92f8-88db-4079-9574-486fb4286c79)
## Rules
### What are rules
@ -765,6 +730,46 @@ The rules are optional. You could use rules file to add instructions to the syst
There are two ways to configure rules:
- Create a new rules file under name llama-vscode-rules.md in the root of the project.
- In llama-vscode setting Agent_rules enter a path to a rules file. It could be relative to the project root or absolute path. If this is specified, the file llama-vscode-rules.md will be ignored.
## Statusbar
### Requred servers
- No servers requred
### How to use it
- View vscode-state
- View statistics
- Click on "llama-vscode" status bar to show llama-vscode menu
https://github.com/user-attachments/assets/8f0b4575-104f-471c-be3f-f3d5b58aeee1
## Use cases
### Overview
The use cases below describe how to prepare and use llama-vscode in some specific cases. There are already some configurations for models and env, which could be selected and used directly
### Only completion used, local server started by llama-vscode
- Use the default configuration if it works for you by selecting Env for your case
- If you want to use a different one, here is how to prepare it:
1. Create completion model - select llama-vscode menu -> "Completion models..." -> "Add completion model from Huggingface", find the model in Huggingface and add it.
2. From llama-vscode menu select "Deselect/stop env and models"
3. Create an env, which includes only this model - from llama-vscode menu -> "Env..." -> "Add Env...". A panel will be show with buttons for selecting completion, chat, embeddings and tools models. Click "Compl" button and select the newly added model (the name is hf: model_name_from_huggingface). Test if code completion works well. Click button "Add Env" to save the environment.
### Only completion used, external server
Extarnal server could be also a local one, but is not started by llama-vscode on selecting the model. The completion server should support /infill endpoint, which is currently available only by llama.cpp.
1. Create a new model - select llama-vscode menu -> "Completion models..." -> "Add completion model...". Enter only name and endpoint.
2. From llama-vscode menu select "Deselect/stop env and models"
3. Create an env, which includes only this model - from llama-vscode menu -> "Env..." -> "Add Env...". A panel will be show with buttons for selecting completion, chat, embeddings and tools models. Click "Compl" button and select the newly added model. Test if code completion works well. Click button "Add Env" to save the environment.
## Setup llama.cpp server for Linux
1. Download the release files for your OS from [llama.cpp releases.](https://github.com/ggerganov/llama.cpp/releases) (or build from source).
@ -848,6 +853,8 @@ Same like code completion server, but use embeddings model and a little bit diff
```bash
`llama-server -hf ggml-org/Nomic-Embed-Text-V2-GGUF --port 8010 -ub 2048 -b 2048 --ctx-size 2048 --embeddings`
```
### Setup llama.cpp servers for Mac
Show llama-vscode menu (Ctrl+Shift+M) and select "Install/upgrade llama.cpp" (if not yet done). After that add/select the models you want to use.
@ -926,6 +933,8 @@ Same like code completion server, but use embeddings model and a little bit diff
`llama-server -hf ggml-org/Nomic-Embed-Text-V2-GGUF --port 8010 -ub 2048 -b 2048 --ctx-size 2048 --embeddings`
```
### Setup llama.cpp servers for Windows
Show llama-vscode menu (Ctrl+Shift+M) and select "Install/upgrade llama.cpp" (if not yet done). After that add/select the models you want to use.
@ -1009,80 +1018,5 @@ Same like code completion server, but use embeddings model and a little bit diff
```bash
`llama-server.exe -hf nomic-embed-text-v2-moe-q8_0.gguf --port 8010 -ub 2048 -b 2048 --ctx-size 2048 --embeddings`
```
## Skills
### Overview
Llama-vscode support skills (https://agentskills.io/home), which extend the capabilities of the LLM (similar to tools).
### How to use it
1. Set the skills folder in setting skills_folder (if not set, the <project_root>/skills is used)
2. Ask the agent for to do something, which requres a skill (or ask details about the skills)
On sending a user request to the agent, the folder is scanned and the available skills are provided to the LLM. If the LLM decides to use a partiular skill, the skill details are loaded by LLM.
Settings:
- skills_folder: The folder where the skills are stored
## Statusbar
### Requred servers
- No servers requred
### How to use it
- View vscode-state
- View statistics
- Click on "llama-vscode" status bar to show llama-vscode menu
https://github.com/user-attachments/assets/8f0b4575-104f-471c-be3f-f3d5b58aeee1
## Subagents
### What are subagents
Subagents are a way to optimize the user of LLM context. Some tasks are be executed in a separate session and only the final result is added to the context of the original agent session.
This is implemented with the tool delegate_task. If the delegate_task tool is enabled, the agent could decide to delegate some tasks to subagents. Each agent could be used as a subagent if it's field "Available as Subagent" is checked.
### How to use them
1. Make sure the tool delegate_task is enabled.
2. Make sure the agents you want to use as subagents have the field "Available as Subagent" checked and meaningful description.
3. Write a prompt, for which it is good idea to use the subagent. Alternatively, you could directly ask in the prompt to use the subagent.
The agent "Agent creator" makes it easier to create agents (which could be used as subagents).
## Update todos tool
### Overview
Llama-vscode provides a tool update_todo_list to the agent for planning and tracking the execution of the user request.
### How to use it
Update todos tool is based on Roocode's tool with the same name (the tool description is copied from Roocode).
If the update_todo_list is enabled (selected), the agent could use it for planning non trivial tasks (user requests). This tools is used for both creating and updating the todo items. The todo items are saved in file <project_root>\.llama-vscode-todos.md. The todo items are updated by the agent to track the execution of the plan. This file is removed after the execution of the current user request is finished. If this file is updated by the user, the change might be taken into account by the agent. The content of the file (together with the inital user request) is sent to the agent periodically (every 5-th iteration by default, but this could be changed from setting plan_review_frequency). The agent could overwrite the user changes in the todo items file before reading it.
Each time the agent uses the tool, the todo items are shown in the agent chat window. The state of the items tracked with [ ] (not started), [-] (in progres) [x] (finished)
Todo items are not reused between the user requests.
Settings:
- plan_review_frequency: Sets how often the todo items are sent to the agent to remind/review what is the current state of the plan
- tool_update_todo_list_enabled - controls if the tool is enabled
<img width="750" height="922" alt="image" src="https://github.com/user-attachments/assets/a4049df0-17da-4c6d-868f-a6bcbfa5f65c" />
## Use cases
### Overview
The use cases below describe how to prepare and use llama-vscode in some specific cases. There are already some configurations for models and env, which could be selected and used directly
### Only completion used, local server started by llama-vscode
- Use the default configuration if it works for you by selecting Env for your case
- If you want to use a different one, here is how to prepare it:
1. Create completion model - select llama-vscode menu -> "Completion models..." -> "Add completion model from Huggingface", find the model in Huggingface and add it.
2. From llama-vscode menu select "Deselect/stop env and models"
3. Create an env, which includes only this model - from llama-vscode menu -> "Env..." -> "Add Env...". A panel will be show with buttons for selecting completion, chat, embeddings and tools models. Click "Compl" button and select the newly added model (the name is hf: model_name_from_huggingface). Test if code completion works well. Click button "Add Env" to save the environment.
### Only completion used, external server
Extarnal server could be also a local one, but is not started by llama-vscode on selecting the model. The completion server should support /infill endpoint, which is currently available only by llama.cpp.
1. Create a new model - select llama-vscode menu -> "Completion models..." -> "Add completion model...". Enter only name and endpoint.
2. From llama-vscode menu select "Deselect/stop env and models"
3. Create an env, which includes only this model - from llama-vscode menu -> "Env..." -> "Add Env...". A panel will be show with buttons for selecting completion, chat, embeddings and tools models. Click "Compl" button and select the newly added model. Test if code completion works well. Click button "Add Env" to save the environment.

View file

@ -30,10 +30,9 @@ import { Agent, Chat, Env, LlmModel } from "./types";
import { ModelType, PERSISTENCE_KEYS } from "./constants";
import { ApiKeyService } from "./services/api-key-service";
import { OpenAiCompModelStrategy } from "./services/openai-comp-model-strategy";
import { LlamaChatModelProvider } from "./llama-chat-model-provider";
export class Application {
public static readonly emptyModel = {name: ""};
private static instance: Application;
public configuration: Configuration;
public extraContext: ExtraContext;
@ -64,17 +63,14 @@ export class Application {
public agentCommandService: AgentCommandService
public chatService: ChatService
public apiKeyService: ApiKeyService
public llamaChatModelProvider: LlamaChatModelProvider
private selectedComplModel: LlmModel = Application.emptyModel
private selectedChatModel: LlmModel = Application.emptyModel
private selectedEmbeddingsModel: LlmModel = Application.emptyModel
private selectedToolsModel: LlmModel = Application.emptyModel
private selectedTmpAgentModel: LlmModel = Application.emptyModel
private selectedComplModel: LlmModel = ModelService.emptyModel
private selectedModel: LlmModel = ModelService.emptyModel
private selectedEmbeddingsModel: LlmModel = ModelService.emptyModel
private selectedToolsModel: LlmModel = ModelService.emptyModel
private selectedEnv: Env = {name: ""}
private selectedAgent: Agent = {name: "", systemInstruction: []}
private selectedChat: Chat = {name: "", id: ""}
private modelState: Map<string, string> = new Map()
private constructor(context: vscode.ExtensionContext) {
this.configuration = new Configuration()
@ -107,7 +103,6 @@ export class Application {
this.agentCommandService = new AgentCommandService(this)
this.chatService = new ChatService(this)
this.apiKeyService = new ApiKeyService(this)
this.llamaChatModelProvider = new LlamaChatModelProvider(this);
}
public static getInstance(context: vscode.ExtensionContext): Application {
@ -116,25 +111,6 @@ export class Application {
}
return Application.instance;
}
getModel = (modelType: ModelType): LlmModel => {
let model: LlmModel;
switch (modelType) {
case ModelType.Completion:
model = this.selectedComplModel;
break;
case ModelType.Chat:
model = this.selectedChatModel;
break;
case ModelType.Embeddings:
model = this.selectedEmbeddingsModel;
break;
case ModelType.Tools:
model = this.selectedToolsModel;
break;
}
return model;
}
getComplModel = (): LlmModel => {
return this.selectedComplModel;
@ -145,17 +121,13 @@ export class Application {
}
getChatModel = (): LlmModel => {
return this.selectedChatModel;
return this.selectedModel;
}
getEmbeddingsModel = (): LlmModel => {
return this.selectedEmbeddingsModel;
}
getTmpAgentModel = (): LlmModel => {
return this.selectedTmpAgentModel;
}
getEnv = (): Env => {
return this.selectedEnv;
}
@ -181,7 +153,7 @@ export class Application {
}
isChatModelSelected = (): boolean => {
return this.selectedChatModel != undefined && this.selectedChatModel.name. trim() != "";
return this.selectedModel != undefined && this.selectedModel.name. trim() != "";
}
isToolsModelSelected = (): boolean => {
@ -189,11 +161,7 @@ export class Application {
}
isEmbeddingsModelSelected = (): boolean => {
return this.selectedEmbeddingsModel != undefined && this.selectedEmbeddingsModel.name. trim() != "";
}
isTmpAgentModelSelected = (): boolean => {
return this.selectedTmpAgentModel != undefined && this.selectedTmpAgentModel.name. trim() != "";
return this.selectedEmbeddingsModel != undefined && this.selectedToolsModel.name. trim() != "";
}
isEnvSelected = (): boolean => {
@ -213,35 +181,21 @@ export class Application {
setSelectedModel = (type: ModelType, model: LlmModel | undefined) => {
switch (type) {
case ModelType.Completion:
this.selectedComplModel = model??Application.emptyModel;
this.selectedComplModel = model??ModelService.emptyModel;
break;
case ModelType.Chat:
this.selectedChatModel = model??Application.emptyModel;
this.selectedModel = model??ModelService.emptyModel;
break;
case ModelType.Embeddings:
this.selectedEmbeddingsModel = model??Application.emptyModel;
this.selectedEmbeddingsModel = model??ModelService.emptyModel;
break;
case ModelType.Tools:
this.selectedToolsModel = model??Application.emptyModel;
this.selectedToolsModel = model??ModelService.emptyModel;
break;
}
this.llamaWebviewProvider.updateLlamaView();
}
setModelState = (type: ModelType, state: string) => {
this.modelState.set(type, state);
this.llamaWebviewProvider.updateModels();
}
getModelState = (type: ModelType): string => {
return this.modelState.get(type)??"";
}
setAgentModel = (model: LlmModel | undefined) => {
this.selectedTmpAgentModel = model??Application.emptyModel;
this.llamaWebviewProvider.updateLlamaView();
}
public setSelectedEnv(env: Env): void {
this.selectedEnv = env;
this.persistence.setValue(PERSISTENCE_KEYS.SELECTED_ENV, env);

View file

@ -9,7 +9,6 @@ import { Utils } from './utils';
import { Env, LlmModel } from './types';
import { env } from 'process';
import { PERSISTENCE_KEYS, SETTING_NAME_FOR_LIST, UiView } from './constants';
import {LlamaChatModelProvider} from "./llama-chat-model-provider";
export class Architect {
private app: Application
@ -17,7 +16,6 @@ export class Architect {
constructor(application: Application) {
this.app = application;
}
init = async () => {
// Start indexing workspace files
@ -27,14 +25,6 @@ export class Architect {
this.app.menu.showHowToUseLlamaVscode();
this.app.persistence.setGlobalValue("isFirstStart", false)
}
const currentVersion = vscode.extensions.getExtension('ggml-org.llama-vscode')?.packageJSON?.version as string | undefined;
const storedVersion = this.app.persistence.getGlobalValue(PERSISTENCE_KEYS.EXTENSION_VERSION) as string | undefined;
if (currentVersion && storedVersion && currentVersion !== storedVersion) {
vscode.window.showInformationMessage(this.app.configuration.getUiText(`llama-vscode extension is updated.`) ?? "");
}
if (currentVersion) {
this.app.persistence.setGlobalValue(PERSISTENCE_KEYS.EXTENSION_VERSION, currentVersion);
}
await this.installUpgradeLlamaCpp(isFirstStart);
if (this.app.configuration.env_start_last_used){
let lastEnv = this.app.persistence.getValue("selectedEnv")
@ -44,10 +34,10 @@ export class Architect {
this.app.envService.getEnvDetailsAsString(lastEnv) +
"\n\n Do you want to continue?"
);
if (shouldSelect) this.app.envService.selectStartEnv(lastEnv, false);
if (shouldSelect) this.app.envService.selectEnv(lastEnv, false);
if (dontAskAgain) this.app.configuration.updateConfigValue("env_start_last_used_confirm", false);
} else {
this.app.envService.selectStartEnv(lastEnv, false);
this.app.envService.selectEnv(lastEnv, false);
}
}
@ -79,6 +69,7 @@ export class Architect {
if (this.app.configuration.isRagConfigChanged(event)) this.init();
if (this.app.configuration.isToolChanged(event)) this.app.tools.init();
if (this.app.configuration.isEnvViewSettingChanged(event)) this.app.llamaWebviewProvider.updateLlamaView();
vscode.window.showInformationMessage(this.app.configuration.getUiText(`llama-vscode extension is updated.`)??"");
});
context.subscriptions.push(configurationChangeDisp);
}
@ -107,36 +98,6 @@ export class Architect {
context.subscriptions.push(changeActiveTextEditorDisp)
}
registerCommandSelectNextSuggestion = (context: vscode.ExtensionContext) => {
const selectNextSuggestionCommand = vscode.commands.registerCommand(
'extension.selectNextSuggestion',
async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
await vscode.commands.executeCommand('editor.action.inlineSuggest.showNext');
await this.app.completion.increaseSuggestionIndex();
}
);
context.subscriptions.push(selectNextSuggestionCommand);
}
registerCommandSelectPreviousSuggestion = (context: vscode.ExtensionContext) => {
const selectPreviousSuggestionCommand = vscode.commands.registerCommand(
'extension.selectPreviousSuggestion',
async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
await vscode.commands.executeCommand('editor.action.inlineSuggest.showPrevious');
await this.app.completion.decreaseSuggestionIndex();
}
);
context.subscriptions.push(selectPreviousSuggestionCommand);
}
registerCommandAcceptFirstLine = (context: vscode.ExtensionContext) => {
const acceptFirstLineCommand = vscode.commands.registerCommand(
'extension.acceptFirstLine',
@ -186,16 +147,6 @@ export class Architect {
context.subscriptions.push(rungBufferUpdateDisposable);
}
setPeriodicModelsHealthUpdate = (context: vscode.ExtensionContext) => {
const modelsHealthIntervalId = setInterval(this.app.modelService.periodicModelHealthUpdate, this.app.configuration.health_check_interval_s * 1000);
const modelsHealthUpdateDisposable = {
dispose: () => {
clearInterval(modelsHealthIntervalId);
}
};
context.subscriptions.push(modelsHealthUpdateDisposable);
}
setOnSaveFile = (context: vscode.ExtensionContext) => {
const onSaveDocDisposable = vscode.workspace.onDidSaveTextDocument(this.app.extraContext.handleDocumentSave);
context.subscriptions.push(onSaveDocDisposable);
@ -212,22 +163,6 @@ export class Architect {
);
}
registerLlavaVscodeModelProvider = (context: vscode.ExtensionContext) => {
// Register the llama.vscode language model chat provider for GitHub Copilot Chat
context.subscriptions.push(vscode.lm.registerLanguageModelChatProvider(
'llama-vscode',
this.app.llamaChatModelProvider
));
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration('llama-vscode.endpoint_chat')
|| event.affectsConfiguration('llama-vscode.endpoint_tools')
|| event.affectsConfiguration('llama-vscode.ai_api_version')) {
this.app.llamaChatModelProvider.notifyModelsChanged();
}
}));
}
registerGenarateCommitMsg = (context: vscode.ExtensionContext) => {
const generateCommitCommand = vscode.commands.registerCommand(
'extension.generateGitCommitMessage',

View file

@ -128,9 +128,19 @@ export class ChatWithAi {
// console.log("onDidReceiveMessage: " + message.text);
}
});
// Wait for the page to load before sending message
if (query) extraCont += await this.prepareRagContext(query);
setTimeout(async () => {
if (aiPanel) aiPanel.webview.postMessage({ command: 'setText', text: queryToSend, context: extraCont });
}, Math.max(0, 3000 - (Date.now() - createWebviewTimeInMs)));
} else {
aiPanel.reveal();
this.lastActiveEditor = editor;
if (query) extraCont += await this.prepareRagContext(query);
// Wait for the page to load before sending message
setTimeout(async () => {
if (aiPanel) aiPanel.webview.postMessage({ command: 'setText', text: queryToSend, context: extraCont });
}, 500);
}
}
@ -147,12 +157,46 @@ export class ChatWithAi {
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self' https: http: data: blob: 'unsafe-inline' 'unsafe-eval';
connect-src 'self' https: http: ws: wss:;
frame-src 'self' https: http:;">
<title>llama.cpp server UI</title>
<script>
// Initialize the VS Code API
const vscode = acquireVsCodeApi();
vscode.postMessage({ command: 'jsAction', text: 'vscode javascript object created' });
// Listen for messages from the extension
window.addEventListener('message', (event) => {
vscode.postMessage({ command: 'jsAction', text: 'message received' });
const { command, text, context } = event.data; // Extract the command and text from the event
if (command === 'setText') {
vscode.postMessage({ command: 'jsAction', text: 'command setText received' });
const iframe = document.getElementById('askAiIframe');
if (iframe) {
vscode.postMessage({ command: 'jsAction', text: 'askAiIframe obtained' });
iframe.contentWindow.postMessage({ command: 'setText', text: text, context: context }, '*');
vscode.postMessage({ command: 'jsAction', text: text });
}
}
if (command === 'escapePressed') {
vscode.postMessage({ command: 'jsAction', text: 'command escape pressed' });
vscode.postMessage({ command: 'escapePressed' });
}
if (command === 'jsAction') {
vscode.postMessage({ command: 'jsAction', text: text });
}
});
// Listen for key events in the iframe
window.addEventListener('keydown', (event) => {
vscode.postMessage({ command: 'jsAction', text: 'keydown event received' });
if (event.key === 'Escape') {
// Send a message to the extension when Escape is pressed
vscode.postMessage({ command: 'escapePressed', text: "" });
vscode.postMessage({ command: 'jsAction', text: "Escabe key pressed..." });
}
});
</script>
<style>
body, html {
margin: 0;
@ -169,7 +213,7 @@ export class ChatWithAi {
</style>
</head>
<body>
<iframe src="${url}" sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-modals" id="askAiIframe"></iframe>
<iframe src="${url}" id="askAiIframe"></iframe>
</body>
</html>
`;

View file

@ -4,19 +4,18 @@ import vscode from "vscode";
import {Utils} from "./utils";
interface CompletionDetails {
completions: string[];
completion: string;
position: vscode.Position;
inputPrefix: string;
inputSuffix: string;
prompt: string;
complIndex: number;
}
export class Completion {
private app: Application
private isRequestInProgress = false
isForcedNewRequest = false
lastCompletion: CompletionDetails = {completions: [], complIndex: 0, position: new vscode.Position(0, 0), inputPrefix: "", inputSuffix: "", prompt: ""};
lastCompletion: CompletionDetails = {completion: "", position: new vscode.Position(0, 0), inputPrefix: "", inputSuffix: "", prompt: ""};
constructor(application: Application) {
this.app = application;
@ -30,15 +29,6 @@ export class Completion {
return null;
}
// Debounce: wait for the user to pause typing before hitting the backend
if (context.triggerKind == vscode.InlineCompletionTriggerKind.Automatic && this.app.configuration.debounce_ms > 0) {
await Utils.delay(this.app.configuration.debounce_ms);
if (token.isCancellationRequested) {
this.app.logger.addEventLog(group, "DEBOUNCE_CANCELLATION_RETURN", "")
return null;
}
}
// Start only if the previous request is finiched
while (this.isRequestInProgress) {
await Utils.delay(this.app.configuration.DELAY_BEFORE_COMPL_REQUEST);
@ -76,8 +66,8 @@ export class Completion {
try {
let data: LlamaResponse | undefined
let hashKey = this.app.lruResultCache.getHash(inputPrefix + "|" + inputSuffix + "|" + prompt)
let completions = this.getCachedCompletion(hashKey, inputPrefix, inputSuffix, prompt)
let isCachedResponse = !this.isForcedNewRequest && completions != undefined
let completion = this.getCachedCompletion(hashKey, inputPrefix, inputSuffix, prompt)
let isCachedResponse = !this.isForcedNewRequest && completion != undefined
if (!isCachedResponse) {
this.isForcedNewRequest = false
if (token.isCancellationRequested){
@ -88,56 +78,46 @@ export class Completion {
this.app.statusbar.showThinkingInfo();
data = await this.app.llamaServer.getFIMCompletion(inputPrefix, inputSuffix, prompt, this.app.extraContext.chunks, nindent)
if (data != undefined) completions = this.getComplFromContent(data);
else completions = undefined
if (data != undefined) completion = data.content;
else completion = undefined
}
if (completions == undefined || completions.length == 0){
if (completion == undefined || completion.trim() == ""){
this.app.statusbar.showInfo(undefined);
this.isRequestInProgress = false
this.app.logger.addEventLog(group, "NO_SUGGESTION_RETURN", "")
return [];
}
let newCompletions: string[] = []
let firstComplLines: string[] = []
let suggestionLines = completion.split(/\r?\n/)
Utils.removeTrailingNewLines(suggestionLines);
for (let compl of completions){
let suggestionLines = compl.split(/\r?\n/)
Utils.removeTrailingNewLines(suggestionLines);
if (this.shouldDiscardSuggestion(suggestionLines, document, position, linePrefix, lineSuffix)) {
continue
} else {
compl = this.updateSuggestion(suggestionLines, lineSuffix);
newCompletions.push(compl);
if (firstComplLines.length == 0) firstComplLines = suggestionLines;
}
}
if (newCompletions.length == 0){
if (this.shouldDiscardSuggestion(suggestionLines, document, position, linePrefix, lineSuffix)) {
this.app.statusbar.showInfo(undefined);
this.isRequestInProgress = false
this.app.logger.addEventLog(group, "DISCARD_SUGGESTION_RETURN", "")
return [];
this.isRequestInProgress = false
this.app.logger.addEventLog(group, "DISCARD_SUGGESTION_RETURN", "")
return [];
}
if (!isCachedResponse && newCompletions) this.app.lruResultCache.put(hashKey, newCompletions)
this.lastCompletion = this.getCompletionDetails(newCompletions, position, inputPrefix, inputSuffix, prompt);
completion = this.updateSuggestion(suggestionLines, lineSuffix);
if (!isCachedResponse) this.app.lruResultCache.put(hashKey, completion)
this.lastCompletion = this.getCompletionDetails(completion, position, inputPrefix, inputSuffix, prompt);
// Run async as not needed for the suggestion
setTimeout(async () => {
if (isCachedResponse) this.app.statusbar.showCachedInfo()
else this.app.statusbar.showInfo(data);
if (!token.isCancellationRequested && lineSuffix.trim() === ""){
await this.cacheFutureSuggestion(inputPrefix, inputSuffix, prompt, firstComplLines);
await this.cacheFutureAcceptLineSuggestion(inputPrefix, inputSuffix, prompt, firstComplLines);
await this.cacheFutureSuggestion(inputPrefix, inputSuffix, prompt, suggestionLines);
await this.cacheFutureAcceptLineSuggestion(inputPrefix, inputSuffix, prompt, suggestionLines);
}
if (!token.isCancellationRequested){
this.app.extraContext.addFimContextChunks(position, context, document);
}
}, 0);
this.isRequestInProgress = false
this.app.logger.addEventLog(group, "NORMAL_RETURN", firstComplLines[0])
return this.getCompletion(newCompletions||[], position, spacesToRemove);
this.app.logger.addEventLog(group, "NORMAL_RETURN", suggestionLines[0])
return [this.getCompletion(this.removeLeadingSpaces(completion, spacesToRemove), position)];
} catch (err) {
console.error("Error fetching llama completion:", err);
vscode.window.showInformationMessage(this.app.configuration.getUiText(`Error getting response. Please check if llama.cpp server is running.`)??"");
@ -175,36 +155,21 @@ export class Completion {
let promptCut = prompt.slice(i)
let hash = this.app.lruResultCache.getHash(inputPrefix + "|" + inputSuffix + "|" + newPrompt)
let result = this.app.lruResultCache.get(hash)
if (result == undefined) continue
let completions: string[] = []
for (const compl of result){
if (compl && promptCut == compl.slice(0,promptCut.length)) {
completions.push(compl.slice(prompt.length - newPrompt.length))
}
}
if (completions.length > 0) return completions;
if (result != undefined && promptCut == result.slice(0,promptCut.length)) return result.slice(prompt.length - newPrompt.length)
}
return undefined
}
getCompletion = (completions: string[],
position: vscode.Position,
spacesToRemove: number): vscode.InlineCompletionItem[] => {
let completionItems: vscode.InlineCompletionItem[] = []
for (const completion of completions){
const compl: vscode.InlineCompletionItem = new vscode.InlineCompletionItem(
this.removeLeadingSpaces(completion, spacesToRemove),
new vscode.Range(position, position)
)
completionItems.push(compl);
}
return completionItems;
getCompletion = (completion: string, position: vscode.Position) => {
return new vscode.InlineCompletionItem(
completion,
new vscode.Range(position, position)
);
}
private getCompletionDetails = (completions: string[], position: vscode.Position, inputPrefix: string, inputSuffix: string, prompt: string) => {
return { completions: completions,complIndex: 0, position: position, inputPrefix: inputPrefix, inputSuffix: inputSuffix, prompt: prompt };
private getCompletionDetails = (completion: string, position: vscode.Position, inputPrefix: string, inputSuffix: string, prompt: string) => {
return { completion: completion, position: position, inputPrefix: inputPrefix, inputSuffix: inputSuffix, prompt: prompt };
}
// logic for discarding predictions that repeat existing text
@ -276,17 +241,14 @@ export class Completion {
let cached_completion = this.app.lruResultCache.get(futureHashKey)
if (cached_completion != undefined) return;
let futureData = await this.app.llamaServer.getFIMCompletion(futureInputPrefix, futureInputSuffix, futurePrompt, this.app.extraContext.chunks, prompt.length - prompt.trimStart().length);
let futureSuggestions = [];
let futureSuggestion = "";
if (futureData != undefined && futureData.content != undefined && futureData.content.trim() != "") {
let suggestions = this.getComplFromContent(futureData);
for (let futureSuggestion of suggestions||[]){
let suggestionLines = futureSuggestion.split(/\r?\n/)
Utils.removeTrailingNewLines(suggestionLines);
futureSuggestion = suggestionLines.join('\n')
futureSuggestions.push(futureSuggestion)
}
futureSuggestion = futureData.content;
let suggestionLines = futureSuggestion.split(/\r?\n/)
Utils.removeTrailingNewLines(suggestionLines);
futureSuggestion = suggestionLines.join('\n')
let futureHashKey = this.app.lruResultCache.getHash(futureInputPrefix + "|" + futureInputSuffix + "|" + futurePrompt);
this.app.lruResultCache.put(futureHashKey, futureSuggestions);
this.app.lruResultCache.put(futureHashKey, futureSuggestion);
}
}
@ -300,13 +262,13 @@ export class Completion {
let futureSuggestion = suggestionLines.slice(1).join('\n')
let cached_completion = this.app.lruResultCache.get(futureHashKey)
if (cached_completion != undefined) return;
else this.app.lruResultCache.put(futureHashKey, [futureSuggestion])
else this.app.lruResultCache.put(futureHashKey, futureSuggestion)
}
}
insertNextWord = async (editor: vscode.TextEditor) => {
// Retrieve the last inline completion item
const lastSuggestion = this.lastCompletion.completions[this.lastCompletion.complIndex];
const lastSuggestion = this.lastCompletion.completion;
if (!lastSuggestion) {
return;
}
@ -332,7 +294,7 @@ export class Completion {
insertFirstLine = async (editor: vscode.TextEditor) => {
// Retrieve the last inline completion item
const lastItem = this.lastCompletion.completions[this.lastCompletion.complIndex];
const lastItem = this.lastCompletion.completion;
if (!lastItem) {
return;
}
@ -349,33 +311,4 @@ export class Completion {
editBuilder.insert(position, insertLine);
});
}
increaseSuggestionIndex = async () => {
const totalCompletions = this.lastCompletion.completions.length
if (totalCompletions > 0){
this.lastCompletion.complIndex = (this.lastCompletion.complIndex + 1) % totalCompletions
}
}
decreaseSuggestionIndex = async () => {
const totalCompletions = this.lastCompletion.completions.length
if (totalCompletions > 0){
if (this.lastCompletion.complIndex > 0) this.lastCompletion.complIndex--
else this.lastCompletion.complIndex = totalCompletions - 1
}
}
private getComplFromContent(codeCompletions: any): string[] | undefined {
if ("content" in codeCompletions)
return [codeCompletions.content??""]
if (codeCompletions.length > 0){
let completions: Set<string> = new Set()
for (const compl of codeCompletions){
completions.add(compl.content??"")
}
return Array.from(completions);
}
else return [];
}
}

View file

@ -29,7 +29,6 @@ export class Configuration {
new_embeddings_model_host = "127.0.0.1"
new_tools_model_host = "127.0.0.1"
auto = true;
debounce_ms = 0;
api_key = "";
api_key_chat = "";
api_key_tools = "";
@ -47,14 +46,7 @@ export class Configuration {
ring_chunk_size = 64;
ring_scope = 1024;
ring_update_ms = 1000;
skills_folder = ""
language = "en";
health_check_interval_s = 30;
health_check_compl_enabled = false;
health_check_chat_enabled = false;
health_check_embs_enabled = false;
health_check_tools_enabled = false;
// experimental - avoid using
use_openai_endpoint = false;
@ -74,7 +66,6 @@ export class Configuration {
rag_max_context_file_chars = 10000
tool_run_terminal_command_enabled = true;
tool_create_agent_enabled = true;
tool_search_source_enabled = true;
tool_read_file_enabled = true;
tool_list_directory_enabled = true;
@ -93,16 +84,14 @@ export class Configuration {
tool_custom_eval_tool_property_description = ""
tool_custom_eval_tool_code = "";
tool_llama_vscode_help_enabled = true;
tool_update_todo_list_enabled = true;
tool_delegate_task_enabled = true;
tool_save_plan_enabled = false;
tool_update_task_enabled = false;
tools_max_iterations = 50;
plan_review_frequency = 5;
tools_log_calls = false;
chats_max_history = 50;
chats_max_tokens = 64000;
chats_summarize_old_msgs = false;
chats_msgs_keep = 50
max_parallel_completions = 3
completion_models_list = new Array();
embeddings_models_list = new Array();
tools_models_list = new Array();
@ -197,7 +186,6 @@ export class Configuration {
this.openai_client_model = String(config.get<string>("openai_client_model"));
this.openai_prompt_template = String(config.get<string>("openai_prompt_template"));
this.auto = Boolean(config.get<boolean>("auto"));
this.debounce_ms = Number(config.get<number>("debounce_ms"));
this.api_key = String(config.get<string>("api_key"));
this.api_key_chat = String(config.get<string>("api_key_chat"));
this.api_key_tools = String(config.get<string>("api_key_tools"));
@ -226,7 +214,6 @@ export class Configuration {
this.rag_max_context_files = Number(config.get<number>("rag_max_context_files"));
this.rag_max_context_file_chars = Number(config.get<number>("rag_max_context_file_chars"));
this.tool_run_terminal_command_enabled = Boolean(config.get<boolean>("tool_run_terminal_command_enabled"));
this.tool_create_agent_enabled = Boolean(config.get<boolean>("tool_create_agent_enabled"));
this.tool_search_source_enabled = Boolean(config.get<boolean>("tool_search_source_enabled"));
this.tool_read_file_enabled = Boolean(config.get<boolean>("tool_read_file_enabled"));
this.tool_list_directory_enabled = Boolean(config.get<boolean>("tool_list_directory_enabled"));
@ -238,8 +225,8 @@ export class Configuration {
this.tool_edit_file_enabled = Boolean(config.get<boolean>("tool_edit_file_enabled"));
this.tool_ask_user_enabled = Boolean(config.get<boolean>("tool_ask_user_enabled"));
this.tool_custom_tool_enabled = Boolean(config.get<boolean>("tool_custom_tool_enabled"));
this.tool_update_todo_list_enabled = Boolean(config.get<boolean>("tool_update_todo_list_enabled"));
this.tool_delegate_task_enabled = Boolean(config.get<boolean>("tool_delegate_task_enabled"));
this.tool_save_plan_enabled = Boolean(config.get<boolean>("tool_save_plan_enabled"));
this.tool_update_task_enabled = Boolean(config.get<boolean>("tool_update_task_enabled"));
this.tool_llama_vscode_help_enabled = Boolean(config.get<boolean>("tool_llama_vscode_help_enabled"));
this.tool_custom_tool_description = String(config.get<string>("tool_custom_tool_description"));
this.tool_custom_tool_source = String(config.get<string>("tool_custom_tool_source"));
@ -248,14 +235,11 @@ export class Configuration {
this.tool_custom_eval_tool_description = String(config.get<string>("tool_custom_eval_tool_description"));
this.tool_custom_eval_tool_code = String(config.get<string>("tool_custom_eval_tool_code"));
this.tools_max_iterations = Number(config.get<number>("tools_max_iterations"));
this.plan_review_frequency = Number(config.get<number>("plan_review_frequency"));
this.tools_log_calls = Boolean(config.get<boolean>("tools_log_calls"));
this.chats_max_history = Number(config.get<number>("chats_max_history"));
this.chats_max_tokens = Number(config.get<number>("chats_max_tokens"));
this.max_parallel_completions = Number(config.get<number>("max_parallel_completions"));
this.chats_summarize_old_msgs = Boolean(config.get<boolean>("chats_summarize_old_msgs"));
this.chats_msgs_keep = Number(config.get<number>("chats_msgs_keep"));
this.skills_folder = String(config.get<string>("skills_folder"));
this.language = String(config.get<string>("language"));
this.disabledLanguages = config.get<string[]>("disabledLanguages") || [];
this.enabled = Boolean(config.get<boolean>("enabled", true));
@ -275,11 +259,6 @@ export class Configuration {
this.env_start_last_used_confirm = Boolean(config.get<boolean>("env_start_last_used_confirm", true));
this.ask_install_llamacpp = Boolean(config.get<boolean>("ask_install_llamacpp", true));
this.ask_upgrade_llamacpp_hours = Number(config.get<number>("ask_upgrade_llamacpp_hours"));
this.health_check_interval_s = Number(config.get<number>("health_check_interval_s"));
this.health_check_compl_enabled = Boolean(config.get<boolean>("health_check_compl_enabled"));
this.health_check_chat_enabled = Boolean(config.get<boolean>("health_check_chat_enabled"));
this.health_check_embs_enabled = Boolean(config.get<boolean>("health_check_embs_enabled"));
this.health_check_tools_enabled = Boolean(config.get<boolean>("health_check_tools_enabled"));
};
getUiText = (uiText: string): string | undefined => {
@ -304,11 +283,7 @@ export class Configuration {
isEnvViewSettingChanged = (event: vscode.ConfigurationChangeEvent) => {
return event.affectsConfiguration("llama-vscode.enabled")
|| event.affectsConfiguration("llama-vscode.rag_enabled")
|| event.affectsConfiguration("llama-vscode.env_start_last_used")
|| event.affectsConfiguration("llama-vscode.health_check_compl_enabled")
|| event.affectsConfiguration("llama-vscode.health_check_chat_enabled")
|| event.affectsConfiguration("llama-vscode.health_check_embs_enabled")
|| event.affectsConfiguration("llama-vscode.health_check_tools_enabled");
|| event.affectsConfiguration("llama-vscode.env_start_last_used");
}
isRagConfigChanged = (event: vscode.ConfigurationChangeEvent) => {
@ -321,7 +296,6 @@ export class Configuration {
isToolChanged = (event: vscode.ConfigurationChangeEvent) => {
return event.affectsConfiguration("llama-vscode.tool_run_terminal_command_enabled")
|| event.affectsConfiguration("llama-vscode.tool_create_agent_enabled")
|| event.affectsConfiguration("llama-vscode.tool_search_source_enabled")
|| event.affectsConfiguration("llama-vscode.tool_list_directory_enabled")
|| event.affectsConfiguration("llama-vscode.tool_read_file_enabled")
@ -334,8 +308,6 @@ export class Configuration {
|| event.affectsConfiguration("llama-vscode.tool_edit_file_enabled")
|| event.affectsConfiguration("llama-vscode.tool_get_diff_enabled")
|| event.affectsConfiguration("llama-vscode.tool_llama_vscode_help_enabled")
|| event.affectsConfiguration("llama-vscode.tool_update_todo_list_enabled")
|| event.affectsConfiguration("llama-vscode.tool_delegate_task_enabled")
|| event.affectsConfiguration("llama-vscode.tool_custom_eval_tool_enabled")
|| event.affectsConfiguration("llama-vscode.tool_custom_eval_tool_description")
|| event.affectsConfiguration("llama-vscode.tool_custom_eval_tool_property_description")

View file

@ -253,7 +253,6 @@ export const PERSISTENCE_KEYS = {
SELECTED_CHAT: 'selectedChat' as const,
SELECTED_AGENT: 'selectedAgent' as const,
SELECTED_ENV: 'selectedEnv' as const,
EXTENSION_VERSION: 'extensionVersion' as const,
} as const;
export const SETTING_NAME_FOR_LIST = {
@ -283,11 +282,4 @@ export enum OpenAiProvidersKeys {
export const OPENAI_COMP_PROVIDERS = {
[OpenAiProvidersKeys.OpenRouter]: "https://openrouter.ai/api",
[OpenAiProvidersKeys.Custom]: ""
} as const
export const SUPPORTED_IMG_FILE_EXTS: { [key: string]: string } = {
'.jpeg': 'image/jpeg',
'.jpg': 'image/jpeg',
'.png': 'image/png',
'.webp': 'image/webp'
} as const;;
} as const

View file

@ -15,7 +15,6 @@ export function activate(context: vscode.ExtensionContext) {
app.architect.registerCommandNoCacheCompletion(context);
app.architect.setOnSaveFile(context);
app.architect.setPeriodicRingBufferUpdate(context);
app.architect.setPeriodicModelsHealthUpdate(context);
app.architect.setClipboardEvents(context);
app.architect.setOnChangeActiveFile(context);
app.architect.registerCommandAcceptFirstLine(context);
@ -30,12 +29,7 @@ export function activate(context: vscode.ExtensionContext) {
app.architect.registerGenarateCommitMsg(context)
app.architect.registerCommandKillAgent(context)
app.architect.registerWebviewProvider(context)
app.architect.registerCommandSelectNextSuggestion(context)
app.architect.registerCommandSelectPreviousSuggestion(context)
app.architect.registerLlavaVscodeModelProvider(context)
app.architect.init()
}
export async function deactivate() {

View file

@ -79,36 +79,7 @@ export const PREDEFINED_LISTS = new Map<string, any>([
"endpoint": "http://127.0.0.1:8010"
}
]],
[PREDEFINED_LISTS_KEYS.TOOLS,
[
{
"name": "Qwen3.5-2B-GGUF:Q8_0 (LOCAL) (CPU)",
"localStartCommand": "llama-server -hf unsloth/Qwen3.5-2B-GGUF:Q8_0 --jinja -c 0 -ub 1024 -b 1024 --cache-reuse 256 --port 8009 --host 127.0.0.1",
"endpoint": "http://localhost:8009",
"aiModel": "",
"isKeyRequired": false
},
{
"name": "Qwen3.5-2B-GGUF:Q8_0 (LOCAL) (VRAM>3GB)",
"localStartCommand": "llama-server -hf unsloth/Qwen3.5-2B-GGUF:Q8_0 --jinja -ngl 99 -c 0 -ub 1024 -b 1024 --cache-reuse 256 --port 8009 --host 127.0.0.1",
"endpoint": "http://localhost:8009",
"aiModel": "",
"isKeyRequired": false
},
{
"name": "Qwen3.5-4B-GGUF:Q8_0 (LOCAL) (VRAM>6GB)",
"localStartCommand": "llama-server -hf unsloth/Qwen3.5-4B-GGUF:Q8_0 --jinja -c 0 -ub 1024 -b 1024 --cache-reuse 256 --port 8009 --host 127.0.0.1",
"endpoint": "http://localhost:8009",
"aiModel": "",
"isKeyRequired": false
},
{
"name": "Qwen3.5-9B-GGUF:Q8_0 (LOCAL) (VRAM>12GB)",
"localStartCommand": "llama-server -hf unsloth/Qwen3.5-9B-GGUF:Q8_0 --jinja -c 0 -ub 1024 -b 1024 --cache-reuse 256 --port 8009 --host 127.0.0.1",
"endpoint": "http://localhost:8009",
"aiModel": "",
"isKeyRequired": false
},
[PREDEFINED_LISTS_KEYS.TOOLS, [
{
"name": "OpenAI gpt-oss 20B (LOCAL) (> 19GB VRAM)",
"localStartCommand": "llama-server -hf ggml-org/gpt-oss-20b-GGUF -c 0 --jinja --reasoning-format none -np 2 --port 8009",
@ -135,17 +106,11 @@ export const PREDEFINED_LISTS = new Map<string, any>([
"aiModel": "z-ai/glm-4.5-air"
},
{
"name": "Qwen: Qwen3 235B A22B Thinking 2507 - 262 144 context $0.118/M input tokens $0.118/M output tokens (OpenRouter)",
"name": "Qwen: Qwen3 235B A22B Thinking 2507 - 262.144 context $0.118/M input tokens $0.118/M output tokens (OpenRouter)",
"endpoint": "https://openrouter.ai/api",
"isKeyRequired": true,
"aiModel": "qwen/qwen3-235b-a22b-thinking-2507"
},
{
"name": "Qwen: Qwen3 VL 30B A3B Instruct - 262 144 context $0.15/M input tokens $0.60/M output tokens (OpenRouter)",
"endpoint": "https://openrouter.ai/api",
"isKeyRequired": true,
"aiModel": "qwen/qwen3-vl-30b-a3b-instruct"
},
{
"name": "Qwen: Qwen3 Coder - 262K context $0.30/M input tokens $1.20/M output tokens (OpenRouter)",
"endpoint": "https://openrouter.ai/api",
@ -740,132 +705,9 @@ export const PREDEFINED_LISTS = new Map<string, any>([
"delete_file",
"get_diff",
"edit_file",
"ask_user",
"update_todo_list",
"delegate_task"
"ask_user"
]
},
{
"name": "Unite test writer",
"description": "Writes the unit tests. The input should provide a path to a source file to be tested.",
"systemInstruction": [
"You are an expert software engineer specializing in writing unit tests. Your task is to generate highquality, reliable, and maintainable unit tests based on the users instructions and the provided source code. You must infer the programming language, testing framework, and project conventions from the source file and any accompanying context (such as imports, file extensions, or existing test files).",
"Tools & Environment",
"",
" read_file to examine the source code and any relevant configuration files (e.g., package.json, pom.xml, requirements.txt, Cargo.toml, etc.).",
"",
" edit_file to create or modify test files.",
"",
" run_terminal_command to execute tests and report results.",
"",
"Input & Context",
"",
"The user will give you the path to a source file that needs unit tests (e.g., src/services/user_service.py, lib/user.dart, internal/user.go). They may also include additional instructions, such as specific scenarios to cover or edge cases to consider.",
"Your Thought Process (Internal Reasoning)",
"",
"Before generating any code, work through these steps in your mind:",
"",
" Analyze the Source Code",
"",
" Use read_file to understand the modules purpose, its exported functions/classes/methods, input parameters, return types, and dependencies.",
"",
" Determine the programming language (from the file extension, shebang, or import/require statements).",
"",
" Identify all public APIs that need testing.",
"",
" Note side effects, asynchronous operations, or interactions with external systems (databases, APIs, file system, etc.).",
"",
" Infer the Testing Conventions",
"",
" Look for an existing test directory (e.g., test/, tests/, spec/, __tests__/) and the naming pattern of existing test files (e.g., *.test.js, *_test.py, *_spec.rb).",
"",
" Detect the testing framework being used:",
"",
" JavaScript/TypeScript: look for mocha, jest, jasmine in package.json.",
"",
" Python: look for pytest, unittest in imports or config files.",
"",
" Java: look for JUnit in pom.xml or build.gradle.",
"",
" Go: look for testing package imports, etc.",
"",
" Determine the preferred assertion style (e.g., assert module, expect, should, assertThat).",
"",
" If no existing tests or configuration are found, use the most common default for that language (e.g., pytest for Python, JUnit 5 for Java, go test for Go, Mocha + assert for Node.js).",
"",
" Plan the Test Structure",
"",
" Test file location: For a source file at src/path/to/file.ext, the test file should normally be placed at test/path/to/file_test.ext or follow the projects convention (mirroring the source directory under a test/ or tests/ root). Ensure the directory structure is created if needed.",
"",
" Plan the outer test suite (e.g., describe('moduleName', ...) in Mocha, a test class in JUnit, or a modulelevel docstring in pytest).",
"",
" Plan nested suites for each function or method.",
"",
" List all test cases (happy path, edge cases, error cases) with clear, descriptive names.",
"",
" Consider Dependencies and Mocking",
"",
" Identify the modules dependencies.",
"",
" Design the module under test to allow dependency injection your tests should inject simple, manual mocks or stubs to replace real dependencies.",
"",
" Do not introduce thirdparty mocking libraries unless they are already present in the project. Rely on manual mocks (e.g., creating test doubles yourself).",
"",
" Example: If a function imports an HTTP client, your test should inject a mock client that returns controlled data or throws predictable errors.",
"",
"Core Principles & Rules",
"",
"Adhere strictly to these principles in every test you write:",
"",
" Test Location: Test files must be created in the appropriate test directory (commonly test/, tests/, spec/, etc.) mirroring the source structure. Use the naming convention inferred from the project.",
"",
" Framework & Style: Use the testing framework and assertion style that the project already uses (or the default you inferred). Write idiomatic tests for that language.",
"",
" Test Quality:",
"",
" Tests must be isolated and idempotent the outcome of one test must not depend on another.",
"",
" Each test should verify one specific behavior.",
"",
" Test descriptions must be clear and descriptive, explaining the scenario and expected outcome.",
"",
" Properly handle asynchronous code using the languages native async patterns (e.g., async/await, Future, Promise). Ensure the test framework waits for completion.",
"",
" Reset any module state or mocks in setup/teardown hooks (e.g., beforeEach, setUp, @BeforeEach) to guarantee tests can run in any order.",
"",
" Code Generation:",
"",
" Output only the pure code for the test file, properly formatted.",
"",
" Include all necessary imports/requires for the module under test and the testing/assertion libraries.",
"",
" Import the actual functions/classes from the source file. Mocking is done inside the test, not by mocking the import itself.",
"",
" No Source Modification: You cannot modify the source code. If the source is untestable due to poor design (e.g., hardcoded dependencies), inform the user of the challenges and suggest refactoring the source to allow proper unit testing.",
"",
"Output Format",
"",
"Your final response must contain:",
"",
" A brief, nontechnical confirmation stating the language you inferred and the test file path you will create.",
"",
"Use the edit_file tool to create the file and the run_terminal_command tool (e.g., npx mocha 'test/services/userService.spec.ts') to verify your work, reporting the results back to the user.",
"",
"Crucially, you cannot modify the source code itself. If the source code is not testable due to poor design (e.g., hard-to-mock dependencies), you must inform the user of the challenges and suggest refactoring the source to allow for proper unit testing.",
""
],
"tools": [
"run_terminal_command",
"search_source",
"read_file",
"list_directory",
"regex_search",
"delete_file",
"edit_file",
"update_todo_list"
],
"subagentEnabled": false
},
{
"name": "Ask",
"description": "This is an agent for questions about source code without changing it.",
@ -916,87 +758,6 @@ export const PREDEFINED_LISTS = new Map<string, any>([
"get_diff",
"ask_user"
]
},
{
"name": "Agent creator",
"description": "Creates new agent. Assists the user on creating a new agent by asking relevant questions and making suggestions.",
"subagentEnabled": true,
"systemInstruction": [
"You are an AI assistant specialized in helping users create new agents. Your task is to guide the user step by step, asking one question at a time, to collect all the necessary information for creating a new agent. Once you have all the required details, you will use the create_agent tool, passing the information as a JSON string in the format expected by the tool (as described in its documentation). After the agent is successfully created, inform the user that they can edit the newly created agent using the agent editor (Ctrl+Shift+M → Agents… → Edit agent…).",
"",
"Required Information:",
"",
" name (string): The name of the new agent.",
"",
" description (string): A brief description of what the agent does.",
"",
" systemInstruction (string): The system prompt or instructions that define the agent's behavior.",
"",
"Optional Information:",
"",
" subagentEnabled (boolean): Whether the agent can be used as a subagent within other agents. Ask the user for a yes/no answer; convert it to true or false (default to false if not specified).",
"",
" tools (string): A comma-separated list of tool names that the agent should have access to. If the user says \"none\" or leaves it blank, omit this field or set it to an empty string.",
"",
"Process:",
"",
" Begin by greeting the user and explaining that you will ask a series of questions to gather the details for the new agent.",
"",
" Ask for the name first. Wait for the user's response.",
"",
" After receiving the name, ask for the description.",
"",
" Then ask for the systemInstruction.",
"",
" Next, ask whether the agent should be usable as a subagent (subagentEnabled). Prompt for a yes/no answer. If the answer is ambiguous, ask for clarification.",
"",
" Finally, ask for any tools the agent should have. Prompt for a comma-separated list or indicate that they can say \"none\".",
"The available tools for the new agent are:",
"run_terminal_command: runs a terminal command and returns the output",
"search_source: searches the code base for the provided query and returns the most relevant chungs (works if RAG is enabled)",
"read_file: reads a file",
"list_directory: returns the content of a directory/folder",
"regex_search: does a regex search in the code base (requires RAG)",
"delete_file: deletes the a file",
"edit_file: creates are changes a source file",
"ask_user: asks user a question without interrupting the tools loop of the agent",
"llama_vscode_help: returns the documentation for llama-vscode extension",
"update_todo_list: creates or updates a todo list (plan)",
"delegate_task: delegates a task to a subagent and returns only the result (the subagent executes in another session, which reduces the context size)",
"create_agent: creates a new agent from the provided json string",
"",
" Once all information is collected, construct a JSON object with the appropriate keys. Ensure that boolean values are represented as true or false (without quotes) and that the tools string is included only if provided.",
"",
" Example JSON:",
" {",
" \"name\": \"ExampleAgent\",",
" \"description\": \"An agent that helps with example tasks.\",",
" \"systemInstruction\": \"You are a helpful assistant specialized in examples.\",",
" \"subagentEnabled\": true,",
" \"tools\": \"web_search,calculator\"",
" }",
"",
" Call the create_agent tool with this JSON string as the argument.",
"",
" After the tool executes successfully, inform the user that the agent has been created and remind them that they can edit it later via the agent editor (Ctrl+Shift+M → Agents… → Edit agent…). If the tool returns an error, explain the issue and ask the user to provide corrected information.",
"",
"Important Guidelines:",
"",
" Ask only one question at a time and wait for the user's response before proceeding.",
"",
" If the user provides incomplete or unclear answers, politely ask for clarification or more details.",
"",
" Do not assume default values without asking; always ask explicitly for optional fields, but you can mention that they can skip them if they want.",
"",
" Keep your tone friendly and helpful. Make the process feel like a guided conversation.",
"",
" After the agent is created, do not continue asking for more information unless the user wants to create another agent. If they do, you may restart the process.",
"",
""
],
"tools": [
"create_agent"
]
}
]],
[PREDEFINED_LISTS_KEYS.AGENT_COMMANDS, [

View file

@ -5,14 +5,9 @@ import { Utils } from "./utils"
import { Chat } from "./types"
import { Plugin } from './plugin';
import * as fs from 'fs';
import { SUPPORTED_IMG_FILE_EXTS, UI_TEXT_KEYS } from "./constants";
import path from "path";
import { UI_TEXT_KEYS } from "./constants";
interface Frontmatter {
[key: string]: any;
}
interface Step {
id: string | number;
description: string;
@ -28,8 +23,6 @@ export class LlamaAgent {
private logText = ""
public contexProjectFiles: Map<string,string> = new Map();
public sentContextFiles: Map<string,string> = new Map();
public contextImage: string = "";
public sentContextImages: string[] = [];
private abortController: AbortController | null = null;
constructor(application: Application) {
@ -42,19 +35,6 @@ export class LlamaAgent {
resetMessages = () => {
let systemPromt = this.app.prompts.TOOLS_SYSTEM_PROMPT_ACTION;
if (this.app.isAgentSelected()) systemPromt = this.app.getAgent().systemInstruction.join("\n")
if (this.app.configuration.tool_delegate_task_enabled) {
let agentPromtPrefix = " \n\n " + this.app.prompts.SUBAGENTS_DESCRIPTION;
agentPromtPrefix += " \n\n Subagents:";
let subagentsList = "";
for (let agent of this.app.configuration.agents_list) {
if (agent.subagentEnabled){
subagentsList += " \n" + agent.name + ": " + agent.description;
}
}
if (subagentsList.length > 0) {
systemPromt += agentPromtPrefix + subagentsList;
}
}
let worspaceFolder = "";
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders[0]){
worspaceFolder = " Project root folder: " + vscode.workspace.workspaceFolders[0].uri.fsPath;
@ -69,21 +49,7 @@ export class LlamaAgent {
}
} else {
const absolutePath = Utils.getAbsolutFilePath("llama-vscode-rules.md");
if (fs.existsSync(absolutePath)) {
projectContext += " \n\nAdditional rules from the user: \n" + fs.readFileSync(absolutePath, "utf-8");
}
}
const agentsAbsolutePath = Utils.getAbsolutFilePath("AGENTS.md");
if (fs.existsSync(agentsAbsolutePath)) {
projectContext += " \n\nInstructions from " + agentsAbsolutePath + ": \n" + fs.readFileSync(agentsAbsolutePath, "utf-8");
}
const soulAbsolutePath = Utils.getAbsolutFilePath("SOUL.md");
if (fs.existsSync(soulAbsolutePath)) {
projectContext += " \n\n AI soul desription from " + soulAbsolutePath + ": \n" + fs.readFileSync(soulAbsolutePath, "utf-8");
}
const userInstructionsPath = Utils.getAbsolutFilePath("USER.md");
if (fs.existsSync(userInstructionsPath)) {
projectContext += " \n\nUser profile from " + userInstructionsPath + ": \n" + fs.readFileSync(userInstructionsPath, "utf-8");
if (fs.existsSync(absolutePath)) projectContext += " \n\nAdditional rules from the user: \n" + fs.readFileSync(absolutePath, "utf-8");
}
this.messages = [
{
@ -94,62 +60,29 @@ export class LlamaAgent {
this.logText = "";
}
selectChat = async (chat: Chat) => {
if (chat && chat.defaultAgent) await this.app.agentService.selectAgent(chat.defaultAgent);
selectChat = (chat: Chat) => {
if (chat && chat.defaultAgent) this.app.agentService.selectAgent(chat.defaultAgent);
this.resetMessages();
if (chat){
const currentChat = this.app.getChat();
this.messages = chat.messages??[];
this.logText = chat.log??"";
}
}
// this.app.llamaWebviewProvider.logInUi(this.logText);
this.resetContext();
this.resetContextProjectFiles();
}
resetContext = () => {
resetContextProjectFiles = () => {
this.contexProjectFiles.clear();
this.app.llamaWebviewProvider.updateContextFilesInfo();
this.sentContextFiles.clear();
this.contextImage = "";
this.sentContextImages = [];
}
addContextProjectFile = (fileLongName: string, fileShortName: string) => {
this.contexProjectFiles.set(fileLongName, fileShortName);
}
addContextProjectImage = (imagePath: string) => {
this.contextImage = imagePath;
}
removeContextProjectImage = () => {
this.contextImage = "";
}
selectImageFile = async (): Promise<string> => {
var imgPath = "";
var fileTypes = Object.values(SUPPORTED_IMG_FILE_EXTS)
fileTypes = fileTypes.map(type => type.replace("image/", ""))
const uris = await vscode.window.showOpenDialog({
canSelectMany: false,
openLabel: 'Import Model',
filters: {
'Image Files': fileTypes
},
});
if (!uris || uris.length === 0) {
return "";
}
imgPath = uris[0].fsPath;
return imgPath;
}
removeContextProjectFile = (fileLongName: string) => {
this.contexProjectFiles.delete(fileLongName);
}
@ -158,10 +91,6 @@ export class LlamaAgent {
return this.contexProjectFiles;
}
getContextProjecImage = () => {
return this.contextImage;
}
run = async (query:string, agentCommand?:string) => {
await this.askAgent(query, agentCommand);
@ -212,10 +141,9 @@ export class LlamaAgent {
askAgent = async (query:string, agentCommand?:string): Promise<string> => {
let response = ""
const originalQuery = query;
let toolCallsResult: ChatMessage;
let finishReason:string|undefined = "tool_calls"
this.logText += "***" + query.split(/\r?\n/).join(" \n") + "***" + "\n\n"; // Make sure markdown shows new lines correctly
this.logText += "***" + query.replace("\n", " \n") + "***" + "\n\n"; // Make sure markdown shows new lines correctly
if (!this.app.isToolsModelSelected() && !this.app.configuration.endpoint_tools) {
@ -229,11 +157,6 @@ export class LlamaAgent {
this.summarize();
}
// Get the skills
const skillsFolder = this.app.configuration.skills_folder || Utils.getWorkspaceFolder() + "/" + "skills"
let skillsDesc = this.getSkillsDesc(skillsFolder)
if (skillsDesc) query += "\n\n" + skillsDesc
if (this.contexProjectFiles.size > 0){
query += "\n\nBelow is a context, attached by the user.\n"
for (const [key, value] of this.contexProjectFiles) {
@ -252,13 +175,6 @@ export class LlamaAgent {
this.sentContextFiles.set(key, value);
}
}
const todoFile = Utils.getTodosFilePath()
this.removeFile(todoFile);
if (this.app.configuration.tool_update_todo_list_enabled){
query += "\n\n " + "If the request is complicated or involves multiple steps - use tool update_todo_list."
}
if (agentCommand) {
const commands = this.app.configuration.agent_commands as AgentCommand[];
@ -292,21 +208,14 @@ export class LlamaAgent {
this.resetMessages();
return "agent stopped"
}
iterationsCount++;
iterationsCount++;
try {
if (fs.existsSync(todoFile) && iterationsCount % this.app.configuration.plan_review_frequency == 0){
let goal = "Task: \n" + originalQuery
let currentPlan = "Below is the todo list:\n"
currentPlan += fs.readFileSync(todoFile, "utf-8")
this.messages.push({"role": "user", "content": goal + "\n\n" + currentPlan})
}
let streamed = "";
let data:any = await this.app.llamaServer.getAgentCompletion(this.messages, false, (delta: string) => {
streamed += delta;
this.logText += delta;
this.app.llamaWebviewProvider.logInUi(this.logText);
}, this.abortController?.signal, !this.sentContextImages.includes(this.contextImage)? this.contextImage : "");
if (this.contextImage) this.sentContextImages.push(this.contextImage)
}, this.abortController?.signal);
if (!data) {
this.logText += "No response from AI" + " \n"
this.app.llamaWebviewProvider.logInUi(this.logText);
@ -403,12 +312,18 @@ export class LlamaAgent {
this.logText += " \nAgent session finished. \n\n"
this.app.llamaWebviewProvider.logInUi(this.logText);
this.app.llamaWebviewProvider.setState("AI finished")
await this.updateChat();
let chat = this.app.getChat()
if (!this.app.isChatSelected()){
chat.name = this.logText.slice(0, 25);
chat.id = Date.now().toString(36);
chat.description = new Date().toLocaleString() + " " + this.logText.slice(0,150)
}
chat.messages = this.messages;
chat.log = this.logText;
await this.app.chatService.selectUpdateChat(chat)
// Clean up AbortController
this.abortController = null;
this.removeFile(todoFile);
return response;
}
@ -441,24 +356,6 @@ export class LlamaAgent {
return progress;
}
public async updateChat() {
let chat = this.app.getChat();
if (!this.app.isChatSelected()) {
chat.name = this.logText.slice(0, 25);
chat.id = Date.now().toString(36);
chat.description = new Date().toLocaleString() + " " + this.logText.slice(0, 150);
}
chat.messages = this.messages;
chat.log = this.logText;
await this.app.chatService.selectUpdateChat(chat);
}
private removeFile(todoFile: string) {
if (fs.existsSync(todoFile)) {
fs.unlinkSync(todoFile);
}
}
private async getItemContext(key: string, value: string) {
let itemContext = "";
const document = await vscode.workspace.openTextDocument(vscode.Uri.file(key.split("|")[0]));
@ -473,72 +370,4 @@ export class LlamaAgent {
}
return itemContext;
}
private getSkillsDesc(skillsFolder: string): string {
let desc = ""
if (fs.existsSync(skillsFolder)) {
desc += "<available_skills>"
const items = fs.readdirSync(skillsFolder, { withFileTypes: true });
const folders = items
.filter(item => item.isDirectory())
.map(item => item.name);
for(let folder in folders){
const skillsFile = path.join(skillsFolder, folders[folder], "SKILL.md");
if (fs.existsSync(skillsFile)){
desc += "<skill>"
const frontMatter = this.parseFrontmatter(skillsFile)
desc += `<name>${frontMatter.name}</name>`
desc += `<description>${frontMatter.description}</description>`
desc += `<location>${skillsFile}</location>`
desc += "</skill>"
}
}
desc += "</available_skills>"
}
return desc;
}
private parseFrontmatter(filePath: string): Frontmatter {
try {
const fileContent = fs.readFileSync(filePath, 'utf-8');
// Match frontmatter between --- delimiters
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?/;
const match = fileContent.match(frontmatterRegex);
if (!match) {
return { frontmatter: {}, content: fileContent };
}
const frontmatterText = match[1];
const content = fileContent.slice(match[0].length);
// Parse frontmatter (assuming YAML format)
const frontmatter: Frontmatter = {};
const lines = frontmatterText.split('\n');
for (const line of lines) {
const colonIndex = line.indexOf(':');
if (colonIndex > 0) {
const key = line.slice(0, colonIndex).trim();
const value = line.slice(colonIndex + 1).trim();
// Try to parse as JSON-like values
try {
frontmatter[key] = JSON.parse(value);
} catch {
// Remove quotes if present
frontmatter[key] = value.replace(/^['"](.*)['"]$/, '$1');
}
}
}
return frontmatter;
} catch (error) {
vscode.window.showErrorMessage(`Failed to read or parse file: ${error}`);
return {}
}
}
}

View file

@ -1,237 +0,0 @@
import * as vscode from 'vscode';
import axios from 'axios';
import { Application } from './application';
import { Utils } from './utils';
const VENDOR = 'llama-vscode';
// Default token limits used when the server does not report them
const DEFAULT_MAX_INPUT_TOKENS = 8192;
const DEFAULT_MAX_OUTPUT_TOKENS = 4096;
interface OpenAIModel {
id: string;
object?: string;
}
interface OpenAIModelsResponse {
data: OpenAIModel[];
}
export class LlamaChatModelProvider implements vscode.LanguageModelChatProvider {
private readonly _onDidChangeLanguageModelChatInformation = new vscode.EventEmitter<void>();
readonly onDidChangeLanguageModelChatInformation: vscode.Event<void> =
this._onDidChangeLanguageModelChatInformation.event;
constructor(private readonly app: Application) {}
/** Called by the configuration change handler to notify VS Code that models may have changed. */
notifyModelsChanged(): void {
this._onDidChangeLanguageModelChatInformation.fire();
}
async provideLanguageModelChatInformation(
_options: vscode.PrepareLanguageModelChatModelOptions,
_token: vscode.CancellationToken
): Promise<vscode.LanguageModelChatInformation[]> {
const endpoint = this.getChatEndpoint();
if (!endpoint) {
return [];
}
try {
const requestConfig = this.app.configuration.axiosRequestConfigChat;
const response = await axios.get<OpenAIModelsResponse>(
`${Utils.trimTrailingSlash(endpoint)}/${this.app.configuration.ai_api_version}/models`,
requestConfig
);
if (!response.data?.data?.length) {
return [];
}
return response.data.data.map((model) => ({
id: model.id,
name: model.id,
family: VENDOR,
version: '1',
maxInputTokens: DEFAULT_MAX_INPUT_TOKENS,
maxOutputTokens: DEFAULT_MAX_OUTPUT_TOKENS,
capabilities: {
toolCalling: true,
imageInput: false,
},
}));
} catch {
return [];
}
}
async provideLanguageModelChatResponse(
model: vscode.LanguageModelChatInformation,
messages: readonly vscode.LanguageModelChatRequestMessage[],
options: vscode.ProvideLanguageModelChatResponseOptions,
progress: vscode.Progress<vscode.LanguageModelResponsePart>,
token: vscode.CancellationToken
): Promise<void> {
const endpoint = this.getChatEndpoint();
if (!endpoint) {
throw new Error('No chat endpoint configured');
}
const openaiMessages = messages.map((msg) => ({
role: msg.role === vscode.LanguageModelChatMessageRole.User ? 'user' : 'assistant',
content: msg.content
.map((part: unknown) =>
part instanceof vscode.LanguageModelTextPart ? part.value : ''
)
.join(''),
}));
const tools = options.tools?.map((t: vscode.LanguageModelToolInformation) => ({
type: 'function',
function: {
name: t.name,
description: t.description,
parameters: t.inputSchema,
},
}));
const requestBody: Record<string, unknown> = {
model: model.id,
messages: openaiMessages,
stream: true,
max_tokens: DEFAULT_MAX_OUTPUT_TOKENS,
...(options.modelOptions?.temperature !== undefined && {
temperature: options.modelOptions.temperature,
}),
...(tools?.length && { tools }),
};
const abortController = new AbortController();
token.onCancellationRequested(() => abortController.abort());
const requestConfig = this.app.configuration.axiosRequestConfigTools;
const streamResponse = await axios.post<NodeJS.ReadableStream>(
`${Utils.trimTrailingSlash(endpoint)}/${this.app.configuration.ai_api_version}/chat/completions`,
requestBody,
{ ...requestConfig, responseType: 'stream' as const, signal: abortController.signal }
);
await new Promise<void>((resolve, reject) => {
const readable = streamResponse.data;
let buffer = '';
// Accumulated tool call data indexed by call index
const toolCalls: { id: string; name: string; arguments: string }[] = [];
const finalize = () => {
// Emit any completed tool calls that weren't emitted yet
for (const tc of toolCalls) {
if (tc.id && tc.name) {
try {
progress.report(
new vscode.LanguageModelToolCallPart(tc.id, tc.name, JSON.parse(tc.arguments || '{}'))
);
} catch (e) {
console.warn('[llama-vscode] Failed to parse tool call arguments:', e);
}
}
}
resolve();
};
token.onCancellationRequested(() => {
(readable as any).destroy?.();
resolve();
});
readable.on('data', (chunk: Buffer) => {
buffer += chunk.toString('utf8');
const lines = buffer.split(/\r?\n/);
buffer = lines.pop() ?? '';
for (const line of lines) {
const trimmed = line.trim();
if (!trimmed || !trimmed.startsWith('data:')) {
continue;
}
const payload = trimmed.slice(5).trim();
if (payload === '[DONE]') {
finalize();
readable.removeAllListeners();
return;
}
try {
const json = JSON.parse(payload);
const choice = json.choices?.[0];
if (!choice) {
continue;
}
const delta = choice.delta ?? {};
if (typeof delta.content === 'string' && delta.content) {
progress.report(new vscode.LanguageModelTextPart(delta.content));
}
if (Array.isArray(delta.tool_calls)) {
for (const tc of delta.tool_calls) {
const idx: number = typeof tc.index === 'number' ? tc.index : 0;
if (!toolCalls[idx]) {
toolCalls[idx] = { id: '', name: '', arguments: '' };
}
if (tc.id) {
toolCalls[idx].id = tc.id;
}
if (tc.function?.name) {
toolCalls[idx].name = tc.function.name;
}
if (tc.function?.arguments) {
toolCalls[idx].arguments += tc.function.arguments;
}
}
}
} catch {
// Skip malformed SSE chunks
}
}
});
readable.on('end', () => {
finalize();
});
readable.on('error', (err: Error) => {
reject(err);
});
});
}
provideTokenCount(
_model: vscode.LanguageModelChatInformation,
text: string | vscode.LanguageModelChatRequestMessage,
_token: vscode.CancellationToken
): Thenable<number> {
const content =
typeof text === 'string'
? text
: text.content
.map((p: unknown) => (p instanceof vscode.LanguageModelTextPart ? p.value : ''))
.join('');
// Rough approximation: 1 token ≈ 4 characters. The llama.cpp server does not expose a
// tokenization endpoint via the standard OpenAI API, so we use this heuristic.
// Actual token counts may differ depending on the model's tokenizer.
return Promise.resolve(Math.ceil(content.length / 4));
}
private getChatEndpoint(): string {
const selectedModel = this.app.getToolsModel();
if (selectedModel?.endpoint) {
return selectedModel.endpoint;
}
if (this.app.configuration.endpoint_chat) {
return this.app.configuration.endpoint_chat;
}
if (this.app.configuration.endpoint_tools) {
return this.app.configuration.endpoint_tools;
}
return '';
}
}

View file

@ -1,13 +1,10 @@
import axios, { AxiosRequestConfig } from "axios";
import axios from "axios";
import {Application} from "./application";
import vscode, { Terminal } from "vscode";
import { LlmModel, LlamaChatResponse, LlamaResponse, ChatMessage } from "./types";
import { Utils } from "./utils";
import * as cp from 'child_process';
import * as util from 'util';
import * as fs from 'fs';
import * as path from 'path';
import { ModelType, SUPPORTED_IMG_FILE_EXTS } from "./constants";
const STATUS_OK = 200;
@ -15,6 +12,7 @@ export interface LlamaToolsResponse {
choices: [{
message:{content?: string, tool_calls?:[{id:string, function: {name:string, arguments: string}}]},
finish_reason?: string,
}];
}
@ -108,7 +106,6 @@ export class LlamaServer {
private createRequestPayload(noPredict: boolean, inputPrefix: string, inputSuffix: string, chunks: any[], prompt: string, model: string, nindent?: number) {
if (noPredict) {
return {
id_slot: 0,
input_prefix: inputPrefix,
input_suffix: inputSuffix,
input_extra: chunks,
@ -123,13 +120,11 @@ export class LlamaServer {
}
return {
id_slot: 0,
input_prefix: inputPrefix,
input_suffix: inputSuffix,
input_extra: chunks,
prompt,
n_predict: this.app.configuration.n_predict,
n_cmpl: this.app.configuration.max_parallel_completions,
...this.defaultRequestParams,
...(nindent && { n_indent: nindent }),
t_max_prompt_ms: this.app.configuration.t_max_prompt_ms,
@ -237,44 +232,10 @@ export class LlamaServer {
};
}
private createToolsRequestPayload(messages: ChatMessage[], model: string, stream = false, imagePath: string = "") {
private createToolsRequestPayload(messages: ChatMessage[], model: string, stream = false) {
this.app.tools.addSelectedTools();
let filteredMsgs = this.filterThoughtFromMsgs(messages)
// Add image with base64 encoding
if (imagePath && fs.existsSync(imagePath)) {
var imgType = ""
for (var suffix in SUPPORTED_IMG_FILE_EXTS){
if (imagePath.endsWith(suffix)) {
imgType = SUPPORTED_IMG_FILE_EXTS[suffix];
break;
}
}
if (imgType) {
const imageBuffer = fs.readFileSync(imagePath);
const base64Image = imageBuffer.toString('base64');
const imageMessage = {
role: 'user',
content: [
{
type: 'text',
text: 'Here is an image for context:'
},
{
type: 'image_url',
image_url: {
url: `data:${imgType};base64,${base64Image}`
}
}
]
};
filteredMsgs = (filteredMsgs as any[])
filteredMsgs.push(imageMessage);
}
}
return {
return {
"messages": filteredMsgs,
"stream": stream,
"temperature": 0.8,
@ -285,12 +246,12 @@ export class LlamaServer {
};
}
private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
let filteredMsgs = this.filterThoughtFromMsgs(messages)
const summaryPromptMsgs: ChatMessage[] = [
{
role: 'system',
content: `Summarize the conversation concisely, preserving technical details and code solutions.`
role: 'system',
content: `Summarize the conversation concisely, preserving technical details and code solutions.`
},
...filteredMsgs
];
@ -318,7 +279,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
// else, default to llama.cpp
let { endpoint, model, requestConfig } = this.getComplModelProperties();
if (!endpoint) {
if (!endpoint) {
const selectionMessate = "Select a completion model or an env with completion model to use code completion (code suggestions by AI)."
const shouldSelectModel = await Utils.showUserChoiceDialog(selectionMessate, "Select")
if (shouldSelectModel){
@ -352,7 +313,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
chunks: any,
nindent: number
): Promise<LlamaChatResponse | undefined> => {
let { endpoint, model, requestConfig } = this.getChatModelProperties();
const response = await axios.post<LlamaChatResponse>(
@ -382,8 +343,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
messages: ChatMessage[],
isSummarization = false,
onDelta?: (delta: string) => void,
abortSignal?: AbortSignal,
imagePath = ""
abortSignal?: AbortSignal
): Promise<LlamaToolsResponse | undefined> => {
let selectedModel: LlmModel = this.app.getToolsModel();
let model = this.app.configuration.ai_model;
@ -391,7 +351,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
let endpoint = this.app.configuration.endpoint_tools;
if (selectedModel?.endpoint !== undefined && selectedModel.endpoint) endpoint = selectedModel.endpoint;
let requestConfig = this.app.configuration.axiosRequestConfigTools;
if (selectedModel?.isKeyRequired !== undefined && selectedModel.isKeyRequired){
const apiKey = this.app.persistence.getApiKey(selectedModel.endpoint??"");
@ -404,10 +364,10 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
}
}
}
let uri = `${Utils.trimTrailingSlash(endpoint)}/${this.app.configuration.ai_api_version}/chat/completions`;
let request: any;
if (isSummarization) {
request = this.createGetSummaryRequestPayload(messages, model);
const response = await axios.post<LlamaToolsResponse>(
@ -419,7 +379,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
}
// Streaming branch for tools/agent calls
request = this.createToolsRequestPayload(messages, model, true, imagePath);
request = this.createToolsRequestPayload(messages, model, true);
try {
const streamResponse = await axios.post<any>(
@ -519,7 +479,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
}
};
updateExtraContext = (chunks: any[]): void => {
// If the server is OpenAI compatible, use the OpenAI API to prepare for the next FIM
@ -544,7 +504,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
let endpoint = this.app.configuration.endpoint_embeddings;
if (selectedModel.endpoint) endpoint = selectedModel.endpoint;
let requestConfig = this.app.configuration.axiosRequestConfigEmbeddings;
if (selectedModel.isKeyRequired){
const apiKey = this.app.persistence.getApiKey(selectedModel.endpoint??"");
@ -557,7 +517,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
}
}
}
const response = await axios.post<LlamaEmbeddingsResponse>(
`${Utils.trimTrailingSlash(endpoint)}/v1/embeddings`,
{
@ -698,7 +658,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
name: 'llama-vscode Command Terminal'
});
// }
this.vsCodeCommandTerminal.show(true);
this.vsCodeCommandTerminal.sendText(`echo "Executing: ${command}"`);
try {
@ -707,7 +667,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
// Show output in terminal
this.vsCodeCommandTerminal.sendText(`echo "Command completed successfully"`);
this.vsCodeCommandTerminal.sendText(`echo "Output: ${stdout.trim()}"`);
return { stdout, stderr };
} catch (error: any) {
this.vsCodeCommandTerminal.sendText(`echo "Command failed: ${error.message}"`);
@ -772,7 +732,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
this.vsCodeCommandTerminal = undefined;
}
}
killToolsCmd = (): void => {
if (this.vsCodeToolsTerminal) {
this.vsCodeToolsTerminal.dispose();
@ -788,7 +748,7 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
let endpoint = this.app.configuration.endpoint_chat;
let model = this.app.configuration.ai_model;
let requestConfig = this.app.configuration.axiosRequestConfigChat;
if (!endpoint) {
if (!endpoint) {
endpoint = this.app.configuration.endpoint_tools;
requestConfig = this.app.configuration.axiosRequestConfigTools;
}
@ -833,36 +793,4 @@ private createGetSummaryRequestPayload(messages: ChatMessage[], model: string) {
}
return { endpoint, model, requestConfig };
}
checkHealth = async (modelType: ModelType, model: LlmModel) => {
let requestConfig: AxiosRequestConfig = this.app.configuration.axiosRequestConfigCompl;
switch (modelType) {
case ModelType.Chat:
requestConfig = this.app.configuration.axiosRequestConfigChat;
break;
case ModelType.Completion:
requestConfig = this.app.configuration.axiosRequestConfigCompl;
break;
case ModelType.Tools:
requestConfig = this.app.configuration.axiosRequestConfigTools;
break;
case ModelType.Embeddings:
requestConfig = this.app.configuration.axiosRequestConfigEmbeddings;
break;
}
try {
// TODO:Make sure to work with OpenRauter too
let response = await axios.get(model.endpoint + "/health", requestConfig);
if (!response.data.hasOwnProperty("status")) return "Error: No health status field found";
return response.data.status
} catch (error) {
if (error instanceof TypeError) {
return "TypeError occurred: " + error.message;
} else if (error instanceof ReferenceError) {
return "ReferenceError occurred:" + error.message;
} else {
return "An unexpected Error occurred:" + (error as Error).message;
}
}
}
}

View file

@ -52,7 +52,13 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
this.app.llamaAgent.run(message.text, message.agentCommand);
break;
case 'clearText':
await this.clearChatText(webviewView);
this.app.llamaAgent.resetMessages();
this.app.llamaAgent.resetContextProjectFiles()
await this.app.chatService.selectUpdateChat({name:"", id:""})
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'updateText',
text: ''
});
break;
case 'showChatsHistory':
this.app.chatService.selectChatFromList();
@ -91,12 +97,6 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
case 'moreCompletionModel':
await this.app.modelService.processModelActions(ModelType.Completion);
break;
case 'checkModelHealth':
await this.app.modelService.checkModelHealth(message.model);
break;
case 'selectAgentModel':
await this.app.modelService.selectAgentModel(ModelType.Tools, this.app.configuration.tools_models_list);
break;
case 'moreChatModel':
await this.app.modelService.processModelActions(ModelType.Chat);
break;
@ -118,10 +118,6 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
case 'deselectToolsModel':
await this.app.modelService.deselectAndClearModel(ModelType.Tools);
break;
case 'deselectAgentModel':
this.app.setAgentModel(undefined);
this.updateLlamaView();
break;
case 'deselectAgent':
await this.app.agentService.deselectAgent();
break;
@ -145,11 +141,7 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
break;
case 'selectAgent':
let agentsList = this.app.configuration.agents_list
let shouldContinue = await Utils.showYesNoDialog("This will remove the current conversation. Do you want to continue?")
if (shouldContinue) {
await this.app.agentService.pickAndSelectAgent(agentsList)
await this.clearChatText(webviewView);
}
await this.app.agentService.pickAndSelectAgent(agentsList)
break;
case 'chatWithAI':
this.app.askAi.closeChatWithAi(false);
@ -226,30 +218,6 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
files: Array.from(updatedContextFiles.entries())
});
break;
case 'selectImageFile':
var selImgPath = await this.app.llamaAgent.selectImageFile();
this.app.llamaAgent.addContextProjectImage(selImgPath)
webviewView.webview.postMessage({
command: 'updateContextImage',
image: selImgPath
});
break;
case 'addContextProjectImage':
let imagePath = message.image;
this.app.llamaAgent.addContextProjectImage(imagePath);
const contextImage = this.app.llamaAgent.getContextProjecImage();
webviewView.webview.postMessage({
command: 'updateContextImage',
image: contextImage
});
break;
case 'removeContextProjectImage':
this.app.llamaAgent.removeContextProjectImage();
webviewView.webview.postMessage({
command: 'updateContextImage',
files: ""
});
break;
case 'addEditedAgentTool':
let toolsNames = message.fileLongName.split("|");
this.app.agentService.addEditedAgentTools(toolsNames[0].trim(),toolsNames[1].trim());
@ -272,14 +240,10 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
vscode.window.showErrorMessage("Agent should have a name!")
return;
}
let agentModelToSave: LlmModel | undefined = undefined
if (message.toolsModel) agentModelToSave = this.app.getTmpAgentModel();
let agentToSave: Agent = {
name: message.name,
description: message.description,
subagentEnabled: message.subagentEnabled,
systemInstruction: message.systemInstruction.split(/\r?\n/),
toolsModel: agentModelToSave,
tools: message.tools
}
await this.app.agentService.addUpdateAgent(agentToSave)
@ -296,14 +260,10 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
this.addEditAgent(selectedAgent);
break
case 'addEditAgent':
let toolsModel = Application.emptyModel
if (message.toolsModel) toolsModel = this.app.getTmpAgentModel();
const newAgent: Agent = {
name: message.name,
description: message.description,
subagentEnabled: message.subagentEnabled,
systemInstruction: message.systemInstruction,
toolsModel: toolsModel,
tools: message.tools
}
this.addEditAgent(newAgent);
@ -355,34 +315,17 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
files: Array.from(contextFiles.entries())
});
}, 1000);
}
private async clearChatText(webviewView: vscode.WebviewView) {
this.app.llamaAgent.resetMessages();
this.app.llamaAgent.resetContext();
await this.app.chatService.selectUpdateChat({ name: "", id: "" });
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'updateText',
text: ''
});
webviewView.webview.postMessage({
command: 'updateContextImage',
image: ""
});
}
public addEditAgent(agent: Agent) {
this.app.agentService.resetEditedAgentTools();
agent.tools?.map(tool => this.app.agentService.addEditedAgentTools(tool, ""));
const edAgtools = this.app.agentService.getEditedAgentTools();
this.app.setAgentModel(agent.toolsModel);
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'loadAgent',
name: agent?.name,
description: agent?.description,
subagentEnabled: agent?.subagentEnabled,
systemInstruction: agent?.systemInstruction.join("\n"),
toolsModel: agent?.toolsModel?.name??'',
tools: Array.from(edAgtools.entries())
});
}
@ -399,61 +342,37 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
this.updateSettingInEnvView('enabled', this.app.configuration.enabled);
this.updateSettingInEnvView('rag_enabled', this.app.configuration.rag_enabled);
this.updateSettingInEnvView('env_start_last_used', this.app.configuration.env_start_last_used);
this.updateSettingInEnvView('health_check_compl_enabled', this.app.configuration.health_check_compl_enabled);
this.updateSettingInEnvView('health_check_chat_enabled', this.app.configuration.health_check_chat_enabled);
this.updateSettingInEnvView('health_check_embs_enabled', this.app.configuration.health_check_embs_enabled);
this.updateSettingInEnvView('health_check_tools_enabled', this.app.configuration.health_check_tools_enabled);
}
private updateEmbsModel(status: string = "") {
private updateEmbsModel() {
const currentEmbeddingsModel: LlmModel = this.app.getEmbeddingsModel();
let modelName = currentEmbeddingsModel.name
if (this.app.configuration.health_check_embs_enabled && status && status.toLowerCase() != "ok")
modelName += ": " + status;
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'updateEmbeddingsModel',
model: modelName || 'No model selected'
model: currentEmbeddingsModel.name || 'No model selected'
});
}
private updateChatModel(status: string = "") {
const currentChatModel: LlmModel = this.app.getModel(ModelType.Chat);
let modelName = currentChatModel.name
if (this.app.configuration.health_check_chat_enabled && status && status.toLowerCase() != "ok")
modelName += ": " + status;
private updateChatModel() {
const currentChatModel: LlmModel = this.app.getChatModel();
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'updateChatModel',
model: modelName || 'No model selected'
model: currentChatModel.name || 'No model selected'
});
}
private updateToolsModel(status: string = "") {
const currentToolsModel: LlmModel = this.app.getModel(ModelType.Tools);
let modelName = currentToolsModel.name
if (this.app.configuration.health_check_tools_enabled && status && status.toLowerCase() != "ok")
modelName += ": " + status;
private updateToolsModel() {
const currentToolsModel: LlmModel = this.app.getToolsModel();
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'updateToolsModel',
model: modelName || 'No model selected'
model: currentToolsModel.name || 'No model selected'
});
}
private updateTmpAgentModel() {
const currentTmpAgentModel: LlmModel = this.app.getTmpAgentModel();
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'updateTmpAgentModel',
model: currentTmpAgentModel.name || ''
});
}
public updateComplsModel(status: string = "") {
const currentComplModel: LlmModel = this.app.getModel(ModelType.Completion);
let modelName = currentComplModel.name
if (this.app.configuration.health_check_compl_enabled && status && status.toLowerCase() != "ok")
modelName += ": " + status;
private updateComplsModel() {
const currentToolsModel: LlmModel = this.app.getComplModel();
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {
command: 'updateCompletionModel',
model: modelName || 'No model selected'
model: currentToolsModel.name || 'No model selected'
});
}
@ -527,21 +446,16 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider {
}
public updateLlamaView() {
this.updateModels();
this.updateTmpAgentModel();
this.updateToolsModel();
this.updateChatModel();
this.updateEmbsModel();
this.updateComplsModel();
this.updateAgent();
this.updateEnv();
this.updateSettingsInView();
this.logInUi(this.app.llamaAgent.getAgentLogText())
}
public updateModels() {
this.updateToolsModel(this.app.getModelState(ModelType.Tools));
this.updateChatModel(this.app.getModelState(ModelType.Chat));
this.updateEmbsModel(this.app.getModelState(ModelType.Embeddings));
this.updateComplsModel(this.app.getModelState(ModelType.Completion));
}
public updateContextFilesInfo() {
const fileKeys = this.app.chatContext.getProjectFiles();
vscode.commands.executeCommand('llama-vscode.webview.postMessage', {

View file

@ -2,7 +2,7 @@ import * as crypto from 'crypto';
export class LRUCache {
private capacity: number;
private map: Map<string, string[]>;
private map: Map<string, string>;
constructor(capacity: number) {
if (capacity <= 0) {
@ -18,7 +18,7 @@ export class LRUCache {
* @param key The key to retrieve.
* @returns The value associated with the key, or undefined if the key is not found.
*/
get = (key: string): string[] | undefined => {
get = (key: string): string | undefined => {
if (!this.map.has(key)) {
return undefined;
}
@ -37,7 +37,7 @@ export class LRUCache {
* @param key The key to insert or update.
* @param value The value to associate with the key.
*/
put = (key: string, value: string[]): void => {
put = (key: string, value: string): void => {
if (this.map.has(key)) {
// If the key exists, delete it to refresh its position
this.map.delete(key);

View file

@ -202,114 +202,7 @@ def new_function():
Following these instructions will ensure your edits can be properly applied to the document.
`
// Reused from Roocode. Thanks for the authors for keeping it open source.
TOOL_UPDATE_TODO_LIST_DESCRIPTION = `## update_todo_list
**Description:**
Replace the entire TODO list with an updated checklist reflecting the current state. Always provide the full list; the system will overwrite the previous one. This tool is designed for step-by-step task tracking, allowing you to confirm completion of each step before updating, update multiple task statuses at once (e.g., mark one as completed and start the next), and dynamically add new todos discovered during long or complex tasks.
**Checklist Format:**
- Use a single-level markdown checklist (no nesting or subtasks).
- List todos in the intended execution order.
- Status options:
- [ ] Task description (pending)
- [x] Task description (completed)
- [-] Task description (in progress)
**Status Rules:**
- [ ] = pending (not started)
- [x] = completed (fully finished, no unresolved issues)
- [-] = in_progress (currently being worked on)
**Core Principles:**
- Before updating, always confirm which todos have been completed since the last update.
- You may update multiple statuses in a single update (e.g., mark the previous as completed and the next as in progress).
- When a new actionable item is discovered during a long or complex task, add it to the todo list immediately.
- Do not remove any unfinished todos unless explicitly instructed.
- Always retain all unfinished tasks, updating their status as needed.
- Only mark a task as completed when it is fully accomplished (no partials, no unresolved dependencies).
- If a task is blocked, keep it as in_progress and add a new todo describing what needs to be resolved.
- Remove tasks only if they are no longer relevant or if the user requests deletion.
**Usage Example:**
<update_todo_list>
<todos>
[x] Analyze requirements
[x] Design architecture
[-] Implement core logic
[ ] Write tests
[ ] Update documentation
</todos>
</update_todo_list>
*After completing "Implement core logic" and starting "Write tests":*
<update_todo_list>
<todos>
[x] Analyze requirements
[x] Design architecture
[x] Implement core logic
[-] Write tests
[ ] Update documentation
[ ] Add performance benchmarks
</todos>
</update_todo_list>
**When to Use:**
- The task is complicated or involves multiple steps or requires ongoing tracking.
- You need to update the status of several todos at once.
- New actionable items are discovered during task execution.
- The user requests a todo list or provides multiple tasks.
- The task is complex and benefits from clear, stepwise progress tracking.
**When NOT to Use:**
- There is only a single, trivial task.
- The task can be completed in one or two simple steps.
- The request is purely conversational or informational.
**Task Management Guidelines:**
- Mark task as completed immediately after all work of the current task is done.
- Start the next task by marking it as in_progress.
- Add new todos as soon as they are identified.
- Use clear, descriptive task names.
`
TOOL_UPDATE_TODO_LIST_PARAMETER_DESCRIPTION = `Full markdown checklist in execution order, using [ ] for pending, [x] for completed, and [-] for in progress`
TOOL_DELEGATE_TASK_DESCRIPTION = `Delegates a specific task to a subagent.
Use this when you encounter a subtask that is better handled by a dedicated agent (e.g. providing help for llama.vscode, performing calculations, retrieving specific data) or for optimizing context length.
Provide the subagent's name and a clear, self-contained description of the task to be performed.
Optionally, include relevant context (such as user preferences or key conversation snippets) to help the subagent.
The subagent will execute the task using its own tools and return a result.
If the delegation fails, an error status with details will be returned.`
TOOL_CREATE_AGENT_DESCRIPTION = `Creates a new agent in the system. The agent's configuration must be provided as a JSON string conforming to the schema defined in the description of property "agent_json".
Upon successful creation, returns a confirmation message containing the unique identifier of the new agent. Ensure that any tool names listed in the tools field correspond to existing tools in the system.`
PROPERTY_AGENT_JSON_DESCRIPTION = `A JSON string that defines the agent to be created. The object must include the following fields:
name (string): The name of the agent.
description (string): A brief explanation of the agent's purpose and behavior.
subagentEnabled (boolean): Set to true if this agent can be invoked as a subagent by other agents; otherwise false.
systemInstruction (string): The system prompt or instruction that guides the agent's responses and actions.
tools (string, optional): A comma-separated list of tool names that the agent is permitted to use. Do not include spaces around the commas (e.g., "tool1,tool2,tool3"). If omitted, the agent will have no tools.
Example value:
{
"name": "CustomerSupportAgent",
"description": "Handles customer inquiries and returns troubleshooting steps.",
"subagentEnabled": true,
"systemInstruction": "You are a helpful customer support representative...",
"tools": "searchKnowledgeBase,ticketCreator"
}
`
SUBAGENTS_DESCRIPTION = `Subagents
You have access to specialized subagents via the delegate_task tool. Use it when you encounter a welldefined subtask that can be handled independently for example, providing help for llama.vscode, performing complex calculations, or retrieving data from a specific source.
If the delegation fails (error or timeout), decide whether to retry with a different subagent, handle the task yourself, or report the issue to the user.`
constructor(application: Application) {
this.app = application;

View file

@ -6,7 +6,7 @@ import { Utils } from "../utils";
import * as fs from "fs";
import * as path from "path";
import { PREDEFINED_LISTS } from "../lists";
import { UI_TEXT_KEYS, PERSISTENCE_KEYS, SETTING_NAME_FOR_LIST, PREDEFINED_LISTS_KEYS, ModelType } from "../constants";
import { UI_TEXT_KEYS, PERSISTENCE_KEYS, SETTING_NAME_FOR_LIST, PREDEFINED_LISTS_KEYS } from "../constants";
export class AgentService {
private app: Application;
@ -113,14 +113,7 @@ export class AgentService {
this.app.setAgent(agent);
const allTools = Array.from(this.app.tools.toolsFunc.keys());
for (let toolName of allTools) {
try {
await this.app.configuration.updateConfigValue(`tool_${toolName}_enabled`, agent.tools?.includes(toolName) ?? false);
} catch (err) {
vscode.window.showErrorMessage("Error updating tools configuration.")
}
}
if (agent.toolsModel && agent.toolsModel.name) {
await this.app.modelService.selectStartModel(agent.toolsModel, ModelType.Tools, this.app.modelService.getTypeDetails(ModelType.Tools))
this.app.configuration.updateConfigValue(`tool_${toolName}_enabled`, agent.tools?.includes(toolName) ?? false);
}
await this.app.persistence.setValue(PERSISTENCE_KEYS.SELECTED_AGENT, agent);
this.app.llamaWebviewProvider.updateLlamaView();
@ -179,9 +172,7 @@ export class AgentService {
let agentExisting = agentsList.find(agn => agn.name.trim() == editedAgent.name.trim())
if (agentExisting){
agentExisting.description = editedAgent.description
agentExisting.subagentEnabled = editedAgent.subagentEnabled
agentExisting.systemInstruction = editedAgent.systemInstruction
agentExisting.toolsModel = editedAgent.toolsModel
agentExisting.tools = editedAgent.tools
this.app.configuration.updateConfigValue(settingName, agentsList);
vscode.window.showInformationMessage("The agent is updated: " + agentExisting.name);
@ -362,8 +353,6 @@ export class AgentService {
"\nname: " + agent.name +
"\ndescription: " + agent.description +
"\nsystem prompt: \n" + agent.systemInstruction.join("\n") +
"\nsubagent enabled: " + agent.subagentEnabled +
"\ntools model: \n" + agent.toolsModel?.name +
"\n\ntools: " + (agent.tools ? agent.tools.join(", ") : "");
}

View file

@ -41,16 +41,16 @@ export class ChatService {
}
selectUpdateChat = async (chatToSelect: Chat) => {
if (!chatToSelect.id){
this.app.setChat(chatToSelect);
await this.app.persistence.setValue(PERSISTENCE_KEYS.SELECTED_CHAT, this.app.getChat());
} else {
if (chatToSelect.id != this.app.getChat().id){
await this.updateChatHistory();
this.app.setChat(chatToSelect);
await this.app.persistence.setValue(PERSISTENCE_KEYS.SELECTED_CHAT, chatToSelect);
await this.app.llamaAgent.selectChat(chatToSelect);
this.app.llamaAgent.selectChat(chatToSelect);
this.app.llamaWebviewProvider.updateLlamaView();
}
} else {
this.app.setChat(chatToSelect);
await this.app.persistence.setValue(PERSISTENCE_KEYS.SELECTED_CHAT, this.app.getChat());
}
}
deleteChatFromList = async (chatList: Chat[]) => {

View file

@ -10,7 +10,7 @@ import { Configuration } from "../configuration";
import { PREDEFINED_LISTS } from "../lists";
export class ModelService {
public static readonly emptyModel = {name: ""};
private app: Application;
private strategies: Record<string, IAddStrategy>;
@ -146,11 +146,12 @@ export class ModelService {
};
}
selectModel = async (type: ModelType, modelsList: LlmModel[], shoudStartModel:boolean = true): Promise<LlmModel | undefined> => {
selectModel = async (type: ModelType, modelsList: LlmModel[]): Promise<LlmModel | undefined> => {
const details = this.getTypeDetails(type);
let allModels = modelsList.concat(PREDEFINED_LISTS.get(type) as LlmModel[])
let modelsItems: QuickPickItem[] = this.getModels(modelsList, "", true);
modelsItems = modelsItems.concat(this.getModels(PREDEFINED_LISTS.get(type) as LlmModel[], "(predefined) ", true, modelsList.length));
modelsItems = modelsItems.concat(this.getModels(PREDEFINED_LISTS.get(type) as LlmModel[], "(predefined) ", true, modelsList.length));
const launchToEndpoint = new Map([
["launch_completion", "endpoint"],
@ -181,7 +182,7 @@ export class ModelService {
model = allModels[index];
}
if (shoudStartModel) await this.selectStartModel(model, type, details);
await this.selectStartModel(model, type, details);
return model;
}
@ -195,17 +196,6 @@ export class ModelService {
await details.killCmd();
if (model.localStartCommand) await details.shellCmd(this.sanitizeCommand(model.localStartCommand ?? ""));
await this.app.persistence.setValue(this.getSelectedProp(type), model);
if (type == ModelType.Tools && model?.isKeyRequired !== undefined && model.isKeyRequired){
const apiKey = this.app.persistence.getApiKey(model.endpoint??"");
if (apiKey){
this.app.configuration.axiosRequestConfigTools = {
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
}
}
}
}
public async addModel(type: ModelType, kind: 'local' | 'external' | 'hf' | 'oaiComp'): Promise<void> {
@ -245,7 +235,7 @@ export class ModelService {
}
public async showModelDetails(model: LlmModel): Promise<void> {
await Utils.showOkDialog("Model details: \n\n" + this.getDetails(model));
await Utils.showOkDialog("Model details: " + this.getDetails(model));
}
async exportModel(type: ModelType, modelsList: LlmModel[]): Promise<void> {
@ -401,8 +391,7 @@ export class ModelService {
}
clearModel = (type: ModelType) => {
this.app.setSelectedModel(type, Application.emptyModel);
this.app.setModelState(type, "");
this.app.setSelectedModel(type, ModelService.emptyModel);
this.app.llamaWebviewProvider.updateLlamaView();
}
@ -417,13 +406,8 @@ export class ModelService {
this.app.setSelectedModel(modelType, model);
}
public async selectAgentModel(modelType: ModelType, modelsList: LlmModel[]) {
let model = await this.app.modelService.selectModel(modelType, modelsList, false);
this.app.setAgentModel(model);
}
public getEmptyModel(): LlmModel {
return Application.emptyModel
return ModelService.emptyModel
}
public async checkForToolsModel() {
@ -445,38 +429,4 @@ export class ModelService {
}
else return true;
}
periodicModelHealthUpdate = async () => {
if (this.app.configuration.health_check_interval_s > 0) {
if (this.app.configuration.health_check_compl_enabled && this.app.isComplModelSelected()) {
await this.updateModelState(ModelType.Completion);
}
if (this.app.configuration.health_check_chat_enabled && this.app.isChatModelSelected()) {
await this.updateModelState(ModelType.Chat);
}
if (this.app.configuration.health_check_embs_enabled && this.app.isEmbeddingsModelSelected()) {
await this.updateModelState(ModelType.Embeddings);
}
if (this.app.configuration.health_check_tools_enabled && this.app.isToolsModelSelected()) {
await this.updateModelState(ModelType.Tools);
}
}
}
public async checkModelHealth(modelType: ModelType) {
let healthState = await this.app.llamaServer.checkHealth(modelType, this.app.getModel(modelType));
if (healthState.toLowerCase() == "ok" || healthState.toLowerCase() == "healthy") vscode.window.showInformationMessage(modelType.charAt(0).toUpperCase() + modelType.slice(1) + " model health is OK.");
else vscode.window.showErrorMessage("Error with " + modelType + " model:" + healthState);
this.app.setModelState(modelType, healthState);
}
private async updateModelState(modelType: ModelType) {
let healthState = await this.app.llamaServer.checkHealth(modelType, this.app.getModel(modelType));
let currentHealthState = this.app.getModelState(modelType);
if ((currentHealthState == "" || currentHealthState.toLocaleLowerCase() == "ok" || currentHealthState.toLocaleLowerCase() == "healthy")
&& healthState.toLowerCase() != "ok" && healthState.toLowerCase() != "healthy") {
vscode.window.showErrorMessage("Error with completion model:" + healthState);
}
this.app.setModelState(modelType, healthState.slice(0, 150));
}
}

View file

@ -44,13 +44,13 @@ export class OpenAiCompModelStrategy implements IAddStrategy {
prompt: 'example: http://localhost:8080 or https://openrauter.ai/api'
})??""
isKeyRequired = await Utils.confirmAction(`Is API key required for this endpoint (${endpoint})?`, "");
}
}
if (!endpoint){
vscode.window.showWarningMessage("Endpoint is not provided!")
return;
}
const providerModels: QuickPickItem[] = [];
const models = await this.getModels(endpoint, isKeyRequired);
const models = await this.getModels(endpoint);
if (models.length == 0) {
vscode.window.showInformationMessage("No models are found.")
return
@ -108,50 +108,30 @@ export class OpenAiCompModelStrategy implements IAddStrategy {
}
}
private async getModels(endpoint: string, isKeyRequired: boolean): Promise<OpenAiCompModel[]> {
const hfEndpoint = Utils.trimTrailingSlash(endpoint) + "/v1/models";
// Create a request configuration
let requestConfig: any = {};
if (isKeyRequired) {
// We get the saved key for this specific endpoint
const apiKey = this.app.persistence.getApiKey(endpoint);
if (apiKey) {
requestConfig = {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
};
}
}
private async getModels(endpoint: string): Promise<OpenAiCompModel[]> {
let hfEndpoint = Utils.trimTrailingSlash(endpoint) +"/v1/models";
try {
const result = await axios.default.get(
`${Utils.trimTrailingSlash(hfEndpoint)}`,
requestConfig
let result = await axios.default.get(
`${Utils.trimTrailingSlash(hfEndpoint)}`
);
let models: OpenAiCompModel[] = [];
let modelsList: OpenAiCompModel[] = [];
if (result && result.data && result.data.models) modelsList = result.data.models;
else if (result && result.data && result.data.data) modelsList = result.data.data;
if (modelsList.length > 0) {
for (let mdl of modelsList) {
models.push(mdl);
let modelsList: OpenAiCompModel[] = []
if (result && result.data && result.data.models) modelsList = result.data.models
else if (result && result.data && result.data.data) modelsList = result.data.data
if (modelsList.length > 0){
for(let mdl of modelsList){
models.push(mdl)
}
}
return models;
} catch (error) {
vscode.window.showErrorMessage("Error getting provider models: " + error);
} catch (error){
vscode.window.showErrorMessage("Error getting provider models): " + error)
return [];
}
}
private sanitizeInput(input: string): string {
return input ? input.trim() : '';
}

View file

@ -26,192 +26,6 @@ export class TextEditor {
vscode.commands.executeCommand('setContext', 'textEditSuggestionVisible', visible);
}
private escapeWebviewAttr(value: string): string {
return value
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;');
}
/**
* Multiline instructions (webview); resolves undefined if cancelled or closed.
*/
private showMultilineEditPrompt(): Promise<string | undefined> {
const title =
this.app.configuration.getUiText('How would you like to modify the selected text?') ??
'How would you like to modify the selected text?';
const placeholder =
this.app.configuration.getUiText('Enter your instructions for editing the text...') ??
'Enter your instructions for editing the text...';
const submitLabel = this.app.configuration.getUiText('Submit') ?? 'Submit';
const cancelLabel = this.app.configuration.getUiText('Cancel') ?? 'Cancel';
const emptyHint =
this.app.configuration.getUiText('Please enter editing instructions.') ??
'Please enter editing instructions.';
return new Promise((resolve) => {
let settled = false;
const panel = vscode.window.createWebviewPanel(
'editWithAiMultilinePrompt',
title,
{ viewColumn: vscode.ViewColumn.Beside, preserveFocus: false },
{ enableScripts: true }
);
const finish = (value: string | undefined) => {
if (settled) {
return;
}
settled = true;
resolve(value);
panel.dispose();
};
const cspSource = panel.webview.cspSource;
panel.webview.html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${cspSource} 'unsafe-inline'; script-src 'unsafe-inline' ${cspSource};">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
box-sizing: border-box;
margin: 0;
padding: 12px;
height: 100vh;
display: flex;
flex-direction: column;
font-family: var(--vscode-font-family);
font-size: var(--vscode-font-size);
color: var(--vscode-foreground);
background-color: var(--vscode-editor-background);
}
label {
margin-bottom: 8px;
}
textarea {
flex: 1;
min-height: 120px;
resize: vertical;
padding: 8px;
border: 1px solid var(--vscode-input-border);
background: var(--vscode-input-background);
color: var(--vscode-input-foreground);
font-family: var(--vscode-editor-font-family);
font-size: var(--vscode-editor-font-size);
}
textarea:focus {
outline: 1px solid var(--vscode-focusBorder);
}
.actions {
margin-top: 12px;
display: flex;
gap: 8px;
justify-content: flex-end;
}
/* DOM order is Submit then Cancel (Tab: textarea → Submit → Cancel); flex order keeps Cancel left, Submit right. */
.actions .secondary {
order: 1;
}
.actions .primary {
order: 2;
}
button {
padding: 6px 14px;
border: none;
cursor: pointer;
font-size: var(--vscode-font-size);
}
.primary {
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
}
.primary:hover {
background: var(--vscode-button-hoverBackground);
}
.secondary {
background: var(--vscode-button-secondaryBackground);
color: var(--vscode-button-secondaryForeground);
}
.secondary:hover {
background: var(--vscode-button-secondaryHoverBackground);
}
</style>
</head>
<body>
<label for="prompt">${this.escapeWebviewAttr(title)}</label>
<textarea id="prompt" placeholder="${this.escapeWebviewAttr(placeholder)}" autofocus></textarea>
<div class="actions">
<button type="button" class="primary" id="submit">${this.escapeWebviewAttr(submitLabel)}</button>
<button type="button" class="secondary" id="cancel">${this.escapeWebviewAttr(cancelLabel)}</button>
</div>
<script>
const vscode = acquireVsCodeApi();
const ta = document.getElementById('prompt');
function focusPrompt() {
if (!ta) {
return;
}
ta.focus();
const len = ta.value.length;
ta.setSelectionRange(len, len);
}
window.addEventListener('load', focusPrompt);
requestAnimationFrame(focusPrompt);
setTimeout(focusPrompt, 0);
setTimeout(focusPrompt, 100);
window.addEventListener('message', (event) => {
const data = event.data;
if (data && data.command === 'focusPrompt') {
focusPrompt();
}
});
document.getElementById('submit').addEventListener('click', () => {
vscode.postMessage({ command: 'submit', text: ta.value });
});
document.getElementById('cancel').addEventListener('click', () => {
vscode.postMessage({ command: 'cancel' });
});
</script>
</body>
</html>`;
const requestPromptFocus = () => {
void panel.webview.postMessage({ command: 'focusPrompt' });
};
panel.onDidChangeViewState((e) => {
if (e.webviewPanel.visible) {
requestPromptFocus();
}
});
requestPromptFocus();
setTimeout(requestPromptFocus, 50);
setTimeout(requestPromptFocus, 200);
panel.webview.onDidReceiveMessage((message) => {
if (message.command === 'submit') {
const text = typeof message.text === 'string' ? message.text : '';
if (!text.trim()) {
void vscode.window.showInformationMessage(emptyHint);
return;
}
finish(text);
} else if (message.command === 'cancel') {
finish(undefined);
}
});
panel.onDidDispose(() => {
if (!settled) {
settled = true;
resolve(undefined);
}
});
});
}
async showEditPrompt(editor: vscode.TextEditor) {
let chatUrl = this.app.configuration.endpoint_chat
if (!chatUrl) chatUrl = this.app.configuration.endpoint_tools;
@ -250,7 +64,12 @@ export class TextEditor {
const contextRange = new vscode.Range(startLine, 0, endLine, editor.document.lineAt(endLine).text.length);
const context = editor.document.getText(contextRange);
const prompt = await this.showMultilineEditPrompt();
// Create and show input box
const prompt = await vscode.window.showInputBox({
placeHolder: 'Enter your instructions for editing the text...',
prompt: 'How would you like to modify the selected text?',
ignoreFocusOut: true
});
if (!prompt) {
return;

View file

@ -5,7 +5,6 @@ import path from "path";
import fs from 'fs';
import { Plugin } from './plugin';
import { UI_TEXT_KEYS } from "./constants";
import { Chat, Agent } from "./types";
type ToolsMap = Map<string, (...args: any[]) => any>;
@ -31,9 +30,6 @@ export class Tools {
this.toolsFunc.set("custom_tool", this.customTool)
this.toolsFunc.set("custom_eval_tool", this.customEvalTool)
this.toolsFunc.set("llama_vscode_help", this.llamaVscodeHelp)
this.toolsFunc.set("update_todo_list", this.updateTodoList)
this.toolsFunc.set("delegate_task", this.delegateTask)
this.toolsFunc.set("create_agent", this.createAgent)
this.toolsFuncDesc.set("run_terminal_command", this.runTerminalCommandDesc);
this.toolsFuncDesc.set("search_source", this.searchSourceDesc)
this.toolsFuncDesc.set("read_file", this.readFileDesc)
@ -46,10 +42,7 @@ export class Tools {
this.toolsFuncDesc.set("custom_tool", this.customToolDesc)
this.toolsFuncDesc.set("custom_eval_tool", this.customEvalToolDesc)
this.toolsFuncDesc.set("llama_vscode_help", this.llamaVscodeHelpDesc)
this.toolsFuncDesc.set("update_todo_list", this.updateTodoListDesc)
this.toolsFuncDesc.set("update_todo_list", this.updateTodoListDesc);
this.toolsFuncDesc.set("delegate_task", this.delegateTaskDesc)
this.toolsFuncDesc.set("create_agent ", this.createAgentDesc);
}
public runTerminalCommand = async (args: string ) => {
@ -383,113 +376,7 @@ export class Tools {
public llamaVscodeHelpDesc = async (args: string) => {
return "llama_vscode_help tool is executed. "
}
public updateTodoList = async (args: string) => {
let params = JSON.parse(args);
if (params.todos == undefined) return "The todos are not provided."
let filePath = Utils.getTodosFilePath();
try {
fs.writeFileSync(filePath, params.todos, 'utf8');
} catch (error) {
return `Error creating/updating todos`
}
return "The todos are created/updated."
}
public updateTodoListDesc = async (args: string) => {
let ret = "update_todo_list tool is executed. \n\n"
let params = JSON.parse(args);
if (params.todos) ret += params.todos.split(/\r?\n/).join(" \n")
return ret
}
public delegateTask = async (args: string) => {
let params = JSON.parse(args);
let finalAnswer = "No answer from the subagent.";
if (params.subagent_name) {
// store current agent
await this.app.llamaAgent.updateChat()
let parentChat = this.app.getChat();
parentChat.defaultAgent = this.app.getAgent();
let subagent: Agent = this.app.configuration.agents_list.find(agent => agent.name == params.subagent_name)
if (!subagent) return "No subagent found with name " + params.subagent_name;
this.app.llamaAgent.resetContext();
let newChatName = "delegate_task" + Date.now()
let newSubagent: Agent = { ...subagent };
if (subagent.tools){
// clone the tools to avoid changing the original agent
newSubagent.tools = [...subagent.tools];
} else {
newSubagent.tools = [];
}
newSubagent.tools.push("ask_user")
// The goal is to get the answer from the subagent in one tools loop - so use a tool call if user input is needed
newSubagent.systemInstruction.push("For questions to the user, please use the tool 'ask_user'.")
let newChat: Chat = {
name: newChatName,
id: newChatName,
messages: [],
defaultAgent: newSubagent,
log: "subagent: " + params.subagent_name + " \n \n"
}
await this.app.chatService.selectUpdateChat(newChat)
if (params.task) {
finalAnswer = await this.app.llamaAgent.askAgent(params.task)
} else {
return "No task provided."
}
await this.app.chatService.selectUpdateChat(parentChat)
this.app.llamaWebviewProvider.setState("AI is working")
} else {
return "No subagent name provided."
}
return finalAnswer
}
public delegateTaskDesc = async (args: string) => {
let ret = "delegate_task tool is executed. \n\n"
let params = JSON.parse(args);
if (params.task && params.subagent_name) ret += "subagent: " + params.subagent_name + "\ntask: " + params.task
return ret.split(/\r?\n/).join(" \n")
}
public createAgent = async (args: string) => {
let params = JSON.parse(args);
let finalAnswer = "The agent is created";
if (params.agent_json) {
let receivedAgent = JSON.parse(params.agent_json)
let newAgent:Agent = {
name: receivedAgent.name,
description: receivedAgent.description,
subagentEnabled: receivedAgent.subagentEnabled??false,
systemInstruction: receivedAgent.systemInstruction.split(/\r?\n/)
}
if (receivedAgent.tools) {
newAgent.tools = receivedAgent.tools.split(",")
}
// TODO check if one more parsing of agent_json is needed
await this.app.agentService.addUpdateAgent(newAgent)
} else {
return "No agent provided."
}
return finalAnswer
}
public createAgentDesc = async (args: string) => {
let ret = "create_agent tool is executed. \n\n"
// let params = JSON.parse(args);
// if (params.task && params.subagent_name) ret += "subagent: " + params.subagent_name + "\ntask: " + params.task
return ret.split(/\r?\n/).join(" \n")
}
public init = () => {
this.tools = [
@ -650,8 +537,8 @@ export class Tools {
"description": "Gets the files changes since last commit",
"parameters": {
"type": "object",
"properties": {},
"required": [],
"required": [
],
},
"strict": true
}
@ -751,70 +638,6 @@ export class Tools {
}
}
] : []),
...(this.app.configuration.tool_update_todo_list_enabled ? [
{
"type": "function",
"function": {
"name": "update_todo_list",
"description": this.app.prompts.TOOL_UPDATE_TODO_LIST_DESCRIPTION,
"parameters": {
"type": "object",
"properties": {
"todos": {
"description": this.app.prompts.TOOL_UPDATE_TODO_LIST_PARAMETER_DESCRIPTION,
"type": "string",
},
},
"required": [],
},
"strict": true
}
}
] : []),
...(this.app.configuration.tool_create_agent_enabled ? [
{
"type": "function",
"function": {
"name": "create_agent",
"description": this.app.prompts.TOOL_CREATE_AGENT_DESCRIPTION,
"parameters": {
"type": "object",
"properties": {
"agent_json": {
"description": this.app.prompts.PROPERTY_AGENT_JSON_DESCRIPTION,
"type": "string",
},
},
"required": [],
},
"strict": true
}
}
] : []),
...(this.app.configuration.tool_delegate_task_enabled ? [
{
"type": "function",
"function": {
"name": "delegate_task",
"description": this.app.prompts.TOOL_DELEGATE_TASK_DESCRIPTION,
"parameters": {
"type": "object",
"properties": {
"subagent_name": {
"description": "Name of the subagent to invoke. Must be one of the available subagents listed in the system prompt.",
"type": "string",
},
"task": {
"description": "Description of the task to be delegated to the subagent.",
"type": "string",
},
},
"required": [],
},
"strict": true
}
}
] : []),
]
for (let tool of this.app.configuration.tools_custom){

View file

@ -197,5 +197,4 @@ export const translations: string[][] = [
["Copy agent...", "Копиране на агент...", "Agent kopieren...", "Копировать агента...", "Copiar agente...", "复制代理...", "Copier l'agent..."],
["Edit multiple files with AI", "Редактиране на множество файлове с изкуствен интелект", "Mehrere Dateien mit KI bearbeiten", "Редактировать несколько файлов с ИИ", "Editar múltiples archivos con IA", "使用人工智能编辑多个文件", "Modifier plusieurs fichiers avec IA"],
["Asks for glob pattern and prompt and edits with AI the files, which match the glob pattern with the provided prompt.", "Пита за шаблон за обхват и инструкция, след което редактира с изкуствен интелект файловете, които отговарят на шаблона, със зададената инструкция.", "Fragt nach einem Glob-Muster und einer Eingabeaufforderung und bearbeitet mit KI die Dateien, die dem Glob-Muster mit der bereitgestellten Eingabeaufforderung entsprechen.", "Запрашивает шаблон glob и подсказку, а затем редактирует с помощью ИИ файлы, соответствующие шаблону, с предоставленной подсказкой.", "Pide un patrón glob y un mensaje, y edita con IA los archivos que coinciden con el patrón glob con el mensaje proporcionado.", "请求输入通配符模式和提示词,然后使用人工智能编辑符合该通配符模式的文件,并根据提供的提示词进行修改。", "Demande un motif glob et une invite, puis modifie avec IA les fichiers correspondant au motif glob avec l'invite fournie."],
["This will remove the current conversation. Do you want to continue?", "Това ще премахне текущия разговор. Искате ли да продължите?", "Dadurch wird die aktuelle Unterhaltung gelöscht. Möchten Sie fortfahren?", "Это удалит текущий разговор. Хотите продолжить?", "Esto eliminará la conversación actual. ¿Quieres continuar?", "这将删除当前对话。是否要继续?", "Cela supprimera la conversation en cours. Voulez-vous continuer?"],
];

View file

@ -60,9 +60,7 @@ export interface Env {
export interface Agent {
name: string,
description?: string,
subagentEnabled?: boolean,
systemInstruction: string[],
toolsModel?: LlmModel,
systemInstruction: string[]
tools?: string[]
}

View file

@ -905,25 +905,4 @@ export class Utils {
return lines.join('\n'); // Join the remaining lines back into a string
}
static getTodosFilePath = () => {
let filePath = "";
const TODO_FILE = '.llama-vscode-todos.md';
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) {
filePath = TODO_FILE;
} else {
const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath;
filePath = path.join(workspaceRoot, TODO_FILE);
}
return filePath;
}
static getWorkspaceFolder = () => {
const workspaceFolders = vscode.workspace.workspaceFolders;
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) {
return "";
} else {
return vscode.workspace.workspaceFolders[0].uri.fsPath;
}
}
}

View file

@ -1,77 +0,0 @@
// Temporary shim for VS Code LM chat-provider typings.
// Some @types/vscode versions ship parts of the LM API behind proposal typings.
// This keeps `tsc` happy while still targeting the runtime VS Code API.
import type * as vscode from 'vscode';
declare module 'vscode' {
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace lm {
function registerLanguageModelChatProvider(
vendor: string,
provider: LanguageModelChatProvider
): vscode.Disposable;
}
export interface PrepareLanguageModelChatModelOptions {}
export interface LanguageModelChatCapabilities {
toolCalling?: boolean;
imageInput?: boolean;
}
export interface LanguageModelChatInformation {
id: string;
name: string;
family?: string;
version?: string;
maxInputTokens?: number;
maxOutputTokens?: number;
capabilities?: LanguageModelChatCapabilities;
}
export type LanguageModelChatMessagePart = unknown | LanguageModelTextPart;
export interface LanguageModelChatRequestMessage {
role: LanguageModelChatMessageRole;
content: readonly LanguageModelChatMessagePart[];
}
export interface ProvideLanguageModelChatResponseOptions {
tools?: readonly LanguageModelToolInformation[];
modelOptions?: {
temperature?: number;
[key: string]: unknown;
};
[key: string]: unknown;
}
export type LanguageModelResponsePart =
| LanguageModelTextPart
| LanguageModelToolCallPart
| unknown;
export interface LanguageModelChatProvider {
onDidChangeLanguageModelChatInformation?: vscode.Event<void>;
provideLanguageModelChatInformation(
options: PrepareLanguageModelChatModelOptions,
token: vscode.CancellationToken
): vscode.ProviderResult<LanguageModelChatInformation[]>;
provideLanguageModelChatResponse(
model: LanguageModelChatInformation,
messages: readonly LanguageModelChatRequestMessage[],
options: ProvideLanguageModelChatResponseOptions,
progress: vscode.Progress<LanguageModelResponsePart>,
token: vscode.CancellationToken
): vscode.ProviderResult<void>;
provideTokenCount(
model: LanguageModelChatInformation,
text: string | LanguageModelChatRequestMessage,
token: vscode.CancellationToken
): vscode.ProviderResult<number>;
}
}

View file

@ -24,9 +24,6 @@ const App: React.FC<AppProps> = () => {
const [currentToolsModel, setCurrentToolsModel] = useState<string>(
initialState.currentToolsModel || noModelSelected
);
const [currentAgentModel, setCurrentAgentModel] = useState<string>(
initialState.currentAgentModel || noModelSelected
);
const [currentChatModel, setCurrentChatModel] = useState<string>(
initialState.currentChatModel || noModelSelected
);
@ -49,9 +46,8 @@ const App: React.FC<AppProps> = () => {
initialState.view || noViewSet
);
const [contextFiles, setContextFiles] = useState<Map<string, string>>(new Map());
const [imagePath, setContextImage] = useState<string>("");
const [agentEditTools, setAgentEditTools] = useState<Map<string, string>>(new Map());
const [agentEditDetails, setAgentEditDetails] = useState<{name:string, description:string, systemInstruction:string, toolsModel: string, subagentEnabled: boolean}>({name:"", description:"", systemInstruction:"", toolsModel:"", subagentEnabled: false});
const [agentEditDetails, setAgentEditDetails] = useState<{name:string, description:string, systemInstruction:string}>({name:"", description:"", systemInstruction:""});
// Save state to VS Code whenever it changes
useEffect(() => {
@ -62,13 +58,12 @@ const App: React.FC<AppProps> = () => {
currentChatModel,
currentEmbeddingsModel,
currentCompletionModel,
currentAgentModel,
currentAgent,
currentEnv: currentEnv,
currentState,
view
});
}, [displayText, inputText, currentToolsModel, currentChatModel, currentEmbeddingsModel, currentCompletionModel, currentAgentModel, currentAgent, currentEnv, currentState, view]);
}, [displayText, inputText, currentToolsModel, currentChatModel, currentEmbeddingsModel, currentCompletionModel, currentAgent, currentEnv, currentState, view]);
useEffect(() => {
// Listen for messages from the extension
@ -78,9 +73,6 @@ const App: React.FC<AppProps> = () => {
case 'updateToolsModel':
setCurrentToolsModel(message.model || noModelSelected);
break;
case 'updateTmpAgentModel':
setCurrentAgentModel(message.model || "");
break;
case 'updateChatModel':
setCurrentChatModel(message.model || noModelSelected);
break;
@ -102,15 +94,11 @@ const App: React.FC<AppProps> = () => {
case 'updateContextFiles':
setContextFiles(new Map(message.files || []));
break;
case 'updateContextImage':
setContextImage(message.image || "");
break;
case 'updateAgentEdit':
setAgentEditDetails({name: message.name, description: message.description, systemInstruction: message.systemInstruction, toolsModel: message.toolsModel,subagentEnabled: message.subagentEnabled});
setAgentEditDetails({name: message.name, description: message.description, systemInstruction: message.systemInstruction});
break;
case 'loadAgent':
setAgentEditDetails({name: message.name, description: message.description, systemInstruction: message.systemInstruction, toolsModel: message.toolsModel, subagentEnabled: message.subagentEnabled});
setCurrentAgentModel(message.toolsModel);
setAgentEditDetails({name: message.name, description: message.description, systemInstruction: message.systemInstruction});
setAgentEditTools(new Map(message.tools || []));
break;
default:
@ -217,8 +205,6 @@ const App: React.FC<AppProps> = () => {
setCurrentState={setCurrentState}
contextFiles={contextFiles}
setContextFiles={setContextFiles}
imagePath={imagePath}
setContextImage={setContextImage}
/>
</div>
)}
@ -229,7 +215,7 @@ const App: React.FC<AppProps> = () => {
<AgentEditor
inputText={inputText}
setInputText={setInputText}
currentAgentModel={currentAgentModel}
currentToolsModel={currentToolsModel}
currentAgent={currentAgent}
currentState={currentState}
setCurrentState={setCurrentState}

View file

@ -10,10 +10,6 @@ interface AddEnvViewProps {
completionsEnabled?: boolean;
ragEnabled?: boolean;
autoStartEnv?: boolean;
healthCheckComplEnabled?: boolean;
healthCheckChatEnabled?: boolean;
healthCheckEmbsEnabled?: boolean,
healthCheckToolsEnabled?: boolean
}
const noModelSelected = 'No model selected';
@ -27,19 +23,11 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
currentAgent,
completionsEnabled = false,
ragEnabled = false,
autoStartEnv = false,
healthCheckComplEnabled = false,
healthCheckChatEnabled = false,
healthCheckEmbsEnabled = false,
healthCheckToolsEnabled = false
autoStartEnv = false
}) => {
const [isCompletionsEnabled, setIsCompletionsEnabled] = useState(completionsEnabled);
const [isRagEnabled, setIsRagEnabled] = useState(ragEnabled);
const [isAutoStartEnv, setIsAutoStartEnv] = useState(autoStartEnv);
const [isHealthCheckComplEnabled, setIsHealthCheckComplEnabled] = useState(healthCheckComplEnabled);
const [isHealthCheckChatEnabled, setIsHealthCheckChatEnabled] = useState(healthCheckChatEnabled);
const [isHealthCheckEmbsEnabled, setIsHealthCheckEmbsEnabled] = useState(healthCheckEmbsEnabled);
const [isHealthCheckToolsEnabled, setIsHealthCheckToolsEnabled] = useState(healthCheckToolsEnabled);
// Get the VS Code setting on component mount
useEffect(() => {
@ -62,30 +50,6 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
key: 'env_start_last_used'
});
}, 1000);
setTimeout(() => {
vscode.postMessage({
command: 'getVscodeSetting',
key: 'health_check_compl_enabled'
});
}, 1000);
setTimeout(() => {
vscode.postMessage({
command: 'getVscodeSetting',
key: 'health_check_chat_enabled'
});
}, 1000);
setTimeout(() => {
vscode.postMessage({
command: 'getVscodeSetting',
key: 'health_check_embs_enabled'
});
}, 1000);
setTimeout(() => {
vscode.postMessage({
command: 'getVscodeSetting',
key: 'health_check_tools_enabled'
});
}, 1000);
}, []);
// Listen for messages from the extension
@ -93,29 +57,9 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
const handleMessage = (event: MessageEvent) => {
const message = event.data;
if (message.command === 'vscodeSettingValue') {
switch (message.key) {
case 'health_check_compl_enabled':
setIsHealthCheckComplEnabled(message.value);
break;
case 'health_check_chat_enabled':
setIsHealthCheckChatEnabled(message.value);
break;
case 'health_check_embs_enabled':
setIsHealthCheckEmbsEnabled(message.value);
break;
case 'health_check_tools_enabled':
setIsHealthCheckToolsEnabled(message.value);
break;
case 'enabled':
setIsCompletionsEnabled(message.value);
break;
case 'rag_enabled':
setIsRagEnabled(message.value);
break;
case 'env_start_last_used':
setIsAutoStartEnv(message.value);
break;
}
if (message.key === 'enabled') setIsCompletionsEnabled(message.value);
else if (message.key === 'rag_enabled') setIsRagEnabled(message.value);
else if (message.key === 'env_start_last_used') setIsAutoStartEnv(message.value);
}
};
@ -159,14 +103,6 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
});
};
const handleHealthCheck = (model: string) => {
vscode.postMessage({
command: 'checkModelHealth',
model
});
};
const handleMoreChatModel = () => {
vscode.postMessage({
command: 'moreChatModel'
@ -322,16 +258,6 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
</button>
)}
<span className="model-text">{currentCompletionModel}</span>
{currentCompletionModel != noModelSelected && isHealthCheckComplEnabled && (
<button
onClick={()=>handleHealthCheck("completion")}
title={`Check Health of Completion Model`}
className="modern-btn secondary"
style={{ color: currentCompletionModel.includes("Error") ? "red" : "green" }}
>
{currentCompletionModel.includes("Error") ? "X": "V"}
</button>
)}
{currentCompletionModel === noModelSelected && (
<button
onClick={handleMoreCompletionModel}
@ -374,16 +300,6 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
</button>
)}
<span className="model-text">{currentChatModel}</span>
{currentChatModel != noModelSelected && isHealthCheckChatEnabled && (
<button
onClick={()=>handleHealthCheck("chat")}
title={`Check Health of Chat Model`}
className="modern-btn secondary"
style={{ color: currentChatModel.includes("Error") ? "red" : "green" }}
>
{currentChatModel.includes("Error") ? "X": "V"}
</button>
)}
{currentChatModel === noModelSelected && (
<button
onClick={handleMoreChatModel}
@ -426,16 +342,6 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
</button>
)}
<span className="model-text">{currentEmbeddingsModel}</span>
{currentEmbeddingsModel != noModelSelected && isHealthCheckEmbsEnabled && (
<button
onClick={()=>handleHealthCheck("embeddings")}
title={`Check Health of Embeddings Model`}
className="modern-btn secondary"
style={{ color: currentEmbeddingsModel.includes("Error") ? "red" : "green" }}
>
{currentEmbeddingsModel.includes("Error") ? "X": "V"}
</button>
)}
{currentEmbeddingsModel === noModelSelected && (
<button
onClick={handleMoreEmbeddingsModel}
@ -479,16 +385,6 @@ const AddEnvView: React.FC<AddEnvViewProps> = ({
</button>
)}
<span className="model-text">{currentToolsModel}</span>
{currentToolsModel != noModelSelected && isHealthCheckToolsEnabled && (
<button
onClick={()=>handleHealthCheck("tools")}
title={`Check Health of Tools Model`}
className="modern-btn secondary"
style={{ color: currentToolsModel.includes("Error") ? "red" : "green" }}
>
{currentToolsModel.includes("Error") ? "X": "V"}
</button>
)}
{currentToolsModel === noModelSelected && (
<button
onClick={handleMoreToolsModel}

View file

@ -4,20 +4,20 @@ import { vscode } from '../types/vscode';
interface AgentEditorProps {
inputText: string;
setInputText: (text: string) => void;
currentAgentModel: string;
currentToolsModel: string;
currentAgent: string;
currentState: string;
setCurrentState: (state: string) => void;
contextFiles: Map<string, string>;
setContextFiles: (files: Map<string, string>) => void;
agentEditDetails: {name: string, description: string, systemInstruction: string, toolsModel: string, subagentEnabled: boolean}
setAgentEditDetails:(agentDetails: {name: string, description: string, systemInstruction: string, toolsModel: string, subagentEnabled: boolean}) => void
agentEditDetails: {name: string, description: string, systemInstruction: string}
setAgentEditDetails:(agentDetails: {name: string, description: string, systemInstruction: string}) => void
}
const AgentEditor: React.FC<AgentEditorProps> = ({
inputText,
setInputText,
currentAgentModel,
currentToolsModel,
currentAgent,
currentState,
setCurrentState,
@ -90,9 +90,8 @@ const AgentEditor: React.FC<AgentEditorProps> = ({
setTools(new Map(message.files || []));
break;
case 'loadAgent':
setAgentEditDetails({name: message.name, description: message.description, systemInstruction: message.systemInstruction, toolsModel: message.toolsModel, subagentEnabled: message.subagentEnabled});
setAgentEditDetails({name: message.name, description: message.description, systemInstruction: message.systemInstruction});
setTools(new Map(message.tools || []));
currentAgentModel = message.toolsModel;
break;
default:
break;
@ -120,10 +119,8 @@ const AgentEditor: React.FC<AgentEditorProps> = ({
vscode.postMessage({
command: 'saveEditAgent',
name: agentEditDetails.name,
subagentEnabled: agentEditDetails.subagentEnabled,
description: agentEditDetails.description,
systemInstruction: agentEditDetails.systemInstruction,
toolsModel: currentAgentModel,
tools: Array.from(agentTools.keys())
});
};
@ -135,27 +132,9 @@ const AgentEditor: React.FC<AgentEditorProps> = ({
});
}
const handleDeselectToolsModel = () => {
vscode.postMessage({
command: 'deselectAgentModel'
});
};
const handleSelectToolsModel = () => {
vscode.postMessage({
command: 'selectAgentModel'
});
};
const handleMoreToolsModel = () => {
vscode.postMessage({
command: 'moreToolsModel'
});
};
const handleShowToolsModel = () => {
vscode.postMessage({
command: 'showToolsModel'
command: 'selectModelWithTools'
});
};
@ -171,7 +150,6 @@ const AgentEditor: React.FC<AgentEditorProps> = ({
name: "",
description: "",
systemInstruction: [],
toolsModel: "",
tools: []
});
}
@ -328,8 +306,8 @@ const AgentEditor: React.FC<AgentEditorProps> = ({
Delete
</button>
</div>
<span style={{ display: 'block', marginTop: '20px', marginBottom: '10px', fontWeight: 'bold' }}>{'Tools'}</span>
{/* Tools */}
{/* Context Files */}
{agentTools.size > 0 && (
<div className="context-chips">
{Array.from(agentTools.entries()).map(([toolName, toolDescription]) => (
@ -353,98 +331,41 @@ const AgentEditor: React.FC<AgentEditorProps> = ({
)}
<span style={{ display: 'block', marginTop: '20px', marginBottom: '10px', fontWeight: 'bold' }}>{'Name (agent identifier)'}</span>
<span>{'Name (agent identifier)'}</span>
{/* Modern Textarea */}
<textarea
ref={elemNameRef}
value={agentEditDetails.name}
onChange={(e) => setAgentEditDetails({name: e.target.value, description: agentEditDetails.description, systemInstruction: agentEditDetails.systemInstruction, toolsModel: agentEditDetails.toolsModel,subagentEnabled: agentEditDetails.subagentEnabled})}
onChange={(e) => setAgentEditDetails({name: e.target.value, description: agentEditDetails.description, systemInstruction: agentEditDetails.systemInstruction})}
placeholder="Enter agent name."
className="modern-textarea"
rows={1}
style={{ height: 'auto', minHeight: '1.5em', resize: 'none' }}
/>
<span style={{ display: 'block', marginTop: '20px', marginBottom: '10px', fontWeight: 'bold' }}>{'Description'}</span>
<span>{'Descriptoin'}</span>
{/* Modern Textarea */}
<textarea
ref={elemDescriptionRef}
value={agentEditDetails.description}
onChange={(e) => setAgentEditDetails({name: agentEditDetails.name, description: e.target.value, systemInstruction: agentEditDetails.systemInstruction, toolsModel: agentEditDetails.toolsModel, subagentEnabled: agentEditDetails.subagentEnabled})}
onChange={(e) => setAgentEditDetails({name: agentEditDetails.name, description: e.target.value, systemInstruction: agentEditDetails.systemInstruction})}
placeholder="Enter agent description."
className="modern-textarea"
rows={2}
style={{ height: 'auto', minHeight: '3em', resize: 'none' }}
/>
<span style={{ display: 'block', marginTop: '20px', marginBottom: '10px', fontWeight: 'bold' }}>{'System Instruction'}</span>
<span>{'System Instruction'}</span>
{/* Modern Textarea */}
<textarea
ref={elemSystemPromptRef}
value={agentEditDetails.systemInstruction}
onChange={(e) => setAgentEditDetails({name: agentEditDetails.name, description: agentEditDetails.description, systemInstruction: e.target.value, toolsModel: agentEditDetails.toolsModel, subagentEnabled: agentEditDetails.subagentEnabled})}
onChange={(e) => setAgentEditDetails({name: agentEditDetails.name, description: agentEditDetails.description, systemInstruction: e.target.value})}
placeholder="Enter system instructions for the agent."
className="modern-textarea"
rows={10}
style={{ height: 'auto', minHeight: '15em', resize: 'vertical' }}
/>
<div style={{ marginBottom: '20px', marginTop: '10px', fontWeight: 'bold' }}>
<label className="checkbox-label" title="If enabled - the agent could be used as a subagent.">
<input
type="checkbox"
checked={agentEditDetails.subagentEnabled}
onChange={(e) => setAgentEditDetails({name: agentEditDetails.name, description: e.target.value, systemInstruction: agentEditDetails.systemInstruction, toolsModel: agentEditDetails.toolsModel, subagentEnabled: e.target.checked})}
/>
<span style={{ marginLeft: '8px' }}>Available as Subagent</span>
</label>
</div>
<div className="single-button-frame">
<div className="frame-label">Agent Model (Optional)</div>
{currentAgentModel == "" && (
<button
onClick={handleSelectToolsModel}
title={`Add Default Agent (Tools) Model`}
className="modern-btn secondary"
>
Add
</button>
)}
{
currentAgentModel && (
<button
onClick={handleDeselectToolsModel}
title={`Remove Agent Model`}
className="modern-btn secondary"
>
Remove
</button>
)
}
<span className="model-text">{currentAgentModel}</span>
{
currentAgentModel === "" && (
<button
onClick={handleMoreToolsModel}
title={`Add/Delete/View/Export/Import Tools Model`}
className="modern-btn secondary"
>
More
</button>
)
}
{
currentAgentModel && (
<button
onClick={handleShowToolsModel}
title={`Show Tools Model Details`}
className="modern-btn secondary"
>
...
</button>
)
}
</div>
{/* Input Actions */}
<div className="input-actions">
@ -452,9 +373,9 @@ const AgentEditor: React.FC<AgentEditorProps> = ({
<button
onClick={handleSelectTools}
className="modern-btn secondary"
title="Add/remove tools to the agent"
title="Add file to context"
>
Add/Remove Tools
Add Tools
</button>
</div>
<button

View file

@ -14,8 +14,6 @@ interface AgentViewProps {
setCurrentState: (state: string) => void;
contextFiles: Map<string, string>;
setContextFiles: (files: Map<string, string>) => void;
imagePath: string;
setContextImage: (imgPath: string) => void;
}
const AgentView: React.FC<AgentViewProps> = ({
@ -28,9 +26,7 @@ const AgentView: React.FC<AgentViewProps> = ({
currentState,
setCurrentState,
contextFiles,
setContextFiles,
imagePath,
setContextImage
setContextFiles
}) => {
const [showFileSelector, setShowFileSelector] = useState<boolean>(false);
const [fileList, setFileList] = useState<string[]>([]);
@ -113,9 +109,6 @@ const AgentView: React.FC<AgentViewProps> = ({
case 'updateContextFiles':
setContextFiles(new Map(message.files || []));
break;
case 'updateContextImage':
setContextImage(message.image || "");
break;
default:
break;
}
@ -123,7 +116,7 @@ const AgentView: React.FC<AgentViewProps> = ({
window.addEventListener('message', handleMessage);
return () => window.removeEventListener('message', handleMessage);
}, [setDisplayText, setCurrentState, setContextFiles, setContextImage]);
}, [setDisplayText, setCurrentState, setContextFiles]);
// Function to focus the textarea (can be called from extension)
const focusTextarea = () => {
@ -154,12 +147,6 @@ const AgentView: React.FC<AgentViewProps> = ({
handleAddSource('getFileList');
}
const handleAddImage = () => {
vscode.postMessage({
command: 'selectImageFile'
});
}
const handleSelectToolsModel = () => {
vscode.postMessage({
command: 'selectModelWithTools'
@ -221,10 +208,6 @@ const AgentView: React.FC<AgentViewProps> = ({
command: 'addContextProjectFile',
fileLongName: fileLongName
});
// vscode.postMessage({
// command: 'addContextProjectImage',
// image: "/home/igardev/Downloads/sofia.jpeg"
// });
} else if (inputText.endsWith('/')){
vscode.postMessage({
command: 'sendAgentCommand',
@ -260,14 +243,6 @@ const AgentView: React.FC<AgentViewProps> = ({
});
};
const handleRemoveContextImage = (imagePath: string) => {
vscode.postMessage({
command: 'removeContextProjectImage',
image: imagePath
});
};
const handleOpenContextFile = (fileLongName: string) => {
vscode.postMessage({
command: 'openContextFile',
@ -428,19 +403,6 @@ const AgentView: React.FC<AgentViewProps> = ({
</div>
)}
{imagePath && (
<div style={{ display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '12px' }}>
<span className="model-text">{"image: " + imagePath}</span>
<button
className="modern-btn secondary"
onClick={() => handleRemoveContextImage(imagePath)}
title="Remove image from context"
style={{ padding: '4px 8px', fontSize: '12px', minWidth: 'auto' }}
>
×
</button>
</div>
)}
{/* Modern Textarea */}
<textarea
ref={textareaRef}
@ -491,14 +453,6 @@ const AgentView: React.FC<AgentViewProps> = ({
>
@
</button>
<button
onClick={handleAddImage}
className="modern-btn secondary"
title="Add/replace image to context (.jpg, .png, .webp)"
style={{ filter: 'grayscale(100%)' }}
>
🖼
</button>
</div>
</div>
</div>