@hongmaple0820/scale-engine 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 +15 -0
- package/README.md +64 -0
- package/dist/adapters/ClaudeCodeAdapter.d.ts +48 -0
- package/dist/adapters/ClaudeCodeAdapter.js +188 -0
- package/dist/adapters/ClaudeCodeAdapter.js.map +1 -0
- package/dist/adapters/CodexAdapter.d.ts +14 -0
- package/dist/adapters/CodexAdapter.js +153 -0
- package/dist/adapters/CodexAdapter.js.map +1 -0
- package/dist/api/cli.d.ts +2 -0
- package/dist/api/cli.js +396 -0
- package/dist/api/cli.js.map +1 -0
- package/dist/api/doctor.d.ts +28 -0
- package/dist/api/doctor.js +182 -0
- package/dist/api/doctor.js.map +1 -0
- package/dist/api/mcp.d.ts +32 -0
- package/dist/api/mcp.js +227 -0
- package/dist/api/mcp.js.map +1 -0
- package/dist/artifact/fsm.d.ts +36 -0
- package/dist/artifact/fsm.js +199 -0
- package/dist/artifact/fsm.js.map +1 -0
- package/dist/artifact/fsmDefinitions.d.ts +18 -0
- package/dist/artifact/fsmDefinitions.js +243 -0
- package/dist/artifact/fsmDefinitions.js.map +1 -0
- package/dist/artifact/sqliteStore.d.ts +61 -0
- package/dist/artifact/sqliteStore.js +394 -0
- package/dist/artifact/sqliteStore.js.map +1 -0
- package/dist/artifact/store.d.ts +49 -0
- package/dist/artifact/store.js +118 -0
- package/dist/artifact/store.js.map +1 -0
- package/dist/artifact/types.d.ts +333 -0
- package/dist/artifact/types.js +50 -0
- package/dist/artifact/types.js.map +1 -0
- package/dist/context/ContextBuilder.d.ts +36 -0
- package/dist/context/ContextBuilder.js +53 -0
- package/dist/context/ContextBuilder.js.map +1 -0
- package/dist/core/container.d.ts +14 -0
- package/dist/core/container.js +33 -0
- package/dist/core/container.js.map +1 -0
- package/dist/core/eventBus.d.ts +60 -0
- package/dist/core/eventBus.js +158 -0
- package/dist/core/eventBus.js.map +1 -0
- package/dist/core/logger.d.ts +3 -0
- package/dist/core/logger.js +12 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/evolution/BehaviorTracker.d.ts +38 -0
- package/dist/evolution/BehaviorTracker.js +52 -0
- package/dist/evolution/BehaviorTracker.js.map +1 -0
- package/dist/evolution/EvolutionEngine.d.ts +99 -0
- package/dist/evolution/EvolutionEngine.js +321 -0
- package/dist/evolution/EvolutionEngine.js.map +1 -0
- package/dist/guardrails/Gateway.d.ts +26 -0
- package/dist/guardrails/Gateway.js +57 -0
- package/dist/guardrails/Gateway.js.map +1 -0
- package/dist/guardrails/advancedDetectors.d.ts +26 -0
- package/dist/guardrails/advancedDetectors.js +138 -0
- package/dist/guardrails/advancedDetectors.js.map +1 -0
- package/dist/guardrails/detectors.d.ts +25 -0
- package/dist/guardrails/detectors.js +170 -0
- package/dist/guardrails/detectors.js.map +1 -0
- package/dist/guardrails/roles.d.ts +4 -0
- package/dist/guardrails/roles.js +54 -0
- package/dist/guardrails/roles.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/KnowledgeBase.d.ts +25 -0
- package/dist/knowledge/KnowledgeBase.js +81 -0
- package/dist/knowledge/KnowledgeBase.js.map +1 -0
- package/dist/orchestration/EffectsWiring.d.ts +8 -0
- package/dist/orchestration/EffectsWiring.js +87 -0
- package/dist/orchestration/EffectsWiring.js.map +1 -0
- package/dist/routing/ModelRouter.d.ts +30 -0
- package/dist/routing/ModelRouter.js +69 -0
- package/dist/routing/ModelRouter.js.map +1 -0
- package/dist/tasks/TaskEngine.d.ts +97 -0
- package/dist/tasks/TaskEngine.js +269 -0
- package/dist/tasks/TaskEngine.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCALE Engine — SQLite Artifact Store (W3)
|
|
3
|
+
*
|
|
4
|
+
* 替代 InMemoryArtifactStore,提供持久化存储。
|
|
5
|
+
* 设计参考:docs/02-DATA-MODEL.md §四、docs/03-CORE-MODULES.md §3.2
|
|
6
|
+
*
|
|
7
|
+
* 特性:
|
|
8
|
+
* - SQLite WAL 模式(读写并发安全)
|
|
9
|
+
* - JSON 序列化 payload/gates/statusHistory/parents/children/tags/labels
|
|
10
|
+
* - 事件自动落入 events 表
|
|
11
|
+
* - 完整 CRUD + query + findChildren + findParents
|
|
12
|
+
*/
|
|
13
|
+
import Database from 'better-sqlite3';
|
|
14
|
+
import { ArtifactNotFoundError } from './types.js';
|
|
15
|
+
import { mkdirSync, existsSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { dirname, join } from 'node:path';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Schema DDL
|
|
19
|
+
// ============================================================================
|
|
20
|
+
const SCHEMA_DDL = `
|
|
21
|
+
-- Artifacts 主表
|
|
22
|
+
CREATE TABLE IF NOT EXISTS artifacts (
|
|
23
|
+
id TEXT PRIMARY KEY,
|
|
24
|
+
type TEXT NOT NULL,
|
|
25
|
+
version INTEGER NOT NULL DEFAULT 1,
|
|
26
|
+
status TEXT NOT NULL DEFAULT 'DRAFT',
|
|
27
|
+
status_history TEXT NOT NULL DEFAULT '[]', -- JSON array of StatusChange
|
|
28
|
+
parents TEXT NOT NULL DEFAULT '[]', -- JSON array of ArtifactId
|
|
29
|
+
children TEXT NOT NULL DEFAULT '[]', -- JSON array of ArtifactId
|
|
30
|
+
supersedes TEXT,
|
|
31
|
+
title TEXT NOT NULL,
|
|
32
|
+
content_ref TEXT NOT NULL DEFAULT '',
|
|
33
|
+
payload TEXT NOT NULL DEFAULT '{}', -- JSON
|
|
34
|
+
gates TEXT NOT NULL DEFAULT '[]', -- JSON array of Gate
|
|
35
|
+
created_by TEXT NOT NULL DEFAULT '{}', -- JSON Actor
|
|
36
|
+
created_at INTEGER NOT NULL,
|
|
37
|
+
updated_at INTEGER NOT NULL,
|
|
38
|
+
closed_at INTEGER,
|
|
39
|
+
tags TEXT NOT NULL DEFAULT '[]', -- JSON array
|
|
40
|
+
labels TEXT NOT NULL DEFAULT '{}' -- JSON object
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
CREATE INDEX IF NOT EXISTS idx_artifacts_type ON artifacts(type);
|
|
44
|
+
CREATE INDEX IF NOT EXISTS idx_artifacts_status ON artifacts(status);
|
|
45
|
+
CREATE INDEX IF NOT EXISTS idx_artifacts_created_at ON artifacts(created_at);
|
|
46
|
+
|
|
47
|
+
-- Events 表(事件溯源的持久化副本)
|
|
48
|
+
CREATE TABLE IF NOT EXISTS events (
|
|
49
|
+
id TEXT PRIMARY KEY,
|
|
50
|
+
type TEXT NOT NULL,
|
|
51
|
+
timestamp INTEGER NOT NULL,
|
|
52
|
+
session_id TEXT,
|
|
53
|
+
artifact_id TEXT,
|
|
54
|
+
actor TEXT DEFAULT '{}',
|
|
55
|
+
payload TEXT NOT NULL DEFAULT '{}',
|
|
56
|
+
metadata TEXT DEFAULT '{}'
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_events_type ON events(type);
|
|
60
|
+
CREATE INDEX IF NOT EXISTS idx_events_artifact_id ON events(artifact_id);
|
|
61
|
+
CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
|
|
62
|
+
|
|
63
|
+
-- Artifact 关系边表(加速 parent/child 查询)
|
|
64
|
+
CREATE TABLE IF NOT EXISTS artifact_edges (
|
|
65
|
+
parent_id TEXT NOT NULL,
|
|
66
|
+
child_id TEXT NOT NULL,
|
|
67
|
+
PRIMARY KEY (parent_id, child_id)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
CREATE INDEX IF NOT EXISTS idx_edges_parent ON artifact_edges(parent_id);
|
|
71
|
+
CREATE INDEX IF NOT EXISTS idx_edges_child ON artifact_edges(child_id);
|
|
72
|
+
|
|
73
|
+
-- 元信息表
|
|
74
|
+
CREATE TABLE IF NOT EXISTS meta (
|
|
75
|
+
key TEXT PRIMARY KEY,
|
|
76
|
+
value TEXT NOT NULL
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
-- 初始化 schema version
|
|
80
|
+
INSERT OR IGNORE INTO meta (key, value) VALUES ('schema_version', '1');
|
|
81
|
+
`;
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// SQLiteArtifactStore
|
|
84
|
+
// ============================================================================
|
|
85
|
+
export class SQLiteArtifactStore {
|
|
86
|
+
eventBus;
|
|
87
|
+
db;
|
|
88
|
+
seq = 0;
|
|
89
|
+
artifactsDir;
|
|
90
|
+
// Prepared statements (性能优化)
|
|
91
|
+
stmtInsert;
|
|
92
|
+
stmtGet;
|
|
93
|
+
stmtUpdate;
|
|
94
|
+
stmtDelete;
|
|
95
|
+
stmtInsertEdge;
|
|
96
|
+
stmtDeleteEdges;
|
|
97
|
+
stmtFindChildren;
|
|
98
|
+
stmtFindParents;
|
|
99
|
+
stmtInsertEvent;
|
|
100
|
+
constructor(eventBus, opts = {}) {
|
|
101
|
+
this.eventBus = eventBus;
|
|
102
|
+
const dbPath = opts.dbPath ?? '.scale/scale.db';
|
|
103
|
+
this.artifactsDir = opts.artifactsDir ?? '.scale/artifacts';
|
|
104
|
+
// 确保目录存在
|
|
105
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
106
|
+
if (!existsSync(this.artifactsDir))
|
|
107
|
+
mkdirSync(this.artifactsDir, { recursive: true });
|
|
108
|
+
// 创建 DB
|
|
109
|
+
this.db = new Database(dbPath);
|
|
110
|
+
this.db.pragma('journal_mode = WAL');
|
|
111
|
+
this.db.pragma('foreign_keys = ON');
|
|
112
|
+
this.db.pragma('busy_timeout = 5000');
|
|
113
|
+
// 初始化 schema
|
|
114
|
+
this.db.exec(SCHEMA_DDL);
|
|
115
|
+
// 准备 statements
|
|
116
|
+
this.prepareStatements();
|
|
117
|
+
// 恢复 seq
|
|
118
|
+
const maxRow = this.db.prepare(`SELECT id FROM artifacts ORDER BY created_at DESC LIMIT 1`).get();
|
|
119
|
+
if (maxRow) {
|
|
120
|
+
const parts = maxRow.id.split('-');
|
|
121
|
+
this.seq = parseInt(parts[parts.length - 1], 10) || 0;
|
|
122
|
+
}
|
|
123
|
+
// 订阅 EventBus 事件 → 自动写入 events 表
|
|
124
|
+
this.eventBus.on('*', (event) => {
|
|
125
|
+
try {
|
|
126
|
+
this.stmtInsertEvent.run(event.id, event.type, event.timestamp, event.sessionId ?? null, event.artifactId ?? null, JSON.stringify(event.actor ?? {}), JSON.stringify(event.payload ?? {}), JSON.stringify({}));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// 容忍写入失败(避免循环依赖阻塞)
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
prepareStatements() {
|
|
134
|
+
this.stmtInsert = this.db.prepare(`
|
|
135
|
+
INSERT INTO artifacts (id, type, version, status, status_history, parents, children, supersedes,
|
|
136
|
+
title, content_ref, payload, gates, created_by, created_at, updated_at, closed_at, tags, labels)
|
|
137
|
+
VALUES (@id, @type, @version, @status, @statusHistory, @parents, @children, @supersedes,
|
|
138
|
+
@title, @contentRef, @payload, @gates, @createdBy, @createdAt, @updatedAt, @closedAt, @tags, @labels)
|
|
139
|
+
`);
|
|
140
|
+
this.stmtGet = this.db.prepare(`SELECT * FROM artifacts WHERE id = ?`);
|
|
141
|
+
this.stmtUpdate = this.db.prepare(`
|
|
142
|
+
UPDATE artifacts SET
|
|
143
|
+
version = @version, status = @status, status_history = @statusHistory,
|
|
144
|
+
parents = @parents, children = @children, supersedes = @supersedes,
|
|
145
|
+
title = @title, content_ref = @contentRef, payload = @payload,
|
|
146
|
+
gates = @gates, updated_at = @updatedAt, closed_at = @closedAt,
|
|
147
|
+
tags = @tags, labels = @labels
|
|
148
|
+
WHERE id = @id
|
|
149
|
+
`);
|
|
150
|
+
this.stmtDelete = this.db.prepare(`DELETE FROM artifacts WHERE id = ?`);
|
|
151
|
+
this.stmtInsertEdge = this.db.prepare(`INSERT OR IGNORE INTO artifact_edges (parent_id, child_id) VALUES (?, ?)`);
|
|
152
|
+
this.stmtDeleteEdges = this.db.prepare(`DELETE FROM artifact_edges WHERE child_id = ?`);
|
|
153
|
+
this.stmtFindChildren = this.db.prepare(`
|
|
154
|
+
SELECT a.* FROM artifacts a
|
|
155
|
+
INNER JOIN artifact_edges e ON a.id = e.child_id
|
|
156
|
+
WHERE e.parent_id = ?
|
|
157
|
+
`);
|
|
158
|
+
this.stmtFindParents = this.db.prepare(`
|
|
159
|
+
SELECT a.* FROM artifacts a
|
|
160
|
+
INNER JOIN artifact_edges e ON a.id = e.parent_id
|
|
161
|
+
WHERE e.child_id = ?
|
|
162
|
+
`);
|
|
163
|
+
this.stmtInsertEvent = this.db.prepare(`
|
|
164
|
+
INSERT OR IGNORE INTO events (id, type, timestamp, session_id, artifact_id, actor, payload, metadata)
|
|
165
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
166
|
+
`);
|
|
167
|
+
}
|
|
168
|
+
// ===== CRUD =====
|
|
169
|
+
async create(input) {
|
|
170
|
+
const id = this.generateId(input.type);
|
|
171
|
+
const contentRef = this.contentPath(input.type, id);
|
|
172
|
+
if (input.contentBody) {
|
|
173
|
+
mkdirSync(dirname(contentRef), { recursive: true });
|
|
174
|
+
writeFileSync(contentRef, input.contentBody, 'utf-8');
|
|
175
|
+
}
|
|
176
|
+
const artifact = {
|
|
177
|
+
id,
|
|
178
|
+
type: input.type,
|
|
179
|
+
version: 1,
|
|
180
|
+
status: input.initialStatus ?? 'DRAFT',
|
|
181
|
+
statusHistory: [],
|
|
182
|
+
parents: input.parents ?? [],
|
|
183
|
+
children: [],
|
|
184
|
+
title: input.title,
|
|
185
|
+
contentRef,
|
|
186
|
+
payload: input.payload,
|
|
187
|
+
gates: [],
|
|
188
|
+
createdBy: input.createdBy ?? { kind: 'system', component: 'CLI' },
|
|
189
|
+
createdAt: Date.now(),
|
|
190
|
+
updatedAt: Date.now(),
|
|
191
|
+
tags: input.tags ?? [],
|
|
192
|
+
labels: input.labels ?? {},
|
|
193
|
+
};
|
|
194
|
+
const insertAll = this.db.transaction(() => {
|
|
195
|
+
this.stmtInsert.run(this.toRow(artifact));
|
|
196
|
+
// 写入边表
|
|
197
|
+
for (const parentId of artifact.parents) {
|
|
198
|
+
this.stmtInsertEdge.run(parentId, id);
|
|
199
|
+
// 更新父的 children 字段
|
|
200
|
+
const parentRow = this.stmtGet.get(parentId);
|
|
201
|
+
if (parentRow) {
|
|
202
|
+
const parentChildren = JSON.parse(parentRow.children);
|
|
203
|
+
if (!parentChildren.includes(id)) {
|
|
204
|
+
parentChildren.push(id);
|
|
205
|
+
this.db.prepare(`UPDATE artifacts SET children = ? WHERE id = ?`).run(JSON.stringify(parentChildren), parentId);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
insertAll();
|
|
211
|
+
this.eventBus.emit('artifact.created', { id, type: input.type, title: input.title }, { artifactId: id, actor: artifact.createdBy });
|
|
212
|
+
return artifact;
|
|
213
|
+
}
|
|
214
|
+
async get(id) {
|
|
215
|
+
const row = this.stmtGet.get(id);
|
|
216
|
+
return row ? this.fromRow(row) : null;
|
|
217
|
+
}
|
|
218
|
+
async update(id, updates) {
|
|
219
|
+
const existing = await this.get(id);
|
|
220
|
+
if (!existing)
|
|
221
|
+
throw new ArtifactNotFoundError(id);
|
|
222
|
+
const updated = {
|
|
223
|
+
...existing,
|
|
224
|
+
...updates,
|
|
225
|
+
id, // 不允许改 id
|
|
226
|
+
type: existing.type, // 不允许改 type
|
|
227
|
+
version: existing.version + 1,
|
|
228
|
+
updatedAt: Date.now(),
|
|
229
|
+
};
|
|
230
|
+
this.stmtUpdate.run(this.toRow(updated));
|
|
231
|
+
this.eventBus.emit('artifact.updated', { id, fields: Object.keys(updates) }, { artifactId: id });
|
|
232
|
+
return updated;
|
|
233
|
+
}
|
|
234
|
+
async delete(id) {
|
|
235
|
+
const existing = await this.get(id);
|
|
236
|
+
if (!existing)
|
|
237
|
+
throw new ArtifactNotFoundError(id);
|
|
238
|
+
const deleteAll = this.db.transaction(() => {
|
|
239
|
+
this.stmtDeleteEdges.run(id);
|
|
240
|
+
this.stmtDelete.run(id);
|
|
241
|
+
});
|
|
242
|
+
deleteAll();
|
|
243
|
+
this.eventBus.emit('artifact.deleted', { id }, { artifactId: id });
|
|
244
|
+
}
|
|
245
|
+
async query(filter) {
|
|
246
|
+
const conditions = ['1=1'];
|
|
247
|
+
const params = [];
|
|
248
|
+
if (filter.type) {
|
|
249
|
+
const types = Array.isArray(filter.type) ? filter.type : [filter.type];
|
|
250
|
+
conditions.push(`type IN (${types.map(() => '?').join(',')})`);
|
|
251
|
+
params.push(...types);
|
|
252
|
+
}
|
|
253
|
+
if (filter.status) {
|
|
254
|
+
const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
255
|
+
conditions.push(`status IN (${statuses.map(() => '?').join(',')})`);
|
|
256
|
+
params.push(...statuses);
|
|
257
|
+
}
|
|
258
|
+
if (filter.tags && filter.tags.length > 0) {
|
|
259
|
+
// JSON 包含检查:每个 tag 都必须在 tags JSON 数组中
|
|
260
|
+
for (const tag of filter.tags) {
|
|
261
|
+
conditions.push(`tags LIKE ?`);
|
|
262
|
+
params.push(`%"${tag}"%`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (filter.parentId) {
|
|
266
|
+
conditions.push(`id IN (SELECT child_id FROM artifact_edges WHERE parent_id = ?)`);
|
|
267
|
+
params.push(filter.parentId);
|
|
268
|
+
}
|
|
269
|
+
let sql = `SELECT * FROM artifacts WHERE ${conditions.join(' AND ')} ORDER BY created_at DESC`;
|
|
270
|
+
if (filter.limit) {
|
|
271
|
+
sql += ` LIMIT ?`;
|
|
272
|
+
params.push(filter.limit);
|
|
273
|
+
}
|
|
274
|
+
const rows = this.db.prepare(sql).all(...params);
|
|
275
|
+
return rows.map((r) => this.fromRow(r));
|
|
276
|
+
}
|
|
277
|
+
async findChildren(parentId, type) {
|
|
278
|
+
if (type) {
|
|
279
|
+
const rows = this.db.prepare(`
|
|
280
|
+
SELECT a.* FROM artifacts a
|
|
281
|
+
INNER JOIN artifact_edges e ON a.id = e.child_id
|
|
282
|
+
WHERE e.parent_id = ? AND a.type = ?
|
|
283
|
+
`).all(parentId, type);
|
|
284
|
+
return rows.map((r) => this.fromRow(r));
|
|
285
|
+
}
|
|
286
|
+
const rows = this.stmtFindChildren.all(parentId);
|
|
287
|
+
return rows.map((r) => this.fromRow(r));
|
|
288
|
+
}
|
|
289
|
+
async findParents(childId) {
|
|
290
|
+
const rows = this.stmtFindParents.all(childId);
|
|
291
|
+
return rows.map((r) => this.fromRow(r));
|
|
292
|
+
}
|
|
293
|
+
async setGate(artifactId, gate) {
|
|
294
|
+
const artifact = await this.get(artifactId);
|
|
295
|
+
if (!artifact)
|
|
296
|
+
throw new ArtifactNotFoundError(artifactId);
|
|
297
|
+
const idx = artifact.gates.findIndex((g) => g.name === gate.name);
|
|
298
|
+
if (idx >= 0)
|
|
299
|
+
artifact.gates[idx] = gate;
|
|
300
|
+
else
|
|
301
|
+
artifact.gates.push(gate);
|
|
302
|
+
this.db.prepare(`UPDATE artifacts SET gates = ?, updated_at = ? WHERE id = ?`)
|
|
303
|
+
.run(JSON.stringify(artifact.gates), Date.now(), artifactId);
|
|
304
|
+
this.eventBus.emit('artifact.gate_checked', { artifactId, gate }, { artifactId });
|
|
305
|
+
}
|
|
306
|
+
// ===== 额外方法 =====
|
|
307
|
+
/** 查询事件(从 events 表) */
|
|
308
|
+
queryEvents(opts = {}) {
|
|
309
|
+
const conditions = ['1=1'];
|
|
310
|
+
const params = [];
|
|
311
|
+
if (opts.artifactId) {
|
|
312
|
+
conditions.push('artifact_id = ?');
|
|
313
|
+
params.push(opts.artifactId);
|
|
314
|
+
}
|
|
315
|
+
if (opts.type) {
|
|
316
|
+
conditions.push('type = ?');
|
|
317
|
+
params.push(opts.type);
|
|
318
|
+
}
|
|
319
|
+
let sql = `SELECT * FROM events WHERE ${conditions.join(' AND ')} ORDER BY timestamp DESC`;
|
|
320
|
+
if (opts.limit) {
|
|
321
|
+
sql += ` LIMIT ?`;
|
|
322
|
+
params.push(opts.limit);
|
|
323
|
+
}
|
|
324
|
+
return this.db.prepare(sql).all(...params);
|
|
325
|
+
}
|
|
326
|
+
/** 获取统计信息 */
|
|
327
|
+
stats() {
|
|
328
|
+
const artifactCount = this.db.prepare('SELECT COUNT(*) as c FROM artifacts').get().c;
|
|
329
|
+
const eventCount = this.db.prepare('SELECT COUNT(*) as c FROM events').get().c;
|
|
330
|
+
const rows = this.db.prepare('SELECT type, COUNT(*) as c FROM artifacts GROUP BY type').all();
|
|
331
|
+
const byType = {};
|
|
332
|
+
for (const r of rows)
|
|
333
|
+
byType[r.type] = r.c;
|
|
334
|
+
return { artifactCount, eventCount, byType };
|
|
335
|
+
}
|
|
336
|
+
/** 关闭数据库连接 */
|
|
337
|
+
close() {
|
|
338
|
+
this.db.close();
|
|
339
|
+
}
|
|
340
|
+
// ===== 内部 =====
|
|
341
|
+
generateId(type) {
|
|
342
|
+
const date = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
|
343
|
+
this.seq = (this.seq + 1) % 10000;
|
|
344
|
+
return `${type.toUpperCase()}-${date}-${this.seq.toString().padStart(4, '0')}`;
|
|
345
|
+
}
|
|
346
|
+
contentPath(type, id) {
|
|
347
|
+
return join(this.artifactsDir, type.toLowerCase(), `${id}.md`);
|
|
348
|
+
}
|
|
349
|
+
toRow(a) {
|
|
350
|
+
return {
|
|
351
|
+
id: a.id,
|
|
352
|
+
type: a.type,
|
|
353
|
+
version: a.version,
|
|
354
|
+
status: a.status,
|
|
355
|
+
statusHistory: JSON.stringify(a.statusHistory),
|
|
356
|
+
parents: JSON.stringify(a.parents),
|
|
357
|
+
children: JSON.stringify(a.children),
|
|
358
|
+
supersedes: a.supersedes ?? null,
|
|
359
|
+
title: a.title,
|
|
360
|
+
contentRef: a.contentRef,
|
|
361
|
+
payload: JSON.stringify(a.payload),
|
|
362
|
+
gates: JSON.stringify(a.gates),
|
|
363
|
+
createdBy: JSON.stringify(a.createdBy),
|
|
364
|
+
createdAt: a.createdAt,
|
|
365
|
+
updatedAt: a.updatedAt,
|
|
366
|
+
closedAt: a.closedAt ?? null,
|
|
367
|
+
tags: JSON.stringify(a.tags),
|
|
368
|
+
labels: JSON.stringify(a.labels),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
fromRow(row) {
|
|
372
|
+
return {
|
|
373
|
+
id: row.id,
|
|
374
|
+
type: row.type,
|
|
375
|
+
version: row.version,
|
|
376
|
+
status: row.status,
|
|
377
|
+
statusHistory: JSON.parse(row.status_history),
|
|
378
|
+
parents: JSON.parse(row.parents),
|
|
379
|
+
children: JSON.parse(row.children),
|
|
380
|
+
supersedes: row.supersedes ?? undefined,
|
|
381
|
+
title: row.title,
|
|
382
|
+
contentRef: row.content_ref,
|
|
383
|
+
payload: JSON.parse(row.payload),
|
|
384
|
+
gates: JSON.parse(row.gates),
|
|
385
|
+
createdBy: JSON.parse(row.created_by),
|
|
386
|
+
createdAt: row.created_at,
|
|
387
|
+
updatedAt: row.updated_at,
|
|
388
|
+
closedAt: row.closed_at ?? undefined,
|
|
389
|
+
tags: JSON.parse(row.tags),
|
|
390
|
+
labels: JSON.parse(row.labels),
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=sqliteStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqliteStore.js","sourceRoot":"","sources":["../../src/artifact/sqliteStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAA;AAErC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAGlD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MA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,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAmB;YAC/D,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAiB;YAChD,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAiB;YAClD,UAAU,EAAE,GAAG,CAAC,UAAU,IAAI,SAAS;YACvC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,UAAU,EAAE,GAAG,CAAC,WAAW;YAC3B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YAChC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAW;YACtC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAU;YAC9C,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,QAAQ,EAAE,GAAG,CAAC,SAAS,IAAI,SAAS;YACpC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAa;YACtC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAA2B;SACzD,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Artifact, ArtifactType, Gate, ArtifactId } from './types.js';
|
|
2
|
+
import type { IEventBus } from '../core/eventBus.js';
|
|
3
|
+
export interface CreateArtifactInput {
|
|
4
|
+
type: ArtifactType;
|
|
5
|
+
title: string;
|
|
6
|
+
payload: unknown;
|
|
7
|
+
parents?: ArtifactId[];
|
|
8
|
+
tags?: string[];
|
|
9
|
+
labels?: Record<string, string>;
|
|
10
|
+
createdBy?: import('./types.js').Actor;
|
|
11
|
+
initialStatus?: string;
|
|
12
|
+
contentBody?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ArtifactFilter {
|
|
15
|
+
type?: ArtifactType | ArtifactType[];
|
|
16
|
+
status?: string | string[];
|
|
17
|
+
tags?: string[];
|
|
18
|
+
parentId?: ArtifactId;
|
|
19
|
+
limit?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface IArtifactStore {
|
|
22
|
+
create(input: CreateArtifactInput): Promise<Artifact>;
|
|
23
|
+
get(id: ArtifactId): Promise<Artifact | null>;
|
|
24
|
+
update(id: ArtifactId, updates: Partial<Artifact>): Promise<Artifact>;
|
|
25
|
+
delete(id: ArtifactId): Promise<void>;
|
|
26
|
+
query(filter: ArtifactFilter): Promise<Artifact[]>;
|
|
27
|
+
findChildren(parentId: ArtifactId, type?: ArtifactType): Promise<Artifact[]>;
|
|
28
|
+
findParents(childId: ArtifactId): Promise<Artifact[]>;
|
|
29
|
+
setGate(artifactId: ArtifactId, gate: Gate): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare class InMemoryArtifactStore implements IArtifactStore {
|
|
32
|
+
private eventBus;
|
|
33
|
+
private artifacts;
|
|
34
|
+
private artifactsDir;
|
|
35
|
+
private seq;
|
|
36
|
+
constructor(eventBus: IEventBus, opts?: {
|
|
37
|
+
artifactsDir?: string;
|
|
38
|
+
});
|
|
39
|
+
create(input: CreateArtifactInput): Promise<Artifact>;
|
|
40
|
+
get(id: ArtifactId): Promise<Artifact | null>;
|
|
41
|
+
update(id: ArtifactId, updates: Partial<Artifact>): Promise<Artifact>;
|
|
42
|
+
delete(id: ArtifactId): Promise<void>;
|
|
43
|
+
query(filter: ArtifactFilter): Promise<Artifact[]>;
|
|
44
|
+
findChildren(parentId: ArtifactId, type?: ArtifactType): Promise<Artifact[]>;
|
|
45
|
+
findParents(childId: ArtifactId): Promise<Artifact[]>;
|
|
46
|
+
setGate(artifactId: ArtifactId, gate: Gate): Promise<void>;
|
|
47
|
+
private generateId;
|
|
48
|
+
private contentPath;
|
|
49
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// SCALE Engine — Artifact Store (内存版骨架, W3 升级 SQLite)
|
|
2
|
+
// 设计参考:docs/03-CORE-MODULES.md §3.2
|
|
3
|
+
import { ArtifactNotFoundError } from './types.js';
|
|
4
|
+
import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
5
|
+
import { join, dirname } from 'node:path';
|
|
6
|
+
export class InMemoryArtifactStore {
|
|
7
|
+
eventBus;
|
|
8
|
+
artifacts = new Map();
|
|
9
|
+
artifactsDir;
|
|
10
|
+
seq = 0;
|
|
11
|
+
constructor(eventBus, opts = {}) {
|
|
12
|
+
this.eventBus = eventBus;
|
|
13
|
+
this.artifactsDir = opts.artifactsDir ?? '.scale/artifacts';
|
|
14
|
+
if (!existsSync(this.artifactsDir))
|
|
15
|
+
mkdirSync(this.artifactsDir, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
async create(input) {
|
|
18
|
+
const id = this.generateId(input.type);
|
|
19
|
+
const contentRef = this.contentPath(input.type, id);
|
|
20
|
+
if (input.contentBody) {
|
|
21
|
+
mkdirSync(dirname(contentRef), { recursive: true });
|
|
22
|
+
writeFileSync(contentRef, input.contentBody, 'utf-8');
|
|
23
|
+
}
|
|
24
|
+
const artifact = {
|
|
25
|
+
id, type: input.type, version: 1,
|
|
26
|
+
status: input.initialStatus ?? 'DRAFT',
|
|
27
|
+
statusHistory: [],
|
|
28
|
+
parents: input.parents ?? [],
|
|
29
|
+
children: [],
|
|
30
|
+
title: input.title,
|
|
31
|
+
contentRef,
|
|
32
|
+
payload: input.payload,
|
|
33
|
+
gates: [],
|
|
34
|
+
createdBy: input.createdBy ?? { kind: 'system', component: 'CLI' },
|
|
35
|
+
createdAt: Date.now(),
|
|
36
|
+
updatedAt: Date.now(),
|
|
37
|
+
tags: input.tags ?? [],
|
|
38
|
+
labels: input.labels ?? {},
|
|
39
|
+
};
|
|
40
|
+
this.artifacts.set(id, artifact);
|
|
41
|
+
// 更新父 artifacts 的 children
|
|
42
|
+
for (const parentId of artifact.parents) {
|
|
43
|
+
const parent = this.artifacts.get(parentId);
|
|
44
|
+
if (parent)
|
|
45
|
+
parent.children.push(id);
|
|
46
|
+
}
|
|
47
|
+
this.eventBus.emit('artifact.created', { id, type: input.type, title: input.title }, { artifactId: id, actor: artifact.createdBy });
|
|
48
|
+
return artifact;
|
|
49
|
+
}
|
|
50
|
+
async get(id) {
|
|
51
|
+
return this.artifacts.get(id) ?? null;
|
|
52
|
+
}
|
|
53
|
+
async update(id, updates) {
|
|
54
|
+
const existing = this.artifacts.get(id);
|
|
55
|
+
if (!existing)
|
|
56
|
+
throw new ArtifactNotFoundError(id);
|
|
57
|
+
const updated = { ...existing, ...updates, version: existing.version + 1, updatedAt: Date.now() };
|
|
58
|
+
this.artifacts.set(id, updated);
|
|
59
|
+
this.eventBus.emit('artifact.updated', { id, fields: Object.keys(updates) }, { artifactId: id });
|
|
60
|
+
return updated;
|
|
61
|
+
}
|
|
62
|
+
async delete(id) {
|
|
63
|
+
if (!this.artifacts.has(id))
|
|
64
|
+
throw new ArtifactNotFoundError(id);
|
|
65
|
+
this.artifacts.delete(id);
|
|
66
|
+
this.eventBus.emit('artifact.deleted', { id }, { artifactId: id });
|
|
67
|
+
}
|
|
68
|
+
async query(filter) {
|
|
69
|
+
let result = Array.from(this.artifacts.values());
|
|
70
|
+
if (filter.type) {
|
|
71
|
+
const types = Array.isArray(filter.type) ? filter.type : [filter.type];
|
|
72
|
+
result = result.filter((a) => types.includes(a.type));
|
|
73
|
+
}
|
|
74
|
+
if (filter.status) {
|
|
75
|
+
const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
76
|
+
result = result.filter((a) => statuses.includes(a.status));
|
|
77
|
+
}
|
|
78
|
+
if (filter.tags) {
|
|
79
|
+
result = result.filter((a) => filter.tags.every((t) => a.tags.includes(t)));
|
|
80
|
+
}
|
|
81
|
+
if (filter.parentId) {
|
|
82
|
+
result = result.filter((a) => a.parents.includes(filter.parentId));
|
|
83
|
+
}
|
|
84
|
+
if (filter.limit)
|
|
85
|
+
result = result.slice(0, filter.limit);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
async findChildren(parentId, type) {
|
|
89
|
+
return this.query({ parentId, type });
|
|
90
|
+
}
|
|
91
|
+
async findParents(childId) {
|
|
92
|
+
const child = this.artifacts.get(childId);
|
|
93
|
+
if (!child)
|
|
94
|
+
return [];
|
|
95
|
+
return child.parents.map((id) => this.artifacts.get(id)).filter(Boolean);
|
|
96
|
+
}
|
|
97
|
+
async setGate(artifactId, gate) {
|
|
98
|
+
const artifact = this.artifacts.get(artifactId);
|
|
99
|
+
if (!artifact)
|
|
100
|
+
throw new ArtifactNotFoundError(artifactId);
|
|
101
|
+
const idx = artifact.gates.findIndex((g) => g.name === gate.name);
|
|
102
|
+
if (idx >= 0)
|
|
103
|
+
artifact.gates[idx] = gate;
|
|
104
|
+
else
|
|
105
|
+
artifact.gates.push(gate);
|
|
106
|
+
this.eventBus.emit('artifact.gate_checked', { artifactId, gate }, { artifactId });
|
|
107
|
+
}
|
|
108
|
+
// ===== 内部 =====
|
|
109
|
+
generateId(type) {
|
|
110
|
+
const date = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
|
111
|
+
this.seq = (this.seq + 1) % 10000;
|
|
112
|
+
return `${type.toUpperCase()}-${date}-${this.seq.toString().padStart(4, '0')}`;
|
|
113
|
+
}
|
|
114
|
+
contentPath(type, id) {
|
|
115
|
+
return join(this.artifactsDir, type.toLowerCase(), `${id}.md`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/artifact/store.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,oCAAoC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,OAAO,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