@timmeck/brain 2.1.2 → 2.2.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 +71 -21
- package/brain.log +22 -0
- package/dist/brain.js +54 -0
- package/dist/brain.js.map +1 -1
- package/dist/cli/commands/status.js +9 -0
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/db/migrations/010_memory_schema.d.ts +2 -0
- package/dist/db/migrations/010_memory_schema.js +52 -0
- package/dist/db/migrations/010_memory_schema.js.map +1 -0
- package/dist/db/migrations/011_memory_fts.d.ts +2 -0
- package/dist/db/migrations/011_memory_fts.js +54 -0
- package/dist/db/migrations/011_memory_fts.js.map +1 -0
- package/dist/db/migrations/012_decisions_changelog.d.ts +2 -0
- package/dist/db/migrations/012_decisions_changelog.js +97 -0
- package/dist/db/migrations/012_decisions_changelog.js.map +1 -0
- package/dist/db/migrations/013_tasks.d.ts +2 -0
- package/dist/db/migrations/013_tasks.js +53 -0
- package/dist/db/migrations/013_tasks.js.map +1 -0
- package/dist/db/migrations/014_project_docs.d.ts +2 -0
- package/dist/db/migrations/014_project_docs.js +43 -0
- package/dist/db/migrations/014_project_docs.js.map +1 -0
- package/dist/db/migrations/index.js +10 -0
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/db/repositories/changelog.repository.d.ts +15 -0
- package/dist/db/repositories/changelog.repository.js +60 -0
- package/dist/db/repositories/changelog.repository.js.map +1 -0
- package/dist/db/repositories/decision.repository.d.ts +17 -0
- package/dist/db/repositories/decision.repository.js +89 -0
- package/dist/db/repositories/decision.repository.js.map +1 -0
- package/dist/db/repositories/doc.repository.d.ts +16 -0
- package/dist/db/repositories/doc.repository.js +85 -0
- package/dist/db/repositories/doc.repository.js.map +1 -0
- package/dist/db/repositories/memory.repository.d.ts +26 -0
- package/dist/db/repositories/memory.repository.js +136 -0
- package/dist/db/repositories/memory.repository.js.map +1 -0
- package/dist/db/repositories/session.repository.d.ts +18 -0
- package/dist/db/repositories/session.repository.js +82 -0
- package/dist/db/repositories/session.repository.js.map +1 -0
- package/dist/db/repositories/task.repository.d.ts +18 -0
- package/dist/db/repositories/task.repository.js +110 -0
- package/dist/db/repositories/task.repository.js.map +1 -0
- package/dist/embeddings/engine.d.ts +5 -0
- package/dist/embeddings/engine.js +82 -3
- package/dist/embeddings/engine.js.map +1 -1
- package/dist/hooks/post-tool-use.js +40 -18
- package/dist/hooks/post-tool-use.js.map +1 -1
- package/dist/hooks/pre-tool-use.d.ts +2 -0
- package/dist/hooks/pre-tool-use.js +44 -0
- package/dist/hooks/pre-tool-use.js.map +1 -0
- package/dist/ipc/router.d.ts +10 -0
- package/dist/ipc/router.js +37 -1
- package/dist/ipc/router.js.map +1 -1
- package/dist/mcp/tools.js +266 -0
- package/dist/mcp/tools.js.map +1 -1
- package/dist/services/analytics.service.d.ts +13 -0
- package/dist/services/analytics.service.js +13 -0
- package/dist/services/analytics.service.js.map +1 -1
- package/dist/services/changelog.service.d.ts +17 -0
- package/dist/services/changelog.service.js +77 -0
- package/dist/services/changelog.service.js.map +1 -0
- package/dist/services/decision.service.d.ts +17 -0
- package/dist/services/decision.service.js +64 -0
- package/dist/services/decision.service.js.map +1 -0
- package/dist/services/doc.service.d.ts +30 -0
- package/dist/services/doc.service.js +140 -0
- package/dist/services/doc.service.js.map +1 -0
- package/dist/services/memory.service.d.ts +44 -0
- package/dist/services/memory.service.js +189 -0
- package/dist/services/memory.service.js.map +1 -0
- package/dist/services/task.service.d.ts +35 -0
- package/dist/services/task.service.js +116 -0
- package/dist/services/task.service.js.map +1 -0
- package/dist/types/decision.types.d.ts +75 -0
- package/dist/types/decision.types.js +2 -0
- package/dist/types/decision.types.js.map +1 -0
- package/dist/types/doc.types.d.ts +23 -0
- package/dist/types/doc.types.js +2 -0
- package/dist/types/doc.types.js.map +1 -0
- package/dist/types/memory.types.d.ts +1 -0
- package/dist/types/memory.types.js +2 -0
- package/dist/types/memory.types.js.map +1 -0
- package/dist/types/synapse.types.d.ts +2 -2
- package/dist/types/task.types.d.ts +47 -0
- package/dist/types/task.types.js +2 -0
- package/dist/types/task.types.js.map +1 -0
- package/dist/utils/events.d.ts +47 -0
- package/dist/utils/events.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { getEventBus } from '../utils/events.js';
|
|
2
|
+
import { getLogger } from '../utils/logger.js';
|
|
3
|
+
export class TaskService {
|
|
4
|
+
taskRepo;
|
|
5
|
+
memoryRepo;
|
|
6
|
+
decisionRepo;
|
|
7
|
+
changelogRepo;
|
|
8
|
+
projectRepo;
|
|
9
|
+
synapseManager;
|
|
10
|
+
logger = getLogger();
|
|
11
|
+
constructor(taskRepo, memoryRepo, decisionRepo, changelogRepo, projectRepo, synapseManager) {
|
|
12
|
+
this.taskRepo = taskRepo;
|
|
13
|
+
this.memoryRepo = memoryRepo;
|
|
14
|
+
this.decisionRepo = decisionRepo;
|
|
15
|
+
this.changelogRepo = changelogRepo;
|
|
16
|
+
this.projectRepo = projectRepo;
|
|
17
|
+
this.synapseManager = synapseManager;
|
|
18
|
+
}
|
|
19
|
+
addTask(input) {
|
|
20
|
+
const bus = getEventBus();
|
|
21
|
+
let projectId = input.projectId ?? null;
|
|
22
|
+
if (!projectId && input.project) {
|
|
23
|
+
const project = this.projectRepo.findByName(input.project);
|
|
24
|
+
if (project)
|
|
25
|
+
projectId = project.id;
|
|
26
|
+
}
|
|
27
|
+
const taskId = this.taskRepo.create({
|
|
28
|
+
project_id: projectId,
|
|
29
|
+
session_id: input.sessionId ?? null,
|
|
30
|
+
parent_task_id: input.parentTaskId ?? null,
|
|
31
|
+
title: input.title,
|
|
32
|
+
description: input.description ?? null,
|
|
33
|
+
status: 'pending',
|
|
34
|
+
priority: input.priority ?? 5,
|
|
35
|
+
due_date: input.dueDate ?? null,
|
|
36
|
+
completed_at: null,
|
|
37
|
+
blocked_by: input.blockedBy ? JSON.stringify(input.blockedBy) : null,
|
|
38
|
+
tags: input.tags ? JSON.stringify(input.tags) : null,
|
|
39
|
+
notes: null,
|
|
40
|
+
embedding: null,
|
|
41
|
+
});
|
|
42
|
+
if (projectId) {
|
|
43
|
+
this.synapseManager.strengthen({ type: 'task', id: taskId }, { type: 'project', id: projectId }, 'co_occurs');
|
|
44
|
+
}
|
|
45
|
+
bus.emit('task:created', { taskId, projectId });
|
|
46
|
+
this.logger.info(`Task #${taskId} created: ${input.title}`);
|
|
47
|
+
return { taskId };
|
|
48
|
+
}
|
|
49
|
+
updateTask(id, input) {
|
|
50
|
+
const bus = getEventBus();
|
|
51
|
+
if (input.note) {
|
|
52
|
+
this.taskRepo.addNote(id, input.note);
|
|
53
|
+
}
|
|
54
|
+
const updateData = {};
|
|
55
|
+
if (input.status)
|
|
56
|
+
updateData.status = input.status;
|
|
57
|
+
if (input.title)
|
|
58
|
+
updateData.title = input.title;
|
|
59
|
+
if (input.description)
|
|
60
|
+
updateData.description = input.description;
|
|
61
|
+
if (input.priority)
|
|
62
|
+
updateData.priority = input.priority;
|
|
63
|
+
if (input.dueDate)
|
|
64
|
+
updateData.due_date = input.dueDate;
|
|
65
|
+
if (input.tags)
|
|
66
|
+
updateData.tags = JSON.stringify(input.tags);
|
|
67
|
+
if (input.blockedBy)
|
|
68
|
+
updateData.blocked_by = JSON.stringify(input.blockedBy);
|
|
69
|
+
if (input.status === 'completed')
|
|
70
|
+
updateData.completed_at = new Date().toISOString();
|
|
71
|
+
if (Object.keys(updateData).length > 0) {
|
|
72
|
+
this.taskRepo.update(id, updateData);
|
|
73
|
+
}
|
|
74
|
+
if (input.status === 'completed') {
|
|
75
|
+
bus.emit('task:completed', { taskId: id });
|
|
76
|
+
this.logger.info(`Task #${id} completed`);
|
|
77
|
+
}
|
|
78
|
+
return this.taskRepo.getById(id);
|
|
79
|
+
}
|
|
80
|
+
listTasks(input = {}) {
|
|
81
|
+
if (input.status) {
|
|
82
|
+
return this.taskRepo.findByStatus(input.status, input.projectId, input.limit ?? 50);
|
|
83
|
+
}
|
|
84
|
+
if (input.parentTaskId) {
|
|
85
|
+
return this.taskRepo.findSubtasks(input.parentTaskId);
|
|
86
|
+
}
|
|
87
|
+
return this.taskRepo.findAll(input.projectId, input.limit ?? 50);
|
|
88
|
+
}
|
|
89
|
+
getById(id) {
|
|
90
|
+
return this.taskRepo.getById(id);
|
|
91
|
+
}
|
|
92
|
+
getTaskContext(id) {
|
|
93
|
+
const task = this.taskRepo.getById(id);
|
|
94
|
+
if (!task)
|
|
95
|
+
return { task: undefined, subtasks: [], memories: [], decisions: [], changes: [] };
|
|
96
|
+
const subtasks = this.taskRepo.findSubtasks(id);
|
|
97
|
+
// Get related items via synapse activation
|
|
98
|
+
const activated = this.synapseManager.activate({ type: 'task', id });
|
|
99
|
+
const memoryIds = activated.filter(a => a.node.type === 'memory').map(a => a.node.id);
|
|
100
|
+
const decisionIds = activated.filter(a => a.node.type === 'decision').map(a => a.node.id);
|
|
101
|
+
const changelogIds = activated.filter(a => a.node.type === 'changelog_entry').map(a => a.node.id);
|
|
102
|
+
const memories = memoryIds.map(mid => this.memoryRepo.getById(mid)).filter(Boolean);
|
|
103
|
+
const decisions = decisionIds.map(did => this.decisionRepo.getById(did)).filter(Boolean);
|
|
104
|
+
const changes = changelogIds.map(cid => this.changelogRepo.getById(cid)).filter(Boolean);
|
|
105
|
+
return { task, subtasks, memories, decisions, changes };
|
|
106
|
+
}
|
|
107
|
+
searchTasks(query, limit) {
|
|
108
|
+
try {
|
|
109
|
+
return this.taskRepo.search(query, limit ?? 20);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=task.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.service.js","sourceRoot":"","sources":["../../src/services/task.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS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AAE,CAAC,CAAC;QAC1F,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAElG,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpF,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACzF,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEzF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAC1D,CAAC;IAED,WAAW,CAAC,KAAa,EAAE,KAAc;QACvC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export type DecisionCategory = 'architecture' | 'technology' | 'pattern' | 'convention' | 'dependency' | 'process' | 'other';
|
|
2
|
+
export type DecisionStatus = 'active' | 'superseded' | 'deprecated' | 'rejected';
|
|
3
|
+
export type ChangeType = 'created' | 'modified' | 'deleted' | 'renamed' | 'refactored';
|
|
4
|
+
export interface DecisionRecord {
|
|
5
|
+
id: number;
|
|
6
|
+
project_id: number | null;
|
|
7
|
+
session_id: number | null;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
alternatives: string | null;
|
|
11
|
+
category: DecisionCategory;
|
|
12
|
+
status: DecisionStatus;
|
|
13
|
+
superseded_by: number | null;
|
|
14
|
+
tags: string | null;
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at: string;
|
|
17
|
+
embedding: Buffer | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ChangelogEntry {
|
|
20
|
+
id: number;
|
|
21
|
+
project_id: number;
|
|
22
|
+
session_id: number | null;
|
|
23
|
+
file_path: string;
|
|
24
|
+
change_type: ChangeType;
|
|
25
|
+
summary: string;
|
|
26
|
+
reason: string | null;
|
|
27
|
+
diff_snippet: string | null;
|
|
28
|
+
related_error_id: number | null;
|
|
29
|
+
related_decision_id: number | null;
|
|
30
|
+
commit_hash: string | null;
|
|
31
|
+
created_at: string;
|
|
32
|
+
embedding: Buffer | null;
|
|
33
|
+
}
|
|
34
|
+
export interface RecordDecisionInput {
|
|
35
|
+
title: string;
|
|
36
|
+
description: string;
|
|
37
|
+
alternatives?: Array<{
|
|
38
|
+
option: string;
|
|
39
|
+
pros?: string[];
|
|
40
|
+
cons?: string[];
|
|
41
|
+
rejected_reason?: string;
|
|
42
|
+
}>;
|
|
43
|
+
category?: DecisionCategory;
|
|
44
|
+
tags?: string[];
|
|
45
|
+
project?: string;
|
|
46
|
+
projectId?: number;
|
|
47
|
+
sessionId?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface QueryDecisionsInput {
|
|
50
|
+
query?: string;
|
|
51
|
+
category?: DecisionCategory;
|
|
52
|
+
projectId?: number;
|
|
53
|
+
status?: DecisionStatus;
|
|
54
|
+
limit?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface RecordChangeInput {
|
|
57
|
+
filePath: string;
|
|
58
|
+
changeType: ChangeType;
|
|
59
|
+
summary: string;
|
|
60
|
+
reason?: string;
|
|
61
|
+
diffSnippet?: string;
|
|
62
|
+
relatedErrorId?: number;
|
|
63
|
+
relatedDecisionId?: number;
|
|
64
|
+
commitHash?: string;
|
|
65
|
+
project?: string;
|
|
66
|
+
projectId?: number;
|
|
67
|
+
sessionId?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface QueryChangesInput {
|
|
70
|
+
query?: string;
|
|
71
|
+
filePath?: string;
|
|
72
|
+
projectId?: number;
|
|
73
|
+
sessionId?: number;
|
|
74
|
+
limit?: number;
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision.types.js","sourceRoot":"","sources":["../../src/types/decision.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type DocType = 'readme' | 'claude_md' | 'package_json' | 'tsconfig' | 'architecture' | 'api' | 'other';
|
|
2
|
+
export interface ProjectDocRecord {
|
|
3
|
+
id: number;
|
|
4
|
+
project_id: number;
|
|
5
|
+
file_path: string;
|
|
6
|
+
doc_type: DocType;
|
|
7
|
+
content: string;
|
|
8
|
+
content_hash: string;
|
|
9
|
+
parsed_metadata: string | null;
|
|
10
|
+
last_indexed_at: string;
|
|
11
|
+
embedding: Buffer | null;
|
|
12
|
+
}
|
|
13
|
+
export interface IndexProjectInput {
|
|
14
|
+
projectPath: string;
|
|
15
|
+
project?: string;
|
|
16
|
+
projectId?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface QueryDocsInput {
|
|
19
|
+
query?: string;
|
|
20
|
+
projectId?: number;
|
|
21
|
+
docType?: DocType;
|
|
22
|
+
limit?: number;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.types.js","sourceRoot":"","sources":["../../src/types/doc.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { MemoryRecord, SessionRecord, MemoryCategory, MemorySource, SessionOutcome, RememberInput, RecallInput, StartSessionInput, EndSessionInput, MemoryRepoInterface, SessionRepoInterface, MemoryEngineConfig, } from '@timmeck/brain-core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.types.js","sourceRoot":"","sources":["../../src/types/memory.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type NodeType = 'error' | 'solution' | 'code_module' | 'rule' | 'antipattern' | 'project' | 'insight';
|
|
2
|
-
export type SynapseType = 'solves' | 'causes' | 'similar_to' | 'uses_module' | 'depends_on' | 'derived_from' | 'co_occurs' | 'prevents' | 'improves' | 'generalizes' | 'cross_project';
|
|
1
|
+
export type NodeType = 'error' | 'solution' | 'code_module' | 'rule' | 'antipattern' | 'project' | 'insight' | 'memory' | 'session' | 'decision' | 'changelog_entry' | 'task' | 'doc';
|
|
2
|
+
export type SynapseType = 'solves' | 'causes' | 'similar_to' | 'uses_module' | 'depends_on' | 'derived_from' | 'co_occurs' | 'prevents' | 'improves' | 'generalizes' | 'cross_project' | 'remembers' | 'relates_to' | 'informs';
|
|
3
3
|
export interface SynapseRecord {
|
|
4
4
|
id: number;
|
|
5
5
|
source_type: NodeType;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'blocked' | 'cancelled';
|
|
2
|
+
export interface TaskRecord {
|
|
3
|
+
id: number;
|
|
4
|
+
project_id: number | null;
|
|
5
|
+
session_id: number | null;
|
|
6
|
+
parent_task_id: number | null;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string | null;
|
|
9
|
+
status: TaskStatus;
|
|
10
|
+
priority: number;
|
|
11
|
+
due_date: string | null;
|
|
12
|
+
completed_at: string | null;
|
|
13
|
+
blocked_by: string | null;
|
|
14
|
+
tags: string | null;
|
|
15
|
+
notes: string | null;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
embedding: Buffer | null;
|
|
19
|
+
}
|
|
20
|
+
export interface AddTaskInput {
|
|
21
|
+
title: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
priority?: number;
|
|
24
|
+
dueDate?: string;
|
|
25
|
+
tags?: string[];
|
|
26
|
+
parentTaskId?: number;
|
|
27
|
+
blockedBy?: number[];
|
|
28
|
+
project?: string;
|
|
29
|
+
projectId?: number;
|
|
30
|
+
sessionId?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateTaskInput {
|
|
33
|
+
status?: TaskStatus;
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
priority?: number;
|
|
37
|
+
dueDate?: string;
|
|
38
|
+
notes?: string;
|
|
39
|
+
tags?: string[];
|
|
40
|
+
blockedBy?: number[];
|
|
41
|
+
}
|
|
42
|
+
export interface ListTasksInput {
|
|
43
|
+
projectId?: number;
|
|
44
|
+
status?: TaskStatus;
|
|
45
|
+
parentTaskId?: number;
|
|
46
|
+
limit?: number;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.types.js","sourceRoot":"","sources":["../../src/types/task.types.ts"],"names":[],"mappings":""}
|
package/dist/utils/events.d.ts
CHANGED
|
@@ -48,6 +48,53 @@ export type BrainEvents = {
|
|
|
48
48
|
'terminal:disconnected': {
|
|
49
49
|
terminalId: number;
|
|
50
50
|
};
|
|
51
|
+
'memory:created': {
|
|
52
|
+
memoryId: number;
|
|
53
|
+
projectId: number | null;
|
|
54
|
+
category: string;
|
|
55
|
+
};
|
|
56
|
+
'memory:recalled': {
|
|
57
|
+
memoryId: number;
|
|
58
|
+
query: string;
|
|
59
|
+
};
|
|
60
|
+
'memory:superseded': {
|
|
61
|
+
oldId: number;
|
|
62
|
+
newId: number;
|
|
63
|
+
};
|
|
64
|
+
'session:started': {
|
|
65
|
+
sessionId: number;
|
|
66
|
+
projectId: number | null;
|
|
67
|
+
};
|
|
68
|
+
'session:ended': {
|
|
69
|
+
sessionId: number;
|
|
70
|
+
summary: string;
|
|
71
|
+
};
|
|
72
|
+
'decision:recorded': {
|
|
73
|
+
decisionId: number;
|
|
74
|
+
projectId: number | null;
|
|
75
|
+
category: string;
|
|
76
|
+
};
|
|
77
|
+
'decision:superseded': {
|
|
78
|
+
oldId: number;
|
|
79
|
+
newId: number;
|
|
80
|
+
};
|
|
81
|
+
'changelog:recorded': {
|
|
82
|
+
changeId: number;
|
|
83
|
+
projectId: number;
|
|
84
|
+
filePath: string;
|
|
85
|
+
};
|
|
86
|
+
'task:created': {
|
|
87
|
+
taskId: number;
|
|
88
|
+
projectId: number | null;
|
|
89
|
+
};
|
|
90
|
+
'task:completed': {
|
|
91
|
+
taskId: number;
|
|
92
|
+
};
|
|
93
|
+
'doc:indexed': {
|
|
94
|
+
docId: number;
|
|
95
|
+
projectId: number;
|
|
96
|
+
docType: string;
|
|
97
|
+
};
|
|
51
98
|
};
|
|
52
99
|
export type BrainEventName = keyof BrainEvents;
|
|
53
100
|
export declare class TypedEventBus extends GenericEventBus<BrainEvents> {
|
package/dist/utils/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAkCvE,MAAM,OAAO,aAAc,SAAQ,eAA4B;CAAG;AAElE,IAAI,WAAW,GAAyB,IAAI,CAAC;AAE7C,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,IAAI,aAAa,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timmeck/brain",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Adaptive error memory and code intelligence system with Hebbian synapse network, hybrid search, and REST API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@huggingface/transformers": "^3.8.1",
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
45
|
-
"@timmeck/brain-core": "^1.
|
|
45
|
+
"@timmeck/brain-core": "^1.6.0",
|
|
46
46
|
"better-sqlite3": "^11.7.0",
|
|
47
47
|
"chalk": "^5.6.2",
|
|
48
48
|
"commander": "^13.0.0",
|