format: cover folded skills' js/ts scripts with repo prettier
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
The repo format:check glob covers ts/js alongside md; four non-markdown scripts inside the folded tree were flagged after the md pass. Same pinned prettier 3.8.1, same markup-only class (verified: node --check still passes on the js files).
This commit is contained in:
@@ -22,17 +22,17 @@
|
|||||||
// - Serialize/save configurations
|
// - Serialize/save configurations
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
// Define parameters that match YOUR algorithm
|
// Define parameters that match YOUR algorithm
|
||||||
// Examples (customize for your art):
|
// Examples (customize for your art):
|
||||||
// - Counts: how many elements (particles, circles, branches, etc.)
|
// - Counts: how many elements (particles, circles, branches, etc.)
|
||||||
// - Scales: size, speed, spacing
|
// - Scales: size, speed, spacing
|
||||||
// - Probabilities: likelihood of events
|
// - Probabilities: likelihood of events
|
||||||
// - Angles: rotation, direction
|
// - Angles: rotation, direction
|
||||||
// - Colors: palette arrays
|
// - Colors: palette arrays
|
||||||
|
|
||||||
seed: 12345,
|
seed: 12345,
|
||||||
// define colorPalette as an array -- choose whatever colors you'd like ['#d97757', '#6a9bcc', '#788c5d', '#b0aea5']
|
// define colorPalette as an array -- choose whatever colors you'd like ['#d97757', '#6a9bcc', '#788c5d', '#b0aea5']
|
||||||
// Add YOUR parameters here based on your algorithm
|
// Add YOUR parameters here based on your algorithm
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -41,9 +41,9 @@ let params = {
|
|||||||
// ALWAYS use seeded random for Art Blocks-style reproducible output
|
// ALWAYS use seeded random for Art Blocks-style reproducible output
|
||||||
|
|
||||||
function initializeSeed(seed) {
|
function initializeSeed(seed) {
|
||||||
randomSeed(seed);
|
randomSeed(seed);
|
||||||
noiseSeed(seed);
|
noiseSeed(seed);
|
||||||
// Now all random() and noise() calls will be deterministic
|
// Now all random() and noise() calls will be deterministic
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -51,36 +51,34 @@ function initializeSeed(seed) {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(800, 800);
|
createCanvas(800, 800);
|
||||||
|
|
||||||
// Initialize seed first
|
// Initialize seed first
|
||||||
initializeSeed(params.seed);
|
initializeSeed(params.seed);
|
||||||
|
|
||||||
// Set up your generative system
|
// Set up your generative system
|
||||||
// This is where you initialize:
|
// This is where you initialize:
|
||||||
// - Arrays of objects
|
// - Arrays of objects
|
||||||
// - Grid structures
|
// - Grid structures
|
||||||
// - Initial positions
|
// - Initial positions
|
||||||
// - Starting states
|
// - Starting states
|
||||||
|
|
||||||
// For static art: call noLoop() at the end of setup
|
// For static art: call noLoop() at the end of setup
|
||||||
// For animated art: let draw() keep running
|
// For animated art: let draw() keep running
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
// Option 1: Static generation (runs once, then stops)
|
// Option 1: Static generation (runs once, then stops)
|
||||||
// - Generate everything in setup()
|
// - Generate everything in setup()
|
||||||
// - Call noLoop() in setup()
|
// - Call noLoop() in setup()
|
||||||
// - draw() doesn't do much or can be empty
|
// - draw() doesn't do much or can be empty
|
||||||
|
// Option 2: Animated generation (continuous)
|
||||||
// Option 2: Animated generation (continuous)
|
// - Update your system each frame
|
||||||
// - Update your system each frame
|
// - Common patterns: particle movement, growth, evolution
|
||||||
// - Common patterns: particle movement, growth, evolution
|
// - Can optionally call noLoop() after N frames
|
||||||
// - Can optionally call noLoop() after N frames
|
// Option 3: User-triggered regeneration
|
||||||
|
// - Use noLoop() by default
|
||||||
// Option 3: User-triggered regeneration
|
// - Call redraw() when parameters change
|
||||||
// - Use noLoop() by default
|
|
||||||
// - Call redraw() when parameters change
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -90,23 +88,23 @@ function draw() {
|
|||||||
// Examples: particles, agents, cells, nodes, etc.
|
// Examples: particles, agents, cells, nodes, etc.
|
||||||
|
|
||||||
class Entity {
|
class Entity {
|
||||||
constructor() {
|
constructor() {
|
||||||
// Initialize entity properties
|
// Initialize entity properties
|
||||||
// Use random() here - it will be seeded
|
// Use random() here - it will be seeded
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
// Update entity state
|
// Update entity state
|
||||||
// This might involve:
|
// This might involve:
|
||||||
// - Physics calculations
|
// - Physics calculations
|
||||||
// - Behavioral rules
|
// - Behavioral rules
|
||||||
// - Interactions with neighbors
|
// - Interactions with neighbors
|
||||||
}
|
}
|
||||||
|
|
||||||
display() {
|
display() {
|
||||||
// Render the entity
|
// Render the entity
|
||||||
// Keep rendering logic separate from update logic
|
// Keep rendering logic separate from update logic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -130,32 +128,34 @@ class Entity {
|
|||||||
|
|
||||||
// Color utilities
|
// Color utilities
|
||||||
function hexToRgb(hex) {
|
function hexToRgb(hex) {
|
||||||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
return result ? {
|
return result
|
||||||
|
? {
|
||||||
r: parseInt(result[1], 16),
|
r: parseInt(result[1], 16),
|
||||||
g: parseInt(result[2], 16),
|
g: parseInt(result[2], 16),
|
||||||
b: parseInt(result[3], 16)
|
b: parseInt(result[3], 16),
|
||||||
} : null;
|
}
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function colorFromPalette(index) {
|
function colorFromPalette(index) {
|
||||||
return params.colorPalette[index % params.colorPalette.length];
|
return params.colorPalette[index % params.colorPalette.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mapping and easing
|
// Mapping and easing
|
||||||
function mapRange(value, inMin, inMax, outMin, outMax) {
|
function mapRange(value, inMin, inMax, outMin, outMax) {
|
||||||
return outMin + (outMax - outMin) * ((value - inMin) / (inMax - inMin));
|
return outMin + (outMax - outMin) * ((value - inMin) / (inMax - inMin));
|
||||||
}
|
}
|
||||||
|
|
||||||
function easeInOutCubic(t) {
|
function easeInOutCubic(t) {
|
||||||
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constrain to bounds
|
// Constrain to bounds
|
||||||
function wrapAround(value, max) {
|
function wrapAround(value, max) {
|
||||||
if (value < 0) return max;
|
if (value < 0) return max;
|
||||||
if (value > max) return 0;
|
if (value > max) return 0;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -163,16 +163,16 @@ function wrapAround(value, max) {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
function updateParameter(paramName, value) {
|
function updateParameter(paramName, value) {
|
||||||
params[paramName] = value;
|
params[paramName] = value;
|
||||||
// Decide if you need to regenerate or just update
|
// Decide if you need to regenerate or just update
|
||||||
// Some params can update in real-time, others need full regeneration
|
// Some params can update in real-time, others need full regeneration
|
||||||
}
|
}
|
||||||
|
|
||||||
function regenerate() {
|
function regenerate() {
|
||||||
// Reinitialize your generative system
|
// Reinitialize your generative system
|
||||||
// Useful when parameters change significantly
|
// Useful when parameters change significantly
|
||||||
initializeSeed(params.seed);
|
initializeSeed(params.seed);
|
||||||
// Then regenerate your system
|
// Then regenerate your system
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -181,19 +181,19 @@ function regenerate() {
|
|||||||
|
|
||||||
// Drawing with transparency for trails/fading
|
// Drawing with transparency for trails/fading
|
||||||
function fadeBackground(opacity) {
|
function fadeBackground(opacity) {
|
||||||
fill(250, 249, 245, opacity); // Anthropic light with alpha
|
fill(250, 249, 245, opacity); // Anthropic light with alpha
|
||||||
noStroke();
|
noStroke();
|
||||||
rect(0, 0, width, height);
|
rect(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using noise for organic variation
|
// Using noise for organic variation
|
||||||
function getNoiseValue(x, y, scale = 0.01) {
|
function getNoiseValue(x, y, scale = 0.01) {
|
||||||
return noise(x * scale, y * scale);
|
return noise(x * scale, y * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creating vectors from angles
|
// Creating vectors from angles
|
||||||
function vectorFromAngle(angle, magnitude = 1) {
|
function vectorFromAngle(angle, magnitude = 1) {
|
||||||
return createVector(cos(angle), sin(angle)).mult(magnitude);
|
return createVector(cos(angle), sin(angle)).mult(magnitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -201,7 +201,7 @@ function vectorFromAngle(angle, magnitude = 1) {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
function exportImage() {
|
function exportImage() {
|
||||||
saveCanvas('generative-art-' + params.seed, 'png');
|
saveCanvas('generative-art-' + params.seed, 'png');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ function parseFrontmatter(content: string): { frontmatter: RuleFrontmatter | nul
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
frontmatter: frontmatter as RuleFrontmatter,
|
frontmatter: frontmatter as RuleFrontmatter,
|
||||||
body: body.trim()
|
body: body.trim(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,8 +118,7 @@ function readMetadata(): any {
|
|||||||
|
|
||||||
function readRules(): Rule[] {
|
function readRules(): Rule[] {
|
||||||
const rulesDir = path.join(__dirname, '..', 'rules');
|
const rulesDir = path.join(__dirname, '..', 'rules');
|
||||||
const files = fs.readdirSync(rulesDir)
|
const files = fs.readdirSync(rulesDir).filter((f) => f.endsWith('.md') && !f.startsWith('_'));
|
||||||
.filter(f => f.endsWith('.md') && !f.startsWith('_'));
|
|
||||||
|
|
||||||
const rules: Rule[] = [];
|
const rules: Rule[] = [];
|
||||||
|
|
||||||
@@ -144,7 +143,7 @@ function readRules(): Rule[] {
|
|||||||
frontmatter,
|
frontmatter,
|
||||||
content: body,
|
content: body,
|
||||||
category: category.name,
|
category: category.name,
|
||||||
categorySection: category.section
|
categorySection: category.section,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -21,7 +21,7 @@ export function waitForEvent(
|
|||||||
threadManager: ThreadManager,
|
threadManager: ThreadManager,
|
||||||
threadId: string,
|
threadId: string,
|
||||||
eventType: LaceEventType,
|
eventType: LaceEventType,
|
||||||
timeoutMs = 5000
|
timeoutMs = 5000,
|
||||||
): Promise<LaceEvent> {
|
): Promise<LaceEvent> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
@@ -62,7 +62,7 @@ export function waitForEventCount(
|
|||||||
threadId: string,
|
threadId: string,
|
||||||
eventType: LaceEventType,
|
eventType: LaceEventType,
|
||||||
count: number,
|
count: number,
|
||||||
timeoutMs = 5000
|
timeoutMs = 5000,
|
||||||
): Promise<LaceEvent[]> {
|
): Promise<LaceEvent[]> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
@@ -76,8 +76,8 @@ export function waitForEventCount(
|
|||||||
} else if (Date.now() - startTime > timeoutMs) {
|
} else if (Date.now() - startTime > timeoutMs) {
|
||||||
reject(
|
reject(
|
||||||
new Error(
|
new Error(
|
||||||
`Timeout waiting for ${count} ${eventType} events after ${timeoutMs}ms (got ${matchingEvents.length})`
|
`Timeout waiting for ${count} ${eventType} events after ${timeoutMs}ms (got ${matchingEvents.length})`,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(check, 10);
|
setTimeout(check, 10);
|
||||||
@@ -113,7 +113,7 @@ export function waitForEventMatch(
|
|||||||
threadId: string,
|
threadId: string,
|
||||||
predicate: (event: LaceEvent) => boolean,
|
predicate: (event: LaceEvent) => boolean,
|
||||||
description: string,
|
description: string,
|
||||||
timeoutMs = 5000
|
timeoutMs = 5000,
|
||||||
): Promise<LaceEvent> {
|
): Promise<LaceEvent> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ function combineGraphs(blocks, skillName) {
|
|||||||
// Wrap each subgraph in a cluster for visual grouping
|
// Wrap each subgraph in a cluster for visual grouping
|
||||||
return ` subgraph cluster_${i} {
|
return ` subgraph cluster_${i} {
|
||||||
label="${block.name}";
|
label="${block.name}";
|
||||||
${body.split('\n').map(line => ' ' + line).join('\n')}
|
${body
|
||||||
|
.split('\n')
|
||||||
|
.map((line) => ' ' + line)
|
||||||
|
.join('\n')}
|
||||||
}`;
|
}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ function renderToSvg(dotContent) {
|
|||||||
return execSync('dot -Tsvg', {
|
return execSync('dot -Tsvg', {
|
||||||
input: dotContent,
|
input: dotContent,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
maxBuffer: 10 * 1024 * 1024
|
maxBuffer: 10 * 1024 * 1024,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error running dot:', err.message);
|
console.error('Error running dot:', err.message);
|
||||||
@@ -84,7 +87,7 @@ function renderToSvg(dotContent) {
|
|||||||
function main() {
|
function main() {
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const combine = args.includes('--combine');
|
const combine = args.includes('--combine');
|
||||||
const skillDirArg = args.find(a => !a.startsWith('--'));
|
const skillDirArg = args.find((a) => !a.startsWith('--'));
|
||||||
|
|
||||||
if (!skillDirArg) {
|
if (!skillDirArg) {
|
||||||
console.error('Usage: render-graphs.js <skill-directory> [--combine]');
|
console.error('Usage: render-graphs.js <skill-directory> [--combine]');
|
||||||
|
|||||||
Reference in New Issue
Block a user