dsh-gallery 0.16.2 → 0.16.6
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/CHANGELOG.md +110 -1
- package/README.md +56 -8
- package/client.js +535 -76
- package/host/feedback.js +138 -0
- package/host/http.js +288 -5
- package/package.json +102 -98
package/host/feedback.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 待处理反馈存储(v0.16.4):独立文件 dsh-gallery-feedback.json。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独一个文件(和 marks.json / labels.js 都分开):
|
|
5
|
+
* · marks.json —— 判定标记,**持久状态**(改过就一直生效)
|
|
6
|
+
* · labels.json —— 手动标签,**持久状态**
|
|
7
|
+
* · feedback.json —— 待处理反馈,**一次性消息**(人处理完就没了)
|
|
8
|
+
*
|
|
9
|
+
* 生命周期不同就不能放同一份:用户从反馈篮删掉一条反馈,
|
|
10
|
+
* 不该把已经定好的标签/标记也一起撤销(labels.js 里已记过这个教训)。
|
|
11
|
+
*
|
|
12
|
+
* 为什么需要落盘(v0.16.4 之前没有):
|
|
13
|
+
* 反馈草稿原先只存在内存 `draftRef` 里,插件一重启反馈就没了。
|
|
14
|
+
* A 档要「Agent 能主动拉反馈」,Agent 拉到的必须是**落盘的那份**,
|
|
15
|
+
* 否则重启一次,用户已经标过的意见就没了。
|
|
16
|
+
*
|
|
17
|
+
* 数据形态:
|
|
18
|
+
* {
|
|
19
|
+
* "schema": 1,
|
|
20
|
+
* "feedback": {
|
|
21
|
+
* "<relPath>": {
|
|
22
|
+
* "action": "approve|reject|finalize|...",
|
|
23
|
+
* "reason": "...", // 可选
|
|
24
|
+
* "changeOnly": ["色调"], // 可选
|
|
25
|
+
* "keep": ["构图", "人物位置"], // 可选
|
|
26
|
+
* "preserve": ["..."], // 可选
|
|
27
|
+
* "region": { ... }, // 可选(圈选批注的几何)
|
|
28
|
+
* "markedAt": 1700000000000
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* 键用 relPath(与 marks / labels 一致):文件被改名/移动后不会误命中,孤儿记录不影响扫描。
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { promises as fsp } from 'node:fs'
|
|
37
|
+
import path from 'node:path'
|
|
38
|
+
|
|
39
|
+
const FEEDBACK_FILENAME = 'dsh-gallery-feedback.json'
|
|
40
|
+
|
|
41
|
+
/** 进程内写队列,与 marks.js / labels.js 同策略:把「读-改-写」串起来,避免并发互相覆盖。 */
|
|
42
|
+
let writeChain = Promise.resolve()
|
|
43
|
+
|
|
44
|
+
function enqueue(fn) {
|
|
45
|
+
const next = writeChain.then(fn, fn)
|
|
46
|
+
writeChain = next.catch(() => {})
|
|
47
|
+
return next
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function feedbackFilePath(settingsFile) {
|
|
51
|
+
return path.join(path.dirname(settingsFile), FEEDBACK_FILENAME)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 读待处理反馈。文件不存在 / 格式坏都返回空对象,绝不抛错。 */
|
|
55
|
+
export async function readFeedback(settingsFile) {
|
|
56
|
+
try {
|
|
57
|
+
const raw = await fsp.readFile(feedbackFilePath(settingsFile), 'utf8')
|
|
58
|
+
const parsed = JSON.parse(raw)
|
|
59
|
+
const feedback = (parsed !== null && typeof parsed === 'object' &&
|
|
60
|
+
typeof parsed.feedback === 'object' && parsed.feedback !== null) ? parsed.feedback : {}
|
|
61
|
+
return { schema: 1, feedback }
|
|
62
|
+
} catch {
|
|
63
|
+
return { schema: 1, feedback: {} }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** 原子写(tmp → rename),tmp 名带 pid + 随机数,并发不互踩。 */
|
|
68
|
+
async function writeFeedback(settingsFile, feedback) {
|
|
69
|
+
const file = feedbackFilePath(settingsFile)
|
|
70
|
+
const tmp = `${file}.tmp-${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`
|
|
71
|
+
const payload = { schema: 1, feedback: feedback ?? {} }
|
|
72
|
+
await fsp.mkdir(path.dirname(file), { recursive: true })
|
|
73
|
+
await fsp.writeFile(tmp, JSON.stringify(payload, null, 2))
|
|
74
|
+
await fsp.rename(tmp, file)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 记一条待处理反馈(用户做判定时调)。
|
|
79
|
+
* 同一路径再次判定会**覆盖**旧的那条 —— 一个资产当前只有一条有效意见,
|
|
80
|
+
* 反复标记同一张图不该攒出多条互相矛盾的反馈。
|
|
81
|
+
*/
|
|
82
|
+
export async function setFeedback(settingsFile, relPath, item) {
|
|
83
|
+
return enqueue(async () => {
|
|
84
|
+
const current = await readFeedback(settingsFile)
|
|
85
|
+
const next = { ...current.feedback }
|
|
86
|
+
if (item === null || item === undefined) {
|
|
87
|
+
delete next[relPath]
|
|
88
|
+
} else {
|
|
89
|
+
next[relPath] = { ...item, markedAt: item.markedAt ?? Date.now() }
|
|
90
|
+
}
|
|
91
|
+
await writeFeedback(settingsFile, next)
|
|
92
|
+
return next
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 批量记(一次读改写 + 一次原子写)。 */
|
|
97
|
+
export async function setFeedbackBatch(settingsFile, updates) {
|
|
98
|
+
return enqueue(async () => {
|
|
99
|
+
const current = await readFeedback(settingsFile)
|
|
100
|
+
const next = { ...current.feedback }
|
|
101
|
+
for (const u of updates) {
|
|
102
|
+
const relPath = String(u?.path ?? '')
|
|
103
|
+
if (relPath === '') continue
|
|
104
|
+
const item = u?.item
|
|
105
|
+
if (item === null || item === undefined) delete next[relPath]
|
|
106
|
+
else next[relPath] = { ...item, markedAt: item.markedAt ?? Date.now() }
|
|
107
|
+
}
|
|
108
|
+
await writeFeedback(settingsFile, next)
|
|
109
|
+
return next
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 确认已处理 —— 人点发送 / 人点清空反馈篮后调,把这些条从待处理里移除。
|
|
115
|
+
*
|
|
116
|
+
* 注意:**Agent 拉取不调用这个**。
|
|
117
|
+
* Agent 拉走反馈只代表「Agent 看到了」,不代表「人处理完了」——
|
|
118
|
+
* 两者混同的话,Agent 看一眼就会把用户的意见吞掉。
|
|
119
|
+
*/
|
|
120
|
+
export async function ackFeedback(settingsFile, relPaths) {
|
|
121
|
+
return enqueue(async () => {
|
|
122
|
+
const current = await readFeedback(settingsFile)
|
|
123
|
+
const next = { ...current.feedback }
|
|
124
|
+
for (const relPath of relPaths) {
|
|
125
|
+
delete next[relPath]
|
|
126
|
+
}
|
|
127
|
+
await writeFeedback(settingsFile, next)
|
|
128
|
+
return next
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** 清空全部待处理反馈(人点「清空反馈篮」时调)。 */
|
|
133
|
+
export async function clearFeedback(settingsFile) {
|
|
134
|
+
return enqueue(async () => {
|
|
135
|
+
await writeFeedback(settingsFile, {})
|
|
136
|
+
return {}
|
|
137
|
+
})
|
|
138
|
+
}
|
package/host/http.js
CHANGED
|
@@ -39,6 +39,9 @@ const listCache = new Map()
|
|
|
39
39
|
const listInflight = new Map()
|
|
40
40
|
import { resolveReadable, serveMedia, contentTypeFor } from './media.js'
|
|
41
41
|
import { MARK_ACTIONS, readMarks, writeMarks, setMark, setMarksBatch, marksFilePath } from './marks.js'
|
|
42
|
+
import { readFeedback, setFeedback, setFeedbackBatch, ackFeedback, clearFeedback } from './feedback.js'
|
|
43
|
+
// v0.16.4 A 档:把待处理反馈渲染成成稿文本(纯函数,不碰落盘数据)
|
|
44
|
+
import { makeFeedback, renderFeedbackText } from './feedback-text.js'
|
|
42
45
|
import { LABEL_CATEGORIES, readLabels, setLabel, setLabelsBatch, deleteLabels } from './labels.js'
|
|
43
46
|
import {
|
|
44
47
|
registerFrame, deleteFrames, frameTimecode, makeFrameName, makeMaskName, maskPolygonMeta,
|
|
@@ -66,6 +69,112 @@ function LOG_RESOLVE(label, detail) {
|
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
/**
|
|
73
|
+
* 把相对路径解析成绝对路径(按 roots 依次试,第一个命中的即用)。
|
|
74
|
+
* 解析不出返回空串 —— 调用方自行决定要不要跳过。
|
|
75
|
+
*/
|
|
76
|
+
function absoluteOf(roots, relPath) {
|
|
77
|
+
if (!Array.isArray(roots)) return ''
|
|
78
|
+
for (const root of roots) {
|
|
79
|
+
if (typeof root !== 'string' || root === '') continue
|
|
80
|
+
const abs = path.resolve(root, relPath)
|
|
81
|
+
if (isInside(root, abs)) return abs
|
|
82
|
+
}
|
|
83
|
+
return ''
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* v0.16.4:按条件过滤资产(后置过滤,不重扫)。
|
|
88
|
+
*
|
|
89
|
+
* 为什么后置:扫描本身有缓存、且要按 roots 遍历;筛选只影响「返回哪些」,
|
|
90
|
+
* 放在扫描后最省。分组的 counts 会按过滤后的集合重算,保证台面显示与筛选结果一致。
|
|
91
|
+
*
|
|
92
|
+
* 筛选维度(AND 组合):
|
|
93
|
+
* label / category —— 生效分类(手动标签优先,与台面显示一致)
|
|
94
|
+
* action —— 判定动作(来自 marks)
|
|
95
|
+
* confirmed —— 是否已确认(来自 marks 的 confirmed 字段)
|
|
96
|
+
* ext —— 扩展名
|
|
97
|
+
* q —— 路径模糊匹配
|
|
98
|
+
*/
|
|
99
|
+
// v0.16.4: 导出以便真跑测试(纯函数,不改行为)
|
|
100
|
+
export async function applyAssetFilter(value, opts) {
|
|
101
|
+
const {
|
|
102
|
+
filterLabel, filterCategory, filterAction, filterExt,
|
|
103
|
+
filterConfirmed, filterQuery, filterLimit, settingsFile,
|
|
104
|
+
} = opts
|
|
105
|
+
|
|
106
|
+
let marks = {}
|
|
107
|
+
try {
|
|
108
|
+
marks = (await readMarks(settingsFile)).marks ?? {}
|
|
109
|
+
} catch { marks = {} }
|
|
110
|
+
|
|
111
|
+
const labelSet = filterLabel !== '' ? new Set([filterLabel]) : null
|
|
112
|
+
const categorySet = filterCategory !== '' ? new Set([filterCategory]) : null
|
|
113
|
+
|
|
114
|
+
const keep = (f) => {
|
|
115
|
+
const category = String(f?.category ?? '')
|
|
116
|
+
if (labelSet !== null && !labelSet.has(category)) return false
|
|
117
|
+
if (categorySet !== null && !categorySet.has(category)) return false
|
|
118
|
+
|
|
119
|
+
const ext = String(f?.extension ?? '')
|
|
120
|
+
if (filterExt !== '' && !ext.toLowerCase().endsWith(filterExt)) return false
|
|
121
|
+
|
|
122
|
+
if (filterQuery !== '') {
|
|
123
|
+
const hay = `${f?.relPath ?? ''} ${f?.name ?? ''}`.toLowerCase()
|
|
124
|
+
if (!hay.includes(filterQuery)) return false
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const mark = marks[f?.relPath]
|
|
128
|
+
if (filterAction !== '' && String(mark?.action ?? '') !== filterAction) return false
|
|
129
|
+
if (filterConfirmed !== null && (mark?.confirmed === true) !== filterConfirmed) return false
|
|
130
|
+
|
|
131
|
+
return true
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const decorate = (f) => {
|
|
135
|
+
const mark = marks[f?.relPath]
|
|
136
|
+
return {
|
|
137
|
+
...f,
|
|
138
|
+
confirmed: mark?.confirmed === true,
|
|
139
|
+
markAction: String(mark?.action ?? ''),
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const out = { ...value }
|
|
144
|
+
out.filtered = true
|
|
145
|
+
|
|
146
|
+
if (Array.isArray(value?.groups)) {
|
|
147
|
+
const groups = []
|
|
148
|
+
for (const g of value.groups) {
|
|
149
|
+
const files = (Array.isArray(g.files) ? g.files : []).filter(keep).map(decorate)
|
|
150
|
+
if (files.length === 0) continue
|
|
151
|
+
groups.push({
|
|
152
|
+
...g,
|
|
153
|
+
files,
|
|
154
|
+
counts: {
|
|
155
|
+
final: files.filter((f) => f.category === 'final').length,
|
|
156
|
+
input: files.filter((f) => f.category === 'input').length,
|
|
157
|
+
intermediate: files.filter((f) => f.category === 'intermediate').length,
|
|
158
|
+
unknown: files.filter((f) => f.category === 'unknown' || f.category === undefined).length,
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
out.groups = groups
|
|
163
|
+
out.total = groups.reduce((n, g) => n + g.files.length, 0)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (Array.isArray(value?.items)) {
|
|
167
|
+
out.items = value.items.filter(keep).map(decorate).slice(0, filterLimit)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (Array.isArray(value?.files)) {
|
|
171
|
+
out.files = value.files.filter(keep).map(decorate).slice(0, filterLimit)
|
|
172
|
+
out.total = out.files.length
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return out
|
|
176
|
+
}
|
|
177
|
+
|
|
69
178
|
/** 统一 JSON 响应。 */
|
|
70
179
|
function json(body, status) {
|
|
71
180
|
|
|
@@ -275,6 +384,20 @@ export function registerOpsRoute(ctx, config) {
|
|
|
275
384
|
|
|
276
385
|
const sessionId = typeof body?.sessionId === 'string' ? body.sessionId : ''
|
|
277
386
|
|
|
387
|
+
// ── v0.16.4:检索维度 ──────────────────────────────────
|
|
388
|
+
// 目标:Agent 能按条件取资产(不只是「当前选中那一张」)。
|
|
389
|
+
// 全部可选、AND 组合;分类取的是**手动标签覆写后的生效值**(与台面显示一致)。
|
|
390
|
+
const filterLabel = typeof body?.label === 'string' ? body.label : ''
|
|
391
|
+
const filterCategory = typeof body?.category === 'string' ? body.category : ''
|
|
392
|
+
const filterAction = typeof body?.action === 'string' ? body.action : ''
|
|
393
|
+
const filterExt = typeof body?.ext === 'string' ? body.ext.toLowerCase() : ''
|
|
394
|
+
const filterConfirmed = body?.confirmed === true ? true
|
|
395
|
+
: body?.confirmed === false ? false : null
|
|
396
|
+
const filterQuery = typeof body?.q === 'string' ? body.q.trim().toLowerCase() : ''
|
|
397
|
+
const filterLimit = Math.max(1, Math.min(500, Math.trunc(Number(body?.limit)) || 100))
|
|
398
|
+
const hasFilter = filterLabel !== '' || filterCategory !== '' || filterAction !== ''
|
|
399
|
+
|| filterExt !== '' || filterConfirmed !== null || filterQuery !== ''
|
|
400
|
+
|
|
278
401
|
// 配置 / 隐藏列表写在 settingsFile 里,它的 mtime 变了就让缓存失效。
|
|
279
402
|
// sessionId 必须在键里:切对话后不能复用上一会话的分组结果。
|
|
280
403
|
let settingsStamp = 0
|
|
@@ -283,6 +406,8 @@ export function registerOpsRoute(ctx, config) {
|
|
|
283
406
|
kind, scope, sessionId, body?.page ?? 1,
|
|
284
407
|
resolved.roots, resolved.windowHours, resolved.maxDepth,
|
|
285
408
|
resolved.maxItems, settingsStamp,
|
|
409
|
+
filterLabel, filterCategory, filterAction, filterExt,
|
|
410
|
+
filterConfirmed, filterQuery, filterLimit,
|
|
286
411
|
])
|
|
287
412
|
const hit = listCache.get(cacheKey)
|
|
288
413
|
if (hit !== undefined && Date.now() - hit.at < LIST_CACHE_MS) return json(hit.value)
|
|
@@ -291,12 +416,21 @@ export function registerOpsRoute(ctx, config) {
|
|
|
291
416
|
|
|
292
417
|
const task = scanGallery(config, kind, scope, sessionId, body?.page)
|
|
293
418
|
.then((value) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
419
|
+
// ── v0.16.4:按条件过滤 ────────────────────────────
|
|
420
|
+
// 标记(判定 / 确认态)来自 marks 文件;手动标签已在 scan 阶段
|
|
421
|
+
// 覆写到 item.category,所以这里直接用 category 即可。
|
|
422
|
+
if (!hasFilter) {
|
|
423
|
+
listCache.set(cacheKey, { at: Date.now(), value })
|
|
424
|
+
return value
|
|
298
425
|
}
|
|
299
|
-
return value
|
|
426
|
+
return applyAssetFilter(value, {
|
|
427
|
+
filterLabel, filterCategory, filterAction, filterExt,
|
|
428
|
+
filterConfirmed, filterQuery, filterLimit,
|
|
429
|
+
settingsFile: resolved.settingsFile,
|
|
430
|
+
}).then((filtered) => {
|
|
431
|
+
listCache.set(cacheKey, { at: Date.now(), value: filtered })
|
|
432
|
+
return filtered
|
|
433
|
+
})
|
|
300
434
|
})
|
|
301
435
|
.finally(() => { listInflight.delete(cacheKey) })
|
|
302
436
|
listInflight.set(cacheKey, task)
|
|
@@ -867,6 +1001,155 @@ export function registerOpsRoute(ctx, config) {
|
|
|
867
1001
|
return json({ ok: true, marks: stored.marks })
|
|
868
1002
|
}
|
|
869
1003
|
|
|
1004
|
+
if (op === 'setFeedback') {
|
|
1005
|
+
/**
|
|
1006
|
+
* 记一条待处理反馈(用户做判定时调)。
|
|
1007
|
+
* 落盘 dsh-gallery-feedback.json —— 插件重启也不丢。
|
|
1008
|
+
*/
|
|
1009
|
+
const relPath = String(body?.path ?? '')
|
|
1010
|
+
if (relPath === '') {
|
|
1011
|
+
return json({ ok: false, error: { code: 'bad-request', message: '缺少 path' } }, 400)
|
|
1012
|
+
}
|
|
1013
|
+
const item = body?.item
|
|
1014
|
+
if (item !== null && item !== undefined && typeof item !== 'object') {
|
|
1015
|
+
return json({ ok: false, error: { code: 'bad-request', message: 'item 不合法' } }, 400)
|
|
1016
|
+
}
|
|
1017
|
+
try {
|
|
1018
|
+
const settingsFile = resolveOptions(config).settingsFile
|
|
1019
|
+
const next = await setFeedback(settingsFile, relPath, item ?? null)
|
|
1020
|
+
return json({ ok: true, count: Object.keys(next).length, feedback: next })
|
|
1021
|
+
} catch (error) {
|
|
1022
|
+
return json({ ok: false, error: { code: 'feedback-write-failed', message: String(error?.message ?? error) } }, 500)
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
if (op === 'setFeedbackBatch') {
|
|
1027
|
+
/**
|
|
1028
|
+
* 批量记待处理反馈(v0.16.4):一次读改写 + 一次原子写。
|
|
1029
|
+
* 改标签可能一次动几十张图,逐条发请求会拖慢且互相覆盖。
|
|
1030
|
+
*/
|
|
1031
|
+
const updates = Array.isArray(body?.updates) ? body.updates : null
|
|
1032
|
+
if (updates === null) {
|
|
1033
|
+
return json({ ok: false, error: { code: 'bad-request', message: '缺少 updates' } }, 400)
|
|
1034
|
+
}
|
|
1035
|
+
try {
|
|
1036
|
+
const settingsFile = resolveOptions(config).settingsFile
|
|
1037
|
+
const next = await setFeedbackBatch(settingsFile, updates)
|
|
1038
|
+
return json({ ok: true, count: Object.keys(next).length, feedback: next })
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
return json({ ok: false, error: { code: 'feedback-write-failed', message: String(error?.message ?? error) } }, 500)
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
if (op === 'getPendingFeedback') {
|
|
1045
|
+
/**
|
|
1046
|
+
* 取待处理反馈(**纯读**)。
|
|
1047
|
+
*
|
|
1048
|
+
* A 档:Agent 主动来拉。
|
|
1049
|
+
* ⚠️ 这里**不**标记已读 —— Agent 拉走 ≠ 人处理完了。
|
|
1050
|
+
* 清零的时机是「人点发送」或「人点清空反馈篮」,走 ackFeedback。
|
|
1051
|
+
*/
|
|
1052
|
+
try {
|
|
1053
|
+
const settingsFile = resolveOptions(config).settingsFile
|
|
1054
|
+
const fb = await readFeedback(settingsFile)
|
|
1055
|
+
const marks = (await readMarks(settingsFile)).marks ?? {}
|
|
1056
|
+
/**
|
|
1057
|
+
* v0.16.5:一条落盘记录可能带**多条框选批注**(annotations 数组)。
|
|
1058
|
+
*
|
|
1059
|
+
* 原来一条记录只对应一处 region,同一张图框两处时后写的把先写的覆盖了。
|
|
1060
|
+
* 现在落盘按整组存,读取时展开成「一处理解一条 item」——
|
|
1061
|
+
* 这样 Agent 拿到的条数与人在图上框的处数一致,
|
|
1062
|
+
* 也和前端草稿里 `Annotation N` 的编号一一对应。
|
|
1063
|
+
*
|
|
1064
|
+
* 按图分组排序:同一张图的条目必须连续,不能被别的图的判定插进来,
|
|
1065
|
+
* 否则草稿读起来是断的。排序键取该图第一条的时间。
|
|
1066
|
+
*/
|
|
1067
|
+
const buckets = []
|
|
1068
|
+
for (const entry of Object.entries(fb.feedback)) {
|
|
1069
|
+
const relPath = entry[0]
|
|
1070
|
+
const item = entry[1] ?? {}
|
|
1071
|
+
const mark = marks[relPath]
|
|
1072
|
+
const base = {
|
|
1073
|
+
relPath,
|
|
1074
|
+
absolute: absoluteOf(resolved.roots, relPath),
|
|
1075
|
+
reason: String(item.reason ?? ''),
|
|
1076
|
+
changeOnly: Array.isArray(item.changeOnly) ? item.changeOnly : [],
|
|
1077
|
+
keep: Array.isArray(item.keep) ? item.keep : [],
|
|
1078
|
+
preserve: Array.isArray(item.preserve) ? item.preserve : [],
|
|
1079
|
+
region: item.region ?? null,
|
|
1080
|
+
markedAt: Number(item.markedAt) || 0,
|
|
1081
|
+
// v0.16.4:带上分类与归属会话 —— Agent 拿到就能判断该改哪个文件、归哪条对话
|
|
1082
|
+
category: String(item.category ?? 'unknown'),
|
|
1083
|
+
sessionId: String(item.sessionId ?? ''),
|
|
1084
|
+
confirmed: mark?.confirmed === true,
|
|
1085
|
+
}
|
|
1086
|
+
const flatAction = String(item.action ?? '')
|
|
1087
|
+
const annots = Array.isArray(item.annotations)
|
|
1088
|
+
? item.annotations.filter((a) => a !== null && typeof a === 'object' && a.region)
|
|
1089
|
+
: []
|
|
1090
|
+
const group = []
|
|
1091
|
+
if (annots.length === 0) {
|
|
1092
|
+
// 旧格式 / 纯标记:一条记录就是一条
|
|
1093
|
+
group.push({ ...base, action: flatAction })
|
|
1094
|
+
} else {
|
|
1095
|
+
// 该图还有一条独立判定(如「交付不合格」)时,先出这一条
|
|
1096
|
+
if (flatAction !== '' && flatAction !== 'annotate') {
|
|
1097
|
+
group.push({ ...base, action: flatAction })
|
|
1098
|
+
}
|
|
1099
|
+
for (const a of annots) {
|
|
1100
|
+
group.push({
|
|
1101
|
+
...base,
|
|
1102
|
+
action: 'annotate',
|
|
1103
|
+
reason: typeof a.note === 'string' ? a.note : '',
|
|
1104
|
+
// 批注只管「这块改成什么」,不继承整图判定的只改 / 锁死
|
|
1105
|
+
changeOnly: [],
|
|
1106
|
+
keep: [],
|
|
1107
|
+
preserve: [],
|
|
1108
|
+
region: a.region,
|
|
1109
|
+
markedAt: Number(a.markedAt) || base.markedAt,
|
|
1110
|
+
annotId: String(a.id ?? ''),
|
|
1111
|
+
})
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
buckets.push(group)
|
|
1115
|
+
}
|
|
1116
|
+
buckets.sort((x, y) => ((x[0]?.markedAt ?? 0) - (y[0]?.markedAt ?? 0)))
|
|
1117
|
+
const items = buckets.flat()
|
|
1118
|
+
/**
|
|
1119
|
+
* draft:把待处理条目渲染成**可直接粘进 composer 的成稿文本**。
|
|
1120
|
+
* Agent 不必自己拼格式;人也能直接拿去用。
|
|
1121
|
+
* 渲染是纯函数,不影响落盘数据,也不触发任何发送。
|
|
1122
|
+
*/
|
|
1123
|
+
let draft = ''
|
|
1124
|
+
try {
|
|
1125
|
+
const locale = body?.locale === 'en' ? 'en' : 'zh'
|
|
1126
|
+
draft = renderFeedbackText(makeFeedback({ sessionId: '', items }), { locale })
|
|
1127
|
+
} catch { draft = '' }
|
|
1128
|
+
return json({ ok: true, schema: 1, count: items.length, items, draft })
|
|
1129
|
+
} catch (error) {
|
|
1130
|
+
return json({ ok: false, error: { code: 'feedback-read-failed', message: String(error?.message ?? error) } }, 500)
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
if (op === 'ackFeedback') {
|
|
1135
|
+
/**
|
|
1136
|
+
* 确认已处理 —— **人**点发送 / 人点清空反馈篮时调。
|
|
1137
|
+
* 移除给定路径的待处理反馈;不传 paths 表示清空全部。
|
|
1138
|
+
*/
|
|
1139
|
+
try {
|
|
1140
|
+
const settingsFile = resolveOptions(config).settingsFile
|
|
1141
|
+
const paths = Array.isArray(body?.paths)
|
|
1142
|
+
? body.paths.map((p) => String(p ?? '')).filter((p) => p !== '')
|
|
1143
|
+
: null
|
|
1144
|
+
const next = paths === null
|
|
1145
|
+
? await clearFeedback(settingsFile)
|
|
1146
|
+
: await ackFeedback(settingsFile, paths)
|
|
1147
|
+
return json({ ok: true, count: Object.keys(next).length })
|
|
1148
|
+
} catch (error) {
|
|
1149
|
+
return json({ ok: false, error: { code: 'feedback-ack-failed', message: String(error?.message ?? error) } }, 500)
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
|
|
870
1153
|
if (op === 'marks') {
|
|
871
1154
|
const relPath = String(body?.path ?? '')
|
|
872
1155
|
if (relPath === '') {
|
package/package.json
CHANGED
|
@@ -1,98 +1,102 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-gallery",
|
|
3
|
-
"version": "0.16.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "产出台:图片 / 文件 / 音视频实时可见、当场校验;原生产出标签(素材 / 过程稿 / 定稿 / 未归类)可手动改且持久生效,改标签动作与图上圈选批注攒进反馈篮,由人审核合并后发送,全程零自动发送;视频「截取当前帧」自动存入当前对话资产;图上左键画矩形框、右键多点闭合成实心多边形,可导出 ComfyUI 直接可用的 RGBA 遮罩(选区内 alpha=0、RGB 保留原图),另出红 / 绿 /
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/Hope2023Dcr/dsh-gallery.git"
|
|
9
|
-
},
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/Hope2023Dcr/dsh-gallery/issues"
|
|
12
|
-
},
|
|
13
|
-
"homepage": "https://github.com/Hope2023Dcr/dsh-gallery#readme",
|
|
14
|
-
"exports": {
|
|
15
|
-
".": "./index.js",
|
|
16
|
-
"./client": "./client.js",
|
|
17
|
-
"./locale/*.json": "./locale/*.json",
|
|
18
|
-
"./icon": "./icon.svg"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"install.mjs",
|
|
22
|
-
"index.js",
|
|
23
|
-
"client.js",
|
|
24
|
-
"session-index.js",
|
|
25
|
-
"host/*.js",
|
|
26
|
-
"cordis.patch.yml",
|
|
27
|
-
"locale/*.json",
|
|
28
|
-
"icon.svg",
|
|
29
|
-
"README.md",
|
|
30
|
-
"LICENSE",
|
|
31
|
-
"CHANGELOG.md",
|
|
32
|
-
"docs/screenshots/*.png"
|
|
33
|
-
],
|
|
34
|
-
"dsh": {
|
|
35
|
-
"bundle": {
|
|
36
|
-
"patch": "./cordis.patch.yml"
|
|
37
|
-
},
|
|
38
|
-
"client": {
|
|
39
|
-
"platform": "web",
|
|
40
|
-
"immediately": true,
|
|
41
|
-
"inject": [
|
|
42
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
|
43
|
-
"@deepseek-ai/dsh-client-locale"
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"author": {
|
|
48
|
-
"name": "Hope2023Dcr"
|
|
49
|
-
},
|
|
50
|
-
"license": "MIT",
|
|
51
|
-
"keywords": [
|
|
52
|
-
"dsh-plugin",
|
|
53
|
-
"deepseek-harness",
|
|
54
|
-
"dsh",
|
|
55
|
-
"output-gallery",
|
|
56
|
-
"image-gallery",
|
|
57
|
-
"file-preview",
|
|
58
|
-
"sidebar-plugin",
|
|
59
|
-
"agent-tools",
|
|
60
|
-
"media-gallery",
|
|
61
|
-
"video-preview",
|
|
62
|
-
"audio-preview",
|
|
63
|
-
"range-seek",
|
|
64
|
-
"filter",
|
|
65
|
-
"deliverable",
|
|
66
|
-
"human-in-the-loop",
|
|
67
|
-
"asset-tags",
|
|
68
|
-
"manual-label",
|
|
69
|
-
"feedback-basket",
|
|
70
|
-
"batch",
|
|
71
|
-
"region-selection",
|
|
72
|
-
"annotation",
|
|
73
|
-
"frame-capture",
|
|
74
|
-
"annotation-follow",
|
|
75
|
-
"middle-mouse-pan",
|
|
76
|
-
"polygon-selection",
|
|
77
|
-
"mask-export",
|
|
78
|
-
"rgba-mask",
|
|
79
|
-
"comfyui",
|
|
80
|
-
"inpainting",
|
|
81
|
-
"drag-metadata",
|
|
82
|
-
"external-assets",
|
|
83
|
-
"clipboard-paste",
|
|
84
|
-
"image-crop",
|
|
85
|
-
"magnifier",
|
|
86
|
-
"media-trim",
|
|
87
|
-
"ffmpeg",
|
|
88
|
-
"audio-trim",
|
|
89
|
-
"video-trim"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-gallery",
|
|
3
|
+
"version": "0.16.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "产出台:图片 / 文件 / 音视频实时可见、当场校验;原生产出标签(素材 / 过程稿 / 定稿 / 未归类)可手动改且持久生效,改标签动作与图上圈选批注攒进反馈篮,由人审核合并后发送,全程零自动发送;视频「截取当前帧」自动存入当前对话资产;图上左键画矩形框、右键多点闭合成实心多边形,可导出 ComfyUI 直接可用的 RGBA 遮罩(选区内 alpha=0、RGB 保留原图),另出红 / 绿 / 蓝纯色半透明填充预览图供目视核对;同一张图可连框多处、每处各带说明一并交给 Agent,分类显隐按图片 / 文件 / 音视频各记各的;把图拖进对话框会自动带上文件名与绝对路径(含对应主遮罩名),Agent 不必扫目录找图;批注框跟随图片缩放平移,标注态按住鼠标中键可平移且框不脱框。Output gallery for DeepSeek Harness: live image/file/audio/video preview, persistent manual asset labels, region annotations and label changes queued in a human-approved feedback basket, one-click video frame capture filed into the current session, rectangle and multi-point polygon selections exported as ComfyUI-ready RGBA masks (alpha=0 inside the selection, original RGB kept) plus a colored translucent fill preview, drag-to-chat that carries the file name and absolute path so agents need no directory scan; annotation boxes follow image zoom/pan, and holding the middle mouse button pans the image while annotating without losing the boxes.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Hope2023Dcr/dsh-gallery.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/Hope2023Dcr/dsh-gallery/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/Hope2023Dcr/dsh-gallery#readme",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./index.js",
|
|
16
|
+
"./client": "./client.js",
|
|
17
|
+
"./locale/*.json": "./locale/*.json",
|
|
18
|
+
"./icon": "./icon.svg"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"install.mjs",
|
|
22
|
+
"index.js",
|
|
23
|
+
"client.js",
|
|
24
|
+
"session-index.js",
|
|
25
|
+
"host/*.js",
|
|
26
|
+
"cordis.patch.yml",
|
|
27
|
+
"locale/*.json",
|
|
28
|
+
"icon.svg",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE",
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"docs/screenshots/*.png"
|
|
33
|
+
],
|
|
34
|
+
"dsh": {
|
|
35
|
+
"bundle": {
|
|
36
|
+
"patch": "./cordis.patch.yml"
|
|
37
|
+
},
|
|
38
|
+
"client": {
|
|
39
|
+
"platform": "web",
|
|
40
|
+
"immediately": true,
|
|
41
|
+
"inject": [
|
|
42
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
|
43
|
+
"@deepseek-ai/dsh-client-locale"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"author": {
|
|
48
|
+
"name": "Hope2023Dcr"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"keywords": [
|
|
52
|
+
"dsh-plugin",
|
|
53
|
+
"deepseek-harness",
|
|
54
|
+
"dsh",
|
|
55
|
+
"output-gallery",
|
|
56
|
+
"image-gallery",
|
|
57
|
+
"file-preview",
|
|
58
|
+
"sidebar-plugin",
|
|
59
|
+
"agent-tools",
|
|
60
|
+
"media-gallery",
|
|
61
|
+
"video-preview",
|
|
62
|
+
"audio-preview",
|
|
63
|
+
"range-seek",
|
|
64
|
+
"filter",
|
|
65
|
+
"deliverable",
|
|
66
|
+
"human-in-the-loop",
|
|
67
|
+
"asset-tags",
|
|
68
|
+
"manual-label",
|
|
69
|
+
"feedback-basket",
|
|
70
|
+
"batch",
|
|
71
|
+
"region-selection",
|
|
72
|
+
"annotation",
|
|
73
|
+
"frame-capture",
|
|
74
|
+
"annotation-follow",
|
|
75
|
+
"middle-mouse-pan",
|
|
76
|
+
"polygon-selection",
|
|
77
|
+
"mask-export",
|
|
78
|
+
"rgba-mask",
|
|
79
|
+
"comfyui",
|
|
80
|
+
"inpainting",
|
|
81
|
+
"drag-metadata",
|
|
82
|
+
"external-assets",
|
|
83
|
+
"clipboard-paste",
|
|
84
|
+
"image-crop",
|
|
85
|
+
"magnifier",
|
|
86
|
+
"media-trim",
|
|
87
|
+
"ffmpeg",
|
|
88
|
+
"audio-trim",
|
|
89
|
+
"video-trim",
|
|
90
|
+
"copy-file",
|
|
91
|
+
"viewer-shortcut",
|
|
92
|
+
"agent-seam",
|
|
93
|
+
"pending-feedback"
|
|
94
|
+
],
|
|
95
|
+
"publishConfig": {
|
|
96
|
+
"access": "public",
|
|
97
|
+
"registry": "https://registry.npmjs.org/"
|
|
98
|
+
},
|
|
99
|
+
"engines": {
|
|
100
|
+
"node": ">=20"
|
|
101
|
+
}
|
|
102
|
+
}
|