@moonwatch/js 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/dist/init.js +12 -4
  2. package/package.json +1 -1
package/dist/init.js CHANGED
@@ -7,7 +7,7 @@ var import_path = require("path");
7
7
  var import_readline = require("readline");
8
8
  var CLAUDE_MD = "CLAUDE.md";
9
9
  var CURSORRULES = ".cursorrules";
10
- var SKILL_REF = "> See node_modules/@moonwatch/js/SKILL.md for the @moonwatch/js logging workflow.";
10
+ var MARKER = "@moonwatch/js";
11
11
  var cwd = process.cwd();
12
12
  function prompt(question) {
13
13
  const rl = (0, import_readline.createInterface)({ input: process.stdin, output: process.stdout });
@@ -18,19 +18,27 @@ function prompt(question) {
18
18
  });
19
19
  });
20
20
  }
21
+ function findSkillRef() {
22
+ const skillPath = (0, import_path.resolve)(__dirname, "..", "SKILL.md");
23
+ if ((0, import_fs.existsSync)(skillPath)) {
24
+ const relative = (0, import_path.resolve)(cwd) === (0, import_path.resolve)((0, import_path.join)(skillPath, "..", "..")) ? "node_modules/@moonwatch/js/SKILL.md" : skillPath.replace(/\\/g, "/");
25
+ return `> See ${relative} for the @moonwatch/js logging workflow.`;
26
+ }
27
+ return "> See node_modules/@moonwatch/js/SKILL.md for the @moonwatch/js logging workflow.";
28
+ }
21
29
  function appendIfMissing(filename) {
22
30
  const filepath = (0, import_path.resolve)(cwd, filename);
23
- const marker = "node_modules/@moonwatch/js/SKILL.md";
24
31
  let content = "";
25
32
  if ((0, import_fs.existsSync)(filepath)) {
26
33
  content = (0, import_fs.readFileSync)(filepath, "utf-8");
27
- if (content.includes(marker)) {
34
+ if (content.includes(MARKER)) {
28
35
  console.log(` ${filename}: already configured, skipping`);
29
36
  return false;
30
37
  }
31
38
  }
39
+ const skillRef = findSkillRef();
32
40
  const separator = content.length > 0 && !content.endsWith("\n") ? "\n\n" : content.length > 0 ? "\n" : "";
33
- (0, import_fs.writeFileSync)(filepath, content + separator + SKILL_REF + "\n", "utf-8");
41
+ (0, import_fs.writeFileSync)(filepath, content + separator + skillRef + "\n", "utf-8");
34
42
  console.log(` ${filename}: ${content.length > 0 ? "updated" : "created"}`);
35
43
  return true;
36
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonwatch/js",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "JavaScript SDK for Moonwatch",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",