@moonwatch/js 0.1.8 → 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.
package/dist/index.js CHANGED
@@ -348,7 +348,7 @@ var LEVEL_ORDER = {
348
348
  FATAL: 4
349
349
  };
350
350
  var SDK_VERSION = "0.1.4";
351
- var DEFAULT_BASE_URL = "https://log.terodato.com";
351
+ var DEFAULT_BASE_URL = "https://moonwatch.dev";
352
352
  var BATCH_SIZE = 50;
353
353
  var MAX_BUFFER_SIZE = 1e3;
354
354
  var FLUSH_INTERVAL_MS = 1e3;
package/dist/index.mjs CHANGED
@@ -319,7 +319,7 @@ var LEVEL_ORDER = {
319
319
  FATAL: 4
320
320
  };
321
321
  var SDK_VERSION = "0.1.4";
322
- var DEFAULT_BASE_URL = "https://log.terodato.com";
322
+ var DEFAULT_BASE_URL = "https://moonwatch.dev";
323
323
  var BATCH_SIZE = 50;
324
324
  var MAX_BUFFER_SIZE = 1e3;
325
325
  var FLUSH_INTERVAL_MS = 1e3;
package/dist/init.js CHANGED
@@ -4,31 +4,103 @@
4
4
  // src/init.ts
5
5
  var import_fs = require("fs");
6
6
  var import_path = require("path");
7
+ var import_readline = require("readline");
7
8
  var CLAUDE_MD = "CLAUDE.md";
8
9
  var CURSORRULES = ".cursorrules";
9
- var SKILL_REF = "> See node_modules/@moonwatch/js/SKILL.md for the @moonwatch/js logging workflow.";
10
+ var MARKER = "@moonwatch/js";
10
11
  var cwd = process.cwd();
