Files
MemRelay/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/OpenCode 导出提示词要锁死 SQL 和绝对路径.md
T
memrelay 126e6cf5cc update: OpenCode 导出提示词要锁死 SQL 和绝对路径
MemRelay-Operation: memory-save:opencode-prompt-contract-20261111-3
MemRelay-Resource: a1c2c463-892d-4d3a-bafc-fa3edccb20d7
2026-11-11 02:02:25 +08:00

30 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: OpenCode 导出提示词要锁死 SQL 和绝对路径
type: experience
permalink: main/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/open-code-导出提示词要锁死-sql-和绝对路径
stable_id: a1c2c463-892d-4d3a-bafc-fa3edccb20d7
scope: project
memory_type: experience
project_id: d5a7f581-c442-4554-87b9-ee723b8b0258
usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998
status: active
revision: 3
request_id: opencode-prompt-contract-20261111-3
created_at: '2026-11-10T16:49:27.968106+00:00'
updated_at: '2026-11-10T18:02:23.007338+00:00'
tags:
- OpenCode
- 提示词
- workspace
- 核对
---
## 做法(已在生产验证,实现见 app/nqi/opencode.py)
- 一条提示词可以带多条导出命令(实测 4 条一次成功)。要点:加载 adhoc_query 技能;程序发起、没人回答,不询问不确认不预览;在技能目录下逐条执行;SQL 一个字符都不能改也不要按技能规范重写;不得换目录和文件名;每条输出 DONE/FAIL 行。
- 命令:python script/download-file-all-async.py --sql "..." --save-dir "/workspace/tasks/<任务>/<阶段>" --filename "x.csv"。保存、读取、删除只在 /workspace 下。
- 程序只认工具证据:bash 工具实际执行的命令里 --sql 必须与下发的逐字节相同,--save-dir/--filename 对上;脚本输出「文件已保存至:<路径>」才算落盘,「服务端响应体为空」是空结果。AI 回复文字不采信。
- CSV 列顺序不跟 SELECT,按表头取列;必需列要齐;列数不对的行丢弃;有 eff_from_date/eff_to_date 时每行要满足当天有效。不合格换新文件名 _r1/_r2 重做,最多 2 次。
- SQL 里日期写 make_date(年, 月, 日),见「OpenCode 提示词里的日期会被脱敏改掉」。
## 依据
adhoc_query 技能默认不导出,只有提示词明确要求时才调用 download-file-all-async.py。保存目录必须是绝对路径。超过 10 万行技能会再向用户确认(江门全市 4G 约 4.1 万行,未触发)。