How to Regenerate the Style Library for the GPT-Image2 Agent Skill Locally

Run node scripts/generate-style-skill.mjs after installing dependencies to rebuild data/style-library.json from the source style definitions.

The GPT-Image2 project from freestylefly/awesome-gpt-image-2 maintains a centralized style library that powers its agent skill's artistic rendering capabilities. When you modify style definitions or pull updates from the repository, you must regenerate this library locally to ensure the agent recognizes new or changed styles. The codebase provides a dedicated Node.js script that automates this compilation process.

Prerequisites for Local Regeneration

Before regenerating the style library, ensure your environment meets the following requirements:

  • Node.js installed (version compatible with the project's package.json specifications)
  • Repository cloned locally from https://github.com/freestylefly/awesome-gpt-image-2.git
  • All dependencies installed via npm ci or pnpm install

The project relies on standard Node.js modules including fs, path, and axios as declared in package.json to handle file system operations and style aggregation.

Step-by-Step Regeneration Process

Install Node.js Dependencies

Navigate to the repository root and install exact dependency versions to ensure script compatibility:

npm ci

Alternatively, if you prefer pnpm:

pnpm install

This resolves all required modules specified in package.json, including any utilities used by the generation script.

Execute the Generation Script

Run the style library compiler located at scripts/generate-style-skill.mjs:

node scripts/generate-style-skill.mjs

Some configurations may expose this via an npm convenience script:

npm run generate-style

The script performs the following operations:

  • Scans style definition files throughout the source tree (typically under src/ or data/ directories)
  • Collates individual style objects into a canonical JSON structure
  • Assigns unique id fields and preserves metadata such as name and rendering parameters
  • Writes the aggregated output to data/style-library.json

Verify the Output File

Confirm successful regeneration by inspecting data/style-library.json:

cat data/style-library.json | head -20

The file should contain a JSON array where each element represents a style object with properties like id, name, and style-specific configuration parameters.

Working with the Regenerated Library

Loading Styles in Application Code

After regeneration, import the compiled library into your agent skill implementation:

import fs from 'fs';
import path from 'path';

const libPath = path.resolve('data/style-library.json');
const library = JSON.parse(fs.readFileSync(libPath, 'utf8'));

console.log(`Loaded ${library.length} styles`);
library.forEach(s => console.log(`• ${s.id}: ${s.name}`));

Applying Styles to Generation Requests

Use the regenerated data to apply specific styles to image generation calls:

import styleLib from '../data/style-library.json';

function getStyleById(id) {
  return styleLib.find(s => s.id === id);
}

// Example: apply impressionist style to a prompt
const chosenStyle = getStyleById('impressionist');
await generateImage({ prompt: 'sunset over mountains', style: chosenStyle });

Summary

  • The style library is defined in data/style-library.json and consumed by the GPT-Image2 agent skill.
  • The regeneration script at scripts/generate-style-skill.mjs compiles source style definitions into the final JSON format.
  • Always run npm ci before executing the generator to ensure dependencies match the project's locked versions.
  • The script automatically handles style object aggregation, ID assignment, and metadata preservation.
  • Verify regeneration by checking that new or updated style entries appear in data/style-library.json before deploying the agent skill.

Frequently Asked Questions

What file format does the style library use?

The compiled style library uses standard JSON format stored at data/style-library.json. According to the freestylefly/awesome-gpt-image-2 source code, this file contains an array of style objects, each with unique identifiers and rendering metadata required by the agent skill.

Can I run the generator without installing dependencies?

No. The scripts/generate-style-skill.mjs script depends on Node.js modules (including fs, path, and potentially axios) that must be resolved through npm ci or pnpm install as specified in package.json. Running the script without installation will result in module resolution errors.

How do I add new styles to the library?

Add new style definitions to the appropriate source files within the repository (typically under src/ or data/ directories), then execute node scripts/generate-style-skill.mjs. The generator automatically incorporates new definitions into data/style-library.json during the collation process, preserving existing style entries while appending new ones.

Why is my regenerated library missing recent updates?

Ensure you have pulled the latest changes from the freestylefly/awesome-gpt-image-2 repository before running the generator. The script reads from local source files, so any style definitions not present in your working directory will not appear in the regenerated data/style-library.json. Run git pull and reinstall dependencies if the issue persists.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →