heymark 2.0.1 → 2.1.0

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/src/alias.js CHANGED
@@ -1,41 +1,41 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const Module = require("module");
4
-
5
- const PREFIX = "@/";
6
- const REGISTERED_KEY = "__heymark_alias_registered__";
7
- const ROOT = __dirname;
8
-
9
- function getPath(request) {
10
- if (!request.startsWith(PREFIX)) {
11
- return null;
12
- }
13
-
14
- const rest = request.slice(PREFIX.length);
15
- const base = path.join(ROOT, rest);
16
- const candidates = [`${base}.js`, path.join(base, "index.js"), base];
17
-
18
- const found = candidates.find((c) => fs.existsSync(c));
19
- return found || base;
20
- }
21
-
22
- function registerPath() {
23
- const g = /** @type {Record<string, unknown>} */ (globalThis);
24
- if (g[REGISTERED_KEY] === true) {
25
- return;
26
- }
27
-
28
- const original = Module._resolveFilename;
29
-
30
- Module._resolveFilename = function (request, parent, isMain, options) {
31
- const resolved = typeof request === "string" ? getPath(request) : null;
32
- if (resolved) {
33
- return original.call(this, resolved, parent, isMain, options);
34
- }
35
- return original.call(this, request, parent, isMain, options);
36
- };
37
-
38
- g[REGISTERED_KEY] = true;
39
- }
40
-
41
- registerPath();
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const Module = require("module");
4
+
5
+ const PREFIX = "@/";
6
+ const REGISTERED_KEY = "__heymark_alias_registered__";
7
+ const ROOT = __dirname;
8
+
9
+ function getPath(request) {
10
+ if (!request.startsWith(PREFIX)) {
11
+ return null;
12
+ }
13
+
14
+ const rest = request.slice(PREFIX.length);
15
+ const base = path.join(ROOT, rest);
16
+ const candidates = [`${base}.js`, path.join(base, "index.js"), base];
17
+
18
+ const found = candidates.find((c) => fs.existsSync(c));
19
+ return found || base;
20
+ }
21
+
22
+ function registerPath() {
23
+ const g = /** @type {Record<string, unknown>} */ (globalThis);
24
+ if (g[REGISTERED_KEY] === true) {
25
+ return;
26
+ }
27
+
28
+ const original = Module._resolveFilename;
29
+
30
+ Module._resolveFilename = function (request, parent, isMain, options) {
31
+ const resolved = typeof request === "string" ? getPath(request) : null;
32
+ if (resolved) {
33
+ return original.call(this, resolved, parent, isMain, options);
34
+ }
35
+ return original.call(this, request, parent, isMain, options);
36
+ };
37
+
38
+ g[REGISTERED_KEY] = true;
39
+ }
40
+
41
+ registerPath();
@@ -1,17 +1,17 @@
1
- const { cleaner } = require("@/commands/cleaner");
2
- const { selectTools } = require("@/commands/select-tools");
3
- const { readCache } = require("@/skill-repo/cache-folder");
4
-
5
- function runClean(flags, context) {
6
- const selectedTools = selectTools(flags, context.tools);
7
- const { skills } = readCache(context.cwd);
8
-
9
- const skillNames = skills.map((s) => s.name);
10
- const cleanedCount = cleaner(context.tools, selectedTools, skillNames, context.cwd);
11
-
12
- console.log(`[Done] ${cleanedCount} tools cleaned.`);
13
- }
14
-
15
- module.exports = {
16
- runClean,
17
- };
1
+ const { cleaner } = require("@/commands/cleaner");
2
+ const { selectTools } = require("@/commands/select-tools");
3
+ const { readCache } = require("@/skill-repo/cache-folder");
4
+
5
+ function runClean(flags, context) {
6
+ const selectedTools = selectTools(flags, context.tools);
7
+ const { skills } = readCache(context.cwd);
8
+
9
+ const skillNames = skills.map((s) => s.name);
10
+ const cleanedCount = cleaner(context.tools, selectedTools, skillNames, context.cwd);
11
+
12
+ console.log(`[Done] ${cleanedCount} tools cleaned.`);
13
+ }
14
+
15
+ module.exports = {
16
+ runClean,
17
+ };
@@ -1,27 +1,27 @@
1
- function cleaner(tools, selectedTools, skillNames, cwd) {
2
- let headerPrinted = false;
3
- let cleanedCount = 0;
4
-
5
- for (const toolKey of selectedTools) {
6
- const cleanedPaths = tools[toolKey].clean(skillNames, cwd);
7
- if (cleanedPaths.length === 0) continue;
8
-
9
- if (!headerPrinted) {
10
- console.log("[Clean]");
11
- headerPrinted = true;
12
- }
13
-
14
- cleanedPaths.forEach((p) => console.log(` Removed: ${p}`));
15
- cleanedCount++;
16
- }
17
-
18
- if (headerPrinted) {
19
- console.log("");
20
- }
21
-
22
- return cleanedCount;
23
- }
24
-
25
- module.exports = {
26
- cleaner,
27
- };
1
+ function cleaner(tools, selectedTools, skillNames, cwd) {
2
+ let headerPrinted = false;
3
+ let cleanedCount = 0;
4
+
5
+ for (const toolKey of selectedTools) {
6
+ const cleanedPaths = tools[toolKey].clean(skillNames, cwd);
7
+ if (cleanedPaths.length === 0) continue;
8
+
9
+ if (!headerPrinted) {
10
+ console.log("[Clean]");
11
+ headerPrinted = true;
12
+ }
13
+
14
+ cleanedPaths.forEach((p) => console.log(` Removed: ${p}`));
15
+ cleanedCount++;
16
+ }
17
+
18
+ if (headerPrinted) {
19
+ console.log("");
20
+ }
21
+
22
+ return cleanedCount;
23
+ }
24
+
25
+ module.exports = {
26
+ cleaner,
27
+ };
@@ -1,14 +1,14 @@
1
- const COMMAND_LINK = "link";
2
- const COMMAND_SYNC = "sync";
3
- const COMMAND_CLEAN = "clean";
4
- const COMMAND_HELP = "help";
5
-
6
- const LATEST_VERSION_COMMAND = "npx heymark@latest";
7
-
8
- module.exports = {
9
- COMMAND_LINK,
10
- COMMAND_SYNC,
11
- COMMAND_CLEAN,
12
- COMMAND_HELP,
13
- LATEST_VERSION_COMMAND,
14
- };
1
+ const COMMAND_LINK = "link";
2
+ const COMMAND_SYNC = "sync";
3
+ const COMMAND_CLEAN = "clean";
4
+ const COMMAND_HELP = "help";
5
+
6
+ const LATEST_VERSION_COMMAND = "npx heymark@latest";
7
+
8
+ module.exports = {
9
+ COMMAND_LINK,
10
+ COMMAND_SYNC,
11
+ COMMAND_CLEAN,
12
+ COMMAND_HELP,
13
+ LATEST_VERSION_COMMAND,
14
+ };
@@ -1,34 +1,34 @@
1
- const { LATEST_VERSION_COMMAND } = require("@/commands/constants");
2
-
3
- function runHelp(flags, context) {
4
- if (flags.length > 0) {
5
- console.error(`[Error] Unknown: ${flags.join(", ")}. help takes no arguments.`);
6
- process.exit(1);
7
- }
8
-
9
- const toolLines = Object.entries(context.tools)
10
- .map(([key, tool]) => ` ${key.padEnd(14)} ${tool.output}`)
11
- .join("\n");
12
-
13
- console.log(`
14
- Usage:
15
- heymark link <repo-url>
16
- heymark sync .
17
- heymark sync <tool1> <tool2> ...
18
- heymark clean .
19
- heymark clean <tool1> <tool2> ...
20
-
21
- Link flags:
22
- --branch | -b
23
- --folder | -f
24
-
25
- Supported tools:
26
- ${toolLines}
27
-
28
- Update: ${LATEST_VERSION_COMMAND}
29
- `);
30
- }
31
-
32
- module.exports = {
33
- runHelp,
34
- };
1
+ const { LATEST_VERSION_COMMAND } = require("@/commands/constants");
2
+
3
+ function runHelp(flags, context) {
4
+ if (flags.length > 0) {
5
+ console.error(`[Error] Unknown: ${flags.join(", ")}. help takes no arguments.`);
6
+ process.exit(1);
7
+ }
8
+
9
+ const toolLines = Object.entries(context.tools)
10
+ .map(([key, tool]) => ` ${key.padEnd(14)} ${tool.output}`)
11
+ .join("\n");
12
+
13
+ console.log(`
14
+ Usage:
15
+ heymark link <repo-url>
16
+ heymark sync .
17
+ heymark sync <tool1> <tool2> ...
18
+ heymark clean .
19
+ heymark clean <tool1> <tool2> ...
20
+
21
+ Link flags:
22
+ --branch | -b
23
+ --folder | -f
24
+
25
+ Supported tools:
26
+ ${toolLines}
27
+
28
+ Update: ${LATEST_VERSION_COMMAND}
29
+ `);
30
+ }
31
+
32
+ module.exports = {
33
+ runHelp,
34
+ };
@@ -1,18 +1,18 @@
1
- const key = "branch";
2
- const FLAG = "--branch";
3
- const SHORT_FLAG = "-b";
4
-
5
- function is(flag) {
6
- return flag === FLAG || flag === SHORT_FLAG;
7
- }
8
-
9
- function parse(flags, index) {
10
- const value = flags[index + 1];
11
- if (!value) {
12
- console.error("[Error] --branch needs a value.");
13
- process.exit(1);
14
- }
15
- return { value: value.trim(), advance: 1 };
16
- }
17
-
18
- module.exports = { key, is, parse };
1
+ const key = "branch";
2
+ const FLAG = "--branch";
3
+ const SHORT_FLAG = "-b";
4
+
5
+ function is(flag) {
6
+ return flag === FLAG || flag === SHORT_FLAG;
7
+ }
8
+
9
+ function parse(flags, index) {
10
+ const value = flags[index + 1];
11
+ if (!value) {
12
+ console.error("[Error] --branch needs a value.");
13
+ process.exit(1);
14
+ }
15
+ return { value: value.trim(), advance: 1 };
16
+ }
17
+
18
+ module.exports = { key, is, parse };
@@ -1,18 +1,18 @@
1
- const key = "folder";
2
- const FLAG = "--folder";
3
- const SHORT_FLAG = "-f";
4
-
5
- function is(flag) {
6
- return flag === FLAG || flag === SHORT_FLAG;
7
- }
8
-
9
- function parse(flags, index) {
10
- const value = flags[index + 1];
11
- if (!value) {
12
- console.error("[Error] --folder needs a value.");
13
- process.exit(1);
14
- }
15
- return { value: value.trim(), advance: 1 };
16
- }
17
-
18
- module.exports = { key, is, parse };
1
+ const key = "folder";
2
+ const FLAG = "--folder";
3
+ const SHORT_FLAG = "-f";
4
+
5
+ function is(flag) {
6
+ return flag === FLAG || flag === SHORT_FLAG;
7
+ }
8
+
9
+ function parse(flags, index) {
10
+ const value = flags[index + 1];
11
+ if (!value) {
12
+ console.error("[Error] --folder needs a value.");
13
+ process.exit(1);
14
+ }
15
+ return { value: value.trim(), advance: 1 };
16
+ }
17
+
18
+ module.exports = { key, is, parse };
@@ -1,58 +1,58 @@
1
- const path = require("path");
2
- const { writeConfig } = require("@/skill-repo/config-file");
3
- const { SKILL_REPO_DEFAULT_BRANCH } = require("@/skill-repo/constants");
4
- const branch = require("@/commands/link/flags/branch");
5
- const folder = require("@/commands/link/flags/folder");
6
-
7
- function parseFlags(flags, handlers) {
8
- const result = {};
9
- for (let i = 0; i < flags.length; i++) {
10
- const flag = flags[i];
11
- const handler = handlers.find((h) => h.is(flag));
12
- if (handler) {
13
- const parsed = handler.parse(flags, i);
14
- result[handler.key] = parsed.value;
15
- i += parsed.advance;
16
- continue;
17
- }
18
- console.error(`[Error] Unknown flag: ${flag}`);
19
- process.exit(1);
20
- }
21
- return result;
22
- }
23
-
24
- function parseConfig(flags) {
25
- const repoUrl = flags[0];
26
- if (!repoUrl || repoUrl.startsWith("--")) {
27
- console.error(
28
- "[Error] Provide a repo URL. Example: heymark link https://github.com/org/repo.git"
29
- );
30
- process.exit(1);
31
- }
32
-
33
- const parsed = parseFlags(flags.slice(1), [branch, folder]);
34
-
35
- return {
36
- repoUrl: repoUrl.trim(),
37
- branch: parsed.branch || SKILL_REPO_DEFAULT_BRANCH,
38
- folder: parsed.folder || "",
39
- };
40
- }
41
-
42
- function runLink(flags, context) {
43
- const config = parseConfig(flags);
44
- const configPath = writeConfig(context.cwd, config);
45
-
46
- console.log(`[Link] Saved to ${path.relative(context.cwd, configPath) || configPath}`);
47
- console.log(` repo: ${config.repoUrl}`);
48
- if (config.branch !== SKILL_REPO_DEFAULT_BRANCH) {
49
- console.log(` branch: ${config.branch}`);
50
- }
51
- if (config.folder) {
52
- console.log(` folder: ${config.folder}`);
53
- }
54
- }
55
-
56
- module.exports = {
57
- runLink,
58
- };
1
+ const path = require("path");
2
+ const { writeConfig } = require("@/skill-repo/config-file");
3
+ const { SKILL_REPO_DEFAULT_BRANCH } = require("@/skill-repo/constants");
4
+ const branch = require("@/commands/link/flags/branch");
5
+ const folder = require("@/commands/link/flags/folder");
6
+
7
+ function parseFlags(flags, handlers) {
8
+ const result = {};
9
+ for (let i = 0; i < flags.length; i++) {
10
+ const flag = flags[i];
11
+ const handler = handlers.find((h) => h.is(flag));
12
+ if (handler) {
13
+ const parsed = handler.parse(flags, i);
14
+ result[handler.key] = parsed.value;
15
+ i += parsed.advance;
16
+ continue;
17
+ }
18
+ console.error(`[Error] Unknown flag: ${flag}`);
19
+ process.exit(1);
20
+ }
21
+ return result;
22
+ }
23
+
24
+ function parseConfig(flags) {
25
+ const repoUrl = flags[0];
26
+ if (!repoUrl || repoUrl.startsWith("--")) {
27
+ console.error(
28
+ "[Error] Provide a repo URL. Example: heymark link https://github.com/org/repo.git"
29
+ );
30
+ process.exit(1);
31
+ }
32
+
33
+ const parsed = parseFlags(flags.slice(1), [branch, folder]);
34
+
35
+ return {
36
+ repoUrl: repoUrl.trim(),
37
+ branch: parsed.branch || SKILL_REPO_DEFAULT_BRANCH,
38
+ folder: parsed.folder || "",
39
+ };
40
+ }
41
+
42
+ function runLink(flags, context) {
43
+ const config = parseConfig(flags);
44
+ const configPath = writeConfig(context.cwd, config);
45
+
46
+ console.log(`[Link] Saved to ${path.relative(context.cwd, configPath) || configPath}`);
47
+ console.log(` repo: ${config.repoUrl}`);
48
+ if (config.branch !== SKILL_REPO_DEFAULT_BRANCH) {
49
+ console.log(` branch: ${config.branch}`);
50
+ }
51
+ if (config.folder) {
52
+ console.log(` folder: ${config.folder}`);
53
+ }
54
+ }
55
+
56
+ module.exports = {
57
+ runLink,
58
+ };
@@ -1,35 +1,35 @@
1
- const ALL_TOOLS_TOKEN = ".";
2
-
3
- function selectTools(flags, availableTools) {
4
- const availableToolKeys = Object.keys(availableTools);
5
- if (flags.length === 0) {
6
- return availableToolKeys;
7
- }
8
-
9
- if (flags.some((tool) => tool.includes(","))) {
10
- console.error("[Error] Use spaces between tools, not commas.");
11
- process.exit(1);
12
- }
13
-
14
- if (flags.includes(ALL_TOOLS_TOKEN)) {
15
- if (flags.length > 1) {
16
- console.error("[Error] Use '.' alone for all tools.");
17
- process.exit(1);
18
- }
19
- return availableToolKeys;
20
- }
21
-
22
- const invalid = flags.filter((tool) => !availableTools[tool]);
23
- if (invalid.length > 0) {
24
- console.error(
25
- `[Error] Unknown: ${invalid.join(", ")}. Available: ${availableToolKeys.join(", ")}`
26
- );
27
- process.exit(1);
28
- }
29
-
30
- return Array.from(new Set(flags));
31
- }
32
-
33
- module.exports = {
34
- selectTools,
35
- };
1
+ const ALL_TOOLS_TOKEN = ".";
2
+
3
+ function selectTools(flags, availableTools) {
4
+ const availableToolKeys = Object.keys(availableTools);
5
+ if (flags.length === 0) {
6
+ return availableToolKeys;
7
+ }
8
+
9
+ if (flags.some((tool) => tool.includes(","))) {
10
+ console.error("[Error] Use spaces between tools, not commas.");
11
+ process.exit(1);
12
+ }
13
+
14
+ if (flags.includes(ALL_TOOLS_TOKEN)) {
15
+ if (flags.length > 1) {
16
+ console.error("[Error] Use '.' alone for all tools.");
17
+ process.exit(1);
18
+ }
19
+ return availableToolKeys;
20
+ }
21
+
22
+ const invalid = flags.filter((tool) => !availableTools[tool]);
23
+ if (invalid.length > 0) {
24
+ console.error(
25
+ `[Error] Unknown: ${invalid.join(", ")}. Available: ${availableToolKeys.join(", ")}`
26
+ );
27
+ process.exit(1);
28
+ }
29
+
30
+ return Array.from(new Set(flags));
31
+ }
32
+
33
+ module.exports = {
34
+ selectTools,
35
+ };
@@ -1,35 +1,35 @@
1
- const { cleaner } = require("@/commands/cleaner");
2
- const { selectTools } = require("@/commands/select-tools");
3
- const { readCache } = require("@/skill-repo/cache-folder");
4
- const { readConfig } = require("@/skill-repo/config-file");
5
- const { SKILL_REPO_DEFAULT_BRANCH } = require("@/skill-repo/constants");
6
-
7
- function runSync(flags, context) {
8
- const selectedTools = selectTools(flags, context.tools);
9
- const { skills } = readCache(context.cwd);
10
- const config = readConfig(context.cwd);
11
-
12
- console.log("[Sync]");
13
- if (config) {
14
- console.log(` repo: ${config.repoUrl}`);
15
- if (config.folder) console.log(` folder: ${config.folder}`);
16
- if (config.branch !== SKILL_REPO_DEFAULT_BRANCH) console.log(` branch: ${config.branch}`);
17
- }
18
- console.log("");
19
-
20
- const skillNames = skills.map((s) => s.name);
21
- cleaner(context.tools, selectedTools, skillNames, context.cwd);
22
-
23
- for (const toolKey of selectedTools) {
24
- const tool = context.tools[toolKey];
25
- const count = tool.generate(skills, context.cwd);
26
- console.log(` ${tool.name.padEnd(16)} -> ${tool.output} (${count} skills)`);
27
- }
28
-
29
- console.log("");
30
- console.log(`[Done] ${selectedTools.length} tools synced.`);
31
- }
32
-
33
- module.exports = {
34
- runSync,
35
- };
1
+ const { cleaner } = require("@/commands/cleaner");
2
+ const { selectTools } = require("@/commands/select-tools");
3
+ const { readCache } = require("@/skill-repo/cache-folder");
4
+ const { readConfig } = require("@/skill-repo/config-file");
5
+ const { SKILL_REPO_DEFAULT_BRANCH } = require("@/skill-repo/constants");
6
+
7
+ function runSync(flags, context) {
8
+ const selectedTools = selectTools(flags, context.tools);
9
+ const { skills } = readCache(context.cwd);
10
+ const config = readConfig(context.cwd);
11
+
12
+ console.log("[Sync]");
13
+ if (config) {
14
+ console.log(` repo: ${config.repoUrl}`);
15
+ if (config.folder) console.log(` folder: ${config.folder}`);
16
+ if (config.branch !== SKILL_REPO_DEFAULT_BRANCH) console.log(` branch: ${config.branch}`);
17
+ }
18
+ console.log("");
19
+
20
+ const skillNames = skills.map((s) => s.name);
21
+ cleaner(context.tools, selectedTools, skillNames, context.cwd);
22
+
23
+ for (const toolKey of selectedTools) {
24
+ const tool = context.tools[toolKey];
25
+ const count = tool.generate(skills, context.cwd);
26
+ console.log(` ${tool.name.padEnd(16)} -> ${tool.output} (${count} skills)`);
27
+ }
28
+
29
+ console.log("");
30
+ console.log(`[Done] ${selectedTools.length} tools synced.`);
31
+ }
32
+
33
+ module.exports = {
34
+ runSync,
35
+ };