qiyu-cli 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +349 -57
- package/dist/cli.js +48 -7
- package/dist/commands/api-notes.js +54 -0
- package/dist/commands/api.js +113 -39
- package/dist/commands/auth.js +150 -28
- package/dist/commands/credentials-source.js +30 -5
- package/dist/commands/db-notes.js +75 -0
- package/dist/commands/db.js +112 -113
- package/dist/commands/query-notes.js +58 -0
- package/dist/commands/query.js +427 -56
- package/dist/commands/skill.js +477 -38
- package/dist/commands/spec-types.js +101 -1
- package/dist/commands/stats.js +139 -30
- package/dist/commands/store-flags.js +18 -0
- package/dist/commands/store-notes.js +38 -0
- package/dist/commands/store-precheck.js +254 -0
- package/dist/commands/store.js +128 -75
- package/dist/commands/sync-notes.js +367 -0
- package/dist/commands/sync-run.js +155 -44
- package/dist/commands/sync.js +182 -121
- package/dist/core/config.js +274 -24
- package/dist/core/credentials.js +38 -4
- package/dist/core/edition.js +13 -3
- package/dist/core/envelope.js +73 -9
- package/dist/core/errors.js +73 -16
- package/dist/core/http.js +151 -52
- package/dist/core/ratelimit.js +5 -1
- package/dist/core/registry/index.js +26 -2
- package/dist/core/registry/params/export.session.check.json +17 -2
- package/dist/core/registry/params/export.session.json +24 -2
- package/dist/core/registry/params/export.session.one.json +10 -2
- package/dist/core/registry/params/export.session.one.message.json +17 -2
- package/dist/core/registry/specs.json +64 -42
- package/dist/core/shell.js +30 -0
- package/dist/core/time.js +1 -1
- package/dist/core/validate.js +21 -2
- package/dist/output.js +204 -28
- package/dist/postinstall.js +14 -5
- package/dist/query/errors.js +145 -45
- package/dist/query/mask.js +1277 -25
- package/dist/query/metric-catalog.js +11 -0
- package/dist/query/native-error.js +189 -0
- package/dist/query/sandbox.js +129 -24
- package/dist/query/table-query.js +36 -5
- package/dist/schedule/install.js +136 -13
- package/dist/skill/check.js +11 -6
- package/dist/skill/detect.js +122 -27
- package/dist/skill/install.js +233 -43
- package/dist/skill/paths.js +54 -0
- package/dist/skill/qiyu/SKILL.md +38 -8
- package/dist/skill/qiyu/errors.md +5 -4
- package/dist/skill/qiyu/protocols.md +57 -5
- package/dist/skill/qiyu/setup.md +6 -2
- package/dist/store/config.js +92 -16
- package/dist/store/duckdb.js +51 -5
- package/dist/store/retry.js +92 -4
- package/dist/store/schema.js +26 -3
- package/dist/sync/engine.js +257 -65
- package/dist/sync/registry.js +4 -0
- package/dist/sync/state.js +20 -0
- package/dist/sync/tasks/dim.js +23 -14
- package/dist/sync/tasks/knowledge.js +50 -8
- package/dist/sync/tasks/pipeline.js +29 -9
- package/dist/sync/tasks/reports.js +176 -49
- package/dist/sync/tasks/sessions.js +88 -21
- package/dist/sync/tasks/tickets.js +59 -8
- package/dist/sync/types.js +60 -1
- package/dist/sync/windowing.js +0 -22
- package/dist/sync/write-contract.js +47 -0
- package/package.json +1 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// src/commands/store-precheck.ts —— 只读命令的「库前置检查」:**唯一实现点**
|
|
2
|
+
// (2026-10-31,PR #54)。
|
|
3
|
+
//
|
|
4
|
+
// 背景(起因 × 九个命令逐条对照的 E2E 矩阵实测):这套前置检查此前在**三个文件**里
|
|
5
|
+
// 各写了一份 —— `commands/db.ts`(E 族四命令共用)、`commands/sync.ts`(sync 三命令)、
|
|
6
|
+
// `commands/store.ts` 的 status 路径。复制出来的那几份已经漂移,其中一处是**事实错误**:
|
|
7
|
+
// · `store status --db <FIFO>` / `--db /dev/null` 说「**--db 指向的是目录**而非数据库文件」,
|
|
8
|
+
// 而那个路径根本不是目录(`mkfifo`、字符设备实测)—— 判据是 `!isFile()`(覆盖
|
|
9
|
+
// 命名管道 / 设备 / 套接字),文案却按「目录」这一种成因写死;
|
|
10
|
+
// · 同一成因在其余八个命令上是「指向的不是普通文件」—— **同一输入两种说法**,
|
|
11
|
+
// 且前一种把 Agent 引向「我传了个目录」这个不存在的方向;
|
|
12
|
+
// · 「缺 schema_version」同理:`store status` 说「请运行:qiyu store init」,
|
|
13
|
+
// 其余命令说「空库(无任何表)。请先运行:…」。
|
|
14
|
+
// 形态归属:「同一份解码规则复制到多处 → 同一输入两个结论」。
|
|
15
|
+
// 同族前科:`nonEmptyValue` 空串判据(`tests/empty-string-single-source.test.ts`)、
|
|
16
|
+
// profile 名解析(PR #41)、打开失败成因(PR #53)。
|
|
17
|
+
//
|
|
18
|
+
// ⚠️ **本模块只服务只读命令**。`store init` 的前置检查是**另一条规则**(用 `lstatSync`
|
|
19
|
+
// 拒绝符号链接 + 建父目录,出口是「写」),结构不并入此处;它只复用本模块的两条
|
|
20
|
+
// **非普通文件**文案,免得同一成因在 init 与只读命令上说两套话。
|
|
21
|
+
import { lstatSync, statSync } from 'node:fs';
|
|
22
|
+
import { fail, storeInitCommand } from '../output.js';
|
|
23
|
+
import { TABLES } from '../store/schema.js';
|
|
24
|
+
import { missingTableCauses } from '../query/errors.js';
|
|
25
|
+
/**
|
|
26
|
+
* 「库尚未初始化」的恢复命令 hint —— **唯一渲染点**。
|
|
27
|
+
*
|
|
28
|
+
* 两个产地共用这一句:① 本模块 `statGuard` 的 ENOENT 分支;② `sync-run.ts` 的
|
|
29
|
+
* `storeInitFail` 兜底(store 打开失败但底层没带 hint 时)。两处成因不同、**动作相同**
|
|
30
|
+
* (都是「跑一次 store init」),文案因此也必须同源 —— 各写一份就是下一次漂移的种子
|
|
31
|
+
* (本轮 `store-precheck-single-source.test.ts` 的指纹扫描正是从 `sync-run.ts` 抓到它的)。
|
|
32
|
+
*/
|
|
33
|
+
export function storeNotInitializedHint(path) {
|
|
34
|
+
return '数据库尚未初始化。请先运行:' + storeInitCommand(path);
|
|
35
|
+
}
|
|
36
|
+
/** `--db` 指向**目录**时的 hint。 */
|
|
37
|
+
export const DIRECTORY_DB_HINT = '--db 指向的是目录而非数据库文件,请给出 .duckdb 数据库文件路径';
|
|
38
|
+
/**
|
|
39
|
+
* `--db` 指向目录以外的非普通文件(命名管道 / 设备 / 套接字)时的 hint。
|
|
40
|
+
* ⚠️ **不能**与 `DIRECTORY_DB_HINT` 合并成一句:「是目录」对 FIFO 是**假话**,
|
|
41
|
+
* Agent 会去查自己是不是传了目录(它没有),而真正要做的只是换个路径。
|
|
42
|
+
*/
|
|
43
|
+
export const NON_REGULAR_DB_HINT = '--db 指向的不是普通文件(命名管道 / 设备 / 套接字等特殊文件),请给出 .duckdb 数据库文件路径';
|
|
44
|
+
/**
|
|
45
|
+
* 非普通文件的 hint —— 按 `stat` 的**实际结果**分形。
|
|
46
|
+
* 判据只问「是不是普通文件」,成因却有两种;把一种当成全部就是本轮修的那个错。
|
|
47
|
+
*/
|
|
48
|
+
export function nonRegularFileHint(isDirectory) {
|
|
49
|
+
return isDirectory ? DIRECTORY_DB_HINT : NON_REGULAR_DB_HINT;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `statSync` 失败(ENOENT 之外)的 hint —— **按 errno 分形**。
|
|
53
|
+
*
|
|
54
|
+
* ⚠️ 2026-11-07 审查实测:此前所有非 ENOENT 错误一律说「请检查路径权限」,
|
|
55
|
+
* 而实测 `statSync` 的失败原因至少还有三种,逐字报文(macOS):
|
|
56
|
+
* · `ELOOP: too many symbolic links encountered`(`ln -s loop loop`)
|
|
57
|
+
* · `ENOTDIR: not a directory`(`plain.txt/child`)
|
|
58
|
+
* · `ENAMETOOLONG: name too long`(300 字符路径)
|
|
59
|
+
* 这三种都不是权限问题 —— 让 Agent 去查权限,它会在一个没有权限问题的地方白找一轮。
|
|
60
|
+
* 判据只问「能不能 stat」,成因必须由 errno 说出来。
|
|
61
|
+
* 未归类的 errno 如实说「未专门归类」,不猜成权限。
|
|
62
|
+
*/
|
|
63
|
+
export function statFailureHint(errno) {
|
|
64
|
+
switch (errno) {
|
|
65
|
+
case 'EACCES':
|
|
66
|
+
case 'EPERM':
|
|
67
|
+
return '请检查路径权限(只读命令不需要写权限)';
|
|
68
|
+
case 'ELOOP':
|
|
69
|
+
return '路径中存在符号链接成环(ELOOP),stat 无法解析 —— 请改用真实路径,或先修掉循环链接';
|
|
70
|
+
case 'ENOTDIR':
|
|
71
|
+
return '路径中有一段不是目录(ENOTDIR)—— 请检查 --db 的拼写(它可能把文件当成了目录)';
|
|
72
|
+
case 'ENAMETOOLONG':
|
|
73
|
+
return '路径过长(ENAMETOOLONG)—— 请缩短 --db 路径';
|
|
74
|
+
default:
|
|
75
|
+
return `无法访问该路径(errno=${errno ?? '未知'}):本 CLI 只按 errno 归类了权限 / 链接成环 /`
|
|
76
|
+
+ '路径中有非目录段 / 路径过长四种,其余请按报文里的系统错误码定位';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 断链符号链接的 hint(`statGuard` 的 ENOENT 分流用);不是断链时返回 `null`。
|
|
81
|
+
*
|
|
82
|
+
* 只读命令对断链必须说「链接目标不存在」,**不得**指向 `store init` ——
|
|
83
|
+
* `store init` 拒绝符号链接(`目标是符号链接,请给出真实路径`),照 hint 执行只会换一句错。
|
|
84
|
+
* `lstat` 本身再失败(父目录不存在等)时同样返回 `null`,交回「路径不存在」原分支。
|
|
85
|
+
*/
|
|
86
|
+
function danglingSymlinkHint(path) {
|
|
87
|
+
let lst;
|
|
88
|
+
try {
|
|
89
|
+
lst = lstatSync(path);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
if (!lst.isSymbolicLink())
|
|
95
|
+
return null;
|
|
96
|
+
return `路径是一个符号链接,但它指向的目标不存在(stat 跟随链接后得到 ENOENT)。`
|
|
97
|
+
+ '请改用真实路径,或把链接改指向存在的库;`store init` 不接受符号链接路径,'
|
|
98
|
+
+ '照「先运行 store init」执行只会得到第二条错误';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 只读命令的库前置检查(`statSync` 的 ENOENT / 非普通文件 / 其余 errno 三分)。
|
|
102
|
+
* 合格(是一个普通文件)→ `null`,调用方继续打开库。
|
|
103
|
+
*
|
|
104
|
+
* hint 一律指向 `qiyu store init` 的**完整命令**(带本次 `--db` 绝对路径)——
|
|
105
|
+
* 裸命令会作用在默认库上,逐字执行即死循环(`tests/store-hint-selection.test.ts`)。
|
|
106
|
+
*/
|
|
107
|
+
export function statGuard(path) {
|
|
108
|
+
let st;
|
|
109
|
+
try {
|
|
110
|
+
st = statSync(path);
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
if (e.code === 'ENOENT') {
|
|
114
|
+
// ⚠️ 断链符号链接的 `statSync` 也抛 ENOENT(跟随链接后目标不存在),与「路径真的
|
|
115
|
+
// 不存在」在 errno 上无法区分 —— 但两者该给的 hint 相反(2026-11-09 审计实测):
|
|
116
|
+
// 前者说「请运行 store init」,而 `store init` 自己 lstat 出是符号链接、拒绝执行,
|
|
117
|
+
// 用户被两条 hint 锁进死循环。先 lstat 一次分流:lstat 层存在 → 一定是断链。
|
|
118
|
+
const link = danglingSymlinkHint(path);
|
|
119
|
+
if (link !== null) {
|
|
120
|
+
return fail({
|
|
121
|
+
code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
122
|
+
message: `符号链接指向不存在的目标:${path}`,
|
|
123
|
+
hint: link,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return fail({
|
|
127
|
+
code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
128
|
+
message: `数据库文件不存在:${path}`,
|
|
129
|
+
hint: storeNotInitializedHint(path),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return fail({
|
|
133
|
+
code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
134
|
+
message: `无法访问 ${path}:${e instanceof Error ? e.message : String(e)}`,
|
|
135
|
+
hint: statFailureHint(e.code),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (!st.isFile()) {
|
|
139
|
+
return fail({
|
|
140
|
+
code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
141
|
+
message: `不是普通文件:${path}`,
|
|
142
|
+
hint: nonRegularFileHint(st.isDirectory()),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 库里**本 CLI 未声明**的表名(`TABLES` 之外)。
|
|
149
|
+
*
|
|
150
|
+
* ⚠️ 为什么必须是共享实现(2026-11-01 实测修):`store status` 与 `store init` 都用
|
|
151
|
+
* **全库** `information_schema` 拿表名,但 `store.count()` 内部走 `assertTable` ——
|
|
152
|
+
* 库里有未声明的表时抛 `usage`(`未知表:xxx`,退出码 2),于是 `store status` 在
|
|
153
|
+
* **库恰好有漂移时整条命令失败**(连 `schema_version` 都拿不到)。而 `db tables` 对
|
|
154
|
+
* 同一状态只是把它列进 warnings ——「库中有而声明无」是全仓一致认可**要警告不失败**的
|
|
155
|
+
* 漂移状态(`db tables` 的实现与 README 都这么写)。成因:判据只问了「库里有几张表」,
|
|
156
|
+
* 没问「这几张是不是本 CLI 的」。
|
|
157
|
+
*/
|
|
158
|
+
export function undeclaredTables(names) {
|
|
159
|
+
const declared = new Set(TABLES.map((t) => t.name));
|
|
160
|
+
// 排序:`information_schema` 不保证顺序,`db tables` 此前自己 `.sort()`、`store`
|
|
161
|
+
// 不排序 —— 同一库两次输出 warnings 顺序不同。统一在唯一实现点排序。
|
|
162
|
+
return names.filter((n) => !declared.has(n)).sort();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 「声明有而库中无」的表名(以 `TABLES` 为权威、按声明顺序)。
|
|
166
|
+
*
|
|
167
|
+
* ⚠️ 为什么必须是共享实现(2026-11-02 实测修):`db tables` / `db describe` 会把它
|
|
168
|
+
* 列进 warnings 并给出成因与对策(`missingTableCauses`),而 `store status` / `store init`
|
|
169
|
+
* 此前只算了「库中有而声明无」那一半 —— 同一库、同一时刻,`db tables` 警告
|
|
170
|
+
* `tickets` 不在,`store status` 却报 `ok` 且零 warnings(README 承诺两边表集一致,
|
|
171
|
+
* 缺表时恰恰不一致,而 Agent 拿到的却是干净的成功)。只说一半漂移是比不说更容易被
|
|
172
|
+
* 当成没事的形态:Agent 见 warnings 为空就以为「声明与实况已对齐」。
|
|
173
|
+
*/
|
|
174
|
+
export function declaredMissingTables(names) {
|
|
175
|
+
const actual = new Set(names);
|
|
176
|
+
return TABLES.map((t) => t.name).filter((n) => !actual.has(n));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* 「库中有而声明无」的 warning 文案 —— **唯一渲染点**(`store init` / `store status` /
|
|
180
|
+
* `db tables` 共用;`db tables` 走下面的 `storeTablesWarnings`)。
|
|
181
|
+
* 空数组 → `undefined`(不产生 `meta.warnings` 键:该键是**条件键**)。
|
|
182
|
+
*/
|
|
183
|
+
export function undeclaredTablesWarning(undeclared) {
|
|
184
|
+
if (undeclared.length === 0)
|
|
185
|
+
return undefined;
|
|
186
|
+
return [`库中有而声明无:${undeclared.join('、')}。这些表没有元数据声明(可能来自旧版 CLI `
|
|
187
|
+
+ '或其他工具),不出现在 tables 中'];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* 「声明 vs 实况」两个方向的 `meta.warnings` —— **唯一渲染点**(`store init` /
|
|
191
|
+
* `store status` / `db tables` 三处此前各拼一遍)。
|
|
192
|
+
*
|
|
193
|
+
* 两半都必须在场:只报「库中有而声明无」会让缺表静默(见 `declaredMissingTables` 的说明)。
|
|
194
|
+
* 缺表那半的成因与对策**不得**自带一份,取 `query/errors.ts` 的 `missingTableCauses()`
|
|
195
|
+
* (与 db/query/stats 四个出口逐字同源 —— tests/missing-table-causes.test.ts 钉着)。
|
|
196
|
+
* 两半都为空 → `undefined`(`meta.warnings` 是条件键)。
|
|
197
|
+
*/
|
|
198
|
+
export function storeTablesWarnings(names, path, profileFlag) {
|
|
199
|
+
const warnings = [];
|
|
200
|
+
const missing = declaredMissingTables(names);
|
|
201
|
+
if (missing.length > 0) {
|
|
202
|
+
warnings.push(`声明有而库中无:${missing.join('、')}。这些表不出现在 tables 中。`
|
|
203
|
+
+ missingTableCauses(path, profileFlag));
|
|
204
|
+
}
|
|
205
|
+
warnings.push(...(undeclaredTablesWarning(undeclaredTables(names)) ?? []));
|
|
206
|
+
return warnings.length > 0 ? warnings : undefined;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 查 `schema_version` 表列名的 SQL —— **唯一字符串**(db/store/sync 三个调用点共用,
|
|
210
|
+
* 各自经自己的会话执行;判据本体在 `schemaVersionMissing`)。
|
|
211
|
+
*/
|
|
212
|
+
export const SCHEMA_VERSION_COLUMNS_SQL = "SELECT column_name FROM information_schema.columns WHERE table_schema='main' AND table_name='schema_version'";
|
|
213
|
+
/**
|
|
214
|
+
* 库结构校验:已有 `schema_version` → `null`;否则给出**按成因分形**的失败载荷。
|
|
215
|
+
*
|
|
216
|
+
* ⚠️ **成因必须分形**:「有表但无 `schema_version`」是**他人库** —— `store init` 会再次
|
|
217
|
+
* 拒绝(`store/duckdb.ts` 的他人库防线),把它一并引导向 `store init` 就是
|
|
218
|
+
* `store init` → 原命令的死循环;「零表」才是 `init` 可补的成因。
|
|
219
|
+
*
|
|
220
|
+
* ⚠️ **表名不是身份证明**(2026-11-07 审查实测):别的工具也会建叫 `schema_version`
|
|
221
|
+
* 的表。探针实测 `schema_version(version_id, applied_at)` 的库:旧判据放行,`store status`
|
|
222
|
+
* 落 internal「存储操作失败(底层:Binder Error: … version not found)」+「备份重建」hint
|
|
223
|
+
* —— 把一个只是**不是本 CLI 的库**说成损坏缓存。调用方用 `SCHEMA_VERSION_COLUMNS_SQL`
|
|
224
|
+
* 查到列名后传 `versionColumns`;**没传**时保持旧判据(不猜)。
|
|
225
|
+
*
|
|
226
|
+
* ⚠️ 返回载荷而不是自己 `fail()`:调用方失败前还得先关掉自己持有的会话
|
|
227
|
+
* (`openSandbox` 的 session / `openStore` 的 store),关会话是调用方的所有权责任。
|
|
228
|
+
*/
|
|
229
|
+
export function schemaVersionMissing(path, names, versionColumns) {
|
|
230
|
+
if (names.includes('schema_version')) {
|
|
231
|
+
// ⚠️ 列名比较必须与 DuckDB 的解析规则一致(Codex 2026-11-09 第十三轮 P2,真机实测):
|
|
232
|
+
// `CREATE TABLE schema_version ("VERSION" INTEGER, …)` 反射出 `VERSION`/`Version`,
|
|
233
|
+
// 而 `SELECT MAX(version)` 照样解析成功 —— 旧的小写精确比较会把**可用的库**判成他人库、
|
|
234
|
+
// 挡住全部读命令。反例同样实测过:带空格的 `" version"` / `"version "` 与 `version_id`
|
|
235
|
+
// 确实解析失败,只有大小写变体不可区分。
|
|
236
|
+
if (versionColumns !== undefined
|
|
237
|
+
&& !versionColumns.some((c) => c.toLowerCase() === 'version')) {
|
|
238
|
+
return {
|
|
239
|
+
code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
240
|
+
message: `目标数据库不是本 CLI 创建的(schema_version 表缺少 version 列,`
|
|
241
|
+
+ `实际列:${versionColumns.join('、')}):${path}`,
|
|
242
|
+
hint: '目标数据库不是本 CLI 创建的,请换 --db 路径',
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
249
|
+
message: `数据库结构不完整(缺表):${path}`,
|
|
250
|
+
hint: names.length > 0
|
|
251
|
+
? '目标数据库不是本 CLI 创建的,请换 --db 路径'
|
|
252
|
+
: '空库(无任何表)。请先运行:' + storeInitCommand(path),
|
|
253
|
+
};
|
|
254
|
+
}
|
package/dist/commands/store.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// src/commands/store.ts
|
|
2
|
-
import {
|
|
2
|
+
import { lstatSync, mkdirSync } from 'node:fs';
|
|
3
3
|
import { dirname } from 'node:path';
|
|
4
4
|
import { resolveStoreConfig, currentStoreEnv } from '../store/config.js';
|
|
5
5
|
import { openStore } from '../store/index.js';
|
|
6
|
-
import { ok, fail, usageFail, sanitizeControlChars, setPretty } from '../output.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { ok, fail, usageFail, failFromTagged, sanitizeControlChars, setPretty, storeInitCommand, syncRunCommand, describeArgs, } from '../output.js';
|
|
7
|
+
import { classifyOpenFailure, openFailureHint } from '../store/retry.js';
|
|
8
|
+
import { DB_PATH_HELP, parseStoreFlags } from './store-flags.js';
|
|
9
|
+
import { SCHEMA_VERSION_COLUMNS_SQL, statGuard, schemaVersionMissing, nonRegularFileHint, undeclaredTables, storeTablesWarnings, } from './store-precheck.js';
|
|
10
|
+
import { TABLES } from '../store/schema.js';
|
|
11
|
+
import { storeFieldNotes } from './store-notes.js';
|
|
12
|
+
import { GLOBAL_FLAGS, helpArgsError, prettyAfterSubcommand, prettyPositionalProblem, REJECTED_FLAGS, STORE_FLAGS } from './spec-types.js';
|
|
9
13
|
/**
|
|
10
14
|
* 命令契约(F 组 D4):`skill check` 据此判断 skill 正文里的 `qiyu store …` 是否真的存在。
|
|
11
15
|
* `flags` 是**完整接受集**(含全局 flag),`--pretty` 同时在 `rejected` 里。
|
|
@@ -32,11 +36,11 @@ const USAGE = `用法:qiyu store <子命令> [参数]
|
|
|
32
36
|
store status [--db <path>] [--profile <name>] [--backend <name>]
|
|
33
37
|
查看数据库状态与各表行数
|
|
34
38
|
|
|
35
|
-
⚠️
|
|
36
|
-
|
|
39
|
+
⚠️ 存储配置仍需手工编辑 ~/.config/qiyu/config.json(store 命令本身不写配置;配置文件可能已
|
|
40
|
+
由 auth login 创建,但只含 credentials 键,不含 store 段)。也可用 --db / QIYU_DB_PATH 直接指定库路径。
|
|
41
|
+
${DB_PATH_HELP}
|
|
37
42
|
`;
|
|
38
|
-
|
|
39
|
-
export function thrownToExit(e) {
|
|
43
|
+
export function thrownToExit(e, profileFlag) {
|
|
40
44
|
const err = e;
|
|
41
45
|
// usage 类错误(store 层预检抛出,如未知列/缺列/连接已关闭):归 usageFail 双通道、
|
|
42
46
|
// 退出码 2 —— 这是用法错误不是环境故障(M1 修:此前被下方排除条件挡住后落 internal)。
|
|
@@ -51,30 +55,56 @@ export function thrownToExit(e) {
|
|
|
51
55
|
// ① DuckDB 拒绝打开非 DuckDB 文件 / 执行期错误 → 环境/数据问题,退出码 1、internal;
|
|
52
56
|
// ② 其余 → 用法错误,退出码 2(usageFail 双通道)。
|
|
53
57
|
const msg = err.message ?? String(e);
|
|
54
|
-
|
|
58
|
+
// ⚠️ 打开失败的成因分流走 `store/retry.ts` 的 `classifyOpenFailure`(2026-10-31 单一实现点):
|
|
59
|
+
// 判据与 hint 口径必须与 `query/sandbox.ts` 的 `openSandbox`、`sync-run.ts` 的
|
|
60
|
+
// `storeInitFail` 一致 —— 此前三处各写各的,
|
|
61
|
+
// 同一个 `chmod 000` 的文件在 `store status` 与 `query` 上给出**互相矛盾**的 hint
|
|
62
|
+
// (一个说「检查读写权限」、一个说「请确认文件存在且由本 CLI 创建,跑 store init」)。
|
|
63
|
+
// 判据本身的形态要求(DuckDB 原生报文、strerror 在句尾、锚 `$` 不能子串搜)见那里的注释。
|
|
64
|
+
const openFailure = classifyOpenFailure(e);
|
|
65
|
+
if (openFailure !== null) {
|
|
55
66
|
return fail({ code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
56
|
-
message: `无法打开 ${msg}`, hint:
|
|
57
|
-
}
|
|
58
|
-
// ⚠️ open/执行期 errno 分流(R 组 R6):EACCES/EPERM/EROFS 是环境问题不是程序错误,
|
|
59
|
-
// 归因必须准(K 组 M3 只做了 lstat/statSync 层,这里补 open 期)。
|
|
60
|
-
if (/^(EACCES|EPERM|EROFS)/.test(msg)) {
|
|
61
|
-
return fail({ code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
62
|
-
message: `无法打开 ${msg}`, hint: '请检查路径写权限(磁盘只读或目录无写权限都会导致无法打开)' });
|
|
67
|
+
message: `无法打开 ${msg}`, hint: openFailureHint(openFailure) });
|
|
63
68
|
}
|
|
64
69
|
// ⚠️ internal 兜底(第四轮 I 组 H1/M8 修):spec §8.2 禁止把 DuckDB 英文原文裸透
|
|
65
70
|
// 给 Agent —— 必须中文包装 + 底层原文;hint 中性化(status 只读路径也会走到这里,
|
|
66
71
|
// 不能说「写入」)。
|
|
72
|
+
// ⚠️ hint 不得指向 `qiyu store status`(2026-11-07 审查):本函数是 `store init` 与
|
|
73
|
+
// `store status` **共用**的出口 —— 当失败的命令本身就是 `store status` 时,
|
|
74
|
+
// 「请用 store status 检查数据库状态」是在让 Agent 重跑刚失败的同一条命令(死循环)。
|
|
75
|
+
// 换成两个子命令都成立的诊断动作:换一个 --db 验证库本身是否有问题。
|
|
76
|
+
// ⚠️ 恢复命令必须经渲染器带出(store-hint-selection 的 BARE_HINT 守卫):
|
|
77
|
+
// 重建目标是一个**尚不存在的新路径**,渲染器只接路径 —— 用全仓统一的占位符 `<新路径>`
|
|
78
|
+
// 传入,替换契约(换成真实 .duckdb 路径、不要指回原文件)随 hint 一并写明。
|
|
67
79
|
return fail({ code: 'internal', kind: 'internal', retryable: false,
|
|
68
|
-
message: `存储操作失败(底层:${msg})`, hint: '
|
|
80
|
+
message: `存储操作失败(底层:${msg})`, hint: '数据库执行期错误(重跑同一条命令不会改变结果)。'
|
|
81
|
+
+ '请先用 --db 指向另一个库验证是否是该库的问题;若只有该库失败,请先备份该文件,再用 '
|
|
82
|
+
+ storeInitCommand('<新路径>', profileFlag) + ' 重建(把 <新路径> 整段替换成新的 .duckdb 文件路径,'
|
|
83
|
+
+ '不要指回出问题的文件 —— 本地库只是缓存),之后带同一个 --db 跑 '
|
|
84
|
+
+ syncRunCommand('<新路径>', profileFlag) + ' 可重新拉取' });
|
|
85
|
+
// ⚠️ `profileFlag` 必须随 hint 带出(CodeRabbit 2026-11-09 minor):`sync run` 从**解析出的
|
|
86
|
+
// 档**读 `store.options.knowledgeRobotIds` 与 `profiles.<name>.robots`(robotId 注入面),
|
|
87
|
+
// 只给 `--db` 的恢复命令会用错 robot 集合且不报错(真库实测:带 `--profile alpha` 解析出
|
|
88
|
+
// [1000001]、不带则为空)。调用点见本文件 storeCommand 两处与 sync.ts 的 openRo。
|
|
69
89
|
}
|
|
70
90
|
export async function storeCommand(argv) {
|
|
71
91
|
setPretty(false); // G1:每条命令入口重置输出格式 —— 同一进程内多次 run(测试)不残留上一条命令的开关。
|
|
72
92
|
const [sub, ...rest] = argv;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
// ⚠️ 无子命令 = 用法错误(退 2 + stdout JSON),**不是**裸文本帮助(2026-11-07 审查):
|
|
94
|
+
// 此前它和 `--help` 共用一个分支,把 USAGE 写进 stdout 并退 0 —— 而顶层 `run()`、
|
|
95
|
+
// `api` / `auth` / `query` / `skill` 五个命令族对同一形态都给 usageFail(退 2 + JSON)。
|
|
96
|
+
// `cli.ts` 的 USAGE 还明写「`--help` 是**唯一**以裸文本输出的情形」,README 则承诺
|
|
97
|
+
// 「Agent 靠退出码和 stdout 的 JSON 做决定」—— 裸文本让 `qiyu store | jq` 直接 parse error。
|
|
98
|
+
// 原始裁决见计划 2026-09-30 §无参数分支:「无参数是用法错误,不是『用户请求帮助』」。
|
|
99
|
+
if (sub === undefined) {
|
|
100
|
+
return usageFail(`用法:qiyu store <init|status> [参数](\`qiyu store --help\` 查看全部)`, '可用子命令:init、status');
|
|
101
|
+
}
|
|
102
|
+
if (sub === '--help' || sub === '-h') {
|
|
103
|
+
// --help 不吞**未知**参数;已知 flag 与子命令名/取值一律放行(2026-11-06 审查:
|
|
104
|
+
// `store status --db /tmp/x --help` 此前被 `GLOBAL_FLAG_NAMES` 判成「未知参数」退 2)。
|
|
105
|
+
const problem = helpArgsError(rest, STORE_SPECS.flatMap((sp) => sp.flags), '。--help 不接受额外参数');
|
|
106
|
+
if (problem !== undefined)
|
|
107
|
+
return usageFail(problem);
|
|
78
108
|
process.stdout.write(USAGE);
|
|
79
109
|
return 0;
|
|
80
110
|
}
|
|
@@ -82,15 +112,17 @@ export async function storeCommand(argv) {
|
|
|
82
112
|
// store 级:--pretty 是合法**输出开关**,但它必须写在具体子命令之后(`store init --pretty`)。
|
|
83
113
|
// 写在这里时没有任何子命令可修饰 —— 给出正确写法,而不是说成"未知子命令"(B 惯例)。
|
|
84
114
|
if (sub === '--pretty') {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
const problem = helpArgsError(rest, STORE_SPECS.flatMap((sp) => sp.flags));
|
|
116
|
+
if (problem !== undefined)
|
|
117
|
+
return usageFail(`${problem}。--pretty 不接受额外参数`);
|
|
118
|
+
const badPos = prettyPositionalProblem(rest, STORE_SPECS);
|
|
119
|
+
if (badPos !== undefined)
|
|
120
|
+
return usageFail(badPos);
|
|
90
121
|
if (rest.includes('--help') || rest.includes('-h')) {
|
|
91
122
|
process.stdout.write(USAGE);
|
|
92
123
|
return 0;
|
|
93
124
|
}
|
|
125
|
+
// ⚠️ 位置参数一律按「顺序写反」引导(2026-11-07 审查)—— 见 db.ts 同款注释。
|
|
94
126
|
return usageFail(prettyAfterSubcommand('store'));
|
|
95
127
|
}
|
|
96
128
|
return usageFail(`未知子命令:${sub}\n可用子命令:init、status`);
|
|
@@ -99,9 +131,9 @@ export async function storeCommand(argv) {
|
|
|
99
131
|
// ⚠️ 次序不能反:若先过滤「未知 token」再 parseStoreFlags,`store init --db <path>` 的
|
|
100
132
|
// --db 及其值会被当未知参数误拒(v1 计划的实测缺陷,D/F 组独立发现)。
|
|
101
133
|
if (rest.includes('--help') || rest.includes('-h')) {
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
return usageFail(
|
|
134
|
+
const problem = helpArgsError(rest, STORE_SPECS.flatMap((sp) => sp.flags));
|
|
135
|
+
if (problem !== undefined)
|
|
136
|
+
return usageFail(problem);
|
|
105
137
|
process.stdout.write(USAGE);
|
|
106
138
|
return 0;
|
|
107
139
|
}
|
|
@@ -117,16 +149,19 @@ export async function storeCommand(argv) {
|
|
|
117
149
|
}
|
|
118
150
|
// parseStoreFlags 之后剩下的 rest 才是真正的未知参数(带值 flag 的值位已被消费)
|
|
119
151
|
if (flags.rest.length > 0)
|
|
120
|
-
return usageFail(`未知参数:${flags.rest
|
|
152
|
+
return usageFail(`未知参数:${describeArgs(flags.rest)}`);
|
|
121
153
|
let resolved;
|
|
122
154
|
try {
|
|
123
155
|
resolved = resolveStoreConfig({ flags: { db: flags.db, profile: flags.profile, backend: flags.backend },
|
|
124
156
|
env: currentStoreEnv() });
|
|
157
|
+
// ⚠️ failFromTagged(不是 usageFail):配置层会抛带 `kind: config_insecure` 的错误
|
|
158
|
+
// (含凭证且权限过宽 —— 退出码 1、只能由人 chmod)。包成 usageFail 会把它降级成
|
|
159
|
+
// 「改参数重来」退出码 2 并丢掉 hint,与 auth/api 那条路径的说法相反。
|
|
125
160
|
}
|
|
126
161
|
catch (e) {
|
|
127
|
-
return
|
|
162
|
+
return failFromTagged(e);
|
|
128
163
|
}
|
|
129
|
-
const { config, configPath, configExists } = resolved;
|
|
164
|
+
const { config, configPath, configExists, profileFlag } = resolved;
|
|
130
165
|
if (sub === 'init') {
|
|
131
166
|
// 文件前置检查(spec §7.1 步骤 2;验收 41)
|
|
132
167
|
// ⚠️ lstat 异常按 errno 分流(K 组 M3):只有 ENOENT 才是「不存在 → DuckDB 会创建」;
|
|
@@ -149,13 +184,18 @@ export async function storeCommand(argv) {
|
|
|
149
184
|
}
|
|
150
185
|
}
|
|
151
186
|
if (st !== undefined && st.isFile() === false && st.isDirectory() === true) {
|
|
187
|
+
// ⚠️ 两处「非普通文件」文案走 `store-precheck.ts` 的 `nonRegularFileHint`(2026-10-31
|
|
188
|
+
// 单一实现点)——此前 init/status 与 db/sync 各写各的,`!isFile()` 这个判据
|
|
189
|
+
// 覆盖了目录 / FIFO / 设备 / 套接字 四种成因,而 status 只按「目录」写死文案,
|
|
190
|
+
// 对 FIFO 说出「你传了个目录」(假话)。init 的结构不并入共享实现(它的
|
|
191
|
+
// lstat/符号链接拒绝/建父目录是写路径特有),但这段文案与 status/db/sync 同源。
|
|
152
192
|
return fail({ code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
153
|
-
message: `不是普通文件:${config.path}`, hint:
|
|
193
|
+
message: `不是普通文件:${config.path}`, hint: nonRegularFileHint(true) });
|
|
154
194
|
}
|
|
155
195
|
if (st !== undefined && st.isFile() === false && st.isSymbolicLink() === false && st.isDirectory() === false) {
|
|
156
196
|
// 其它特殊文件(设备/套接字等)同样拒绝
|
|
157
197
|
return fail({ code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
158
|
-
message: `不是普通文件:${config.path}`, hint:
|
|
198
|
+
message: `不是普通文件:${config.path}`, hint: nonRegularFileHint(false) });
|
|
159
199
|
}
|
|
160
200
|
if (st !== undefined && st.isSymbolicLink() === true) {
|
|
161
201
|
return fail({ code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
@@ -181,76 +221,89 @@ export async function storeCommand(argv) {
|
|
|
181
221
|
store = await openStore(config, 'rw');
|
|
182
222
|
}
|
|
183
223
|
catch (e) {
|
|
184
|
-
return thrownToExit(e);
|
|
224
|
+
return thrownToExit(e, profileFlag);
|
|
185
225
|
}
|
|
186
226
|
try {
|
|
187
227
|
await store.init();
|
|
188
|
-
|
|
228
|
+
// ⚠️ 与 `store status` 同口径(2026-11-01):`store.tables()` 给的是**全库**清单
|
|
229
|
+
// (含未声明表),两个命令若一个全给、一个只给声明表,README 承诺的
|
|
230
|
+
// 「两边数量应当一致」就成了假话。未声明的表名进 warnings,不静默丢弃。
|
|
231
|
+
const all = await store.tables();
|
|
189
232
|
const sv = await store.query('SELECT COALESCE(MAX(version),0) AS v FROM schema_version');
|
|
233
|
+
const declared = new Set(TABLES.map((t) => t.name));
|
|
234
|
+
const warnings = storeTablesWarnings(all, config.path, profileFlag);
|
|
190
235
|
return ok({ path: config.path, backend: config.backend, config_path: configPath,
|
|
191
236
|
config_exists: configExists,
|
|
192
237
|
schema_version: Number(sv.rows[0]?.v ?? 0),
|
|
193
|
-
tables }
|
|
238
|
+
tables: all.filter((n) => declared.has(n)) }, warnings === undefined
|
|
239
|
+
? { field_notes: storeFieldNotes() }
|
|
240
|
+
: { field_notes: storeFieldNotes(), warnings });
|
|
194
241
|
}
|
|
195
242
|
catch (e) {
|
|
196
|
-
return thrownToExit(e);
|
|
243
|
+
return thrownToExit(e, profileFlag);
|
|
197
244
|
}
|
|
198
245
|
finally {
|
|
199
246
|
await store.close();
|
|
200
247
|
}
|
|
201
248
|
}
|
|
202
249
|
// status
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
// ⚠️ 修复批 2 裁定:D 交付后本 hint **不改指** `qiyu sync run`(设计稿 §9.5 的
|
|
215
|
-
// 「D 交付后改指 sync run」不再采纳)——「初始化存储」的最小命令是 store init,
|
|
216
|
-
// 且 sync status/verify 是只读命令,指它们跑一次写操作并非必要。
|
|
217
|
-
// 同步侧(sync status/verify/install、sync run 的 storeInitFail)与 C1 同口径。
|
|
218
|
-
}
|
|
219
|
-
return fail({ code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
220
|
-
message: `无法访问 ${config.path}:${e instanceof Error ? e.message : String(e)}`,
|
|
221
|
-
hint: '请检查路径权限(status 是只读命令,不需要写权限)' });
|
|
222
|
-
}
|
|
223
|
-
if (!st.isFile()) {
|
|
224
|
-
// ⚠️ P 组 P-H2:目录成因**不能**引导向 store init(init 也拒绝目录 → 死循环)——
|
|
225
|
-
// 独立 hint,与「不存在」成因分形。
|
|
226
|
-
return fail({ code: 'store_not_initialized', kind: 'store_not_initialized', retryable: false,
|
|
227
|
-
message: `不是普通文件:${config.path}`,
|
|
228
|
-
hint: '--db 指向的是目录而非数据库文件,请给出 .duckdb 数据库文件路径' });
|
|
229
|
-
}
|
|
250
|
+
// 库前置检查(ENOENT / 权限 / 非普通文件)走 `store-precheck.ts` 的 `statGuard`
|
|
251
|
+
// ——**唯一实现点**(2026-10-31 收敛)。此前这里自己写了一份,与 db/sync 那两份
|
|
252
|
+
// already 漂移出两种说法:本文件的权限 hint 写「status 是只读命令」、非普通文件写
|
|
253
|
+
// 「指向的是目录」(对 FIFO/设备是假话);db/sync 写「只读命令」「不是普通文件」。
|
|
254
|
+
// ⚠️ 「不存在」成因的裁定保留在此(不进共享实现):D 交付后本 hint **不改指**
|
|
255
|
+
// `qiyu sync run`(设计稿 §9.5 的「D 交付后改指 sync run」不再采纳)——「初始化存储」
|
|
256
|
+
// 的最小命令是 store init,且 sync status/verify 是只读命令,指它们跑一次写操作并非必要。
|
|
257
|
+
// 同步侧(sync status/verify/install、sync run 的 storeInitFail)与 C1 同口径。
|
|
258
|
+
const guarded = statGuard(config.path);
|
|
259
|
+
if (guarded !== null)
|
|
260
|
+
return guarded;
|
|
230
261
|
let store;
|
|
231
262
|
try {
|
|
232
263
|
store = await openStore(config, 'ro');
|
|
233
264
|
}
|
|
234
265
|
catch (e) {
|
|
235
|
-
return thrownToExit(e);
|
|
266
|
+
return thrownToExit(e, profileFlag);
|
|
236
267
|
}
|
|
237
268
|
try {
|
|
238
269
|
const names = await store.tables();
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
270
|
+
// ⚠️ 成因分形(他人库不引导向 init)在共享实现里,口径与 db/sync 逐字一致。
|
|
271
|
+
// ⚠️ 表名不是身份证明(2026-11-07 审查实测):他人工具的 schema_version 无 version 列时,
|
|
272
|
+
// 旧判据放行,下面的 MAX(version) 抛 Binder Error 落 internal「备份重建」—— 假归因。
|
|
273
|
+
const versionColumns = names.includes('schema_version')
|
|
274
|
+
? (await store.query(SCHEMA_VERSION_COLUMNS_SQL)).rows.map((r) => String(r.column_name))
|
|
275
|
+
: undefined;
|
|
276
|
+
const missing = schemaVersionMissing(config.path, names, versionColumns);
|
|
277
|
+
if (missing !== null)
|
|
278
|
+
return fail(missing);
|
|
244
279
|
const tables = [];
|
|
245
|
-
|
|
280
|
+
// ⚠️ 只能对**声明表**(`TABLES`)做 COUNT(2026-11-01 实测修):`store.count()` 内部
|
|
281
|
+
// 走 `assertTable`,库里有未声明的表(旧版 CLI 或其它工具建的)时抛 `usage`
|
|
282
|
+
// (`未知表:xxx`,退出码 2)—— 于是 `store status` 在**库恰好有漂移时整条命令失败**,
|
|
283
|
+
// 连 `schema_version` 都拿不到,而 `db tables` 对同一状态只是把它列进 warnings
|
|
284
|
+
//(README 与 `db tables` 都明确把「库中有而声明无」当作**要警告、不失败**的漂移)。
|
|
285
|
+
// `names` 来自全库 `information_schema`(含未声明表),因此必须按声明集过滤后再 COUNT;
|
|
286
|
+
// 未声明的表名进 warnings(不得静默 —— 与 `db tables` 同口径,README 承诺要报警)。
|
|
287
|
+
const undeclared = new Set(undeclaredTables(names));
|
|
288
|
+
for (const n of names) {
|
|
289
|
+
if (undeclared.has(n))
|
|
290
|
+
continue;
|
|
246
291
|
tables.push({ name: n, rows: await store.count(n) });
|
|
292
|
+
}
|
|
247
293
|
const sv = await store.query('SELECT COALESCE(MAX(version),0) AS v FROM schema_version');
|
|
294
|
+
// ⚠️ 两半漂移都进 warnings,**唯一渲染点**在 `storeTablesWarnings`(2026-11-02 实测修):
|
|
295
|
+
// 此前这里只算「库中有而声明无」,声明表被删时 tables 少了几张却零 warnings ——
|
|
296
|
+
// 同一库上 `db tables` 会警告、`store status` 报 ok 且干净,README 又教 Agent
|
|
297
|
+
// 「数量不等时先读 warnings」,于是 Agent 读到空 warnings 反而确认了「没事」。
|
|
298
|
+
const warnings = storeTablesWarnings(names, config.path, profileFlag);
|
|
248
299
|
return ok({ path: config.path, backend: config.backend, config_path: configPath,
|
|
249
300
|
config_exists: configExists,
|
|
250
|
-
schema_version: Number(sv.rows[0]?.v ?? 0), tables }
|
|
301
|
+
schema_version: Number(sv.rows[0]?.v ?? 0), tables }, warnings === undefined
|
|
302
|
+
? { field_notes: storeFieldNotes() }
|
|
303
|
+
: { field_notes: storeFieldNotes(), warnings });
|
|
251
304
|
}
|
|
252
305
|
catch (e) {
|
|
253
|
-
return thrownToExit(e);
|
|
306
|
+
return thrownToExit(e, profileFlag);
|
|
254
307
|
}
|
|
255
308
|
finally {
|
|
256
309
|
await store.close();
|