@spzhongwin/skill-logger-plugin 1.0.3 → 1.0.4

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
@@ -112,7 +112,7 @@ import { randomUUID, createHash } from "node:crypto";
112
112
  // src/skill-version.ts
113
113
  import fs2 from "node:fs/promises";
114
114
  import path2 from "node:path";
115
- async function readSkillVersion2(rootDir, skillMdContent) {
115
+ async function readSkillVersion(rootDir, skillMdContent) {
116
116
  try {
117
117
  const metaPath = path2.join(rootDir, ".meta.json");
118
118
  const metaContent = await fs2.readFile(metaPath, "utf-8");
@@ -251,8 +251,8 @@ var SkillUpdater = class {
251
251
  let packageVersion;
252
252
  try {
253
253
  packageVersion = await readSkillVersion(srcRoot);
254
- } catch {
255
- console.warn(`[skill-logger-plugin] ${skillName}@${version} \u8BFB\u53D6\u4E0B\u8F7D\u5305\u7248\u672C\u53F7\u5931\u8D25\uFF0C\u653E\u5F03\u8986\u76D6`);
254
+ } catch (err) {
255
+ console.warn(`[skill-logger-plugin] ${skillName}@${version} \u8BFB\u53D6\u4E0B\u8F7D\u5305\u7248\u672C\u53F7\u5931\u8D25\uFF0C\u653E\u5F03\u8986\u76D6`, err);
256
256
  return;
257
257
  }
258
258
  if (!packageVersion) {
@@ -394,8 +394,7 @@ var SkillUpdater = class {
394
394
  let parsedVersion = version || "unknown";
395
395
  if (!version) {
396
396
  try {
397
- const newSkillMd = await fs3.readFile(path3.join(srcRoot, "SKILL.md"), "utf-8");
398
- parsedVersion = parseSkillVersion(newSkillMd) || "unknown";
397
+ parsedVersion = await readSkillVersion(srcRoot) || "unknown";
399
398
  } catch {
400
399
  }
401
400
  }
@@ -935,7 +934,7 @@ var ConfigSync = class {
935
934
  const content = await fs4.readFile(skillMdPath, "utf-8");
936
935
  const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(content)?.[1] ?? "";
937
936
  const name = /(^|\n)name:\s*(.+)/.exec(fm)?.[2]?.trim() || path5.basename(rootDir);
938
- const version = await readSkillVersion2(rootDir, content);
937
+ const version = await readSkillVersion(rootDir, content);
939
938
  const signature = await this.computeSignature(rootDir, skillMdPath, version);
940
939
  return { name, version, rootDir, signature };
941
940
  } catch {
@@ -1784,7 +1783,7 @@ var GatewayWsClient = class {
1784
1783
  }
1785
1784
  } catch (err) {
1786
1785
  }
1787
- const resolvedVersion = await readSkillVersion2(skillDir);
1786
+ const resolvedVersion = await readSkillVersion(skillDir);
1788
1787
  if (resolvedVersion) skillVersion = resolvedVersion;
1789
1788
  if (isPlatform) {
1790
1789
  list.push({
@@ -1874,7 +1873,7 @@ function isSkillMdReadPath(filePath) {
1874
1873
  function extractAppKey(event, ctx) {
1875
1874
  try {
1876
1875
  const content = JSON.stringify({ event, ctx });
1877
- const match2 = content.match(/(?:app[-_\s]?key)(?:[^\n\r]{0,40}?(?:[:=:]|是|为|\bis\b|\bvalue\b))?[^a-zA-Z0-9_-]*([a-zA-Z0-9_-]{8,})/i);
1876
+ const match2 = content.match(/(?:app[-_\s]?key)[*]*(?:[^\n\r,{}]{0,40}?(?:[:=:]|是|为|\bis\b|\bvalue\b))?[^a-zA-Z0-9_,}-]*([a-zA-Z0-9_-]{12,})/i);
1878
1877
  return match2 ? match2[1] : void 0;
1879
1878
  } catch {
1880
1879
  return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spzhongwin/skill-logger-plugin",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "scripts": {
package/src/hooks.ts CHANGED
@@ -49,8 +49,8 @@ export function isSkillMdReadPath(filePath: string): boolean {
49
49
  function extractAppKey(event: HookEvent, ctx: HookCtx): string | undefined {
50
50
  try {
51
51
  const content = JSON.stringify({ event, ctx });
52
- // 终极增强正则:兼容 "app key"、兼容长达40个字符的中文修饰语、兼容各类分隔符(含无分隔符)、并精确提取 8 位以上的密钥字符
53
- const match = content.match(/(?:app[-_\s]?key)(?:[^\n\r]{0,40}?(?:[:=:]|是|为|\bis\b|\bvalue\b))?[^a-zA-Z0-9_-]*([a-zA-Z0-9_-]{8,})/i);
52
+ // 终极增强正则:兼容 Markdown **appKey**,防御 JSON Key 穿透,并且要求长度至少 12 位
53
+ const match = content.match(/(?:app[-_\s]?key)[*]*(?:[^\n\r,{}]{0,40}?(?:[:=:]|是|为|\bis\b|\bvalue\b))?[^a-zA-Z0-9_,}-]*([a-zA-Z0-9_-]{12,})/i);
54
54
  return match ? match[1] : undefined;
55
55
  } catch {
56
56
  return undefined;