@timmeck/brain-core 2.31.2 → 2.33.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/codegen-dashboard.html +222 -1
- package/dist/codegen/codegen-server.d.ts +5 -0
- package/dist/codegen/codegen-server.js +106 -1
- package/dist/codegen/codegen-server.js.map +1 -1
- package/dist/codegen/context-builder.d.ts +4 -0
- package/dist/codegen/context-builder.js +26 -2
- package/dist/codegen/context-builder.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/research/bootstrap-service.d.ts +57 -0
- package/dist/research/bootstrap-service.js +325 -0
- package/dist/research/bootstrap-service.js.map +1 -0
- package/dist/research/data-miner.d.ts +1 -0
- package/dist/research/data-miner.js +22 -5
- package/dist/research/data-miner.js.map +1 -1
- package/dist/research/research-orchestrator.d.ts +14 -0
- package/dist/research/research-orchestrator.js +140 -0
- package/dist/research/research-orchestrator.js.map +1 -1
- package/dist/self-modification/index.d.ts +2 -0
- package/dist/self-modification/index.js +2 -0
- package/dist/self-modification/index.js.map +1 -0
- package/dist/self-modification/self-modification-engine.d.ts +93 -0
- package/dist/self-modification/self-modification-engine.js +588 -0
- package/dist/self-modification/self-modification-engine.js.map +1 -0
- package/dist/self-scanner/index.d.ts +2 -0
- package/dist/self-scanner/index.js +2 -0
- package/dist/self-scanner/index.js.map +1 -0
- package/dist/self-scanner/self-scanner.d.ts +99 -0
- package/dist/self-scanner/self-scanner.js +397 -0
- package/dist/self-scanner/self-scanner.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/self-modification/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type Database from 'better-sqlite3';
|
|
2
|
+
import type { ContextBuilder } from '../codegen/context-builder.js';
|
|
3
|
+
import type { SelfScanner } from '../self-scanner/self-scanner.js';
|
|
4
|
+
import type { ThoughtStream } from '../consciousness/thought-stream.js';
|
|
5
|
+
export interface SelfModificationConfig {
|
|
6
|
+
brainName: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
maxTokens?: number;
|
|
10
|
+
maxPerHour?: number;
|
|
11
|
+
maxChangedLines?: number;
|
|
12
|
+
projectRoot?: string;
|
|
13
|
+
}
|
|
14
|
+
export type ModificationStatus = 'proposed' | 'generating' | 'testing' | 'ready' | 'approved' | 'rejected' | 'applied' | 'rolled_back' | 'failed';
|
|
15
|
+
export interface FileDiff {
|
|
16
|
+
filePath: string;
|
|
17
|
+
oldContent: string;
|
|
18
|
+
newContent: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SelfModification {
|
|
21
|
+
id: number;
|
|
22
|
+
title: string;
|
|
23
|
+
problem_description: string;
|
|
24
|
+
source_engine: string;
|
|
25
|
+
target_files: string[];
|
|
26
|
+
generated_diff: FileDiff[] | null;
|
|
27
|
+
test_result: 'pending' | 'passed' | 'failed';
|
|
28
|
+
test_output: string | null;
|
|
29
|
+
status: ModificationStatus;
|
|
30
|
+
applied_at: string | null;
|
|
31
|
+
rollback_data: FileDiff[] | null;
|
|
32
|
+
tokens_used: number;
|
|
33
|
+
model_used: string;
|
|
34
|
+
generation_time_ms: number;
|
|
35
|
+
created_at: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SelfModificationStatus {
|
|
38
|
+
brainName: string;
|
|
39
|
+
totalModifications: number;
|
|
40
|
+
byStatus: Record<string, number>;
|
|
41
|
+
lastModification: string | null;
|
|
42
|
+
projectRoot: string | null;
|
|
43
|
+
}
|
|
44
|
+
export declare function runSelfModificationMigration(db: Database.Database): void;
|
|
45
|
+
export declare class SelfModificationEngine {
|
|
46
|
+
private readonly db;
|
|
47
|
+
private readonly config;
|
|
48
|
+
private readonly log;
|
|
49
|
+
private contextBuilder;
|
|
50
|
+
private selfScanner;
|
|
51
|
+
private ts;
|
|
52
|
+
private recentGenerations;
|
|
53
|
+
private readonly stmtInsert;
|
|
54
|
+
private readonly stmtUpdate;
|
|
55
|
+
private readonly stmtGet;
|
|
56
|
+
private readonly stmtGetPending;
|
|
57
|
+
private readonly stmtGetHistory;
|
|
58
|
+
private readonly stmtCountByStatus;
|
|
59
|
+
private readonly stmtCountTotal;
|
|
60
|
+
private readonly stmtLastModification;
|
|
61
|
+
private readonly stmtGetByStatus;
|
|
62
|
+
constructor(db: Database.Database, config: SelfModificationConfig);
|
|
63
|
+
setContextBuilder(cb: ContextBuilder): void;
|
|
64
|
+
setSelfScanner(scanner: SelfScanner): void;
|
|
65
|
+
setThoughtStream(ts: ThoughtStream): void;
|
|
66
|
+
/** Propose a new self-modification. */
|
|
67
|
+
proposeModification(title: string, problem: string, targetFiles: string[], sourceEngine?: string): SelfModification;
|
|
68
|
+
/** Generate code changes via Claude API. */
|
|
69
|
+
generateCode(modificationId: number): Promise<SelfModification>;
|
|
70
|
+
/** Test a modification by writing files, building, running tests, then restoring. */
|
|
71
|
+
testModification(modificationId: number): SelfModification;
|
|
72
|
+
/** Apply an approved modification — write files and build. */
|
|
73
|
+
applyModification(modificationId: number): SelfModification;
|
|
74
|
+
/** Rollback an applied modification. */
|
|
75
|
+
rollbackModification(modificationId: number): SelfModification;
|
|
76
|
+
/** Approve a modification (calls applyModification). */
|
|
77
|
+
approveModification(modificationId: number): SelfModification;
|
|
78
|
+
/** Reject a modification. */
|
|
79
|
+
rejectModification(modificationId: number, notes?: string): SelfModification;
|
|
80
|
+
/** Get all pending modifications (ready or proposed). */
|
|
81
|
+
getPending(): SelfModification[];
|
|
82
|
+
/** Get modification history. */
|
|
83
|
+
getHistory(limit?: number): SelfModification[];
|
|
84
|
+
/** Get a single modification by ID. */
|
|
85
|
+
getModification(id: number): SelfModification | null;
|
|
86
|
+
/** Get status counts. */
|
|
87
|
+
getStatus(): SelfModificationStatus;
|
|
88
|
+
private updateModification;
|
|
89
|
+
private checkRateLimit;
|
|
90
|
+
private parseGeneratedFiles;
|
|
91
|
+
private restoreFiles;
|
|
92
|
+
private recoverFromCrash;
|
|
93
|
+
}
|