@hasna/skills 0.9.14 → 0.9.15

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/mcp.js CHANGED
@@ -20019,7 +20019,7 @@ var package_default;
20019
20019
  var init_package = __esm(() => {
20020
20020
  package_default = {
20021
20021
  name: "@hasna/skills",
20022
- version: "0.9.14",
20022
+ version: "0.9.15",
20023
20023
  description: "Skills library for AI coding agents",
20024
20024
  type: "module",
20025
20025
  bin: {
@@ -48796,13 +48796,24 @@ var init_codex_hook_trust_files = () => {};
48796
48796
  // src/lib/codex-hook-trust-layout.ts
48797
48797
  var init_codex_hook_trust_layout = () => {};
48798
48798
 
48799
+ // src/lib/codex-hook-additions-review.ts
48800
+ var events, matchedEvents, proofs;
48801
+ var init_codex_hook_additions_review = __esm(() => {
48802
+ init_codex_hook_trust_files();
48803
+ init_codex_hook_trust_layout();
48804
+ events = { UserPromptSubmit: ["userPromptSubmit", "user_prompt_submit"], SessionStart: ["sessionStart", "session_start"], SubagentStart: ["subagentStart", "subagent_start"] };
48805
+ matchedEvents = { ...events, PreToolUse: ["preToolUse", "pre_tool_use"] };
48806
+ proofs = new WeakMap;
48807
+ });
48808
+
48799
48809
  // src/lib/codex-hook-discovery-recovery.ts
48800
48810
  import { createHash as createHash13 } from "crypto";
48801
48811
  function assertCodexHookDiscoveryRecovery(binding, witness) {
48802
- const proof = proofs.get(witness);
48812
+ const proof = proofs2.get(witness);
48803
48813
  need4(!!proof && binding.agent === "codex" && witness.discoverySha256 === sha(JSON.stringify(binding)), "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
48804
48814
  unchanged2(proof.before);
48805
48815
  unchanged2(proof.current);
48816
+ proof.recheckAdditions();
48806
48817
  }
48807
48818
  function verifiesCodexHookDiscoverySource(binding, source, currentDigest, witness) {
48808
48819
  if (!witness || source.path !== witness.configPath || source.hashMode !== "bytes")
@@ -48811,11 +48822,12 @@ function verifiesCodexHookDiscoverySource(binding, source, currentDigest, witnes
48811
48822
  need4(source.sha256 === witness.beforeSha256 && currentDigest === witness.currentSha256, "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
48812
48823
  return true;
48813
48824
  }
48814
- var sha = (text2) => createHash13("sha256").update(text2).digest("hex"), proofs;
48825
+ var sha = (text2) => createHash13("sha256").update(text2).digest("hex"), proofs2;
48815
48826
  var init_codex_hook_discovery_recovery = __esm(() => {
48816
48827
  init_codex_hook_trust_files();
48817
48828
  init_codex_hook_trust_layout();
48818
- proofs = new WeakMap;
48829
+ init_codex_hook_additions_review();
48830
+ proofs2 = new WeakMap;
48819
48831
  });
48820
48832
 
48821
48833
  // src/lib/agent-discovery.ts
@@ -59783,17 +59795,17 @@ var WSContext = class {
59783
59795
  if (typeof args[0] === "function") {
59784
59796
  const [createEvents, options] = args;
59785
59797
  return async function upgradeWebSocket(c, next) {
59786
- const events = await createEvents(c);
59787
- const result = await handler(c, events, options);
59798
+ const events2 = await createEvents(c);
59799
+ const result = await handler(c, events2, options);
59788
59800
  if (result) {
59789
59801
  return result;
59790
59802
  }
59791
59803
  await next();
59792
59804
  };
59793
59805
  } else {
59794
- const [c, events, options] = args;
59806
+ const [c, events2, options] = args;
59795
59807
  return (async () => {
59796
- const upgraded = await handler(c, events, options);
59808
+ const upgraded = await handler(c, events2, options);
59797
59809
  if (!upgraded) {
59798
59810
  throw new Error("Failed to upgrade WebSocket");
59799
59811
  }
@@ -60990,7 +61002,7 @@ var init_dist2 = __esm(() => {
60990
61002
  "sec-websocket-extensions",
60991
61003
  "sec-websocket-protocol"
60992
61004
  ]);
60993
- upgradeWebSocket = defineWebSocketHelper(async (c, events, options) => {
61005
+ upgradeWebSocket = defineWebSocketHelper(async (c, events2, options) => {
60994
61006
  if (c.req.header("upgrade")?.toLowerCase() !== "websocket")
60995
61007
  return;
60996
61008
  const env = c.env;
@@ -61027,7 +61039,7 @@ var init_dist2 = __esm(() => {
61027
61039
  url: new URL(c.req.url)
61028
61040
  };
61029
61041
  try {
61030
- events?.onOpen?.(new Event("open"), ctx);
61042
+ events2?.onOpen?.(new Event("open"), ctx);
61031
61043
  } catch (e2) {
61032
61044
  (options?.onError ?? console.error)(e2);
61033
61045
  }
@@ -61035,7 +61047,7 @@ var init_dist2 = __esm(() => {
61035
61047
  const datas = Array.isArray(data) ? data : [data];
61036
61048
  for (const data2 of datas)
61037
61049
  try {
61038
- events?.onMessage?.(new MessageEvent("message", { data: isBinary ? data2 instanceof ArrayBuffer ? data2 : data2.buffer.slice(data2.byteOffset, data2.byteOffset + data2.byteLength) : typeof data2 === "string" ? data2 : Buffer.from(data2).toString("utf-8") }), ctx);
61050
+ events2?.onMessage?.(new MessageEvent("message", { data: isBinary ? data2 instanceof ArrayBuffer ? data2 : data2.buffer.slice(data2.byteOffset, data2.byteOffset + data2.byteLength) : typeof data2 === "string" ? data2 : Buffer.from(data2).toString("utf-8") }), ctx);
61039
61051
  } catch (e2) {
61040
61052
  (options?.onError ?? console.error)(e2);
61041
61053
  }
@@ -61048,7 +61060,7 @@ var init_dist2 = __esm(() => {
61048
61060
  });
61049
61061
  ws.on("close", (code2, reason) => {
61050
61062
  try {
61051
- events?.onClose?.(new CloseEvent("close", {
61063
+ events2?.onClose?.(new CloseEvent("close", {
61052
61064
  code: code2,
61053
61065
  reason: reason.toString()
61054
61066
  }), ctx);
@@ -61058,7 +61070,7 @@ var init_dist2 = __esm(() => {
61058
61070
  });
61059
61071
  ws.on("error", (error61) => {
61060
61072
  try {
61061
- events?.onError?.(new ErrorEvent("error", { error: error61 }), ctx);
61073
+ events2?.onError?.(new ErrorEvent("error", { error: error61 }), ctx);
61062
61074
  } catch (e2) {
61063
61075
  (options?.onError ?? console.error)(e2);
61064
61076
  }
package/bin/migrate.js CHANGED
@@ -7,7 +7,7 @@ import { join as join5 } from "path";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "@hasna/skills",
10
- version: "0.9.14",
10
+ version: "0.9.15",
11
11
  description: "Skills library for AI coding agents",
12
12
  type: "module",
13
13
  bin: {
package/bin/server.js CHANGED
@@ -24122,7 +24122,7 @@ var init_dist_es9 = __esm(() => {
24122
24122
  // package.json
24123
24123
  var package_default = {
24124
24124
  name: "@hasna/skills",
24125
- version: "0.9.14",
24125
+ version: "0.9.15",
24126
24126
  description: "Skills library for AI coding agents",
24127
24127
  type: "module",
24128
24128
  bin: {
package/bin/worker.js CHANGED
@@ -24125,7 +24125,7 @@ import { randomUUID as randomUUID6 } from "crypto";
24125
24125
  // package.json
24126
24126
  var package_default = {
24127
24127
  name: "@hasna/skills",
24128
- version: "0.9.14",
24128
+ version: "0.9.15",
24129
24129
  description: "Skills library for AI coding agents",
24130
24130
  type: "module",
24131
24131
  bin: {
package/dist/index.js CHANGED
@@ -9610,7 +9610,7 @@ import { isAbsolute as isAbsolute11, join as join23, resolve as resolve11 } from
9610
9610
  // package.json
9611
9611
  var package_default = {
9612
9612
  name: "@hasna/skills",
9613
- version: "0.9.14",
9613
+ version: "0.9.15",
9614
9614
  description: "Skills library for AI coding agents",
9615
9615
  type: "module",
9616
9616
  bin: {
@@ -16439,14 +16439,20 @@ function unchanged2(before) {
16439
16439
  need4(sameStat(before.stat, after.stat) && after.sha256 === before.sha256, "INPUT_CHANGED");
16440
16440
  }
16441
16441
 
16442
+ // src/lib/codex-hook-additions-review.ts
16443
+ var events = { UserPromptSubmit: ["userPromptSubmit", "user_prompt_submit"], SessionStart: ["sessionStart", "session_start"], SubagentStart: ["subagentStart", "subagent_start"] };
16444
+ var matchedEvents = { ...events, PreToolUse: ["preToolUse", "pre_tool_use"] };
16445
+ var proofs = new WeakMap;
16446
+
16442
16447
  // src/lib/codex-hook-discovery-recovery.ts
16443
16448
  var sha2 = (text2) => createHash15("sha256").update(text2).digest("hex");
16444
- var proofs = new WeakMap;
16449
+ var proofs2 = new WeakMap;
16445
16450
  function assertCodexHookDiscoveryRecovery(binding, witness) {
16446
- const proof = proofs.get(witness);
16451
+ const proof = proofs2.get(witness);
16447
16452
  need4(!!proof && binding.agent === "codex" && witness.discoverySha256 === sha2(JSON.stringify(binding)), "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
16448
16453
  unchanged2(proof.before);
16449
16454
  unchanged2(proof.current);
16455
+ proof.recheckAdditions();
16450
16456
  }
16451
16457
  function verifiesCodexHookDiscoverySource(binding, source, currentDigest, witness) {
16452
16458
  if (!witness || source.path !== witness.configPath || source.hashMode !== "bytes")
@@ -71,7 +71,8 @@ export declare function reconcileCodexNativeHooks(options: CodexNativeHookReconc
71
71
  hooksPath: string;
72
72
  hooksSha256: string;
73
73
  };
74
- additions: any[];
74
+ additions: any;
75
+ version?: number | undefined;
75
76
  } | undefined;
76
77
  configDiscoveryRecovery?: import("./codex-hook-discovery-recovery.js").CodexHookDiscoveryRecovery | undefined;
77
78
  version: number;
@@ -4,6 +4,25 @@ export interface NativeHookAdditionsRecovery {
4
4
  path: string;
5
5
  reviewedPlanDigest?: string;
6
6
  }
7
+ /** Internal capability, not a caller-supplied config override. */
8
+ export interface ReviewedNativeHookAdditions {
9
+ readonly reviewSha256: string;
10
+ }
11
+ type JournalHook = {
12
+ key: string;
13
+ currentHash: string;
14
+ };
15
+ type TrustState = Readonly<{
16
+ trusted_hash: string;
17
+ enabled?: true;
18
+ }>;
19
+ type AddedTrustState = Readonly<{
20
+ key: string;
21
+ state: TrustState;
22
+ }>;
23
+ /** Rebind the proof to this exact journal transition and recheck every source.
24
+ * A serialized/cloned receipt can never create a discovery exception. */
25
+ export declare function readReviewedAdditionTrustStates(proof: ReviewedNativeHookAdditions, before: Snapshot, current: Snapshot, journalHooks: JournalHook[]): readonly AddedTrustState[];
7
26
  /** An explicit, private review of a later producer's append-only hook change.
8
27
  * The producer backups must themselves describe exactly the completed journal
9
28
  * operation. Neither a claimed receipt nor a matching raw hash grants authority
@@ -25,6 +44,7 @@ export declare function reviewNativeHookAdditions(options: {
25
44
  }): {
26
45
  hooks: any[];
27
46
  recheck: () => void;
47
+ trustProof: ReviewedNativeHookAdditions;
28
48
  receipt: {
29
49
  reviewPath: string;
30
50
  reviewSha256: string;
@@ -36,7 +56,8 @@ export declare function reviewNativeHookAdditions(options: {
36
56
  hooksPath: string;
37
57
  hooksSha256: string;
38
58
  };
39
- additions: any[];
59
+ additions: any;
60
+ version?: number | undefined;
40
61
  };
41
62
  };
42
63
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { AgentDiscoveryBinding, DiscoverySource } from "./agent-discovery.js";
2
2
  import { type snapshot } from "./codex-hook-trust-files.js";
3
+ import { type ReviewedNativeHookAdditions } from "./codex-hook-additions-review.js";
3
4
  type Snapshot = ReturnType<typeof snapshot>;
4
5
  /** A receipt projection, not an override supplied by a CLI caller. Only this
5
6
  * module can create the in-memory proof used by discovery verification. */
@@ -17,7 +18,7 @@ export interface CodexHookDiscoveryRecovery {
17
18
  export declare function createCodexHookDiscoveryRecovery(binding: AgentDiscoveryBinding, before: Snapshot, current: Snapshot, hooks: Array<{
18
19
  key: string;
19
20
  currentHash: string;
20
- }>): CodexHookDiscoveryRecovery | undefined;
21
+ }>, additions?: ReviewedNativeHookAdditions): CodexHookDiscoveryRecovery | undefined;
21
22
  export declare function assertCodexHookDiscoveryRecovery(binding: AgentDiscoveryBinding, witness: CodexHookDiscoveryRecovery): void;
22
23
  /** Verify this one historical byte witness using the already-validated native
23
24
  * transition. Every other source still uses its ordinary current-file hash. */
package/dist/sdk/index.js CHANGED
@@ -31310,17 +31310,17 @@ class JsonEventsStore {
31310
31310
  }
31311
31311
  async appendEvent(event) {
31312
31312
  await this.init();
31313
- const events = await this.readJson(this.eventsPath, []);
31314
- events.push(event);
31315
- await this.writeJson(this.eventsPath, events);
31313
+ const events2 = await this.readJson(this.eventsPath, []);
31314
+ events2.push(event);
31315
+ await this.writeJson(this.eventsPath, events2);
31316
31316
  return event;
31317
31317
  }
31318
31318
  async appendEventOnce(event, options = {}) {
31319
31319
  await this.init();
31320
- const events = await this.readJson(this.eventsPath, []);
31320
+ const events2 = await this.readJson(this.eventsPath, []);
31321
31321
  const dedupe = options.dedupe !== false;
31322
31322
  if (dedupe) {
31323
- const existing = findEventByIdentity(events, { id: event.id, dedupeKey: event.dedupeKey });
31323
+ const existing = findEventByIdentity(events2, { id: event.id, dedupeKey: event.dedupeKey });
31324
31324
  if (existing) {
31325
31325
  return {
31326
31326
  event: existing,
@@ -31330,8 +31330,8 @@ class JsonEventsStore {
31330
31330
  };
31331
31331
  }
31332
31332
  }
31333
- events.push(event);
31334
- await this.writeJson(this.eventsPath, events);
31333
+ events2.push(event);
31334
+ await this.writeJson(this.eventsPath, events2);
31335
31335
  return {
31336
31336
  event,
31337
31337
  stored: true,
@@ -31341,13 +31341,13 @@ class JsonEventsStore {
31341
31341
  }
31342
31342
  async listEvents(options = {}) {
31343
31343
  await this.init();
31344
- const events = await this.readJson(this.eventsPath, []);
31345
- return queryEvents(events, options);
31344
+ const events2 = await this.readJson(this.eventsPath, []);
31345
+ return queryEvents(events2, options);
31346
31346
  }
31347
31347
  async listEventsPage(options = {}) {
31348
31348
  await this.init();
31349
- const events = await this.readJson(this.eventsPath, []);
31350
- const queried = queryEvents(events, {
31349
+ const events2 = await this.readJson(this.eventsPath, []);
31350
+ const queried = queryEvents(events2, {
31351
31351
  eventId: options.eventId,
31352
31352
  source: options.source,
31353
31353
  type: options.type
@@ -31365,8 +31365,8 @@ class JsonEventsStore {
31365
31365
  };
31366
31366
  }
31367
31367
  async findEventByIdentity(identity3) {
31368
- const events = await this.listEvents();
31369
- return findEventByIdentity(events, identity3);
31368
+ const events2 = await this.listEvents();
31369
+ return findEventByIdentity(events2, identity3);
31370
31370
  }
31371
31371
  async appendDelivery(result) {
31372
31372
  await this.init();
@@ -31471,8 +31471,8 @@ function normalizeEventPageLimit(limit) {
31471
31471
  throw new Error(`Event page limit must be a positive integer, got ${limit}`);
31472
31472
  return Math.min(limit, MAX_EVENT_PAGE_LIMIT);
31473
31473
  }
31474
- function queryEvents(events, options) {
31475
- let rows = events;
31474
+ function queryEvents(events2, options) {
31475
+ let rows = events2;
31476
31476
  if (options.eventId)
31477
31477
  rows = rows.filter((event) => event.id === options.eventId);
31478
31478
  if (options.source)
@@ -31491,8 +31491,8 @@ function assertCursorFilter(name, cursorValue, optionValue) {
31491
31491
  if (cursorValue !== optionValue)
31492
31492
  throw new Error(`Local JSON event cursor ${name} filter mismatch`);
31493
31493
  }
31494
- function findEventByIdentity(events, identity3) {
31495
- return events.find((event) => identity3.id !== undefined && event.id === identity3.id || identity3.dedupeKey !== undefined && event.dedupeKey === identity3.dedupeKey);
31494
+ function findEventByIdentity(events2, identity3) {
31495
+ return events2.find((event) => identity3.id !== undefined && event.id === identity3.id || identity3.dedupeKey !== undefined && event.dedupeKey === identity3.dedupeKey);
31496
31496
  }
31497
31497
  function buildSignatureBase(timestamp, body4) {
31498
31498
  return `${timestamp}.${body4}`;
@@ -32125,16 +32125,16 @@ class EventsClient {
32125
32125
  async listEventsPage(options = {}) {
32126
32126
  if (this.store.listEventsPage)
32127
32127
  return this.store.listEventsPage(options);
32128
- const events = queryClientEvents(await this.store.listEvents(), {
32128
+ const events2 = queryClientEvents(await this.store.listEvents(), {
32129
32129
  eventId: options.eventId,
32130
32130
  source: options.source,
32131
32131
  type: options.type
32132
32132
  });
32133
32133
  const offset = decodeLocalJsonEventCursor(options.cursor, options);
32134
32134
  const limit = normalizeEventPageLimit(options.limit);
32135
- const pageEvents = events.slice(offset, offset + limit);
32135
+ const pageEvents = events2.slice(offset, offset + limit);
32136
32136
  const nextOffset = offset + pageEvents.length;
32137
- const hasMore = nextOffset < events.length;
32137
+ const hasMore = nextOffset < events2.length;
32138
32138
  return {
32139
32139
  events: pageEvents,
32140
32140
  cursor: options.cursor,
@@ -32265,8 +32265,8 @@ class EventsClient {
32265
32265
  return createDeliveryResult(event, channel, attempts);
32266
32266
  }
32267
32267
  }
32268
- function queryClientEvents(events, options) {
32269
- let rows = events;
32268
+ function queryClientEvents(events2, options) {
32269
+ let rows = events2;
32270
32270
  if (options.eventId)
32271
32271
  rows = rows.filter((event) => event.id === options.eventId);
32272
32272
  if (options.source)
@@ -32373,7 +32373,7 @@ var init_event_sink = __esm(() => {
32373
32373
  // package.json
32374
32374
  var package_default = {
32375
32375
  name: "@hasna/skills",
32376
- version: "0.9.14",
32376
+ version: "0.9.15",
32377
32377
  description: "Skills library for AI coding agents",
32378
32378
  type: "module",
32379
32379
  bin: {
@@ -40267,14 +40267,20 @@ function unchanged2(before) {
40267
40267
  need4(sameStat(before.stat, after.stat) && after.sha256 === before.sha256, "INPUT_CHANGED");
40268
40268
  }
40269
40269
 
40270
+ // src/lib/codex-hook-additions-review.ts
40271
+ var events = { UserPromptSubmit: ["userPromptSubmit", "user_prompt_submit"], SessionStart: ["sessionStart", "session_start"], SubagentStart: ["subagentStart", "subagent_start"] };
40272
+ var matchedEvents = { ...events, PreToolUse: ["preToolUse", "pre_tool_use"] };
40273
+ var proofs = new WeakMap;
40274
+
40270
40275
  // src/lib/codex-hook-discovery-recovery.ts
40271
40276
  var sha = (text2) => createHash14("sha256").update(text2).digest("hex");
40272
- var proofs = new WeakMap;
40277
+ var proofs2 = new WeakMap;
40273
40278
  function assertCodexHookDiscoveryRecovery(binding, witness) {
40274
- const proof = proofs.get(witness);
40279
+ const proof = proofs2.get(witness);
40275
40280
  need4(!!proof && binding.agent === "codex" && witness.discoverySha256 === sha(JSON.stringify(binding)), "RECONCILE_DISCOVERY_RECOVERY_CHANGED");
40276
40281
  unchanged2(proof.before);
40277
40282
  unchanged2(proof.current);
40283
+ proof.recheckAdditions();
40278
40284
  }
40279
40285
  function verifiesCodexHookDiscoverySource(binding, source, currentDigest, witness) {
40280
40286
  if (!witness || source.path !== witness.configPath || source.hashMode !== "bytes")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/skills",
3
- "version": "0.9.14",
3
+ "version": "0.9.15",
4
4
  "description": "Skills library for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {