@gobing-ai/knowledge-kit 0.0.22 → 0.0.24

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.
Files changed (76) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +137 -59
  3. package/package.json +4 -4
  4. package/plugins/generations/content-gen/dist/index.js +97 -45
  5. package/plugins/generations/core-facts-gen/dist/index.js +106 -57
  6. package/plugins/generations/daily-article-gen/dist/index.js +105 -56
  7. package/plugins/generations/dailynews-gen/dist/index.js +235 -57
  8. package/plugins/generations/dailynews-gen/src/index.ts +67 -2
  9. package/plugins/generations/dailynews-gen/src/script-builder.ts +36 -15
  10. package/plugins/generations/dailynews-gen/src/script-plan.ts +142 -0
  11. package/plugins/generations/episode-plan-gen/dist/index.js +115 -66
  12. package/plugins/generations/gemini-tts/README.md +125 -0
  13. package/plugins/generations/gemini-tts/dist/index.js +23348 -0
  14. package/plugins/generations/gemini-tts/package.json +16 -0
  15. package/plugins/generations/gemini-tts/plugin.json +6 -0
  16. package/plugins/generations/gemini-tts/profiles.json +3 -0
  17. package/plugins/generations/gemini-tts/src/gemini-client.ts +220 -0
  18. package/plugins/generations/gemini-tts/src/index.ts +33 -0
  19. package/plugins/generations/gemini-tts/src/voice-create.ts +180 -0
  20. package/plugins/generations/gemini-tts/tsconfig.json +8 -0
  21. package/plugins/generations/image-gen/dist/index.js +338 -117
  22. package/plugins/generations/image-gen/presets/formats/daily-news-cover.yaml +19 -0
  23. package/plugins/generations/image-gen/presets/formats/xhs-card.yaml +55 -0
  24. package/plugins/generations/image-gen/presets/styles/daily-news.yaml +9 -0
  25. package/plugins/generations/image-gen/presets/styles/xhs-knowledge.yaml +7 -0
  26. package/plugins/generations/image-gen/src/index.ts +148 -14
  27. package/plugins/generations/image-gen/src/job.ts +30 -0
  28. package/plugins/generations/image-gen/src/providers/errors.ts +91 -0
  29. package/plugins/generations/image-gen/src/providers/types.ts +79 -0
  30. package/plugins/generations/news-report-gen/dist/index.js +136 -55
  31. package/plugins/generations/news-report-gen/src/index.ts +57 -1
  32. package/plugins/generations/voice-gen/dist/index.js +121 -69
  33. package/plugins/generations/voice-gen/package.json +3 -0
  34. package/plugins/generations/voice-gen/src/index.ts +2 -1
  35. package/plugins/generations/voice-gen/src/voicebox-client.ts +2 -1
  36. package/plugins/ingestions/aihot-ingest/dist/index.js +103 -53
  37. package/plugins/ingestions/horizon-ingest/dist/index.js +102 -53
  38. package/plugins/ingestions/karakeep-local/dist/index.js +273 -224
  39. package/plugins/ingestions/last30days-ingest/dist/index.js +97 -48
  40. package/plugins/ingestions/web-search/dist/index.js +121 -72
  41. package/plugins/kk/config.example.yaml +13 -0
  42. package/plugins/kk/plugin.json +1 -1
  43. package/plugins/kk/scripts/daily-voice-style.zh.md +52 -0
  44. package/plugins/kk/scripts/kk-workflow-stages.ts +438 -17
  45. package/plugins/kk/skills/publish/SKILL.md +24 -1
  46. package/plugins/kk/skills/xhs-images/SKILL.md +89 -0
  47. package/plugins/kk/skills/xhs-images/references/card-layouts.md +35 -0
  48. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +164 -13
  49. package/plugins/publishings/emdash-pub/dist/index.js +94 -45
  50. package/plugins/publishings/infoq-pub/dist/index.js +94 -45
  51. package/plugins/publishings/juejin-pub/dist/index.js +94 -45
  52. package/plugins/publishings/medium-pub/dist/index.js +94 -45
  53. package/plugins/publishings/podcast-pub/dist/index.js +115 -55
  54. package/plugins/publishings/podcast-pub/src/map.ts +30 -10
  55. package/plugins/publishings/podcast-pub/src/show-notes.ts +6 -1
  56. package/plugins/publishings/qiita-pub/dist/index.js +94 -45
  57. package/plugins/publishings/substack-pub/dist/index.js +94 -45
  58. package/plugins/publishings/surfdash-pub/dist/index.js +99 -63
  59. package/plugins/publishings/surfdash-pub/src/index.ts +10 -1
  60. package/plugins/publishings/wechatmp-pub/dist/index.js +94 -45
  61. package/plugins/publishings/x-pub/dist/index.js +94 -45
  62. package/plugins/publishings/xhs-pub/dist/index.js +8908 -229
  63. package/plugins/publishings/xhs-pub/package.json +1 -0
  64. package/plugins/publishings/xhs-pub/plugin.json +1 -1
  65. package/plugins/publishings/xhs-pub/src/automation-guard.ts +128 -0
  66. package/plugins/publishings/xhs-pub/src/index.ts +753 -24
  67. package/plugins/publishings/xhs-pub/src/profile-check.ts +133 -0
  68. package/plugins/publishings/zenn-pub/dist/index.js +94 -45
  69. package/plugins/sp/lib/env.ts +46 -0
  70. package/plugins/sp/lib/inline-run.generated.mjs +1489 -0
  71. package/plugins/sp/scripts/feature-verification-steps.ts +275 -0
  72. package/plugins/sp/scripts/inline-run-setup.ts +571 -47
  73. package/plugins/sp/scripts/wrapup-drift-probe.mjs +190 -0
  74. package/plugins/sp/scripts/wrapup-drift-probe.ts +258 -0
  75. package/plugins/sp/scripts/wrapup-steps.mjs +77 -6
  76. package/plugins/sp/scripts/wrapup-steps.ts +91 -5
