@hasna/domains 0.0.6 → 0.0.8

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 +1 @@
1
- {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoc5D"}
1
+ {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8d5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-install.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcp-install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuEzD"}
1
+ {"version":3,"file":"mcp-install.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcp-install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuCzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwGzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8D9D"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuJ9D"}
package/dist/cli/index.js CHANGED
@@ -42527,7 +42527,7 @@ WHOIS for ${result.domain}:`);
42527
42527
  const output = exportPortfolio(opts.format);
42528
42528
  console.log(output);
42529
42529
  });
42530
- domain.command("check <domains...>").description("Check domain availability via configured registrar").option("--provider <name>", "Registrar provider to use").action(async (domains, opts) => {
42530
+ domain.command("check <domains...>").description("Check domain availability via configured registrar").option("--provider <name>", "Registrar provider to use").option("-j, --json", "Output JSON").action(async (domains, opts) => {
42531
42531
  const cfg = loadConfig3();
42532
42532
  const providerName = opts.provider ?? cfg.default_registrar ?? "route53";
42533
42533
  const results = await Promise.allSettled(domains.map(async (d3) => {
@@ -42535,17 +42535,33 @@ WHOIS for ${result.domain}:`);
42535
42535
  return provider.checkAvailability(d3);
42536
42536
  }));
42537
42537
  let anyError = false;
42538
+ const output = [];
42538
42539
  for (let i3 = 0;i3 < domains.length; i3++) {
42539
42540
  const r3 = results[i3];
42540
42541
  if (r3.status === "rejected") {
42541
42542
  const reason = r3.reason;
42542
- console.error(`\u2717 ${domains[i3]}: ${reason instanceof Error ? reason.message : String(reason)}`);
42543
+ const error = reason instanceof Error ? reason.message : String(reason);
42544
+ output.push({ domain: domains[i3], error });
42545
+ if (!opts.json) {
42546
+ console.error(`\u2717 ${domains[i3]}: ${error}`);
42547
+ }
42543
42548
  anyError = true;
42544
42549
  } else {
42545
42550
  const result = r3.value;
42546
- console.log(`${result.available ? "\u2713" : "\u2717"} ${result.domain} is ${result.available ? "available" : "not available"}`);
42551
+ output.push({ domain: result.domain, available: result.available });
42552
+ if (!opts.json) {
42553
+ console.log(`${result.available ? "\u2713" : "\u2717"} ${result.domain} is ${result.available ? "available" : "not available"}`);
42554
+ }
42547
42555
  }
42548
42556
  }
42557
+ if (opts.json) {
42558
+ console.log(JSON.stringify({
42559
+ provider: providerName,
42560
+ count: output.length,
42561
+ ok: !anyError,
42562
+ results: output
42563
+ }, null, 2));
42564
+ }
42549
42565
  if (anyError)
42550
42566
  process.exit(1);
42551
42567
  });
