@use-aistack/cli 0.19.1 → 0.19.2

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
@@ -18906,7 +18906,7 @@ function apiEquivalentCost(modelKey, t, atMs) {
18906
18906
  }
18907
18907
 
18908
18908
  // src/version.ts
18909
- var CLI_VERSION = true ? "0.19.1" : "0.0.0-dev";
18909
+ var CLI_VERSION = true ? "0.19.2" : "0.0.0-dev";
18910
18910
 
18911
18911
  // src/api.ts
18912
18912
  var BASE_URL = process.env.AISTACK_URL || "https://aistack.to";
@@ -22738,8 +22738,8 @@ function buildPayload(input) {
22738
22738
  );
22739
22739
  const skills = buildCategory(
22740
22740
  finalized.skills,
22741
- new Set(allowlist.skills),
22742
- optIns.skills,
22741
+ new Set(finalized.skills.map(([name]) => name)),
22742
+ [],
22743
22743
  observedCalls.skills
22744
22744
  );
22745
22745
  const subagents = buildCategory(
@@ -23580,7 +23580,8 @@ function createAggregate2() {
23580
23580
  workflowSeenCalls: /* @__PURE__ */ new Set(),
23581
23581
  workflowSeenTurns: /* @__PURE__ */ new Set(),
23582
23582
  contextFirstCall: /* @__PURE__ */ new Map(),
23583
- workflowToolNames: /* @__PURE__ */ new Map()
23583
+ workflowToolNames: /* @__PURE__ */ new Map(),
23584
+ typedCommands: /* @__PURE__ */ new Map()
23584
23585
  });
23585
23586
  }
23586
23587
  function workflowSessionKey(rec) {
@@ -24020,6 +24021,7 @@ function toolResultBytes(content) {
24020
24021
  }
24021
24022
  return bytes;
24022
24023
  }
24024
+ var SKILL_BODY_PREFIX = "Base directory for this skill:";
24023
24025
  function ingestUser(agg, rec) {
24024
24026
  const msg = asObj(rec.message);
24025
24027
  if (!msg) return;
@@ -24033,10 +24035,34 @@ function ingestUser(agg, rec) {
24033
24035
  if (asStr(block.type) === "text") text += asStr(block.text) ?? "";
24034
24036
  }
24035
24037
  }
24038
+ if (rec.isMeta === true && !asStr(rec.sourceToolUseID) && text.startsWith(SKILL_BODY_PREFIX)) {
24039
+ ingestTypedSkill(agg, rec, text);
24040
+ return;
24041
+ }
24036
24042
  if (!text.includes("<command-name>")) return;
24043
+ const names = [];
24037
24044
  for (const match of text.matchAll(SLASH_RE)) {
24038
- bump(agg.slashCommands, cleanName(match[1]));
24045
+ const name = cleanName(match[1]);
24046
+ bump(agg.slashCommands, name);
24047
+ names.push(name);
24048
+ }
24049
+ const uuid = asStr(rec.uuid);
24050
+ if (uuid && names.length > 0) agg.typedCommands.set(uuid, names);
24051
+ }
24052
+ function ingestTypedSkill(agg, rec, text) {
24053
+ const parent = asStr(rec.parentUuid);
24054
+ const typed = parent ? agg.typedCommands.get(parent) : void 0;
24055
+ if (typed?.length === 1) {
24056
+ const name = typed[0];
24057
+ const left = (agg.slashCommands.get(name) ?? 0) - 1;
24058
+ if (left > 0) agg.slashCommands.set(name, left);
24059
+ else agg.slashCommands.delete(name);
24060
+ bump(agg.skillCalls, name);
24061
+ return;
24039
24062
  }
24063
+ const dir = text.slice(SKILL_BODY_PREFIX.length).split("\n")[0].trim();
24064
+ const base = dir.split(/[\\/]/).filter(Boolean).pop();
24065
+ bump(agg.skillCalls, base ? cleanName(base) : "(unnamed)");
24040
24066
  }
24041
24067
 
24042
24068
  // src/harness/claude/scan.ts
@@ -24222,7 +24248,8 @@ function createFileState() {
24222
24248
  metaTsMs: null,
24223
24249
  forked: false,
24224
24250
  sawResponse: false,
24225
- callNames: /* @__PURE__ */ new Map()
24251
+ callNames: /* @__PURE__ */ new Map(),
24252
+ turnSkills: /* @__PURE__ */ new Set()
24226
24253
  };
24227
24254
  }
