dsh-memvault 0.10.1 → 0.11.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/README.md +60 -24
- package/README.zh.md +70 -34
- package/cordis.patch.yml +23 -0
- package/docs/CORE-DESIGN.md +9 -0
- package/docs/DEVLOG.md +607 -0
- package/docs/PLAN-0.11.md +421 -0
- package/docs/domains/game-dev.md +67 -0
- package/lib/blocks.js +34 -8
- package/lib/client.js +631 -12
- package/lib/config.js +207 -0
- package/lib/core/block-write.js +70 -17
- package/lib/core/host.js +15 -4
- package/lib/core/knowledge.js +332 -0
- package/lib/core/pipeline.js +13 -4
- package/lib/core/promotion.js +155 -0
- package/lib/core/proposals.js +508 -0
- package/lib/core/schema.js +159 -1
- package/lib/core/store.js +160 -3
- package/lib/core/tools.js +155 -4
- package/lib/domain-host.js +490 -0
- package/lib/domain.js +483 -0
- package/lib/gate.js +201 -0
- package/lib/index.js +412 -7
- package/lib/panel.js +209 -3
- package/package.json +1 -1
- package/scripts/seed-domains.mjs +171 -0
- package/scripts/smoke-panel.mjs +200 -14
- package/src/client/index.js +629 -10
package/lib/panel.js
CHANGED
|
@@ -53,6 +53,36 @@ export const REVIEW_PATH = '/memvault/api/review'
|
|
|
53
53
|
/** Exact route that replays a retained extraction input (writes the store). */
|
|
54
54
|
export const REPLAY_PATH = '/memvault/api/replay'
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Exact route for the core-block proposal queue.
|
|
58
|
+
*
|
|
59
|
+
* GET lists (read-only), POST decides. Same path on purpose: an approval is a
|
|
60
|
+
* statement about one proposal, and splitting the decision across two URLs would
|
|
61
|
+
* only make "what did I just approve" harder to follow in a log.
|
|
62
|
+
*/
|
|
63
|
+
export const PROPOSALS_PATH = '/memvault/api/proposals'
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Exact route for domain packs.
|
|
67
|
+
*
|
|
68
|
+
* GET lists packs plus which ones are currently injected; POST creates/updates a
|
|
69
|
+
* pack or moves its status. Authoring and approval share the route because both are
|
|
70
|
+
* "a human deciding what background the model gets".
|
|
71
|
+
*/
|
|
72
|
+
export const DOMAIN_PATH = '/memvault/api/domain'
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Read-only plane for the six tacit-knowledge classes.
|
|
76
|
+
*
|
|
77
|
+
* A route rather than part of `status` because the panel polls status often and
|
|
78
|
+
* these aggregates need two grouped queries; keeping them off the hot path is what
|
|
79
|
+
* lets status stay cheap.
|
|
80
|
+
*/
|
|
81
|
+
export const KNOWLEDGE_PATH = '/memvault/api/knowledge'
|
|
82
|
+
|
|
83
|
+
/** The knowledge flow, merged from tables that already carry timestamps. */
|
|
84
|
+
export const TIMELINE_PATH = '/memvault/api/timeline'
|
|
85
|
+
|
|
56
86
|
/** Largest accepted JSON body; a core block is at most a few KiB. */
|
|
57
87
|
export const MAX_BODY_BYTES = 64 * 1024
|
|
58
88
|
|
|
@@ -103,7 +133,7 @@ const clampValue = (value) => {
|
|
|
103
133
|
* Shape the panel's payload.
|
|
104
134
|
*
|
|
105
135
|
* @param options.read - read-half config plus the cache facts (`cacheAgeMs`,
|
|
106
|
-
* `renderedChars`, `error`, `enabled`).
|
|
136
|
+
* `renderedChars`, `droppedBlocks`, `error`, `enabled`).
|
|
107
137
|
* @param options.blocks - the blocks the last read returned.
|
|
108
138
|
* @param options.extract - write-half config plus `sessions` and `diagnostics`.
|
|
109
139
|
* @param options.at - ISO timestamp of this snapshot.
|
|
@@ -116,11 +146,30 @@ const clampValue = (value) => {
|
|
|
116
146
|
*/
|
|
117
147
|
export function buildStatus({
|
|
118
148
|
read = {}, blocks = [], extract = {}, at = new Date().toISOString(), writable = true, configIssues = {}, dbFile = {},
|
|
119
|
-
paths = [], discovery = {}, writeScope = {},
|
|
149
|
+
paths = [], discovery = {}, writeScope = {}, proposals = null, domain = null,
|
|
120
150
|
} = {}) {
|
|
121
151
|
return {
|
|
122
152
|
at,
|
|
123
153
|
writable: writable !== false,
|
|
154
|
+
// Which domain packs are injected right now, and the one the scorer suspected.
|
|
155
|
+
// `null` when the store is unavailable; `[]` means "looked, nothing active".
|
|
156
|
+
domain: domain === null ? null : {
|
|
157
|
+
packs: domain.packs ?? 0,
|
|
158
|
+
approved: domain.approved ?? 0,
|
|
159
|
+
active: Array.isArray(domain.active) ? domain.active : [],
|
|
160
|
+
shadow: Array.isArray(domain.shadow) ? domain.shadow : [],
|
|
161
|
+
probeDir: domain.probeDir ?? '',
|
|
162
|
+
reasons: Array.isArray(domain.reasons) ? domain.reasons : [],
|
|
163
|
+
},
|
|
164
|
+
// Core-block proposals waiting for a human. `null` when the store is not
|
|
165
|
+
// open (a read-only composition), which the panel renders as "unavailable"
|
|
166
|
+
// rather than as an empty queue.
|
|
167
|
+
proposals: proposals === null ? null : {
|
|
168
|
+
pending: proposals.pending ?? 0,
|
|
169
|
+
stale: proposals.stale ?? 0,
|
|
170
|
+
applied: proposals.applied ?? 0,
|
|
171
|
+
oldestAgeMs: proposals.oldestAgeMs ?? null,
|
|
172
|
+
},
|
|
124
173
|
configIssues: {
|
|
125
174
|
unknown: configIssues.unknown ?? [],
|
|
126
175
|
problems: configIssues.problems ?? [],
|
|
@@ -160,6 +209,9 @@ export function buildStatus({
|
|
|
160
209
|
cacheAgeMs: read.cacheAgeMs ?? null,
|
|
161
210
|
renderedChars: read.renderedChars ?? 0,
|
|
162
211
|
blockCount: blocks.length,
|
|
212
|
+
// Blocks that exist but did not fit the character budget. Reported so an
|
|
213
|
+
// emptied injection is not mistaken for a missing configuration.
|
|
214
|
+
droppedBlocks: read.droppedBlocks ?? 0,
|
|
163
215
|
error: read.error ?? null,
|
|
164
216
|
},
|
|
165
217
|
blocks: blocks.map((b) => ({
|
|
@@ -267,7 +319,8 @@ export function readJsonBody(req, maxBytes = MAX_BODY_BYTES) {
|
|
|
267
319
|
export function createPanelApi({
|
|
268
320
|
status, refresh, writeBlock = null, flush = null, readMemories = null,
|
|
269
321
|
readProvenance = null, writeFlag = null, readReview = null, replay = null, readStructure = null,
|
|
270
|
-
reindex = null,
|
|
322
|
+
reindex = null, readProposals = null, decideProposal = null,
|
|
323
|
+
readDomains = null, writeDomain = null, readKnowledge = null, readTimeline = null,
|
|
271
324
|
}) {
|
|
272
325
|
const guard = (req, res) => {
|
|
273
326
|
if (!isTrustedRequest(req?.headers)) {
|
|
@@ -554,6 +607,155 @@ export function createPanelApi({
|
|
|
554
607
|
else sendJson(res, 500, { ok: false, error: String(out?.error ?? 'reindex failed') })
|
|
555
608
|
}
|
|
556
609
|
|
|
610
|
+
/**
|
|
611
|
+
* The proposal queue: read it with GET, decide one with POST.
|
|
612
|
+
*
|
|
613
|
+
* The decision is the only place in the plugin where a block changes without a
|
|
614
|
+
* human typing its new value, so this handler does not accept a `value` field at
|
|
615
|
+
* all: it can approve, refuse or undo what was already proposed, and nothing else.
|
|
616
|
+
*/
|
|
617
|
+
const proposalsRoute = async (req, res) => {
|
|
618
|
+
if (!guard(req, res)) return
|
|
619
|
+
try {
|
|
620
|
+
if (req.method === 'GET') {
|
|
621
|
+
if (!readProposals) {
|
|
622
|
+
sendJson(res, 405, { ok: false, error: 'the proposal queue is unavailable in this composition' })
|
|
623
|
+
return
|
|
624
|
+
}
|
|
625
|
+
const url = new URL(String(req.url ?? '/'), 'http://127.0.0.1')
|
|
626
|
+
const status = url.searchParams.get('status') ?? 'pending'
|
|
627
|
+
const limit = Number(url.searchParams.get('limit') ?? 20)
|
|
628
|
+
sendJson(res, 200, { ok: true, ...readProposals({ status, limit }) })
|
|
629
|
+
return
|
|
630
|
+
}
|
|
631
|
+
if (req.method !== 'POST') {
|
|
632
|
+
sendJson(res, 405, { ok: false, error: 'GET or POST only' })
|
|
633
|
+
return
|
|
634
|
+
}
|
|
635
|
+
if (!decideProposal) {
|
|
636
|
+
sendJson(res, 403, { ok: false, error: 'approving needs the write half (config panel.writes: true)' })
|
|
637
|
+
return
|
|
638
|
+
}
|
|
639
|
+
const read = await readJsonBody(req)
|
|
640
|
+
if (read.tooLarge) {
|
|
641
|
+
sendJson(res, 413, { ok: false, error: `body is larger than ${MAX_BODY_BYTES} bytes` })
|
|
642
|
+
return
|
|
643
|
+
}
|
|
644
|
+
if (read.error) {
|
|
645
|
+
sendJson(res, 400, { ok: false, error: read.error })
|
|
646
|
+
return
|
|
647
|
+
}
|
|
648
|
+
const out = await decideProposal(read.body ?? {})
|
|
649
|
+
if (!out?.ok) {
|
|
650
|
+
sendJson(res, out?.status ?? 400, {
|
|
651
|
+
ok: false,
|
|
652
|
+
error: String(out?.error ?? 'the decision failed'),
|
|
653
|
+
currentUpdatedAt: out?.currentUpdatedAt ?? null,
|
|
654
|
+
cooledUntil: out?.cooledUntil ?? null,
|
|
655
|
+
})
|
|
656
|
+
return
|
|
657
|
+
}
|
|
658
|
+
sendJson(res, 200, {
|
|
659
|
+
ok: true,
|
|
660
|
+
proposal: out.proposal ?? null,
|
|
661
|
+
row: out.row ?? null,
|
|
662
|
+
superseded: out.superseded ?? [],
|
|
663
|
+
})
|
|
664
|
+
} catch (error) {
|
|
665
|
+
sendJson(res, 500, { ok: false, error: String(error?.message ?? error) })
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Domain packs: read the shelf with GET, author or approve one with POST.
|
|
671
|
+
*
|
|
672
|
+
* The status change is separate from the upsert (`action: 'status'` vs
|
|
673
|
+
* `action: 'upsert'`) because they have different authorities: a status change
|
|
674
|
+
* needs a source, an upsert may be a draft.
|
|
675
|
+
*/
|
|
676
|
+
const domainRoute = async (req, res) => {
|
|
677
|
+
if (!guard(req, res)) return
|
|
678
|
+
try {
|
|
679
|
+
if (req.method === 'GET') {
|
|
680
|
+
if (!readDomains) {
|
|
681
|
+
sendJson(res, 405, { ok: false, error: 'domain packs are unavailable in this composition' })
|
|
682
|
+
return
|
|
683
|
+
}
|
|
684
|
+
sendJson(res, 200, { ok: true, ...readDomains() })
|
|
685
|
+
return
|
|
686
|
+
}
|
|
687
|
+
if (req.method !== 'POST') {
|
|
688
|
+
sendJson(res, 405, { ok: false, error: 'GET or POST only' })
|
|
689
|
+
return
|
|
690
|
+
}
|
|
691
|
+
if (!writeDomain) {
|
|
692
|
+
sendJson(res, 403, { ok: false, error: 'authoring domains needs the write half (config panel.writes: true)' })
|
|
693
|
+
return
|
|
694
|
+
}
|
|
695
|
+
const read = await readJsonBody(req)
|
|
696
|
+
if (read.tooLarge) {
|
|
697
|
+
sendJson(res, 413, { ok: false, error: `body is larger than ${MAX_BODY_BYTES} bytes` })
|
|
698
|
+
return
|
|
699
|
+
}
|
|
700
|
+
if (read.error) {
|
|
701
|
+
sendJson(res, 400, { ok: false, error: read.error })
|
|
702
|
+
return
|
|
703
|
+
}
|
|
704
|
+
const out = await writeDomain(read.body ?? {})
|
|
705
|
+
if (!out?.ok) {
|
|
706
|
+
sendJson(res, out?.status ?? 400, { ok: false, error: String(out?.error ?? 'the write failed') })
|
|
707
|
+
return
|
|
708
|
+
}
|
|
709
|
+
sendJson(res, 200, { ok: true, domain: out.domain ?? null })
|
|
710
|
+
} catch (error) {
|
|
711
|
+
sendJson(res, 500, { ok: false, error: String(error?.message ?? error) })
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/** The flow view: GET only, same read-only rule as the health plane. */
|
|
716
|
+
const timelineRoute = async (req, res) => {
|
|
717
|
+
if (!guard(req, res)) return
|
|
718
|
+
if (req.method !== 'GET') {
|
|
719
|
+
sendJson(res, 405, { ok: false, error: 'GET only' })
|
|
720
|
+
return
|
|
721
|
+
}
|
|
722
|
+
if (!readTimeline) {
|
|
723
|
+
sendJson(res, 503, { ok: false, error: 'the timeline is unavailable in this composition' })
|
|
724
|
+
return
|
|
725
|
+
}
|
|
726
|
+
try {
|
|
727
|
+
const url = new URL(req.url ?? '/', 'http://localhost')
|
|
728
|
+
const limit = Number(url.searchParams.get('limit') ?? 60)
|
|
729
|
+
sendJson(res, 200, { ok: true, ...readTimeline({ limit: Number.isFinite(limit) ? limit : 60 }) })
|
|
730
|
+
} catch (error) {
|
|
731
|
+
sendJson(res, 500, { ok: false, error: String(error?.message ?? error) })
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Knowledge health: read-only, GET only.
|
|
737
|
+
*
|
|
738
|
+
* No POST: a knowledge row is written by the capture channel, never typed by
|
|
739
|
+
* hand, and its promotion path goes through the proposal queue like everything
|
|
740
|
+
* else that can reach the prompt.
|
|
741
|
+
*/
|
|
742
|
+
const knowledgeRoute = async (req, res) => {
|
|
743
|
+
if (!guard(req, res)) return
|
|
744
|
+
if (req.method !== 'GET') {
|
|
745
|
+
sendJson(res, 405, { ok: false, error: 'GET only' })
|
|
746
|
+
return
|
|
747
|
+
}
|
|
748
|
+
if (!readKnowledge) {
|
|
749
|
+
sendJson(res, 503, { ok: false, error: 'the knowledge plane is unavailable in this composition' })
|
|
750
|
+
return
|
|
751
|
+
}
|
|
752
|
+
try {
|
|
753
|
+
sendJson(res, 200, { ok: true, ...readKnowledge() })
|
|
754
|
+
} catch (error) {
|
|
755
|
+
sendJson(res, 500, { ok: false, error: String(error?.message ?? error) })
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
557
759
|
return {
|
|
558
760
|
status: wrap(() => status(), 'GET'),
|
|
559
761
|
refresh: wrap(() => refresh(), 'POST'),
|
|
@@ -566,5 +768,9 @@ export function createPanelApi({
|
|
|
566
768
|
replay: replayNow,
|
|
567
769
|
structure,
|
|
568
770
|
reindex: reindexNow,
|
|
771
|
+
proposals: proposalsRoute,
|
|
772
|
+
domain: domainRoute,
|
|
773
|
+
knowledge: knowledgeRoute,
|
|
774
|
+
timeline: timelineRoute,
|
|
569
775
|
}
|
|
570
776
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-memvault",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "DeepSeek Harness plugin: inject MemVault core memory blocks into the system prompt, extract finished turns as one windowed pass, and show, edit, trace, review and replay all of it in a memory panel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Seed the four starter domain packs.
|
|
4
|
+
*
|
|
5
|
+
* They exist so the mechanism is demonstrable before anyone authors a pack: each
|
|
6
|
+
* one is written as a `draft` and printed with the command that would approve it.
|
|
7
|
+
* Nothing here activates anything — approving a pack is a human decision, and a
|
|
8
|
+
* script that both writes and approves would be exactly the self-approval loop the
|
|
9
|
+
* design forbids.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* node scripts/seed-domains.mjs # dry run: show what would be written
|
|
13
|
+
* node scripts/seed-domains.mjs --apply # write them as drafts
|
|
14
|
+
* node scripts/seed-domains.mjs --apply --db <path>
|
|
15
|
+
*
|
|
16
|
+
* The store path defaults to the plugin's own (`DSH_MEMVAULT_CORE_DB`, then
|
|
17
|
+
* `MEMVAULT_DB_PATH`, then `~/.dsh/memvault/memvault.db`).
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync } from 'node:fs'
|
|
20
|
+
|
|
21
|
+
import { CoreStore } from '../lib/core/store.js'
|
|
22
|
+
import { DEFAULT_DB_PATH } from '../lib/blocks.js'
|
|
23
|
+
import { listDomains, upsertDomain } from '../lib/domain.js'
|
|
24
|
+
|
|
25
|
+
const PACKS = [
|
|
26
|
+
{
|
|
27
|
+
domain_id: 'game',
|
|
28
|
+
name: '游戏开发',
|
|
29
|
+
index_text: '游戏机制类任务:实现前先查目标引擎当前版本的官方文档(API 与物理/碰撞层配置),'
|
|
30
|
+
+ '再动手;引擎版本与导出设置要写进注释。适合按引擎分文件组织,不把玩法逻辑塞进 UI 层。',
|
|
31
|
+
detail_text: [
|
|
32
|
+
'## 常见坑',
|
|
33
|
+
'- Godot 4:2D 物理用 CharacterBody2D + move_and_slide,不要再用 KinematicBody2D。',
|
|
34
|
+
'- Unity:Rigidbody2D 与 Collider2D 的 Layer 碰撞矩阵要显式配置,默认全开会让触发器互相干扰。',
|
|
35
|
+
'- 帧率相关逻辑必须用 delta,不要用固定像素位移。',
|
|
36
|
+
'## 参考',
|
|
37
|
+
'- Godot 官方文档「Physics introduction」。',
|
|
38
|
+
'- Unity Manual「Layer-based collision detection」。',
|
|
39
|
+
].join('\n'),
|
|
40
|
+
signals: {
|
|
41
|
+
keywords: ['游戏', '玩法', 'godot', 'unity', '碰撞', '关卡', '帧率'],
|
|
42
|
+
pathGlobs: ['games', 'game/', 'godot', 'unity'],
|
|
43
|
+
fileMarkers: ['project.godot', 'Assets', 'ProjectSettings'],
|
|
44
|
+
deps: ['phaser', 'three', 'pixi.js', 'godot'],
|
|
45
|
+
},
|
|
46
|
+
// A gate, not a red line: the write tools are refused until the model records
|
|
47
|
+
// the document it read. Red lines are advice; this one has teeth.
|
|
48
|
+
gates: [{
|
|
49
|
+
id: 'engine-docs',
|
|
50
|
+
text: '实现游戏机制前先查目标引擎当前版本的官方文档(API 与物理/碰撞层配置)',
|
|
51
|
+
blocks: ['write', 'edit', 'apply_patch', 'memory_add'],
|
|
52
|
+
evidence: { requireUrl: true, minQuote: 40 },
|
|
53
|
+
}],
|
|
54
|
+
redlines: ['不要在没查引擎版本的情况下替换 API', '物理相关改动必须给出 delta 处理'],
|
|
55
|
+
sources: [
|
|
56
|
+
{ title: 'Godot docs: Physics introduction', url: 'https://docs.godotengine.org/en/stable/tutorials/physics/' },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
domain_id: 'study',
|
|
61
|
+
name: '学习与课程',
|
|
62
|
+
index_text: '学习类任务:先确认课程/教材版本与考核范围,再整理;笔记按周归档,复习优先看错题。'
|
|
63
|
+
+ '没给范围时先问,不要按自己的假设铺开。',
|
|
64
|
+
detail_text: [
|
|
65
|
+
'## 约定',
|
|
66
|
+
'- 一周一个文件,命名 `YYYY-Www.md`;错题单独一栏目。',
|
|
67
|
+
'- 复习顺序:错题 → 概念图 → 课后题。',
|
|
68
|
+
'- 引用教材要给章节号,方便回查。',
|
|
69
|
+
].join('\n'),
|
|
70
|
+
signals: {
|
|
71
|
+
keywords: ['课程', '作业', '复习', '笔记', '考试', '教材'],
|
|
72
|
+
pathGlobs: ['notes', 'study', 'course', 'school'],
|
|
73
|
+
fileMarkers: ['syllabus.md', 'notes.md'],
|
|
74
|
+
deps: [],
|
|
75
|
+
},
|
|
76
|
+
redlines: ['不要替用户决定考核重点', '引用教材必须带章节号'],
|
|
77
|
+
sources: [{ title: '用户既有笔记约定' }],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
domain_id: 'modeling',
|
|
81
|
+
name: '建模与 3D',
|
|
82
|
+
index_text: '建模类任务:导出前检查单位、法线与缩放;glTF 的轴向约定要显式说明。'
|
|
83
|
+
+ '涉及依赖安装时先看 Blender 版本对应的 Python API。',
|
|
84
|
+
detail_text: [
|
|
85
|
+
'## 常见坑',
|
|
86
|
+
'- Blender 导 glTF 默认 +Y up,与 Unity 的左手系要注意二次翻转。',
|
|
87
|
+
'- 法线反了在引擎里表现为“黑面”,不在建模软件里报错。',
|
|
88
|
+
'- 单位统一为米;缩放要在物体上应用(apply scale)。',
|
|
89
|
+
].join('\n'),
|
|
90
|
+
signals: {
|
|
91
|
+
keywords: ['建模', 'blender', 'gltf', 'fbx', '材质', '法线'],
|
|
92
|
+
pathGlobs: ['models', 'blender', 'art'],
|
|
93
|
+
// Literal paths only: the probe checks existence, it does not glob.
|
|
94
|
+
fileMarkers: ['scene.blend', 'model.blend'],
|
|
95
|
+
deps: ['three', 'babylonjs'],
|
|
96
|
+
},
|
|
97
|
+
gates: [{
|
|
98
|
+
id: 'export-check',
|
|
99
|
+
text: '导出前核对单位、法线与轴向约定,并把结论写进交付说明',
|
|
100
|
+
blocks: ['write', 'apply_patch'],
|
|
101
|
+
evidence: { requireUrl: true, minQuote: 40 },
|
|
102
|
+
}],
|
|
103
|
+
redlines: ['导出前必须检查法线与单位', '轴向约定要写进交付说明'],
|
|
104
|
+
sources: [{ title: 'Blender Manual: glTF 2.0 export' }],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
domain_id: 'project',
|
|
108
|
+
name: '工程与项目',
|
|
109
|
+
index_text: '工程类任务:改动前先读仓库约定(AGENTS.md / 提交规范),一个逻辑改动一个提交,'
|
|
110
|
+
+ '提交信息写清“为什么”。跨模块改动先确认调用方,不要顺手重构。',
|
|
111
|
+
detail_text: [
|
|
112
|
+
'## 约定',
|
|
113
|
+
'- 提交前缀:feat / fix / docs / test / chore。',
|
|
114
|
+
'- 一个逻辑改动一个提交;临时脚本只放 TEMP,不入库。',
|
|
115
|
+
'- 改公共接口前先 grep 调用方;不确定就先问。',
|
|
116
|
+
'- 测试不进 CI 前先本地跑通,别把“跑不了”写进交付说明。',
|
|
117
|
+
].join('\n'),
|
|
118
|
+
signals: {
|
|
119
|
+
keywords: ['接口', '部署', '迁移', '重构', '提交', '测试'],
|
|
120
|
+
pathGlobs: ['src', 'api', 'lib', 'packages'],
|
|
121
|
+
fileMarkers: ['package.json', 'AGENTS.md', 'Cargo.toml', 'pyproject.toml'],
|
|
122
|
+
deps: ['express', 'fastify', 'react', 'vue'],
|
|
123
|
+
},
|
|
124
|
+
redlines: ['不要 force push', '不要在没有调用方清单时改公共接口'],
|
|
125
|
+
sources: [{ title: '仓库 AGENTS.md 与既有提交规范' }],
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
function parseArgs(argv) {
|
|
130
|
+
const out = { apply: false, force: false, dbPath: DEFAULT_DB_PATH }
|
|
131
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
132
|
+
if (argv[i] === '--apply') out.apply = true
|
|
133
|
+
else if (argv[i] === '--force') out.force = true
|
|
134
|
+
else if (argv[i] === '--db') out.dbPath = argv[++i]
|
|
135
|
+
}
|
|
136
|
+
return out
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const args = parseArgs(process.argv.slice(2))
|
|
140
|
+
|
|
141
|
+
if (!existsSync(args.dbPath)) {
|
|
142
|
+
console.error(`store does not exist: ${args.dbPath}`)
|
|
143
|
+
console.error('start the plugin once (or point --db at a database) before seeding drafts.')
|
|
144
|
+
process.exit(1)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const store = new CoreStore(args.dbPath)
|
|
148
|
+
try {
|
|
149
|
+
const existing = new Set(listDomains(store, { status: 'all' }).map((domain) => domain.domainId))
|
|
150
|
+
for (const pack of PACKS) {
|
|
151
|
+
const skip = existing.has(pack.domain_id) && !args.force
|
|
152
|
+
const state = skip ? 'exists (skipped)' : (args.apply ? 'draft written' : 'would write draft')
|
|
153
|
+
if (args.apply && !skip) {
|
|
154
|
+
// `status: 'draft'` is load-bearing: seeding must not approve anything.
|
|
155
|
+
const out = upsertDomain(store, { ...pack, status: 'draft' }, { proposer: 'script' })
|
|
156
|
+
if (!out.ok) {
|
|
157
|
+
console.error(`${pack.domain_id}: ${out.error}`)
|
|
158
|
+
continue
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
console.log(`${pack.domain_id.padEnd(10)} ${state} signals: ${Object.keys(pack.signals).join('+')}`)
|
|
162
|
+
}
|
|
163
|
+
console.log('')
|
|
164
|
+
console.log('approve one after reading it:')
|
|
165
|
+
console.log(' curl -X POST http://127.0.0.1:<port>/memvault/api/domain \\')
|
|
166
|
+
console.log(' -H "content-type: application/json" \\')
|
|
167
|
+
console.log(' -d \'{"action":"status","domain_id":"game","status":"active"}\'')
|
|
168
|
+
console.log('or use the 进化 tab in the MemVault panel.')
|
|
169
|
+
} finally {
|
|
170
|
+
store.close()
|
|
171
|
+
}
|