# 问题 修复 文件 1 前端构建失败(引号错误) size="small type=" → size="small" type=" PosterHistoryPage.vue 2 migrate_014 ORM vs 缺失列 全部改为原始 SQL,不再引用 ORM 模型 migrate_014.py 3 cleanup 字段名错误 output_path → ppt_path cleanup.py 4 文案生成 case 越权 添加 case.user_id != user_id 校验 poster/service.py 5 存储路径未接通持久化卷 全部改用 get_storage_root()(默认 /app/api/storage/insurance) config.py, ppt/routes.py, poster/service.py, poster/tasks.py 高风险问题修复 # 问题 修复 文件 6 migrate_019 rollback 撤销成功字段 每个 ALTER 后立即 commit,失败只回滚当前语句 migrate_019.py 7 迁移锁 Windows 不兼容 + 句柄未持久化 全局变量保存锁句柄,支持 Windows msvcrt api/insurance/db/__init__.py 8 PDF 校验异常时放行 异常返回 False(文件损坏) security.py 9 健康检查始终返回成功 缺少关键资源时返回 503 + missing 列表 poster/routes.py 10 短密钥掩码泄露原值 ≤4 字符返回 **** ppt_admin_service.py 11 设置无键名白名单 添加 _ALLOWED_SETTING_KEYS 白名单 ppt_admin_service.py 12 容器重启任务永久 stuck 添加 recover_stale_tasks() 启动恢复函数 poster/tasks.py, ppt/parse_worker.py
222 lines
6.3 KiB
JavaScript
222 lines
6.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Pin/unpin sub-commands as standalone skill shortcuts.
|
|
*
|
|
* Usage:
|
|
* node <scripts_path>/pin.mjs pin <command>
|
|
* node <scripts_path>/pin.mjs unpin <command>
|
|
*
|
|
* `pin audit` creates a lightweight audit skill that redirects to Impeccable's audit workflow.
|
|
* `unpin audit` removes that shortcut.
|
|
*
|
|
* The script discovers harness directories (.claude/skills, .cursor/skills, etc.)
|
|
* in the project root and creates/removes the pin in all of them.
|
|
*/
|
|
|
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync, readdirSync } from 'node:fs';
|
|
import { basename, join, resolve, dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
// All known harness directories
|
|
const HARNESS_DIRS = [
|
|
'.claude', '.cursor', '.gemini', '.codex', '.agents', '.github', '.grok',
|
|
'.trae', '.trae-cn', '.pi', '.opencode', '.kiro', '.rovodev', '.vibe', '.qoder',
|
|
];
|
|
|
|
const CODEX_HARNESSES = new Set(['.codex', '.agents']);
|
|
|
|
// Valid sub-command names
|
|
const VALID_COMMANDS = [
|
|
'craft', 'init', 'extract', 'document', 'shape',
|
|
'critique', 'audit',
|
|
'polish', 'bolder', 'quieter', 'distill', 'harden', 'onboard', 'live',
|
|
'animate', 'colorize', 'typeset', 'layout', 'delight', 'overdrive',
|
|
'clarify', 'adapt', 'optimize',
|
|
];
|
|
|
|
// Marker to identify pinned skills (so unpin doesn't delete user skills)
|
|
const PIN_MARKER = '<!-- impeccable-pinned-skill -->';
|
|
|
|
/**
|
|
* Walk up from startDir to find a project root.
|
|
*/
|
|
function findProjectRoot(startDir = process.cwd()) {
|
|
let dir = resolve(startDir);
|
|
while (dir !== '/') {
|
|
if (
|
|
existsSync(join(dir, 'package.json')) ||
|
|
existsSync(join(dir, '.git')) ||
|
|
existsSync(join(dir, 'skills-lock.json'))
|
|
) {
|
|
return dir;
|
|
}
|
|
const parent = resolve(dir, '..');
|
|
if (parent === dir) break;
|
|
dir = parent;
|
|
}
|
|
return resolve(startDir);
|
|
}
|
|
|
|
/**
|
|
* Find harness skill directories that have an impeccable skill installed.
|
|
*/
|
|
function findHarnessDirs(projectRoot) {
|
|
const dirs = [];
|
|
for (const harness of HARNESS_DIRS) {
|
|
const skillsDir = join(projectRoot, harness, 'skills');
|
|
// Only pin in harness dirs that already have impeccable installed
|
|
const impeccableDir = join(skillsDir, 'impeccable');
|
|
if (existsSync(impeccableDir) || existsSync(join(skillsDir, 'i-impeccable'))) {
|
|
dirs.push(skillsDir);
|
|
}
|
|
}
|
|
return dirs;
|
|
}
|
|
|
|
/**
|
|
* Load command metadata (descriptions for pinned skills).
|
|
*/
|
|
function loadCommandMetadata() {
|
|
const metadataPath = join(__dirname, 'command-metadata.json');
|
|
if (existsSync(metadataPath)) {
|
|
return JSON.parse(readFileSync(metadataPath, 'utf-8'));
|
|
}
|
|
return {};
|
|
}
|
|
|
|
/**
|
|
* Generate a pinned skill's SKILL.md content.
|
|
*/
|
|
function commandPrefixForSkillsDir(skillsDir) {
|
|
return CODEX_HARNESSES.has(basename(dirname(skillsDir))) ? '$' : '/';
|
|
}
|
|
|
|
function generatePinnedSkill(command, metadata, commandPrefix) {
|
|
const desc = metadata[command]?.description || `Shortcut for ${commandPrefix}impeccable ${command}.`;
|
|
const hint = metadata[command]?.argumentHint || '[target]';
|
|
|
|
return `---
|
|
name: ${command}
|
|
description: "${desc}"
|
|
argument-hint: "${hint}"
|
|
user-invocable: true
|
|
---
|
|
|
|
${PIN_MARKER}
|
|
|
|
This is a pinned shortcut for \`${commandPrefix}impeccable ${command}\`.
|
|
|
|
Invoke ${commandPrefix}impeccable ${command}, passing along any arguments provided here, and follow its instructions.
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Pin a command: create shortcut skill in all harness dirs.
|
|
*/
|
|
function pin(command, projectRoot) {
|
|
const metadata = loadCommandMetadata();
|
|
const harnessDirs = findHarnessDirs(projectRoot);
|
|
|
|
if (harnessDirs.length === 0) {
|
|
console.log('No harness directories with impeccable installed found.');
|
|
return false;
|
|
}
|
|
|
|
let created = 0;
|
|
|
|
for (const skillsDir of harnessDirs) {
|
|
const commandPrefix = commandPrefixForSkillsDir(skillsDir);
|
|
const content = generatePinnedSkill(command, metadata, commandPrefix);
|
|
// Check if skill already exists (and isn't a pin)
|
|
const skillDir = join(skillsDir, command);
|
|
if (existsSync(skillDir)) {
|
|
const existingMd = join(skillDir, 'SKILL.md');
|
|
if (existsSync(existingMd)) {
|
|
const existing = readFileSync(existingMd, 'utf-8');
|
|
if (!existing.includes(PIN_MARKER)) {
|
|
console.log(` SKIP: ${skillDir} (non-pinned skill already exists)`);
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
mkdirSync(skillDir, { recursive: true });
|
|
writeFileSync(join(skillDir, 'SKILL.md'), content, 'utf-8');
|
|
console.log(` + ${skillDir}`);
|
|
created++;
|
|
}
|
|
|
|
if (created > 0) {
|
|
console.log(`\nPinned '${command}' as a standalone shortcut in ${created} location(s).`);
|
|
console.log('Use the pinned command directly in each harness.');
|
|
}
|
|
|
|
return created > 0;
|
|
}
|
|
|
|
/**
|
|
* Unpin a command: remove shortcut skill from all harness dirs.
|
|
*/
|
|
function unpin(command, projectRoot) {
|
|
const harnessDirs = findHarnessDirs(projectRoot);
|
|
let removed = 0;
|
|
|
|
for (const skillsDir of harnessDirs) {
|
|
const skillDir = join(skillsDir, command);
|
|
if (!existsSync(skillDir)) continue;
|
|
|
|
const skillMd = join(skillDir, 'SKILL.md');
|
|
if (!existsSync(skillMd)) continue;
|
|
|
|
// Safety: only remove if it's a pinned skill
|
|
const content = readFileSync(skillMd, 'utf-8');
|
|
if (!content.includes(PIN_MARKER)) {
|
|
console.log(` SKIP: ${skillDir} (not a pinned skill)`);
|
|
continue;
|
|
}
|
|
|
|
rmSync(skillDir, { recursive: true, force: true });
|
|
console.log(` - ${skillDir}`);
|
|
removed++;
|
|
}
|
|
|
|
if (removed > 0) {
|
|
console.log(`\nUnpinned '${command}' from ${removed} location(s).`);
|
|
console.log(`Use Impeccable's '${command}' workflow directly to access it.`);
|
|
} else {
|
|
console.log(`No pinned '${command}' shortcut found.`);
|
|
}
|
|
|
|
return removed > 0;
|
|
}
|
|
|
|
// --- CLI ---
|
|
const [,, action, command] = process.argv;
|
|
|
|
if (!action || !command) {
|
|
console.log('Usage: node pin.mjs <pin|unpin> <command>');
|
|
console.log(`\nAvailable commands: ${VALID_COMMANDS.join(', ')}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
if (action !== 'pin' && action !== 'unpin') {
|
|
console.error(`Unknown action: ${action}. Use 'pin' or 'unpin'.`);
|
|
process.exit(1);
|
|
}
|
|
|
|
if (!VALID_COMMANDS.includes(command)) {
|
|
console.error(`Unknown command: ${command}`);
|
|
console.error(`Available commands: ${VALID_COMMANDS.join(', ')}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const root = findProjectRoot();
|
|
|
|
if (action === 'pin') {
|
|
pin(command, root);
|
|
} else {
|
|
unpin(command, root);
|
|
}
|