@soleri/core 2.0.1 → 2.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.
Files changed (68) hide show
  1. package/dist/brain/brain.d.ts +2 -49
  2. package/dist/brain/brain.d.ts.map +1 -1
  3. package/dist/brain/brain.js +1 -158
  4. package/dist/brain/brain.js.map +1 -1
  5. package/dist/brain/intelligence.d.ts +51 -0
  6. package/dist/brain/intelligence.d.ts.map +1 -0
  7. package/dist/brain/intelligence.js +666 -0
  8. package/dist/brain/intelligence.js.map +1 -0
  9. package/dist/brain/types.d.ts +165 -0
  10. package/dist/brain/types.d.ts.map +1 -0
  11. package/dist/brain/types.js +2 -0
  12. package/dist/brain/types.js.map +1 -0
  13. package/dist/curator/curator.d.ts +28 -0
  14. package/dist/curator/curator.d.ts.map +1 -0
  15. package/dist/curator/curator.js +525 -0
  16. package/dist/curator/curator.js.map +1 -0
  17. package/dist/curator/types.d.ts +87 -0
  18. package/dist/curator/types.d.ts.map +1 -0
  19. package/dist/curator/types.js +3 -0
  20. package/dist/curator/types.js.map +1 -0
  21. package/dist/facades/types.d.ts +1 -1
  22. package/dist/index.d.ts +11 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +11 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/llm/llm-client.d.ts +28 -0
  27. package/dist/llm/llm-client.d.ts.map +1 -0
  28. package/dist/llm/llm-client.js +226 -0
  29. package/dist/llm/llm-client.js.map +1 -0
  30. package/dist/runtime/core-ops.d.ts +17 -0
  31. package/dist/runtime/core-ops.d.ts.map +1 -0
  32. package/dist/runtime/core-ops.js +613 -0
  33. package/dist/runtime/core-ops.js.map +1 -0
  34. package/dist/runtime/domain-ops.d.ts +25 -0
  35. package/dist/runtime/domain-ops.d.ts.map +1 -0
  36. package/dist/runtime/domain-ops.js +130 -0
  37. package/dist/runtime/domain-ops.js.map +1 -0
  38. package/dist/runtime/runtime.d.ts +19 -0
  39. package/dist/runtime/runtime.d.ts.map +1 -0
  40. package/dist/runtime/runtime.js +66 -0
  41. package/dist/runtime/runtime.js.map +1 -0
  42. package/dist/runtime/types.d.ts +41 -0
  43. package/dist/runtime/types.d.ts.map +1 -0
  44. package/dist/runtime/types.js +2 -0
  45. package/dist/runtime/types.js.map +1 -0
  46. package/dist/text/similarity.d.ts +8 -0
  47. package/dist/text/similarity.d.ts.map +1 -0
  48. package/dist/text/similarity.js +161 -0
  49. package/dist/text/similarity.js.map +1 -0
  50. package/package.json +6 -2
  51. package/src/__tests__/brain-intelligence.test.ts +623 -0
  52. package/src/__tests__/core-ops.test.ts +218 -0
  53. package/src/__tests__/curator.test.ts +574 -0
  54. package/src/__tests__/domain-ops.test.ts +160 -0
  55. package/src/__tests__/llm-client.test.ts +69 -0
  56. package/src/__tests__/runtime.test.ts +95 -0
  57. package/src/brain/brain.ts +27 -221
  58. package/src/brain/intelligence.ts +1061 -0
  59. package/src/brain/types.ts +176 -0
  60. package/src/curator/curator.ts +699 -0
  61. package/src/curator/types.ts +114 -0
  62. package/src/index.ts +55 -1
  63. package/src/llm/llm-client.ts +310 -0
  64. package/src/runtime/core-ops.ts +665 -0
  65. package/src/runtime/domain-ops.ts +144 -0
  66. package/src/runtime/runtime.ts +76 -0
  67. package/src/runtime/types.ts +39 -0
  68. package/src/text/similarity.ts +168 -0
