feat: sync triage skill files
This commit is contained in:
+20
-6
@@ -4,6 +4,16 @@ import path from 'path';
|
||||
import { GITEA_SERVER_URL, GITEA_REPOSITORY, GITEA_TOKEN, PR_HEAD_BRANCH, FINDINGS_PATH } from './config.js';
|
||||
|
||||
const remoteUrl = `${GITEA_SERVER_URL.replace(/\/$/, '')}/${GITEA_REPOSITORY}.git`;
|
||||
const SYNC_PATHS = [
|
||||
FINDINGS_PATH,
|
||||
'.amazonq/rules/triage-findings.md',
|
||||
'.claude/skills/triage-findings/SKILL.md',
|
||||
'.gemini/skills/triage-findings/SKILL.md',
|
||||
'.github/copilot-instructions.md',
|
||||
'.github/skills/triage-findings/SKILL.md',
|
||||
'CLAUDE.md',
|
||||
'GEMINI.md',
|
||||
];
|
||||
|
||||
function makeRunner(spawn) {
|
||||
return function run(args, cwd, env) {
|
||||
@@ -55,16 +65,20 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync)
|
||||
run(['config', 'user.email', 'ai-review[bot]@gitea'], repoDir);
|
||||
run(['config', 'user.name', 'AI Review Bot'], repoDir);
|
||||
|
||||
const srcFindings = path.join(workspace, FINDINGS_PATH);
|
||||
const destFindings = path.join(repoDir, FINDINGS_PATH);
|
||||
fs.mkdirSync(path.dirname(destFindings), { recursive: true });
|
||||
fs.copyFileSync(srcFindings, destFindings);
|
||||
// Always copy source files over the repo copy so skill files stay in sync.
|
||||
for (const relPath of SYNC_PATHS) {
|
||||
const src = path.join(workspace, relPath);
|
||||
const dest = path.join(repoDir, relPath);
|
||||
if (!fs.existsSync(src)) continue;
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
}
|
||||
|
||||
run(['add', FINDINGS_PATH], repoDir);
|
||||
run(['add', ...SYNC_PATHS], repoDir);
|
||||
|
||||
const status = run(['status', '--porcelain'], repoDir);
|
||||
if (!status) {
|
||||
console.log(' findings.json 無變更,跳過 commit');
|
||||
console.log(' sync files 無變更,跳過 commit');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user