@soleri/core 9.3.0 → 9.3.1
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/engine/module-manifest.d.ts +2 -0
- package/dist/engine/module-manifest.d.ts.map +1 -1
- package/dist/engine/module-manifest.js +115 -0
- package/dist/engine/module-manifest.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/planning/task-complexity-assessor.d.ts +42 -0
- package/dist/planning/task-complexity-assessor.d.ts.map +1 -0
- package/dist/planning/task-complexity-assessor.js +132 -0
- package/dist/planning/task-complexity-assessor.js.map +1 -0
- package/dist/runtime/admin-ops.d.ts.map +1 -1
- package/dist/runtime/admin-ops.js +18 -0
- package/dist/runtime/admin-ops.js.map +1 -1
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
- package/dist/runtime/orchestrate-ops.js +43 -32
- package/dist/runtime/orchestrate-ops.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/module-manifest.test.ts +43 -0
- package/src/engine/module-manifest.ts +117 -0
- package/src/index.ts +8 -0
- package/src/planning/task-complexity-assessor.test.ts +298 -0
- package/src/planning/task-complexity-assessor.ts +183 -0
- package/src/runtime/admin-ops.test.ts +23 -0
- package/src/runtime/admin-ops.ts +19 -0
- package/src/runtime/orchestrate-ops.test.ts +204 -0
- package/src/runtime/orchestrate-ops.ts +49 -38
- package/src/vault/vault-scaling.test.ts +5 -5
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
assessTaskComplexity,
|
|
4
|
+
type AssessmentInput,
|
|
5
|
+
type AssessmentResult,
|
|
6
|
+
} from './task-complexity-assessor.js';
|
|
7
|
+
|
|
8
|
+
// ─── Helpers ────────────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
function assess(partial: Partial<AssessmentInput> & { prompt: string }): AssessmentResult {
|
|
11
|
+
return assessTaskComplexity(partial);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function signalByName(result: AssessmentResult, name: string) {
|
|
15
|
+
return result.signals.find((s) => s.name === name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ─── Simple Tasks ───────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
describe('assessTaskComplexity — simple tasks', () => {
|
|
21
|
+
it('classifies "rename variable X" as simple', () => {
|
|
22
|
+
const result = assess({ prompt: 'rename variable X to Y' });
|
|
23
|
+
expect(result.classification).toBe('simple');
|
|
24
|
+
expect(result.score).toBeLessThan(40);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('classifies "fix typo in README" as simple', () => {
|
|
28
|
+
const result = assess({ prompt: 'fix typo in README' });
|
|
29
|
+
expect(result.classification).toBe('simple');
|
|
30
|
+
expect(result.score).toBeLessThan(40);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('classifies "add CSS class" as simple', () => {
|
|
34
|
+
const result = assess({ prompt: 'add CSS class to the header' });
|
|
35
|
+
expect(result.classification).toBe('simple');
|
|
36
|
+
expect(result.score).toBeLessThan(40);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('classifies single-file estimate as simple', () => {
|
|
40
|
+
const result = assess({ prompt: 'update button color', filesEstimated: 1 });
|
|
41
|
+
expect(result.classification).toBe('simple');
|
|
42
|
+
expect(signalByName(result, 'file-count')!.triggered).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('classifies task with 2 files as simple', () => {
|
|
46
|
+
const result = assess({ prompt: 'update two files', filesEstimated: 2 });
|
|
47
|
+
expect(result.classification).toBe('simple');
|
|
48
|
+
expect(signalByName(result, 'file-count')!.triggered).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// ─── Complex Tasks ──────────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
describe('assessTaskComplexity — complex tasks', () => {
|
|
55
|
+
it('classifies "add authentication" touching multiple files as complex', () => {
|
|
56
|
+
const result = assess({ prompt: 'add authentication to the API', filesEstimated: 4 });
|
|
57
|
+
expect(result.classification).toBe('complex');
|
|
58
|
+
expect(result.score).toBeGreaterThanOrEqual(40);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('classifies "refactor the vault module" as complex via cross-cutting when combined with files', () => {
|
|
62
|
+
const result = assess({ prompt: 'refactor across the vault module', filesEstimated: 5 });
|
|
63
|
+
expect(result.classification).toBe('complex');
|
|
64
|
+
expect(result.score).toBeGreaterThanOrEqual(40);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('classifies "migrate database schema" touching multiple files as complex', () => {
|
|
68
|
+
const result = assess({ prompt: 'migrate database schema to v2', filesEstimated: 3 });
|
|
69
|
+
expect(result.classification).toBe('complex');
|
|
70
|
+
expect(signalByName(result, 'cross-cutting-keywords')!.triggered).toBe(true);
|
|
71
|
+
expect(signalByName(result, 'file-count')!.triggered).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('classifies many-file task with design decision as complex', () => {
|
|
75
|
+
const result = assess({ prompt: 'how should we update styles across the app', filesEstimated: 5 });
|
|
76
|
+
expect(result.classification).toBe('complex');
|
|
77
|
+
expect(result.score).toBeGreaterThanOrEqual(40);
|
|
78
|
+
expect(signalByName(result, 'file-count')!.triggered).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('classifies task with design decision as complex', () => {
|
|
82
|
+
const result = assess({
|
|
83
|
+
prompt: 'how should we structure the new cache layer',
|
|
84
|
+
filesEstimated: 3,
|
|
85
|
+
});
|
|
86
|
+
expect(result.classification).toBe('complex');
|
|
87
|
+
expect(signalByName(result, 'design-decisions-needed')!.triggered).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('classifies task with new dependency as complex', () => {
|
|
91
|
+
const result = assess({
|
|
92
|
+
prompt: 'add a new package for rate limiting and install it',
|
|
93
|
+
filesEstimated: 3,
|
|
94
|
+
});
|
|
95
|
+
expect(result.classification).toBe('complex');
|
|
96
|
+
expect(signalByName(result, 'new-dependencies')!.triggered).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// ─── Edge Cases ─────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
describe('assessTaskComplexity — edge cases', () => {
|
|
103
|
+
it('handles empty prompt as simple', () => {
|
|
104
|
+
const result = assess({ prompt: '' });
|
|
105
|
+
expect(result.classification).toBe('simple');
|
|
106
|
+
expect(result.score).toBe(0);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('clamps score to 0 minimum (negative weights only)', () => {
|
|
110
|
+
const result = assess({
|
|
111
|
+
prompt: 'do the thing',
|
|
112
|
+
hasParentPlan: true,
|
|
113
|
+
});
|
|
114
|
+
expect(result.score).toBe(0);
|
|
115
|
+
expect(result.classification).toBe('simple');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('clamps score to 100 maximum', () => {
|
|
119
|
+
const result = assess({
|
|
120
|
+
prompt: 'add authentication, migrate the DB, install new package, how should we design this, refactor across all modules',
|
|
121
|
+
filesEstimated: 10,
|
|
122
|
+
domains: ['vault', 'brain', 'planning'],
|
|
123
|
+
});
|
|
124
|
+
expect(result.score).toBeLessThanOrEqual(100);
|
|
125
|
+
expect(result.score).toBeGreaterThanOrEqual(0);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('parent context reduces complexity', () => {
|
|
129
|
+
const withoutParent = assess({
|
|
130
|
+
prompt: 'add authorization to the API',
|
|
131
|
+
filesEstimated: 4,
|
|
132
|
+
});
|
|
133
|
+
const withParent = assess({
|
|
134
|
+
prompt: 'add authorization to the API',
|
|
135
|
+
filesEstimated: 4,
|
|
136
|
+
hasParentPlan: true,
|
|
137
|
+
});
|
|
138
|
+
expect(withParent.score).toBeLessThan(withoutParent.score);
|
|
139
|
+
expect(signalByName(withParent, 'approach-already-described')!.triggered).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('parentIssueContext also reduces complexity', () => {
|
|
143
|
+
const result = assess({
|
|
144
|
+
prompt: 'add authorization to the API',
|
|
145
|
+
filesEstimated: 4,
|
|
146
|
+
parentIssueContext: 'Use middleware pattern as described in RFC-42',
|
|
147
|
+
});
|
|
148
|
+
expect(signalByName(result, 'approach-already-described')!.triggered).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('borderline score at exactly 40 is complex', () => {
|
|
152
|
+
// file-count (25) + new-dependencies (15) = 40
|
|
153
|
+
const result = assess({
|
|
154
|
+
prompt: 'install the redis package',
|
|
155
|
+
filesEstimated: 3,
|
|
156
|
+
});
|
|
157
|
+
expect(result.score).toBe(40);
|
|
158
|
+
expect(result.classification).toBe('complex');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('borderline score at 39 is simple', () => {
|
|
162
|
+
// file-count (25) + new-dependencies (15) + approach-described (-15) = 25
|
|
163
|
+
const result = assess({
|
|
164
|
+
prompt: 'install the redis package',
|
|
165
|
+
filesEstimated: 3,
|
|
166
|
+
hasParentPlan: true,
|
|
167
|
+
});
|
|
168
|
+
expect(result.score).toBeLessThan(40);
|
|
169
|
+
expect(result.classification).toBe('simple');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// ─── Individual Signals ─────────────────────────────────────────────
|
|
174
|
+
|
|
175
|
+
describe('assessTaskComplexity — individual signals', () => {
|
|
176
|
+
describe('file-count signal', () => {
|
|
177
|
+
it('triggers at 3 files', () => {
|
|
178
|
+
const result = assess({ prompt: 'task', filesEstimated: 3 });
|
|
179
|
+
expect(signalByName(result, 'file-count')!.triggered).toBe(true);
|
|
180
|
+
expect(signalByName(result, 'file-count')!.weight).toBe(25);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('does not trigger at 2 files', () => {
|
|
184
|
+
const result = assess({ prompt: 'task', filesEstimated: 2 });
|
|
185
|
+
expect(signalByName(result, 'file-count')!.triggered).toBe(false);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('does not trigger when no estimate provided', () => {
|
|
189
|
+
const result = assess({ prompt: 'task' });
|
|
190
|
+
expect(signalByName(result, 'file-count')!.triggered).toBe(false);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe('cross-cutting-keywords signal', () => {
|
|
195
|
+
it.each([
|
|
196
|
+
'add authentication',
|
|
197
|
+
'implement authorization',
|
|
198
|
+
'migrate the database',
|
|
199
|
+
'refactor across modules',
|
|
200
|
+
'handle cross-cutting concerns',
|
|
201
|
+
])('triggers for: "%s"', (prompt) => {
|
|
202
|
+
const result = assess({ prompt });
|
|
203
|
+
expect(signalByName(result, 'cross-cutting-keywords')!.triggered).toBe(true);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('does not trigger for benign text', () => {
|
|
207
|
+
const result = assess({ prompt: 'fix button alignment' });
|
|
208
|
+
expect(signalByName(result, 'cross-cutting-keywords')!.triggered).toBe(false);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('new-dependencies signal', () => {
|
|
213
|
+
it.each([
|
|
214
|
+
'add dependency for caching',
|
|
215
|
+
'install redis',
|
|
216
|
+
'new package for validation',
|
|
217
|
+
'npm install lodash',
|
|
218
|
+
])('triggers for: "%s"', (prompt) => {
|
|
219
|
+
const result = assess({ prompt });
|
|
220
|
+
expect(signalByName(result, 'new-dependencies')!.triggered).toBe(true);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('does not trigger for normal text', () => {
|
|
224
|
+
const result = assess({ prompt: 'update existing code' });
|
|
225
|
+
expect(signalByName(result, 'new-dependencies')!.triggered).toBe(false);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('design-decisions-needed signal', () => {
|
|
230
|
+
it.each([
|
|
231
|
+
'how should we handle caching',
|
|
232
|
+
'which approach for the API',
|
|
233
|
+
'design decision on storage',
|
|
234
|
+
'architectural decision for events',
|
|
235
|
+
'evaluate the trade-off between speed and accuracy',
|
|
236
|
+
])('triggers for: "%s"', (prompt) => {
|
|
237
|
+
const result = assess({ prompt });
|
|
238
|
+
expect(signalByName(result, 'design-decisions-needed')!.triggered).toBe(true);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
describe('approach-already-described signal', () => {
|
|
243
|
+
it('triggers with hasParentPlan', () => {
|
|
244
|
+
const result = assess({ prompt: 'task', hasParentPlan: true });
|
|
245
|
+
const signal = signalByName(result, 'approach-already-described')!;
|
|
246
|
+
expect(signal.triggered).toBe(true);
|
|
247
|
+
expect(signal.weight).toBe(-15);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('triggers with parentIssueContext', () => {
|
|
251
|
+
const result = assess({ prompt: 'task', parentIssueContext: 'Steps described here' });
|
|
252
|
+
expect(signalByName(result, 'approach-already-described')!.triggered).toBe(true);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('does not trigger with empty parentIssueContext', () => {
|
|
256
|
+
const result = assess({ prompt: 'task', parentIssueContext: ' ' });
|
|
257
|
+
expect(signalByName(result, 'approach-already-described')!.triggered).toBe(false);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
describe('multi-domain signal', () => {
|
|
262
|
+
it('triggers with 2+ domains', () => {
|
|
263
|
+
const result = assess({ prompt: 'task', domains: ['vault', 'brain'] });
|
|
264
|
+
expect(signalByName(result, 'multi-domain')!.triggered).toBe(true);
|
|
265
|
+
expect(signalByName(result, 'multi-domain')!.weight).toBe(5);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('does not trigger with single domain', () => {
|
|
269
|
+
const result = assess({ prompt: 'task', domains: ['vault'] });
|
|
270
|
+
expect(signalByName(result, 'multi-domain')!.triggered).toBe(false);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('does not trigger with no domains', () => {
|
|
274
|
+
const result = assess({ prompt: 'task' });
|
|
275
|
+
expect(signalByName(result, 'multi-domain')!.triggered).toBe(false);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// ─── Reasoning Output ───────────────────────────────────────────────
|
|
281
|
+
|
|
282
|
+
describe('assessTaskComplexity — reasoning', () => {
|
|
283
|
+
it('includes signal names in reasoning when triggered', () => {
|
|
284
|
+
const result = assess({ prompt: 'migrate the database', filesEstimated: 5 });
|
|
285
|
+
expect(result.reasoning).toContain('cross-cutting-keywords');
|
|
286
|
+
expect(result.reasoning).toContain('file-count');
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('provides fallback reasoning when nothing triggers', () => {
|
|
290
|
+
const result = assess({ prompt: 'fix typo' });
|
|
291
|
+
expect(result.reasoning).toContain('No complexity signals detected');
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('always returns 6 signals', () => {
|
|
295
|
+
const result = assess({ prompt: 'anything' });
|
|
296
|
+
expect(result.signals).toHaveLength(6);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Complexity Assessor — pure function that classifies tasks as simple or complex.
|
|
3
|
+
*
|
|
4
|
+
* Used by the planning module to decide whether a decomposed GH issue
|
|
5
|
+
* needs a full plan or can be executed directly.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ─── Types ──────────────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
export interface AssessmentInput {
|
|
11
|
+
/** User's task description. */
|
|
12
|
+
prompt: string;
|
|
13
|
+
/** Estimated number of files to touch. */
|
|
14
|
+
filesEstimated?: number;
|
|
15
|
+
/** GH issue body if available. */
|
|
16
|
+
parentIssueContext?: string;
|
|
17
|
+
/** Whether the approach is already described in a parent plan. */
|
|
18
|
+
hasParentPlan?: boolean;
|
|
19
|
+
/** Which domains are involved. */
|
|
20
|
+
domains?: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AssessmentSignal {
|
|
24
|
+
name: string;
|
|
25
|
+
weight: number;
|
|
26
|
+
triggered: boolean;
|
|
27
|
+
detail: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AssessmentResult {
|
|
31
|
+
classification: 'simple' | 'complex';
|
|
32
|
+
/** 0-100 complexity score. Threshold at 40. */
|
|
33
|
+
score: number;
|
|
34
|
+
signals: AssessmentSignal[];
|
|
35
|
+
/** One-line explanation. */
|
|
36
|
+
reasoning: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ─── Signal Detectors ───────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
const CROSS_CUTTING_PATTERNS = [
|
|
42
|
+
/\bauth(?:entication|orization)?\b/i,
|
|
43
|
+
/\bmigrat(?:e|ion|ing)\b/i,
|
|
44
|
+
/\brefactor(?:ing)?\s+across\b/i,
|
|
45
|
+
/\bcross[- ]cutting\b/i,
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const NEW_DEPENDENCY_PATTERNS = [
|
|
49
|
+
/\badd\s+dep(?:endency|endencies)?\b/i,
|
|
50
|
+
/\binstall\b/i,
|
|
51
|
+
/\bnew\s+package\b/i,
|
|
52
|
+
/\bnpm\s+install\b/i,
|
|
53
|
+
/\badd\s+(?:a\s+)?(?:new\s+)?(?:npm\s+)?package\b/i,
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const DESIGN_DECISION_PATTERNS = [
|
|
57
|
+
/\bhow\s+should\b/i,
|
|
58
|
+
/\bwhich\s+approach\b/i,
|
|
59
|
+
/\bdesign\s+decision\b/i,
|
|
60
|
+
/\barchitectur(?:e|al)\s+(?:decision|choice)\b/i,
|
|
61
|
+
/\btrade[- ]?off/i,
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
function detectFileCount(input: AssessmentInput): AssessmentSignal {
|
|
65
|
+
const files = input.filesEstimated ?? 0;
|
|
66
|
+
const triggered = files >= 3;
|
|
67
|
+
return {
|
|
68
|
+
name: 'file-count',
|
|
69
|
+
weight: 25,
|
|
70
|
+
triggered,
|
|
71
|
+
detail: triggered
|
|
72
|
+
? `Estimated ${files} files (≥3 threshold)`
|
|
73
|
+
: files > 0
|
|
74
|
+
? `Estimated ${files} file${files === 1 ? '' : 's'} (under threshold)`
|
|
75
|
+
: 'No file estimate provided',
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function detectCrossCutting(input: AssessmentInput): AssessmentSignal {
|
|
80
|
+
const text = input.prompt;
|
|
81
|
+
const match = CROSS_CUTTING_PATTERNS.find((p) => p.test(text));
|
|
82
|
+
return {
|
|
83
|
+
name: 'cross-cutting-keywords',
|
|
84
|
+
weight: 20,
|
|
85
|
+
triggered: !!match,
|
|
86
|
+
detail: match
|
|
87
|
+
? `Detected cross-cutting keyword: "${text.match(match)?.[0]}"`
|
|
88
|
+
: 'No cross-cutting keywords detected',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function detectNewDependencies(input: AssessmentInput): AssessmentSignal {
|
|
93
|
+
const text = input.prompt;
|
|
94
|
+
const match = NEW_DEPENDENCY_PATTERNS.find((p) => p.test(text));
|
|
95
|
+
return {
|
|
96
|
+
name: 'new-dependencies',
|
|
97
|
+
weight: 15,
|
|
98
|
+
triggered: !!match,
|
|
99
|
+
detail: match
|
|
100
|
+
? `Detected dependency signal: "${text.match(match)?.[0]}"`
|
|
101
|
+
: 'No new dependency signals detected',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function detectDesignDecisions(input: AssessmentInput): AssessmentSignal {
|
|
106
|
+
const text = input.prompt;
|
|
107
|
+
const match = DESIGN_DECISION_PATTERNS.find((p) => p.test(text));
|
|
108
|
+
return {
|
|
109
|
+
name: 'design-decisions-needed',
|
|
110
|
+
weight: 20,
|
|
111
|
+
triggered: !!match,
|
|
112
|
+
detail: match
|
|
113
|
+
? `Detected design decision signal: "${text.match(match)?.[0]}"`
|
|
114
|
+
: 'No design decision signals detected',
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function detectApproachDescribed(input: AssessmentInput): AssessmentSignal {
|
|
119
|
+
const hasContext = !!(input.hasParentPlan || input.parentIssueContext?.trim());
|
|
120
|
+
return {
|
|
121
|
+
name: 'approach-already-described',
|
|
122
|
+
weight: -15,
|
|
123
|
+
triggered: hasContext,
|
|
124
|
+
detail: hasContext
|
|
125
|
+
? 'Approach already described in parent plan or issue'
|
|
126
|
+
: 'No pre-existing approach context',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function detectMultiDomain(input: AssessmentInput): AssessmentSignal {
|
|
131
|
+
const domains = input.domains ?? [];
|
|
132
|
+
const triggered = domains.length >= 2;
|
|
133
|
+
return {
|
|
134
|
+
name: 'multi-domain',
|
|
135
|
+
weight: 5,
|
|
136
|
+
triggered,
|
|
137
|
+
detail: triggered
|
|
138
|
+
? `Involves ${domains.length} domains: ${domains.join(', ')}`
|
|
139
|
+
: domains.length === 1
|
|
140
|
+
? `Single domain: ${domains[0]}`
|
|
141
|
+
: 'No domains specified',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ─── Assessor ───────────────────────────────────────────────────────
|
|
146
|
+
|
|
147
|
+
const COMPLEXITY_THRESHOLD = 40;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Assess task complexity from structured input.
|
|
151
|
+
*
|
|
152
|
+
* Returns a classification (`simple` | `complex`), a numeric score (0-100),
|
|
153
|
+
* the individual signals that contributed, and a one-line reasoning string.
|
|
154
|
+
*
|
|
155
|
+
* Pure function — no side effects, no DB, no MCP calls.
|
|
156
|
+
*/
|
|
157
|
+
export function assessTaskComplexity(input: AssessmentInput): AssessmentResult {
|
|
158
|
+
const signals: AssessmentSignal[] = [
|
|
159
|
+
detectFileCount(input),
|
|
160
|
+
detectCrossCutting(input),
|
|
161
|
+
detectNewDependencies(input),
|
|
162
|
+
detectDesignDecisions(input),
|
|
163
|
+
detectApproachDescribed(input),
|
|
164
|
+
detectMultiDomain(input),
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
const rawScore = signals.reduce(
|
|
168
|
+
(sum, s) => sum + (s.triggered ? s.weight : 0),
|
|
169
|
+
0,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// Clamp to 0-100
|
|
173
|
+
const score = Math.max(0, Math.min(100, rawScore));
|
|
174
|
+
const classification = score >= COMPLEXITY_THRESHOLD ? 'complex' : 'simple';
|
|
175
|
+
|
|
176
|
+
const triggered = signals.filter((s) => s.triggered);
|
|
177
|
+
const reasoning =
|
|
178
|
+
triggered.length === 0
|
|
179
|
+
? 'No complexity signals detected — treating as simple task'
|
|
180
|
+
: `${classification === 'complex' ? 'Complex' : 'Simple'}: ${triggered.map((s) => s.name).join(', ')} (score ${score})`;
|
|
181
|
+
|
|
182
|
+
return { classification, score, signals, reasoning };
|
|
183
|
+
}
|
|
@@ -133,6 +133,29 @@ describe('createAdminOps', () => {
|
|
|
133
133
|
expect(grouped.vault).toContain('vault_search');
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
+
it('returns routing hints in grouped mode', async () => {
|
|
137
|
+
const op = findOp(ops, 'admin_tool_list');
|
|
138
|
+
const allOps = [
|
|
139
|
+
{ name: 'admin_health', description: 'Health check', auth: 'read' },
|
|
140
|
+
];
|
|
141
|
+
const result = (await op.handler({ _allOps: allOps })) as Record<string, unknown>;
|
|
142
|
+
const routing = result.routing as Record<string, string>;
|
|
143
|
+
expect(routing).toBeDefined();
|
|
144
|
+
expect(typeof routing).toBe('object');
|
|
145
|
+
// Spot-check a few known intent signals
|
|
146
|
+
expect(routing['search knowledge']).toBe('vault.search_intelligent');
|
|
147
|
+
expect(routing['plan this']).toBe('plan.create_plan');
|
|
148
|
+
expect(routing['health check']).toBe('admin.admin_health');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('returns routing hints in fallback mode', async () => {
|
|
152
|
+
const op = findOp(ops, 'admin_tool_list');
|
|
153
|
+
const result = (await op.handler({})) as Record<string, unknown>;
|
|
154
|
+
const routing = result.routing as Record<string, string>;
|
|
155
|
+
expect(routing).toBeDefined();
|
|
156
|
+
expect(Object.keys(routing).length).toBeGreaterThan(0);
|
|
157
|
+
});
|
|
158
|
+
|
|
136
159
|
it('returns verbose format when verbose=true', async () => {
|
|
137
160
|
const op = findOp(ops, 'admin_tool_list');
|
|
138
161
|
const allOps = [{ name: 'admin_health', description: 'Health check', auth: 'read' }];
|
package/src/runtime/admin-ops.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { join, dirname } from 'node:path';
|
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import type { OpDefinition } from '../facades/types.js';
|
|
12
12
|
import type { AgentRuntime } from './types.js';
|
|
13
|
+
import { ENGINE_MODULE_MANIFEST } from '../engine/module-manifest.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Resolve the @soleri/core package.json version.
|
|
@@ -113,6 +114,7 @@ export function createAdminOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
113
114
|
return {
|
|
114
115
|
count: allOps.length,
|
|
115
116
|
ops: grouped,
|
|
117
|
+
routing: buildRoutingHints(),
|
|
116
118
|
};
|
|
117
119
|
}
|
|
118
120
|
// Fallback — just describe admin ops
|
|
@@ -130,6 +132,7 @@ export function createAdminOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
130
132
|
'admin_diagnostic',
|
|
131
133
|
],
|
|
132
134
|
},
|
|
135
|
+
routing: buildRoutingHints(),
|
|
133
136
|
};
|
|
134
137
|
},
|
|
135
138
|
},
|
|
@@ -321,6 +324,22 @@ function formatBytes(bytes: number): string {
|
|
|
321
324
|
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
322
325
|
}
|
|
323
326
|
|
|
327
|
+
/**
|
|
328
|
+
* Build a flat routing map from ENGINE_MODULE_MANIFEST intentSignals.
|
|
329
|
+
* Keys are natural-language phrases, values are `{suffix}.{op}` paths.
|
|
330
|
+
*/
|
|
331
|
+
function buildRoutingHints(): Record<string, string> {
|
|
332
|
+
const routing: Record<string, string> = {};
|
|
333
|
+
for (const mod of ENGINE_MODULE_MANIFEST) {
|
|
334
|
+
if (mod.intentSignals) {
|
|
335
|
+
for (const [phrase, op] of Object.entries(mod.intentSignals)) {
|
|
336
|
+
routing[phrase] = `${mod.suffix}.${op}`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return routing;
|
|
341
|
+
}
|
|
342
|
+
|
|
324
343
|
function formatUptime(seconds: number): string {
|
|
325
344
|
if (seconds < 60) return `${seconds}s`;
|
|
326
345
|
const minutes = Math.floor(seconds / 60);
|