@@ -14665,6 +14665,72 @@ var init_zod = __esm(() => {
14665
14665
  init_external();
14666
14666
  });
14667
14667
 
14668
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/errors.js
14669
+ var ErrorCode;
14670
+ var init_errors3 = __esm(() => {
14671
+ ErrorCode = {
14672
+ NotFound: "NOT_FOUND",
14673
+ Validation: "VALIDATION",
14674
+ Conflict: "CONFLICT",
14675
+ Internal: "INTERNAL"
14676
+ };
14677
+ });
14678
+
14679
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14680
+ var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
14681
+ var init_api_response = __esm(() => {
14682
+ init_errors3();
14683
+ API_ERROR_CODES = {
14684
+ SUCCESS: 0,
14685
+ NOT_FOUND: 404,
14686
+ VALIDATION_ERROR: 422,
14687
+ BAD_REQUEST: 400,
14688
+ UNAUTHORIZED: 401,
14689
+ FORBIDDEN: 403,
14690
+ CONFLICT: 409,
14691
+ INTERNAL_ERROR: 500
14692
+ };
14693
+ ERROR_CODE_TO_HTTP = {
14694
+ [ErrorCode.NotFound]: API_ERROR_CODES.NOT_FOUND,
14695
+ [ErrorCode.Validation]: API_ERROR_CODES.VALIDATION_ERROR,
14696
+ [ErrorCode.Conflict]: API_ERROR_CODES.CONFLICT,
14697
+ [ErrorCode.Internal]: API_ERROR_CODES.INTERNAL_ERROR
14698
+ };
14699
+ CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
14700
+ });
14701
+
14702
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14703
+ var init_cursor = () => {};
14704
+
14705
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14706
+ var init_event_severity = () => {};
14707
+
14708
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/output.js
14709
+ function processStream(name) {
14710
+ const proc = globalThis.process;
14711
+ const stream = proc?.[name];
14712
+ if (stream === undefined) {
14713
+ throw new Error(`No ${name} target available: set one via setDefaultOutputTargets or pass an explicit target`);
14714
+ }
14715
+ return stream;
14716
+ }
14717
+ function writeLine(message, target) {
14718
+ target.write(`${message}
14719
+ `);
14720
+ }
14721
+ function echoError(message, target = defaultStderrTarget ?? processStream("stderr")) {
14722
+ writeLine(message, target);
14723
+ }
14724
+ var defaultStderrTarget;
14725
+
14726
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/index.js
14727
+ var init_dist = __esm(() => {
14728
+ init_api_response();
14729
+ init_cursor();
14730
+ init_errors3();
14731
+ init_event_severity();
14732
+ });
14733
+
14668
14734
  // ../../node_modules/.bun/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
