@krisada-m/ksd-intelligence 0.0.0-stage → 1.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.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -2
  3. package/dist/adapters/agy/skills.js +252 -0
  4. package/dist/adapters/cli/check-changed.js +3 -0
  5. package/dist/adapters/cli/main.js +1002 -0
  6. package/dist/adapters/cli/policy-bin.js +10 -0
  7. package/dist/adapters/cli/review-verdict.js +3 -0
  8. package/dist/adapters/omp/extension.js +893 -0
  9. package/dist/adapters/omp/skills.js +130 -0
  10. package/dist/adapters/ui/hud.js +318 -0
  11. package/dist/adapters/ui/tree.js +460 -0
  12. package/dist/core/audit/index.js +2 -0
  13. package/dist/core/audit/log.js +505 -0
  14. package/dist/core/audit/summary.js +188 -0
  15. package/dist/core/changes/changes.js +591 -0
  16. package/dist/core/changes/git.js +266 -0
  17. package/dist/core/changes/plan.js +109 -0
  18. package/dist/core/changes/render.js +356 -0
  19. package/dist/core/engine/build.js +178 -0
  20. package/dist/core/engine/child.js +389 -0
  21. package/dist/core/engine/host.js +206 -0
  22. package/dist/core/engine/lock.js +133 -0
  23. package/dist/core/engine/protocol.js +43 -0
  24. package/dist/core/engine/runtime.js +44 -0
  25. package/dist/core/engine/status.js +381 -0
  26. package/dist/core/engine/typescript.js +194 -0
  27. package/dist/core/engine/workspace.js +72 -0
  28. package/dist/core/graph/graph.js +127 -0
  29. package/dist/core/graph/limits.js +16 -0
  30. package/dist/core/impact/query.js +1292 -0
  31. package/dist/core/impact/render.js +590 -0
  32. package/dist/core/impact/session.js +694 -0
  33. package/dist/core/indexing/declarations.js +455 -0
  34. package/dist/core/indexing/differential.js +345 -0
  35. package/dist/core/indexing/doctor.js +120 -0
  36. package/dist/core/indexing/indexer.js +792 -0
  37. package/dist/core/indexing/keys.js +451 -0
  38. package/dist/core/indexing/lexical.js +212 -0
  39. package/dist/core/indexing/packages.js +57 -0
  40. package/dist/core/indexing/program.js +171 -0
  41. package/dist/core/indexing/resolve.js +1004 -0
  42. package/dist/core/indexing/stamp.js +52 -0
  43. package/dist/core/indexing/surface.js +335 -0
  44. package/dist/core/indexing/ui-progress.js +37 -0
  45. package/dist/core/indexing/verify.js +76 -0
  46. package/dist/core/kernel/config.js +383 -0
  47. package/dist/core/kernel/glob.js +105 -0
  48. package/dist/core/kernel/guards.js +4 -0
  49. package/dist/core/kernel/types.js +3 -0
  50. package/dist/core/kernel/verdict.js +142 -0
  51. package/dist/core/knowledge/anchors.js +139 -0
  52. package/dist/core/knowledge/knowledge.js +95 -0
  53. package/dist/core/knowledge/learning.js +102 -0
  54. package/dist/core/knowledge/render.js +76 -0
  55. package/dist/core/knowledge/store.js +109 -0
  56. package/dist/core/knowledge/yaml.js +87 -0
  57. package/dist/core/search/lexical.js +382 -0
  58. package/dist/core/search/render.js +98 -0
  59. package/dist/core/search/segments.js +118 -0
  60. package/dist/core/verify/parse.js +127 -0
  61. package/dist/core/verify/render.js +67 -0
  62. package/dist/core/verify/report.js +40 -0
  63. package/dist/core/verify/revision.js +79 -0
  64. package/dist/core/verify/run.js +117 -0
  65. package/dist/core/verify/store.js +66 -0
  66. package/dist/core/verify/verify.js +173 -0
  67. package/dist/core/workspace/init.js +267 -0
  68. package/dist/core/workspace/probe.js +56 -0
  69. package/dist/core/workspace/scan.js +420 -0
  70. package/dist/index.js +20 -0
  71. package/dist/policy/change-scope.js +500 -0
  72. package/dist/policy/check-changed.js +40 -0
  73. package/dist/policy/config.js +106 -0
  74. package/dist/policy/dist/policy.d.ts +17 -0
  75. package/dist/policy/dist/policy.js +147 -0
  76. package/dist/policy/dist/runtime.d.ts +40 -0
  77. package/dist/policy/dist/runtime.js +75 -0
  78. package/dist/policy/dist/sdlc.d.ts +7 -0
  79. package/dist/policy/dist/sdlc.js +27 -0
  80. package/dist/policy/eslint-rules/index.js +107 -0
  81. package/dist/policy/index.d.ts +2 -0
  82. package/dist/policy/index.js +241 -0
  83. package/dist/policy/package.json +33 -0
  84. package/dist/policy/policy.d.ts +2 -0
  85. package/dist/policy/policy.js +2 -0
  86. package/dist/policy/review-verdict.js +262 -0
  87. package/dist/policy/sdlc.js +2 -0
  88. package/dist/storage/records.js +245 -0
  89. package/dist/storage/sqlite.js +314 -0
  90. package/dist/workflow/catalog.js +69 -0
  91. package/dist/workflow/classify.js +55 -0
  92. package/dist/workflow/loader.js +140 -0
  93. package/dist/workflow/packs.js +469 -0
  94. package/dist/workflow/registry.js +359 -0
  95. package/dist/workflow/render.js +61 -0
  96. package/dist/workflow/router.js +141 -0
  97. package/dist/workflow/sources.js +229 -0
  98. package/dist/workflow/types.js +44 -0
  99. package/dist/workflow/updates.js +532 -0
  100. package/package.json +74 -4
  101. package/scripts/agy-mcp.mjs +27 -0
  102. package/scripts/mcp/stdio.mjs +304 -0
  103. package/scripts/mcp/tools.mjs +451 -0
  104. package/skills/ksd-intelligence/SKILL.md +54 -0
  105. package/skills/matt-sdlc/SKILL.md +42 -0
  106. package/skills/osmani-quality/SKILL.md +38 -0
  107. package/skills/poteto-mode/SKILL.md +40 -0
  108. package/skills/pstack-analysis/SKILL.md +36 -0
  109. package/skills.lock.json +71 -0
  110. package/skills.registry.json +181 -0
