@cccarv82/freya 2.13.2 → 2.13.3

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/cli/web-ui.css CHANGED
@@ -134,6 +134,7 @@ body {
134
134
  .shell {
135
135
  display: grid;
136
136
  grid-template-columns: 72px minmax(520px, 1fr);
137
+ grid-template-rows: 1fr;
137
138
  height: 100vh;
138
139
  min-height: 0;
139
140
  }
@@ -360,6 +361,7 @@ body {
360
361
  display: flex;
361
362
  flex-direction: column;
362
363
  min-height: 0;
364
+ overflow: hidden;
363
365
  padding: 8px 0 18px;
364
366
  }
365
367
 
package/cli/web-ui.js CHANGED
@@ -163,67 +163,113 @@
163
163
  }
164
164
 
165
165
  function formatPlanForDisplay(rawPlan) {
166
+ var text = String(rawPlan || '');
167
+ if (!text) return null;
168
+
169
+ // --- Strategy 1: try full JSON parse (works when copilot output is complete) ---
166
170
  try {
167
- const text = String(rawPlan || '');
168
- const start = text.indexOf('{');
169
- if (start === -1) return null;
170
- let depth = 0, inStr = false, esc = false, jsonStr = null;
171
- for (let i = start; i < text.length; i++) {
172
- const ch = text[i];
173
- if (esc) { esc = false; continue; }
174
- if (ch === '\\') { esc = true; continue; }
175
- if (ch === '"') { inStr = !inStr; continue; }
176
- if (inStr) continue;
177
- if (ch === '{') depth++;
178
- if (ch === '}') { depth--; if (depth === 0) { jsonStr = text.slice(start, i + 1); break; } }
171
+ var start = text.indexOf('{');
172
+ if (start !== -1) {
173
+ var depth = 0, inStr = false, esc = false, jsonStr = null;
174
+ for (var i = start; i < text.length; i++) {
175
+ var ch = text[i];
176
+ if (esc) { esc = false; continue; }
177
+ if (ch === '\\') { esc = true; continue; }
178
+ if (ch === '"') { inStr = !inStr; continue; }
179
+ if (inStr) continue;
180
+ if (ch === '{') depth++;
181
+ if (ch === '}') { depth--; if (depth === 0) { jsonStr = text.slice(start, i + 1); break; } }
182
+ }
183
+ if (jsonStr) {
184
+ var plan = JSON.parse(jsonStr);
185
+ var actions = Array.isArray(plan.actions) ? plan.actions : [];
186
+ if (actions.length > 0) {
187
+ return formatActions(actions);
188
+ }
189
+ }
179
190
  }
180
- if (!jsonStr) return null;
181
- const plan = JSON.parse(jsonStr);
182
- const actions = Array.isArray(plan.actions) ? plan.actions : [];
183
- if (actions.length === 0) return null;
184
-
185
- const icons = {
186
- append_daily_log: '\u{1F4DD}', appenddailylog: '\u{1F4DD}',
187
- create_task: '\u2705', createtask: '\u2705',
188
- create_blocker: '\u{1F6A7}', createblocker: '\u{1F6A7}',
189
- suggest_report: '\u{1F4CA}', suggestreport: '\u{1F4CA}',
190
- oracle_query: '\u{1F50D}', oraclequery: '\u{1F50D}'
191
- };
191
+ } catch (e) { /* fall through to regex strategy */ }
192
192
 
193
- const lines = actions.map(function(a, i) {
194
- var type = String(a.type || '').trim().toLowerCase().replace(/_/g, '');
195
- var icon = icons[type] || icons[String(a.type || '').trim()] || '\u2022';
196
- var num = i + 1;
197
- var typeNorm = type.replace(/_/g, '');
193
+ // --- Strategy 2: regex fallback for truncated/malformed JSON ---
194
+ var lines = [];
195
+ var num = 0;
198
196
 
199
- if (typeNorm === 'appenddailylog') {
200
- var t = String(a.text || '').slice(0, 140);
201
- return num + '. ' + icon + ' **Registrar no log:** ' + t + (String(a.text || '').length > 140 ? '...' : '');
202
- }
203
- if (typeNorm === 'createtask') {
204
- var desc = String(a.description || '').slice(0, 120);
205
- var pri = a.priority ? ' (prioridade: **' + String(a.priority).toUpperCase() + '**)' : '';
206
- var cat = a.category ? ' [' + a.category + ']' : '';
207
- return num + '. ' + icon + ' **Criar tarefa:** ' + desc + pri + cat;
208
- }
209
- if (typeNorm === 'createblocker') {
210
- var title = String(a.title || a.description || '').slice(0, 120);
211
- var sev = a.severity ? ' (severidade: **' + String(a.severity).toUpperCase() + '**)' : '';
212
- return num + '. ' + icon + ' **Registrar blocker:** ' + title + sev;
213
- }
214
- if (typeNorm === 'suggestreport') {
215
- return num + '. ' + icon + ' **Sugerir relatorio:** ' + String(a.name || a.reportType || '');
216
- }
217
- if (typeNorm === 'oraclequery') {
218
- return num + '. ' + icon + ' **Consultar oracle:** ' + String(a.query || '').slice(0, 120);
219
- }
220
- return num + '. \u2022 **' + String(a.type || 'acao') + ':** ' + JSON.stringify(a).slice(0, 100);
221
- });
197
+ // Match append_daily_log / appenddailylog actions
198
+ var logRe = /"type"\s*:\s*"append_?daily_?log"\s*,\s*"text"\s*:\s*"([^"]{1,300})/gi;
199
+ var m;
200
+ while ((m = logRe.exec(text)) !== null) {
201
+ num++;
202
+ var t = m[1].slice(0, 140);
203
+ lines.push(num + '. \u{1F4DD} **Registrar no log:** ' + t + (m[1].length > 140 ? '...' : ''));
204
+ }
222
205
 
