@gobing-ai/knowledge-kit 0.0.32 → 0.0.33

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 (65) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +32320 -15021
  3. package/package.json +4 -4
  4. package/plugins/generations/content-gen/dist/index.js +10 -9
  5. package/plugins/generations/core-facts-gen/dist/index.js +13 -12
  6. package/plugins/generations/daily-article-gen/dist/index.js +14 -13
  7. package/plugins/generations/daily-article-gen/src/index.ts +1 -1
  8. package/plugins/generations/dailynews-gen/dist/index.js +10 -9
  9. package/plugins/generations/episode-plan-gen/dist/index.js +58 -15
  10. package/plugins/generations/episode-plan-gen/src/index.ts +76 -6
  11. package/plugins/generations/gemini-tts/README.md +11 -0
  12. package/plugins/generations/gemini-tts/dist/index.js +10 -9
  13. package/plugins/generations/image-gen/dist/index.js +154 -151
  14. package/plugins/generations/image-gen/src/compose/chromium.ts +60 -42
  15. package/plugins/generations/news-report-gen/dist/index.js +13 -12
  16. package/plugins/generations/voice-gen/dist/index.js +10 -9
  17. package/plugins/ingestions/aihot-ingest/dist/index.js +13 -12
  18. package/plugins/ingestions/horizon-ingest/dist/index.js +13 -12
  19. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  20. package/plugins/ingestions/last30days-ingest/dist/index.js +13 -12
  21. package/plugins/ingestions/web-search/dist/index.js +11 -10
  22. package/plugins/kk/README.md +38 -0
  23. package/plugins/kk/decisions/extract/ai-news.yaml +21 -0
  24. package/plugins/kk/decisions/kk-items.yaml +113 -0
  25. package/plugins/kk/plugin.json +1 -1
  26. package/plugins/kk/schedules/cron.tmpl +15 -0
  27. package/plugins/kk/schedules/launchd.plist.tmpl +77 -0
  28. package/plugins/kk/scripts/daily-stages.ts +1533 -0
  29. package/plugins/kk/scripts/kk-workflow-stages.ts +247 -1365
  30. package/plugins/kk/skills/content-safety/SKILL.md +38 -7
  31. package/plugins/kk/skills/web-automation/SKILL.md +100 -0
  32. package/plugins/kk/skills/web-automation/references/browser-launch.md +86 -0
  33. package/plugins/kk/workflows/kk-collect.yaml +258 -0
  34. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +9 -3
  35. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +655 -0
  36. package/plugins/kk/workflows/kk-daily-safety.yaml +170 -0
  37. package/plugins/publishings/emdash-pub/dist/index.js +10 -9
  38. package/plugins/publishings/infoq-pub/dist/index.js +152 -59
  39. package/plugins/publishings/infoq-pub/plugin.json +1 -0
  40. package/plugins/publishings/infoq-pub/src/index.ts +167 -55
  41. package/plugins/publishings/infoq-pub/src/profile-check.ts +4 -2
  42. package/plugins/publishings/juejin-pub/dist/index.js +111 -30
  43. package/plugins/publishings/juejin-pub/plugin.json +1 -0
  44. package/plugins/publishings/juejin-pub/src/index.ts +49 -9
  45. package/plugins/publishings/medium-pub/dist/index.js +10 -9
  46. package/plugins/publishings/podcast-pub/dist/index.js +10 -9
  47. package/plugins/publishings/qiita-pub/dist/index.js +10 -9
  48. package/plugins/publishings/substack-pub/dist/index.js +105 -28
  49. package/plugins/publishings/substack-pub/plugin.json +1 -0
  50. package/plugins/publishings/substack-pub/src/index.ts +39 -8
  51. package/plugins/publishings/substack-pub/src/profile-check.ts +2 -0
  52. package/plugins/publishings/surfdash-pub/dist/index.js +10 -9
  53. package/plugins/publishings/wechatmp-pub/dist/index.js +115 -31
  54. package/plugins/publishings/wechatmp-pub/plugin.json +1 -0
  55. package/plugins/publishings/wechatmp-pub/src/index.ts +42 -9
  56. package/plugins/publishings/wechatmp-pub/src/profile-check.ts +84 -40
  57. package/plugins/publishings/x-pub/dist/index.js +114 -35
  58. package/plugins/publishings/x-pub/plugin.json +1 -0
  59. package/plugins/publishings/x-pub/src/index.ts +68 -14
  60. package/plugins/publishings/xhs-pub/dist/index.js +100 -54
  61. package/plugins/publishings/xhs-pub/plugin.json +1 -0
  62. package/plugins/publishings/xhs-pub/src/index.ts +8 -4
  63. package/plugins/publishings/xhs-pub/src/page.ts +4 -17
  64. package/plugins/publishings/xhs-pub/src/profile-check.ts +28 -15
  65. package/plugins/publishings/zenn-pub/dist/index.js +10 -9