14669
14735
  var require_identity = __commonJS((exports) => {
14670
14736
  var ALIAS = Symbol.for("yaml.alias");
@@ -17569,15 +17635,15 @@ var require_timestamp = __commonJS((exports) => {
17569
17635
  throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
17570
17636
  const [, year, month, day, hour, minute, second] = match.map(Number);
17571
17637
  const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
17572
- let date5 = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
17638
+ let date6 = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
17573
17639
  const tz = match[8];
17574
17640
  if (tz && tz !== "Z") {
17575
17641
  let d = parseSexagesimal(tz, false);
17576
17642
  if (Math.abs(d) < 30)
17577
17643
  d *= 60;
17578
- date5 -= 60000 * d;
17644
+ date6 -= 60000 * d;
17579
17645
  }
17580
- return new Date(date5);
17646
+ return new Date(date6);
17581
17647
  },
17582
17648
  stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
17583
17649
  };
@@ -19437,7 +19503,7 @@ var require_composer = __commonJS((exports) => {
19437
19503
  var node_process = __require("process");
19438
19504
  var directives = require_directives();
19439
19505
  var Document = require_Document();
19440
- var errors3 = require_errors();
19506
+ var errors4 = require_errors();
19441
19507
  var identity = require_identity();
19442
19508
  var composeDoc = require_compose_doc();
19443
19509
  var resolveEnd = require_resolve_end();
@@ -19488,9 +19554,9 @@ var require_composer = __commonJS((exports) => {
19488
19554
  this.onError = (source, code, message, warning) => {
19489
19555
  const pos = getErrorPos(source);
19490
19556
  if (warning)
19491
- this.warnings.push(new errors3.YAMLWarning(pos, code, message));
19557
+ this.warnings.push(new errors4.YAMLWarning(pos, code, message));
19492
19558
  else
19493
- this.errors.push(new errors3.YAMLParseError(pos, code, message));
19559
+ this.errors.push(new errors4.YAMLParseError(pos, code, message));
19494
19560
  };
19495
19561
  this.directives = new directives.Directives({ version: options.version || "1.2" });
19496
19562
  this.options = options;
@@ -19576,7 +19642,7 @@ ${cb}` : comment;
19576
19642
  break;
19577
19643
  case "error": {
19578
19644
  const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message;
19579
- const error51 = new errors3.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
19645
+ const error51 = new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
19580
19646
  if (this.atDirectives || !this.doc)
19581
19647
  this.errors.push(error51);
19582
19648
  else
@@ -19586,7 +19652,7 @@ ${cb}` : comment;
19586
19652
  case "doc-end": {
19587
19653
  if (!this.doc) {
19588
19654
  const msg = "Unexpected doc-end without preceding document";
19589
- this.errors.push(new errors3.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg));
19655
+ this.errors.push(new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg));
19590
19656
  break;
19591
19657
  }
19592
19658
  this.doc.directives.docEnd = true;
@@ -19601,7 +19667,7 @@ ${end.comment}` : end.comment;
19601
19667
  break;
19602
19668
  }
19603
19669
  default:
19604
- this.errors.push(new errors3.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
19670
+ this.errors.push(new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
19605
19671
  }
19606
19672
  }
19607
19673
  *end(forceDoc = false, endOffset = -1) {
@@ -19627,7 +19693,7 @@ ${end.comment}` : end.comment;
19627
19693
  var require_cst_scalar = __commonJS((exports) => {
19628
19694
  var resolveBlockScalar = require_resolve_block_scalar();
19629
19695
  var resolveFlowScalar = require_resolve_flow_scalar();
19630
- var errors3 = require_errors();
19696
+ var errors4 = require_errors();
19631
19697
  var stringifyString = require_stringifyString();
19632
19698
  function resolveAsScalar(token, strict = true, onError) {
19633
19699
  if (token) {
@@ -19636,7 +19702,7 @@ var require_cst_scalar = __commonJS((exports) => {
19636
19702
  if (onError)
19637
19703
  onError(offset, code, message);
19638
19704
  else
19639
- throw new errors3.YAMLParseError([offset, offset + 1], code, message);
19705
+ throw new errors4.YAMLParseError([offset, offset + 1], code, message);
19640
19706
  };
19641
19707
  switch (token.type) {
19642
19708
  case "scalar":
@@ -21516,7 +21582,7 @@ var require_parser = __commonJS((exports) => {
21516
21582
  var require_public_api = __commonJS((exports) => {
21517
21583
  var composer = require_composer();
21518
21584
  var Document = require_Document();
21519
- var errors3 = require_errors();
21585
+ var errors4 = require_errors();
21520
21586
  var log = require_log();
21521
21587
  var identity = require_identity();
21522
21588
  var lineCounter = require_line_counter();
@@ -21533,8 +21599,8 @@ var require_public_api = __commonJS((exports) => {
21533
21599
  const docs = Array.from(composer$1.compose(parser$1.parse(source)));
21534
21600
  if (prettyErrors && lineCounter2)
21535
21601
  for (const doc2 of docs) {
21536
- doc2.errors.forEach(errors3.prettifyError(source, lineCounter2));
21537
- doc2.warnings.forEach(errors3.prettifyError(source, lineCounter2));
21602
+ doc2.errors.forEach(errors4.prettifyError(source, lineCounter2));
21603
+ doc2.warnings.forEach(errors4.prettifyError(source, lineCounter2));
21538
21604
  }
21539
21605
  if (docs.length > 0)
21540
21606
  return docs;
@@ -21549,13 +21615,13 @@ var require_public_api = __commonJS((exports) => {
21549
21615
  if (!doc2)
21550
21616
  doc2 = _doc;
21551
21617
  else if (doc2.options.logLevel !== "silent") {
21552
- doc2.errors.push(new errors3.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
21618
+ doc2.errors.push(new errors4.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
21553
21619
  break;
21554
21620
  }
21555
21621
  }
21556
21622
  if (prettyErrors && lineCounter2) {
21557
- doc2.errors.forEach(errors3.prettifyError(source, lineCounter2));
21558
- doc2.warnings.forEach(errors3.prettifyError(source, lineCounter2));
21623
+ doc2.errors.forEach(errors4.prettifyError(source, lineCounter2));
21624
+ doc2.warnings.forEach(errors4.prettifyError(source, lineCounter2));
21559
21625
  }
21560
21626
  return doc2;
21561
21627
  }
@@ -21607,12 +21673,12 @@ var require_public_api = __commonJS((exports) => {
21607
21673
  });
21608
21674
 
21609
21675
  // ../../node_modules/.bun/yaml@2.9.0/node_modules/yaml/dist/index.js
21610
- var composer, Document, Schema, errors3, Alias, identity, Pair, Scalar, YAMLMap, YAMLSeq, cst, lexer, lineCounter, parser, publicApi, visit, $Composer, $Document, $Schema, $YAMLError, $YAMLParseError, $YAMLWarning, $Alias, $isAlias, $isCollection, $isDocument, $isMap, $isNode, $isPair, $isScalar, $isSeq, $Pair, $Scalar, $YAMLMap, $YAMLSeq, $Lexer, $LineCounter, $Parser, $parse, $parseAllDocuments, $parseDocument, $stringify, $visit, $visitAsync;
21611
- var init_dist = __esm(() => {
21676
+ var composer, Document, Schema, errors4, Alias, identity, Pair, Scalar, YAMLMap, YAMLSeq, cst, lexer, lineCounter, parser, publicApi, visit, $Composer, $Document, $Schema, $YAMLError, $YAMLParseError, $YAMLWarning, $Alias, $isAlias, $isCollection, $isDocument, $isMap, $isNode, $isPair, $isScalar, $isSeq, $Pair, $Scalar, $YAMLMap, $YAMLSeq, $Lexer, $LineCounter, $Parser, $parse, $parseAllDocuments, $parseDocument, $stringify, $visit, $visitAsync;
21677
+ var init_dist2 = __esm(() => {
21612
21678
  composer = require_composer();
21613
21679
  Document = require_Document();
21614
21680
  Schema = require_Schema();
21615
- errors3 = require_errors();
21681
+ errors4 = require_errors();
21616
21682
  Alias = require_Alias();
21617
21683
  identity = require_identity();
21618
21684
  Pair = require_Pair();
@@ -21628,9 +21694,9 @@ var init_dist = __esm(() => {
21628
21694
  $Composer = composer.Composer;
21629
21695
  $Document = Document.Document;
21630
21696
  $Schema = Schema.Schema;
21631
- $YAMLError = errors3.YAMLError;
21632
- $YAMLParseError = errors3.YAMLParseError;
21633
- $YAMLWarning = errors3.YAMLWarning;
21697
+ $YAMLError = errors4.YAMLError;
21698
+ $YAMLParseError = errors4.YAMLParseError;
21699
+ $YAMLWarning = errors4.YAMLWarning;
21634
21700
  $Alias = Alias.Alias;
21635
21701
  $isAlias = identity.isAlias;
21636
21702
  $isCollection = identity.isCollection;
@@ -21655,10 +21721,10 @@ var init_dist = __esm(() => {
21655
21721
  $visitAsync = visit.visitAsync;
21656
21722
  });
21657
21723
 
21658
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.39/node_modules/@gobing-ai/ts-runtime/dist/config.js
21724
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.11/node_modules/@gobing-ai/ts-runtime/dist/config.js
21659
21725
  var configSchema;
21660
21726
  var init_config = __esm(() => {
21661
- init_dist();
21727
+ init_dist2();
21662
21728
  init_zod();
21663
21729
  configSchema = exports_external.object({
21664
21730
  app: exports_external.object({
@@ -21679,7 +21745,7 @@ var init_config = __esm(() => {
21679
21745
  });
21680
21746
  });
21681
21747
 
21682
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.39/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21748
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.11/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21683
21749
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21684
21750
  import { dirname, resolve as resolvePath } from "path";
21685
21751
  function createNodeFileSystem(root, paths) {
@@ -21771,7 +21837,6 @@ var exports_src = {};
21771
21837
  __export(exports_src, {
21772
21838
  trySelectors: () => trySelectors,
21773
21839
  resolveBrowserProfileDir: () => resolveBrowserProfileDir,
21774
- launchPersistentBrowser: () => launchPersistentBrowser,
21775
21840
  FakeFileCliTransport: () => FakeFileCliTransport,
21776
21841
  FakeBrowserTransport: () => FakeBrowserTransport
21777
21842
  });
@@ -21881,22 +21946,6 @@ async function trySelectors(page, selectors, options = {}) {
21881
21946
  }
21882
21947
  return { found: false, selector: null };
21883
21948
  }
21884
- async function launchPersistentBrowser(opts) {
21885
- let chromium;
21886
- try {
21887
- const playwright = await import("playwright");
21888
- chromium = playwright.chromium;
21889
- } catch (error51) {
21890
- const reason = error51 instanceof Error ? error51.message : String(error51);
21891
- throw new Error(`launchPersistentBrowser requires the playwright package on the caller's dependency tree: ${reason}`);
21892
- }
21893
- if (typeof chromium?.launchPersistentContext !== "function") {
21894
- throw new Error("launchPersistentBrowser requires the playwright package on the caller's dependency tree: chromium.launchPersistentContext is missing");
21895
- }
21896
- return chromium.launchPersistentContext(opts.profileDir, {
21897
- headless: opts.headless ?? false
21898
- });
21899
- }
21900
21949
  var init_src = () => {};
21901
21950
 
21902
21951
  // ../../plugins/publishings/surfdash-pub/src/index.ts
@@ -21992,31 +22041,14 @@ var PluginManifestSchema = exports_external.looseObject({
21992
22041
  description: exports_external.string().optional(),
21993
22042
  operations: exports_external.record(exports_external.string(), PluginOperationSchema).optional()
21994
22043
  });
21995
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.39/node_modules/@gobing-ai/ts-runtime/dist/index.js
22044
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.11/node_modules/@gobing-ai/ts-runtime/dist/index.js
21996
22045
  init_file_system_node();
21997
22046
  init_config();
21998
22047
 
21999
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.67/node_modules/@gobing-ai/ts-utils/dist/output.js
22000
- var defaultStderrTarget;
22001
- function processStream(name) {
22002
- const proc = globalThis.process;
22003
- const stream = proc?.[name];
22004
- if (stream === undefined) {
22005
- throw new Error(`No ${name} target available: set one via setDefaultOutputTargets or pass an explicit target`);
22006
- }
22007
- return stream;
22008
- }
22009
- function writeLine(message, target) {
22010
- target.write(`${message}
22011
- `);
22012
- }
22013
- function echoError(message, target = defaultStderrTarget ?? processStream("stderr")) {
22014
- writeLine(message, target);
22015
- }
22016
-
22017
22048
  // ../../packages/kk-core/src/render-md.ts
22018
22049
  if (false) {}
22019
22050
  // ../../plugins/publishings/surfdash-pub/src/index.ts
22051
+ init_dist();
22020
22052
  var TARGET = "surfdash";
22021
22053
  var OPERATIONS = ["publish", "scaffold-locale", "sync"];
22022
22054
  var SCAFFOLD_LOCALES = ["en", "ja"];
@@ -22283,6 +22315,9 @@ async function publishPost(payload) {
22283
22315
  return fail("SURFDASH_ROOT is required when POSTSURFING_BIN is not a path inside the surfdash checkout");
22284
22316
  }
22285
22317
  const locale = process.env.SURFDASH_LOCALE ?? "zh";
22318
+ if (!["zh", "en", "ja"].includes(locale)) {
22319
+ return fail(`SURFDASH_LOCALE must be one of zh/en/ja, got '${locale}'`);
22320
+ }
22286
22321
  const runDate = typeof payload.content.metadata?.runDate === "string" ? payload.content.metadata.runDate : "";
22287
22322
  const today = new Date().toISOString().slice(0, 10).replaceAll("-", "");
22288
22323
  const dateStamp = runDate || today;
@@ -22321,7 +22356,8 @@ async function publishPost(payload) {
22321
22356
  if (spawned.exitCode !== 0) {
22322
22357
  return fail(`postsurfing CLI failed (exit ${spawned.exitCode}): ${withEmdashTokenHint(cliErrorText(spawned))}`);
22323
22358
  }
22324
- const articleUrl = `${(process.env.SURFDASH_URL ?? "https://surfing.salty.vip").replace(/\/$/, "")}/${locale}/posts/${slug}`;
22359
+ const baseUrl = (process.env.SURFDASH_URL ?? "https://surfing.salty.vip").replace(/\/$/, "");
22360
+ const articleUrl = `${baseUrl}${locale === "en" ? "" : `/${locale}`}/posts/${slug}`;
22325
22361
  if (process.env.SURFDASH_AUTO_PUSH === "0") {
22326
22362
  return ResultSchema.parse({
22327
22363
  ok: true,
@@ -449,6 +449,11 @@ async function publishPost(payload: PublishTransportPayload): Promise<Result> {
449
449
  }
450
450
 
451
451
  const locale = process.env.SURFDASH_LOCALE ?? 'zh';
452
+ // Fail loud on legacy locale codes ('cn' is the pre-migration name for zh) —
453
+ // they'd write a content dir no route serves.
454
+ if (!['zh', 'en', 'ja'].includes(locale)) {
455
+ return fail(`SURFDASH_LOCALE must be one of zh/en/ja, got '${locale}'`);
456
+ }
452
457
  // Date-stamped slug (metadata.runDate, e.g. 20260904) keeps same-title daily posts
453
458
  // from colliding; Chinese titles slugify to '' and fall back to the bare date.
454
459
  const runDate = typeof payload.content.metadata?.runDate === 'string' ? payload.content.metadata.runDate : '';
@@ -504,7 +509,11 @@ async function publishPost(payload: PublishTransportPayload): Promise<Result> {
504
509
  // Deploy seam: commit + push the post so deploy.yml builds it, then wait for
505
510
  // the live URL — downstream show-notes advertise a real page, not a 404.
506
511
  // Tests (and offline runs) opt out via SURFDASH_AUTO_PUSH=0.
507
- const articleUrl = `${(process.env.SURFDASH_URL ?? 'https://surfing.salty.vip').replace(/\/$/, '')}/${locale}/posts/${slug}`;
512
+ // URL shape mirrors surfdash's localePathPrefix (surfdash/src/lib/seo.ts):
513
+ // en is served at the site root, zh/ja carry a /<locale> prefix. Composing
514
+ // /<locale>/posts/<slug> unconditionally 404s en posts.
515
+ const baseUrl = (process.env.SURFDASH_URL ?? 'https://surfing.salty.vip').replace(/\/$/, '');
516
+ const articleUrl = `${baseUrl}${locale === 'en' ? '' : `/${locale}`}/posts/${slug}`;
508
517
  if (process.env.SURFDASH_AUTO_PUSH === '0') {
509
518
  return ResultSchema.parse({
510
519
  ok: true,
@@ -14642,6 +14642,72 @@ var init_zod = __esm(() => {
14642
14642
  init_external();
14643
14643
  });
14644
14644
 
14645
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/errors.js
14646
+ var ErrorCode;
14647
+ var init_errors3 = __esm(() => {
14648
+ ErrorCode = {
14649
+ NotFound: "NOT_FOUND",
14650
+ Validation: "VALIDATION",
14651
+ Conflict: "CONFLICT",
14652
+ Internal: "INTERNAL"
14653
+ };
14654
+ });
14655
+
14656
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14657
+ var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
14658
+ var init_api_response = __esm(() => {
14659
+ init_errors3();
14660
+ API_ERROR_CODES = {
14661
+ SUCCESS: 0,
14662
+ NOT_FOUND: 404,
14663
+ VALIDATION_ERROR: 422,
14664
+ BAD_REQUEST: 400,
14665
+ UNAUTHORIZED: 401,
14666
+ FORBIDDEN: 403,
14667
+ CONFLICT: 409,
14668
+ INTERNAL_ERROR: 500
14669
+ };
14670
+ ERROR_CODE_TO_HTTP = {
14671
+ [ErrorCode.NotFound]: API_ERROR_CODES.NOT_FOUND,
14672
+ [ErrorCode.Validation]: API_ERROR_CODES.VALIDATION_ERROR,
14673
+ [ErrorCode.Conflict]: API_ERROR_CODES.CONFLICT,
14674
+ [ErrorCode.Internal]: API_ERROR_CODES.INTERNAL_ERROR
14675
+ };
14676
+ CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
14677
+ });
14678
+
14679
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14680
+ var init_cursor = () => {};
14681
+
14682
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14683
+ var init_event_severity = () => {};
14684
+
14685
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/output.js
14686
+ function processStream(name) {
14687
+ const proc = globalThis.process;
14688
+ const stream = proc?.[name];
14689
+ if (stream === undefined) {
14690
+ throw new Error(`No ${name} target available: set one via setDefaultOutputTargets or pass an explicit target`);
14691
+ }
14692
+ return stream;
14693
+ }
14694
+ function writeLine(message, target) {
14695
+ target.write(`${message}
14696
+ `);
14697
+ }
14698
+ function echoError(message, target = defaultStderrTarget ?? processStream("stderr")) {
14699
+ writeLine(message, target);
14700
+ }
14701
+ var defaultStderrTarget;
14702
+
14703
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.11/node_modules/@gobing-ai/ts-utils/dist/index.js
14704
+ var init_dist = __esm(() => {
14705
+ init_api_response();
14706
+ init_cursor();
14707
+ init_errors3();
14708
+ init_event_severity();
14709
+ });
14710
+
14645
14711
  // ../../node_modules/.bun/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
14646
14712
  var require_identity = __commonJS((exports) => {
14647
14713
  var ALIAS = Symbol.for("yaml.alias");
@@ -17546,15 +17612,15 @@ var require_timestamp = __commonJS((exports) => {
17546
17612
  throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
17547
17613
  const [, year, month, day, hour, minute, second] = match.map(Number);
17548
17614
  const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
17549
- let date5 = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
17615
+ let date6 = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
17550
17616
  const tz = match[8];
17551
17617
  if (tz && tz !== "Z") {
17552
17618
  let d = parseSexagesimal(tz, false);
17553
17619
  if (Math.abs(d) < 30)
17554
17620
  d *= 60;
17555
- date5 -= 60000 * d;
17621
+ date6 -= 60000 * d;
17556
17622
  }
17557
- return new Date(date5);
17623
+ return new Date(date6);
17558
17624
  },
17559
17625
  stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
17560
17626
  };
@@ -19414,7 +19480,7 @@ var require_composer = __commonJS((exports) => {
19414
19480
  var node_process = __require("process");
19415
19481
  var directives = require_directives();
19416
19482
  var Document = require_Document();
19417
- var errors3 = require_errors();
19483
+ var errors4 = require_errors();
19418
19484
  var identity = require_identity();
19419
19485
  var composeDoc = require_compose_doc();
19420
19486
  var resolveEnd = require_resolve_end();
@@ -19465,9 +19531,9 @@ var require_composer = __commonJS((exports) => {
19465
19531
  this.onError = (source, code, message, warning) => {
19466
19532
  const pos = getErrorPos(source);
19467
19533
  if (warning)
19468
- this.warnings.push(new errors3.YAMLWarning(pos, code, message));
19534
+ this.warnings.push(new errors4.YAMLWarning(pos, code, message));
19469
19535
  else
19470
- this.errors.push(new errors3.YAMLParseError(pos, code, message));
19536
+ this.errors.push(new errors4.YAMLParseError(pos, code, message));
19471
19537
  };
19472
19538
  this.directives = new directives.Directives({ version: options.version || "1.2" });
19473
19539
  this.options = options;
@@ -19553,7 +19619,7 @@ ${cb}` : comment;
19553
19619
  break;
19554
19620
  case "error": {
19555
19621
  const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message;
19556
- const error51 = new errors3.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
19622
+ const error51 = new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
19557
19623
  if (this.atDirectives || !this.doc)
19558
19624
  this.errors.push(error51);
19559
19625
  else
@@ -19563,7 +19629,7 @@ ${cb}` : comment;
19563
19629
  case "doc-end": {
19564
19630
  if (!this.doc) {
19565
19631
  const msg = "Unexpected doc-end without preceding document";
19566
- this.errors.push(new errors3.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg));
19632
+ this.errors.push(new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg));
19567
19633
  break;
19568
19634
  }
19569
19635
  this.doc.directives.docEnd = true;
@@ -19578,7 +19644,7 @@ ${end.comment}` : end.comment;
19578
19644
  break;
19579
19645
  }
19580
19646
  default:
19581
- this.errors.push(new errors3.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
19647
+ this.errors.push(new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
19582
19648
  }
19583
19649
  }
19584
19650
  *end(forceDoc = false, endOffset = -1) {
@@ -19604,7 +19670,7 @@ ${end.comment}` : end.comment;
19604
19670
  var require_cst_scalar = __commonJS((exports) => {
19605
19671
  var resolveBlockScalar = require_resolve_block_scalar();
19606
19672
  var resolveFlowScalar = require_resolve_flow_scalar();
19607
- var errors3 = require_errors();
19673
+ var errors4 = require_errors();
19608
19674
  var stringifyString = require_stringifyString();
19609
19675
  function resolveAsScalar(token, strict = true, onError) {
19610
19676
  if (token) {
@@ -19613,7 +19679,7 @@ var require_cst_scalar = __commonJS((exports) => {
19613
19679
  if (onError)
19614
19680
  onError(offset, code, message);
19615
19681
  else
19616
- throw new errors3.YAMLParseError([offset, offset + 1], code, message);
19682
+ throw new errors4.YAMLParseError([offset, offset + 1], code, message);
19617
19683
  };
19618
19684
  switch (token.type) {
19619
19685
  case "scalar":
@@ -21493,7 +21559,7 @@ var require_parser = __commonJS((exports) => {
21493
21559
  var require_public_api = __commonJS((exports) => {
21494
21560
  var composer = require_composer();
21495
21561
  var Document = require_Document();
21496
- var errors3 = require_errors();
21562
+ var errors4 = require_errors();
21497
21563
  var log = require_log();
21498
21564
  var identity = require_identity();
21499
21565
  var lineCounter = require_line_counter();
@@ -21510,8 +21576,8 @@ var require_public_api = __commonJS((exports) => {
21510
21576
  const docs = Array.from(composer$1.compose(parser$1.parse(source)));
21511
21577
  if (prettyErrors && lineCounter2)
21512
21578
  for (const doc2 of docs) {
21513
- doc2.errors.forEach(errors3.prettifyError(source, lineCounter2));
21514
- doc2.warnings.forEach(errors3.prettifyError(source, lineCounter2));
21579
+ doc2.errors.forEach(errors4.prettifyError(source, lineCounter2));
21580
+ doc2.warnings.forEach(errors4.prettifyError(source, lineCounter2));
21515
21581
  }
21516
21582
  if (docs.length > 0)
21517
21583
  return docs;
@@ -21526,13 +21592,13 @@ var require_public_api = __commonJS((exports) => {
21526
21592
  if (!doc2)
21527
21593
  doc2 = _doc;
21528
21594
  else if (doc2.options.logLevel !== "silent") {
21529
- doc2.errors.push(new errors3.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
21595
+ doc2.errors.push(new errors4.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
21530
21596
  break;
21531
21597
  }
21532
21598
  }
21533
21599
  if (prettyErrors && lineCounter2) {
21534
- doc2.errors.forEach(errors3.prettifyError(source, lineCounter2));
21535
- doc2.warnings.forEach(errors3.prettifyError(source, lineCounter2));
21600
+ doc2.errors.forEach(errors4.prettifyError(source, lineCounter2));
21601
+ doc2.warnings.forEach(errors4.prettifyError(source, lineCounter2));
21536
21602
  }
21537
21603
  return doc2;
21538
21604
  }
@@ -21584,12 +21650,12 @@ var require_public_api = __commonJS((exports) => {
21584
21650
  });
21585
21651
 
21586
21652
  // ../../node_modules/.bun/yaml@2.9.0/node_modules/yaml/dist/index.js
21587
- var composer, Document, Schema, errors3, Alias, identity, Pair, Scalar, YAMLMap, YAMLSeq, cst, lexer, lineCounter, parser, publicApi, visit, $Composer, $Document, $Schema, $YAMLError, $YAMLParseError, $YAMLWarning, $Alias, $isAlias, $isCollection, $isDocument, $isMap, $isNode, $isPair, $isScalar, $isSeq, $Pair, $Scalar, $YAMLMap, $YAMLSeq, $Lexer, $LineCounter, $Parser, $parse, $parseAllDocuments, $parseDocument, $stringify, $visit, $visitAsync;
21588
- var init_dist = __esm(() => {
21653
+ var composer, Document, Schema, errors4, Alias, identity, Pair, Scalar, YAMLMap, YAMLSeq, cst, lexer, lineCounter, parser, publicApi, visit, $Composer, $Document, $Schema, $YAMLError, $YAMLParseError, $YAMLWarning, $Alias, $isAlias, $isCollection, $isDocument, $isMap, $isNode, $isPair, $isScalar, $isSeq, $Pair, $Scalar, $YAMLMap, $YAMLSeq, $Lexer, $LineCounter, $Parser, $parse, $parseAllDocuments, $parseDocument, $stringify, $visit, $visitAsync;
21654
+ var init_dist2 = __esm(() => {
21589
21655
  composer = require_composer();
21590
21656
  Document = require_Document();
21591
21657
  Schema = require_Schema();
21592
- errors3 = require_errors();
21658
+ errors4 = require_errors();
21593
21659
  Alias = require_Alias();
21594
21660
  identity = require_identity();
21595
21661
  Pair = require_Pair();
@@ -21605,9 +21671,9 @@ var init_dist = __esm(() => {
21605
21671
  $Composer = composer.Composer;
21606
21672
  $Document = Document.Document;
21607
21673
  $Schema = Schema.Schema;
21608
- $YAMLError = errors3.YAMLError;
21609
- $YAMLParseError = errors3.YAMLParseError;
21610
- $YAMLWarning = errors3.YAMLWarning;
21674
+ $YAMLError = errors4.YAMLError;
21675
+ $YAMLParseError = errors4.YAMLParseError;
21676
+ $YAMLWarning = errors4.YAMLWarning;
21611
21677
  $Alias = Alias.Alias;
21612
21678
  $isAlias = identity.isAlias;
21613
21679
  $isCollection = identity.isCollection;
@@ -21632,10 +21698,10 @@ var init_dist = __esm(() => {
21632
21698
  $visitAsync = visit.visitAsync;
21633
21699
  });
21634
21700
 
21635
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.39/node_modules/@gobing-ai/ts-runtime/dist/config.js
21701
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.11/node_modules/@gobing-ai/ts-runtime/dist/config.js
21636
21702
  var configSchema;
21637
21703
  var init_config = __esm(() => {
21638
- init_dist();
21704
+ init_dist2();
21639
21705
  init_zod();
21640
21706
  configSchema = exports_external.object({
21641
21707
  app: exports_external.object({
@@ -21656,7 +21722,7 @@ var init_config = __esm(() => {
21656
21722
  });
21657
21723
  });
21658
21724
 
21659
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.39/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21725
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.11/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21660
21726
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21661
21727
  import { dirname, resolve as resolvePath } from "path";
21662
21728
  function createNodeFileSystem(root, paths) {
@@ -21834,28 +21900,10 @@ var PluginManifestSchema = exports_external.looseObject({
21834
21900
  description: exports_external.string().optional(),
21835
21901
  operations: exports_external.record(exports_external.string(), PluginOperationSchema).optional()
21836
21902
  });
21837
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.39/node_modules/@gobing-ai/ts-runtime/dist/index.js
21903
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.11/node_modules/@gobing-ai/ts-runtime/dist/index.js
21838
21904
  init_file_system_node();
21839
21905
  init_config();
21840
21906
 
21841
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.67/node_modules/@gobing-ai/ts-utils/dist/output.js
21842
- var defaultStderrTarget;
21843
- function processStream(name) {
21844
- const proc = globalThis.process;
21845
- const stream = proc?.[name];
21846
- if (stream === undefined) {
21847
- throw new Error(`No ${name} target available: set one via setDefaultOutputTargets or pass an explicit target`);
21848
- }
21849
- return stream;
21850
- }
21851
- function writeLine(message, target) {
21852
- target.write(`${message}
21853
- `);
21854
- }
21855
- function echoError(message, target = defaultStderrTarget ?? processStream("stderr")) {
21856
- writeLine(message, target);
21857
- }
21858
-
21859
21907
  // ../../packages/kk-core/src/render-md.ts
21860
21908
  if (false) {}
21861
21909
  // ../../packages/publish-harness/src/index.ts
@@ -21933,6 +21981,7 @@ class FakeBrowserTransport {
21933
21981
  }
21934
21982
 
21935
21983
  // ../../plugins/publishings/wechatmp-pub/src/index.ts
21984
+ init_dist();
21936
21985
  var TARGET = "wechatmp";
21937
21986
  var TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token";
21938
21987
  var REQUEST_TIMEOUT_MS = 120000;