@orbitpanel/cli 1.8.0 → 1.10.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/dist/lib/command-router.js +37 -1
- package/dist/lib/command-router.js.map +1 -1
- package/dist/lib/info-engine.d.ts +34 -24
- package/dist/lib/info-engine.js +53 -36
- package/dist/lib/info-engine.js.map +1 -1
- package/dist/lib/intelligence/agent-prompt.d.ts +28 -0
- package/dist/lib/intelligence/agent-prompt.js +155 -0
- package/dist/lib/intelligence/agent-prompt.js.map +1 -0
- package/dist/lib/intelligence/capability-map.d.ts +53 -0
- package/dist/lib/intelligence/capability-map.js +266 -0
- package/dist/lib/intelligence/capability-map.js.map +1 -0
- package/dist/lib/intelligence/chat-enrichment.d.ts +32 -0
- package/dist/lib/intelligence/chat-enrichment.js +130 -0
- package/dist/lib/intelligence/chat-enrichment.js.map +1 -0
- package/dist/lib/intelligence/context-packet.d.ts +157 -0
- package/dist/lib/intelligence/context-packet.js +129 -0
- package/dist/lib/intelligence/context-packet.js.map +1 -0
- package/dist/lib/intelligence/diagnose-wiring.d.ts +20 -0
- package/dist/lib/intelligence/diagnose-wiring.js +157 -0
- package/dist/lib/intelligence/diagnose-wiring.js.map +1 -0
- package/dist/lib/intelligence/diagnose.d.ts +116 -0
- package/dist/lib/intelligence/diagnose.js +312 -0
- package/dist/lib/intelligence/diagnose.js.map +1 -0
- package/dist/lib/session-summary-format.d.ts +20 -0
- package/dist/lib/session-summary-format.js +69 -0
- package/dist/lib/session-summary-format.js.map +1 -1
- package/dist/lib/shell-commands.d.ts +2 -0
- package/dist/lib/shell-commands.js +58 -4
- package/dist/lib/shell-commands.js.map +1 -1
- package/dist/lib/shell-ink.js +8 -1
- package/dist/lib/shell-ink.js.map +1 -1
- package/dist/lib/shell-render.js +3 -0
- package/dist/lib/shell-render.js.map +1 -1
- package/dist/lib/shell.js +8 -1
- package/dist/lib/shell.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Capability Map — Definisce cosa il CLI Intelligence Layer può fare.
|
|
3
|
+
*
|
|
4
|
+
* Ogni capability ha:
|
|
5
|
+
* - livello (explain, inspect, suggest, act)
|
|
6
|
+
* - se è attivabile nella fase corrente
|
|
7
|
+
* - se richiede conferma utente
|
|
8
|
+
* - se è locale-only o usa backend
|
|
9
|
+
* - se è sicura, sensibile o da posticipare
|
|
10
|
+
*
|
|
11
|
+
* PRINCIPI:
|
|
12
|
+
* - Conservativo: phase 1 = solo lettura e suggerimenti
|
|
13
|
+
* - Esplicito: ogni capability ha un risk assessment
|
|
14
|
+
* - Grounded: mappa direttamente a comandi esistenti nella CLI
|
|
15
|
+
*/
|
|
16
|
+
import type { CapabilityLevel } from './context-packet.js';
|
|
17
|
+
/** I 4 livelli operativi del CLI Intelligence Layer */
|
|
18
|
+
export type CapabilityTier = 'explain' | 'inspect' | 'suggest' | 'act';
|
|
19
|
+
/** Dove viene eseguita l'operazione */
|
|
20
|
+
export type ExecutionScope = 'local_only' | 'backend_read' | 'backend_write';
|
|
21
|
+
/** Rischio dell'operazione */
|
|
22
|
+
export type RiskLevel = 'safe' | 'sensitive' | 'deferred';
|
|
23
|
+
/** Fase di implementazione in cui la capability diventa disponibile */
|
|
24
|
+
export type ImplementationPhase = 1 | 2 | 3;
|
|
25
|
+
/** Singola capability del CLI Intelligence Layer */
|
|
26
|
+
export interface Capability {
|
|
27
|
+
/** Identificatore unico */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Livello operativo */
|
|
30
|
+
tier: CapabilityTier;
|
|
31
|
+
/** Descrizione concisa (per il modello) */
|
|
32
|
+
description: string;
|
|
33
|
+
/** Dove viene eseguita */
|
|
34
|
+
scope: ExecutionScope;
|
|
35
|
+
/** Rischio */
|
|
36
|
+
risk: RiskLevel;
|
|
37
|
+
/** Richiede conferma utente? */
|
|
38
|
+
requiresConfirmation: boolean;
|
|
39
|
+
/** Fase di implementazione */
|
|
40
|
+
phase: ImplementationPhase;
|
|
41
|
+
/** Capability level minimo richiesto */
|
|
42
|
+
minCapabilityLevel: CapabilityLevel;
|
|
43
|
+
/** Comando CLI corrispondente (se esiste) */
|
|
44
|
+
mappedCommand: string | null;
|
|
45
|
+
}
|
|
46
|
+
export declare const CAPABILITY_REGISTRY: readonly Capability[];
|
|
47
|
+
/** Ritorna capabilities disponibili per un dato livello e fase */
|
|
48
|
+
export declare function getAvailableCapabilities(capabilityLevel: CapabilityLevel, phase: ImplementationPhase): Capability[];
|
|
49
|
+
/** Ritorna capabilities raggruppate per tier */
|
|
50
|
+
export declare function getCapabilitiesByTier(capabilityLevel: CapabilityLevel, phase: ImplementationPhase): Record<CapabilityTier, Capability[]>;
|
|
51
|
+
/** Verifica se una capability specifica è abilitata */
|
|
52
|
+
export declare function isCapabilityEnabled(id: string, capabilityLevel: CapabilityLevel, phase: ImplementationPhase): boolean;
|
|
53
|
+
export declare const PHASE_1_EXCLUSIONS: readonly ["high_risk_remote_write", "automatic_memory_sync", "automatic_report_without_confirmation", "autonomous_multi_step_tool_loop", "silent_project_modifications", "backend_memory_write", "session_bidirectional_sync"];
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Capability Map — Definisce cosa il CLI Intelligence Layer può fare.
|
|
3
|
+
*
|
|
4
|
+
* Ogni capability ha:
|
|
5
|
+
* - livello (explain, inspect, suggest, act)
|
|
6
|
+
* - se è attivabile nella fase corrente
|
|
7
|
+
* - se richiede conferma utente
|
|
8
|
+
* - se è locale-only o usa backend
|
|
9
|
+
* - se è sicura, sensibile o da posticipare
|
|
10
|
+
*
|
|
11
|
+
* PRINCIPI:
|
|
12
|
+
* - Conservativo: phase 1 = solo lettura e suggerimenti
|
|
13
|
+
* - Esplicito: ogni capability ha un risk assessment
|
|
14
|
+
* - Grounded: mappa direttamente a comandi esistenti nella CLI
|
|
15
|
+
*/
|
|
16
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
17
|
+
// CAPABILITY REGISTRY
|
|
18
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
19
|
+
export const CAPABILITY_REGISTRY = [
|
|
20
|
+
// ─── TIER: EXPLAIN ────────────────────────────────────────────
|
|
21
|
+
{
|
|
22
|
+
id: 'explain_orbit',
|
|
23
|
+
tier: 'explain',
|
|
24
|
+
description: 'Spiega cos\'è Orbit, come funziona, quali componenti ha',
|
|
25
|
+
scope: 'local_only',
|
|
26
|
+
risk: 'safe',
|
|
27
|
+
requiresConfirmation: false,
|
|
28
|
+
phase: 1,
|
|
29
|
+
minCapabilityLevel: 'offline',
|
|
30
|
+
mappedCommand: null,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'explain_cli',
|
|
34
|
+
tier: 'explain',
|
|
35
|
+
description: 'Spiega i comandi della CLI, il workflow, come usarla',
|
|
36
|
+
scope: 'local_only',
|
|
37
|
+
risk: 'safe',
|
|
38
|
+
requiresConfirmation: false,
|
|
39
|
+
phase: 1,
|
|
40
|
+
minCapabilityLevel: 'offline',
|
|
41
|
+
mappedCommand: '/help',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'explain_state',
|
|
45
|
+
tier: 'explain',
|
|
46
|
+
description: 'Spiega lo stato locale corrente (sessione, progetto, contesto)',
|
|
47
|
+
scope: 'local_only',
|
|
48
|
+
risk: 'safe',
|
|
49
|
+
requiresConfirmation: false,
|
|
50
|
+
phase: 1,
|
|
51
|
+
minCapabilityLevel: 'offline',
|
|
52
|
+
mappedCommand: '/info',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'explain_error',
|
|
56
|
+
tier: 'explain',
|
|
57
|
+
description: 'Spiega un errore recente e suggerisci come risolverlo',
|
|
58
|
+
scope: 'local_only',
|
|
59
|
+
risk: 'safe',
|
|
60
|
+
requiresConfirmation: false,
|
|
61
|
+
phase: 1,
|
|
62
|
+
minCapabilityLevel: 'offline',
|
|
63
|
+
mappedCommand: null,
|
|
64
|
+
},
|
|
65
|
+
// ─── TIER: INSPECT ────────────────────────────────────────────
|
|
66
|
+
{
|
|
67
|
+
id: 'inspect_session',
|
|
68
|
+
tier: 'inspect',
|
|
69
|
+
description: 'Leggi il summary della sessione attiva, task, decisioni',
|
|
70
|
+
scope: 'local_only',
|
|
71
|
+
risk: 'safe',
|
|
72
|
+
requiresConfirmation: false,
|
|
73
|
+
phase: 1,
|
|
74
|
+
minCapabilityLevel: 'offline',
|
|
75
|
+
mappedCommand: '/session info',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'inspect_context',
|
|
79
|
+
tier: 'inspect',
|
|
80
|
+
description: 'Leggi il contesto progetto, health, attributed sources',
|
|
81
|
+
scope: 'local_only',
|
|
82
|
+
risk: 'safe',
|
|
83
|
+
requiresConfirmation: false,
|
|
84
|
+
phase: 1,
|
|
85
|
+
minCapabilityLevel: 'offline',
|
|
86
|
+
mappedCommand: '/context',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'inspect_interventions',
|
|
90
|
+
tier: 'inspect',
|
|
91
|
+
description: 'Lista interventi recenti dal backend Orbit',
|
|
92
|
+
scope: 'backend_read',
|
|
93
|
+
risk: 'safe',
|
|
94
|
+
requiresConfirmation: false,
|
|
95
|
+
phase: 1,
|
|
96
|
+
minCapabilityLevel: 'readonly',
|
|
97
|
+
mappedCommand: '/list',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'inspect_doctor',
|
|
101
|
+
tier: 'inspect',
|
|
102
|
+
description: 'Esegui diagnostica locale (token, API, git, sito)',
|
|
103
|
+
scope: 'local_only',
|
|
104
|
+
risk: 'safe',
|
|
105
|
+
requiresConfirmation: false,
|
|
106
|
+
phase: 1,
|
|
107
|
+
minCapabilityLevel: 'offline',
|
|
108
|
+
mappedCommand: '/doctor',
|
|
109
|
+
},
|
|
110
|
+
// ─── TIER: SUGGEST ────────────────────────────────────────────
|
|
111
|
+
{
|
|
112
|
+
id: 'suggest_next_step',
|
|
113
|
+
tier: 'suggest',
|
|
114
|
+
description: 'Suggerisci il prossimo comando basato sullo stato',
|
|
115
|
+
scope: 'local_only',
|
|
116
|
+
risk: 'safe',
|
|
117
|
+
requiresConfirmation: false,
|
|
118
|
+
phase: 1,
|
|
119
|
+
minCapabilityLevel: 'offline',
|
|
120
|
+
mappedCommand: null,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 'suggest_task_creation',
|
|
124
|
+
tier: 'suggest',
|
|
125
|
+
description: 'Suggerisci task da creare basato sulla conversazione',
|
|
126
|
+
scope: 'local_only',
|
|
127
|
+
risk: 'safe',
|
|
128
|
+
requiresConfirmation: false,
|
|
129
|
+
phase: 1,
|
|
130
|
+
minCapabilityLevel: 'offline',
|
|
131
|
+
mappedCommand: null,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'suggest_report',
|
|
135
|
+
tier: 'suggest',
|
|
136
|
+
description: 'Suggerisci se è il momento di inviare un /report',
|
|
137
|
+
scope: 'local_only',
|
|
138
|
+
risk: 'safe',
|
|
139
|
+
requiresConfirmation: false,
|
|
140
|
+
phase: 1,
|
|
141
|
+
minCapabilityLevel: 'offline',
|
|
142
|
+
mappedCommand: null,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 'suggest_recovery',
|
|
146
|
+
tier: 'suggest',
|
|
147
|
+
description: 'Suggerisci passi di recovery per errori o problemi',
|
|
148
|
+
scope: 'local_only',
|
|
149
|
+
risk: 'safe',
|
|
150
|
+
requiresConfirmation: false,
|
|
151
|
+
phase: 1,
|
|
152
|
+
minCapabilityLevel: 'offline',
|
|
153
|
+
mappedCommand: null,
|
|
154
|
+
},
|
|
155
|
+
// ─── TIER: ACT ────────────────────────────────────────────────
|
|
156
|
+
{
|
|
157
|
+
id: 'act_create_note',
|
|
158
|
+
tier: 'act',
|
|
159
|
+
description: 'Crea una nota nella sessione locale',
|
|
160
|
+
scope: 'local_only',
|
|
161
|
+
risk: 'safe',
|
|
162
|
+
requiresConfirmation: false,
|
|
163
|
+
phase: 2,
|
|
164
|
+
minCapabilityLevel: 'local_write',
|
|
165
|
+
mappedCommand: '/note',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: 'act_create_task',
|
|
169
|
+
tier: 'act',
|
|
170
|
+
description: 'Crea un task nella sessione locale',
|
|
171
|
+
scope: 'local_only',
|
|
172
|
+
risk: 'safe',
|
|
173
|
+
requiresConfirmation: false,
|
|
174
|
+
phase: 2,
|
|
175
|
+
minCapabilityLevel: 'local_write',
|
|
176
|
+
mappedCommand: '/task add',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: 'act_create_decision',
|
|
180
|
+
tier: 'act',
|
|
181
|
+
description: 'Registra una decisione nella sessione locale',
|
|
182
|
+
scope: 'local_only',
|
|
183
|
+
risk: 'safe',
|
|
184
|
+
requiresConfirmation: false,
|
|
185
|
+
phase: 2,
|
|
186
|
+
minCapabilityLevel: 'local_write',
|
|
187
|
+
mappedCommand: '/decision',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
id: 'act_complete_task',
|
|
191
|
+
tier: 'act',
|
|
192
|
+
description: 'Marca un task come completato',
|
|
193
|
+
scope: 'local_only',
|
|
194
|
+
risk: 'safe',
|
|
195
|
+
requiresConfirmation: false,
|
|
196
|
+
phase: 2,
|
|
197
|
+
minCapabilityLevel: 'local_write',
|
|
198
|
+
mappedCommand: '/task done',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: 'act_run_diagnose',
|
|
202
|
+
tier: 'act',
|
|
203
|
+
description: 'Esegui diagnostica aggregata /diagnose',
|
|
204
|
+
scope: 'backend_read',
|
|
205
|
+
risk: 'sensitive',
|
|
206
|
+
requiresConfirmation: true,
|
|
207
|
+
phase: 3,
|
|
208
|
+
minCapabilityLevel: 'readonly',
|
|
209
|
+
mappedCommand: '/diagnose',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: 'act_send_report',
|
|
213
|
+
tier: 'act',
|
|
214
|
+
description: 'Invia report a Orbit (crea intervento)',
|
|
215
|
+
scope: 'backend_write',
|
|
216
|
+
risk: 'sensitive',
|
|
217
|
+
requiresConfirmation: true,
|
|
218
|
+
phase: 3,
|
|
219
|
+
minCapabilityLevel: 'full',
|
|
220
|
+
mappedCommand: '/report',
|
|
221
|
+
},
|
|
222
|
+
];
|
|
223
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
224
|
+
// QUERY FUNCTIONS
|
|
225
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
226
|
+
/** Ritorna capabilities disponibili per un dato livello e fase */
|
|
227
|
+
export function getAvailableCapabilities(capabilityLevel, phase) {
|
|
228
|
+
const levelOrder = {
|
|
229
|
+
offline: 0,
|
|
230
|
+
readonly: 1,
|
|
231
|
+
local_write: 2,
|
|
232
|
+
full: 3,
|
|
233
|
+
};
|
|
234
|
+
const currentLevel = levelOrder[capabilityLevel];
|
|
235
|
+
return CAPABILITY_REGISTRY.filter(cap => {
|
|
236
|
+
const requiredLevel = levelOrder[cap.minCapabilityLevel];
|
|
237
|
+
return cap.phase <= phase && requiredLevel <= currentLevel;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/** Ritorna capabilities raggruppate per tier */
|
|
241
|
+
export function getCapabilitiesByTier(capabilityLevel, phase) {
|
|
242
|
+
const available = getAvailableCapabilities(capabilityLevel, phase);
|
|
243
|
+
return {
|
|
244
|
+
explain: available.filter(c => c.tier === 'explain'),
|
|
245
|
+
inspect: available.filter(c => c.tier === 'inspect'),
|
|
246
|
+
suggest: available.filter(c => c.tier === 'suggest'),
|
|
247
|
+
act: available.filter(c => c.tier === 'act'),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/** Verifica se una capability specifica è abilitata */
|
|
251
|
+
export function isCapabilityEnabled(id, capabilityLevel, phase) {
|
|
252
|
+
return getAvailableCapabilities(capabilityLevel, phase).some(c => c.id === id);
|
|
253
|
+
}
|
|
254
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
255
|
+
// EXCLUSION LIST — cosa NON fare nella prima fase
|
|
256
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
257
|
+
export const PHASE_1_EXCLUSIONS = [
|
|
258
|
+
'high_risk_remote_write',
|
|
259
|
+
'automatic_memory_sync',
|
|
260
|
+
'automatic_report_without_confirmation',
|
|
261
|
+
'autonomous_multi_step_tool_loop',
|
|
262
|
+
'silent_project_modifications',
|
|
263
|
+
'backend_memory_write',
|
|
264
|
+
'session_bidirectional_sync',
|
|
265
|
+
];
|
|
266
|
+
//# sourceMappingURL=capability-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-map.js","sourceRoot":"","sources":["../../../src/lib/intelligence/capability-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0CH,qEAAqE;AACrE,sBAAsB;AACtB,qEAAqE;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAA0B;IACxD,iEAAiE;IACjE;QACE,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,yDAAyD;QACtE,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,MAAM;QACZ,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,CAAC;QACR,kBAAkB,EAAE,SAAS;QAC7B,aAAa,EAAE,IA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AAC,IAAI,KAAK,SAAS,CAAC;QACpD,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC;QACpD,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,mBAAmB,CACjC,EAAU,EACV,eAAgC,EAChC,KAA0B;IAE1B,OAAO,wBAAwB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,qEAAqE;AACrE,kDAAkD;AAClD,qEAAqE;AAErE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,wBAAwB;IACxB,uBAAuB;IACvB,uCAAuC;IACvC,iCAAiC;IACjC,8BAA8B;IAC9B,sBAAsB;IACtB,4BAA4B;CACpB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat enrichment — Arricchisce il messaggio utente con contesto CLI.
|
|
3
|
+
*
|
|
4
|
+
* Questo modulo è il punto di integrazione tra il CLI Intelligence Layer
|
|
5
|
+
* e il flusso AI chat esistente. Arricchisce il messaggio inviato al backend
|
|
6
|
+
* con informazioni sul contesto locale che il backend non conosce.
|
|
7
|
+
*
|
|
8
|
+
* NON modifica il system prompt del backend (non ne ha controllo).
|
|
9
|
+
* NON aggiunge dipendenze nuove.
|
|
10
|
+
* NON fa I/O — usa solo dati già disponibili in OrbitStore.
|
|
11
|
+
*
|
|
12
|
+
* Approccio: prefissa il messaggio utente con un blocco di contesto leggero
|
|
13
|
+
* racchiuso in tag XML-like che il backend LLM può leggere ma che non
|
|
14
|
+
* interferiscono con il messaggio dell'utente.
|
|
15
|
+
*/
|
|
16
|
+
import { type ContextPacketInput } from './context-packet.js';
|
|
17
|
+
import type { OrbitState } from '../../state/types.js';
|
|
18
|
+
/**
|
|
19
|
+
* Costruisce un ContextPacketInput dai dati già presenti in OrbitState.
|
|
20
|
+
* Pure function — nessun I/O, nessun side effect.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildContextInputFromState(state: OrbitState, cwd: string): ContextPacketInput;
|
|
23
|
+
/**
|
|
24
|
+
* Formatta un contesto compatto (~150-200 token) da anteporre al messaggio utente.
|
|
25
|
+
* Il formato è un blocco racchiuso in tag che il LLM può leggere.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatContextPrefix(state: OrbitState, cwd: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Arricchisce il messaggio utente con il contesto CLI.
|
|
30
|
+
* Se il contesto non è disponibile, ritorna il messaggio originale (fallback).
|
|
31
|
+
*/
|
|
32
|
+
export declare function enrichMessageWithContext(userMessage: string, state: OrbitState, cwd: string): string;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat enrichment — Arricchisce il messaggio utente con contesto CLI.
|
|
3
|
+
*
|
|
4
|
+
* Questo modulo è il punto di integrazione tra il CLI Intelligence Layer
|
|
5
|
+
* e il flusso AI chat esistente. Arricchisce il messaggio inviato al backend
|
|
6
|
+
* con informazioni sul contesto locale che il backend non conosce.
|
|
7
|
+
*
|
|
8
|
+
* NON modifica il system prompt del backend (non ne ha controllo).
|
|
9
|
+
* NON aggiunge dipendenze nuove.
|
|
10
|
+
* NON fa I/O — usa solo dati già disponibili in OrbitStore.
|
|
11
|
+
*
|
|
12
|
+
* Approccio: prefissa il messaggio utente con un blocco di contesto leggero
|
|
13
|
+
* racchiuso in tag XML-like che il backend LLM può leggere ma che non
|
|
14
|
+
* interferiscono con il messaggio dell'utente.
|
|
15
|
+
*/
|
|
16
|
+
import { buildContextPacket } from './context-packet.js';
|
|
17
|
+
import { computeSessionStats } from '../session-summary-format.js';
|
|
18
|
+
import { getSetupLevel, getNextStep } from '../info-engine.js';
|
|
19
|
+
/**
|
|
20
|
+
* Costruisce un ContextPacketInput dai dati già presenti in OrbitState.
|
|
21
|
+
* Pure function — nessun I/O, nessun side effect.
|
|
22
|
+
*/
|
|
23
|
+
export function buildContextInputFromState(state, cwd) {
|
|
24
|
+
// Derive InfoState (same logic as /info command in command-router.ts)
|
|
25
|
+
let tasksOpen = 0;
|
|
26
|
+
let tasksDone = 0;
|
|
27
|
+
let notesTotal = 0;
|
|
28
|
+
let notesAgent = 0;
|
|
29
|
+
let decisions = 0;
|
|
30
|
+
let sessionLong = false;
|
|
31
|
+
if (state.session) {
|
|
32
|
+
const stats = computeSessionStats(state.session);
|
|
33
|
+
tasksOpen = stats.tasksOpen;
|
|
34
|
+
tasksDone = stats.tasksDone;
|
|
35
|
+
notesTotal = stats.notesTotal;
|
|
36
|
+
notesAgent = stats.notesAgent;
|
|
37
|
+
decisions = stats.decisions;
|
|
38
|
+
const startMs = new Date(state.session.started_at).getTime();
|
|
39
|
+
sessionLong = (Date.now() - startMs) > 2 * 60 * 60 * 1000;
|
|
40
|
+
}
|
|
41
|
+
const infoState = {
|
|
42
|
+
hasToken: !!state.tokenEntry,
|
|
43
|
+
hasSite: !!state.siteLink,
|
|
44
|
+
hasSession: !!state.session,
|
|
45
|
+
hasManifest: !!state.manifest,
|
|
46
|
+
projectName: state.manifest?.name ?? state.siteLink?.name ?? null,
|
|
47
|
+
environment: state.manifest?.environment ?? state.siteLink?.environment ?? null,
|
|
48
|
+
healthLevel: state.contextHealth.level,
|
|
49
|
+
tasksOpen,
|
|
50
|
+
sessionLong,
|
|
51
|
+
tasksDone,
|
|
52
|
+
notesTotal,
|
|
53
|
+
notesAgent,
|
|
54
|
+
decisions,
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
hasToken: !!state.tokenEntry,
|
|
58
|
+
hasSite: !!state.siteLink,
|
|
59
|
+
hasManifest: !!state.manifest,
|
|
60
|
+
projectName: infoState.projectName,
|
|
61
|
+
platform: state.manifest?.platform ?? state.siteLink?.platform ?? null,
|
|
62
|
+
environment: infoState.environment,
|
|
63
|
+
healthLevel: state.contextHealth.level,
|
|
64
|
+
healthIssues: state.contextHealth.issues.map(i => i.message),
|
|
65
|
+
setupLevel: getSetupLevel(infoState),
|
|
66
|
+
nextStep: getNextStep(infoState),
|
|
67
|
+
session: state.session ? {
|
|
68
|
+
id: state.session.id,
|
|
69
|
+
started_at: state.session.started_at,
|
|
70
|
+
notes: state.session.notes,
|
|
71
|
+
} : null,
|
|
72
|
+
gitBranch: state.gitBranch,
|
|
73
|
+
gitDirty: null, // Not available without I/O
|
|
74
|
+
cwd,
|
|
75
|
+
lastError: state.lastError,
|
|
76
|
+
backendReachable: null, // Not verified yet
|
|
77
|
+
mcpServerActive: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Formatta un contesto compatto (~150-200 token) da anteporre al messaggio utente.
|
|
82
|
+
* Il formato è un blocco racchiuso in tag che il LLM può leggere.
|
|
83
|
+
*/
|
|
84
|
+
export function formatContextPrefix(state, cwd) {
|
|
85
|
+
const input = buildContextInputFromState(state, cwd);
|
|
86
|
+
const packet = buildContextPacket(input);
|
|
87
|
+
const lines = [];
|
|
88
|
+
lines.push('<cli-context>');
|
|
89
|
+
// Project
|
|
90
|
+
const p = packet.project;
|
|
91
|
+
if (p.name) {
|
|
92
|
+
lines.push(`Progetto: ${p.name} (${p.platform ?? '?'}, ${p.environment ?? '?'})`);
|
|
93
|
+
}
|
|
94
|
+
lines.push(`Setup: ${p.setupLevel} | Contesto: ${p.healthLevel}`);
|
|
95
|
+
// Session
|
|
96
|
+
const s = packet.session;
|
|
97
|
+
if (s.active) {
|
|
98
|
+
lines.push(`Sessione attiva: ${s.durationMinutes ?? '?'}min, ${s.counts.notesTotal} note, ${s.counts.tasksOpen} task aperti, ${s.counts.decisions} decisioni`);
|
|
99
|
+
if (s.recentEntries.length > 0) {
|
|
100
|
+
const latest = s.recentEntries[s.recentEntries.length - 1];
|
|
101
|
+
lines.push(`Ultima entry: [${latest.kind}] ${latest.text}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
lines.push('Nessuna sessione attiva');
|
|
106
|
+
}
|
|
107
|
+
// Tech
|
|
108
|
+
if (packet.tech.gitBranch) {
|
|
109
|
+
lines.push(`Branch: ${packet.tech.gitBranch}`);
|
|
110
|
+
}
|
|
111
|
+
// Next step
|
|
112
|
+
lines.push(`Suggerimento: ${p.nextStep.cmd} — ${p.nextStep.reason}`);
|
|
113
|
+
lines.push('</cli-context>');
|
|
114
|
+
return lines.join('\n');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Arricchisce il messaggio utente con il contesto CLI.
|
|
118
|
+
* Se il contesto non è disponibile, ritorna il messaggio originale (fallback).
|
|
119
|
+
*/
|
|
120
|
+
export function enrichMessageWithContext(userMessage, state, cwd) {
|
|
121
|
+
try {
|
|
122
|
+
const prefix = formatContextPrefix(state, cwd);
|
|
123
|
+
return `${prefix}\n\n${userMessage}`;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Fallback: ritorna il messaggio originale senza contesto
|
|
127
|
+
return userMessage;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=chat-enrichment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-enrichment.js","sourceRoot":"","sources":["../../../src/lib/intelligence/chat-enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAG/E;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAiB,EACjB,GAAW;IAEX,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C,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,YAAY;IACZ,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAErE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,WAAmB,EACnB,KAAiB,EACjB,GAAW;IAEX,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/C,OAAO,GAAG,MAAM,OAAO,WAAW,EAAE,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;QAC1D,OAAO,WAAW,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Context Packet — Snapshot del contesto locale per il CLI Intelligence Layer.
|
|
3
|
+
*
|
|
4
|
+
* Questo è il payload che viene passato al modello LLM ogni volta che
|
|
5
|
+
* il CLI Intelligence Layer deve ragionare sullo stato corrente.
|
|
6
|
+
*
|
|
7
|
+
* PRINCIPI:
|
|
8
|
+
* - Proiezione da OrbitState + SessionSummary + InfoState (nessuna fonte nuova)
|
|
9
|
+
* - Minimale ma sufficiente (~1.5-2K token serializzato)
|
|
10
|
+
* - Stabile: i campi cambiano poco tra invocazioni successive
|
|
11
|
+
* - Nessun dato sensibile (token, credenziali, path assoluti)
|
|
12
|
+
*
|
|
13
|
+
* NON contiene:
|
|
14
|
+
* - Token o credenziali
|
|
15
|
+
* - Testi completi di note/decisioni (solo conteggi e ultime 3)
|
|
16
|
+
* - Stato backend (memory, RAG, audit) — quello è responsabilità del backend
|
|
17
|
+
*/
|
|
18
|
+
import type { ContextHealthLevel, NoteKind, NoteSource } from '../../types.js';
|
|
19
|
+
import type { SetupLevel } from '../info-engine.js';
|
|
20
|
+
/** Stato del progetto locale */
|
|
21
|
+
export interface ProjectContext {
|
|
22
|
+
/** Nome del progetto (da manifest o legacy site link) */
|
|
23
|
+
name: string | null;
|
|
24
|
+
/** Piattaforma: wordpress, prestashop, custom */
|
|
25
|
+
platform: string | null;
|
|
26
|
+
/** Ambiente: local, dev, staging, production */
|
|
27
|
+
environment: string | null;
|
|
28
|
+
/** Se il manifest .orbit/project.json è presente */
|
|
29
|
+
hasManifest: boolean;
|
|
30
|
+
/** Livello di maturità configurazione */
|
|
31
|
+
setupLevel: SetupLevel;
|
|
32
|
+
/** Salute del contesto (ok, info, warning, critical) */
|
|
33
|
+
healthLevel: ContextHealthLevel;
|
|
34
|
+
/** Sommario dei problemi di contesto (max 3) */
|
|
35
|
+
healthIssues: string[];
|
|
36
|
+
/** Prossimo passo suggerito dall'info engine */
|
|
37
|
+
nextStep: {
|
|
38
|
+
cmd: string;
|
|
39
|
+
reason: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Stato della sessione locale attiva */
|
|
43
|
+
export interface SessionContext {
|
|
44
|
+
/** Se c'è una sessione attiva */
|
|
45
|
+
active: boolean;
|
|
46
|
+
/** ID sessione (abbreviato a 8 char per leggibilità) */
|
|
47
|
+
id: string | null;
|
|
48
|
+
/** Durata in minuti */
|
|
49
|
+
durationMinutes: number | null;
|
|
50
|
+
/** Branch git corrente */
|
|
51
|
+
gitBranch: string | null;
|
|
52
|
+
/** Conteggi */
|
|
53
|
+
counts: {
|
|
54
|
+
notesTotal: number;
|
|
55
|
+
notesUser: number;
|
|
56
|
+
notesAgent: number;
|
|
57
|
+
tasksOpen: number;
|
|
58
|
+
tasksDone: number;
|
|
59
|
+
decisions: number;
|
|
60
|
+
warnings: number;
|
|
61
|
+
};
|
|
62
|
+
/** Ultime 3 entry (testo troncato a 80 char) */
|
|
63
|
+
recentEntries: RecentEntry[];
|
|
64
|
+
/** Se la sessione è lunga (>2h) */
|
|
65
|
+
isLong: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** Entry recente nel diario sessione (leggera) */
|
|
68
|
+
export interface RecentEntry {
|
|
69
|
+
kind: NoteKind;
|
|
70
|
+
source: NoteSource;
|
|
71
|
+
text: string;
|
|
72
|
+
minutesAgo: number;
|
|
73
|
+
}
|
|
74
|
+
/** Capacità disponibili al momento */
|
|
75
|
+
export interface CapabilitiesContext {
|
|
76
|
+
/** Comandi slash disponibili */
|
|
77
|
+
availableCommands: string[];
|
|
78
|
+
/** Se autenticato con token valido */
|
|
79
|
+
authenticated: boolean;
|
|
80
|
+
/** Se il backend è raggiungibile (null = non verificato) */
|
|
81
|
+
backendReachable: boolean | null;
|
|
82
|
+
/** Se il MCP server locale è attivo (solo per info) */
|
|
83
|
+
mcpServerActive: boolean;
|
|
84
|
+
/** Livello di capability corrente */
|
|
85
|
+
capabilityLevel: CapabilityLevel;
|
|
86
|
+
}
|
|
87
|
+
/** Livello di capability basato sullo stato */
|
|
88
|
+
export type CapabilityLevel = 'offline' | 'readonly' | 'local_write' | 'full';
|
|
89
|
+
/** Stato tecnico dell'ambiente */
|
|
90
|
+
export interface TechContext {
|
|
91
|
+
/** Working directory (basename solo, non path completo) */
|
|
92
|
+
cwd: string;
|
|
93
|
+
/** Branch git */
|
|
94
|
+
gitBranch: string | null;
|
|
95
|
+
/** Se ci sono modifiche non committate (null = non verificato) */
|
|
96
|
+
gitDirty: boolean | null;
|
|
97
|
+
/** Ultimo errore transiente (null se nessuno) */
|
|
98
|
+
lastError: string | null;
|
|
99
|
+
}
|
|
100
|
+
/** Context Packet completo */
|
|
101
|
+
export interface ContextPacket {
|
|
102
|
+
/** Versione dello schema (per compatibilità futura) */
|
|
103
|
+
version: 1;
|
|
104
|
+
/** Timestamp di generazione ISO 8601 */
|
|
105
|
+
generatedAt: string;
|
|
106
|
+
/** Stato progetto */
|
|
107
|
+
project: ProjectContext;
|
|
108
|
+
/** Stato sessione */
|
|
109
|
+
session: SessionContext;
|
|
110
|
+
/** Capacità disponibili */
|
|
111
|
+
capabilities: CapabilitiesContext;
|
|
112
|
+
/** Stato tecnico */
|
|
113
|
+
tech: TechContext;
|
|
114
|
+
}
|
|
115
|
+
/** Input per il builder — usa solo strutture già esistenti nella CLI */
|
|
116
|
+
export interface ContextPacketInput {
|
|
117
|
+
/** OrbitState.* fields selezionati */
|
|
118
|
+
hasToken: boolean;
|
|
119
|
+
hasSite: boolean;
|
|
120
|
+
hasManifest: boolean;
|
|
121
|
+
projectName: string | null;
|
|
122
|
+
platform: string | null;
|
|
123
|
+
environment: string | null;
|
|
124
|
+
healthLevel: ContextHealthLevel;
|
|
125
|
+
healthIssues: string[];
|
|
126
|
+
setupLevel: SetupLevel;
|
|
127
|
+
nextStep: {
|
|
128
|
+
cmd: string;
|
|
129
|
+
reason: string;
|
|
130
|
+
};
|
|
131
|
+
/** SessionState o null */
|
|
132
|
+
session: {
|
|
133
|
+
id: string;
|
|
134
|
+
started_at: string;
|
|
135
|
+
notes: Array<{
|
|
136
|
+
text: string;
|
|
137
|
+
timestamp: string;
|
|
138
|
+
kind?: NoteKind;
|
|
139
|
+
source?: NoteSource;
|
|
140
|
+
taskStatus?: 'open' | 'done';
|
|
141
|
+
}>;
|
|
142
|
+
} | null;
|
|
143
|
+
/** Git */
|
|
144
|
+
gitBranch: string | null;
|
|
145
|
+
gitDirty: boolean | null;
|
|
146
|
+
/** Tech */
|
|
147
|
+
cwd: string;
|
|
148
|
+
lastError: string | null;
|
|
149
|
+
/** Capabilities */
|
|
150
|
+
backendReachable: boolean | null;
|
|
151
|
+
mcpServerActive: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Assembla un ContextPacket da input già disponibili nella CLI.
|
|
155
|
+
* Pure function — nessun side effect, nessuna chiamata I/O.
|
|
156
|
+
*/
|
|
157
|
+
export declare function buildContextPacket(input: ContextPacketInput): ContextPacket;
|