Note
Intention Test VS Code extension has not implemented one-click running for now. A local Python backend should be started before running the extension.
Intention Test requires the following development languages:
- Python 3.10+ with PyTorch
- Node.js
And the following tools for source code analyzation (manual download by user):
- Oracle JDK 1.8 (set
JAVA_HOME) - Apache Maven (or
brew install mavenon macOS) - CodeQL CLI
And an OpenAI API key to access GPT-4o.
- Configure Java 8
echo 'export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home' >> ~/.zshrc echo 'export PATH="$JAVA_HOME/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
- Install Maven (user action):
brew install maven
- Install CodeQL CLI (user downloads zip, then):
mkdir -p ~/.local/apps ~/.local/bin unzip -q -o ~/Code/codeql-osx64.zip -d ~/.local/apps ln -sf ~/.local/apps/codeql/codeql ~/.local/bin/codeql echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zprofile source ~/.zprofile codeql version
Note: The repository also provides setup/MACOS.sh to help configure environment variables and CodeQL linking (it expects you to download installers yourself first).
Pull the latest image from Docker Hub and start the container:
docker pull vhahahav/intention_test:latest
docker run -d --name intention-test \
-p 8080:8080 \
-e OPENAI_API_KEY="your-open-ai-key" \
-e OPENAI_API_URL="https://api.chatanywhere.tech/v1" \
vhahahav/intention_test:latestAPI 端点配置:
- 默认使用
https://api.chatanywhere.tech/v1(国内推荐,延迟更低) - 国外用户可使用:
https://api.chatanywhere.org/v1 - 使用官方 OpenAI API:
https://api.openai.com/v1
The container writes backend/config.ini automatically and starts python server.py --port 8080.
To use another port, change the mapping and environment variable:
docker run -d --name intention-test \
-p 8090:8090 \
-e SERVER_PORT=8090 \
-e OPENAI_API_KEY="your-open-ai-key" \
vhahahav/intention_test:latestLogs can be tailed with docker logs -f intention-test.
To rebuild locally instead of pulling, follow DEPLOY.md.
To develop against the live source tree, bind-mount the repository so container code follows your local changes:
docker run -d --name intention-test-dev \
-p 8080:8080 \
-e OPENAI_API_KEY="your-open-ai-key" \
-v /path/to/intention-test-extension:/app \
vhahahav/intention_test:latest/appinside the container mirrors your host repo; edits on the host take effect immediately.- Ensure the host directory grants read/write permissions to UID/GID
1000:1000(container uservscode). - If necessary, add
-u $(id -u):$(id -g)so the container process runs with your host UID/GID.
python3 -m venv .venv
source .venv/bin/activate
pip install -r backend/requirements.txt
cd backend
cp config.ini config.local.ini # Optional backup
vim config.ini # 填写 OPENAI KEY、URL 与 codeql 路径
# config.ini 示例:
# [openai]
# apikey = your-api-key
# url = https://api.chatanywhere.tech/v1 # 或 https://api.chatanywhere.org/v1(国外)
python server.py --port 8080Ensure Java 8, Maven, CodeQL CLI, and PyTorch are installed as listed above.
When developing outside Docker, update config.ini manually and keep the codeql path valid.
First install node dependencies from project root:
npm installThen in Cursor/VS Code, run the extension host:
# 编译 TypeScript(watch mode)
npm run watch
# 另开终端启动扩展调试
npx vsce package # (可选,仅需一次)
code --extensionDevelopmentPath=$(pwd)或在 VS Code 中按 F5 / Command Palette → “Debug: Start Debugging” 选择 Run Extension。
If you have specify another port when starting backend server,
change the port in settings of the new Extension Development Host window via Intention Test: Port before generating test cases.
Now the tool only supports running on the demo project backend/data/spark inside this repository.
mkdir -p backend/data/ && cd backend/data/
git clone [email protected]:perwendel/spark.git
Paste a valid description in the extension panel (required by backend parser):
# Objective
验证 `ClassName.methodName(ParamTypes...)` 在典型输入下的正确行为。
# Preconditions
1. 已创建 `ClassName` 实例为 `obj`。
2. 准备输入参数:`param1 = ...`,`param2 = ...`。
3. (可选)设置必要的配置/上下文。
# Expected Results
1. 调用 `obj.methodName(param1, param2, ...)` 不抛出异常。
2. 返回值满足断言:`...`(如 不为 null / 大于 0 / 含特定字段)。
3. (可选)对象或外部状态变化符合预期:`...`。
- If the extension shows “Waiting for request...”, ensure backend is running and port matches
Intention Test: Port. - If you see JSON errors with
HTTP/1.0 5xx, check backend console for missing config (OpenAI url/apikey, CodeQL path, JAVA_HOME). - If OpenAI API returns 429 (quota), the backend will surface a readable error instead of crashing; update your key/plan to proceed.
- Test tube icon comes from https://www.svgrepo.com/svg/525096/test-tube-minimalistic