deuk-agent-rule 2.2.0 → 2.2.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.
@@ -1,50 +1,50 @@
1
- import {
2
- copyFileSync,
3
- existsSync,
4
- mkdirSync,
5
- readFileSync,
6
- readdirSync,
7
- rmSync,
8
- writeFileSync,
9
- } from "fs";
10
- import { join, dirname } from "path";
11
- import { fileURLToPath } from "url";
12
-
13
- const __dirname = dirname(fileURLToPath(import.meta.url));
14
- const pkgRoot = join(__dirname, "..");
15
-
16
- /** Copy publish/ templates into bundle/ for npm packaging. */
17
- const publishDir = join(pkgRoot, "publish");
18
- const publishRulesDir = join(publishDir, "rules");
19
- const rulesDest = join(pkgRoot, "bundle", "rules");
20
- const agentsSrc = join(publishDir, "AGENTS.md");
21
- const agentsDest = join(pkgRoot, "bundle", "AGENTS.md");
22
- const cursorrulesSrc = join(publishDir, ".cursorrules");
23
- const cursorrulesDest = join(pkgRoot, "bundle", ".cursorrules");
24
-
25
- if (!existsSync(publishDir)) {
26
- throw new Error("Missing publish template dir: " + publishDir);
27
- }
28
- if (!existsSync(publishRulesDir)) {
29
- throw new Error("Missing publish/rules: " + publishRulesDir);
30
- }
31
- if (!existsSync(agentsSrc)) {
32
- throw new Error("Missing publish/AGENTS.md: " + agentsSrc);
33
- }
34
- if (!existsSync(cursorrulesSrc)) {
35
- throw new Error("Missing publish/.cursorrules: " + cursorrulesSrc);
36
- }
37
-
38
- if (existsSync(rulesDest)) {
39
- rmSync(rulesDest, { recursive: true });
40
- }
41
- mkdirSync(rulesDest, { recursive: true });
42
- for (const name of readdirSync(publishRulesDir)) {
43
- if (!name.endsWith(".mdc")) continue;
44
- copyFileSync(join(publishRulesDir, name), join(rulesDest, name));
45
- }
46
-
47
- const agentsBody = readFileSync(agentsSrc, "utf8");
48
- writeFileSync(agentsDest, agentsBody, "utf8");
49
- copyFileSync(cursorrulesSrc, cursorrulesDest);
50
- console.log("deuk-agent-rule: synced bundle from publish/ template.");
1
+ import {
2
+ copyFileSync,
3
+ existsSync,
4
+ mkdirSync,
5
+ readFileSync,
6
+ readdirSync,
7
+ rmSync,
8
+ writeFileSync,
9
+ } from "fs";
10
+ import { join, dirname } from "path";
11
+ import { fileURLToPath } from "url";
12
+
13
+ const __dirname = dirname(fileURLToPath(import.meta.url));
14
+ const pkgRoot = join(__dirname, "..");
15
+
16
+ /** Copy publish/ templates into bundle/ for npm packaging. */
17
+ const publishDir = join(pkgRoot, "publish");
18
+ const publishRulesDir = join(publishDir, "rules");
19
+ const rulesDest = join(pkgRoot, "bundle", "rules");
20
+ const agentsSrc = join(publishDir, "AGENTS.md");
21
+ const agentsDest = join(pkgRoot, "bundle", "AGENTS.md");
22
+ const cursorrulesSrc = join(publishDir, ".cursorrules");
23
+ const cursorrulesDest = join(pkgRoot, "bundle", ".cursorrules");
24
+
25
+ if (!existsSync(publishDir)) {
26
+ throw new Error("Missing publish template dir: " + publishDir);
27
+ }
28
+ if (!existsSync(publishRulesDir)) {
29
+ throw new Error("Missing publish/rules: " + publishRulesDir);
30
+ }
31
+ if (!existsSync(agentsSrc)) {
32
+ throw new Error("Missing publish/AGENTS.md: " + agentsSrc);
33
+ }
34
+ if (!existsSync(cursorrulesSrc)) {
35
+ throw new Error("Missing publish/.cursorrules: " + cursorrulesSrc);
36
+ }
37
+
38
+ if (existsSync(rulesDest)) {
39
+ rmSync(rulesDest, { recursive: true });
40
+ }
41
+ mkdirSync(rulesDest, { recursive: true });
42
+ for (const name of readdirSync(publishRulesDir)) {
43
+ if (!name.endsWith(".mdc")) continue;
44
+ copyFileSync(join(publishRulesDir, name), join(rulesDest, name));
45
+ }
46
+
47
+ const agentsBody = readFileSync(agentsSrc, "utf8");
48
+ writeFileSync(agentsDest, agentsBody, "utf8");
49
+ copyFileSync(cursorrulesSrc, cursorrulesDest);
50
+ console.log("deuk-agent-rule: synced bundle from publish/ template.");
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Populates ../DeukAgentRulesOSS for the public GitHub repo.
3
+ * Run: cd deuk-agent-rule && npm run sync:oss
4
+ */
5
+ import { cpSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
6
+ import { dirname, join } from "path";
7
+ import { fileURLToPath } from "url";
8
+
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const pkgRoot = join(__dirname, "..");
11
+ const repoRoot = join(pkgRoot, "..");
12
+ const ossRoot = join(repoRoot, "DeukAgentRulesOSS");
13
+ const ossPublic = join(pkgRoot, "oss-public");
14
+
15
+ /** Set DEUK_AGENT_RULES_OSS_REPO to override, e.g. https://github.com/you/DeukAgentRulesOSS */
16
+ const OSS_REPO =
17
+ process.env.DEUK_AGENT_RULES_OSS_REPO || "https://github.com/joygram/DeukAgentRules";
18
+
19
+ function gitBase() {
20
+ let u = OSS_REPO.trim().replace(/\.git$/i, "").replace(/\/$/, "");
21
+ if (!u.startsWith("http")) return u;
22
+ return u;
23
+ }
24
+
25
+ const base = gitBase();
26
+ const gitUrl = base.startsWith("http") ? "git+" + base + ".git" : base;
27
+
28
+ /** Strip OSS package.json hooks not used in the public mirror. */
29
+ function stripOssVersionrcScripts(ossVersionrcPath) {
30
+ let t = readFileSync(ossVersionrcPath, "utf8").replace(/\r\n/g, "\n");
31
+ t = t.replace(/\n scripts:\s*\{\n[\s\S]*?\n \},\s*\n/, "\n");
32
+ writeFileSync(ossVersionrcPath, t, "utf8");
33
+ }
34
+
35
+ mkdirSync(join(ossRoot, "scripts"), { recursive: true });
36
+ mkdirSync(join(ossRoot, "publish"), { recursive: true });
37
+
38
+ cpSync(join(pkgRoot, "publish"), join(ossRoot, "publish"), { recursive: true, force: true });
39
+ if (existsSync(join(pkgRoot, ".github"))) {
40
+ cpSync(join(pkgRoot, ".github"), join(ossRoot, ".github"), { recursive: true, force: true });
41
+ }
42
+ cpSync(join(pkgRoot, "scripts"), join(ossRoot, "scripts"), { recursive: true, force: true });
43
+
44
+ if (!existsSync(ossPublic)) {
45
+ throw new Error("Missing oss-public/: " + ossPublic);
46
+ }
47
+ cpSync(join(pkgRoot, "README.md"), join(ossRoot, "README.md"), { force: true });
48
+ cpSync(join(pkgRoot, "README.ko.md"), join(ossRoot, "README.ko.md"), { force: true });
49
+ if (existsSync(join(pkgRoot, "CHANGELOG.md"))) {
50
+ cpSync(join(pkgRoot, "CHANGELOG.md"), join(ossRoot, "CHANGELOG.md"), { force: true });
51
+ }
52
+ if (existsSync(join(pkgRoot, "package-lock.json"))) {
53
+ cpSync(join(pkgRoot, "package-lock.json"), join(ossRoot, "package-lock.json"), { force: true });
54
+ }
55
+ if (existsSync(join(pkgRoot, "LICENSE"))) {
56
+ cpSync(join(pkgRoot, "LICENSE"), join(ossRoot, "LICENSE"), { force: true });
57
+ }
58
+ if (existsSync(join(pkgRoot, ".npmrc"))) {
59
+ cpSync(join(pkgRoot, ".npmrc"), join(ossRoot, ".npmrc"), { force: true });
60
+ }
61
+ if (existsSync(join(pkgRoot, ".versionrc.cjs"))) {
62
+ cpSync(join(pkgRoot, ".versionrc.cjs"), join(ossRoot, ".versionrc.cjs"), { force: true });
63
+ stripOssVersionrcScripts(join(ossRoot, ".versionrc.cjs"));
64
+ }
65
+ const changelogTemplates = join(pkgRoot, "changelog-templates");
66
+ if (existsSync(changelogTemplates)) {
67
+ cpSync(changelogTemplates, join(ossRoot, "changelog-templates"), { recursive: true, force: true });
68
+ }
69
+ cpSync(join(ossPublic, "RELEASING.md"), join(ossRoot, "RELEASING.md"), { force: true });
70
+ cpSync(join(ossPublic, "RELEASING.ko.md"), join(ossRoot, "RELEASING.ko.md"), { force: true });
71
+ cpSync(join(ossPublic, "GITHUB_DESCRIPTION.md"), join(ossRoot, "GITHUB_DESCRIPTION.md"), {
72
+ force: true,
73
+ });
74
+
75
+ const srcPkg = JSON.parse(readFileSync(join(pkgRoot, "package.json"), "utf8"));
76
+ const outPkg = {
77
+ ...srcPkg,
78
+ license: srcPkg.license || "Apache-2.0",
79
+ repository: {
80
+ type: "git",
81
+ url: gitUrl,
82
+ },
83
+ bugs: {
84
+ url: base.startsWith("http") ? base + "/issues" : base,
85
+ },
86
+ homepage: base.startsWith("http") ? base + "#readme" : base,
87
+ files: [
88
+ "LICENSE",
89
+ "bundle/**/*",
90
+ "scripts/**/*.mjs",
91
+ "README.md",
92
+ "README.ko.md",
93
+ "CHANGELOG.md",
94
+ ],
95
+ };
96
+ delete outPkg.private;
97
+ if (outPkg.scripts && outPkg.scripts["merge:dry"]) {
98
+ const { "merge:dry": _md, ...r2 } = outPkg.scripts;
99
+ outPkg.scripts = r2;
100
+ }
101
+ if (outPkg.scripts && outPkg.scripts["sync:oss"]) {
102
+ const { "sync:oss": _drop, ...rest } = outPkg.scripts;
103
+ outPkg.scripts = rest;
104
+ }
105
+ /** Mirror is not a publish/version source: no bump scripts or release devDependencies. */
106
+ for (const k of ["bump", "bump:patch", "bump:minor", "bump:major"]) {
107
+ if (outPkg.scripts && outPkg.scripts[k]) {
108
+ const { [k]: _drop, ...rest } = outPkg.scripts;
109
+ outPkg.scripts = rest;
110
+ }
111
+ }
112
+ delete outPkg.devDependencies;
113
+
114
+ writeFileSync(join(ossRoot, "package.json"), JSON.stringify(outPkg, null, 2) + "\n", "utf8");
115
+
116
+ const ossPolish = join(ossRoot, "scripts", "changelog-polish.mjs");
117
+ if (existsSync(ossPolish)) {
118
+ unlinkSync(ossPolish);
119
+ }
120
+
121
+ console.log("deuk-agent-rule: synced OSS tree at " + ossRoot);
122
+ console.log(" Override repo URL: DEUK_AGENT_RULES_OSS_REPO=https://github.com/org/DeukAgentRulesOSS");