refactor: strict review variants load skill via Skill tool

Remove embedded files, use Skill tool to load review/security-review
skill instead, matching the same mechanism as /review.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
kingboung 2026-05-12 17:38:56 +08:00
parent 909e001100
commit 08ad8a55da

View File

@ -1,9 +1,8 @@
import { registerBundledSkill } from 'src/skills/bundledSkills.js' import { registerBundledSkill } from 'src/skills/bundledSkills.js'
import { getResolvedLanguage } from 'src/utils/language.js'
import { import {
SKILL_FILES,
SKILL_METADATA, SKILL_METADATA,
} from 'src/costrict/review/skill/builtin.js' } from 'src/costrict/review/skill/builtin.js'
import { getResolvedLanguage } from 'src/utils/language.js'
const LOCALE_MAP: Record<string, string> = { zh: 'zh-CN', en: 'en' } const LOCALE_MAP: Record<string, string> = { zh: 'zh-CN', en: 'en' }
@ -25,7 +24,6 @@ const ALLOWED_TOOLS = [
function registerStrictReviewSkill( function registerStrictReviewSkill(
name: string, name: string,
skillKey: string, skillKey: string,
files: Record<string, string>,
description: string, description: string,
): void { ): void {
registerBundledSkill({ registerBundledSkill({
@ -35,23 +33,18 @@ function registerStrictReviewSkill(
userInvocable: true, userInvocable: true,
disableModelInvocation: false, disableModelInvocation: false,
allowedTools: ALLOWED_TOOLS, allowedTools: ALLOWED_TOOLS,
files,
async getPromptForCommand(args) { async getPromptForCommand(args) {
return [{ type: 'text', text: args.trim() || `Please perform a ${skillKey}.` }] return [{ type: 'text', text: `Please use the Skill tool to load the \`${skillKey}\` skill.\n\n${args.trim()}` }]
}, },
}) })
} }
export function registerStrictReviewSkills(): void { export function registerStrictReviewSkills(): void {
const locale = getLocale() const locale = getLocale()
const localeFiles = SKILL_FILES[locale]
const localeMetadata = SKILL_METADATA[locale] const localeMetadata = SKILL_METADATA[locale]
if (!localeFiles || !localeMetadata) return if (!localeMetadata) return
for (const [skillKey, files] of Object.entries(localeFiles)) { for (const [skillKey, meta] of Object.entries(localeMetadata)) {
const meta = localeMetadata[skillKey] registerStrictReviewSkill(`strict:${skillKey}`, skillKey, meta.description)
if (!meta || !files) continue
registerStrictReviewSkill(`strict:${skillKey}`, skillKey, files, meta.description)
} }
} }