@eworkbase/plugin-ai-rules 0.3.4 → 0.3.6
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/dist/plugin.mjs +16 -4
- package/dist/ui/dist-BGSb8hFh.js +262 -0
- package/dist/ui/index.html +1 -1
- package/dist/ui/main.js +24 -24
- package/dist/ui/markdown-editor-assets/LICENSE +21 -0
- package/dist/ui/markdown-editor-assets/ant.js +174 -0
- package/dist/ui/markdown-editor-assets/dist/js/highlight.js/styles/github.min.css +10 -0
- package/dist/ui/markdown-editor-assets/lute.min.js +87 -0
- package/dist/ui/markdown-editor-assets/zh_CN.js +86 -0
- package/dist/ui/style.css +2279 -0
- package/package.json +11 -11
package/dist/plugin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -7840,9 +7840,10 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
|
7840
7840
|
}
|
|
7841
7841
|
//#endregion
|
|
7842
7842
|
//#region src/injection-writer.ts
|
|
7843
|
-
/**
|
|
7843
|
+
/** 安全读写规则资源与客户端片段,清理空 Skill 目录并保护并发用户修改。 */
|
|
7844
7844
|
const BLOCK_START = "<!-- WORKBASE_INJECT_START -->";
|
|
7845
7845
|
const BLOCK_END = "<!-- WORKBASE_INJECT_END -->";
|
|
7846
|
+
const SKILLS_DIRECTORY = "skills";
|
|
7846
7847
|
const INSTRUCTION_FILES = /* @__PURE__ */ new Set(["AGENTS.md", "CLAUDE.md"]);
|
|
7847
7848
|
const JSON_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".jsonc"]);
|
|
7848
7849
|
const MAXIMUM_FILE_BYTES = 4194304;
|
|
@@ -7991,6 +7992,7 @@ function writeSafeFile({ root, relativePath, content }) {
|
|
|
7991
7992
|
const filePath = safeFilePath(root, relativePath);
|
|
7992
7993
|
if (content === null) {
|
|
7993
7994
|
rmSync(filePath, { force: true });
|
|
7995
|
+
removeEmptySkillDirectories(root, relativePath);
|
|
7994
7996
|
return;
|
|
7995
7997
|
}
|
|
7996
7998
|
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
@@ -8000,6 +8002,16 @@ function writeSafeFile({ root, relativePath, content }) {
|
|
|
8000
8002
|
mode: 384
|
|
8001
8003
|
});
|
|
8002
8004
|
}
|
|
8005
|
+
function removeEmptySkillDirectories(root, relativePath) {
|
|
8006
|
+
const segments = relativePath.split("/");
|
|
8007
|
+
const skillDirectoryIndex = segments.indexOf(SKILLS_DIRECTORY) + 1;
|
|
8008
|
+
if (skillDirectoryIndex === 0) return;
|
|
8009
|
+
for (let depth = segments.length - 1; depth > skillDirectoryIndex; depth -= 1) {
|
|
8010
|
+
const directory = safeFilePath(root, segments.slice(0, depth).join("/"));
|
|
8011
|
+
if (!lstatSync(directory, { throwIfNoEntry: false })?.isDirectory() || readdirSync(directory).length > 0) return;
|
|
8012
|
+
rmdirSync(directory);
|
|
8013
|
+
}
|
|
8014
|
+
}
|
|
8003
8015
|
function mergeContent({ relativePath, before, fragment }) {
|
|
8004
8016
|
if (isStructured(relativePath)) {
|
|
8005
8017
|
const merged = mergeDocument(parseDocument$1(relativePath, before ?? ""), parseDocument$1(relativePath, fragment));
|
|
@@ -8083,7 +8095,7 @@ function restoreDocument({ location, original, applied, current, requireApplied
|
|
|
8083
8095
|
}
|
|
8084
8096
|
function isStructured(relativePath) {
|
|
8085
8097
|
if (relativePath.split("/").some((segment) => [
|
|
8086
|
-
|
|
8098
|
+
SKILLS_DIRECTORY,
|
|
8087
8099
|
"commands",
|
|
8088
8100
|
"agents"
|
|
8089
8101
|
].includes(segment))) return false;
|
|
@@ -15678,7 +15690,7 @@ const CONFIGURATION_INPUT_SCHEMA = object({
|
|
|
15678
15690
|
}).strict();
|
|
15679
15691
|
var plugin_default = definePlugin({
|
|
15680
15692
|
id: "ai-rules",
|
|
15681
|
-
title: "AI
|
|
15693
|
+
title: "AI 规则",
|
|
15682
15694
|
setup(context, hooks) {
|
|
15683
15695
|
registerResources(context, hooks);
|
|
15684
15696
|
const rulesRoot = path.join(context.project.root, RULES_DIRECTORY);
|