@yolk_vat-y/dsh-project-memory 0.7.0 → 0.7.1
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 +10 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/client/client.js +87 -72
- package/client/client.js.map +1 -1
- package/package.json +8 -8
- package/src/client/MemoryView.tsx +2 -11
- package/src/client/TaskComponents.tsx +1 -10
- package/src/client/TaskPanel.tsx +3 -8
- package/src/client/i18n.ts +29 -0
- package/src/client/kind-label.js +38 -0
- package/src/client/slash.ts +4 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolk_vat-y/dsh-project-memory",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Persistent project memory for dsh agents: index docs (PDF/Markdown/text) and code symbols into a searchable per-workspace store, recall them with cited sources, and keep experience entries (problems -> solutions) searchable on demand.",
|
|
5
5
|
"author": "00080000 <3388065969@qq.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"url": "https://github.com/00080000/dsh-project-memory.git"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test": "node test/run-test.mjs && node test/taskbridge.test.mjs && node test/insight-store.test.mjs && node test/util-value.test.mjs && node test/reflection-pipeline.test.mjs && node test/auto-inject.test.mjs && node test/insight-actions.test.mjs && node test/insight-paging.test.mjs && node test/config-schema.test.mjs && node test/host-contract.test.mjs && node test/session-dir.test.mjs && node test/llm-route.test.mjs && node test/doc-index.test.mjs && node test/chunker.test.mjs && node test/client-hints.test.mjs && node test/client-paging.test.mjs && node test/client-task-sync.test.mjs && node test/recall.test.mjs && node test/recall-vector-fusion.test.mjs && node test/vector-index.test.mjs && node test/readiness.test.mjs && node test/insight-derive.test.mjs && node test/readiness-eval.test.mjs && node test/ops.test.mjs && node test/injection-audit.test.mjs && node test/signal-source.test.mjs && node test/skill.test.mjs && node test/injection-budget.test.mjs && node test/injection-scenarios.test.mjs && node test/bugfix-0.5.7.test.mjs && node test/client-icons.test.mjs && node test/client-slash.test.mjs && node test/client-toolview.test.mjs && node test/workflow-command.test.mjs && node test/client-session-id.test.mjs && node test/client-degraded.test.mjs && node test/settings-card.test.mjs && node test/watch-idle.test.mjs && node test/citation-paths.test.mjs && node test/task-view.test.mjs && node test/root-guards.test.mjs && node test/root-policy.test.mjs && node test/gitignore-index.test.mjs && node test/store-gitignore.test.mjs && node test/atomic-write.test.mjs && node test/store-cache.test.mjs && node test/store-concurrent.test.mjs && node test/store-lock.test.mjs && node test/windows-compat.test.mjs && node test/tool-schema-size.test.mjs && node test/enhancer.test.mjs && node test/multilingual-ru.test.mjs && node test/tokenizer-equivalence.test.mjs && node test/lazy-batch.test.mjs && node test/pdfjs-host.test.mjs && node test/index-failures.test.mjs && node test/audit-2026-11-02.test.mjs && node test/memorydir-guard.test.mjs && node test/audit-2026-11-05.test.mjs && node test/fix-2026-11-10-shell-write-ops.test.mjs && node test/fix-2026-11-10-trigger-derived-refresh.test.mjs && node test/fix-2026-11-10-manual-promote-dedup.test.mjs && node test/fix-2026-11-10-old-host-human.test.mjs && node test/fix-2026-11-10-project-memory-service.test.mjs && node test/lazy-ignore-scope.test.mjs && node test/watch-missing-root-warn.test.mjs && node test/inject-visible.test.mjs && node test/inject-reconcile.test.mjs && node test/shard-bucket.test.mjs && node test/audit-2026-11-10.test.mjs && node test/audit-2026-11-11.test.mjs",
|
|
23
|
+
"test": "node test/run-test.mjs && node test/taskbridge.test.mjs && node test/insight-store.test.mjs && node test/util-value.test.mjs && node test/reflection-pipeline.test.mjs && node test/auto-inject.test.mjs && node test/insight-actions.test.mjs && node test/insight-paging.test.mjs && node test/config-schema.test.mjs && node test/host-contract.test.mjs && node test/session-dir.test.mjs && node test/llm-route.test.mjs && node test/doc-index.test.mjs && node test/chunker.test.mjs && node test/client-hints.test.mjs && node test/client-paging.test.mjs && node test/client-task-sync.test.mjs && node test/recall.test.mjs && node test/recall-vector-fusion.test.mjs && node test/vector-index.test.mjs && node test/readiness.test.mjs && node test/insight-derive.test.mjs && node test/readiness-eval.test.mjs && node test/ops.test.mjs && node test/injection-audit.test.mjs && node test/signal-source.test.mjs && node test/skill.test.mjs && node test/injection-budget.test.mjs && node test/injection-scenarios.test.mjs && node test/bugfix-0.5.7.test.mjs && node test/client-icons.test.mjs && node test/client-slash.test.mjs && node test/client-kind-label.test.mjs && node test/client-toolview.test.mjs && node test/workflow-command.test.mjs && node test/client-session-id.test.mjs && node test/client-degraded.test.mjs && node test/settings-card.test.mjs && node test/watch-idle.test.mjs && node test/citation-paths.test.mjs && node test/task-view.test.mjs && node test/root-guards.test.mjs && node test/root-policy.test.mjs && node test/gitignore-index.test.mjs && node test/store-gitignore.test.mjs && node test/atomic-write.test.mjs && node test/store-cache.test.mjs && node test/store-concurrent.test.mjs && node test/store-lock.test.mjs && node test/windows-compat.test.mjs && node test/tool-schema-size.test.mjs && node test/enhancer.test.mjs && node test/multilingual-ru.test.mjs && node test/tokenizer-equivalence.test.mjs && node test/lazy-batch.test.mjs && node test/pdfjs-host.test.mjs && node test/index-failures.test.mjs && node test/audit-2026-11-02.test.mjs && node test/memorydir-guard.test.mjs && node test/audit-2026-11-05.test.mjs && node test/fix-2026-11-10-shell-write-ops.test.mjs && node test/fix-2026-11-10-trigger-derived-refresh.test.mjs && node test/fix-2026-11-10-manual-promote-dedup.test.mjs && node test/fix-2026-11-10-old-host-human.test.mjs && node test/fix-2026-11-10-project-memory-service.test.mjs && node test/lazy-ignore-scope.test.mjs && node test/watch-missing-root-warn.test.mjs && node test/inject-visible.test.mjs && node test/inject-reconcile.test.mjs && node test/shard-bucket.test.mjs && node test/audit-2026-11-10.test.mjs && node test/audit-2026-11-11.test.mjs",
|
|
24
24
|
"eval:injection": "node test/injection-scenarios.test.mjs",
|
|
25
25
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.client.json",
|
|
26
26
|
"selfcheck:triggers": "node test/injection-scenarios.test.mjs --selfcheck",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
58
|
-
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.
|
|
59
|
-
"@deepseek-ai/dsh-client-store": "0.2.2-rc.
|
|
60
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.
|
|
62
|
-
"@deepseek-ai/dsh-llm": "0.2.2-rc.
|
|
63
|
-
"@deepseek-ai/dsh-tools": "0.2.2-rc.
|
|
58
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.5",
|
|
59
|
+
"@deepseek-ai/dsh-client-store": "0.2.2-rc.5",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.5",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.5",
|
|
62
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.5",
|
|
63
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.5",
|
|
64
64
|
"@deepseek-ai/schemastery": "^3.18.3",
|
|
65
65
|
"@tsdown/css": "0.22.14",
|
|
66
66
|
"@types/react": "^18.3.31",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { useEffect, useCallback, useRef, useState } from 'react'
|
|
10
10
|
import { Button } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
11
11
|
import { invokeCommand } from './commands.ts'
|
|
12
|
+
import { insightKindLabel } from './kind-label.js'
|
|
12
13
|
import { HOST_PAGE_MAX, PAGE_SIZE, PREFETCH_MARGIN, SPINNER_DELAY_MS, appendUnique, createRequestGate, insightListLine, normalizeWindow, progressCounts } from './paging.js'
|
|
13
14
|
import css from './TaskPanel.module.css'
|
|
14
15
|
|
|
@@ -132,16 +133,6 @@ export function parseInsightPayloadText(text?: string | null): ListPayload | nul
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
function kindText(kind: string, t: any): string {
|
|
136
|
-
const map: Record<string, string> = {
|
|
137
|
-
lesson: t('mem.kind.lesson'),
|
|
138
|
-
decision: t('mem.kind.decision'),
|
|
139
|
-
procedure: t('mem.kind.procedure'),
|
|
140
|
-
experience: t('mem.kind.experience'),
|
|
141
|
-
}
|
|
142
|
-
return map[kind] ?? kind
|
|
143
|
-
}
|
|
144
|
-
|
|
145
136
|
export function MemoryView({
|
|
146
137
|
ctx,
|
|
147
138
|
sessionId,
|
|
@@ -562,7 +553,7 @@ export function MemoryView({
|
|
|
562
553
|
<div key={row.id} className={`${css.memRow}${row.archived ? ` ${css.memRowArchived}` : ''}`}>
|
|
563
554
|
<div className={css.memRowMain}>
|
|
564
555
|
<span className={css.memTitle}>
|
|
565
|
-
<span className={css.kindBadge}>{
|
|
556
|
+
<span className={css.kindBadge}>{insightKindLabel(row.kind, t)}</span>
|
|
566
557
|
{row.title || row.body}
|
|
567
558
|
</span>
|
|
568
559
|
<span className={css.memMeta}>
|
|
@@ -13,21 +13,12 @@ import {
|
|
|
13
13
|
IconFolderOpenOutline16,
|
|
14
14
|
} from './icons.ts'
|
|
15
15
|
import { createTranslate } from './locales.ts'
|
|
16
|
+
import { insightKindLabel } from './kind-label.js'
|
|
16
17
|
import { useTaskDrag } from './task-hooks.ts'
|
|
17
18
|
import { type Task, type TaskInsight, type TaskStep } from './task-data-store.ts'
|
|
18
19
|
import { timeAgo } from '../util/relative-time.js'
|
|
19
20
|
import css from './TaskPanel.module.css'
|
|
20
21
|
|
|
21
|
-
function insightKindLabel(kind: string, t: ReturnType<typeof createTranslate>): string {
|
|
22
|
-
const map: Record<string, string> = {
|
|
23
|
-
lesson: t('mem.kind.lesson'),
|
|
24
|
-
decision: t('mem.kind.decision'),
|
|
25
|
-
procedure: t('mem.kind.procedure'),
|
|
26
|
-
experience: t('mem.kind.experience'),
|
|
27
|
-
}
|
|
28
|
-
return map[kind] ?? kind
|
|
29
|
-
}
|
|
30
|
-
|
|
31
22
|
type InsightAction = 'confirm' | 'promote' | 'delete'
|
|
32
23
|
|
|
33
24
|
function StepIcon({ status }: { status: TaskStep['status'] }) {
|
package/src/client/TaskPanel.tsx
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
IconFolderOpenOutline16,
|
|
13
13
|
IconQuestionOutline14,
|
|
14
14
|
} from './icons.ts'
|
|
15
|
-
import {
|
|
15
|
+
import { zh } from './locales.ts'
|
|
16
|
+
import { translatorFor } from './i18n.ts'
|
|
16
17
|
import { invokeCommand } from './commands.ts'
|
|
17
18
|
import { missingServices, service } from './services.ts'
|
|
18
19
|
import { useTaskData, useTaskDataActions, parseTaskPayloadText } from './task-data-store.ts'
|
|
@@ -26,12 +27,6 @@ const STATUS_CYCLE = ['pending', 'in_progress', 'completed'] as const
|
|
|
26
27
|
// 视图列表的唯一事实来源在 UI store(`/` 菜单那三行也读它);这里不再抄一份。
|
|
27
28
|
const VIEW_CYCLE = PANEL_VIEWS
|
|
28
29
|
|
|
29
|
-
function getT(ctx: any) {
|
|
30
|
-
// 服务一律走软探测(services.ts):宿主的翻译服务不在时退英文,而不是抛错带崩整个面板。
|
|
31
|
-
const locale = service(ctx, 'locale')?.getSnapshot?.()?.active === 'zh' ? zh : en
|
|
32
|
-
return createTranslate(locale)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
30
|
function useSessionId(ctx: any): string | null {
|
|
36
31
|
const [, force] = useState(0)
|
|
37
32
|
useEffect(() => {
|
|
@@ -69,7 +64,7 @@ export function TaskPanelEntry({ ctx }: { ctx: any }) {
|
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
function TaskPanelView({ ctx }: { ctx: any }) {
|
|
72
|
-
const t =
|
|
67
|
+
const t = translatorFor(ctx)
|
|
73
68
|
const data = useTaskData()
|
|
74
69
|
const ui = useTaskUI()
|
|
75
70
|
// 缺失的客户端服务:面板照常挂载,但必须把原因摆在界面上(否则用户看到的是
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client 半边唯一的「按宿主语言取翻译函数」入口。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独一个模块:同一段「软读 locale 服务 → 中文用 zh、其余(含服务缺失)用 en →
|
|
5
|
+
* createTranslate」原先在 TaskPanel.tsx(getT)与 slash.ts(translator)各写一份。
|
|
6
|
+
* 语言判据是产品语义而不是某次渲染的局部细节:两份副本各自演化时,面板会中文、
|
|
7
|
+
* `/` 菜单却英文,而且看起来都"正常"。收敛到这里,只保留一个事实。
|
|
8
|
+
*
|
|
9
|
+
* 语义(刻意定死):
|
|
10
|
+
* - 只认 `active === 'zh'`;其它值(en / 未知 / 缺失 locale 服务)一律英文——
|
|
11
|
+
* 与旧实现一致,也不把"未知语言"猜成中文;
|
|
12
|
+
* - `service()` 是软探测,宿主没有 locale 服务时这里不抛错,面板照常渲染英文。
|
|
13
|
+
* @module dsh-project-memory/client/i18n
|
|
14
|
+
*/
|
|
15
|
+
import { createTranslate, en, zh } from './locales.ts'
|
|
16
|
+
import { service } from './services.ts'
|
|
17
|
+
|
|
18
|
+
/** 翻译函数签名(key 可能是运行期拼出来的,故不按词典 key 做字面量约束)。 */
|
|
19
|
+
export type Translator = (key: string, params?: Record<string, string | number>) => string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 当前宿主语言对应的翻译函数。
|
|
23
|
+
* @param ctx - client 上下文(缺失/贫服务宿主也能调用)。
|
|
24
|
+
* @returns 翻译函数;语言服务不可读时退回英文。
|
|
25
|
+
*/
|
|
26
|
+
export function translatorFor(ctx: any): Translator {
|
|
27
|
+
const active = service(ctx, 'locale')?.getSnapshot?.()?.active
|
|
28
|
+
return createTranslate(active === 'zh' ? zh : en) as unknown as Translator
|
|
29
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记忆 kind 的展示名(纯函数、零依赖,面板卡片与记忆视图共用)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独一个模块:同一份「kind → 词典 key」映射原先在两处各抄一份
|
|
5
|
+
* (TaskComponents.tsx 的 insightKindLabel、MemoryView.tsx 的 kindText,逐字相同)。
|
|
6
|
+
* 新增 kind 时漏改一处,两个界面就会对同一条记忆显示不同的标签;而词典 key 本身
|
|
7
|
+
* 是 locales.ts 的一等公民(`mem.kind.*` 中英两份),映射不该散落在组件里。
|
|
8
|
+
*
|
|
9
|
+
* 语义(刻意定死,边缘输入也用测试钉住):
|
|
10
|
+
* - 四个合法 kind 一律走 `t(key)`,语言切换由词典自己负责;
|
|
11
|
+
* - 其余值**原样返回**(字符串化),绝不回退到某个默认 kind —— 脏数据要让调用方看见;
|
|
12
|
+
* - 用 `hasOwn` 而不是 `map[kind] ?? kind` 查表:`kind: '__proto__'` / `'constructor'`
|
|
13
|
+
* 在对象字面量上会命中原型成员(返回函数/对象),React 渲染对象会直接抛
|
|
14
|
+
* "Objects are not valid as a React child"。非 kind 的键必须当成非法值处理。
|
|
15
|
+
* @module dsh-project-memory/client/kind-label
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** kind → 词典 key(唯一一份;与 locales.ts 的 `mem.kind.*` 一一对应)。 */
|
|
19
|
+
export const KIND_LABEL_KEYS = Object.freeze({
|
|
20
|
+
lesson: 'mem.kind.lesson',
|
|
21
|
+
decision: 'mem.kind.decision',
|
|
22
|
+
procedure: 'mem.kind.procedure',
|
|
23
|
+
experience: 'mem.kind.experience',
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 一条记忆的 kind 展示名。
|
|
28
|
+
* @param {unknown} kind - 记忆条目的 kind(可能是缺失/脏值)。
|
|
29
|
+
* @param {any} t - 翻译函数。这里刻意不收窄成 `(key: string) => string`:组件的 t 是
|
|
30
|
+
* `ReturnType<typeof createTranslate>`(key 为词典字面量并集),收窄会让严格模式下的
|
|
31
|
+
* 函数参数逆变检查拒绝调用;key 本身由本模块掌管,调用方只需要"能翻译一个字符串 key"。
|
|
32
|
+
* @returns {string} 本地化后的标签;非法 kind 原样字符串化。
|
|
33
|
+
*/
|
|
34
|
+
export function insightKindLabel(kind, t) {
|
|
35
|
+
const key = typeof kind === 'string' && Object.hasOwn(KIND_LABEL_KEYS, kind) ? KIND_LABEL_KEYS[kind] : null
|
|
36
|
+
if (key === null) return String(kind ?? '')
|
|
37
|
+
return t(key)
|
|
38
|
+
}
|
package/src/client/slash.ts
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* 面板 `closed`/`view` 是浏览器侧状态,直接调 `openView(view)`;也不实现 matchSpace / matchEnter。
|
|
5
5
|
*/
|
|
6
6
|
import type { ComponentType } from 'react'
|
|
7
|
-
import {
|
|
8
|
-
import { service } from './services.ts'
|
|
7
|
+
import { translatorFor, type Translator } from './i18n.ts'
|
|
9
8
|
import type { PanelView } from './task-ui-store.ts'
|
|
10
9
|
import { IconChecklistOutline16, IconGlobeOutline16, IconLightOutline16 } from './icons.ts'
|
|
11
10
|
|
|
@@ -65,16 +64,6 @@ export interface SlashSourceDeps {
|
|
|
65
64
|
openView(view: PanelView): void
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
/** 翻译函数签名(key 来自 ROWS,不是字面量,故不做类型约束)。 */
|
|
69
|
-
type Translate = (key: string, params?: Record<string, string | number>) => string
|
|
70
|
-
|
|
71
|
-
/** 按当前语言取翻译函数。 */
|
|
72
|
-
function translator(ctx: any): Translate {
|
|
73
|
-
// 软探测(services.ts):宿主没有翻译服务时退英文,而不是抛错。
|
|
74
|
-
const dict = service(ctx, 'locale')?.getSnapshot?.()?.active === 'zh' ? zh : en
|
|
75
|
-
return createTranslate(dict) as unknown as Translate
|
|
76
|
-
}
|
|
77
|
-
|
|
78
67
|
/**
|
|
79
68
|
* 一轮候选:把三行装配成菜单行,再按查询与位置过滤。
|
|
80
69
|
* 三行都不接参数(动作全在面板卡片里),所以位置过滤只做一件事:非 leading 位置不弹这一整组
|
|
@@ -83,7 +72,7 @@ function translator(ctx: any): Translate {
|
|
|
83
72
|
* @param req - 宿主给的候选请求(query / position)。
|
|
84
73
|
* @returns 菜单行;永不抛出。
|
|
85
74
|
*/
|
|
86
|
-
export function buildSlashCandidates(t:
|
|
75
|
+
export function buildSlashCandidates(t: Translator, req: any): readonly Record<string, unknown>[] {
|
|
87
76
|
if (req?.position !== undefined && req.position !== 'leading') return []
|
|
88
77
|
const query = typeof req?.query === 'string' ? req.query.trim().toLowerCase() : ''
|
|
89
78
|
const rows = ROWS.map((row) => {
|
|
@@ -131,7 +120,7 @@ function consumeSpan(deps: SlashSourceDeps, pick: any): boolean {
|
|
|
131
120
|
* @param pick - 宿主给的点击载荷。
|
|
132
121
|
* @returns PickOutcome;拿不到可用形状时返回 undefined(菜单照常关闭,草稿不动)。
|
|
133
122
|
*/
|
|
134
|
-
export function dispatchSlashPick(t:
|
|
123
|
+
export function dispatchSlashPick(t: Translator, deps: SlashSourceDeps, pick: any): unknown {
|
|
135
124
|
const title = pick?.candidate?.name
|
|
136
125
|
if (typeof title !== 'string' || title === '') return undefined
|
|
137
126
|
const row = ROWS.find((candidate) => t(candidate.labelKey) === title)
|
|
@@ -152,7 +141,7 @@ export function dispatchSlashPick(t: Translate, deps: SlashSourceDeps, pick: any
|
|
|
152
141
|
* @returns 触发器源;只依赖宿主的公开契约字段。
|
|
153
142
|
*/
|
|
154
143
|
export function createSlashSource(ctx: any, deps: SlashSourceDeps): Record<string, unknown> {
|
|
155
|
-
const t =
|
|
144
|
+
const t = translatorFor(ctx)
|
|
156
145
|
return {
|
|
157
146
|
trigger: '/',
|
|
158
147
|
name: SLASH_SOURCE_NAME,
|