From 6d5730ab18f8bf243f32956b27d6003f6e4fa9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=B1=BC=E5=B0=8F=E4=B8=B8=E5=AD=90?= <11136280+zhangyuxiaowanzia@user.noreply.gitee.com> Date: Fri, 12 Jun 2026 14:49:20 +0800 Subject: [PATCH] feat: add Codex skill install guidance --- apps/jscpd/README.md | 10 ++++++++++ apps/jscpd/__tests__/options.test.ts | 20 +++++++++++++++++++- apps/jscpd/src/index.ts | 6 +++++- docs/ai-ready.md | 14 +++++++++++++- 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/apps/jscpd/README.md b/apps/jscpd/README.md index a6384e46..a3baff89 100644 --- a/apps/jscpd/README.md +++ b/apps/jscpd/README.md @@ -629,6 +629,16 @@ npx skills add kucherenko/jscpd --skill jscpd npx skills add kucherenko/jscpd --skill dry-refactoring ``` +To install both skills for Codex explicitly: + +```bash +npx skills add kucherenko/jscpd --skill jscpd --skill dry-refactoring --agent codex +``` + +Add `--global` to install into Codex's user skills directory +(`~/.codex/skills/`) instead of the current project's `.agents/skills/` +directory. + ### PMD CPD XML ```xml diff --git a/apps/jscpd/__tests__/options.test.ts b/apps/jscpd/__tests__/options.test.ts index 3eeb857b..513a680c 100644 --- a/apps/jscpd/__tests__/options.test.ts +++ b/apps/jscpd/__tests__/options.test.ts @@ -5,7 +5,7 @@ import * as fs from 'fs'; import * as path from 'path'; import {IClone} from '@jscpd/core'; import {jscpd, detectClones, detectClonesAndStatistic} from '../src'; -import {bold, yellow} from 'colors/safe'; +import {bold, grey, yellow} from 'colors/safe'; const pathToFixtures = __dirname + '/../../../fixtures'; @@ -205,6 +205,24 @@ describe('jscpd options', () => { }); }); + describe('tips', () => { + it('should print the dry-refactoring skill install command by default', async () => { + await jscpd(['', '', fileWithClones]); + const log = (console.log as any); + expect(log).toHaveBeenCalledWith( + grey('💡 Auto-refactor with AI: npx skills add kucherenko/jscpd --skill dry-refactoring'), + ); + }); + + it('should not print skill install tips when --noTips is enabled', async () => { + await jscpd(['', '', fileWithClones, '--noTips']); + const log = (console.log as any); + expect(log).not.toHaveBeenCalledWith( + expect.stringContaining('npx skills add'), + ); + }); + }); + describe('Not Supported Format', () => { it('should skip files with not supported formats', async () => { const clones: IClone[] = await jscpd(['', '', diff --git a/apps/jscpd/src/index.ts b/apps/jscpd/src/index.ts index c7525aee..51b24d20 100644 --- a/apps/jscpd/src/index.ts +++ b/apps/jscpd/src/index.ts @@ -25,6 +25,8 @@ import { registerHooks } from "./init/hooks"; import { readJSONSync } from "fs-extra"; const TIMER_LABEL = "time"; +const DRY_REFACTORING_SKILL_INSTALL_COMMAND = + "npx skills add kucherenko/jscpd --skill dry-refactoring"; export const detectClones = ( opts: IOptions, @@ -63,7 +65,9 @@ export const detectClones = ( if (!options.noTips) { console.log(""); console.log( - grey("💡 Auto-refactor with AI: npx skills add kucherenko/jscpd"), + grey( + `💡 Auto-refactor with AI: ${DRY_REFACTORING_SKILL_INSTALL_COMMAND}`, + ), ); console.log( grey( diff --git a/docs/ai-ready.md b/docs/ai-ready.md index ac7953ec..b0230836 100644 --- a/docs/ai-ready.md +++ b/docs/ai-ready.md @@ -59,6 +59,18 @@ A guided process for reading clone output, choosing the right extraction strateg npx skills add kucherenko/jscpd --skill dry-refactoring ``` +### Codex + +To install both skills for Codex explicitly: + +```bash +npx skills add kucherenko/jscpd --skill jscpd --skill dry-refactoring --agent codex +``` + +Use `--global` to install them into the Codex user skills directory +(`~/.codex/skills/`) instead of the current project's `.agents/skills/` +directory. + After installation, ask your agent to "find and fix code duplication" and it will invoke jscpd with the right options and act on the results. ## MCP Server @@ -118,4 +130,4 @@ Available MCP tools exposed via the `/mcp` endpoint: - `get_statistics` — Get project stats (no inputs) - `check_current_directory` — Re-scan the working directory (no inputs) -Snippet checking uses an ephemeral in-memory store per request for isolation — no cross-request contamination, automatic cleanup, concurrent-request safe. \ No newline at end of file +Snippet checking uses an ephemeral in-memory store per request for isolation — no cross-request contamination, automatic cleanup, concurrent-request safe.