fivocell 5.4.0 → 6.0.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/dist/__tests__/performance.test.d.ts +2 -0
- package/dist/__tests__/performance.test.d.ts.map +1 -0
- package/dist/__tests__/performance.test.js +78 -0
- package/dist/__tests__/performance.test.js.map +1 -0
- package/dist/__tests__/polish.test.d.ts +2 -0
- package/dist/__tests__/polish.test.d.ts.map +1 -0
- package/dist/__tests__/polish.test.js +95 -0
- package/dist/__tests__/polish.test.js.map +1 -0
- package/dist/walls/06-memory/database/batch-write.d.ts +15 -0
- package/dist/walls/06-memory/database/batch-write.d.ts.map +1 -0
- package/dist/walls/06-memory/database/batch-write.js +56 -0
- package/dist/walls/06-memory/database/batch-write.js.map +1 -0
- package/dist/walls/06-memory/database/database.d.ts.map +1 -1
- package/dist/walls/06-memory/database/database.js +13 -0
- package/dist/walls/06-memory/database/database.js.map +1 -1
- package/dist/walls/06-memory/database/migrations.d.ts +19 -0
- package/dist/walls/06-memory/database/migrations.d.ts.map +1 -0
- package/dist/walls/06-memory/database/migrations.js +78 -0
- package/dist/walls/06-memory/database/migrations.js.map +1 -0
- package/dist/walls/06-memory/database/query-cache.d.ts +13 -0
- package/dist/walls/06-memory/database/query-cache.d.ts.map +1 -0
- package/dist/walls/06-memory/database/query-cache.js +80 -0
- package/dist/walls/06-memory/database/query-cache.js.map +1 -0
- package/dist/walls/06-memory/database/validation.d.ts +12 -0
- package/dist/walls/06-memory/database/validation.d.ts.map +1 -0
- package/dist/walls/06-memory/database/validation.js +73 -0
- package/dist/walls/06-memory/database/validation.js.map +1 -0
- package/dist/walls/07-runtime/cli/cli.js +60 -0
- package/dist/walls/07-runtime/cli/cli.js.map +1 -1
- package/dist/walls/07-runtime/daemon/restart.d.ts +13 -0
- package/dist/walls/07-runtime/daemon/restart.d.ts.map +1 -0
- package/dist/walls/07-runtime/daemon/restart.js +47 -0
- package/dist/walls/07-runtime/daemon/restart.js.map +1 -0
- package/dist/walls/07-runtime/daemon/server.d.ts.map +1 -1
- package/dist/walls/07-runtime/daemon/server.js +27 -6
- package/dist/walls/07-runtime/daemon/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ValidationError {
|
|
2
|
+
field: string;
|
|
3
|
+
message: string;
|
|
4
|
+
value?: unknown;
|
|
5
|
+
}
|
|
6
|
+
export declare function validateEventType(type: string): string | null;
|
|
7
|
+
export declare function validateImportance(importance: number): string | null;
|
|
8
|
+
export declare function validateProjectName(name: string): string | null;
|
|
9
|
+
export declare function validateSummary(summary: string): string | null;
|
|
10
|
+
export declare function validateMemoryEvent(event: Record<string, unknown>): ValidationError[];
|
|
11
|
+
export declare function sanitizeString(input: string, maxLength?: number): string;
|
|
12
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/walls/06-memory/database/validation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASpE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK/D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI9D;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,EAAE,CAgBrF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,GAAG,MAAM,CAG9E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateEventType = validateEventType;
|
|
4
|
+
exports.validateImportance = validateImportance;
|
|
5
|
+
exports.validateProjectName = validateProjectName;
|
|
6
|
+
exports.validateSummary = validateSummary;
|
|
7
|
+
exports.validateMemoryEvent = validateMemoryEvent;
|
|
8
|
+
exports.sanitizeString = sanitizeString;
|
|
9
|
+
const VALID_EVENT_TYPES = [
|
|
10
|
+
'file_event', 'edit', 'decision', 'error', 'fix',
|
|
11
|
+
'verification', 'publish', 'handoff', 'pattern', 'style',
|
|
12
|
+
'session', 'branch', 'risk', 'question', 'ai_work',
|
|
13
|
+
];
|
|
14
|
+
const VALID_CI_STATUSES = ['success', 'failure', 'cancelled', 'failed', 'rolled_back'];
|
|
15
|
+
const VALID_MEMORY_IMPORTANCE = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
16
|
+
const VALID_SYNC_STRATEGIES = ['local-wins', 'remote-wins', 'importance', 'timestamp'];
|
|
17
|
+
function validateEventType(type) {
|
|
18
|
+
if (!type)
|
|
19
|
+
return 'Event type is required';
|
|
20
|
+
if (!VALID_EVENT_TYPES.includes(type)) {
|
|
21
|
+
return `Invalid event type: "${type}". Valid: ${VALID_EVENT_TYPES.join(', ')}`;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function validateImportance(importance) {
|
|
26
|
+
if (importance == null)
|
|
27
|
+
return null; // optional, defaults to 3
|
|
28
|
+
if (typeof importance !== 'number' || !Number.isInteger(importance)) {
|
|
29
|
+
return 'Importance must be an integer';
|
|
30
|
+
}
|
|
31
|
+
if (importance < 1 || importance > 10) {
|
|
32
|
+
return 'Importance must be between 1 and 10';
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function validateProjectName(name) {
|
|
37
|
+
if (!name || typeof name !== 'string')
|
|
38
|
+
return 'Project name is required';
|
|
39
|
+
if (name.length > 200)
|
|
40
|
+
return 'Project name must be 200 characters or less';
|
|
41
|
+
if (/[<>:"/\\|?*\x00-\x1f]/.test(name))
|
|
42
|
+
return 'Project name contains invalid characters';
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function validateSummary(summary) {
|
|
46
|
+
if (!summary || typeof summary !== 'string')
|
|
47
|
+
return 'Summary is required';
|
|
48
|
+
if (summary.length > 2000)
|
|
49
|
+
return 'Summary must be 2000 characters or less';
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function validateMemoryEvent(event) {
|
|
53
|
+
const errors = [];
|
|
54
|
+
const typeErr = validateEventType(event.type);
|
|
55
|
+
if (typeErr)
|
|
56
|
+
errors.push({ field: 'type', message: typeErr, value: event.type });
|
|
57
|
+
const projErr = validateProjectName(event.project);
|
|
58
|
+
if (projErr)
|
|
59
|
+
errors.push({ field: 'project', message: projErr, value: event.project });
|
|
60
|
+
const sumErr = validateSummary(event.summary);
|
|
61
|
+
if (sumErr)
|
|
62
|
+
errors.push({ field: 'summary', message: sumErr, value: event.summary });
|
|
63
|
+
const impErr = validateImportance(event.importance);
|
|
64
|
+
if (impErr)
|
|
65
|
+
errors.push({ field: 'importance', message: impErr, value: event.importance });
|
|
66
|
+
return errors;
|
|
67
|
+
}
|
|
68
|
+
function sanitizeString(input, maxLength = 2000) {
|
|
69
|
+
if (typeof input !== 'string')
|
|
70
|
+
return '';
|
|
71
|
+
return input.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, '').trim().slice(0, maxLength);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../src/walls/06-memory/database/validation.ts"],"names":[],"mappings":";;AAgBA,8CAMC;AAED,gDASC;AAED,kDAKC;AAED,0C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AK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAErF,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,UAAoB,CAAC,CAAC;IAC9D,IAAI,MAAM;QAAE,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IAE3F,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,cAAc,CAAC,KAAa,EAAE,YAAoB,IAAI;IACpE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -211,6 +211,13 @@ switch (cmd) {
|
|
|
211
211
|
case 'dash':
|
|
212
212
|
doDashboard();
|
|
213
213
|
break;
|
|
214
|
+
case 'perf':
|
|
215
|
+
case 'performance':
|
|
216
|
+
doPerf();
|
|
217
|
+
break;
|
|
218
|
+
case 'migrate':
|
|
219
|
+
doMigrate();
|
|
220
|
+
break;
|
|
214
221
|
case 'cross-project':
|
|
215
222
|
doCrossProject();
|
|
216
223
|
break;
|
|
@@ -3129,6 +3136,8 @@ function doHelp() {
|
|
|
3129
3136
|
console.log(` ${C.primary('cell memory')} Search/timeline/compact/verify/export memory`);
|
|
3130
3137
|
console.log(` ${C.primary('cell cross-project')} Share/list/insights from cross-project memory`);
|
|
3131
3138
|
console.log(` ${C.primary('cell dashboard')} Open web dashboard in browser`);
|
|
3139
|
+
console.log(` ${C.primary('cell perf')} Show performance stats & cache info`);
|
|
3140
|
+
console.log(` ${C.primary('cell migrate')} Run database migrations`);
|
|
3132
3141
|
console.log(` ${C.primary('cell context --topic')} Add topic-based memory search to context`);
|
|
3133
3142
|
console.log(` ${C.primary('cell repl')} Interactive REPL with / completion (or just run \`cell\` in a TTY)`);
|
|
3134
3143
|
console.log(` ${C.primary('cell help')} Show this help`);
|
|
@@ -3387,6 +3396,57 @@ function doHandoff() {
|
|
|
3387
3396
|
console.log(C.dim(' cell handoff --log "title" "summary" Log new entry'));
|
|
3388
3397
|
console.log();
|
|
3389
3398
|
}
|
|
3399
|
+
// ─── cell migrate — run database migrations ───────────────────────────────
|
|
3400
|
+
function doMigrate() {
|
|
3401
|
+
console.log(C.bold(' ── Database Migrations ──\n'));
|
|
3402
|
+
try {
|
|
3403
|
+
const { getMigrationStatus, runMigrations } = require('../../06-memory/database/migrations');
|
|
3404
|
+
const status = getMigrationStatus();
|
|
3405
|
+
console.log(C.dim(` Current version: ${status.currentVersion}`));
|
|
3406
|
+
console.log(C.dim(` Applied: ${status.applied.join(', ') || 'none'}`));
|
|
3407
|
+
console.log(C.dim(` Pending: ${status.pending}\n`));
|
|
3408
|
+
if (status.pending > 0) {
|
|
3409
|
+
const result = runMigrations();
|
|
3410
|
+
if (result.errors.length > 0) {
|
|
3411
|
+
console.log(C.warn(` Applied ${result.applied}, ${result.errors.length} errors:`));
|
|
3412
|
+
for (const e of result.errors)
|
|
3413
|
+
console.log(C.warn(` ${e}`));
|
|
3414
|
+
}
|
|
3415
|
+
else {
|
|
3416
|
+
console.log(C.success(` Applied ${result.applied} migration(s)`));
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
else {
|
|
3420
|
+
console.log(C.dim(' Database is up to date.'));
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
catch (e) {
|
|
3424
|
+
console.log(C.warn(` Migration failed: ${e?.message || String(e)}`));
|
|
3425
|
+
}
|
|
3426
|
+
console.log();
|
|
3427
|
+
}
|
|
3428
|
+
// ─── cell perf — performance stats & cache info ───────────────────────────
|
|
3429
|
+
function doPerf() {
|
|
3430
|
+
console.log(C.bold(' ── Performance ──\n'));
|
|
3431
|
+
try {
|
|
3432
|
+
const { getCacheStats } = require('../../06-memory/database/query-cache');
|
|
3433
|
+
const { getDatabaseStats, optimizeDatabase } = require('../../06-memory/database/database');
|
|
3434
|
+
const stats = getCacheStats();
|
|
3435
|
+
console.log(` Query Cache:`);
|
|
3436
|
+
console.log(` Size: ${C.num(String(stats.size))} entries`);
|
|
3437
|
+
console.log(` Hits: ${C.num(String(stats.hits))}`);
|
|
3438
|
+
console.log(` Misses: ${C.num(String(stats.misses))}`);
|
|
3439
|
+
console.log(` Hit rate: ${stats.hitRate}`);
|
|
3440
|
+
const dbStats = getDatabaseStats();
|
|
3441
|
+
console.log(`\n Database:`);
|
|
3442
|
+
console.log(` Tables: ${C.num(String(Object.keys(dbStats).length - 2))}`);
|
|
3443
|
+
console.log(` Size: ${(dbStats.db_size_bytes / 1024).toFixed(1)} KB`);
|
|
3444
|
+
}
|
|
3445
|
+
catch (e) {
|
|
3446
|
+
console.log(C.warn(` Perf check failed: ${e?.message || String(e)}`));
|
|
3447
|
+
}
|
|
3448
|
+
console.log();
|
|
3449
|
+
}
|
|
3390
3450
|
// ─── cell dashboard — open web dashboard ───────────────────────────────────
|
|
3391
3451
|
function doDashboard() {
|
|
3392
3452
|
console.log(C.bold(' ── Cell Dashboard ──\n'));
|