@hasna/skills 0.1.42 → 0.1.43

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/bin/index.js CHANGED
@@ -1910,7 +1910,7 @@ var package_default;
1910
1910
  var init_package = __esm(() => {
1911
1911
  package_default = {
1912
1912
  name: "@hasna/skills",
1913
- version: "0.1.42",
1913
+ version: "0.1.43",
1914
1914
  description: "Skills library for AI coding agents",
1915
1915
  type: "module",
1916
1916
  bin: {
@@ -1973,7 +1973,7 @@ var init_package = __esm(() => {
1973
1973
  typescript: "^5"
1974
1974
  },
1975
1975
  dependencies: {
1976
- "@hasna/events": "^0.1.3",
1976
+ "@hasna/events": "^0.1.7",
1977
1977
  "@modelcontextprotocol/sdk": "^1.26.0",
1978
1978
  chalk: "^5.3.0",
1979
1979
  commander: "^12.1.0",
@@ -43329,9 +43329,15 @@ function print(value, json, text) {
43329
43329
  else
43330
43330
  console.log(text);
43331
43331
  }
43332
+ function hasJsonOption(options) {
43333
+ return Boolean(options?.json || options?.opts?.().json || options?.optsWithGlobals?.().json || options?.parent?.opts?.().json || options?.parent?.optsWithGlobals?.().json);
43334
+ }
43335
+ function wantsJson(actionOptions, command) {
43336
+ return hasJsonOption(actionOptions) || hasJsonOption(command);
43337
+ }
43332
43338
  function registerWebhookCommands(program2, options) {
43333
43339
  const webhooks = program2.command(options.webhooksCommandName ?? "webhooks").description("Manage Hasna event webhook subscriptions");
43334
- webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions) => {
43340
+ webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions, command) => {
43335
43341
  const timestamp = new Date().toISOString();
43336
43342
  const channel = {
43337
43343
  id: actionOptions.id,
@@ -43352,11 +43358,11 @@ function registerWebhookCommands(program2, options) {
43352
43358
  throw new Error(`Transport ${actionOptions.transport} is reserved for future use and cannot be added yet`);
43353
43359
  }
43354
43360
  const saved = await createClient(options).addChannel(channel);
43355
- print(sanitizeChannelForOutput(saved), Boolean(actionOptions.json), `Added ${saved.transport} channel ${saved.id}`);
43361
+ print(sanitizeChannelForOutput(saved), wantsJson(actionOptions, command), `Added ${saved.transport} channel ${saved.id}`);
43356
43362
  });
43357
- webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
43363
+ webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
43358
43364
  const channels = await createClient(options).listChannels();
43359
- if (actionOptions.json) {
43365
+ if (wantsJson(actionOptions, command)) {
43360
43366
  console.log(JSON.stringify(sanitizeChannelsForOutput(channels), null, 2));
43361
43367
  return;
43362
43368
  }
@@ -43368,11 +43374,11 @@ function registerWebhookCommands(program2, options) {
43368
43374
  console.log(`${channel.id} ${channel.enabled ? "enabled" : "disabled"} ${channel.transport} ${channel.webhook?.url ?? channel.command?.command ?? channel.transport}`);
43369
43375
  }
43370
43376
  });
43371
- webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
43377
+ webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
43372
43378
  const removed = await createClient(options).removeChannel(id);
43373
- print({ removed }, Boolean(actionOptions.json), removed ? `Removed ${id}` : `Channel not found: ${id}`);
43379
+ print({ removed }, wantsJson(actionOptions, command), removed ? `Removed ${id}` : `Channel not found: ${id}`);
43374
43380
  });
43375
- webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
43381
+ webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
43376
43382
  const result = await createClient(options).testChannel(id, {
43377
43383
  source: options.source,
43378
43384
  type: actionOptions.type,
@@ -43380,13 +43386,13 @@ function registerWebhookCommands(program2, options) {
43380
43386
  message: actionOptions.message,
43381
43387
  data: parseJsonObject(actionOptions.data, { test: true })
43382
43388
  });
43383
- print(result, Boolean(actionOptions.json), `${result.status}: ${result.channelId}`);
43389
+ print(result, wantsJson(actionOptions, command), `${result.status}: ${result.channelId}`);
43384
43390
  });
43385
43391
  return webhooks;
43386
43392
  }
43387
43393
  function registerEventCommands(program2, options) {
43388
43394
  const events = program2.command(options.eventsCommandName ?? "events").description("Emit, list, and replay Hasna events");
43389
- events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions) => {
43395
+ events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions, command) => {
43390
43396
  const result = await createClient(options).emit({
43391
43397
  source: actionOptions.source ?? options.source,
43392
43398
  type,
@@ -43397,9 +43403,9 @@ function registerEventCommands(program2, options) {
43397
43403
  data: parseJsonObject(actionOptions.data, {}),
43398
43404
  metadata: parseJsonObject(actionOptions.metadata, {})
43399
43405
  }, { deliver: actionOptions.deliver, dedupe: actionOptions.dedupe });
43400
- print(result, Boolean(actionOptions.json), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
43406
+ print(result, wantsJson(actionOptions, command), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
43401
43407
  });
43402
- events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
43408
+ events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
43403
43409
  let rows = await createClient(options).listEvents();
43404
43410
  if (actionOptions.source)
43405
43411
  rows = rows.filter((event) => event.source === actionOptions.source);
@@ -43407,7 +43413,7 @@ function registerEventCommands(program2, options) {
43407
43413
  rows = rows.filter((event) => event.type === actionOptions.type);
43408
43414
  if (actionOptions.limit)
43409
43415
  rows = rows.slice(-actionOptions.limit);
43410
- if (actionOptions.json) {
43416
+ if (wantsJson(actionOptions, command)) {
43411
43417
  console.log(JSON.stringify(rows, null, 2));
43412
43418
  return;
43413
43419
  }
@@ -43418,14 +43424,14 @@ function registerEventCommands(program2, options) {
43418
43424
  for (const event of rows)
43419
43425
  console.log(`${event.time} ${event.id} ${event.source} ${event.type} ${event.severity}`);
43420
43426
  });
43421
- events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
43427
+ events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
43422
43428
  const result = await createClient(options).replay({
43423
43429
  eventId: actionOptions.id,
43424
43430
  source: actionOptions.source,
43425
43431
  type: actionOptions.type,
43426
43432
  dryRun: actionOptions.dryRun
43427
43433
  });
43428
- print(result, Boolean(actionOptions.json), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
43434
+ print(result, wantsJson(actionOptions, command), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
43429
43435
  });
43430
43436
  return events;
43431
43437
  }
package/bin/mcp.js CHANGED
@@ -21797,7 +21797,7 @@ class StdioServerTransport {
21797
21797
  // package.json
21798
21798
  var package_default = {
21799
21799
  name: "@hasna/skills",
21800
- version: "0.1.42",
21800
+ version: "0.1.43",
21801
21801
  description: "Skills library for AI coding agents",
21802
21802
  type: "module",
21803
21803
  bin: {
@@ -21860,7 +21860,7 @@ var package_default = {
21860
21860
  typescript: "^5"
21861
21861
  },
21862
21862
  dependencies: {
21863
- "@hasna/events": "^0.1.3",
21863
+ "@hasna/events": "^0.1.7",
21864
21864
  "@modelcontextprotocol/sdk": "^1.26.0",
21865
21865
  chalk: "^5.3.0",
21866
21866
  commander: "^12.1.0",
package/dist/index.js CHANGED
@@ -18043,7 +18043,7 @@ import { dirname as dirname3, relative as relative2 } from "path";
18043
18043
  // package.json
18044
18044
  var package_default = {
18045
18045
  name: "@hasna/skills",
18046
- version: "0.1.42",
18046
+ version: "0.1.43",
18047
18047
  description: "Skills library for AI coding agents",
18048
18048
  type: "module",
18049
18049
  bin: {
@@ -18106,7 +18106,7 @@ var package_default = {
18106
18106
  typescript: "^5"
18107
18107
  },
18108
18108
  dependencies: {
18109
- "@hasna/events": "^0.1.3",
18109
+ "@hasna/events": "^0.1.7",
18110
18110
  "@modelcontextprotocol/sdk": "^1.26.0",
18111
18111
  chalk: "^5.3.0",
18112
18112
  commander: "^12.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/skills",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "description": "Skills library for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -63,7 +63,7 @@
63
63
  "typescript": "^5"
64
64
  },
65
65
  "dependencies": {
66
- "@hasna/events": "^0.1.3",
66
+ "@hasna/events": "^0.1.7",
67
67
  "@modelcontextprotocol/sdk": "^1.26.0",
68
68
  "chalk": "^5.3.0",
69
69
  "commander": "^12.1.0",