24228
24255
  function genuineDelta(payload, state, tsMs) {
@@ -24291,9 +24318,10 @@ function ingestLine(agg, raw, state, sinceMs) {
24291
24318
  }
24292
24319
  noteActivity(agg, state, tsMs);
24293
24320
  noteProjectDay(agg, state.cwd ?? "(unknown)", tsMs);
24294
- if (type === "event_msg" && payload)
24321
+ if (type === "event_msg" && payload) {
24322
+ if (asStr(payload.type) === "task_started") state.turnSkills.clear();
24295
24323
  ingestEvent(agg, payload, state, tsMs, firstCall);
24296
- else if (type === "response_item" && payload)
24324
+ } else if (type === "response_item" && payload)
24297
24325
  ingestItem(agg, payload, state, tsMs);
24298
24326
  else if (type === "compacted" && tsMs !== null && state.sessionId) {
24299
24327
  agg.workflow.ingest({
@@ -24403,10 +24431,16 @@ function ingestItem(agg, payload, state, tsMs) {
24403
24431
  if (!name) return;
24404
24432
  const callId = asStr(payload.call_id) ?? asStr(payload.id);
24405
24433
  if (callId) state.callNames.set(callId, name);
24434
+ if (name !== "apply_patch" && (!callId || !agg.toolCallDedup.has(callId)))
24435
+ ingestSkillReads(agg, payload.arguments ?? payload.input, state);
24406
24436
  ingestCall(agg, name, callId);
24407
24437
  ingestWorkflowCall(agg, payload, name, callId, state, tsMs);
24408
24438
  return;
24409
24439
  }
24440
+ if (type === "message" && asStr(payload.role) === "user") {
24441
+ ingestSkillMention(agg, payload, state);
24442
+ return;
24443
+ }
24410
24444
  if (type === "local_shell_call") {
24411
24445
  const callId = asStr(payload.call_id) ?? asStr(payload.id);
24412
24446
  if (callId) state.callNames.set(callId, "local_shell");
@@ -24435,6 +24469,33 @@ function ingestItem(agg, payload, state, tsMs) {
24435
24469
  );
24436
24470
  }
24437
24471
  }
24472
+ var SKILL_READ_RE = /([A-Za-z0-9._:@-]+)[/\\]SKILL\.md\b/g;
24473
+ function ingestSkillReads(agg, args, state) {
24474
+ if (typeof args !== "string" || !args.includes("SKILL.md")) return;
24475
+ for (const match of args.matchAll(SKILL_READ_RE))
24476
+ countTurnSkill(agg, cleanName(match[1]), state);
24477
+ }
24478
+ var SKILL_MENTION_RE = /^<skill>\s*<name>([^<]{1,200})<\/name>/;
24479
+ function ingestSkillMention(agg, payload, state) {
24480
+ for (const rawBlock of asArr(payload.content)) {
24481
+ const text = asStr(asObj(rawBlock)?.text);
24482
+ const name = text ? SKILL_MENTION_RE.exec(text)?.[1] : void 0;
24483
+ if (!name) continue;
24484
+ const id = asStr(payload.id);
24485
+ if (id) {
24486
+ const key2 = `skill-mention:${id}`;
24487
+ if (agg.toolCallDedup.has(key2)) return;
24488
+ agg.toolCallDedup.add(key2);
24489
+ }
24490
+ countTurnSkill(agg, cleanName(name), state);
24491
+ return;
24492
+ }
24493
+ }
24494
+ function countTurnSkill(agg, name, state) {
24495
+ if (state.turnSkills.has(name)) return;
24496
+ state.turnSkills.add(name);
24497
+ bump(agg.skillCalls, name);
24498
+ }
24438
24499
  function ingestToolResult(agg, payload, state, tsMs) {
24439
24500
  if (tsMs === null || !state.sessionId) return;
24440
24501
  const callId = asStr(payload.call_id) ?? asStr(payload.id);
@@ -27343,6 +27404,16 @@ function noteConfiguredMcpServers2(agg, state, serverNames) {
27343
27404
  }
27344
27405
  state.mcpServers.sort((a, b) => b.length - a.length);
27345
27406
  }
27407
+ function ingestTypedSkill2(agg, row) {
27408
+ const id = asStr(row.id);
27409
+ const dir = asStr(row.skillDir)?.trim();
27410
+ if (!id || !dir) return;
27411
+ const key2 = `typed-skill:${id}`;
27412
+ if (agg.toolCallDedup.has(key2)) return;
27413
+ agg.toolCallDedup.add(key2);
27414
+ const base = dir.split(/[\\/]/).filter(Boolean).pop();
27415
+ if (base) bump(agg.skillCalls, cleanName(base));
27416
+ }
27346
27417
 
27347
27418
  // src/harness/opencode/scan.ts
27348
27419
  import { readFileSync as readFileSync12 } from "node:fs";
@@ -27527,6 +27598,21 @@ function readDb(agg, state, open4, file, sinceMs) {
27527
27598
  messageId: r.message_id
27528
27599
  });
27529
27600
  }
27601
+ const typedSkills = db.prepare(
27602
+ `select id, substr(rest, 1, case when instr(rest, char(10)) > 0
27603
+ then instr(rest, char(10)) - 1 else 512 end) as skill_dir
27604
+ from (
27605
+ select p.id as id, substr(json_extract(p.data, '$.text'),
27606
+ instr(json_extract(p.data, '$.text'), 'Base directory for this skill: ') + 31) as rest
27607
+ from part p join message m on m.id = p.message_id
27608
+ where p.time_created >= ?
27609
+ and json_extract(p.data, '$.type') = 'text'
27610
+ and json_extract(m.data, '$.role') = 'user'
27611
+ and instr(json_extract(p.data, '$.text'), 'Base directory for this skill: ') > 0
27612
+ )`
27613
+ );
27614
+ for (const r of typedSkills.all(sinceMs))
27615
+ ingestTypedSkill2(agg, { id: r.id, skillDir: r.skill_dir });
27530
27616
  try {
27531
27617
  const v2parts = db.prepare(
27532
27618
  `select sm.id || ':' || je.key as id, sm.id as message_id,