算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
anima-rate-limits【设计与创意】Implement rate limiting for Anima API code generation requests. Use when batching component generation, handling rate limit errors, or optimizing API throughput for large design systems. Trigger with: "anima rate limit", "anima throttling", "anima batch generation".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: anima-rate-limits description: 'Implement rate limiting for Anima API code generation requests.
Use when batching component generation, handling rate limit errors,
or optimizing API throughput for large design systems.
Trigger with: "anima rate limit", "anima throttling", "anima batch generation".
' allowed-tools: Read, Write, Edit, Bash(npm:*) version: 2.0.0 argument-hint: "[figma-workload]" model: inherit effort: high license: MIT author: Jeremy Longshore jeremy@intentsolutions.io tags:
Handle Figma rate limits from the current SDK's structured callback and treat any Anima generation quota as account-specific until the provider or agreement says otherwise. Never encode an invented requests-per-minute or concurrency allowance.
| Surface | Signal | Required action |
|---|---|---|
FigmaRestApi.onRateLimited | retryAfter, figmaPlanTier, figmaRateLimitType | Retry only inside a bounded elapsed-time budget |
figmaRateLimitMaxWait | 1–180 seconds; default 60 | Set explicitly for the request's latency budget |
| Anima generation | Returned error/progress state and account contract | Stop or queue; do not infer a numeric quota |
ANIMA_TOKEN, FIGMA_TOKEN, and FIGMA_FILE_KEY in the runtime secret manager or injected environment, and verify that the token has only the scopes required for the selected file. Never put tokens in source, fixtures, logs, generated receipts, or retry payloads.// src/anima/client.ts
import { Anima, FigmaRestApi } from '@animaapp/anima-sdk';
const figmaRestApi = new FigmaRestApi({
defaultOptions: {
token: process.env.FIGMA_TOKEN!,
onRateLimited: async ({ retryAfter, figmaPlanTier, figmaRateLimitType }) => {
console.warn({ retryAfter, figmaPlanTier, figmaRateLimitType });
return retryAfter > 0 && retryAfter <= 5; // Repository latency budget.
},
},
});
export const anima = new Anima({
auth: { token: process.env.ANIMA_TOKEN! },
figmaRestApi,
});
const result = await anima.generateCode({
fileKey: process.env.FIGMA_FILE_KEY!,
nodesId: ['1:2'],
figmaRateLimitMaxWait: 5,
settings: { framework: 'react', language: 'typescript', styling: 'tailwind' },
});
console.log({ fileCount: Object.keys(result.files).length, sessionId: result.sessionId });
FigmaRestApi own Figma retry decisions. Do not add a second uncoordinated retry loop around the same request.For a sandbox batch, keep the work bounded and make the outcome auditable without exposing design data:
const nodeIds = ['synthetic-card', 'synthetic-button'];
const receipt = {
batchId: 'sandbox-2026-01-15-a',
requested: nodeIds.length,
succeeded: 0,
failed: 0,
contactsExported: 0,
};
for (const nodeId of nodeIds) {
try {
await anima.generateCode({ fileKey: process.env.FIGMA_FILE_KEY!, nodesId: [nodeId], figmaRateLimitMaxWait: 5, settings });
receipt.succeeded++;
} catch (error) {
receipt.failed++;
// Store only a redacted status and node fingerprint; never serialize `error` or source.
}
}
console.log(JSON.stringify({ ...receipt, tokenPresent: Boolean(process.env.ANIMA_TOKEN) }));
An acceptable completion receipt is requested=2; succeeded=2; failed=0; contacts_exported=0 with the sandbox ID and limiter settings recorded separately. A production batch should use the same controls, a reviewed allowlist, and an owner-approved change record before increasing concurrency.
Use Read and Grep to inspect the existing integration and generated diff before changing anything. Use Write or Edit only inside the approved generated-code, test, or configuration paths. Use the declared Bash commands only for the explicit install, validation, or diagnostic steps in this workflow; never print tokens, source designs, generated source, or private website captures.