@@ -14642,7 +14642,7 @@ var init_zod = __esm(() => {
14642
14642
  init_external();
14643
14643
  });
14644
14644
 
14645
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/errors.js
14645
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/errors.js
14646
14646
  var ErrorCode;
14647
14647
  var init_errors3 = __esm(() => {
14648
14648
  ErrorCode = {
@@ -14653,7 +14653,7 @@ var init_errors3 = __esm(() => {
14653
14653
  };
14654
14654
  });
14655
14655
 
14656
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14656
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14657
14657
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
14658
14658
  var init_api_response = __esm(() => {
14659
14659
  init_errors3();
@@ -14676,13 +14676,13 @@ var init_api_response = __esm(() => {
14676
14676
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
14677
14677
  });
14678
14678
 
14679
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14679
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14680
14680
  var init_cursor = () => {};
14681
14681
 
14682
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14682
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14683
14683
  var init_event_severity = () => {};
14684
14684
 
14685
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/output.js
14685
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/output.js
14686
14686
  function processStream(name) {
14687
14687
  const proc = globalThis.process;
14688
14688
  const stream = proc?.[name];
@@ -14700,7 +14700,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
14700
14700
  }
14701
14701
  var defaultStderrTarget;
14702
14702
 
14703
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/index.js
14703
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/index.js
14704
14704
  var init_dist = __esm(() => {
14705
14705
  init_api_response();
14706
14706
  init_cursor();
@@ -21698,7 +21698,7 @@ var init_dist2 = __esm(() => {
21698
21698
  $visitAsync = visit.visitAsync;
21699
21699
  });
21700
21700
 
21701
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/config.js
21701
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/config.js
21702
21702
  var configSchema;
21703
21703
  var init_config = __esm(() => {
21704
21704
  init_dist2();
@@ -21722,7 +21722,7 @@ var init_config = __esm(() => {
21722
21722
  });
21723
21723
  });
21724
21724
 
21725
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21725
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21726
21726
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21727
21727
  import { dirname, resolve as resolvePath } from "path";
21728
21728
  function createNodeFileSystem(root, paths) {
@@ -21896,11 +21896,12 @@ var PluginManifestSchema = exports_external.looseObject({
21896
21896
  name: exports_external.string().min(1),
21897
21897
  kind: PluginKindSchema,
21898
21898
  entry: exports_external.string().min(1),
21899
+ check: exports_external.string().min(1).optional(),
21899
21900
  version: exports_external.string().optional(),
21900
21901
  description: exports_external.string().optional(),
21901
21902
  operations: exports_external.record(exports_external.string(), PluginOperationSchema).optional()
21902
21903
  });
21903
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/index.js
21904
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/index.js
21904
21905
  init_file_system_node();
21905
21906
  init_config();
21906
21907
 
@@ -14671,7 +14671,7 @@ var init_zod = __esm(() => {
14671
14671
  init_external();
14672
14672
  });
14673
14673
 
14674
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/errors.js
14674
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/errors.js
14675
14675
  var ErrorCode;
14676
14676
  var init_errors3 = __esm(() => {
14677
14677
  ErrorCode = {
@@ -14682,7 +14682,7 @@ var init_errors3 = __esm(() => {
14682
14682
  };
14683
14683
  });
14684
14684
 
14685
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14685
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14686
14686
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
14687
14687
  var init_api_response = __esm(() => {
14688
14688
  init_errors3();
@@ -14705,10 +14705,10 @@ var init_api_response = __esm(() => {
14705
14705
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
14706
14706
  });
14707
14707
 
14708
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14708
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14709
14709
  var init_cursor = () => {};
14710
14710
 
14711
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/env.js
14711
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/env.js
14712
14712
  function getEnvVar(name, fallback) {
14713
14713
  const raw = process.env[name];
14714
14714
  return raw === undefined ? fallback : raw;
@@ -14717,10 +14717,10 @@ function getEnvVars() {
14717
14717
  return process.env;
14718
14718
  }
14719
14719
 
14720
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14720
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14721
14721
  var init_event_severity = () => {};
14722
14722
 
14723
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/object.js
14723
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/object.js
14724
14724
  function isPlainObject2(value) {
14725
14725
  return typeof value === "object" && value !== null && !Array.isArray(value);
14726
14726
  }
@@ -14738,7 +14738,7 @@ function deepMerge(target, source) {
14738
14738
  return result;
14739
14739
  }
14740
14740
 
14741
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/output.js
14741
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/output.js
14742
14742
  function processStream(name) {
14743
14743
  const proc = globalThis.process;
14744
14744
  const stream = proc?.[name];
@@ -14756,7 +14756,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
14756
14756
  }
14757
14757
  var defaultStderrTarget;
14758
14758
 
14759
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/index.js
14759
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/index.js
14760
14760
  var init_dist = __esm(() => {
14761
14761
  init_api_response();
14762
14762
  init_cursor();
@@ -21754,7 +21754,7 @@ var init_dist2 = __esm(() => {
21754
21754
  $visitAsync = visit.visitAsync;
21755
21755
  });
21756
21756
 
21757
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/config.js
21757
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/config.js
21758
21758
  function getProcessEnv() {
21759
21759
  return getEnvVars();
21760
21760
  }
@@ -21832,7 +21832,7 @@ var init_config = __esm(() => {
21832
21832
  };
21833
21833
  });
21834
21834
 
21835
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21835
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21836
21836
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21837
21837
  import { dirname, resolve as resolvePath } from "path";
21838
21838
  function createNodeFileSystem(root, paths) {
@@ -21919,7 +21919,7 @@ function findProjectRoot(startDir) {
21919
21919
  }
21920
21920
  var init_file_system_node = () => {};
21921
21921
 
21922
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
21922
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
21923
21923
  var DbModuleNotInstalledError;
21924
21924
  var init_db_errors = __esm(() => {
21925
21925
  DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
@@ -29130,7 +29130,7 @@ var init_execa = __esm(() => {
29130
29130
  } = getIpcExport());
29131
29131
  });
29132
29132
 
29133
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
29133
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
29134
29134
  function resolveDeadline(optionTimeout, defaultTimeout) {
29135
29135
  if (optionTimeout === null)
29136
29136
  return null;
@@ -29222,7 +29222,7 @@ function ownProcessGroupLifecycle(ownership) {
29222
29222
  }
29223
29223
  var MAX_TIMEOUT_MS = 2147483647, DEFAULT_KILL_GRACE_MS = 5000, GROUP_POLL_INTERVAL_MS = 25, GROUP_KILL_PATIENCE_MS = 2000;
29224
29224
 
29225
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29225
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29226
29226
  import { isatty } from "tty";
29227
29227
  function processEventSeverity(reason, exitCode) {
29228
29228
  if (reason === "error")
@@ -29594,7 +29594,7 @@ var init_process_executor = __esm(() => {
29594
29594
  init_config();
29595
29595
  });
29596
29596
 
29597
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
29597
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
29598
29598
  function getNodeFileSystem() {
29599
29599
  if (!_nodeFileSystem)
29600
29600
  _nodeFileSystem = createNodeFileSystem();
@@ -29741,15 +29741,16 @@ var PluginManifestSchema = exports_external.looseObject({
29741
29741
  name: exports_external.string().min(1),
29742
29742
  kind: PluginKindSchema,
29743
29743
  entry: exports_external.string().min(1),
29744
+ check: exports_external.string().min(1).optional(),
29744
29745
  version: exports_external.string().optional(),
29745
29746
  description: exports_external.string().optional(),
29746
29747
  operations: exports_external.record(exports_external.string(), PluginOperationSchema).optional()
29747
29748
  });
29748
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/index.js
29749
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/index.js
29749
29750
  init_file_system_node();
29750
29751
  init_config();
29751
29752
 
29752
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/path.js
29753
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/path.js
29753
29754
  function normalizeSeparators(path6) {
29754
29755
  return path6.replaceAll("\\", "/");
29755
29756
  }
@@ -29807,7 +29808,7 @@ function getProcessCwd() {
29807
29808
  return globalThis.process?.cwd?.() ?? "/";
29808
29809
  }
29809
29810
 
29810
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/index.js
29811
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/index.js
29811
29812
  init_runtime_node_bun();
29812
29813
 
29813
29814
  // ../../packages/kk-core/src/render-md.ts
@@ -29920,7 +29921,10 @@ async function trySelectors(page, selectors, options = {}) {
29920
29921
  return { found: false, selector: null };
29921
29922
  }
29922
29923
 
29923
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.15+e28deaf1f2c5a2b1/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
29924
+ // ../../packages/publish-harness/src/browser.ts
29925
+ import { resolve as resolve2 } from "path";
29926
+
29927
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
29924
29928
  class BrowserAutomationError extends Error {
29925
29929
  constructor(message, options) {
29926
29930
  super(message, options);
@@ -29969,10 +29973,10 @@ class OperationAbortedError extends BrowserAutomationError {
29969
29973
  this.name = "OperationAbortedError";
29970
29974
  }
29971
29975
  }
29972
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.15+e28deaf1f2c5a2b1/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29976
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29973
29977
  import { mkdir } from "fs/promises";
29974
29978
 
29975
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.15+e28deaf1f2c5a2b1/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
29979
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
29976
29980
  function resolveProfileDir(profileDir) {
29977
29981
  if (profileDir.trim() === "") {
29978
29982
  throw new InvalidProfileDirError;
@@ -29984,7 +29988,7 @@ function resolveProfileDir(profileDir) {
29984
29988
  return resolved;
29985
29989
  }
29986
29990
 
29987
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.15+e28deaf1f2c5a2b1/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29991
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29988
29992
  var PROFILE_DIR_MODE = 448;
29989
29993
  var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
29990
29994
  var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
@@ -30035,7 +30039,7 @@ function createPersistentLauncher(options = {}) {
30035
30039
  };
30036
30040
  }
30037
30041
 
30038
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.15+e28deaf1f2c5a2b1/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
30042
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
30039
30043
  var DEFAULT_TIMEOUT_MS = 30000;
30040
30044
  var POLL_INTERVAL_MS = 250;
30041
30045
  var defaultLauncher;
@@ -30114,11 +30118,67 @@ async function pollPredicate(page, predicate, timeoutMs, signal) {
30114
30118
  function sleep(ms) {
30115
30119
  return new Promise((resolve2) => setTimeout(resolve2, ms));
30116
30120
  }
30121
+ // ../../packages/publish-harness/src/profile-dir.ts
30122
+ import { mkdir as mkdir2, stat } from "fs/promises";
30123
+ async function ensureProfileDir2(profileDir, headless) {
30124
+ const existing = await stat(profileDir).catch(() => null);
30125
+ if (existing) {
30126
+ if (!existing.isDirectory())
30127
+ throw new InvalidProfileDirError(`profileDir is not a directory: "${profileDir}".`);
30128
+ return;
30129
+ }
30130
+ if (headless)
30131
+ throw new BrowserProfileMissingError(profileDir);
30132
+ await mkdir2(profileDir, { recursive: true, mode: 448 });
30133
+ }
30134
+
30117
30135
  // ../../packages/publish-harness/src/browser.ts
30118
30136
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
30119
30137
  var DEFAULT_STEP_TIMEOUT_MS = 30000;
30120
30138
  var DEFAULT_POLL_MS = 500;
30121
30139
  var ATTACH_POLL_MS = 100;
30140
+ function createKkBrowserLauncher(loadPlaywright = () => import("playwright")) {
30141
+ return {
30142
+ async launch(request) {
30143
+ if (request.profileDir.trim() === "")
30144
+ throw new InvalidProfileDirError;
30145
+ const profileDir = resolve2(request.profileDir);
30146
+ await ensureProfileDir2(profileDir, request.headless);
30147
+ let playwright;
30148
+ try {
30149
+ playwright = await loadPlaywright();
30150
+ } catch (error51) {
30151
+ throw new PlaywrightUnavailableError('The "playwright" dependency is not installed. Run `bunx playwright install chromium`.', { cause: error51 });
30152
+ }
30153
+ const channel = process.env.KK_BROWSER_CHANNEL?.trim() || "chromium";
30154
+ let context2;
30155
+ try {
30156
+ context2 = await playwright.chromium.launchPersistentContext(profileDir, {
30157
+ headless: request.headless,
30158
+ channel,
30159
+ args: ["--disable-blink-features=AutomationControlled"],
30160
+ ignoreDefaultArgs: ["--enable-automation"]
30161
+ });
30162
+ } catch (error51) {
30163
+ const message = errorMessage2(error51);
30164
+ if (/singleton|already in use|in use by another/i.test(message)) {
30165
+ throw new BrowserProfileBusyError(profileDir, error51);
30166
+ }
30167
+ if (/playwright install|executable doesn't exist/i.test(message)) {
30168
+ throw new PlaywrightUnavailableError(`Browser channel '${channel}' is not installed. Run \`bunx playwright install chromium\` (or install Google Chrome for KK_BROWSER_CHANNEL=chrome).`, { cause: error51 });
30169
+ }
30170
+ throw error51;
30171
+ }
30172
+ await context2.addInitScript(() => {
30173
+ Object.defineProperty(navigator, "webdriver", { get: () => {
30174
+ return;
30175
+ } });
30176
+ });
30177
+ return context2;
30178
+ }
30179
+ };
30180
+ }
30181
+ var kkBrowserLauncher = createKkBrowserLauncher();
30122
30182
  function resolveChannelProfileDir(channel, override) {
30123
30183
  const tiers = [override, process.env[`${channel.toUpperCase()}_PROFILE_DIR`], process.env.KK_BROWSER_PROFILE_DIR];
30124
30184
  const chosen = tiers.find((tier) => tier !== undefined && tier.trim().length > 0);
@@ -30126,7 +30186,7 @@ function resolveChannelProfileDir(channel, override) {
30126
30186
  }
30127
30187
  async function checkChannelSession(config3, opts) {
30128
30188
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
30129
- const passes = opts.headedFallback === false ? [true] : [true, false];
30189
+ const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
30130
30190
  let lastDetail = `${config3.channel} readiness was never probed`;
30131
30191
  for (const headless of passes) {
30132
30192
  try {
@@ -30136,12 +30196,12 @@ async function checkChannelSession(config3, opts) {
30136
30196
  url: config3.homeUrl,
30137
30197
  isAuthenticated: config3.isAuthenticated,
30138
30198
  timeoutMs,
30139
- launcher: opts.launcher
30199
+ launcher: opts.launcher ?? kkBrowserLauncher
30140
30200
  }, async () => true);
30141
30201
  return {
30142
30202
  status: "verified",
30143
30203
  profileDir: opts.profileDir,
30144
- detail: `authenticated ${config3.channel} session observed ${headless ? "headlessly" : "via headed fallback"} via profile ${opts.profileDir} (read-only)`
30204
+ detail: `authenticated ${config3.channel} session observed ${headless ? "headlessly" : "via a headed pass"} via profile ${opts.profileDir} (read-only)`
30145
30205
  };
30146
30206
  } catch (error51) {
30147
30207
  if (error51 instanceof BrowserProfileMissingError) {
@@ -30162,7 +30222,7 @@ async function waitUntil(predicate, timeoutMs, pollMs = DEFAULT_POLL_MS) {
30162
30222
  if (await predicate()) {
30163
30223
  return true;
30164
30224
  }
30165
- await new Promise((resolve2) => setTimeout(resolve2, pollMs));
30225
+ await new Promise((resolve3) => setTimeout(resolve3, pollMs));
30166
30226
  }
30167
30227
  return predicate();
30168
30228
  }
@@ -30263,7 +30323,7 @@ var LIVE_URL_RE = /\/p\/[^/?#]+|\/publish\/posts\/published/;
30263
30323
  var PUBLICATION_URL_SOURCES = "SUBSTACK_PUBLICATION_URL (or --publication <url>)";
30264
30324
  function editorUrl(publicationUrl) {
30265
30325
  const base2 = publicationUrl.trim().replace(/\/$/, "").replace(/\/publish$/, "");
30266
- return `${base2}/publish/post/new`;
30326
+ return `${base2}/publish/post`;
30267
30327
  }
30268
30328
  function resolvePublicationUrl(explicit) {
30269
30329
  const trimmed = (explicit ?? process.env.SUBSTACK_PUBLICATION_URL)?.trim() ?? "";
@@ -30305,6 +30365,18 @@ function errorMessage3(error51) {
30305
30365
  function needsLogin(error51) {
30306
30366
  return error51 instanceof LoginTimeoutError || error51 instanceof BrowserProfileMissingError;
30307
30367
  }
30368
+ var SUBSTACK_OPERATIONS = ["post"];
30369
+ function resolveOperation(options, content) {
30370
+ const raw = options?.operation ?? content?.metadata?.operation;
30371
+ if (raw === undefined)
30372
+ return { operation: "post" };
30373
+ if (typeof raw !== "string" || !SUBSTACK_OPERATIONS.includes(raw)) {
30374
+ return {
30375
+ error: `unsupported operation '${String(raw)}' for substack: expected one of ${SUBSTACK_OPERATIONS.join(", ")}`
30376
+ };
30377
+ }
30378
+ return { operation: raw };
30379
+ }
30308
30380
 
30309
30381
  class SubstackBrowserTransport {
30310
30382
  kind = "browser";
@@ -30313,13 +30385,16 @@ class SubstackBrowserTransport {
30313
30385
  stepTimeoutMs;
30314
30386
  constructor(driver = "script", deps = {}) {
30315
30387
  this.driver = driver;
30316
- this.launcher = deps.launcher;
30388
+ this.launcher = deps.launcher ?? kkBrowserLauncher;
30317
30389
  this.stepTimeoutMs = deps.stepTimeoutMs ?? STEP_TIMEOUT_MS;
30318
30390
  }
30319
30391
  async publish(payload) {
30320
30392
  if (this.driver !== "script") {
30321
30393
  return fail(`unsupported driver '${this.driver}' for ${TARGET}`);
30322
30394
  }
30395
+ const mode = resolveOperation(payload.options, payload.content);
30396
+ if (mode.error !== undefined)
30397
+ return fail(mode.error);
30323
30398
  const requested = payload.content.metadata?.publishStatus;
30324
30399
  if (requested !== undefined && requested !== "draft" && requested !== "public") {
30325
30400
  return fail(`unknown publishStatus '${String(requested)}' (expected absent, 'draft' or 'public')`);
@@ -30482,6 +30557,7 @@ if (import.meta.main) {
30482
30557
  }
30483
30558
  export {
30484
30559
  resolvePublicationUrl,
30560
+ resolveOperation,
30485
30561
  processPublishIO,
30486
30562
  main2 as main,
30487
30563
  isAuthenticated,
@@ -30489,6 +30565,7 @@ export {
30489
30565
  editorUrl,
30490
30566
  channelConfig,
30491
30567
  SubstackBrowserTransport,
30568
+ SUBSTACK_OPERATIONS,
30492
30569
  SELECTORS,
30493
30570
  LOGIN_URL_RE,
30494
30571
  CHANNEL
@@ -2,6 +2,7 @@
2
2
  "name": "substack-pub",
3
3
  "kind": "publish",
4
4
  "entry": "./dist/index.js",
5
+ "check": "./src/profile-check.ts",
5
6
  "version": "1.0.0",
6
7
  "description": "Publish plugin for Substack (substack.com): post drafts through the ProseMirror editor via script browser transport (ts-browser-automation)"
7
8
  }
@@ -12,6 +12,7 @@ import {
12
12
  type ChannelBrowserConfig,
13
13
  checkChannelSession,
14
14
  expectOutcome,
15
+ kkBrowserLauncher,
15
16
  markdownToHtml,
16
17
  pasteHtml,
17
18
  resolveChannelProfileDir,
@@ -36,7 +37,10 @@ export const LOGIN_URL_RE = /(\/sign-in|substack\.com\/account\/login)/;
36
37
 
37
38
  /**
38
39
  * Selectors seeded from the wt script (`substack-playwright.ts:84-136`); each list is tried in
39
- * order and the operator dogfood (0193) re-measures them. `send` is Substack's
40
+ * order. Measured live 2026-10-07 (0193): title `textarea[placeholder="Title"]` and body
41
+ * `.ProseMirror[contenteditable="true"]` both hit, harness paste verified; both subtitle
42
+ * candidates miss — the current editor UI has no subtitle field, so they are kept as
43
+ * last-known and only resolve when `metadata.subtitle` is set. `send` is Substack's
40
44
  * `Send to everyone now` — it emails every subscriber — so both live controls (E91-D5) are
41
45
  * reached only from the `public` branch, after the draft branch has already returned.
42
46
  */
@@ -64,15 +68,18 @@ const LIVE_URL_RE = /\/p\/[^/?#]+|\/publish\/posts\/published/;
64
68
  const PUBLICATION_URL_SOURCES = 'SUBSTACK_PUBLICATION_URL (or --publication <url>)';
65
69
 
66
70
  /**
67
- * The publication's new-post editor: `${base}/publish/post/new`, where the base is the
68
- * publication URL without its trailing `/` or `/publish` (seed `substack-playwright.ts:237-244`).
71
+ * The publication's post editor: `${base}/publish/post`, where the base is the publication URL
72
+ * without its trailing `/` or `/publish` (seed `substack-playwright.ts:237-244`). The legacy
73
+ * `/publish/post/new` route autosaves locally ("Saved") but never becomes a post entity, so the
74
+ * URL never rewrites to `/publish/post/<id>` and the draft signal never fires — measured live
75
+ * 2026-10-07 (0193 A/B: `new` no rewrite, bare route rewrote to `/publish/post/219348810`).
69
76
  */
70
77
  export function editorUrl(publicationUrl: string): string {
71
78
  const base = publicationUrl
72
79
  .trim()
73
80
  .replace(/\/$/, '')
74
81
  .replace(/\/publish$/, '');
75
- return `${base}/publish/post/new`;
82
+ return `${base}/publish/post`;
76
83
  }
77
84
 
78
85
  /**
@@ -97,7 +104,7 @@ export function resolvePublicationUrl(explicit?: string): { url: string } | { er
97
104
  return { error: `substack publication URL must be https:, got '${trimmed}' — set ${PUBLICATION_URL_SOURCES}` };
98
105
  }
99
106
  // Nested editor paths are rejected (residual 0197): `…/publish/posts` used to pass validation
100
- // and then be mangled by `editorUrl` (`…/publish/posts/publish/post/new`), so a misconfigured
107
+ // and then be mangled by `editorUrl` (`…/publish/posts/publish/post`), so a misconfigured
101
108
  // run reported an expired session instead of a configuration error. A trailing `/publish` is
102
109
  // accepted and stripped by `editorUrl` — that is the documented shape.
103
110
  const trimmedPath = parsed.pathname.replace(/\/+$/, '');
@@ -139,15 +146,37 @@ function needsLogin(error: unknown): boolean {
139
146
  return error instanceof LoginTimeoutError || error instanceof BrowserProfileMissingError;
140
147
  }
141
148
 
149
+ /**
150
+ * Declared modes (ADR-029 dispatch; task 0205 R2): Substack’s console flow is the publication-scoped post draft. An unknown operation is refused by
151
+ * name before a profile is resolved or a browser opens.
152
+ */
153
+ export const SUBSTACK_OPERATIONS = ['post'] as const;
154
+ export type SubstackOperation = (typeof SUBSTACK_OPERATIONS)[number];
155
+
156
+ /** Exit-early resolution of the requested operation; a default Content without one resolves to `post`. */
157
+ export function resolveOperation(
158
+ options?: Record<string, unknown>,
159
+ content?: Content,
160
+ ): { operation: SubstackOperation; error?: undefined } | { operation?: undefined; error: string } {
161
+ const raw = options?.operation ?? content?.metadata?.operation;
162
+ if (raw === undefined) return { operation: 'post' };
163
+ if (typeof raw !== 'string' || !(SUBSTACK_OPERATIONS as readonly string[]).includes(raw)) {
164
+ return {
165
+ error: `unsupported operation '${String(raw)}' for substack: expected one of ${SUBSTACK_OPERATIONS.join(', ')}`,
166
+ };
167
+ }
168
+ return { operation: raw as SubstackOperation };
169
+ }
170
+
142
171
  export class SubstackBrowserTransport implements PublishTransport {
143
172
  public readonly kind = 'browser';
144
173
  public readonly driver: BrowserDriver;
145
- private readonly launcher?: BrowserLauncher;
174
+ private readonly launcher: BrowserLauncher;
146
175
  private readonly stepTimeoutMs: number;
147
176
 
148
177
  constructor(driver: BrowserDriver = 'script', deps: { launcher?: BrowserLauncher; stepTimeoutMs?: number } = {}) {
149
178
  this.driver = driver;
150
- this.launcher = deps.launcher;
179
+ this.launcher = deps.launcher ?? kkBrowserLauncher;
151
180
  this.stepTimeoutMs = deps.stepTimeoutMs ?? STEP_TIMEOUT_MS;
152
181
  }
153
182
 
@@ -155,6 +184,8 @@ export class SubstackBrowserTransport implements PublishTransport {
155
184
  if (this.driver !== 'script') {
156
185
  return fail(`unsupported driver '${this.driver}' for ${TARGET}`);
157
186
  }
187
+ const mode = resolveOperation(payload.options, payload.content);
188
+ if (mode.error !== undefined) return fail(mode.error);
158
189
  const requested = payload.content.metadata?.publishStatus;
159
190
  if (requested !== undefined && requested !== 'draft' && requested !== 'public') {
160
191
  return fail(`unknown publishStatus '${String(requested)}' (expected absent, 'draft' or 'public')`);
@@ -290,7 +321,7 @@ export class SubstackBrowserTransport implements PublishTransport {
290
321
  }
291
322
  }
292
323
 
293
- /** Draft evidence is URL-only by design: Substack's autosave rewrites `/publish/post/new`. */
324
+ /** Draft evidence is URL-only by design: Substack's autosave rewrites `/publish/post/<id>`. */
294
325
  async function probeDraft(page: Page): Promise<string | null> {
295
326
  const url = page.url();
296
327
  return DRAFT_URL_RE.test(url) ? url : null;
@@ -63,6 +63,8 @@ export async function main(argv: readonly string[] = Bun.argv.slice(2), deps: Pr
63
63
  const publication = resolvePublicationUrl(publicationUrl);
64
64
  if ('error' in publication) {
65
65
  stdout(`substack profile-check: ${publication.error} — ${USAGE}`);
66
+ // Last line is the ADR-032 verdict so `kk plugin check` can name the missing variable.
67
+ stdout(JSON.stringify({ status: 'error', detail: publication.error }));
66
68
  return 2;
67
69
  }
68
70
  const config: ChannelBrowserConfig = channelConfig(publication.url);
@@ -14665,7 +14665,7 @@ var init_zod = __esm(() => {
14665
14665
  init_external();
14666
14666
  });
14667
14667
 
14668
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/errors.js
14668
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/errors.js
14669
14669
  var ErrorCode;
14670
14670
  var init_errors3 = __esm(() => {
14671
14671
  ErrorCode = {
@@ -14676,7 +14676,7 @@ var init_errors3 = __esm(() => {
14676
14676
  };
14677
14677
  });
14678
14678
 
14679
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14679
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14680
14680
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
14681
14681
  var init_api_response = __esm(() => {
14682
14682
  init_errors3();
@@ -14699,13 +14699,13 @@ var init_api_response = __esm(() => {
14699
14699
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
14700
14700
  });
14701
14701
 
14702
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14702
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14703
14703
  var init_cursor = () => {};
14704
14704
 
14705
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14705
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14706
14706
  var init_event_severity = () => {};
14707
14707
 
14708
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/output.js
14708
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/output.js
14709
14709
  function processStream(name) {
14710
14710
  const proc = globalThis.process;
14711
14711
  const stream = proc?.[name];
@@ -14723,7 +14723,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
14723
14723
  }
14724
14724
  var defaultStderrTarget;
14725
14725
 
14726
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.15/node_modules/@gobing-ai/ts-utils/dist/index.js
14726
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/index.js
14727
14727
  var init_dist = __esm(() => {
14728
14728
  init_api_response();
14729
14729
  init_cursor();
@@ -21721,7 +21721,7 @@ var init_dist2 = __esm(() => {
21721
21721
  $visitAsync = visit.visitAsync;
21722
21722
  });
21723
21723
 
21724
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/config.js
21724
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/config.js
21725
21725
  var configSchema;
21726
21726
  var init_config = __esm(() => {
21727
21727
  init_dist2();
@@ -21745,7 +21745,7 @@ var init_config = __esm(() => {
21745
21745
  });
21746
21746
  });
21747
21747
 
21748
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21748
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21749
21749
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21750
21750
  import { dirname, resolve as resolvePath } from "path";
21751
21751
  function createNodeFileSystem(root, paths) {
@@ -22037,11 +22037,12 @@ var PluginManifestSchema = exports_external.looseObject({
22037
22037
  name: exports_external.string().min(1),
22038
22038
  kind: PluginKindSchema,
22039
22039
  entry: exports_external.string().min(1),
22040
+ check: exports_external.string().min(1).optional(),
22040
22041
  version: exports_external.string().optional(),
22041
22042
  description: exports_external.string().optional(),
22042
22043
  operations: exports_external.record(exports_external.string(), PluginOperationSchema).optional()
22043
22044
  });
22044
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.15/node_modules/@gobing-ai/ts-runtime/dist/index.js
22045
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/index.js
22045
22046
  init_file_system_node();
22046
22047
  init_config();
22047
22048