|
| 1 | +/** |
| 2 | + * MVI _next directive helpers for progressive disclosure. |
| 3 | + * |
| 4 | + * When CLEO returns results in minimal MVI mode, `_next` provides a map of |
| 5 | + * available follow-up operations the agent can take. This enables progressive |
| 6 | + * disclosure: agents get lean results and can drill deeper only when needed. |
| 7 | + * |
| 8 | + * @example |
| 9 | + * ```json |
| 10 | + * {"id": "T042", "title": "Fix auth", "status": "active", |
| 11 | + * "_next": {"full": "cleo show T042", "children": "cleo find --parent T042"}} |
| 12 | + * ``` |
| 13 | + * |
| 14 | + * @task T-MVI-06 |
| 15 | + */ |
| 16 | + |
| 17 | +/** Map of follow-up operation names to CLI command strings. */ |
| 18 | +export type NextDirectives = Record<string, string>; |
| 19 | + |
| 20 | +/** |
| 21 | + * Build `_next` directives for a full task detail result (tasks.show). |
| 22 | + * |
| 23 | + * @param taskId - The task ID to generate directives for |
| 24 | + * @returns A map of available follow-up operations |
| 25 | + */ |
| 26 | +export function taskShowNext(taskId: string): NextDirectives { |
| 27 | + return { |
| 28 | + full: `cleo show ${taskId} --mvi full`, |
| 29 | + children: `cleo find --parent ${taskId}`, |
| 30 | + deps: `cleo deps ${taskId}`, |
| 31 | + }; |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | + * Build `_next` directives for a task in a list or find result. |
| 36 | + * |
| 37 | + * @param taskId - The task ID to generate directives for |
| 38 | + * @returns A map of available follow-up operations |
| 39 | + */ |
| 40 | +export function taskListItemNext(taskId: string): NextDirectives { |
| 41 | + return { |
| 42 | + show: `cleo show ${taskId}`, |
| 43 | + }; |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | + * Build `_next` directives for a session in a list or find result. |
| 48 | + * |
| 49 | + * @param sessionId - The session ID to generate directives for |
| 50 | + * @returns A map of available follow-up operations |
| 51 | + */ |
| 52 | +export function sessionListItemNext(sessionId: string): NextDirectives { |
| 53 | + return { |
| 54 | + show: `cleo session show ${sessionId}`, |
| 55 | + serialize: `cleo session serialize ${sessionId}`, |
| 56 | + }; |
| 57 | +} |
| 58 | + |
| 59 | +/** |
| 60 | + * Build `_next` directives for a session start result. |
| 61 | + * |
| 62 | + * @returns A map of available follow-up operations after starting a session |
| 63 | + */ |
| 64 | +export function sessionStartNext(): NextDirectives { |
| 65 | + return { |
| 66 | + current: 'cleo current', |
| 67 | + stop: 'cleo session end', |
| 68 | + }; |
| 69 | +} |
| 70 | + |
| 71 | +/** |
| 72 | + * Build `_next` directives for a memory search (find) hit. |
| 73 | + * |
| 74 | + * @param entryId - The brain entry ID to generate directives for |
| 75 | + * @returns A map of available follow-up operations |
| 76 | + */ |
| 77 | +export function memoryFindHitNext(entryId: string): NextDirectives { |
| 78 | + return { |
| 79 | + fetch: `cleo memory fetch ${entryId}`, |
| 80 | + }; |
| 81 | +} |
0 commit comments