Trae CN分析问题提示词示例
最近在搭建了OpenharmonyArkcompiler开发环境后,在开发新特性之后,执行测试套进行验证,有失败的用例出现。借助Trae CN个人版来进行辅助分析,总结了一套问题分析的提示词,提高了问题分析的速度和质量。另外对于Trae CN 个人版这个AI IDE,请理性对待,不要盲目信任。它还未到人脑地步,因此提示词需要不断优化精准,避免无效修改。我使用的智能体是builder。Trae的代码
1. 前言
最近在搭建了Openharmony Arkcompiler开发环境后,在开发新特性之后,执行测试套进行验证,有失败的用例出现。借助Trae CN个人版来进行辅助分析,总结了一套问题分析的提示词,提高了问题分析的速度和质量。
另外对于Trae CN 个人版这个AI IDE,请理性对待,不要盲目信任。它还未到人脑地步,因此提示词需要不断优化精准,避免无效修改。我使用的智能体是builder。Trae的代码修改要反复审核,切勿盲从。
我修改的主要是C++、ets代码。
2. 配置当前用户 sudo 免密
在wsl中执行sudo visudo,在root ALL=(ALL:ALL) ALL后增加fbb ALL=(ALL:ALL) ALL
作用是在trae cn分析过程中有些操作是需要root权限,提示用户输入密码。配置后就会忽略该操作,提高分析速度。
3. 提示词
3.1 提示词内容
1). 工程编译指令:
cd /home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core
sudo /home/fbb/ohos/arkcompiler/arkts_20260324/build.sh r
2). 测试用例执行:
用例验证指令:
cd /home/fbb/ohos/arkts0205/arkcompiler/runtime_core/static_core
sudo /home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/tests/tests-u-runner/runner.sh --ets-runtime --build-dir="/home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/release_out" --processes=18 --show-progress --compare-files-iterations=2 --test-file override_interface_method.ets
3). 特别注意,以下文件不能做任何修改:
ets_frontend/ets2panda/checker/types/ets/etsFunctionType.cpp
ets2panda/test/compiler/ets/lambda_param_type_unverified.ets
ets2panda/test/compiler/ets/lambda_param_type_unverified_foreach.ets
ets2panda/test/runtime/ets/lambda_n/lambda_arg_ignored.ets
ets2panda/test/runtime/ets/lambda_n/lambda_arg_ignored2.ets
4). 编译报错:
ALL OPTIONS: --ets-runtime --build-dir=/home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/release_out --processes=18 --show-progress --compare-files-iterations=2 --test-file override_interface_method.ets
Loading excluded test lists: ['/home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/tools/es2panda/test/test-lists/ets-runtime/ets-runtime-excluded.txt']
Loading ignored test lists: ['/home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/tools/es2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt', '/home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/tools/es2panda/test/test-lists/ets-runtime/ets-runtime-ignored-INT.txt', '/home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/tools/es2panda/test/test-lists/ets-runtime/ets-runtime-ignored-AMD64-OL2.txt']
Loaded 1 valid tests from the folder '/tmp/ets/ets-runtime/gen'. Excluded 0 tests are not loaded.
0%| | 0/1 [00:00<?, ?it/s]Finished override_interface_method.ets - 0.13 sec - NEW FAILURE
override_interface_method.ets: steps: Run es2panda: /home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/release_out/bin/es2panda --arktsconfig=/home/fbb/ohos/arkcompiler/arkts_20260324/runtime_core/static_core/release_out/tools/es2panda/generated/arktsconfig.json --gen-stdlib=false --extension=ets --opt-level=2 --output=/tmp/ets/ets-runtime/intermediate/override_interface_method.ets.abc /tmp/ets/ets-runtime/gen/override_interface_method.ets
Output: ''
Error: '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
es2panda unexpectedly terminated.
5). 请分析。修改测试用例。并使用编译指令来验证代码修改。
用例执行成功后,请按以下函数优化要求优化改动的函数。
函数优化要求:
- 分析改动的函数的代码行数不能超过50行
- 改动的函数代码长度不能超过120字符
- 改动的函数(包括函数签名)嵌套层次不能超过4层
不能包含任何调试代码 - 工程编译通过
3.2 提示词说明
trae cn的智能体Builder默认是自动修改代码,以测试用例代码为基准,修改业务代码。如果你认为业务代码正确,需要修改测试用例。那就需要显示说明不能修改的文件,说明要修改的是测试用例代码。
更多推荐



所有评论(0)