@ariasbruno/skillbase 0.2.0 → 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.
@@ -1,18 +1,15 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
-
4
- async function exists(target) {
5
- try {
6
- await fs.access(target);
7
- return true;
8
- } catch {
9
- return false;
10
- }
11
- }
3
+ import { exists } from './config.js';
12
4
 
13
5
  async function readJsonIfExists(file) {
14
6
  if (!(await exists(file))) return null;
15
- return JSON.parse(await fs.readFile(file, 'utf8'));
7
+ try {
8
+ return JSON.parse(await fs.readFile(file, 'utf8'));
9
+ } catch (e) {
10
+ console.error(`Warning: Failed to parse JSON at ${file}. Skipping.`);
11
+ return null;
12
+ }
16
13
  }
17
14
 
18
15
  async function readTextIfExists(file) {
package/src/styles.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * skillbase - Sistema de Estilos ANSI
3
+ * Proporciona funciones para colorear texto y símbolos comunes sin dependencias externas.
4
+ */
5
+
6
+ const ESC = '\x1b[';
7
+ const RESET = `${ESC}0m`;
8
+
9
+ const createStyle = (start) => (msg) => `${ESC}${start}m${msg}${RESET}`;
10
+
11
+ export const bold = createStyle('1');
12
+ export const dim = createStyle('2');
13
+ export const italic = createStyle('3');
14
+ export const underline = createStyle('4');
15
+
16
+ export const black = createStyle('30');
17
+ export const red = createStyle('31');
18
+ export const green = createStyle('32');
19
+ export const yellow = createStyle('33');
20
+ export const blue = createStyle('34');
21
+ export const magenta = createStyle('35');
22
+ export const cyan = createStyle('36');
23
+ export const white = createStyle('37');
24
+
25
+ // 256-color grays (estilo Vercel)
26
+ export const dim2 = (msg) => `\x1b[38;5;102m${msg}${RESET}`;
27
+ export const text = (msg) => `\x1b[38;5;145m${msg}${RESET}`;
28
+ export const grayAccent = (msg) => `\x1b[38;5;240m${msg}${RESET}`;
29
+ export const grayLogo = (msg, index = 0) => {
30
+ const grays = ['250', '248', '245', '243', '240', '238'];
31
+ const color = grays[Math.min(index, grays.length - 1)];
32
+ return `\x1b[38;5;${color}m${msg}${RESET}`;
33
+ };
34
+
35
+ // Control de Terminal
36
+ export const H_HIDE_CURSOR = '\x1b[?25l';
37
+ export const H_SHOW_CURSOR = '\x1b[?25h';
38
+ export const H_CLEAR_DOWN = '\x1b[J';
39
+ export const H_MOVE_UP = (n) => (n > 0 ? `\x1b[${n}A` : '');
40
+ export const H_MOVE_TO_COL = (n) => `\x1b[${n}G`;
41
+
42
+ // Símbolos comunes
43
+ export const S_DIAMOND = '◆';
44
+ export const S_BULLET = '◆';
45
+ export const S_POINTER = '❯';
46
+ export const S_STEP = '◇';
47
+ export const S_CHECK = '✔';
48
+ export const S_SQUARE = '◻';
49
+ export const S_SQUARE_FILL = '◼';
50
+ export const S_CROSS = '✖';
51
+ export const S_INFO = 'ℹ';
52
+ export const S_WARNING = '⚠';
53
+ export const S_ARROW_UP = '▲';
54
+ export const S_ARROW_DOWN = '▼';
55
+
56
+ // Estructura Clack
57
+ export const S_BAR = '│';
58
+ export const S_BAR_START = '┌';
59
+ export const S_BAR_END = '└';