trackops 1.0.1 → 1.1.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 (57) hide show
  1. package/README.md +326 -270
  2. package/bin/trackops.js +102 -70
  3. package/lib/config.js +260 -35
  4. package/lib/control.js +517 -475
  5. package/lib/env.js +227 -0
  6. package/lib/i18n.js +61 -53
  7. package/lib/init.js +135 -46
  8. package/lib/locale.js +63 -0
  9. package/lib/opera-bootstrap.js +523 -0
  10. package/lib/opera.js +319 -170
  11. package/lib/registry.js +27 -13
  12. package/lib/release.js +56 -0
  13. package/lib/resources.js +42 -0
  14. package/lib/server.js +907 -554
  15. package/lib/skills.js +148 -124
  16. package/lib/workspace.js +260 -0
  17. package/locales/en.json +331 -139
  18. package/locales/es.json +331 -139
  19. package/package.json +7 -9
  20. package/scripts/skills-marketplace-smoke.js +124 -0
  21. package/scripts/smoke-tests.js +445 -0
  22. package/scripts/sync-skill-version.js +21 -0
  23. package/scripts/validate-skill.js +88 -0
  24. package/skills/trackops/SKILL.md +64 -0
  25. package/skills/trackops/agents/openai.yaml +3 -0
  26. package/skills/trackops/references/activation.md +39 -0
  27. package/skills/trackops/references/troubleshooting.md +34 -0
  28. package/skills/trackops/references/workflow.md +20 -0
  29. package/skills/trackops/scripts/bootstrap-trackops.js +201 -0
  30. package/skills/trackops/skill.json +29 -0
  31. package/templates/opera/en/agent.md +26 -0
  32. package/templates/opera/en/genesis.md +79 -0
  33. package/templates/opera/en/references/autonomy-and-recovery.md +23 -0
  34. package/templates/opera/en/references/opera-cycle.md +62 -0
  35. package/templates/opera/en/registry.md +28 -0
  36. package/templates/opera/en/router.md +39 -0
  37. package/templates/opera/genesis.md +79 -94
  38. package/templates/skills/changelog-updater/locales/en/SKILL.md +11 -0
  39. package/templates/skills/commiter/locales/en/SKILL.md +11 -0
  40. package/templates/skills/project-starter-skill/locales/en/SKILL.md +24 -0
  41. package/ui/css/panels.css +956 -953
  42. package/ui/index.html +1 -1
  43. package/ui/js/api.js +211 -194
  44. package/ui/js/app.js +200 -199
  45. package/ui/js/i18n.js +14 -0
  46. package/ui/js/onboarding.js +439 -437
  47. package/ui/js/state.js +130 -129
  48. package/ui/js/utils.js +175 -172
  49. package/ui/js/views/board.js +255 -254
  50. package/ui/js/views/execution.js +256 -256
  51. package/ui/js/views/insights.js +340 -339
  52. package/ui/js/views/overview.js +365 -364
  53. package/ui/js/views/settings.js +340 -202
  54. package/ui/js/views/sidebar.js +131 -132
  55. package/ui/js/views/skills.js +163 -162
  56. package/ui/js/views/tasks.js +406 -405
  57. package/ui/js/views/topbar.js +239 -183