@@ -43176,7 +43192,7 @@ function registerMonitorCommand(program2) {
43176
43192
  // src/cli/commands/provider.ts
43177
43193
  function registerProviderCommand(program2) {
43178
43194
  const provider = program2.command("provider").description("Configure and test registrar/DNS providers");
43179
- provider.command("list").description("Show all providers and their configuration status").option("--json", "Output JSON").action((opts) => {
43195
+ provider.command("list").description("Show all providers and their configuration status").option("-j, --json", "Output JSON").action((opts) => {
43180
43196
  const providers = getAvailableProviders();
43181
43197
  if (opts.json) {
43182
43198
  console.log(JSON.stringify(providers, null, 2));
@@ -43194,37 +43210,95 @@ Registrar / DNS Providers:`);
43194
43210
  }
43195
43211
  console.log();
43196
43212
  });
43197
- provider.command("test <name>").description("Live-test a provider's credentials").action(async (name) => {
43213
+ provider.command("test <name>").description("Live-test a provider's credentials").option("-j, --json", "Output JSON").action(async (name, opts) => {
43198
43214
  const providers = getAvailableProviders();
43199
43215
  const info = providers.find((p3) => p3.name === name);
43200
43216
  if (!info) {
43201
- console.error(`Unknown provider: ${name}`);
43217
+ const error = `Unknown provider: ${name}`;
43218
+ if (opts.json) {
43219
+ console.log(JSON.stringify({ provider: name, ok: false, error }, null, 2));
43220
+ } else {
43221
+ console.error(error);
43222
+ }
43202
43223
  process.exit(1);
43203
43224
  }
43204
43225
  if (!info.configured) {
43205
- console.error(`\u2717 ${name} is not configured. Set: ${info.envVars.join(", ")}`);
43226
+ const error = `${name} is not configured. Set: ${info.envVars.join(", ")}`;
43227
+ if (opts.json) {
43228
+ console.log(JSON.stringify({
43229
+ provider: name,
43230
+ ok: false,
43231
+ configured: false,
43232
+ required_env: info.envVars,
43233
+ error
43234
+ }, null, 2));
43235
+ } else {
43236
+ console.error(`\u2717 ${error}`);
43237
+ }
43206
43238
  process.exit(1);
43207
43239
  }
43208
- console.log(`Testing ${name}...`);
43240
+ if (!opts.json) {
43241
+ console.log(`Testing ${name}...`);
43242
+ }
43243
+ let registrarOk = null;
43244
+ let dnsOk = null;
43209
43245
  try {
43210
43246
  if (info.type === "registrar" || info.type === "full") {
43211
43247
  const reg = getRegistrarProvider(name);
43212
43248
  await reg.listDomains();
43213
- console.log(`\u2713 Registrar connection OK`);
43249
+ registrarOk = true;
43250
+ if (!opts.json)
43251
+ console.log("\u2713 Registrar connection OK");
43214
43252
  }
43215
43253
  if (info.type === "dns" || info.type === "full") {
43216
43254
  const dns = getDnsProvider(name);
43217
43255
  await dns.getDnsRecords("__test_nonexistent_domain__.invalid");
43218
- console.log(`\u2713 DNS connection OK`);
43256
+ dnsOk = true;
43257
+ if (!opts.json)
43258
+ console.log("\u2713 DNS connection OK");
43259
+ }
43260
+ if (opts.json) {
43261
+ console.log(JSON.stringify({
43262
+ provider: name,
43263
+ ok: true,
43264
+ configured: true,
43265
+ type: info.type,
43266
+ registrar_ok: registrarOk,
43267
+ dns_ok: dnsOk
43268
+ }, null, 2));
43219
43269
  }
43220
43270
  } catch (e3) {
43221
43271
  const msg = e3 instanceof Error ? e3.message : String(e3);
43222
43272
  if (msg.includes("not found") || msg.includes("No hosted zone") || msg.includes("NXDOMAIN")) {
43223
- console.log(`\u2713 Connection OK (no domains yet)`);
43273
+ if (opts.json) {
43274
+ console.log(JSON.stringify({
43275
+ provider: name,
43276
+ ok: true,
43277
+ configured: true,
43278
+ type: info.type,
43279
+ registrar_ok: registrarOk,
43280
+ dns_ok: true,
43281
+ note: "connection-ok-no-domains-yet"
43282
+ }, null, 2));
43283
+ } else {
43284
+ console.log("\u2713 Connection OK (no domains yet)");
43285
+ }
43286
+ return;
43287
+ }
43288
+ if (opts.json) {
43289
+ console.log(JSON.stringify({
43290
+ provider: name,
43291
+ ok: false,
43292
+ configured: true,
43293
+ type: info.type,
43294
+ registrar_ok: registrarOk,
43295
+ dns_ok: dnsOk,
43296
+ error: msg
43297
+ }, null, 2));
43224
43298
  } else {
43225
43299
  console.error(`\u2717 ${name} test failed: ${msg}`);
43226
- process.exit(1);
43227
43300
  }
43301
+ process.exit(1);
43228
43302
  }
43229
43303
  });
43230
43304
  }
@@ -43396,9 +43470,9 @@ ${"\u2500".repeat(45)}`);
43396
43470
  }
43397
43471
 
43398
43472
  // src/cli/commands/mcp-install.ts
43399
- import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
43473
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
43400
43474
  import { homedir as homedir9 } from "os";
43401
- import { join as join9 } from "path";
43475
+ import { dirname as dirname5, join as join9 } from "path";
43402
43476
  import { execSync as execSync3 } from "child_process";
43403
43477
  var MCP_SERVER_NAME = "domains";
43404
43478
  function getClaudeConfigPaths() {
@@ -43414,20 +43488,29 @@ function getMcpBinaryPath() {
43414
43488
  return "domains-mcp";
43415
43489
  }
43416
43490
  }
43491
+ function ensureConfigDir(configPath2) {
43492
+ const dir = dirname5(configPath2);
43493
+ if (!existsSync7(dir)) {
43494
+ mkdirSync6(dir, { recursive: true });
43495
+ }
43496
+ }
43497
+ function readConfig(configPath2) {
43498
+ if (!existsSync7(configPath2))
43499
+ return {};
43500
+ try {
43501
+ return JSON.parse(readFileSync6(configPath2, "utf-8"));
43502
+ } catch {
43503
+ return {};
43504
+ }
43505
+ }
43417
43506
  function registerMcpCommand(program2) {
43418
43507
  const mcp = program2.command("mcp").description("MCP server management for AI agents");
43419
43508
  mcp.command("install").description("Register domains MCP server with Claude Code").option("--project", "Install in project .claude/settings.json instead of global config").action((opts) => {
43420
43509
  const paths = getClaudeConfigPaths();
43421
43510
  const configPath2 = opts.project ? paths.project : paths.global;
43422
43511
  const binary = getMcpBinaryPath();
43423
- let config = {};
43424
- if (existsSync7(configPath2)) {
43425
- try {
43426
- config = JSON.parse(readFileSync6(configPath2, "utf-8"));
43427
- } catch {
43428
- config = {};
43429
- }
43430
- }
43512
+ ensureConfigDir(configPath2);
43513
+ const config = readConfig(configPath2);
43431
43514
  const mcpServers = config.mcpServers ?? {};
43432
43515
  mcpServers[MCP_SERVER_NAME] = { command: binary, args: [] };
43433
43516
  config.mcpServers = mcpServers;
@@ -43445,7 +43528,7 @@ function registerMcpCommand(program2) {
43445
43528
  console.log("Config file not found \u2014 nothing to remove.");
43446
43529
  return;
43447
43530
  }
43448
- const config = JSON.parse(readFileSync6(configPath2, "utf-8"));
43531
+ const config = readConfig(configPath2);
43449
43532
  const mcpServers = config.mcpServers;
43450
43533
  if (!mcpServers?.[MCP_SERVER_NAME]) {
43451
43534
  console.log(`MCP server '${MCP_SERVER_NAME}' is not registered.`);
@@ -43455,23 +43538,50 @@ function registerMcpCommand(program2) {
43455
43538
  writeFileSync4(configPath2, JSON.stringify(config, null, 2), "utf-8");
43456
43539
  console.log(`\u2713 MCP server removed: ${MCP_SERVER_NAME}`);
43457
43540
  });
43458
- mcp.command("status").description("Check if domains MCP server is registered").action(() => {
43541
+ mcp.command("status").description("Check if domains MCP server is registered").option("-j, --json", "Output JSON").action((opts) => {
43459
43542
  const paths = getClaudeConfigPaths();
43460
- for (const [label, configPath2] of [["global", paths.global], ["project", paths.project]]) {
43543
+ const status = [];
43544
+ for (const [scope, configPath2] of [["global", paths.global], ["project", paths.project]]) {
43461
43545
  if (!existsSync7(configPath2)) {
43462
- console.log(` ${label}: not found`);
43546
+ status.push({ scope, config_path: configPath2, exists: false, registered: false });
43463
43547
  continue;
43464
43548
  }
43465
43549
  try {
43466
- const config = JSON.parse(readFileSync6(configPath2, "utf-8"));
43550
+ const config = readConfig(configPath2);
43467
43551
  const mcpServers = config.mcpServers;
43468
- if (mcpServers?.[MCP_SERVER_NAME]) {
43469
- console.log(` ${label}: \u2713 registered`);
43470
- } else {
43471
- console.log(` ${label}: \u2717 not registered`);
43472
- }
43473
- } catch {
43474
- console.log(` ${label}: error reading config`);
43552
+ status.push({
43553
+ scope,
43554
+ config_path: configPath2,
43555
+ exists: true,
43556
+ registered: Boolean(mcpServers?.[MCP_SERVER_NAME])
43557
+ });
43558
+ } catch (error) {
43559
+ status.push({
43560
+ scope,
43561
+ config_path: configPath2,
43562
+ exists: true,
43563
+ registered: false,
43564
+ error: error instanceof Error ? error.message : String(error)
43565
+ });
43566
+ }
43567
+ }
43568
+ if (opts.json) {
43569
+ console.log(JSON.stringify({ server: MCP_SERVER_NAME, checks: status }, null, 2));
43570
+ return;
43571
+ }
43572
+ for (const item of status) {
43573
+ if (!item.exists) {
43574
+ console.log(` ${item.scope}: not found`);
43575
+ continue;
43576
+ }
43577
+ if (item.error) {
43578
+ console.log(` ${item.scope}: error reading config`);
43579
+ continue;
43580
+ }
43581
+ if (item.registered) {
43582
+ console.log(` ${item.scope}: \u2713 registered`);
43583
+ } else {
43584
+ console.log(` ${item.scope}: \u2717 not registered`);
43475
43585
  }
43476
43586
  }
43477
43587
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/domains",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Domain portfolio and DNS management for AI agents — CLI + MCP server with SQLite",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",