@hasna/skills 0.6.0 → 0.6.1

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
@@ -47,6 +47,14 @@ var __export = (target, all) => {
47
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
48
48
  var __require = import.meta.require;
49
49
 
50
+ // src/cli/output.ts
51
+ async function writeCliOutput(text, newline = true) {
52
+ await new Promise((resolve, reject) => {
53
+ process.stdout.write(newline ? `${text}
54
+ ` : text, (error) => error ? reject(error) : resolve());
55
+ });
56
+ }
57
+
50
58
  // ../../node_modules/.bun/react@18.3.1/node_modules/react/cjs/react.development.js
51
59
  var require_react_development = __commonJS((exports, module) => {
52
60
  if (true) {
@@ -36860,7 +36868,7 @@ var package_default;
36860
36868
  var init_package = __esm(() => {
36861
36869
  package_default = {
36862
36870
  name: "@hasna/skills",
36863
- version: "0.6.0",
36871
+ version: "0.6.1",
36864
36872
  description: "Skills library for AI coding agents",
36865
36873
  type: "module",
36866
36874
  bin: {
@@ -53548,7 +53556,7 @@ function registerContextCommands(parent) {
53548
53556
  sessionId: options.session,
53549
53557
  file: options.file
53550
53558
  });
53551
- console.log(options.json ? JSON.stringify(result2) : result2.content);
53559
+ await writeCliOutput(options.json ? JSON.stringify(result2) : result2.content);
53552
53560
  } catch (error) {
53553
53561
  reportContextError(error, options.json);
53554
53562
  }
@@ -53565,7 +53573,7 @@ function registerContextCommands(parent) {
53565
53573
  maxChars: Number(options.maxChars),
53566
53574
  maxSkills: Number(options.maxSkills)
53567
53575
  });
53568
- console.log(options.json ? JSON.stringify(result2) : result2.context);
53576
+ await writeCliOutput(options.json ? JSON.stringify(result2) : result2.context);
53569
53577
  } catch (error) {
53570
53578
  reportContextError(error, options.json);
53571
53579
  }
@@ -53656,9 +53664,9 @@ async function handleProfileSync(options, dependencies = {}) {
53656
53664
  check: options.check ?? dependencies.check
53657
53665
  });
53658
53666
  if (options.json)
53659
- console.log(JSON.stringify(result2));
53667
+ await writeCliOutput(JSON.stringify(result2));
53660
53668
  else
53661
- console.log(options.check ? result2.changed ? "Skills profile or cached bundles need syncing." : "Skills profile and cached bundles are current." : `Synced Skills profile ${result2.profile.profileId} at ${result2.profile.profileRevision}; ${result2.downloaded} bundle(s) downloaded.`);
53669
+ await writeCliOutput(options.check ? result2.changed ? "Skills profile or cached bundles need syncing." : "Skills profile and cached bundles are current." : `Synced Skills profile ${result2.profile.profileId} at ${result2.profile.profileRevision}; ${result2.downloaded} bundle(s) downloaded.`);
53662
53670
  if (options.check && result2.changed)
53663
53671
  process.exitCode = 1;
53664
53672
  } catch (error) {
@@ -77924,7 +77932,7 @@ function registerRuntime(parent) {
77924
77932
  try {
77925
77933
  const client = await CloudExecutionClient.configured();
77926
77934
  const value = operation === "show" ? await client.get(id) : await client[operation](id);
77927
- console.log(JSON.stringify(value, null, 2));
77935
+ await writeCliOutput(JSON.stringify(value, null, 2));
77928
77936
  } catch (error2) {
77929
77937
  console.error(JSON.stringify({ error: error2.message }));
77930
77938
  process.exitCode = 1;
@@ -78260,9 +78268,9 @@ async function handleRun(name, args2, options) {
78260
78268
  throw new Error("Selected local execution accepts arguments and structured --input only");
78261
78269
  const result4 = await executeSelectedLocal(selected, { args: args2, input, cwd: process.cwd() });
78262
78270
  if (options.json)
78263
- console.log(JSON.stringify(result4, null, 2));
78271
+ await writeCliOutput(JSON.stringify(result4, null, 2));
78264
78272
  else {
78265
- process.stdout.write(result4.stdout);
78273
+ await writeCliOutput(result4.stdout, false);
78266
78274
  process.stderr.write(result4.stderr);
78267
78275
  console.error(JSON.stringify({ selection: result4.selection, target: result4.target, exitCode: result4.exitCode, runDirectory: result4.runDirectory }));
78268
78276
  }
@@ -78281,7 +78289,7 @@ async function handleRun(name, args2, options) {
78281
78289
  if (options.wait)
78282
78290
  console.error(JSON.stringify({ executionId: admitted.id, status: admitted.status }));
78283
78291
  const result3 = options.wait ? await client2.wait(admitted.id, { timeoutMs, intervalMs }) : admitted;
78284
- console.log(JSON.stringify(result3, null, 2));
78292
+ await writeCliOutput(JSON.stringify(result3, null, 2));
78285
78293
  if (["failed", "cancelled"].includes(result3.status))
78286
78294
  process.exitCode = 1;
78287
78295
  } catch (error2) {
@@ -78484,7 +78492,7 @@ async function handleRun(name, args2, options) {
78484
78492
  console.log(JSON.stringify({ skill: skill.name, args: args2, ...result2, run: completed }, null, 2));
78485
78493
  else {
78486
78494
  if (result2.stdout)
78487
- process.stdout.write(result2.stdout);
78495
+ await writeCliOutput(result2.stdout, false);
78488
78496
  if (result2.stderr)
78489
78497
  process.stderr.write(result2.stderr);
78490
78498
  if (result2.error)
@@ -79856,15 +79864,15 @@ function agents(value) {
79856
79864
  }
79857
79865
  function registerAgentIntegration(parent) {
79858
79866
  const hook = parent.command("hook").description("Load selected Skills context through agent lifecycle hooks");
79859
- hook.command("install").option("--agent <agent>", "Agent to configure: claude, codex, all", "all").option("--command <path>", "Skills executable used by the hook", "skills").option("--selection-profile <id>", "Shared selection profile", "default").option("--include-vendor", "Also disable discovered vendor system skills in Codex", false).option("--allow-root-aliases", "Allow home .claude/.codex aliases to existing directories within this home", false).option("--apply", "Apply the plan, preserving prior configuration in private backups", false).option("--json", "Output a receipt as JSON", false).description("Plan or install prompt hooks and disable native skill invocation").action((options) => {
79867
+ hook.command("install").option("--agent <agent>", "Agent to configure: claude, codex, all", "all").option("--command <path>", "Skills executable used by the hook", "skills").option("--selection-profile <id>", "Shared selection profile", "default").option("--include-vendor", "Also disable discovered vendor system skills in Codex", false).option("--allow-root-aliases", "Allow home .claude/.codex aliases to existing directories within this home", false).option("--apply", "Apply the plan, preserving prior configuration in private backups", false).option("--json", "Output a receipt as JSON", false).description("Plan or install prompt hooks and disable native skill invocation").action(async (options) => {
79860
79868
  try {
79861
79869
  const plan = planAgentIntegration({ agents: agents(options.agent), command: options.command, profileId: options.selectionProfile, includeVendor: options.includeVendor, allowRootAliases: options.allowRootAliases });
79862
79870
  const result2 = options.apply ? applyAgentIntegration(plan) : { changed: [], backups: [] };
79863
79871
  const receipt = { applied: options.apply, planned: plan.changes.map((change) => change.path), ...result2, rootAliases: plan.rootAliases ?? [], nativeSkills: plan.nativeSkills.map((entry) => ({ agent: entry.agent, path: entry.path, managed: entry.managed, vendor: entry.vendor })) };
79864
79872
  if (options.json)
79865
- console.log(JSON.stringify(receipt));
79873
+ await writeCliOutput(JSON.stringify(receipt));
79866
79874
  else
79867
- console.log(`${options.apply ? "Configured" : "Planned"} ${plan.changes.length} agent configuration change(s).${options.apply ? " Restart the agent and trust the installed hook configuration." : " Use --apply to install."}`);
79875
+ await writeCliOutput(`${options.apply ? "Configured" : "Planned"} ${plan.changes.length} agent configuration change(s).${options.apply ? " Restart the agent and trust the installed hook configuration." : " Use --apply to install."}`);
79868
79876
  } catch (error2) {
79869
79877
  console.error(error2.message);
79870
79878
  process.exitCode = 1;
@@ -79906,29 +79914,29 @@ function registerAgentIntegration(parent) {
79906
79914
  const result2 = JSON.parse(stdout);
79907
79915
  if (typeof result2.context !== "string")
79908
79916
  throw new Error("Invalid Skills context response");
79909
- console.log(JSON.stringify(hookContextOutput(event, result2)));
79917
+ await writeCliOutput(JSON.stringify(hookContextOutput(event, result2)));
79910
79918
  } finally {
79911
79919
  clearTimeout(timer);
79912
79920
  }
79913
79921
  } catch {
79914
79922
  const reason = "Skills context is unavailable. Run skills sync --selection-profile <id> and skills context --stdin --json to diagnose the selected profile.";
79915
79923
  if (event === "UserPromptSubmit")
79916
- console.log(JSON.stringify({ decision: "block", reason }));
79924
+ await writeCliOutput(JSON.stringify({ decision: "block", reason }));
79917
79925
  else if (event === "SessionStart")
79918
- console.log(JSON.stringify({ continue: false, stopReason: reason, systemMessage: reason }));
79926
+ await writeCliOutput(JSON.stringify({ continue: false, stopReason: reason, systemMessage: reason }));
79919
79927
  else
79920
- console.log(JSON.stringify({ systemMessage: reason, hookSpecificOutput: { hookEventName: "SubagentStart", additionalContext: "Required Skills context was unavailable. Report this to the parent before performing task actions." } }));
79928
+ await writeCliOutput(JSON.stringify({ systemMessage: reason, hookSpecificOutput: { hookEventName: "SubagentStart", additionalContext: "Required Skills context was unavailable. Report this to the parent before performing task actions." } }));
79921
79929
  }
79922
79930
  });
79923
79931
  const migrate = parent.command("migrate").description("Preserve and retire native agent skill copies");
79924
- migrate.command("native").option("--project <directory>", "Also inventory native skills in a project directory").option("--include-unmanaged", "Archive user-authored skills as well as Skills-managed copies", false).option("--allow-root-aliases", "Allow home .claude/.codex aliases to existing directories within this home", false).option("--apply", "Move selected skills to private archives outside agent discovery roots", false).option("--json", "Output inventory and archive receipt as JSON", false).description("Inventory native skill copies; preserve complete directories before retiring them").action((options) => {
79932
+ migrate.command("native").option("--project <directory>", "Also inventory native skills in a project directory").option("--include-unmanaged", "Archive user-authored skills as well as Skills-managed copies", false).option("--allow-root-aliases", "Allow home .claude/.codex aliases to existing directories within this home", false).option("--apply", "Move selected skills to private archives outside agent discovery roots", false).option("--json", "Output inventory and archive receipt as JSON", false).description("Inventory native skill copies; preserve complete directories before retiring them").action(async (options) => {
79925
79933
  try {
79926
79934
  const inventory = inventoryNativeSkills(undefined, { projectDir: options.project, allowRootAliases: options.allowRootAliases });
79927
79935
  const result2 = options.apply ? archiveNativeSkills(inventory, { includeUnmanaged: options.includeUnmanaged, allowRootAliases: options.allowRootAliases }) : { entries: [] };
79928
79936
  if (options.json)
79929
- console.log(JSON.stringify({ applied: options.apply, inventory, ...result2 }));
79937
+ await writeCliOutput(JSON.stringify({ applied: options.apply, inventory, ...result2 }));
79930
79938
  else
79931
- console.log(`${inventory.length} native skill(s) found; ${result2.entries.length} archived with recovery receipts.${options.apply ? "" : " Use --apply to archive managed copies."}`);
79939
+ await writeCliOutput(`${inventory.length} native skill(s) found; ${result2.entries.length} archived with recovery receipts.${options.apply ? "" : " Use --apply to archive managed copies."}`);
79932
79940
  } catch (error2) {
79933
79941
  console.error(error2.message);
79934
79942
  process.exitCode = 1;
@@ -80008,7 +80016,7 @@ function registerProfiles(parent) {
80008
80016
  if (options.save)
80009
80017
  writeFileSync22(options.save, `${text2}
80010
80018
  `, { mode: 384, flag: "wx" });
80011
- console.log(options.json ? text2 : `${profile.id} at ${profile.revision}: ${profile.selections.map((skill) => `${skill.slug}@${skill.version}`).join(", ")}`);
80019
+ await writeCliOutput(options.json ? text2 : `${profile.id} at ${profile.revision}: ${profile.selections.map((skill) => `${skill.slug}@${skill.version}`).join(", ")}`);
80012
80020
  } catch (error2) {
80013
80021
  console.error(error2.message);
80014
80022
  process.exitCode = 1;
@@ -80021,7 +80029,7 @@ function registerProfiles(parent) {
80021
80029
  throw new Error("Profile input exceeds the size limit");
80022
80030
  const input = JSON.parse(text2);
80023
80031
  const profile = await saveSkillProfile(id2, input.selections, options.ifMatch);
80024
- console.log(options.json ? JSON.stringify(profile) : `Saved ${profile.id} at ${profile.revision}`);
80032
+ await writeCliOutput(options.json ? JSON.stringify(profile) : `Saved ${profile.id} at ${profile.revision}`);
80025
80033
  } catch (error2) {
80026
80034
  console.error(error2.message);
80027
80035
  process.exitCode = 1;
@@ -80029,7 +80037,7 @@ function registerProfiles(parent) {
80029
80037
  });
80030
80038
  parent.command("station-state <id>").description("Read this actor's last applied skill selection on a station").option("--json", "Output the station receipt as JSON", false).action(async (id2) => {
80031
80039
  try {
80032
- console.log(JSON.stringify(await readStationSkillState(id2), null, 2));
80040
+ await writeCliOutput(JSON.stringify(await readStationSkillState(id2), null, 2));
80033
80041
  } catch (error2) {
80034
80042
  console.error(error2.message);
80035
80043
  process.exitCode = 1;
@@ -83147,7 +83155,6 @@ var init_registry_reconcile2 = __esm(() => {
83147
83155
  init_selection_cache();
83148
83156
  init_registry_reconcile();
83149
83157
  });
83150
-
83151
83158
  // ../../node_modules/.bun/ink@5.2.1+6e93904c7bfe2418/node_modules/ink/build/render.js
83152
83159
  import { Stream } from "stream";
83153
83160
  import process12 from "process";
@@ -90963,8 +90970,8 @@ program2.command("interactive", { isDefault: true }).alias("i").allowExcessArgum
90963
90970
  process.exit(1);
90964
90971
  }
90965
90972
  if (!isTTY2) {
90966
- console.log(JSON.stringify(loadBasicRegistry().map(getCompactSkillDiscovery)));
90967
- process.exit(0);
90973
+ await writeCliOutput(JSON.stringify(loadBasicRegistry().map(getCompactSkillDiscovery)));
90974
+ return;
90968
90975
  }
90969
90976
  render_default(/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(App2, {}, undefined, false, undefined, this));
90970
90977
  });
package/bin/mcp.js CHANGED
@@ -5586,7 +5586,7 @@ var package_default;
5586
5586
  var init_package = __esm(() => {
5587
5587
  package_default = {
5588
5588
  name: "@hasna/skills",
5589
- version: "0.6.0",
5589
+ version: "0.6.1",
5590
5590
  description: "Skills library for AI coding agents",
5591
5591
  type: "module",
5592
5592
  bin: {
@@ -26973,7 +26973,6 @@ var init_selection_resolver = __esm(() => {
26973
26973
  init_selected_document();
26974
26974
  init_selection_cache();
26975
26975
  });
26976
-
26977
26976
  // src/lib/skill-context.ts
26978
26977
  var init_skill_context = __esm(() => {
26979
26978
  init_selection_resolver();
package/bin/migrate.js CHANGED
@@ -7,7 +7,7 @@ import { join as join6 } from "path";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "@hasna/skills",
10
- version: "0.6.0",
10
+ version: "0.6.1",
11
11
  description: "Skills library for AI coding agents",
12
12
  type: "module",
13
13
  bin: {
package/bin/server.js CHANGED
@@ -23100,7 +23100,7 @@ var init_dist_es9 = __esm(() => {
23100
23100
  // package.json
23101
23101
  var package_default = {
23102
23102
  name: "@hasna/skills",
23103
- version: "0.6.0",
23103
+ version: "0.6.1",
23104
23104
  description: "Skills library for AI coding agents",
23105
23105
  type: "module",
23106
23106
  bin: {
package/bin/worker.js CHANGED
@@ -23103,7 +23103,7 @@ import { randomUUID as randomUUID5 } from "crypto";
23103
23103
  // package.json
23104
23104
  var package_default = {
23105
23105
  name: "@hasna/skills",
23106
- version: "0.6.0",
23106
+ version: "0.6.1",
23107
23107
  description: "Skills library for AI coding agents",
23108
23108
  type: "module",
23109
23109
  bin: {
@@ -1,5 +1,2 @@
1
- /**
2
- * run / mcp / self-update — runtime commands
3
- */
4
1
  import type { Command } from "commander";
5
2
  export declare function registerRuntime(parent: Command): void;
@@ -0,0 +1,2 @@
1
+ /** Finish pipe writes before an async command returns, including under backpressure. */
2
+ export declare function writeCliOutput(text: string, newline?: boolean): Promise<void>;
package/dist/index.js CHANGED
@@ -13710,7 +13710,7 @@ import { dirname as dirname8, relative as relative6 } from "path";
13710
13710
  // package.json
13711
13711
  var package_default = {
13712
13712
  name: "@hasna/skills",
13713
- version: "0.6.0",
13713
+ version: "0.6.1",
13714
13714
  description: "Skills library for AI coding agents",
13715
13715
  type: "module",
13716
13716
  bin: {
package/dist/sdk/index.js CHANGED
@@ -24427,7 +24427,7 @@ var init_event_sink = __esm(() => {
24427
24427
  // package.json
24428
24428
  var package_default = {
24429
24429
  name: "@hasna/skills",
24430
- version: "0.6.0",
24430
+ version: "0.6.1",
24431
24431
  description: "Skills library for AI coding agents",
24432
24432
  type: "module",
24433
24433
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/skills",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Skills library for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {