Skip to content

Prompt as Code | GPT Image 2 / 2.5 提示词与案例库,530+ 个案例、20+ 套工业级模板与可复用 Skills,新增 2.5 同提示词对比专区,附完整提示词与生成记录,持续更新。

1.9 KB
Raw Blame
import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { homedir } from 'node:os';
import { fileURLToPath } from 'node:url';

const root = dirname(dirname(fileURLToPath(import.meta.url)));
const skillName = 'gpt-image-2-style-library';
const source = join(root, 'agents', 'skills', skillName);
const targetDefinitions = {
  codex: {
    label: 'Codex',
    root: join(process.env.CODEX_HOME || join(homedir(), '.codex'), 'skills')
  },
  'claude-code': {
    label: 'Claude Code',
    root: join(process.env.CLAUDE_HOME || join(homedir(), '.claude'), 'skills')
  },
  agents: {
    label: 'Shared agent skills',
    root: join(process.env.AGENTS_HOME || join(homedir(), '.agents'), 'skills')
  }
};
const targetAliases = {
  all: Object.keys(targetDefinitions),
  codex: ['codex'],
  claude: ['claude-code'],
  'claude-code': ['claude-code'],
  agents: ['agents'],
  shared: ['agents']
};
const rawTargets = process.argv.slice(2);

if (!existsSync(join(source, 'SKILL.md'))) {
  throw new Error(`Skill source is missing: ${source}`);
}

function selectedTargets() {
  const names = rawTargets.length ? rawTargets : ['all'];
  const selected = new Set();
  for (const name of names) {
    const normalized = name.toLowerCase();
    const matches = targetAliases[normalized];
    if (!matches) {
      throw new Error(`Unknown install target: ${name}. Use all, codex, claude-code, or agents.`);
    }
    for (const match of matches) selected.add(match);
  }
  return [...selected].map((name) => targetDefinitions[name]);
}

for (const targetDefinition of selectedTargets()) {
  const target = join(targetDefinition.root, skillName);
  mkdirSync(targetDefinition.root, { recursive: true });
  rmSync(target, { recursive: true, force: true });
  cpSync(source, target, { recursive: true });

  console.log(`Installed ${skillName} for ${targetDefinition.label}: ${target}`);
}