@@ -0,0 +1,130 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join, resolve } from 'node:path';
4
+ import { defaultSkillsDir, discoverSkillsForPlatform, } from '../../workflow/packs.js';
5
+ // Inspects OMP's profile, RULES.md, config, and skill directories read-only without mutating user state.
6
+ export function detectOmpEnvironment(options = {}) {
7
+ const env = options.env ?? process.env;
8
+ const realHome = options.homeDir ?? env.SNAP_REAL_HOME ?? env.HOME ?? homedir();
9
+ const profile = options.profile ?? env.OMP_PROFILE ?? 'default';
10
+ const agentDir = resolve(options.agentDir ??
11
+ env.PI_CODING_AGENT_DIR ??
12
+ env.OMP_AGENT_DIR ??
13
+ (profile !== 'default'
14
+ ? join(realHome, '.omp', 'profiles', profile, 'agent')
15
+ : join(realHome, '.omp', 'agent')));
16
+ const projectDir = options.workspaceRoot ? resolve(options.workspaceRoot, '.omp') : null;
17
+ const projectSkillsDir = projectDir ? join(projectDir, 'skills') : null;
18
+ const userSkillsDir = join(agentDir, 'skills');
19
+ const sharedSkillsDir = resolve(realHome, '.agents', 'skills');
20
+ const pluginSkillsDir = resolve(options.skillsDir ?? defaultSkillsDir());
21
+ const rulesFiles = [];
22
+ if (projectDir) {
23
+ const projectRules = join(projectDir, 'RULES.md');
24
+ rulesFiles.push({ scope: 'project', path: projectRules, exists: existsSync(projectRules) });
25
+ }
26
+ const userRules = join(agentDir, 'RULES.md');
27
+ rulesFiles.push({ scope: 'user', path: userRules, exists: existsSync(userRules) });
28
+ const configFiles = [];
29
+ if (projectDir) {
30
+ const projectSettings = join(projectDir, 'settings.json');
31
+ configFiles.push({
32
+ kind: 'settings.json',
33
+ scope: 'project',
34
+ path: projectSettings,
35
+ exists: existsSync(projectSettings),
36
+ });
37
+ }
38
+ for (const kind of ['config.yml', 'settings.json', 'engineering-proxy.json']) {
39
+ const file = join(agentDir, kind);
40
+ configFiles.push({ kind, scope: 'user', path: file, exists: existsSync(file) });
41
+ }
42
+ return {
43
+ realHome,
44
+ profile,
45
+ agentDir,
46
+ rulesFiles,
47
+ configFiles,
48
+ projectSkillsDir,
49
+ userSkillsDir,
50
+ sharedSkillsDir,
51
+ pluginSkillsDir,
52
+ };
53
+ }
54
+ // Native OMP skill discovery mirroring `@oh-my-pi/pi-coding-agent` precedence:
55
+ // project `.omp/skills` > active profile/user `<agentDir>/skills` > shared `~/.agents/skills` > marketplace plugin `skills/`.
56
+ // Skills with `disable-model-invocation: true` (e.g. `poteto-mode`) remain in `explicitOnly`.
57
+ export async function discoverOmpSkills(options = {}) {
58
+ const environment = detectOmpEnvironment({
59
+ workspaceRoot: options.workspaceRoot,
60
+ profile: options.profile,
61
+ agentDir: options.agentDir,
62
+ skillsDir: options.skillsDir,
63
+ env: options.env,
64
+ homeDir: options.homeDir,
65
+ });
66
+ const roots = [];
67
+ const seenPaths = new Set();
68
+ const addRoot = (root) => {
69
+ const key = resolve(root.path);
70
+ if (seenPaths.has(key))
71
+ return;
72
+ seenPaths.add(key);
73
+ roots.push(root);
74
+ };
75
+ if (environment.projectSkillsDir) {
76
+ addRoot({
77
+ path: environment.projectSkillsDir,
78
+ label: 'omp:project',
79
+ optional: true,
80
+ });
81
+ }
82
+ if (options.userSkillsDir) {
83
+ addRoot({
84
+ path: options.userSkillsDir,
85
+ label: 'omp:user',
86
+ optional: true,
87
+ allowExternalSymlinks: true,
88
+ auditContent: false,
89
+ });
90
+ }
91
+ else if (options.detectHostPaths || options.profile || options.agentDir) {
92
+ addRoot({
93
+ path: environment.userSkillsDir,
94
+ label: environment.profile === 'default' ? 'omp:user' : `omp:profile:${environment.profile}`,
95
+ optional: true,
96
+ allowExternalSymlinks: true,
97
+ auditContent: false,
98
+ });
99
+ }
100
+ if (options.sharedSkillsDir) {
101
+ addRoot({
102
+ path: options.sharedSkillsDir,
103
+ label: 'omp:shared',
104
+ optional: true,
105
+ allowExternalSymlinks: true,
106
+ auditContent: false,
107
+ });
108
+ }
109
+ else if (options.detectHostPaths) {
110
+ addRoot({
111
+ path: environment.sharedSkillsDir,
112
+ label: 'omp:shared',
113
+ optional: true,
114
+ allowExternalSymlinks: true,
115
+ auditContent: false,
116
+ });
117
+ }
118
+ addRoot({
119
+ path: environment.pluginSkillsDir,
120
+ label: 'omp:plugin:ksd-intelligence',
121
+ optional: false,
122
+ auditContent: true,
123
+ });
124
+ const discovery = await discoverSkillsForPlatform({
125
+ platform: 'omp',
126
+ roots,
127
+ requireCatalog: options.requireCatalog ?? true,
128
+ });
129
+ return { ...discovery, environment };
130
+ }
@@ -0,0 +1,318 @@
1
+ const blocks = ['', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'];
2
+ const sparkBlocks = '⣀⣄⣤⣦⣶⣷⣿';
3
+ const phaseOrder = ['scan', 'program', 'extract', 'resolve', 'verify', 'publish'];
4
+ const reset = '\x1b[0m';
5
+ function safe(text) {
6
+ return text.replace(/[\x00-\x1f\x7f-\x9f]/g, ' ');
7
+ }
8
+ function duration(ms) {
9
+ if (!Number.isFinite(ms) || ms < 0)
10
+ return '?';
11
+ return `${Number((ms / 1000).toFixed(2))}s`;
12
+ }
13
+ function width(text) {
14
+ let size = 0;
15
+ for (const char of text) {
16
+ const point = char.codePointAt(0) ?? 0;
17
+ if (/\p{Mark}/u.test(char) || point === 0x200d || point === 0xfe0f)
18
+ continue;
19
+ size +=
20
+ point >= 0x1100 &&
21
+ (point <= 0x11ff ||
22
+ (point >= 0x2e80 && point <= 0xa4cf) ||
23
+ (point >= 0xac00 && point <= 0xd7ff) ||
24
+ (point >= 0xf900 && point <= 0xfaff) ||
25
+ (point >= 0xfe10 && point <= 0xfe6f) ||
26
+ (point >= 0xff01 && point <= 0xff60) ||
27
+ (point >= 0xffe0 && point <= 0xffe6) ||
28
+ (point >= 0x1f300 && point <= 0x1faff))
29
+ ? 2
30
+ : 1;
31
+ }
32
+ return size;
33
+ }
34
+ function fit(text, columns) {
35
+ let result = '';
36
+ let used = 0;
37
+ for (const char of safe(text)) {
38
+ const size = width(char);
39
+ if (used + size > columns)
40
+ break;
41
+ result += char;
42
+ used += size;
43
+ }
44
+ return result;
45
+ }
46
+ function colorTier(env) {
47
+ if (env.COLORTERM === 'truecolor' || env.COLORTERM === '24bit')
48
+ return 'truecolor';
49
+ return env.TERM?.includes('256color') ? '256' : '16';
50
+ }
51
+ function bar(fraction, length, tier, ascii) {
52
+ const eighths = Math.max(0, Math.min(length * 8, Math.round(fraction * length * 8)));
53
+ const full = Math.floor(eighths / 8);
54
+ const rest = eighths % 8;
55
+ if (ascii || tier === '16')
56
+ return `${'#'.repeat(full)}${rest ? ':' : ''}${'.'.repeat(length - full - (rest ? 1 : 0))}`;
57
+ const filled = `${'█'.repeat(full)}${blocks[rest] ?? ''}`;
58
+ if (tier === 'none')
59
+ return filled + '·'.repeat(length - full - (rest ? 1 : 0));
60
+ const ramp = tier === 'truecolor'
61
+ ? [
62
+ '\x1b[38;2;67;190;113m',
63
+ '\x1b[38;2;76;154;240m',
64
+ '\x1b[38;2;163;113;228m',
65
+ '\x1b[38;2;237;119;171m',
66
+ ]
67
+ : ['\x1b[38;5;77m', '\x1b[38;5;75m', '\x1b[38;5;141m', '\x1b[38;5;212m'];
68
+ let colored = '';
69
+ for (let index = 0; index < filled.length; index++) {
70
+ colored += `${ramp[Math.min(3, Math.floor((index * 4) / length))]}${filled[index]}`;
71
+ }
72
+ return `${colored}${reset}${'·'.repeat(length - full - (rest ? 1 : 0))}`;
73
+ }
74
+ function spark(samples, ascii) {
75
+ if (!samples.length)
76
+ return ascii ? '.' : '⣀';
77
+ const max = Math.max(1, ...samples);
78
+ return samples
79
+ .map((sample) => {
80
+ const index = Math.min(6, Math.floor((sample * 7) / max));
81
+ return ascii ? '.:-=+*#'[index] : sparkBlocks[index];
82
+ })
83
+ .join('');
84
+ }
85
+ function color(text, code, enabled) {
86
+ return enabled ? `\x1b[${code}m${text}${reset}` : text;
87
+ }
88
+ export function openHud(options) {
89
+ const { stream, env } = options;
90
+ if (!stream.isTTY ||
91
+ options.plain ||
92
+ options.json ||
93
+ 'NO_COLOR' in env ||
94
+ env.TERM === 'dumb' ||
95
+ 'CI' in env ||
96
+ env.EI_NO_ANIMATION === '1')
97
+ return undefined;
98
+ const tier = colorTier(env);
99
+ const ascii = tier === '16' ||
100
+ env.EI_ASCII === '1' ||
101
+ !/utf-?8/i.test(`${env.LC_ALL ?? env.LC_CTYPE ?? env.LANG ?? ''}`);
102
+ const now = options.now ?? Date.now;
103
+ const started = now();
104
+ const phases = new Map();
105
+ const samples = [];
106
+ let current;
107
+ let observedPhase;
108
+ const observations = [];
109
+ let latestRate = 0;
110
+ let drawnAt = -Infinity;
111
+ let lines = 0;
112
+ let timer;
113
+ let closed = false;
114
+ let cursorHidden = false;
115
+ function erase() {
116
+ if (!lines)
117
+ return;
118
+ stream.write(`\x1b[${lines}A`);
119
+ for (let index = 0; index < lines; index++)
120
+ stream.write('\r\x1b[2K\x1b[1B');
121
+ stream.write(`\x1b[${lines}A`);
122
+ lines = 0;
123
+ }
124
+ function draw() {
125
+ if (closed || !current)
126
+ return;
127
+ const columns = Math.max(20, stream.columns || 80);
128
+ const narrow = columns < 60;
129
+ const glyph = ascii ? ['-', '>', '+'] : ['◇', '◈', '◆'];
130
+ const phaseNames = options.command === 'index'
131
+ ? [...new Set([...phaseOrder, ...phases.keys()])]
132
+ : [...phases.keys()];
133
+ const currentIndex = phaseNames.indexOf(current.phase);
134
+ const prefix = `${ascii ? '|' : '▌'}ei ${options.command} `;
135
+ const suffix = `${current.kind ? ` · ${current.kind}` : ''} ${duration(now() - started)}`;
136
+ const heading = `${prefix}${fit(options.repo, Math.max(0, columns - width(prefix) - width(suffix)))}${suffix}`;
137
+ const body = [heading];
138
+ if (!narrow && (options.previous || (current.kind === 'cold' && current.reason)))
139
+ body.push(` ${options.previous ? `last run ${duration(options.previous.durationMs)}` : ''}${current.kind === 'cold' && current.reason ? ` · why: ${safe(current.reason)}` : ''}`);
140
+ if (!narrow)
141
+ body.push('');
142
+ for (const [index, phase] of phaseNames.entries()) {
143
+ if (narrow && phase !== current.phase)
144
+ continue;
145
+ const event = phases.get(phase);
146
+ let status = 0;
147
+ if (index === currentIndex)
148
+ status = 1;
149
+ if (index < currentIndex && event)
150
+ status = 2;
151
+ const done = event?.done;
152
+ const total = event?.total;
153
+ const known = done !== undefined &&
154
+ total !== undefined &&
155
+ total > 0 &&
156
+ Number.isFinite(done) &&
157
+ Number.isFinite(total);
158
+ let fraction = status === 2 ? 1 : 0;
159
+ if (known)
160
+ fraction = Math.min(1, Math.max(0, done) / total);
161
+ let beam = bar(fraction, narrow ? 10 : 16, tier, ascii);
162
+ if (!known && status === 1) {
163
+ const length = narrow || ascii ? 10 : 16;
164
+ const position = Math.floor(now() / 100) % length;
165
+ const dot = ascii ? '.' : '·';
166
+ beam = `${dot.repeat(position)}${ascii ? '#' : '█'}${dot.repeat(length - position - 1)}`;
167
+ }
168
+ let count = '';
169
+ if (known)
170
+ count = `${Math.max(0, done).toLocaleString('en-US')}/${total.toLocaleString('en-US')}`;
171
+ if (!known && status === 2)
172
+ count = 'ok';
173
+ if (!known && status === 1)
174
+ count = 'building';
175
+ const label = ` ${glyph[status]} ${phase.padEnd(8)} ${beam} ${count}`;
176
+ body.push(label);
177
+ }
178
+ if (!narrow)
179
+ body.push('', samples.length
180
+ ? ` files/s ${spark(samples, ascii)} ${Math.round(latestRate).toLocaleString('en-US')}`
181
+ : ' files/s measuring');
182
+ if (current.file)
183
+ body.push(` ${ascii ? '>' : '›'} ${safe(current.file)}`);
184
+ erase();
185
+ if (!cursorHidden) {
186
+ stream.write('\x1b[?25l');
187
+ cursorHidden = true;
188
+ }
189
+ for (const line of body)
190
+ stream.write(`\r\x1b[2K${fitAnsi(line, columns)}\n`);
191
+ lines = body.length;
192
+ drawnAt = now();
193
+ timer = setTimeout(draw, 100);
194
+ timer.unref();
195
+ }
196
+ function update(event) {
197
+ if (closed)
198
+ return;
199
+ const time = now();
200
+ if (event.done !== undefined && Number.isFinite(event.done) && event.done >= 0) {
201
+ if (observedPhase !== event.phase ||
202
+ event.done < (observations[observations.length - 1]?.count ?? 0)) {
203
+ observations.length = 0;
204
+ observedPhase = event.phase;
205
+ }
206
+ const baseline = observations[0];
207
+ if (baseline && time > baseline.time && event.done >= baseline.count) {
208
+ latestRate = ((event.done - baseline.count) * 1000) / (time - baseline.time);
209
+ samples.push(latestRate);
210
+ if (samples.length > 24)
211
+ samples.shift();
212
+ }
213
+ observations.push({ count: event.done, time });
214
+ while (observations.length > 2 && time - (observations[1]?.time ?? time) > 2000)
215
+ observations.shift();
216
+ }
217
+ phases.set(event.phase, event);
218
+ current = event;
219
+ if (time - drawnAt < 100)
220
+ return;
221
+ clearTimeout(timer);
222
+ timer = undefined;
223
+ draw();
224
+ }
225
+ return {
226
+ get throughput() {
227
+ return samples;
228
+ },
229
+ update,
230
+ close() {
231
+ if (closed)
232
+ return;
233
+ closed = true;
234
+ clearTimeout(timer);
235
+ erase();
236
+ if (cursorHidden)
237
+ stream.write('\x1b[?25h');
238
+ },
239
+ };
240
+ }
241
+ // Width is measured on visible characters, not ANSI colour controls.
242
+ function fitAnsi(line, columns) {
243
+ const parts = line.split(/(\x1b\[[\d;]*m)/g);
244
+ let remaining = columns;
245
+ let result = '';
246
+ for (const part of parts) {
247
+ if (part.startsWith('\x1b[')) {
248
+ result += part;
249
+ continue;
250
+ }
251
+ const clipped = fit(part, remaining);
252
+ result += clipped;
253
+ remaining -= width(clipped);
254
+ if (remaining <= 0)
255
+ break;
256
+ }
257
+ return line.includes('\x1b[') ? `${result}${reset}` : result;
258
+ }
259
+ export function renderHudSummary(input) {
260
+ const ascii = input.ascii ?? false;
261
+ const columns = Math.max(20, input.columns ?? 80);
262
+ const enabled = input.color === true;
263
+ const success = input.outcome !== 'failed';
264
+ let mark = ascii ? 'ok' : '◆';
265
+ if (!success)
266
+ mark = ascii ? 'x' : '✗';
267
+ const name = `${input.command} ${input.outcome}`;
268
+ const diff = input.previous && success && Number.isFinite(input.previous.durationMs)
269
+ ? input.durationMs - input.previous.durationMs
270
+ : undefined;
271
+ let comparison = '';
272
+ if (diff !== undefined) {
273
+ let sign = '+';
274
+ if (diff < 0)
275
+ sign = ascii ? '-' : '−';
276
+ comparison = ` ${sign}${duration(Math.abs(diff))} vs last`;
277
+ }
278
+ const count = input.files === undefined ? '' : ` · ${input.files.toLocaleString('en-US')} files`;
279
+ const header = `${mark} ${name}${input.kind ? ` ${input.kind}` : ''}${count} · ${duration(input.durationMs)}${comparison}`;
280
+ const lines = [color(fit(header, columns), success ? '32' : '31', enabled)];
281
+ if (input.reason)
282
+ lines.push(` ${safe(input.reason)}`);
283
+ if (input.drift)
284
+ lines.push(` drift ${safe(input.drift)}`);
285
+ if (input.activeIndex && !success)
286
+ lines.push(` in use ${safe(input.activeIndex)}`);
287
+ const phases = input.phases?.filter((phase) => Number.isFinite(phase.durationMs) && phase.durationMs >= 0) ??
288
+ [];
289
+ const totalTime = phases.reduce((sum, phase) => sum + phase.durationMs, 0);
290
+ if (success && phases.length && totalTime > 0) {
291
+ const size = Math.min(24, columns - 12);
292
+ let spent = 0;
293
+ const segments = phases.map((phase, index) => {
294
+ const start = Math.round((spent / totalTime) * size);
295
+ spent += phase.durationMs;
296
+ const end = index === phases.length - 1 ? size : Math.round((spent / totalTime) * size);
297
+ const ramp = ['32', '34', '35', '95'];
298
+ let stroke = index % 2 ? '─' : '━';
299
+ if (ascii)
300
+ stroke = index % 2 ? '-' : '=';
301
+ return color(stroke.repeat(Math.max(0, end - start)), ramp[index % ramp.length] ?? '32', enabled);
302
+ });
303
+ lines.push('', ` timeline ${segments.join('')}`, ` ${phases.map((phase) => safe(phase.phase)).join(' ')}`);
304
+ }
305
+ if (success && input.throughput?.length)
306
+ lines.push(` files/s ${spark(input.throughput, ascii)} ${Math.round(input.throughput[input.throughput.length - 1] ?? 0).toLocaleString('en-US')}`);
307
+ if (success &&
308
+ input.indexed !== undefined &&
309
+ input.outsideScope !== undefined &&
310
+ input.indexed + input.outsideScope > 0) {
311
+ const percentage = Math.round((100 * input.indexed) / (input.indexed + input.outsideScope));
312
+ lines.push(` coverage ${bar(input.indexed / (input.indexed + input.outsideScope), Math.min(16, columns - 15), enabled ? '256' : 'none', ascii)} ${percentage}%`);
313
+ lines.push(` ${input.indexed.toLocaleString('en-US')} indexed · ${input.outsideScope.toLocaleString('en-US')} outside scope${input.errors === undefined ? '' : ` · ${input.errors.toLocaleString('en-US')} errors`}`);
314
+ }
315
+ if (input.next)
316
+ lines.push('', ` ${ascii ? '>' : '›'} ${safe(input.next)}`);
317
+ return `${lines.map((line) => fitAnsi(line, columns)).join('\n')}\n`;
318
+ }