heymark 2.0.0 → 2.0.1

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,97 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { execSync } = require("child_process");
6
-
7
- const CACHE_DIR_NAME = path.join(".heymark", "cache");
8
- const DEFAULT_BRANCH = "main";
9
- const GITHUB_REPO_PATTERN = /github\.com[:/]([^/]+\/[^/]+?)(?:\/|$)/;
10
- const GENERIC_REPO_PATTERN = /([^/]+\/[^/]+?)(?:\/|$)/;
11
-
12
- /**
13
- * Convert repository URL to a stable cache directory name.
14
- * https://github.com/org/repo -> org-repo
15
- * git@github.com:org/repo.git -> org-repo
16
- * @param {string} repoUrl
17
- * @returns {string}
18
- */
19
- function sanitizeRepoName(repoUrl) {
20
- let normalized = repoUrl.trim();
21
- if (normalized.endsWith(".git")) {
22
- normalized = normalized.slice(0, -4);
23
- }
24
-
25
- const match = normalized.match(GITHUB_REPO_PATTERN) || normalized.match(GENERIC_REPO_PATTERN);
26
- if (match) {
27
- return match[1].replace(/\//g, "-");
28
- }
29
-
30
- return normalized.replace(/[^a-zA-Z0-9._-]/g, "-") || "repo";
31
- }
32
-
33
- function cloneLinkedRepo(projectRoot, clonePath, branch, repoUrl) {
34
- execSync(`git clone --depth 1 --branch "${branch}" "${repoUrl}" "${clonePath}"`, {
35
- stdio: "inherit",
36
- cwd: projectRoot,
37
- });
38
- }
39
-
40
- function updateLinkedRepo(clonePath, branch) {
41
- execSync(`git fetch origin && git checkout --quiet . && git pull --quiet origin "${branch}"`, {
42
- stdio: "pipe",
43
- cwd: clonePath,
44
- });
45
- }
46
-
47
- function resolveLinkedFolder(clonePath, folder) {
48
- const rulesDir = folder ? path.join(clonePath, folder) : clonePath;
49
- if (!fs.existsSync(rulesDir) || !fs.statSync(rulesDir).isDirectory()) {
50
- console.error(`[Error] Rules directory not found in repo: ${folder || "(root)"}`);
51
- process.exit(1);
52
- }
53
- return rulesDir;
54
- }
55
-
56
- /**
57
- * Clone or update remote repository and return local rules directory.
58
- * Private repositories require user git credentials (SSH key or token).
59
- * @param {string} projectRoot
60
- * @param {{ repoUrl: string, branch?: string, folder?: string }} config
61
- * @returns {string}
62
- */
63
- function getLinkedRulesDir(projectRoot, config) {
64
- const repoUrl = config.repoUrl;
65
- const branch = config.branch || DEFAULT_BRANCH;
66
- const folder = config.folder || "";
67
-
68
- const cacheBase = path.join(projectRoot, CACHE_DIR_NAME);
69
- const repoName = sanitizeRepoName(repoUrl);
70
- const clonePath = path.join(cacheBase, repoName);
71
-
72
- if (!fs.existsSync(clonePath)) {
73
- fs.mkdirSync(cacheBase, { recursive: true });
74
- try {
75
- cloneLinkedRepo(projectRoot, clonePath, branch, repoUrl);
76
- } catch {
77
- console.error("[Error] Failed to clone rules repository.");
78
- console.error(" For private repos, ensure you have access (SSH key or HTTPS token).");
79
- console.error(" Example: heymark link https://github.com/org/repo.git");
80
- process.exit(1);
81
- }
82
- } else {
83
- try {
84
- updateLinkedRepo(clonePath, branch);
85
- } catch {
86
- // Continue with cached clone when fetch or pull fails.
87
- }
88
- }
89
-
90
- return resolveLinkedFolder(clonePath, folder);
91
- }
92
-
93
- module.exports = {
94
- CACHE_DIR_NAME,
95
- getLinkedRulesDir,
96
- sanitizeRepoName,
97
- };
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- const SKILLS_DIR = path.join(".agent", "skills");
7
- const SKILL_FILE_NAME = "SKILL.md";
8
-
9
- function getSkillDir(projectRoot, ruleName) {
10
- return path.join(projectRoot, SKILLS_DIR, ruleName);
11
- }
12
-
13
- function createSkillContent(rule) {
14
- const frontmatterLines = [
15
- "---",
16
- `name: ${rule.name}`,
17
- `description: "${rule.description}"`,
18
- "---",
19
- ];
20
-
21
- return `${frontmatterLines.join("\n")}\n\n${rule.body}\n`;
22
- }
23
-
24
- module.exports = {
25
- name: "Antigravity",
26
- output: ".agent/skills/*/SKILL.md",
27
-
28
- generate(rules, projectRoot) {
29
- for (const rule of rules) {
30
- const skillDir = getSkillDir(projectRoot, rule.name);
31
- fs.mkdirSync(skillDir, { recursive: true });
32
- const filePath = path.join(skillDir, SKILL_FILE_NAME);
33
- const content = createSkillContent(rule);
34
- fs.writeFileSync(filePath, content, "utf8");
35
- }
36
-
37
- return rules.length;
38
- },
39
-
40
- clean(ruleNames, projectRoot) {
41
- const skillsDirPath = path.join(projectRoot, SKILLS_DIR);
42
- if (!fs.existsSync(skillsDirPath)) {
43
- return [];
44
- }
45
-
46
- fs.rmSync(skillsDirPath, { recursive: true, force: true });
47
- return [SKILLS_DIR];
48
- },
49
- };
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- const SKILLS_DIR = path.join(".claude", "skills");
7
- const SKILL_FILE_NAME = "SKILL.md";
8
-
9
- function getSkillDir(projectRoot, ruleName) {
10
- return path.join(projectRoot, SKILLS_DIR, ruleName);
11
- }
12
-
13
- function createSkillContent(rule) {
14
- const frontmatterLines = [
15
- "---",
16
- `name: ${rule.name}`,
17
- `description: "${rule.description}"`,
18
- "---",
19
- ];
20
-
21
- return `${frontmatterLines.join("\n")}\n\n${rule.body}\n`;
22
- }
23
-
24
- module.exports = {
25
- name: "Claude Code",
26
- output: ".claude/skills/*/SKILL.md",
27
-
28
- generate(rules, projectRoot) {
29
- for (const rule of rules) {
30
- const skillDir = getSkillDir(projectRoot, rule.name);
31
- fs.mkdirSync(skillDir, { recursive: true });
32
- const filePath = path.join(skillDir, SKILL_FILE_NAME);
33
- const content = createSkillContent(rule);
34
- fs.writeFileSync(filePath, content, "utf8");
35
- }
36
-
37
- return rules.length;
38
- },
39
-
40
- clean(ruleNames, projectRoot) {
41
- const skillsDirPath = path.join(projectRoot, SKILLS_DIR);
42
- if (!fs.existsSync(skillsDirPath)) {
43
- return [];
44
- }
45
-
46
- fs.rmSync(skillsDirPath, { recursive: true, force: true });
47
- return [SKILLS_DIR];
48
- },
49
- };
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- const SKILLS_DIR = path.join(".agents", "skills");
7
- const SKILL_FILE_NAME = "SKILL.md";
8
-
9
- function getSkillDir(projectRoot, ruleName) {
10
- return path.join(projectRoot, SKILLS_DIR, ruleName);
11
- }
12
-
13
- function createSkillContent(rule) {
14
- const frontmatterLines = [
15
- "---",
16
- `name: ${rule.name}`,
17
- `description: "${rule.description}"`,
18
- "---",
19
- ];
20
-
21
- return `${frontmatterLines.join("\n")}\n\n${rule.body}\n`;
22
- }
23
-
24
- module.exports = {
25
- name: "OpenAI Codex",
26
- output: ".agents/skills/*/SKILL.md",
27
-
28
- generate(rules, projectRoot) {
29
- for (const rule of rules) {
30
- const skillDir = getSkillDir(projectRoot, rule.name);
31
- fs.mkdirSync(skillDir, { recursive: true });
32
- const filePath = path.join(skillDir, SKILL_FILE_NAME);
33
- const content = createSkillContent(rule);
34
- fs.writeFileSync(filePath, content, "utf8");
35
- }
36
-
37
- return rules.length;
38
- },
39
-
40
- clean(ruleNames, projectRoot) {
41
- const skillsDirPath = path.join(projectRoot, SKILLS_DIR);
42
- if (!fs.existsSync(skillsDirPath)) {
43
- return [];
44
- }
45
-
46
- fs.rmSync(skillsDirPath, { recursive: true, force: true });
47
- return [SKILLS_DIR];
48
- },
49
- };
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- const INSTRUCTIONS_DIR = path.join(".github", "instructions");
7
- const FILE_SUFFIX = ".instructions.md";
8
- const DEFAULT_GLOB = "**";
9
-
10
- function getInstructionPath(projectRoot, ruleName) {
11
- return path.join(projectRoot, INSTRUCTIONS_DIR, `${ruleName}${FILE_SUFFIX}`);
12
- }
13
-
14
- function normalizeGlobs(globsValue) {
15
- if (!globsValue) {
16
- return [DEFAULT_GLOB];
17
- }
18
-
19
- const globs = globsValue
20
- .split(",")
21
- .map((glob) => glob.trim())
22
- .filter(Boolean);
23
-
24
- return globs.length > 0 ? globs : [DEFAULT_GLOB];
25
- }
26
-
27
- function createInstructionContent(rule) {
28
- const applyToLines = normalizeGlobs(rule.globs)
29
- .map((glob) => ` - "${glob}"`)
30
- .join("\n");
31
- const header = `applyTo:\n${applyToLines}\n---`;
32
- return `${header}\n\n${rule.body}\n`;
33
- }
34
-
35
- module.exports = {
36
- name: "GitHub Copilot",
37
- output: ".github/instructions/*.instructions.md",
38
-
39
- generate(rules, projectRoot) {
40
- const destDir = path.join(projectRoot, INSTRUCTIONS_DIR);
41
- fs.mkdirSync(destDir, { recursive: true });
42
-
43
- for (const rule of rules) {
44
- const filePath = getInstructionPath(projectRoot, rule.name);
45
- const content = createInstructionContent(rule);
46
- fs.writeFileSync(filePath, content, "utf8");
47
- }
48
-
49
- return rules.length;
50
- },
51
-
52
- clean(ruleNames, projectRoot) {
53
- const instructionsDirPath = path.join(projectRoot, INSTRUCTIONS_DIR);
54
- if (!fs.existsSync(instructionsDirPath)) {
55
- return [];
56
- }
57
-
58
- fs.rmSync(instructionsDirPath, { recursive: true, force: true });
59
- return [INSTRUCTIONS_DIR];
60
- },
61
- };
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- const RULES_DIR = path.join(".cursor", "rules");
7
- const FILE_SUFFIX = ".mdc";
8
-
9
- function getRulePath(projectRoot, ruleName) {
10
- return path.join(projectRoot, RULES_DIR, `${ruleName}${FILE_SUFFIX}`);
11
- }
12
-
13
- function createRuleContent(rule) {
14
- const frontmatterLines = ["---", `description: "${rule.description}"`];
15
- if (rule.globs) {
16
- frontmatterLines.push(`globs: "${rule.globs}"`);
17
- }
18
- frontmatterLines.push(`alwaysApply: ${rule.alwaysApply}`);
19
- frontmatterLines.push("---");
20
-
21
- return `${frontmatterLines.join("\n")}\n\n${rule.body}\n`;
22
- }
23
-
24
- module.exports = {
25
- name: "Cursor",
26
- output: ".cursor/rules/*.mdc",
27
-
28
- generate(rules, projectRoot) {
29
- const destDir = path.join(projectRoot, RULES_DIR);
30
- fs.mkdirSync(destDir, { recursive: true });
31
-
32
- for (const rule of rules) {
33
- fs.writeFileSync(getRulePath(projectRoot, rule.name), createRuleContent(rule), "utf8");
34
- }
35
-
36
- return rules.length;
37
- },
38
-
39
- clean(ruleNames, projectRoot) {
40
- const rulesDirPath = path.join(projectRoot, RULES_DIR);
41
- if (!fs.existsSync(rulesDirPath)) {
42
- return [];
43
- }
44
-
45
- fs.rmSync(rulesDirPath, { recursive: true, force: true });
46
- return [RULES_DIR];
47
- },
48
- };