@@ -0,0 +1,218 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2
+ import { mkdirSync, rmSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { tmpdir } from 'node:os';
5
+ import { createAgentRuntime } from '../runtime/runtime.js';
6
+ import { createCoreOps } from '../runtime/core-ops.js';
7
+ import type { AgentRuntime } from '../runtime/types.js';
8
+ import type { OpDefinition } from '../facades/types.js';
9
+
10
+ describe('createCoreOps', () => {
11
+ let runtime: AgentRuntime;
12
+ let ops: OpDefinition[];
13
+ let plannerDir: string;
14
+
15
+ beforeEach(() => {
16
+ plannerDir = join(tmpdir(), 'core-ops-test-' + Date.now());
17
+ mkdirSync(plannerDir, { recursive: true });
18
+ runtime = createAgentRuntime({
19
+ agentId: 'test-core-ops',
20
+ vaultPath: ':memory:',
21
+ plansPath: join(plannerDir, 'plans.json'),
22
+ });
23
+ ops = createCoreOps(runtime);
24
+ });
25
+
26
+ afterEach(() => {
27
+ runtime.close();
28
+ rmSync(plannerDir, { recursive: true, force: true });
29
+ });
30
+
31
+ function findOp(name: string): OpDefinition {
32
+ const op = ops.find((o) => o.name === name);
33
+ if (!op) throw new Error(`Op "${name}" not found`);
34
+ return op;
35
+ }
36
+
37
+ it('should return 37 ops', () => {
38
+ expect(ops.length).toBe(37);
39
+ });
40
+
41
+ it('should have all expected op names', () => {
42
+ const names = ops.map((o) => o.name);
43
+ // Search/Vault
44
+ expect(names).toContain('search');
45
+ expect(names).toContain('vault_stats');
46
+ expect(names).toContain('list_all');
47
+ expect(names).toContain('register');
48
+ // Memory
49
+ expect(names).toContain('memory_search');
50
+ expect(names).toContain('memory_capture');
51
+ expect(names).toContain('memory_list');
52
+ expect(names).toContain('session_capture');
53
+ // Export
54
+ expect(names).toContain('export');
55
+ // Planning
56
+ expect(names).toContain('create_plan');
57
+ expect(names).toContain('get_plan');
58
+ expect(names).toContain('approve_plan');
59
+ expect(names).toContain('update_task');
60
+ expect(names).toContain('complete_plan');
61
+ // Brain
62
+ expect(names).toContain('record_feedback');
63
+ expect(names).toContain('rebuild_vocabulary');
64
+ expect(names).toContain('brain_stats');
65
+ expect(names).toContain('llm_status');
66
+ // Brain Intelligence
67
+ expect(names).toContain('brain_session_context');
68
+ expect(names).toContain('brain_strengths');
69
+ expect(names).toContain('brain_global_patterns');
70
+ expect(names).toContain('brain_recommend');
71
+ expect(names).toContain('brain_build_intelligence');
72
+ expect(names).toContain('brain_export');
73
+ expect(names).toContain('brain_import');
74
+ expect(names).toContain('brain_extract_knowledge');
75
+ expect(names).toContain('brain_archive_sessions');
76
+ expect(names).toContain('brain_promote_proposals');
77
+ expect(names).toContain('brain_lifecycle');
78
+ // Curator
79
+ expect(names).toContain('curator_status');
80
+ expect(names).toContain('curator_detect_duplicates');
81
+ expect(names).toContain('curator_contradictions');
82
+ expect(names).toContain('curator_resolve_contradiction');
83
+ expect(names).toContain('curator_groom');
84
+ expect(names).toContain('curator_groom_all');
85
+ expect(names).toContain('curator_consolidate');
86
+ expect(names).toContain('curator_health_audit');
87
+ });
88
+
89
+ it('search should query vault via brain', async () => {
90
+ runtime.vault.seed([
91
+ {
92
+ id: 'co-1',
93
+ type: 'pattern',
94
+ domain: 'testing',
95
+ title: 'Test pattern for core ops',
96
+ severity: 'warning',
97
+ description: 'Core ops test.',
98
+ tags: ['test'],
99
+ },
100
+ ]);
101
+ runtime.brain.rebuildVocabulary();
102
+
103
+ // Re-create ops since brain state changed
104
+ ops = createCoreOps(runtime);
105
+ const results = (await findOp('search').handler({ query: 'core ops test' })) as unknown[];
106
+ expect(results.length).toBeGreaterThan(0);
107
+ });
108
+
109
+ it('vault_stats should return counts', async () => {
110
+ runtime.vault.seed([
111
+ {
112
+ id: 'vs-1',
113
+ type: 'pattern',
114
+ domain: 'd1',
115
+ title: 'T',
116
+ severity: 'warning',
117
+ description: 'D',
118
+ tags: ['t'],
119
+ },
120
+ ]);
121
+ const stats = (await findOp('vault_stats').handler({})) as { totalEntries: number };
122
+ expect(stats.totalEntries).toBe(1);
123
+ });
124
+
125
+ it('create_plan + get_plan should work', async () => {
126
+ const created = (await findOp('create_plan').handler({
127
+ objective: 'Test plan',
128
+ scope: 'core-ops test',
129
+ tasks: [{ title: 'Task 1', description: 'Do something' }],
130
+ })) as { created: boolean; plan: { id: string; status: string } };
131
+ expect(created.created).toBe(true);
132
+ expect(created.plan.status).toBe('draft');
133
+
134
+ const plan = (await findOp('get_plan').handler({ planId: created.plan.id })) as { id: string };
135
+ expect(plan.id).toBe(created.plan.id);
136
+ });
137
+
138
+ it('brain_stats should return stats', async () => {
139
+ const stats = (await findOp('brain_stats').handler({})) as {
140
+ vocabularySize: number;
141
+ feedbackCount: number;
142
+ };
143
+ expect(stats.vocabularySize).toBe(0);
144
+ expect(stats.feedbackCount).toBe(0);
145
+ });
146
+
147
+ it('llm_status should return provider info', async () => {
148
+ const status = (await findOp('llm_status').handler({})) as {
149
+ providers: {
150
+ openai: { available: boolean };
151
+ anthropic: { available: boolean };
152
+ };
153
+ routes: unknown[];
154
+ };
155
+ expect(typeof status.providers.openai.available).toBe('boolean');
156
+ expect(typeof status.providers.anthropic.available).toBe('boolean');
157
+ expect(Array.isArray(status.routes)).toBe(true);
158
+ });
159
+
160
+ it('curator_status should return initialized', async () => {
161
+ const status = (await findOp('curator_status').handler({})) as { initialized: boolean };
162
+ expect(status.initialized).toBe(true);
163
+ });
164
+
165
+ it('curator_health_audit should return score', async () => {
166
+ runtime.vault.seed([
167
+ {
168
+ id: 'ha-1',
169
+ type: 'pattern',
170
+ domain: 'testing',
171
+ title: 'Health pattern',
172
+ severity: 'warning',
173
+ description: 'Testing health.',
174
+ tags: ['health'],
175
+ },
176
+ ]);
177
+ runtime.curator.groomAll();
178
+ const result = (await findOp('curator_health_audit').handler({})) as { score: number };
179
+ expect(result.score).toBeGreaterThan(0);
180
+ });
181
+
182
+ it('memory_capture + memory_search should work', async () => {
183
+ await findOp('memory_capture').handler({
184
+ projectPath: '/test',
185
+ type: 'lesson',
186
+ context: 'Testing core ops',
187
+ summary: 'Core ops memory test works',
188
+ topics: ['testing'],
189
+ filesModified: [],
190
+ toolsUsed: [],
191
+ });
192
+
193
+ const results = (await findOp('memory_search').handler({
194
+ query: 'core ops memory',
195
+ })) as unknown[];
196
+ expect(results.length).toBeGreaterThan(0);
197
+ });
198
+
199
+ it('export should return bundles', async () => {
200
+ runtime.vault.seed([
201
+ {
202
+ id: 'exp-1',
203
+ type: 'pattern',
204
+ domain: 'security',
205
+ title: 'Export test',
206
+ severity: 'warning',
207
+ description: 'Testing export.',
208
+ tags: ['export'],
209
+ },
210
+ ]);
211
+ const result = (await findOp('export').handler({})) as {
212
+ exported: boolean;
213
+ totalEntries: number;
214
+ };
215
+ expect(result.exported).toBe(true);
216
+ expect(result.totalEntries).toBe(1);
217
+ });
218
+ });