@guildai/cli 0.7.1 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guildai/cli",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "description": "Guild.ai CLI - Build, test, and deploy AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "format": "prettier --write .",
35
35
  "format:fix": "prettier --write .",
36
36
  "format:check": "prettier --check .",
37
- "test": "vitest run",
37
+ "test": "vitest run test/unit --config vitest.unit.config.ts",
38
38
  "test:unit": "vitest run test/unit --config vitest.unit.config.ts",
39
39
  "test:e2e": "vitest run test/e2e --exclude='**/**.slow.test.ts'",
40
40
  "test:e2e:slow": "vitest run 'test/e2e/**/*.slow.test.ts'",
@@ -1,61 +0,0 @@
1
- interface LottieKeyframe {
2
- t: number;
3
- s: number[];
4
- e?: number[];
5
- i?: {
6
- x: number;
7
- y: number;
8
- };
9
- o?: {
10
- x: number;
11
- y: number;
12
- };
13
- }
14
- interface LottieProperty {
15
- a: number;
16
- k: number[] | LottieKeyframe[];
17
- }
18
- interface LottieShape {
19
- ty: string;
20
- ks?: {
21
- a: number;
22
- k: {
23
- v: number[][];
24
- c: boolean;
25
- };
26
- };
27
- }
28
- interface LottieLayer {
29
- ty: number;
30
- nm?: string;
31
- refId?: string;
32
- shapes?: LottieShape[];
33
- ks: {
34
- p: LottieProperty;
35
- s: LottieProperty;
36
- r: LottieProperty;
37
- a: LottieProperty;
38
- };
39
- parent?: number;
40
- }
41
- interface LottieAnimation {
42
- w: number;
43
- h: number;
44
- fr: number;
45
- op: number;
46
- layers: LottieLayer[];
47
- assets?: Array<{
48
- id: string;
49
- layers: LottieLayer[];
50
- }>;
51
- }
52
- /**
53
- * Render a single frame of Lottie animation to braille
54
- */
55
- export declare function renderLottieFrame(animation: LottieAnimation, frameNumber: number, widthChars: number, heightChars: number, invert?: boolean): string[];
56
- /**
57
- * Pre-render all frames of a Lottie animation
58
- */
59
- export declare function renderLottieAnimation(animation: LottieAnimation, widthChars: number, heightChars: number, invert?: boolean): string[][];
60
- export {};
61
- //# sourceMappingURL=lottie-renderer.d.ts.map
@@ -1,238 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * Lottie to Braille Renderer
5
- *
6
- * Parses Lottie animation JSON and renders each frame to braille characters.
7
- * Supports basic shape rendering with position/scale/rotation transformations.
8
- */
9
- import { createCanvas, setPixel, fillPath, canvasToStrings, } from './svg-renderer.js';
10
- /**
11
- * Interpolate between keyframes at a given time
12
- */
13
- function interpolateKeyframes(keyframes, time, dimensions) {
14
- if (keyframes.length === 0)
15
- return Array(dimensions).fill(0);
16
- // Find surrounding keyframes
17
- let startKf = keyframes[0];
18
- let endKf = keyframes[keyframes.length - 1];
19
- for (let i = 0; i < keyframes.length - 1; i++) {
20
- if (time >= keyframes[i].t && time <= keyframes[i + 1].t) {
21
- startKf = keyframes[i];
22
- endKf = keyframes[i + 1];
23
- break;
24
- }
25
- }
26
- // If before first or after last keyframe, use start/end value
27
- if (time <= startKf.t)
28
- return startKf.s;
29
- if (time >= endKf.t)
30
- return endKf.s;
31
- // Linear interpolation (ignoring easing for simplicity)
32
- const progress = (time - startKf.t) / (endKf.t - startKf.t);
33
- const result = [];
34
- for (let i = 0; i < dimensions; i++) {
35
- const start = startKf.s[i] || 0;
36
- const end = endKf.s[i] || start;
37
- result.push(start + (end - start) * progress);
38
- }
39
- return result;
40
- }
41
- /**
42
- * Get property value at a given time
43
- */
44
- function getPropertyValue(prop, time, dimensions) {
45
- if (prop.a === 0) {
46
- // Static value
47
- return Array.isArray(prop.k) ? prop.k : [prop.k];
48
- }
49
- else {
50
- // Animated value
51
- return interpolateKeyframes(prop.k, time, dimensions);
52
- }
53
- }
54
- /**
55
- * Draw a Lottie shape using bounding box auto-crop
56
- */
57
- function drawLottieShapeWithBBox(canvas, shapes, layerTransform, canvasPixelWidth, canvasPixelHeight, bboxCenterX, bboxCenterY, bboxSize) {
58
- // Find the path shape
59
- const pathShape = shapes.find((s) => s.ty === 'sh');
60
- if (!pathShape || !pathShape.ks?.k?.v)
61
- return;
62
- // Check if we have a fill
63
- const hasFill = shapes.some((s) => s.ty === 'fl');
64
- const vertices = pathShape.ks.k.v;
65
- const closed = pathShape.ks.k.c;
66
- // Transform vertices and map to canvas pixels
67
- const transformedPoints = vertices.map((v) => {
68
- // Step 1: Transform to Lottie coordinate space
69
- const lottieX = layerTransform.x + v[0] * layerTransform.scaleX;
70
- const lottieY = layerTransform.y + v[1] * layerTransform.scaleY;
71
- // Step 2: Center on bounding box and scale to canvas
72
- // Map bounding box to canvas with some padding
73
- const padding = 0.1; // 10% padding
74
- const scale = Math.min(canvasPixelWidth, canvasPixelHeight) / (bboxSize * (1 + padding));
75
- const x = (lottieX - bboxCenterX) * scale + canvasPixelWidth / 2;
76
- const y = (lottieY - bboxCenterY) * scale + canvasPixelHeight / 2;
77
- return [x, y];
78
- });
79
- // Fill if we have a fill element
80
- if (hasFill && closed) {
81
- fillPath(canvas, transformedPoints);
82
- }
83
- // Draw outline
84
- for (let i = 0; i < transformedPoints.length; i++) {
85
- const p1 = transformedPoints[i];
86
- const p2 = transformedPoints[(i + 1) % transformedPoints.length];
87
- if (!closed && i === transformedPoints.length - 1)
88
- break;
89
- drawLine(canvas, p1[0], p1[1], p2[0], p2[1]);
90
- }
91
- }
92
- /**
93
- * Simple line drawing (Bresenham)
94
- */
95
- function drawLine(canvas, x0, y0, x1, y1) {
96
- x0 = Math.round(x0);
97
- y0 = Math.round(y0);
98
- x1 = Math.round(x1);
99
- y1 = Math.round(y1);
100
- const dx = Math.abs(x1 - x0);
101
- const dy = Math.abs(y1 - y0);
102
- const sx = x0 < x1 ? 1 : -1;
103
- const sy = y0 < y1 ? 1 : -1;
104
- let err = dx - dy;
105
- while (true) {
106
- setPixel(canvas, x0, y0);
107
- if (x0 === x1 && y0 === y1)
108
- break;
109
- const e2 = 2 * err;
110
- if (e2 > -dy) {
111
- err -= dy;
112
- x0 += sx;
113
- }
114
- if (e2 < dx) {
115
- err += dx;
116
- y0 += sy;
117
- }
118
- }
119
- }
120
- /**
121
- * Render a single frame of Lottie animation to braille
122
- */
123
- export function renderLottieFrame(animation, frameNumber, widthChars, heightChars, invert = false) {
124
- const canvas = createCanvas(widthChars, heightChars);
125
- // Calculate pixel dimensions (braille is 2x4 pixels per character)
126
- const canvasPixelWidth = widthChars * 2;
127
- const canvasPixelHeight = heightChars * 4;
128
- // PASS 1: Collect all vertices in Lottie coordinate space to calculate bounding box
129
- const allVertices = [];
130
- for (const layer of animation.layers) {
131
- if (layer.ty === 0 && layer.refId) {
132
- // Pre-composition layer
133
- const asset = animation.assets?.find((a) => a.id === layer.refId);
134
- if (!asset || !asset.layers)
135
- continue;
136
- for (const compLayer of asset.layers) {
137
- if (compLayer.ty !== 4 || !compLayer.shapes)
138
- continue;
139
- const layerPos = getPropertyValue(compLayer.ks.p, frameNumber, 3);
140
- const layerScale = getPropertyValue(compLayer.ks.s, frameNumber, 3);
141
- // Find shape vertices
142
- const pathShape = compLayer.shapes.find((s) => s.ty === 'sh');
143
- if (!pathShape || !pathShape.ks?.k?.v)
144
- continue;
145
- const vertices = pathShape.ks.k.v;
146
- // Transform vertices to Lottie coordinate space
147
- vertices.forEach((v) => {
148
- const x = layerPos[0] + v[0] * (layerScale[0] / 100);
149
- const y = layerPos[1] + v[1] * (layerScale[1] / 100);
150
- allVertices.push([x, y]);
151
- });
152
- }
153
- }
154
- else if (layer.ty === 4 && layer.shapes) {
155
- // Direct shape layer
156
- const position = getPropertyValue(layer.ks.p, frameNumber, 3);
157
- const scale = getPropertyValue(layer.ks.s, frameNumber, 3);
158
- const pathShape = layer.shapes.find((s) => s.ty === 'sh');
159
- if (!pathShape || !pathShape.ks?.k?.v)
160
- continue;
161
- const vertices = pathShape.ks.k.v;
162
- vertices.forEach((v) => {
163
- const x = position[0] + v[0] * (scale[0] / 100);
164
- const y = position[1] + v[1] * (scale[1] / 100);
165
- allVertices.push([x, y]);
166
- });
167
- }
168
- }
169
- // Calculate bounding box
170
- if (allVertices.length === 0) {
171
- return canvasToStrings(canvas); // Empty frame
172
- }
173
- const minX = Math.min(...allVertices.map((v) => v[0]));
174
- const maxX = Math.max(...allVertices.map((v) => v[0]));
175
- const minY = Math.min(...allVertices.map((v) => v[1]));
176
- const maxY = Math.max(...allVertices.map((v) => v[1]));
177
- const bboxWidth = maxX - minX;
178
- const bboxHeight = maxY - minY;
179
- const bboxCenterX = (minX + maxX) / 2;
180
- const bboxCenterY = (minY + maxY) / 2;
181
- // PASS 2: Render shapes using bounding box as viewport
182
- for (const layer of animation.layers) {
183
- if (layer.ty === 0 && layer.refId) {
184
- const asset = animation.assets?.find((a) => a.id === layer.refId);
185
- if (!asset || !asset.layers)
186
- continue;
187
- for (const compLayer of asset.layers) {
188
- if (compLayer.ty !== 4 || !compLayer.shapes)
189
- continue;
190
- const layerPos = getPropertyValue(compLayer.ks.p, frameNumber, 3);
191
- const layerScale = getPropertyValue(compLayer.ks.s, frameNumber, 3);
192
- const layerRot = getPropertyValue(compLayer.ks.r, frameNumber, 1)[0];
193
- const layerTransform = {
194
- x: layerPos[0],
195
- y: layerPos[1],
196
- scaleX: layerScale[0] / 100,
197
- scaleY: layerScale[1] / 100,
198
- rotation: layerRot,
199
- };
200
- drawLottieShapeWithBBox(canvas, compLayer.shapes, layerTransform, canvasPixelWidth, canvasPixelHeight, bboxCenterX, bboxCenterY, Math.max(bboxWidth, bboxHeight));
201
- }
202
- }
203
- else if (layer.ty === 4 && layer.shapes) {
204
- const position = getPropertyValue(layer.ks.p, frameNumber, 3);
205
- const scale = getPropertyValue(layer.ks.s, frameNumber, 3);
206
- const rotation = getPropertyValue(layer.ks.r, frameNumber, 1)[0];
207
- const layerTransform = {
208
- x: position[0],
209
- y: position[1],
210
- scaleX: scale[0] / 100,
211
- scaleY: scale[1] / 100,
212
- rotation,
213
- };
214
- drawLottieShapeWithBBox(canvas, layer.shapes, layerTransform, canvasPixelWidth, canvasPixelHeight, bboxCenterX, bboxCenterY, Math.max(bboxWidth, bboxHeight));
215
- }
216
- }
217
- // Invert if requested
218
- if (invert) {
219
- for (let y = 0; y < canvas.pixels.length; y++) {
220
- for (let x = 0; x < canvas.pixels[y].length; x++) {
221
- canvas.pixels[y][x] = !canvas.pixels[y][x];
222
- }
223
- }
224
- }
225
- return canvasToStrings(canvas);
226
- }
227
- /**
228
- * Pre-render all frames of a Lottie animation
229
- */
230
- export function renderLottieAnimation(animation, widthChars, heightChars, invert = false) {
231
- const frames = [];
232
- const totalFrames = Math.floor(animation.op);
233
- for (let i = 0; i < totalFrames; i++) {
234
- frames.push(renderLottieFrame(animation, i, widthChars, heightChars, invert));
235
- }
236
- return frames;
237
- }
238
- //# sourceMappingURL=lottie-renderer.js.map
@@ -1,110 +0,0 @@
1
- export interface BrailleCanvas {
2
- width: number;
3
- height: number;
4
- pixels: boolean[][];
5
- }
6
- export interface SVGRenderOptions {
7
- width?: number;
8
- height?: number;
9
- fill?: boolean;
10
- fillDensity?: number;
11
- stroke?: boolean;
12
- invert?: boolean;
13
- rotation?: number;
14
- autoFit?: boolean;
15
- explicitBounds?: {
16
- minX: number;
17
- minY: number;
18
- maxX: number;
19
- maxY: number;
20
- };
21
- }
22
- interface TransformMatrix {
23
- a: number;
24
- b: number;
25
- c: number;
26
- d: number;
27
- e: number;
28
- f: number;
29
- }
30
- /**
31
- * Apply transform matrix to a point
32
- */
33
- export declare function transformPoint(x: number, y: number, m: TransformMatrix): [number, number];
34
- /**
35
- * Create an empty braille canvas
36
- */
37
- export declare function createCanvas(widthChars: number, heightChars: number): BrailleCanvas;
38
- /**
39
- * Set a pixel in the canvas
40
- */
41
- export declare function setPixel(canvas: BrailleCanvas, x: number, y: number, value?: boolean): void;
42
- /**
43
- * Draw a line using Bresenham's algorithm
44
- */
45
- export declare function drawLine(canvas: BrailleCanvas, x0: number, y0: number, x1: number, y1: number): void;
46
- /**
47
- * Draw a cubic bezier curve
48
- */
49
- export declare function drawCubicBezier(canvas: BrailleCanvas, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, steps?: number): void;
50
- /**
51
- * Draw a quadratic bezier curve
52
- */
53
- export declare function drawQuadraticBezier(canvas: BrailleCanvas, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, steps?: number): void;
54
- /**
55
- * Fill a closed path using scanline algorithm
56
- */
57
- export declare function fillPath(canvas: BrailleCanvas, points: [number, number][], density?: number): void;
58
- interface ClipRect {
59
- minX: number;
60
- minY: number;
61
- maxX: number;
62
- maxY: number;
63
- }
64
- interface ParsedPath {
65
- pathData: string;
66
- transform: TransformMatrix;
67
- clipRect?: ClipRect;
68
- fill?: string;
69
- }
70
- /**
71
- * Parse SVG hierarchically to match each path with its correct transform chain
72
- */
73
- export declare function parseHierarchicalPaths(svgContent: string): ParsedPath[];
74
- /**
75
- * Parse SVG content and extract path points with transforms applied
76
- */
77
- export declare function extractPathPoints(svgContent: string, targetWidth: number, targetHeight: number, rotation?: number, autoFit?: boolean, explicitBounds?: {
78
- minX: number;
79
- minY: number;
80
- maxX: number;
81
- maxY: number;
82
- }): [number, number][][];
83
- /**
84
- * Render SVG content to a braille canvas
85
- */
86
- export declare function renderSVGToCanvas(svgContent: string, options?: SVGRenderOptions): BrailleCanvas;
87
- /**
88
- * Convert braille canvas to string array
89
- */
90
- export declare function canvasToStrings(canvas: BrailleCanvas): string[];
91
- /**
92
- * Render SVG content string to braille strings
93
- */
94
- export declare function renderSVGContent(content: string, options?: SVGRenderOptions): string[];
95
- /**
96
- * Load and render the Guild logo from local assets
97
- */
98
- export declare function renderGuildLogo(widthChars?: number, heightChars?: number, invert?: boolean, rotation?: number): string[];
99
- /**
100
- * Get raw path points for animation purposes
101
- * Returns points in pixel coordinate space for the given dimensions
102
- */
103
- export declare function getLogoPathPoints(widthChars?: number, heightChars?: number): [number, number][][];
104
- /**
105
- * Get pixel positions from rendered logo (useful for inverted logos)
106
- * Returns array of [x, y] pixel coordinates that are "on" in the rendered logo
107
- */
108
- export declare function getLogoPixelPositions(widthChars?: number, heightChars?: number, invert?: boolean): [number, number][];
109
- export {};
110
- //# sourceMappingURL=svg-renderer.d.ts.map