praxo-cli 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +159 -2
- package/dist/app.js +75 -0
- package/dist/bin.js +21 -0
- package/dist/cli/commands/ai.command.js +189 -0
- package/dist/cli/commands/cmd.command.js +265 -0
- package/dist/cli/commands/completion.command.js +334 -0
- package/dist/cli/commands/config.command.js +27 -0
- package/dist/cli/commands/decision.command.js +287 -0
- package/dist/cli/commands/doctor.command.js +45 -0
- package/dist/cli/commands/project.command.js +24 -0
- package/dist/cli/commands/search.command.js +59 -0
- package/dist/cli/commands/sync.command.js +122 -0
- package/dist/cli/commands/transfer.command.js +148 -0
- package/dist/cli/index.js +156 -0
- package/dist/cli/output.js +133 -0
- package/dist/cli/prompts.js +68 -0
- package/dist/features/ai/client.js +238 -0
- package/dist/features/ai/output.js +7 -0
- package/dist/features/ai/providers.js +52 -0
- package/dist/features/ai/schemas.js +43 -0
- package/dist/features/ai/service.js +183 -0
- package/dist/features/commands/executor.js +54 -0
- package/dist/features/commands/repository.js +61 -0
- package/dist/features/commands/safety.js +154 -0
- package/dist/features/commands/service.js +254 -0
- package/dist/features/commands/template.js +153 -0
- package/dist/features/decisions/repository.js +53 -0
- package/dist/features/decisions/service.js +209 -0
- package/dist/features/decisions/stats.js +84 -0
- package/dist/features/decisions/status.js +7 -0
- package/dist/features/projects/repository.js +51 -0
- package/dist/features/projects/service.js +74 -0
- package/dist/features/sync/git.js +207 -0
- package/dist/features/sync/merge.js +194 -0
- package/dist/features/sync/repository.js +151 -0
- package/dist/features/sync/sanitizer.js +21 -0
- package/dist/features/sync/service.js +199 -0
- package/dist/features/sync/snapshot.js +230 -0
- package/dist/infrastructure/credentials/store.js +105 -0
- package/dist/infrastructure/database/client.js +41 -0
- package/dist/infrastructure/database/migrate.js +102 -0
- package/dist/infrastructure/database/schema.js +138 -0
- package/dist/infrastructure/git/detector.js +48 -0
- package/dist/shared/clipboard.js +19 -0
- package/dist/shared/config.js +163 -0
- package/dist/shared/doctor.js +47 -0
- package/dist/shared/errors.js +19 -0
- package/dist/shared/global-search.js +51 -0
- package/dist/shared/input.js +37 -0
- package/dist/shared/links.js +48 -0
- package/dist/shared/paths.js +14 -0
- package/dist/shared/query.js +10 -0
- package/dist/shared/redaction.js +54 -0
- package/dist/shared/search.js +39 -0
- package/dist/shared/sync-metadata.js +7 -0
- package/dist/shared/tags.js +91 -0
- package/dist/shared/transfer/archive.js +197 -0
- package/dist/shared/transfer/markdown.js +53 -0
- package/dist/shared/transfer/service.js +278 -0
- package/dist/tui/Workspace.js +121 -0
- package/dist/tui/components/AiPanel.js +200 -0
- package/dist/tui/components/Catalog.js +47 -0
- package/dist/tui/components/Confirm.js +28 -0
- package/dist/tui/components/Form.js +113 -0
- package/dist/tui/components/HelpModal.js +44 -0
- package/dist/tui/components/Inspection.js +28 -0
- package/dist/tui/components/KeyHints.js +7 -0
- package/dist/tui/components/SearchInput.js +31 -0
- package/dist/tui/components/SyncPanel.js +93 -0
- package/dist/tui/index.js +18 -0
- package/dist/tui/screens/Commands.js +383 -0
- package/dist/tui/screens/DecisionForms.js +117 -0
- package/dist/tui/screens/Decisions.js +260 -0
- package/dist/tui/screens/Lookup.js +96 -0
- package/dist/tui/theme.js +47 -0
- package/drizzle/0000_initial.sql +105 -0
- package/drizzle/0001_v11_sync.sql +117 -0
- package/drizzle/meta/0000_snapshot.json +735 -0
- package/drizzle/meta/0001_snapshot.json +867 -0
- package/drizzle/meta/_journal.json +20 -0
- package/package.json +77 -4
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Spinner } from '@inkjs/ui';
|
|
3
|
+
import { Box, Text, useApp, useInput } from 'ink';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
6
|
+
import { parseTemplate } from '../../features/commands/template.js';
|
|
7
|
+
import { AppError, messageOf } from '../../shared/errors.js';
|
|
8
|
+
import { Catalog, useCatalog } from '../components/Catalog.js';
|
|
9
|
+
import { AiPanel } from '../components/AiPanel.js';
|
|
10
|
+
import { Confirm } from '../components/Confirm.js';
|
|
11
|
+
import { Form } from '../components/Form.js';
|
|
12
|
+
import { Inspection } from '../components/Inspection.js';
|
|
13
|
+
import { KeyHints } from '../components/KeyHints.js';
|
|
14
|
+
import { SearchInput } from '../components/SearchInput.js';
|
|
15
|
+
import { theme } from '../theme.js';
|
|
16
|
+
const splitTags = (text) => text
|
|
17
|
+
?.split(',')
|
|
18
|
+
.map((part) => part.trim())
|
|
19
|
+
.filter(Boolean) ?? [];
|
|
20
|
+
const optional = (text) => text?.trim() || undefined;
|
|
21
|
+
const trueOrFalse = (value) => value === 'yes';
|
|
22
|
+
/** 构造命令新增或编辑表单字段列表。 */
|
|
23
|
+
function editorFields(item) {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
key: 'template',
|
|
27
|
+
label: '命令模板',
|
|
28
|
+
initial: item?.template,
|
|
29
|
+
placeholder: '支持 {{var:default}}',
|
|
30
|
+
},
|
|
31
|
+
{ key: 'name', label: '命令名称', initial: item?.name, placeholder: '留空则按模板自动生成' },
|
|
32
|
+
{ key: 'note', label: '说明备注', initial: item?.note },
|
|
33
|
+
{ key: 'type', label: '技术类型', initial: item?.type ?? 'custom' },
|
|
34
|
+
{
|
|
35
|
+
key: 'tier',
|
|
36
|
+
label: '优先级',
|
|
37
|
+
initial: item?.tier ?? 'normal',
|
|
38
|
+
placeholder: 'hot 或 normal',
|
|
39
|
+
},
|
|
40
|
+
{ key: 'sos', label: '排障标记 SOS (yes/no)', initial: item?.sos ? 'yes' : 'no' },
|
|
41
|
+
{ key: 'danger', label: '高危标记 (yes/no)', initial: item?.danger ? 'yes' : 'no' },
|
|
42
|
+
{
|
|
43
|
+
key: 'scope',
|
|
44
|
+
label: '作用域',
|
|
45
|
+
initial: item ? (item.projectId ? 'project' : 'global') : 'auto',
|
|
46
|
+
placeholder: item ? 'global 或 project' : 'auto / global / project',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: 'project',
|
|
50
|
+
label: '项目 ID',
|
|
51
|
+
initial: item?.projectId ?? undefined,
|
|
52
|
+
placeholder: '留空自动使用当前项目',
|
|
53
|
+
},
|
|
54
|
+
...(item ? [] : [{ key: 'tags', label: '标签 (逗号分隔)' }]),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
/** 校验并转换命令表单输入为服务层参数。 */
|
|
58
|
+
function commandInput(values) {
|
|
59
|
+
for (const key of ['sos', 'danger']) {
|
|
60
|
+
if (values[key] !== 'yes' && values[key] !== 'no')
|
|
61
|
+
throw new AppError(2, '请为 ' + key + ' 输入 yes 或 no。');
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
template: values.template ?? '',
|
|
65
|
+
name: optional(values.name),
|
|
66
|
+
type: optional(values.type),
|
|
67
|
+
note: values.note,
|
|
68
|
+
tier: values.tier,
|
|
69
|
+
sos: trueOrFalse(values.sos),
|
|
70
|
+
danger: trueOrFalse(values.danger),
|
|
71
|
+
scope: values.scope,
|
|
72
|
+
project: optional(values.project),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** 安全解析命令模板变量列表,供详情面板展示。 */
|
|
76
|
+
function extractVariables(template) {
|
|
77
|
+
try {
|
|
78
|
+
return parseTemplate(template).variables;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** 命令详情展示区:克制留白、突出命令模板与变量,所有区块锁定 flexShrink=0 防挤压重叠。 */
|
|
85
|
+
export function CommandDetails({ item }) {
|
|
86
|
+
if (!item) {
|
|
87
|
+
return (_jsxs(Box, { flexDirection: "column", gap: 1, flexShrink: 0, children: [_jsx(Text, { bold: true, children: "Command Vault" }), _jsx(Text, { dimColor: true, children: "\u672C\u5730\u547D\u4EE4\u5E93 \u00B7 \u6A21\u677F\u53D8\u91CF \u00B7 \u5B89\u5168\u6267\u884C" }), _jsxs(Box, { flexDirection: "column", marginTop: 1, flexShrink: 0, children: [_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 3, flexShrink: 0, children: _jsx(Text, { bold: true, color: theme.accent, children: "A" }) }), _jsxs(Text, { dimColor: true, children: ["\u65B0\u589E\u547D\u4EE4\uFF0C\u652F\u6301 ", '{{port:3000}}', " \u53D8\u91CF"] })] }), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 3, flexShrink: 0, children: _jsx(Text, { bold: true, color: theme.accent, children: "/" }) }), _jsx(Text, { dimColor: true, children: "\u5728\u9876\u90E8\u8F93\u5165\u884C\u5B9E\u65F6\u8FC7\u6EE4" })] }), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 3, flexShrink: 0, children: _jsx(Text, { bold: true, color: theme.accent, children: "?" }) }), _jsx(Text, { dimColor: true, children: "\u67E5\u770B\u5B8C\u6574\u5FEB\u6377\u952E" })] })] })] }));
|
|
88
|
+
}
|
|
89
|
+
const variables = extractVariables(item.template);
|
|
90
|
+
return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsxs(Box, { gap: 2, flexWrap: "wrap", flexShrink: 0, children: [_jsx(Text, { bold: true, children: item.name }), item.tier === 'hot' && (_jsx(Text, { bold: true, color: theme.hot, children: "[HOT]" })), item.sos && (_jsx(Text, { bold: true, color: theme.sos, children: "[SOS]" })), item.danger && (_jsx(Text, { bold: true, color: theme.danger, children: "[\u9AD8\u5371]" }))] }), _jsx(Box, { borderStyle: "round", borderColor: item.danger ? theme.danger : theme.border, borderDimColor: !item.danger, paddingX: 1, marginTop: 1, flexShrink: 0, children: _jsxs(Text, { color: theme.accent, bold: true, wrap: "truncate-end", children: ["$ ", item.template] }) }), variables.length > 0 && (_jsx(Box, { marginBottom: 1, flexShrink: 0, children: _jsxs(Text, { dimColor: true, wrap: "truncate-end", children: ["\u53D8\u91CF:", ' ', variables
|
|
91
|
+
.map((v) => v.fallback !== undefined ? `${v.name}=${v.fallback}` : `${v.name} (必填)`)
|
|
92
|
+
.join(' · ')] }) })), item.note && (_jsx(Box, { marginBottom: 1, flexShrink: 0, children: _jsx(Text, { wrap: "truncate-end", children: item.note }) })), _jsxs(Box, { flexDirection: "column", marginTop: 1, flexShrink: 0, children: [_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u5206\u7C7B" }) }), _jsx(Text, { children: item.type })] }), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u4F5C\u7528\u57DF" }) }), _jsx(Text, { children: item.projectName ?? 'Global' })] }), item.tags.length > 0 && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u6807\u7B7E" }) }), _jsx(Text, { color: theme.tag, children: item.tags.map((tag) => '#' + tag).join(' ') })] })), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u7EDF\u8BA1" }) }), _jsxs(Text, { dimColor: true, children: ["\u590D\u5236 ", item.copyCount, " \u00B7 \u6267\u884C ", item.runCount] })] })] }), _jsx(Box, { marginTop: 1, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: item.id }) })] }));
|
|
93
|
+
}
|
|
94
|
+
/** Command Vault 主界面:国际标准极客键位(/ 展开实时搜索、y/Enter 复制、d/Del 删除、Esc 永不误退)。 */
|
|
95
|
+
export function CommandsScreen({ app, active, initialId, refreshToken, lock, onChanged, setInterrupt, onLinks, }) {
|
|
96
|
+
const { suspendTerminal } = useApp();
|
|
97
|
+
const [query, setQuery] = useState('');
|
|
98
|
+
const [searching, setSearching] = useState(false);
|
|
99
|
+
const [searchSession, bumpSearch] = useState(0);
|
|
100
|
+
const [filters, setFilters] = useState({});
|
|
101
|
+
const [revision, refresh] = useState(0);
|
|
102
|
+
const [view, setView] = useState();
|
|
103
|
+
const [tail, setTail] = useState([]);
|
|
104
|
+
const [message, setMessage] = useState();
|
|
105
|
+
const results = useMemo(() => {
|
|
106
|
+
try {
|
|
107
|
+
const items = app.commands.candidates(filters, query.trim() || undefined);
|
|
108
|
+
if (initialId && !items.some((item) => item.id === initialId)) {
|
|
109
|
+
try {
|
|
110
|
+
items.unshift(app.commands.show(initialId));
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
/* 删除后保留当前列表。 */
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { items };
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return { items: [], error: messageOf(error) };
|
|
120
|
+
}
|
|
121
|
+
}, [app, filters, initialId, query, revision, refreshToken]);
|
|
122
|
+
const catalog = useCatalog(results.items, initialId);
|
|
123
|
+
const item = catalog.item;
|
|
124
|
+
const filterText = [
|
|
125
|
+
filters.type,
|
|
126
|
+
filters.tier,
|
|
127
|
+
filters.sos && 'SOS',
|
|
128
|
+
filters.scope,
|
|
129
|
+
...(filters.tags ?? []),
|
|
130
|
+
]
|
|
131
|
+
.filter(Boolean)
|
|
132
|
+
.join(' · ');
|
|
133
|
+
function open(next) {
|
|
134
|
+
setSearching(false);
|
|
135
|
+
setView(next);
|
|
136
|
+
lock(Boolean(next));
|
|
137
|
+
}
|
|
138
|
+
function startSearch() {
|
|
139
|
+
setSearching(true);
|
|
140
|
+
catalog.setFocus(0);
|
|
141
|
+
lock(true);
|
|
142
|
+
}
|
|
143
|
+
function stopSearch() {
|
|
144
|
+
setSearching(false);
|
|
145
|
+
catalog.setFocus(2);
|
|
146
|
+
lock(false);
|
|
147
|
+
}
|
|
148
|
+
function done(text, id) {
|
|
149
|
+
setMessage({ text });
|
|
150
|
+
if (id)
|
|
151
|
+
catalog.select(id);
|
|
152
|
+
refresh((value) => value + 1);
|
|
153
|
+
onChanged?.();
|
|
154
|
+
open();
|
|
155
|
+
}
|
|
156
|
+
async function work(action) {
|
|
157
|
+
try {
|
|
158
|
+
await action();
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
open();
|
|
162
|
+
refresh((value) => value + 1);
|
|
163
|
+
setMessage({ text: messageOf(error), error: true });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function useCommand(record, action, values) {
|
|
167
|
+
const names = app.commands.variables(record.id, values);
|
|
168
|
+
if (names.length)
|
|
169
|
+
return open({ kind: 'variables', item: record, action, names });
|
|
170
|
+
if (action === 'copy') {
|
|
171
|
+
if (!view)
|
|
172
|
+
open({ kind: 'busy' });
|
|
173
|
+
await app.commands.copy(record.id, values);
|
|
174
|
+
return done('已复制到剪贴板');
|
|
175
|
+
}
|
|
176
|
+
const plan = app.commands.prepare(record.id, values);
|
|
177
|
+
if (plan.risk.kind === 'copy-only')
|
|
178
|
+
throw new AppError(4, plan.risk.reason);
|
|
179
|
+
if (plan.risk.kind === 'parent-shell') {
|
|
180
|
+
if (!view)
|
|
181
|
+
open({ kind: 'busy' });
|
|
182
|
+
const result = await app.commands.run(record.id, values, 'interactive', plan);
|
|
183
|
+
return done(result.kind === 'copied' ? result.reason + ' 已自动复制' : '命令执行完成');
|
|
184
|
+
}
|
|
185
|
+
open({ kind: 'confirm', item: record, plan, values });
|
|
186
|
+
}
|
|
187
|
+
async function run(view, approval) {
|
|
188
|
+
if (process.platform === 'win32') {
|
|
189
|
+
const cancellation = new AbortController();
|
|
190
|
+
setInterrupt(() => cancellation.abort());
|
|
191
|
+
setTail([]);
|
|
192
|
+
open({ kind: 'capturing' });
|
|
193
|
+
let output = '';
|
|
194
|
+
let lastPaint = 0;
|
|
195
|
+
let status = '命令执行完成。';
|
|
196
|
+
try {
|
|
197
|
+
await app.commands.run(view.item.id, view.values, approval, view.plan, {
|
|
198
|
+
signal: cancellation.signal,
|
|
199
|
+
onOutput: (chunk) => {
|
|
200
|
+
output = (output + chunk).slice(-64 * 1024);
|
|
201
|
+
const now = Date.now();
|
|
202
|
+
if (now - lastPaint >= 100) {
|
|
203
|
+
setTail(outputLines(output).slice(-6));
|
|
204
|
+
lastPaint = now;
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
status = messageOf(error);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
setInterrupt();
|
|
214
|
+
}
|
|
215
|
+
refresh((value) => value + 1);
|
|
216
|
+
open({ kind: 'output', lines: [status, ...outputLines(output)] });
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
open({ kind: 'busy' });
|
|
220
|
+
await work(async () => {
|
|
221
|
+
await suspendTerminal(async () => {
|
|
222
|
+
await app.commands.run(view.item.id, view.values, approval, view.plan);
|
|
223
|
+
});
|
|
224
|
+
done('命令执行完成');
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
useInput((key, info) => {
|
|
228
|
+
if (info.escape) {
|
|
229
|
+
if (catalog.detail) {
|
|
230
|
+
catalog.setDetail(false);
|
|
231
|
+
catalog.setFocus(2);
|
|
232
|
+
}
|
|
233
|
+
else if (query || filterText) {
|
|
234
|
+
setQuery('');
|
|
235
|
+
setFilters({});
|
|
236
|
+
bumpSearch((v) => v + 1);
|
|
237
|
+
setMessage({ text: '已清空筛选' });
|
|
238
|
+
}
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (key === '/')
|
|
242
|
+
return startSearch();
|
|
243
|
+
if (key === 'A' && !catalog.detail && !info.ctrl && !info.meta)
|
|
244
|
+
return open({ kind: 'ai', task: { type: 'generate' } });
|
|
245
|
+
if (key === 'f' && !info.ctrl)
|
|
246
|
+
return open({ kind: 'filter' });
|
|
247
|
+
if ((key === 'a' || key === 'n') && !info.ctrl)
|
|
248
|
+
return open({ kind: 'add' });
|
|
249
|
+
if (info.upArrow || (key === 'k' && !info.ctrl))
|
|
250
|
+
return catalog.move(-1);
|
|
251
|
+
if (info.downArrow || (key === 'j' && !info.ctrl))
|
|
252
|
+
return catalog.move(1);
|
|
253
|
+
if (key === 'g' && !info.ctrl)
|
|
254
|
+
return catalog.jump('start');
|
|
255
|
+
if (key === 'G' && !info.ctrl)
|
|
256
|
+
return catalog.jump('end');
|
|
257
|
+
if (!item)
|
|
258
|
+
return;
|
|
259
|
+
if (key === 'I' && (catalog.detail || catalog.focus === 3) && !info.ctrl && !info.meta)
|
|
260
|
+
return open({ kind: 'ai', task: { type: 'explain', command: item.template } });
|
|
261
|
+
if (info.rightArrow) {
|
|
262
|
+
catalog.setDetail(true);
|
|
263
|
+
catalog.setFocus(3);
|
|
264
|
+
}
|
|
265
|
+
if (info.leftArrow) {
|
|
266
|
+
catalog.setDetail(false);
|
|
267
|
+
catalog.setFocus(2);
|
|
268
|
+
}
|
|
269
|
+
if (info.return || (key === 'y' && !info.ctrl))
|
|
270
|
+
void work(() => useCommand(item, 'copy', new Map()));
|
|
271
|
+
if (key.toLowerCase() === 'r' && !info.meta)
|
|
272
|
+
void work(() => useCommand(item, 'run', new Map()));
|
|
273
|
+
if (key === 'e' && !info.ctrl)
|
|
274
|
+
open({ kind: 'edit', item });
|
|
275
|
+
if (info.delete || info.backspace || (key === 'd' && !info.ctrl))
|
|
276
|
+
open({ kind: 'delete', item });
|
|
277
|
+
if (key === 't' && !info.ctrl)
|
|
278
|
+
open({ kind: 'tag', item });
|
|
279
|
+
if (key === 'l' && !info.ctrl)
|
|
280
|
+
onLinks?.(item.id);
|
|
281
|
+
}, { isActive: active && !view && !searching });
|
|
282
|
+
const cancel = () => open();
|
|
283
|
+
if (view?.kind === 'ai')
|
|
284
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(AiPanel, { app: app, task: view.task, onClose: cancel, onChanged: (id) => done('AI 命令草稿已保存', id) }) }));
|
|
285
|
+
if (view?.kind === 'output')
|
|
286
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Inspection, { title: "\u547D\u4EE4\u6267\u884C\u8F93\u51FA", lines: view.lines, onClose: cancel }) }));
|
|
287
|
+
if (view?.kind === 'capturing')
|
|
288
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.warning, paddingX: 2, paddingY: 1, children: [_jsx(Spinner, { label: "\u6B63\u5728\u6267\u884C\u547D\u4EE4\u2026 \u6309 Ctrl+C \u4E2D\u6B62" }), tail.length > 0 && (_jsx(Box, { flexDirection: "column", marginTop: 1, children: tail.map((line, index) => (_jsx(Text, { wrap: "truncate-end", dimColor: true, children: line }, index))) }))] }) }));
|
|
289
|
+
if (view?.kind === 'busy')
|
|
290
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Spinner, { label: "\u6B63\u5728\u5904\u7406\u2026" }) }));
|
|
291
|
+
if (view?.kind === 'filter')
|
|
292
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Form, { title: "\u7B5B\u9009\u547D\u4EE4", fields: [
|
|
293
|
+
{
|
|
294
|
+
key: 'type',
|
|
295
|
+
label: '技术类型',
|
|
296
|
+
initial: filters.type,
|
|
297
|
+
placeholder: 'git / docker / network 等',
|
|
298
|
+
},
|
|
299
|
+
{ key: 'tier', label: '优先级 (hot/normal)', initial: filters.tier },
|
|
300
|
+
{ key: 'sos', label: '仅看 SOS (yes/留空)', initial: filters.sos ? 'yes' : '' },
|
|
301
|
+
{ key: 'scope', label: '作用域 (global/project/all)', initial: filters.scope },
|
|
302
|
+
{ key: 'tags', label: '标签 (逗号分隔)', initial: filters.tags?.join(', ') },
|
|
303
|
+
], onCancel: cancel, onSave: (data) => {
|
|
304
|
+
if (data.sos && data.sos !== 'yes')
|
|
305
|
+
throw new AppError(2, 'SOS 筛选请输入 yes 或留空。');
|
|
306
|
+
const next = {
|
|
307
|
+
type: optional(data.type),
|
|
308
|
+
tier: optional(data.tier),
|
|
309
|
+
sos: data.sos === 'yes' ? true : undefined,
|
|
310
|
+
scope: optional(data.scope),
|
|
311
|
+
tags: splitTags(data.tags),
|
|
312
|
+
};
|
|
313
|
+
app.commands.list(next);
|
|
314
|
+
setFilters(next);
|
|
315
|
+
catalog.setFocus(2);
|
|
316
|
+
cancel();
|
|
317
|
+
} }) }));
|
|
318
|
+
if (view?.kind === 'add' || view?.kind === 'edit') {
|
|
319
|
+
const record = view.kind === 'edit' ? view.item : undefined;
|
|
320
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Form, { title: record ? '编辑命令' : '新增命令', fields: editorFields(record), onCancel: cancel, onSave: (values) => {
|
|
321
|
+
const input = commandInput(values);
|
|
322
|
+
const updated = record
|
|
323
|
+
? app.commands.edit(record.id, {
|
|
324
|
+
...input,
|
|
325
|
+
scope: input.scope,
|
|
326
|
+
})
|
|
327
|
+
: app.commands.create({ ...input, tags: splitTags(values.tags) });
|
|
328
|
+
done(record ? '命令已更新' : '命令已保存', updated.id);
|
|
329
|
+
} }) }));
|
|
330
|
+
}
|
|
331
|
+
if (view?.kind === 'delete')
|
|
332
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Confirm, { title: `确认删除命令「${view.item.name}」?`, tone: "danger", onCancel: cancel, onAccept: () => void work(() => {
|
|
333
|
+
app.commands.remove(view.item.id);
|
|
334
|
+
done('命令已删除');
|
|
335
|
+
}) }) }));
|
|
336
|
+
if (view?.kind === 'tag')
|
|
337
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Form, { title: `管理标签 · ${view.item.name}`, fields: [
|
|
338
|
+
{ key: 'action', label: '操作 (add/remove)', initial: 'add' },
|
|
339
|
+
{ key: 'name', label: '标签名' },
|
|
340
|
+
], onCancel: cancel, onSave: (data) => {
|
|
341
|
+
if (data.action !== 'add' && data.action !== 'remove')
|
|
342
|
+
throw new AppError(2, '操作请输入 add 或 remove。');
|
|
343
|
+
app.commands.tag(view.item.id, data.action, data.name ?? '');
|
|
344
|
+
done('标签已更新');
|
|
345
|
+
} }) }));
|
|
346
|
+
if (view?.kind === 'variables')
|
|
347
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Form, { title: view.action === 'copy' ? '填写变量并复制' : '填写变量并执行', lead: _jsxs(Text, { dimColor: true, children: ["$ ", view.item.template] }), fields: view.names.map((name) => ({ key: name, label: name })), onCancel: cancel, onSave: (data) => useCommand(view.item, view.action, new Map(Object.entries(data))) }) }));
|
|
348
|
+
if (view?.kind === 'confirm')
|
|
349
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsxs(Confirm, { title: view.plan.risk.kind === 'high' ? '高危命令执行确认' : '确认执行以下命令?', tone: view.plan.risk.kind === 'high' ? 'danger' : 'warning', onCancel: cancel, onAccept: () => {
|
|
350
|
+
if (view.plan.risk.kind === 'high')
|
|
351
|
+
open({ ...view, kind: 'danger' });
|
|
352
|
+
else
|
|
353
|
+
void run(view, 'interactive');
|
|
354
|
+
}, children: [_jsxs(Text, { bold: true, color: theme.accent, children: ["$ ", view.plan.text] }), 'executable' in view.plan.risk && (_jsxs(Text, { dimColor: true, children: ["\u53C2\u6570\u5411\u91CF: ", JSON.stringify([view.plan.risk.executable, ...view.plan.risk.args])] })), _jsx(Text, { color: view.plan.risk.kind === 'high' ? theme.warning : undefined, children: view.plan.risk.reason })] }) }));
|
|
355
|
+
if (view?.kind === 'danger')
|
|
356
|
+
return (_jsx(Box, { flexDirection: "column", flexGrow: 1, padding: 1, children: _jsx(Form, { title: "\u9AD8\u5371\u64CD\u4F5C\u4E8C\u6B21\u786E\u8BA4", lead: _jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: theme.danger, children: "\u26A0 \u8BF7\u786E\u8BA4\u4F60\u4E86\u89E3\u8BE5\u547D\u4EE4\u7684\u7834\u574F\u6027\u5F71\u54CD\uFF1A" }), _jsxs(Text, { color: theme.warning, children: ["$ ", view.plan.text] })] }), fields: [{ key: 'confirm', label: '输入 RUN 以继续' }], onCancel: cancel, onSave: (data) => {
|
|
357
|
+
if (data.confirm !== 'RUN')
|
|
358
|
+
throw new AppError(4, '高危确认未通过:请准确输入大写 RUN。');
|
|
359
|
+
return run(view, 'typed');
|
|
360
|
+
} }, "danger") }));
|
|
361
|
+
const status = results.error ? { text: results.error, error: true } : message;
|
|
362
|
+
const hints = searching
|
|
363
|
+
? [
|
|
364
|
+
{ key: '↑↓', label: '选择' },
|
|
365
|
+
{ key: 'Enter', label: '定位列表' },
|
|
366
|
+
{ key: 'Esc', label: '退出输入' },
|
|
367
|
+
]
|
|
368
|
+
: [
|
|
369
|
+
{ key: '/', label: '搜索' },
|
|
370
|
+
{ key: 'Enter', label: '复制' },
|
|
371
|
+
{ key: 'r', label: '执行' },
|
|
372
|
+
{ key: 'a', label: '新增' },
|
|
373
|
+
{ key: '?', label: '帮助' },
|
|
374
|
+
];
|
|
375
|
+
return (_jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [_jsx(Catalog, { items: results.items, index: catalog.index, showDetails: catalog.detail, focus: catalog.focus, listTitle: "Commands", renderItem: (row, selected) => (_jsxs(Box, { gap: 1, children: [_jsx(Text, { bold: selected, color: selected ? theme.accent : undefined, children: selected ? '❯' : ' ' }), _jsx(Text, { bold: selected, color: selected ? theme.accent : undefined, wrap: "truncate-end", children: row.name }), row.tier === 'hot' && (_jsx(Text, { bold: true, color: theme.hot, children: "[HOT]" })), row.sos && (_jsx(Text, { bold: true, color: theme.sos, children: "[SOS]" })), row.danger && (_jsx(Text, { bold: true, color: theme.danger, children: "[!]" }))] })), toolbar: _jsx(SearchInput, { value: query, session: searchSession, active: searching, activePlaceholder: "\u8F93\u5165\u5173\u952E\u8BCD\u7B5B\u9009\u547D\u4EE4\u2026", filters: filterText, count: results.items.length, onChange: setQuery, onSubmit: stopSearch, onCancel: stopSearch, onMove: catalog.move }), details: _jsx(CommandDetails, { item: item }), empty: query || filterText ? '无匹配结果,Esc 清空' : '暂无命令,按 a 新增,A 生成草稿' }), _jsx(KeyHints, { items: hints, status: status })] }));
|
|
376
|
+
}
|
|
377
|
+
/** 清理子进程输出中的控制字符并拆分为安全可展示的文本行。 */
|
|
378
|
+
function outputLines(output) {
|
|
379
|
+
return stripVTControlCharacters(output)
|
|
380
|
+
.split(/\r\n|\r|\n/u)
|
|
381
|
+
.map((part) => [...part].filter((character) => character.charCodeAt(0) >= 32 || character === '\t').join(''))
|
|
382
|
+
.filter(Boolean);
|
|
383
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useWindowSize } from 'ink';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { AiSettings, useAiApproval } from '../components/AiPanel.js';
|
|
5
|
+
import { AppError } from '../../shared/errors.js';
|
|
6
|
+
import { Form } from '../components/Form.js';
|
|
7
|
+
import { confidenceBar, decisionStatusColor, decisionStatusLabel, theme, WIDE_BREAKPOINT, } from '../theme.js';
|
|
8
|
+
/** 决策详情展示区:突出状态徽章、复盘日期、信心进度条与决策依据;所有区块锁定 flexShrink=0 防挤压。 */
|
|
9
|
+
export function DecisionDetails({ item }) {
|
|
10
|
+
if (!item) {
|
|
11
|
+
return (_jsxs(Box, { flexDirection: "column", gap: 1, flexShrink: 0, children: [_jsx(Text, { bold: true, children: "Decision Log" }), _jsx(Text, { dimColor: true, children: "\u51B3\u7B56\u8BB0\u5F55 \u00B7 \u5B9A\u671F\u590D\u76D8 \u00B7 \u7ECF\u9A8C\u6C89\u6DC0" }), _jsxs(Box, { flexDirection: "column", marginTop: 1, flexShrink: 0, children: [_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 3, flexShrink: 0, children: _jsx(Text, { bold: true, color: theme.accent, children: "A" }) }), _jsx(Text, { dimColor: true, children: "30 \u79D2\u8BB0\u5F55\u4E00\u6761\u51B3\u7B56\uFF08\u9ED8\u8BA4 90 \u5929\u540E\u590D\u76D8\uFF09" })] }), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 3, flexShrink: 0, children: _jsx(Text, { bold: true, color: theme.accent, children: "R" }) }), _jsx(Text, { dimColor: true, children: "\u6253\u5F00\u300C\u5F53\u65F6 vs \u73B0\u5728\u300D\u5BF9\u6BD4\u590D\u76D8" })] }), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 3, flexShrink: 0, children: _jsx(Text, { bold: true, color: theme.accent, children: "S" }) }), _jsx(Text, { dimColor: true, children: "\u67E5\u770B\u51B3\u7B56\u7EDF\u8BA1\u4E0E\u9AD8\u4FE1\u5FC3\u51C6\u786E\u7387" })] })] })] }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsxs(Box, { gap: 2, flexWrap: "wrap", flexShrink: 0, children: [_jsx(Text, { bold: true, children: item.title }), _jsxs(Text, { bold: true, color: decisionStatusColor(item.status), children: ["[", decisionStatusLabel(item.status), "]"] })] }), _jsxs(Box, { gap: 3, marginTop: 1, flexShrink: 0, children: [_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Text, { dimColor: true, children: "\u590D\u76D8" }), _jsx(Text, { color: item.status === 'due' ? theme.warning : undefined, bold: item.status === 'due', children: item.reviewAt })] }), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Text, { dimColor: true, children: "\u4FE1\u5FC3" }), _jsx(Text, { color: theme.accent, children: confidenceBar(item.confidence) })] })] }), _jsxs(Box, { flexDirection: "column", marginTop: 1, flexShrink: 0, children: [item.content && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u5185\u5BB9" }) }), _jsx(Text, { wrap: "truncate-end", children: item.content })] })), item.reason && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u4F9D\u636E" }) }), _jsx(Text, { wrap: "truncate-end", children: item.reason })] })), item.alternatives && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u5907\u9009" }) }), _jsx(Text, { wrap: "truncate-end", children: item.alternatives })] })), item.aiNote && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "AI \u5907\u6CE8" }) }), _jsx(Text, { wrap: "truncate-end", children: item.aiNote.split(/\r?\n/u).filter(Boolean).join(' · ') })] })), item.expected && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u9884\u671F" }) }), _jsx(Text, { wrap: "truncate-end", children: item.expected })] }))] }), _jsxs(Box, { flexDirection: "column", marginTop: 1, flexShrink: 0, children: [_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u9886\u57DF" }) }), _jsx(Text, { children: item.domain })] }), _jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u4F5C\u7528\u57DF" }) }), _jsx(Text, { children: item.projectName ?? 'Global' })] }), item.tags.length > 0 && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(Box, { width: 6, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: "\u6807\u7B7E" }) }), _jsx(Text, { color: theme.tag, children: item.tags.map((tag) => '#' + tag).join(' ') })] }))] }), _jsx(Box, { marginTop: 1, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: item.id }) })] }));
|
|
14
|
+
}
|
|
15
|
+
function dateChoice(value) {
|
|
16
|
+
const interval = /^([1-9]\d*)d$/u.exec(value);
|
|
17
|
+
if (interval)
|
|
18
|
+
return { inDays: Number(interval[1]) };
|
|
19
|
+
return { reviewAt: value || undefined };
|
|
20
|
+
}
|
|
21
|
+
const scopeAndProject = (data) => ({
|
|
22
|
+
scope: data.scope,
|
|
23
|
+
project: data.project?.trim() || undefined,
|
|
24
|
+
});
|
|
25
|
+
/** 决策快速新增或完整编辑表单。 */
|
|
26
|
+
export function DecisionEditor({ app, item, onCancel, onSaved, }) {
|
|
27
|
+
if (!item)
|
|
28
|
+
return (_jsx(Form, { title: "\u5FEB\u901F\u8BB0\u5F55\u51B3\u7B56\uFF0830 \u79D2\u901F\u8BB0\uFF09", fields: [
|
|
29
|
+
{ key: 'title', label: '决策标题', placeholder: '例如:本地存储使用 SQLite' },
|
|
30
|
+
{ key: 'reason', label: '核心依据 (选填)', placeholder: '为什么做这个决定' },
|
|
31
|
+
{
|
|
32
|
+
key: 'date',
|
|
33
|
+
label: '复盘周期 (30d/90d/180d 或 YYYY-MM-DD)',
|
|
34
|
+
placeholder: '默认 90d',
|
|
35
|
+
},
|
|
36
|
+
{ key: 'confidence', label: '信心指数 0-100 (选填)', placeholder: '留空不预设' },
|
|
37
|
+
], onCancel: onCancel, onSave: (data) => {
|
|
38
|
+
const confidence = data.confidence?.trim();
|
|
39
|
+
if (confidence && !/^\d+$/u.test(confidence))
|
|
40
|
+
throw new AppError(2, '信心指数必须为 0–100 的整数。');
|
|
41
|
+
const row = app.decisions.create({
|
|
42
|
+
title: data.title ?? '',
|
|
43
|
+
reason: data.reason?.trim() || undefined,
|
|
44
|
+
confidence: confidence ? Number(confidence) : undefined,
|
|
45
|
+
...dateChoice(data.date?.trim() ?? ''),
|
|
46
|
+
});
|
|
47
|
+
onSaved(row.id);
|
|
48
|
+
} }));
|
|
49
|
+
return (_jsx(Form, { title: "\u7F16\u8F91\u51B3\u7B56", fields: [
|
|
50
|
+
{ key: 'title', label: '决策标题', initial: item.title },
|
|
51
|
+
{ key: 'content', label: '决策内容', initial: item.content },
|
|
52
|
+
{ key: 'reason', label: '核心依据', initial: item.reason },
|
|
53
|
+
{ key: 'alternatives', label: '备选方案及原因', initial: item.alternatives },
|
|
54
|
+
{ key: 'expected', label: '预期结果', initial: item.expected },
|
|
55
|
+
{ key: 'confidence', label: '信心指数 (0-100)', initial: String(item.confidence ?? '') },
|
|
56
|
+
{ key: 'domain', label: '所属领域', initial: item.domain },
|
|
57
|
+
{ key: 'reviewAt', label: '复盘日期 (YYYY-MM-DD)', initial: item.reviewAt },
|
|
58
|
+
{
|
|
59
|
+
key: 'scope',
|
|
60
|
+
label: '作用域 (global/project)',
|
|
61
|
+
initial: item.projectId ? 'project' : 'global',
|
|
62
|
+
},
|
|
63
|
+
{ key: 'project', label: '项目 ID', initial: item.projectId ?? undefined },
|
|
64
|
+
], onCancel: onCancel, onSave: (data) => {
|
|
65
|
+
const confidence = data.confidence?.trim();
|
|
66
|
+
if (confidence && !/^\d+$/u.test(confidence))
|
|
67
|
+
throw new AppError(2, '信心指数必须为 0–100 的整数。');
|
|
68
|
+
const row = app.decisions.edit(item.id, {
|
|
69
|
+
title: data.title,
|
|
70
|
+
content: data.content,
|
|
71
|
+
reason: data.reason,
|
|
72
|
+
alternatives: data.alternatives,
|
|
73
|
+
expected: data.expected,
|
|
74
|
+
confidence: confidence ? Number(confidence) : null,
|
|
75
|
+
domain: data.domain,
|
|
76
|
+
reviewAt: data.reviewAt,
|
|
77
|
+
...scopeAndProject(data),
|
|
78
|
+
});
|
|
79
|
+
onSaved(row.id);
|
|
80
|
+
} }));
|
|
81
|
+
}
|
|
82
|
+
/** 决策「当时 vs 现在」对比复盘视图。 */
|
|
83
|
+
export function ReviewForm({ app, item, onCancel, onReview, }) {
|
|
84
|
+
const wide = useWindowSize().columns >= WIDE_BREAKPOINT;
|
|
85
|
+
const [configure, setConfigure] = useState(false);
|
|
86
|
+
const [previous, setPrevious] = useState({});
|
|
87
|
+
const approval = useAiApproval();
|
|
88
|
+
if (configure)
|
|
89
|
+
return (_jsx(AiSettings, { app: app, onClose: () => setConfigure(false), onSaved: () => setConfigure(false) }));
|
|
90
|
+
const then = (_jsxs(Box, { flexDirection: "column", width: wide ? '42%' : '100%', borderStyle: "round", borderColor: theme.border, borderDimColor: true, paddingX: 2, paddingY: 1, children: [_jsx(Text, { bold: true, color: theme.info, children: "\u5F53\u65F6 \u00B7 Then\uFF08\u53EA\u8BFB\u539F\u59CB\u4F9D\u636E\uFF09" }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { bold: true, children: item.title }) }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { dimColor: true, children: "\u6838\u5FC3\u4F9D\u636E" }), _jsx(Text, { wrap: "truncate-end", children: item.reason || '—' })] }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { dimColor: true, children: "\u6392\u9664\u7684\u5907\u9009\u65B9\u6848" }), _jsx(Text, { wrap: "truncate-end", children: item.alternatives || '—' })] }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { dimColor: true, children: "\u9884\u671F\u7ED3\u679C" }), _jsx(Text, { wrap: "truncate-end", children: item.expected || '—' })] }), _jsxs(Box, { gap: 1, marginTop: 1, children: [_jsx(Text, { dimColor: true, children: "\u5F53\u65F6\u4FE1\u5FC3:" }), _jsx(Text, { color: theme.accent, children: confidenceBar(item.confidence) })] })] }));
|
|
91
|
+
return (_jsxs(Box, { flexDirection: wide ? 'row' : 'column', gap: wide ? 1 : 0, children: [then, _jsxs(Box, { width: wide ? '58%' : '100%', flexDirection: "column", children: [approval.panel, _jsx(Form, { title: "\u73B0\u5728 \u00B7 Now\uFF08\u586B\u5199\u590D\u76D8\u7ED3\u8BBA\uFF09", fields: [
|
|
92
|
+
{
|
|
93
|
+
key: 'result',
|
|
94
|
+
label: '实际结果',
|
|
95
|
+
initial: previous.result,
|
|
96
|
+
placeholder: '发生了什么实际效果',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
key: 'rating',
|
|
100
|
+
label: '结果评级',
|
|
101
|
+
initial: previous.rating,
|
|
102
|
+
placeholder: 'accurate (准确) / partial (偏差) / failed (踩坑)',
|
|
103
|
+
},
|
|
104
|
+
{ key: 'lesson', label: '一句话经验教训', initial: previous.lesson },
|
|
105
|
+
], onCancel: onCancel, assist: async (data, signal) => {
|
|
106
|
+
if (!app.ai.settings()) {
|
|
107
|
+
setPrevious(data);
|
|
108
|
+
setConfigure(true);
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
return app.ai.review(item.id, data.result ?? '', { signal, approve: approval.request });
|
|
112
|
+
}, onSave: (data) => onReview({
|
|
113
|
+
result: data.result ?? '',
|
|
114
|
+
rating: data.rating,
|
|
115
|
+
lesson: data.lesson ?? '',
|
|
116
|
+
}) })] })] }));
|
|
117
|
+
}
|