223
- return lines.join('\n');
224
- } catch (e) {
225
- return null;
206
+ // Match create_task actions
207
+ var taskRe = /"type"\s*:\s*"create_?task"\s*,\s*"description"\s*:\s*"([^"]{1,200})/gi;
208
+ while ((m = taskRe.exec(text)) !== null) {
209
+ num++;
210
+ var desc = m[1].slice(0, 120);
211
+ var priMatch = text.slice(m.index, m.index + 400).match(/"priority"\s*:\s*"(\w+)"/i);
212
+ var pri = priMatch ? ' (prioridade: **' + priMatch[1].toUpperCase() + '**)' : '';
213
+ lines.push(num + '. \u2705 **Criar tarefa:** ' + desc + pri);
214
+ }
215
+
216
+ // Match create_blocker actions
217
+ var blockerRe = /"type"\s*:\s*"create_?blocker"\s*,\s*"title"\s*:\s*"([^"]{1,200})/gi;
218
+ while ((m = blockerRe.exec(text)) !== null) {
219
+ num++;
220
+ var title = m[1].slice(0, 120);
221
+ var sevMatch = text.slice(m.index, m.index + 400).match(/"severity"\s*:\s*"(\w+)"/i);
222
+ var sev = sevMatch ? ' (severidade: **' + sevMatch[1].toUpperCase() + '**)' : '';
223
+ lines.push(num + '. \u{1F6A7} **Registrar blocker:** ' + title + sev);
226
224
  }
225
+
226
+ // Match suggest_report actions
227
+ var repRe = /"type"\s*:\s*"suggest_?report"\s*,\s*"name"\s*:\s*"([^"]+)"/gi;
228
+ while ((m = repRe.exec(text)) !== null) {
229
+ num++;
230
+ lines.push(num + '. \u{1F4CA} **Sugerir relatorio:** ' + m[1]);
231
+ }
232
+
233
+ return lines.length > 0 ? lines.join('\n') : null;
234
+ }
235
+
236
+ function formatActions(actions) {
237
+ var icons = {
238
+ appenddailylog: '\u{1F4DD}', createtask: '\u2705',
239
+ createblocker: '\u{1F6A7}', suggestreport: '\u{1F4CA}',
240
+ oraclequery: '\u{1F50D}'
241
+ };
242
+
243
+ var lines = actions.map(function(a, i) {
244
+ var type = String(a.type || '').trim().toLowerCase().replace(/_/g, '');
245
+ var icon = icons[type] || '\u2022';
246
+ var num = i + 1;
247
+
248
+ if (type === 'appenddailylog') {
249
+ var t = String(a.text || '').slice(0, 140);
250
+ return num + '. ' + icon + ' **Registrar no log:** ' + t + (String(a.text || '').length > 140 ? '...' : '');
251
+ }
252
+ if (type === 'createtask') {
253
+ var desc = String(a.description || '').slice(0, 120);
254
+ var pri = a.priority ? ' (prioridade: **' + String(a.priority).toUpperCase() + '**)' : '';
255
+ var cat = a.category ? ' [' + a.category + ']' : '';
256
+ return num + '. ' + icon + ' **Criar tarefa:** ' + desc + pri + cat;
257
+ }
258
+ if (type === 'createblocker') {
259
+ var title = String(a.title || a.description || '').slice(0, 120);
260
+ var sev = a.severity ? ' (severidade: **' + String(a.severity).toUpperCase() + '**)' : '';
261
+ return num + '. ' + icon + ' **Registrar blocker:** ' + title + sev;
262
+ }
263
+ if (type === 'suggestreport') {
264
+ return num + '. ' + icon + ' **Sugerir relatorio:** ' + String(a.name || a.reportType || '');
265
+ }
266
+ if (type === 'oraclequery') {
267
+ return num + '. ' + icon + ' **Consultar oracle:** ' + String(a.query || '').slice(0, 120);
268
+ }
269
+ return num + '. \u2022 **' + String(a.type || 'acao') + '**';
270
+ });
271
+
272
+ return lines.join('\n');
227
273
  }
228
274
 
229
275
  function ensureChatSession() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cccarv82/freya",
3
- "version": "2.13.2",
3
+ "version": "2.13.3",
4
4
  "description": "Personal AI Assistant with local-first persistence",
5
5
  "scripts": {
6
6
  "health": "node scripts/validate-data.js && node scripts/validate-structure.js",