@xfe-repo/cli-plugin-ai-rules 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @xfe-repo/cli-plugin-ai-rules
2
+
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 新增xfe-repo包更新检测能力
8
+ - Updated dependencies
9
+ - @xfe-repo/cli-plugin-git@2.0.2
10
+ - @xfe-repo/cli-core@2.0.3
11
+
12
+ ## 2.0.1
13
+
14
+ ### Patch Changes
15
+
16
+ - add README.md
17
+ - Updated dependencies
18
+ - @xfe-repo/cli-plugin-git@2.0.1
19
+ - @xfe-repo/cli-core@2.0.2
@@ -4,7 +4,7 @@
4
4
  * 处理 skill 文件夹的同步写入:整目录 rm + cp 覆盖,
5
5
  * 不做文件级 diff / 冲突检测。merge 型目标跳过 skill 同步。
6
6
  */
7
- import { cp, rm } from 'node:fs/promises';
7
+ import fs from 'fs-extra';
8
8
  import path from 'node:path';
9
9
  import { SyncItemType } from '../types.js';
10
10
  import { getTarget, isIndividualSlot, resolvePathTemplate } from '../targets.js';
@@ -25,8 +25,8 @@ export function planSkillDirs(target, items) {
25
25
  // ─── Write ──────
26
26
  export async function writeSkillDir(plan, projectRoot) {
27
27
  const absTarget = path.join(projectRoot, plan.targetDir);
28
- await rm(absTarget, { recursive: true, force: true });
29
- await cp(plan.sourceDir, absTarget, { recursive: true });
28
+ await fs.remove(absTarget);
29
+ await fs.copy(plan.sourceDir, absTarget);
30
30
  }
31
31
  export async function patchSkillDirInjections(config, projectRoot, injections) {
32
32
  const skillItems = [...injections.values()].flat().filter((i) => i.type === SyncItemType.Skill && i.sourcePath);
@@ -44,8 +44,8 @@ export async function patchSkillDirInjections(config, projectRoot, injections) {
44
44
  for (const item of skillItems) {
45
45
  const targetDir = path.dirname(template.replace('{id}', item.id));
46
46
  const absTarget = path.join(projectRoot, targetDir);
47
- await rm(absTarget, { recursive: true, force: true });
48
- await cp(item.sourcePath, absTarget, { recursive: true });
47
+ await fs.remove(absTarget);
48
+ await fs.copy(item.sourcePath, absTarget);
49
49
  dirs.push(targetDir);
50
50
  written++;
51
51
  }
@@ -60,7 +60,7 @@ export async function removeStaleSkillDirs(projectRoot, prevDirs, currentDirs) {
60
60
  if (currentSet.has(dir))
61
61
  continue;
62
62
  try {
63
- await rm(path.join(projectRoot, dir), { recursive: true, force: true });
63
+ await fs.remove(path.join(projectRoot, dir));
64
64
  removed++;
65
65
  }
66
66
  catch {
@@ -5,10 +5,9 @@
5
5
  * 缓存在 ~/.xfe/ai-rules-cache/<url-hash>/ 下,全局共享
6
6
  */
7
7
  import { createHash } from 'node:crypto';
8
- import { existsSync } from 'node:fs';
9
- import { mkdir } from 'node:fs/promises';
10
8
  import { homedir } from 'node:os';
11
9
  import path from 'node:path';
10
+ import fs from 'fs-extra';
12
11
  const CACHE_ROOT = path.join(homedir(), '.xfe', 'ai-rules-cache');
13
12
  // ─── Public ──────
14
13
  /**
@@ -18,8 +17,8 @@ const CACHE_ROOT = path.join(homedir(), '.xfe', 'ai-rules-cache');
18
17
  */
19
18
  export async function fetchCachedRepo(ctx, git, config) {
20
19
  const cachePath = getCachePath(config.source);
21
- await mkdir(CACHE_ROOT, { recursive: true });
22
- const isCloned = existsSync(path.join(cachePath, '.git'));
20
+ await fs.ensureDir(CACHE_ROOT);
21
+ const isCloned = fs.pathExistsSync(path.join(cachePath, '.git'));
23
22
  if (!isCloned) {
24
23
  ctx.logger.log(`首次拉取规则仓库: ${config.source}`);
25
24
  const success = await git.clone(ctx, { url: config.source, destination: cachePath });
@@ -46,6 +45,6 @@ export function getCachePath(source) {
46
45
  */
47
46
  export function hasCachedRepo(source) {
48
47
  const cachePath = getCachePath(source);
49
- return existsSync(path.join(cachePath, '.git'));
48
+ return fs.pathExistsSync(path.join(cachePath, '.git'));
50
49
  }
51
50
  //# sourceMappingURL=repo-cache.js.map
package/package.json CHANGED
@@ -1,22 +1,25 @@
1
1
  {
2
2
  "name": "@xfe-repo/cli-plugin-ai-rules",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "XFE AI Rules plugin - sync AI coding rules from remote repo to IDE configs",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "dependencies": {
9
+ "fs-extra": "^11.3.0",
9
10
  "gray-matter": "^4.0.3",
10
11
  "zod": "^4.3.6",
11
- "@xfe-repo/cli-core": "2.0.2",
12
- "@xfe-repo/cli-plugin-git": "2.0.1"
12
+ "@xfe-repo/cli-plugin-git": "2.0.2",
13
+ "@xfe-repo/cli-core": "2.0.3"
13
14
  },
14
15
  "devDependencies": {
16
+ "@types/fs-extra": "^11.0.4",
15
17
  "@types/node": "^24.3.0",
16
18
  "typescript": "^5.9.2"
17
19
  },
18
20
  "files": [
19
21
  "dist",
22
+ "CHANGELOG.md",
20
23
  "!dist/**/*.map"
21
24
  ],
22
25
  "license": "ISC",