12
+ function prompt(question) {
13
+ const rl = (0, import_readline.createInterface)({ input: process.stdin, output: process.stdout });
14
+ return new Promise((resolve2) => {
15
+ rl.question(question, (answer) => {
16
+ rl.close();
17
+ resolve2(answer.trim());
18
+ });
19
+ });
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
+ }
11
29
  function appendIfMissing(filename) {
12
30
  const filepath = (0, import_path.resolve)(cwd, filename);
13
- const marker = "node_modules/@moonwatch/js/SKILL.md";
14
31
  let content = "";
15
32
  if ((0, import_fs.existsSync)(filepath)) {
16
33
  content = (0, import_fs.readFileSync)(filepath, "utf-8");
17
- if (content.includes(marker)) {
34
+ if (content.includes(MARKER)) {
18
35
  console.log(` ${filename}: already configured, skipping`);
19
36
  return false;
20
37
  }
21
38
  }
39
+ const skillRef = findSkillRef();
22
40
  const separator = content.length > 0 && !content.endsWith("\n") ? "\n\n" : content.length > 0 ? "\n" : "";
23
- (0, import_fs.writeFileSync)(filepath, content + separator + SKILL_REF + "\n", "utf-8");
41
+ (0, import_fs.writeFileSync)(filepath, content + separator + skillRef + "\n", "utf-8");
24
42
  console.log(` ${filename}: ${content.length > 0 ? "updated" : "created"}`);
25
43
  return true;
26
44
  }
27
- console.log("\n@moonwatch/js init\n");
28
- var claudeUpdated = appendIfMissing(CLAUDE_MD);
29
- var cursorUpdated = appendIfMissing(CURSORRULES);
30
- if (!claudeUpdated && !cursorUpdated) {
31
- console.log("\nAlready set up \u2014 nothing to do.\n");
32
- } else {
33
- console.log("\nDone. Your AI assistant now has access to the Moonwatch workflow guide.\n");
45
+ function setupClaudeApiKey(apiKey) {
46
+ const claudeDir = (0, import_path.join)(cwd, ".claude");
47
+ const settingsPath = (0, import_path.join)(claudeDir, "settings.local.json");
48
+ let settings = {};
49
+ if ((0, import_fs.existsSync)(settingsPath)) {
50
+ try {
51
+ settings = JSON.parse((0, import_fs.readFileSync)(settingsPath, "utf-8"));
52
+ } catch {
53
+ }
54
+ if (settings.env?.MOONWATCH_API_KEY) {
55
+ const existing = settings.env.MOONWATCH_API_KEY;
56
+ const masked = existing.slice(0, 6) + "..." + existing.slice(-4);
57
+ console.log(` .claude/settings.local.json: API key already set (${masked}), overwriting`);
58
+ }
59
+ }
60
+ if (!(0, import_fs.existsSync)(claudeDir)) {
61
+ (0, import_fs.mkdirSync)(claudeDir, { recursive: true });
62
+ }
63
+ settings.env = settings.env || {};
64
+ settings.env.MOONWATCH_API_KEY = apiKey;
65
+ (0, import_fs.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
66
+ console.log(` .claude/settings.local.json: API key saved`);
67
+ return true;
68
+ }
69
+ async function main() {
70
+ console.log("\n@moonwatch/js init\n");
71
+ console.log("Setting up AI assistant integration...");
72
+ const claudeUpdated = appendIfMissing(CLAUDE_MD);
73
+ const cursorUpdated = appendIfMissing(CURSORRULES);
74
+ if (!claudeUpdated && !cursorUpdated) {
75
+ console.log(" Already set up.\n");
76
+ } else {
77
+ console.log("");
78
+ }
79
+ console.log("Setting up Claude Code MCP connection...");
80
+ const existingSettings = (0, import_path.join)(cwd, ".claude", "settings.local.json");
81
+ let hasKey = false;
82
+ if ((0, import_fs.existsSync)(existingSettings)) {
83
+ try {
84
+ const s = JSON.parse((0, import_fs.readFileSync)(existingSettings, "utf-8"));
85
+ hasKey = !!s.env?.MOONWATCH_API_KEY;
86
+ } catch {
87
+ }
88
+ }
89
+ if (hasKey) {
90
+ const overwrite = await prompt(" API key already configured. Overwrite? (y/N) ");
91
+ if (overwrite.toLowerCase() !== "y") {
92
+ console.log(" Skipping.\n");
93
+ console.log("Done.\n");
94
+ return;
95
+ }
96
+ }
97
+ const apiKey = await prompt(" Enter your Moonwatch API key: ");
98
+ if (!apiKey) {
99
+ console.log(" No key provided, skipping.\n");
100
+ } else {
101
+ setupClaudeApiKey(apiKey);
102
+ console.log("");
103
+ }
104
+ console.log("Done. Your AI assistant now has access to the Moonwatch workflow guide.\n");
34
105
  }
106
+ main();
package/dist/vite.js CHANGED
@@ -27,7 +27,7 @@ var import_crypto = require("crypto");
27
27
  var import_fs = require("fs");
28
28
  var import_path = require("path");
29
29
  var import_os = require("os");
30
- var DEFAULT_ENDPOINT = "https://log.terodato.com";
30
+ var DEFAULT_ENDPOINT = "https://moonwatch.dev";
31
31
  var RELEASE_FILE = (0, import_path.join)((0, import_os.tmpdir)(), ".moonwatch-release");
32
32
  var RELEASE_FILE_MAX_AGE_MS = 5 * 60 * 1e3;
33
33
  function collectMapFiles(dir) {
package/dist/vite.mjs CHANGED
@@ -5,7 +5,7 @@ import { randomUUID } from "crypto";
5
5
  import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "fs";
6
6
  import { join, relative } from "path";
7
7
  import { tmpdir } from "os";
8
- var DEFAULT_ENDPOINT = "https://log.terodato.com";
8
+ var DEFAULT_ENDPOINT = "https://moonwatch.dev";
9
9
  var RELEASE_FILE = join(tmpdir(), ".moonwatch-release");
10
10
  var RELEASE_FILE_MAX_AGE_MS = 5 * 60 * 1e3;
11
11
  function collectMapFiles(dir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonwatch/js",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "JavaScript SDK for Moonwatch",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",