package/ui/js/state.js CHANGED
@@ -1,129 +1,130 @@
1
- /**
2
- * state.js — Store centralizado con patrón pub/sub
3
- * Reemplaza el objeto state simple del app.js anterior.
4
- */
5
-
6
- const _state = {
7
- // Proyectos
8
- projects: [],
9
- registryFile: '',
10
- currentProjectId: null,
11
-
12
- // Payload del backend
13
- payload: null,
14
-
15
- // Selecciones UI
16
- selectedTaskId: null,
17
- activeView: 'overview',
18
-
19
- // Sesiones de terminal
20
- sessions: [],
21
- selectedSessionId: null,
22
- stream: null,
23
-
24
- // Time tracker
25
- timeEntries: [],
26
- activeEntry: null, // { taskId, taskTitle, startedAt }
27
- timerInterval: null,
28
-
29
- // i18n
30
- locale: 'es',
31
- statusLabels: {},
32
- phases: [],
33
-
34
- // Búsqueda
35
- searchQuery: '',
36
-
37
- // Onboarding
38
- onboardingDone: false,
39
-
40
- // Console logs
41
- consoleLogs: [],
42
- consolePanelOpen: false,
43
- };
44
-
45
- const _listeners = {};
46
-
47
- /**
48
- * Obtiene un valor del estado
49
- * @param {string} key
50
- * @returns {*}
51
- */
52
- export function get(key) {
53
- return _state[key];
54
- }
55
-
56
- /**
57
- * Actualiza una o más claves del estado y notifica a los suscriptores
58
- * @param {string|Object} keyOrObject - clave o mapa de {clave: valor}
59
- * @param {*} [value]
60
- */
61
- export function update(keyOrObject, value) {
62
- if (typeof keyOrObject === 'string') {
63
- _state[keyOrObject] = value;
64
- _notify(keyOrObject, value);
65
- } else {
66
- for (const [k, v] of Object.entries(keyOrObject)) {
67
- _state[k] = v;
68
- _notify(k, v);
69
- }
70
- }
71
- }
72
-
73
- /**
74
- * Suscribe una función a cambios de una clave específica
75
- * @param {string} key
76
- * @param {Function} callback - recibe (newValue, key)
77
- * @returns {Function} función de desuscripción
78
- */
79
- export function subscribe(key, callback) {
80
- if (!_listeners[key]) _listeners[key] = new Set();
81
- _listeners[key].add(callback);
82
- return () => _listeners[key]?.delete(callback);
83
- }
84
-
85
- /**
86
- * Obtiene el payload completo (shortcut)
87
- */
88
- export function getPayload() { return _state.payload; }
89
-
90
- /**
91
- * Obtiene el proyecto activo de la lista de proyectos
92
- */
93
- export function getCurrentProject() {
94
- return _state.projects.find(p => p.id === _state.currentProjectId) || null;
95
- }
96
-
97
- /**
98
- * Obtiene las fases según el i18n cargado desde el backend
99
- */
100
- export function getPhases() { return _state.phases; }
101
-
102
- /**
103
- * Obtiene el mapa de labels de estado
104
- */
105
- export function getStatusLabels() { return _state.statusLabels; }
106
-
107
- /**
108
- * Encuentra una tarea por id en el payload actual
109
- * @param {string} id
110
- * @returns {Object|null}
111
- */
112
- export function findTask(id) {
113
- return _state.payload?.derived?.tasks?.find(t => t.id === id) || null;
114
- }
115
-
116
- /**
117
- * Obtiene el estado completo (solo para debug)
118
- */
119
- export function snapshot() { return { ..._state }; }
120
-
121
- function _notify(key, value) {
122
- (_listeners[key] || []).forEach(cb => {
123
- try { cb(value, key); } catch (e) { console.error('[state] Error en suscriptor:', e); }
124
- });
125
- // Notificar también al comodín '*'
126
- (_listeners['*'] || []).forEach(cb => {
127
- try { cb(value, key); } catch (e) { console.error('[state] Error en suscriptor (*)', e); }
128
- });
129
- }
1
+ /**
2
+ * state.js — Store centralizado con patrón pub/sub
3
+ * Reemplaza el objeto state simple del app.js anterior.
4
+ */
5
+
6
+ const _state = {
7
+ // Proyectos
8
+ projects: [],
9
+ registryFile: '',
10
+ currentProjectId: null,
11
+
12
+ // Payload del backend
13
+ payload: null,
14
+
15
+ // Selecciones UI
16
+ selectedTaskId: null,
17
+ activeView: 'overview',
18
+
19
+ // Sesiones de terminal
20
+ sessions: [],
21
+ selectedSessionId: null,
22
+ stream: null,
23
+
24
+ // Time tracker
25
+ timeEntries: [],
26
+ activeEntry: null, // { taskId, taskTitle, startedAt }
27
+ timerInterval: null,
28
+
29
+ // i18n
30
+ locale: 'es',
31
+ statusLabels: {},
32
+ phases: [],
33
+ messages: {},
34
+
35
+ // Búsqueda
36
+ searchQuery: '',
37
+
38
+ // Onboarding
39
+ onboardingDone: false,
40
+
41
+ // Console logs
42
+ consoleLogs: [],
43
+ consolePanelOpen: false,
44
+ };
45
+
46
+ const _listeners = {};
47
+
48
+ /**
49
+ * Obtiene un valor del estado
50
+ * @param {string} key
51
+ * @returns {*}
52
+ */
53
+ export function get(key) {
54
+ return _state[key];
55
+ }
56
+
57
+ /**
58
+ * Actualiza una o más claves del estado y notifica a los suscriptores
59
+ * @param {string|Object} keyOrObject - clave o mapa de {clave: valor}
60
+ * @param {*} [value]
61
+ */
62
+ export function update(keyOrObject, value) {
63
+ if (typeof keyOrObject === 'string') {
64
+ _state[keyOrObject] = value;
65
+ _notify(keyOrObject, value);
66
+ } else {
67
+ for (const [k, v] of Object.entries(keyOrObject)) {
68
+ _state[k] = v;
69
+ _notify(k, v);
70
+ }
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Suscribe una función a cambios de una clave específica
76
+ * @param {string} key
77
+ * @param {Function} callback - recibe (newValue, key)
78
+ * @returns {Function} función de desuscripción
79
+ */
80
+ export function subscribe(key, callback) {
81
+ if (!_listeners[key]) _listeners[key] = new Set();
82
+ _listeners[key].add(callback);
83
+ return () => _listeners[key]?.delete(callback);
84
+ }
85
+
86
+ /**
87
+ * Obtiene el payload completo (shortcut)
88
+ */
89
+ export function getPayload() { return _state.payload; }
90
+
91
+ /**
92
+ * Obtiene el proyecto activo de la lista de proyectos
93
+ */
94
+ export function getCurrentProject() {
95
+ return _state.projects.find(p => p.id === _state.currentProjectId) || null;
96
+ }
97
+
98
+ /**
99
+ * Obtiene las fases según el i18n cargado desde el backend
100
+ */
101
+ export function getPhases() { return _state.phases; }
102
+
103
+ /**
104
+ * Obtiene el mapa de labels de estado
105
+ */
106
+ export function getStatusLabels() { return _state.statusLabels; }
107
+
108
+ /**
109
+ * Encuentra una tarea por id en el payload actual
110
+ * @param {string} id
111
+ * @returns {Object|null}
112
+ */
113
+ export function findTask(id) {
114
+ return _state.payload?.derived?.tasks?.find(t => t.id === id) || null;
115
+ }
116
+
117
+ /**
118
+ * Obtiene el estado completo (solo para debug)
119
+ */
120
+ export function snapshot() { return { ..._state }; }
121
+
122
+ function _notify(key, value) {
123
+ (_listeners[key] || []).forEach(cb => {
124
+ try { cb(value, key); } catch (e) { console.error('[state] Error en suscriptor:', e); }
125
+ });
126
+ // Notificar también al comodín '*'
127
+ (_listeners['*'] || []).forEach(cb => {
128
+ try { cb(value, key); } catch (e) { console.error('[state] Error en suscriptor (*)', e); }
129
+ });
130
+ }
package/ui/js/utils.js CHANGED
@@ -1,172 +1,175 @@
1
- /**
2
- * utils.js — Funciones de utilidad globales
3
- */
4
-
5
- /**
6
- * Escapa caracteres HTML para prevenir XSS
7
- * @param {*} value
8
- * @returns {string}
9
- */
10
- export function esc(value) {
11
- return String(value ?? '')
12
- .replace(/&/g, '&')
13
- .replace(/</g, '&lt;')
14
- .replace(/>/g, '&gt;')
15
- .replace(/"/g, '&quot;')
16
- .replace(/'/g, '&#39;');
17
- }
18
-
19
- /**
20
- * Formatea una fecha ISO a formato legible según locale
21
- * @param {string} value - ISO date string
22
- * @param {'date'|'datetime'|'time'} style
23
- * @returns {string}
24
- */
25
- export function formatDate(value, style = 'datetime') {
26
- if (!value) return '—';
27
- try {
28
- const date = new Date(value);
29
- if (isNaN(date.getTime())) return value;
30
- if (style === 'date') {
31
- return new Intl.DateTimeFormat('es-ES', { dateStyle: 'medium' }).format(date);
32
- }
33
- if (style === 'time') {
34
- return new Intl.DateTimeFormat('es-ES', { timeStyle: 'short' }).format(date);
35
- }
36
- return new Intl.DateTimeFormat('es-ES', { dateStyle: 'medium', timeStyle: 'short' }).format(date);
37
- } catch {
38
- return value;
39
- }
40
- }
41
-
42
- /**
43
- * Formatea duración en ms a HH:MM:SS
44
- * @param {number} ms - milisegundos
45
- * @returns {string}
46
- */
47
- export function formatDuration(ms) {
48
- if (!ms || ms < 0) return '00:00:00';
49
- const totalSeconds = Math.floor(ms / 1000);
50
- const hours = Math.floor(totalSeconds / 3600);
51
- const minutes = Math.floor((totalSeconds % 3600) / 60);
52
- const seconds = totalSeconds % 60;
53
- return [hours, minutes, seconds]
54
- .map(n => String(n).padStart(2, '0'))
55
- .join(':');
56
- }
57
-
58
- /**
59
- * Formatea duración en ms a string legible (ej: "2h 15m")
60
- * @param {number} ms
61
- * @returns {string}
62
- */
63
- export function formatDurationShort(ms) {
64
- if (!ms || ms < 0) return '0m';
65
- const totalMinutes = Math.floor(ms / 60000);
66
- const hours = Math.floor(totalMinutes / 60);
67
- const minutes = totalMinutes % 60;
68
- if (hours === 0) return `${minutes}m`;
69
- if (minutes === 0) return `${hours}h`;
70
- return `${hours}h ${minutes}m`;
71
- }
72
-
73
- /**
74
- * Debounce: retrasa la ejecución de una función hasta que deja de llamarse
75
- * @param {Function} fn
76
- * @param {number} wait - ms
77
- * @returns {Function}
78
- */
79
- export function debounce(fn, wait = 250) {
80
- let timer;
81
- return (...args) => {
82
- clearTimeout(timer);
83
- timer = setTimeout(() => fn(...args), wait);
84
- };
85
- }
86
-
87
- /**
88
- * Genera array de los últimos N días (YYYY-MM-DD)
89
- * @param {number} count
90
- * @returns {string[]}
91
- */
92
- export function lastDays(count = 10) {
93
- return Array.from({ length: count }, (_, i) => {
94
- const d = new Date();
95
- d.setDate(d.getDate() - (count - i - 1));
96
- return d.toISOString().slice(0, 10);
97
- });
98
- }
99
-
100
- /**
101
- * Divide un string multilínea o separado por comas en array de strings
102
- * @param {string} value
103
- * @returns {string[]}
104
- */
105
- export function splitLines(value) {
106
- return String(value || '')
107
- .split(/\r?\n|,/)
108
- .map(s => s.trim())
109
- .filter(Boolean);
110
- }
111
-
112
- /**
113
- * Slugifica un string (minúsculas, sin acentos, sin caracteres especiales)
114
- * @param {string} value
115
- * @returns {string}
116
- */
117
- export function slugify(value) {
118
- return String(value || '')
119
- .normalize('NFD')
120
- .replace(/[\u0300-\u036f]/g, '')
121
- .toLowerCase()
122
- .replace(/[^a-z0-9]+/g, '-')
123
- .replace(/^-+|-+$/g, '')
124
- .slice(0, 48);
125
- }
126
-
127
- /**
128
- * Extrae el historial de todas las tareas ordenado desc por fecha
129
- * @param {Array} tasks
130
- * @returns {Array}
131
- */
132
- export function extractHistory(tasks) {
133
- return (tasks || [])
134
- .flatMap(t => (t.history || []).map(e => ({ ...e, taskId: t.id, taskTitle: t.title })))
135
- .sort((a, b) => (a.at < b.at ? 1 : -1));
136
- }
137
-
138
- /**
139
- * Genera un número de color consistente desde un string
140
- * @param {string} str
141
- * @returns {string} hsl color
142
- */
143
- export function stringToColor(str) {
144
- let hash = 0;
145
- for (const ch of (str || '')) {
146
- hash = ch.charCodeAt(0) + ((hash << 5) - hash);
147
- }
148
- const hue = ((hash % 360) + 360) % 360;
149
- return `hsl(${hue}, 60%, 65%)`;
150
- }
151
-
152
- /**
153
- * Clamp: limita valor entre min y max
154
- */
155
- export function clamp(value, min, max) {
156
- return Math.min(Math.max(value, min), max);
157
- }
158
-
159
- /**
160
- * Crea un elemento <div> con clases opcionales e innerHTML
161
- * (helper para generación de DOM sin frameworks)
162
- * @param {string} tag
163
- * @param {string} [className]
164
- * @param {string} [innerHTML]
165
- * @returns {HTMLElement}
166
- */
167
- export function el(tag = 'div', className = '', innerHTML = '') {
168
- const element = document.createElement(tag);
169
- if (className) element.className = className;
170
- if (innerHTML) element.innerHTML = innerHTML;
171
- return element;
172
- }
1
+ /**
2
+ * utils.js — Funciones de utilidad globales
3
+ */
4
+
5
+ import * as state from './state.js';
6
+
7
+ /**
8
+ * Escapa caracteres HTML para prevenir XSS
9
+ * @param {*} value
10
+ * @returns {string}
11
+ */
12
+ export function esc(value) {
13
+ return String(value ?? '')
14
+ .replace(/&/g, '&amp;')
15
+ .replace(/</g, '&lt;')
16
+ .replace(/>/g, '&gt;')
17
+ .replace(/"/g, '&quot;')
18
+ .replace(/'/g, '&#39;');
19
+ }
20
+
21
+ /**
22
+ * Formatea una fecha ISO a formato legible según locale
23
+ * @param {string} value - ISO date string
24
+ * @param {'date'|'datetime'|'time'} style
25
+ * @returns {string}
26
+ */
27
+ export function formatDate(value, style = 'datetime') {
28
+ if (!value) return '—';
29
+ try {
30
+ const date = new Date(value);
31
+ if (isNaN(date.getTime())) return value;
32
+ const locale = state.get('locale') === 'en' ? 'en-US' : 'es-ES';
33
+ if (style === 'date') {
34
+ return new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(date);
35
+ }
36
+ if (style === 'time') {
37
+ return new Intl.DateTimeFormat(locale, { timeStyle: 'short' }).format(date);
38
+ }
39
+ return new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short' }).format(date);
40
+ } catch {
41
+ return value;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Formatea duración en ms a HH:MM:SS
47
+ * @param {number} ms - milisegundos
48
+ * @returns {string}
49
+ */
50
+ export function formatDuration(ms) {
51
+ if (!ms || ms < 0) return '00:00:00';
52
+ const totalSeconds = Math.floor(ms / 1000);
53
+ const hours = Math.floor(totalSeconds / 3600);
54
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
55
+ const seconds = totalSeconds % 60;
56
+ return [hours, minutes, seconds]
57
+ .map(n => String(n).padStart(2, '0'))
58
+ .join(':');
59
+ }
60
+
61
+ /**
62
+ * Formatea duración en ms a string legible (ej: "2h 15m")
63
+ * @param {number} ms
64
+ * @returns {string}
65
+ */
66
+ export function formatDurationShort(ms) {
67
+ if (!ms || ms < 0) return '0m';
68
+ const totalMinutes = Math.floor(ms / 60000);
69
+ const hours = Math.floor(totalMinutes / 60);
70
+ const minutes = totalMinutes % 60;
71
+ if (hours === 0) return `${minutes}m`;
72
+ if (minutes === 0) return `${hours}h`;
73
+ return `${hours}h ${minutes}m`;
74
+ }
75
+
76
+ /**
77
+ * Debounce: retrasa la ejecución de una función hasta que deja de llamarse
78
+ * @param {Function} fn
79
+ * @param {number} wait - ms
80
+ * @returns {Function}
81
+ */
82
+ export function debounce(fn, wait = 250) {
83
+ let timer;
84
+ return (...args) => {
85
+ clearTimeout(timer);
86
+ timer = setTimeout(() => fn(...args), wait);
87
+ };
88
+ }
89
+
90
+ /**
91
+ * Genera array de los últimos N días (YYYY-MM-DD)
92
+ * @param {number} count
93
+ * @returns {string[]}
94
+ */
95
+ export function lastDays(count = 10) {
96
+ return Array.from({ length: count }, (_, i) => {
97
+ const d = new Date();
98
+ d.setDate(d.getDate() - (count - i - 1));
99
+ return d.toISOString().slice(0, 10);
100
+ });
101
+ }
102
+
103
+ /**
104
+ * Divide un string multilínea o separado por comas en array de strings
105
+ * @param {string} value
106
+ * @returns {string[]}
107
+ */
108
+ export function splitLines(value) {
109
+ return String(value || '')
110
+ .split(/\r?\n|,/)
111
+ .map(s => s.trim())
112
+ .filter(Boolean);
113
+ }
114
+
115
+ /**
116
+ * Slugifica un string (minúsculas, sin acentos, sin caracteres especiales)
117
+ * @param {string} value
118
+ * @returns {string}
119
+ */
120
+ export function slugify(value) {
121
+ return String(value || '')
122
+ .normalize('NFD')
123
+ .replace(/[\u0300-\u036f]/g, '')
124
+ .toLowerCase()
125
+ .replace(/[^a-z0-9]+/g, '-')
126
+ .replace(/^-+|-+$/g, '')
127
+ .slice(0, 48);
128
+ }
129
+
130
+ /**
131
+ * Extrae el historial de todas las tareas ordenado desc por fecha
132
+ * @param {Array} tasks
133
+ * @returns {Array}
134
+ */
135
+ export function extractHistory(tasks) {
136
+ return (tasks || [])
137
+ .flatMap(t => (t.history || []).map(e => ({ ...e, taskId: t.id, taskTitle: t.title })))
138
+ .sort((a, b) => (a.at < b.at ? 1 : -1));
139
+ }
140
+
141
+ /**
142
+ * Genera un número de color consistente desde un string
143
+ * @param {string} str
144
+ * @returns {string} hsl color
145
+ */
146
+ export function stringToColor(str) {
147
+ let hash = 0;
148
+ for (const ch of (str || '')) {
149
+ hash = ch.charCodeAt(0) + ((hash << 5) - hash);
150
+ }
151
+ const hue = ((hash % 360) + 360) % 360;
152
+ return `hsl(${hue}, 60%, 65%)`;
153
+ }
154
+
155
+ /**
156
+ * Clamp: limita valor entre min y max
157
+ */
158
+ export function clamp(value, min, max) {
159
+ return Math.min(Math.max(value, min), max);
160
+ }
161
+
162
+ /**
163
+ * Crea un elemento <div> con clases opcionales e innerHTML
164
+ * (helper para generación de DOM sin frameworks)
165
+ * @param {string} tag
166
+ * @param {string} [className]
167
+ * @param {string} [innerHTML]
168
+ * @returns {HTMLElement}
169
+ */
170
+ export function el(tag = 'div', className = '', innerHTML = '') {
171
+ const element = document.createElement(tag);
172
+ if (className) element.className = className;
173
+ if (innerHTML) element.innerHTML = innerHTML;
174
+ return element;
175
+ }