oh-my-opencode 4.15.1 → 4.16.0

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 (142) hide show
  1. package/dist/cli/doctor/checks/tui-plugin-config.d.ts +4 -4
  2. package/dist/cli/index.js +673 -678
  3. package/dist/cli/install-senpi/index.d.ts +1 -0
  4. package/dist/cli/run/poll-for-completion.d.ts +4 -0
  5. package/dist/cli/run/session-resolver.d.ts +1 -0
  6. package/dist/cli/senpi-platform-flag.d.ts +4 -0
  7. package/dist/cli/types.d.ts +2 -1
  8. package/dist/cli-node/index.js +673 -678
  9. package/dist/features/background-agent/manager.d.ts +16 -0
  10. package/dist/hooks/anthropic-context-window-limit-recovery/aggressive-truncation-strategy.d.ts +1 -0
  11. package/dist/index.js +1334 -1146
  12. package/dist/skills/debugging/references/methodology/06-fix.md +6 -0
  13. package/dist/skills/frontend/ATTRIBUTION.md +10 -1
  14. package/dist/skills/frontend/SKILL.md +8 -3
  15. package/dist/skills/frontend/references/design/README.md +1 -1
  16. package/dist/skills/frontend/references/design/_INDEX.md +1 -1
  17. package/dist/skills/frontend/references/design/lazyweb.md +77 -0
  18. package/dist/skills/frontend/references/design/stitch-design-example.md +121 -0
  19. package/dist/skills/programming/SKILL.md +10 -1
  20. package/dist/skills/programming/references/logging.md +91 -0
  21. package/dist/skills/ulw-plan/SKILL.md +5 -5
  22. package/dist/skills/ulw-plan/references/full-workflow.md +7 -7
  23. package/dist/skills/ulw-plan/references/intent-unclear.md +3 -3
  24. package/dist/skills/ulw-research/ATTRIBUTION.md +2 -2
  25. package/dist/skills/ulw-research/SKILL.md +28 -7
  26. package/dist/tools/skill/description-formatter.d.ts +1 -0
  27. package/dist/tools/skill/description-formatter.test-support.d.ts +9 -0
  28. package/dist/tools/skill/zauc-mocks-skill-tools/test-support.d.ts +25 -0
  29. package/dist/tui.js +121 -419
  30. package/package.json +32 -15
  31. package/packages/git-bash-mcp/dist/cli.js +2 -2
  32. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  33. package/packages/omo-codex/plugin/components/bootstrap/AGENTS.md +55 -0
  34. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +19 -16
  35. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  36. package/packages/omo-codex/plugin/components/codegraph/AGENTS.md +51 -0
  37. package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +936 -248
  38. package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +233 -135
  39. package/packages/omo-codex/plugin/components/codegraph/package.json +1 -1
  40. package/packages/omo-codex/plugin/components/codegraph/src/cache-gc.ts +29 -0
  41. package/packages/omo-codex/plugin/components/codegraph/src/cli.ts +13 -0
  42. package/packages/omo-codex/plugin/components/codegraph/src/hook-sweep.ts +25 -0
  43. package/packages/omo-codex/plugin/components/codegraph/src/hook-types.ts +3 -1
  44. package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +30 -1
  45. package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +16 -2
  46. package/packages/omo-codex/plugin/components/codegraph/src/sweep-cli.ts +80 -0
  47. package/packages/omo-codex/plugin/components/codegraph/test/cache-gc.test.ts +34 -0
  48. package/packages/omo-codex/plugin/components/codegraph/test/hook-exclusion.test.ts +107 -0
  49. package/packages/omo-codex/plugin/components/codegraph/test/hook-registration.test.ts +26 -0
  50. package/packages/omo-codex/plugin/components/codegraph/test/hook-sweep.test.ts +29 -0
  51. package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +8 -21
  52. package/packages/omo-codex/plugin/components/codegraph/test/mcp-bridge-fixtures.ts +108 -0
  53. package/packages/omo-codex/plugin/components/codegraph/test/serve-built-wrapper.test.ts +76 -0
  54. package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge.test.ts +17 -111
  55. package/packages/omo-codex/plugin/components/codegraph/test/serve-provision.test.ts +1 -1
  56. package/packages/omo-codex/plugin/components/codegraph/test/serve.test.ts +45 -67
  57. package/packages/omo-codex/plugin/components/codegraph/test/sweep-cli.test.ts +56 -0
  58. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  59. package/packages/omo-codex/plugin/components/git-bash/AGENTS.md +31 -0
  60. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  61. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/AGENTS.md +45 -0
  62. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  63. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  64. package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus.md +37 -102
  65. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  66. package/packages/omo-codex/plugin/components/start-work-continuation/package.json +1 -1
  67. package/packages/omo-codex/plugin/components/teammode/AGENTS.md +46 -0
  68. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  69. package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +6 -0
  70. package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +6 -0
  71. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  72. package/packages/omo-codex/plugin/components/ultrawork/AGENTS.md +5 -2
  73. package/packages/omo-codex/plugin/components/ultrawork/CHANGELOG.md +2 -0
  74. package/packages/omo-codex/plugin/components/ultrawork/README.md +3 -3
  75. package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +51 -2
  76. package/packages/omo-codex/plugin/components/ultrawork/package.json +2 -1
  77. package/packages/omo-codex/plugin/components/ultrawork/scripts/sync-directive.mjs +14 -1
  78. package/packages/omo-codex/plugin/components/ultrawork/skills/ultrawork/SKILL.md +380 -0
  79. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +5 -2
  80. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +4 -4
  81. package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-unclear.md +2 -2
  82. package/packages/omo-codex/plugin/components/ultrawork/src/codex-hook.ts +5 -3
  83. package/packages/omo-codex/plugin/components/ultrawork/src/skill-pointer.ts +56 -0
  84. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +4 -4
  85. package/packages/omo-codex/plugin/components/ultrawork/test/directive-source.test.ts +12 -0
  86. package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +1 -0
  87. package/packages/omo-codex/plugin/components/ultrawork/test/skill-pointer.test.ts +82 -0
  88. package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +1 -0
  89. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +56 -5
  90. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-hook.d.ts +1 -0
  91. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-hook.js +5 -1
  92. package/packages/omo-codex/plugin/components/ulw-loop/dist/ultrawork-directive.d.ts +2 -1
  93. package/packages/omo-codex/plugin/components/ulw-loop/dist/ultrawork-directive.js +5 -3
  94. package/packages/omo-codex/plugin/components/ulw-loop/dist/ultrawork-skill-pointer.d.ts +7 -0
  95. package/packages/omo-codex/plugin/components/ulw-loop/dist/ultrawork-skill-pointer.js +46 -0
  96. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  97. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-hook.ts +5 -1
  98. package/packages/omo-codex/plugin/components/ulw-loop/src/ultrawork-directive.ts +9 -3
  99. package/packages/omo-codex/plugin/components/ulw-loop/src/ultrawork-skill-pointer.ts +55 -0
  100. package/packages/omo-codex/plugin/components/ulw-loop/test/ultrawork-directive.test.ts +49 -0
  101. package/packages/omo-codex/plugin/package-lock.json +13 -13
  102. package/packages/omo-codex/plugin/package.json +1 -1
  103. package/packages/omo-codex/plugin/scripts/build-components.mjs +63 -17
  104. package/packages/omo-codex/plugin/scripts/materialize-shared-upstreams.mjs +10 -3
  105. package/packages/omo-codex/plugin/scripts/sync-skills.mjs +1 -0
  106. package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +18 -0
  107. package/packages/omo-codex/plugin/skills/debugging/references/methodology/06-fix.md +6 -0
  108. package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +10 -1
  109. package/packages/omo-codex/plugin/skills/frontend/SKILL.md +8 -3
  110. package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +1 -1
  111. package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +1 -1
  112. package/packages/omo-codex/plugin/skills/frontend/references/design/lazyweb.md +77 -0
  113. package/packages/omo-codex/plugin/skills/frontend/references/design/stitch-design-example.md +121 -0
  114. package/packages/omo-codex/plugin/skills/programming/SKILL.md +10 -1
  115. package/packages/omo-codex/plugin/skills/programming/references/logging.md +91 -0
  116. package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +380 -0
  117. package/packages/omo-codex/plugin/skills/ultrawork/agents/openai.yaml +2 -0
  118. package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +5 -2
  119. package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +4 -4
  120. package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-unclear.md +2 -2
  121. package/packages/omo-codex/plugin/skills/ulw-research/ATTRIBUTION.md +2 -2
  122. package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +28 -7
  123. package/packages/omo-codex/plugin/test/install-time-build-runtime.test.mjs +1 -1
  124. package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +2 -0
  125. package/packages/omo-codex/plugin/test/ultrawork-skill-pointer.test.mjs +56 -0
  126. package/packages/omo-codex/plugin/test/ulw-research-epistemic-contract.test.mjs +98 -0
  127. package/packages/omo-codex/plugin/test/ulw-research-skill-contract.test.mjs +6 -6
  128. package/packages/omo-codex/scripts/install-dist/install-local.mjs +259 -3954
  129. package/packages/shared-skills/skills/debugging/references/methodology/06-fix.md +6 -0
  130. package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +10 -1
  131. package/packages/shared-skills/skills/frontend/SKILL.md +8 -3
  132. package/packages/shared-skills/skills/frontend/references/design/README.md +1 -1
  133. package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +1 -1
  134. package/packages/shared-skills/skills/frontend/references/design/lazyweb.md +77 -0
  135. package/packages/shared-skills/skills/frontend/references/design/stitch-design-example.md +121 -0
  136. package/packages/shared-skills/skills/programming/SKILL.md +10 -1
  137. package/packages/shared-skills/skills/programming/references/logging.md +91 -0
  138. package/packages/shared-skills/skills/ulw-plan/SKILL.md +5 -5
  139. package/packages/shared-skills/skills/ulw-plan/references/full-workflow.md +7 -7
  140. package/packages/shared-skills/skills/ulw-plan/references/intent-unclear.md +3 -3
  141. package/packages/shared-skills/skills/ulw-research/ATTRIBUTION.md +2 -2
  142. package/packages/shared-skills/skills/ulw-research/SKILL.md +28 -7
@@ -257,7 +257,7 @@ function shouldRetainLine(line, cutoffMs) {
257
257
  function parseDiagnosticLine(line) {
258
258
  try {
259
259
  const parsed = JSON.parse(line);
260
- if (!isRecord2(parsed)) {
260
+ if (!isRecord(parsed)) {
261
261
  return null;
262
262
  }
263
263
  return parsed;
@@ -268,7 +268,7 @@ function parseDiagnosticLine(line) {
268
268
  throw error;
269
269
  }
270
270
  }
271
- function isRecord2(value) {
271
+ function isRecord(value) {
272
272
  return value !== null && typeof value === "object" && !Array.isArray(value);
273
273
  }
274
274
  function trimToMaxBytes(lines) {
@@ -311,24 +311,24 @@ function isSendOptOutFlag(value) {
311
311
  return includesValue(SEND_OPT_OUT_VALUES, value);
312
312
  }
313
313
  function shouldDisableTelemetry(input) {
314
- const env2 = input.env ?? process.env;
314
+ const env = input.env ?? process.env;
315
315
  const globalPrefix = input.globalEnvPrefix ?? "OMO";
316
316
  const prefixes = Array.from(new Set([globalPrefix, input.productEnvPrefix]));
317
317
  for (const prefix of prefixes) {
318
- if (isDisableFlag(env2[`${prefix}_DISABLE_POSTHOG`])) {
318
+ if (isDisableFlag(env[`${prefix}_DISABLE_POSTHOG`])) {
319
319
  return true;
320
320
  }
321
- if (isSendOptOutFlag(env2[`${prefix}_SEND_ANONYMOUS_TELEMETRY`])) {
321
+ if (isSendOptOutFlag(env[`${prefix}_SEND_ANONYMOUS_TELEMETRY`])) {
322
322
  return true;
323
323
  }
324
324
  }
325
325
  return false;
326
326
  }
327
- function getTelemetryApiKey(env2 = process.env, defaultApiKey = DEFAULT_POSTHOG_API_KEY) {
328
- return env2["POSTHOG_API_KEY"]?.trim() ?? defaultApiKey;
327
+ function getTelemetryApiKey(env = process.env, defaultApiKey = DEFAULT_POSTHOG_API_KEY) {
328
+ return env["POSTHOG_API_KEY"]?.trim() ?? defaultApiKey;
329
329
  }
330
- function getTelemetryHost(env2 = process.env, defaultHost = DEFAULT_POSTHOG_HOST) {
331
- return env2["POSTHOG_HOST"]?.trim() || defaultHost;
330
+ function getTelemetryHost(env = process.env, defaultHost = DEFAULT_POSTHOG_HOST) {
331
+ return env["POSTHOG_HOST"]?.trim() || defaultHost;
332
332
  }
333
333
  var TRUTHY_DISABLE_VALUES, SEND_OPT_OUT_VALUES;
334
334
  var init_env = __esm(() => {
@@ -363,10 +363,10 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname9(proce
363
363
  if (!filename)
364
364
  return;
365
365
  const normalizedFilename = isWindows ? normalizeWindowsPath(filename) : filename;
366
- let { dir, base: file2, ext } = posix.parse(normalizedFilename);
366
+ let { dir, base: file, ext } = posix.parse(normalizedFilename);
367
367
  if (ext === ".js" || ext === ".mjs" || ext === ".cjs")
368
- file2 = file2.slice(0, -1 * ext.length);
369
- const decodedFile = decodeURIComponent(file2);
368
+ file = file.slice(0, -1 * ext.length);
369
+ const decodedFile = decodeURIComponent(file);
370
370
  if (!dir)
371
371
  dir = ".";
372
372
  const n = dir.lastIndexOf("/node_modules");
@@ -665,7 +665,7 @@ function isErrorEvent(event) {
665
665
  function isEvent(candidate) {
666
666
  return typeof Event != "undefined" && isInstanceOf(candidate, Event);
667
667
  }
668
- function isPlainObject2(candidate) {
668
+ function isPlainObject(candidate) {
669
669
  return isBuiltin(candidate, "Object");
670
670
  }
671
671
  function isInstanceOf(candidate, base) {
@@ -689,23 +689,23 @@ var init_type_utils = __esm(() => {
689
689
  });
690
690
 
691
691
  // node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/utils/number-utils.mjs
692
- function clampToRange(value, min, max, logger3, fallbackValue) {
692
+ function clampToRange(value, min, max, logger, fallbackValue) {
693
693
  if (min > max) {
694
- logger3.warn("min cannot be greater than max.");
694
+ logger.warn("min cannot be greater than max.");
695
695
  min = max;
696
696
  }
697
697
  if (isNumber(value))
698
698
  if (value > max) {
699
- logger3.warn(" cannot be greater than max: " + max + ". Using max value instead.");
699
+ logger.warn(" cannot be greater than max: " + max + ". Using max value instead.");
700
700
  return max;
701
701
  } else {
702
702
  if (!(value < min))
703
703
  return value;
704
- logger3.warn(" cannot be less than min: " + min + ". Using min value instead.");
704
+ logger.warn(" cannot be less than min: " + min + ". Using min value instead.");
705
705
  return min;
706
706
  }
707
- logger3.warn(" must be a number. using max or fallback. max: " + max + ", fallback: " + fallbackValue);
708
- return clampToRange(fallbackValue || max, min, max, logger3);
707
+ logger.warn(" must be a number. using max or fallback. max: " + max + ", fallback: " + fallbackValue);
708
+ return clampToRange(fallbackValue || max, min, max, logger);
709
709
  }
710
710
  var init_number_utils = __esm(() => {
711
711
  init_type_utils();
@@ -983,7 +983,7 @@ var _createLogger = (prefix, maybeCall, consoleLike) => {
983
983
  consoleMethod(prefix, ...args);
984
984
  });
985
985
  }
986
- const logger3 = {
986
+ const logger = {
987
987
  debug: (...args) => {
988
988
  _log("debug", ...args);
989
989
  },
@@ -1001,7 +1001,7 @@ var _createLogger = (prefix, maybeCall, consoleLike) => {
1001
1001
  },
1002
1002
  createLogger: (additionalPrefix) => _createLogger(`${prefix} ${additionalPrefix}`, maybeCall, consoleLike)
1003
1003
  };
1004
- return logger3;
1004
+ return logger;
1005
1005
  }, passThrough = (fn) => fn();
1006
1006
  var init_logger = () => {};
1007
1007
 
@@ -3177,18 +3177,18 @@ async function addSourceContext(frames) {
3177
3177
  if (files.length == 0)
3178
3178
  return frames;
3179
3179
  const readlinePromises = [];
3180
- for (const file2 of files) {
3181
- if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(file2))
3180
+ for (const file of files) {
3181
+ if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(file))
3182
3182
  continue;
3183
- const filesToLineRanges = filesToLines[file2];
3183
+ const filesToLineRanges = filesToLines[file];
3184
3184
  if (!filesToLineRanges)
3185
3185
  continue;
3186
3186
  filesToLineRanges.sort((a, b) => a - b);
3187
3187
  const ranges = makeLineReaderRanges(filesToLineRanges);
3188
- if (ranges.every((r) => rangeExistsInContentCache(file2, r)))
3188
+ if (ranges.every((r) => rangeExistsInContentCache(file, r)))
3189
3189
  continue;
3190
- const cache = emplace(LRU_FILE_CONTENTS_CACHE, file2, {});
3191
- readlinePromises.push(getContextLinesFromFile(file2, ranges, cache));
3190
+ const cache = emplace(LRU_FILE_CONTENTS_CACHE, file, {});
3191
+ readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
3192
3192
  }
3193
3193
  await Promise.all(readlinePromises).catch(() => {});
3194
3194
  if (frames && frames.length > 0)
@@ -3197,14 +3197,14 @@ async function addSourceContext(frames) {
3197
3197
  return frames;
3198
3198
  }
3199
3199
  function getContextLinesFromFile(path2, ranges, output) {
3200
- return new Promise((resolve11) => {
3200
+ return new Promise((resolve9) => {
3201
3201
  const stream = createReadStream(path2);
3202
3202
  const lineReaded = createInterface({
3203
3203
  input: stream
3204
3204
  });
3205
3205
  function destroyStreamAndResolve() {
3206
3206
  stream.destroy();
3207
- resolve11();
3207
+ resolve9();
3208
3208
  }
3209
3209
  let lineNumber = 0;
3210
3210
  let currentRangeIndex = 0;
@@ -3292,8 +3292,8 @@ function shouldSkipContextLinesForFrame(frame) {
3292
3292
  return true;
3293
3293
  return false;
3294
3294
  }
3295
- function rangeExistsInContentCache(file2, range) {
3296
- const contents = LRU_FILE_CONTENTS_CACHE.get(file2);
3295
+ function rangeExistsInContentCache(file, range) {
3296
+ const contents = LRU_FILE_CONTENTS_CACHE.get(file);
3297
3297
  if (contents === undefined)
3298
3298
  return false;
3299
3299
  for (let i = range[0];i <= range[1]; i++)
@@ -4676,9 +4676,9 @@ var init_client = __esm(() => {
4676
4676
  if (this.disabled || this.optedOut)
4677
4677
  return;
4678
4678
  if (!this._waitUntilCycle) {
4679
- let resolve11;
4679
+ let resolve9;
4680
4680
  const promise = new Promise((r) => {
4681
- resolve11 = r;
4681
+ resolve9 = r;
4682
4682
  });
4683
4683
  try {
4684
4684
  waitUntil(promise);
@@ -4686,7 +4686,7 @@ var init_client = __esm(() => {
4686
4686
  return;
4687
4687
  }
4688
4688
  this._waitUntilCycle = {
4689
- resolve: resolve11,
4689
+ resolve: resolve9,
4690
4690
  startedAt: Date.now(),
4691
4691
  timer: undefined
4692
4692
  };
@@ -4712,11 +4712,11 @@ var init_client = __esm(() => {
4712
4712
  return cycle?.resolve;
4713
4713
  }
4714
4714
  async resolveWaitUntilFlush() {
4715
- const resolve11 = this._consumeWaitUntilCycle();
4715
+ const resolve9 = this._consumeWaitUntilCycle();
4716
4716
  try {
4717
4717
  await super.flush();
4718
4718
  } catch {} finally {
4719
- resolve11?.();
4719
+ resolve9?.();
4720
4720
  }
4721
4721
  }
4722
4722
  getPersistedProperty(key) {
@@ -4816,15 +4816,15 @@ var init_client = __esm(() => {
4816
4816
  return true;
4817
4817
  if (this.featureFlagsPoller === undefined)
4818
4818
  return false;
4819
- return new Promise((resolve11) => {
4819
+ return new Promise((resolve9) => {
4820
4820
  const timeout = setTimeout(() => {
4821
4821
  cleanup();
4822
- resolve11(false);
4822
+ resolve9(false);
4823
4823
  }, timeoutMs);
4824
4824
  const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
4825
4825
  clearTimeout(timeout);
4826
4826
  cleanup();
4827
- resolve11(count > 0);
4827
+ resolve9(count > 0);
4828
4828
  });
4829
4829
  });
4830
4830
  }
@@ -5330,13 +5330,13 @@ var init_client = __esm(() => {
5330
5330
  this.context?.enter(data, options);
5331
5331
  }
5332
5332
  async _shutdown(shutdownTimeoutMs) {
5333
- const resolve11 = this._consumeWaitUntilCycle();
5333
+ const resolve9 = this._consumeWaitUntilCycle();
5334
5334
  await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
5335
5335
  this.errorTracking.shutdown();
5336
5336
  try {
5337
5337
  return await super._shutdown(shutdownTimeoutMs);
5338
5338
  } finally {
5339
- resolve11?.();
5339
+ resolve9?.();
5340
5340
  }
5341
5341
  }
5342
5342
  async _requestRemoteConfigPayload(flagKey) {
@@ -5378,7 +5378,7 @@ var init_client = __esm(() => {
5378
5378
  const personProperties = {};
5379
5379
  const groupProperties = {};
5380
5380
  for (const [key, value] of Object.entries(eventProperties))
5381
- if (isPlainObject2(value) && groups && key in groups) {
5381
+ if (isPlainObject(value) && groups && key in groups) {
5382
5382
  const groupProps = {};
5383
5383
  for (const [groupKey, groupValue] of Object.entries(value))
5384
5384
  groupProps[String(groupKey)] = String(groupValue);
@@ -5741,8 +5741,8 @@ function createDefaultPostHogTransport(apiKey, options) {
5741
5741
  return new PostHogTelemetryTransport(apiKey, options);
5742
5742
  }
5743
5743
  function isTelemetryClientEnabled(input) {
5744
- const env2 = input.env ?? process.env;
5745
- return !shouldDisableTelemetry({ env: env2, productEnvPrefix: input.product.productEnvPrefix }) && getTelemetryApiKey(env2, input.product.defaultApiKey).length > 0;
5744
+ const env = input.env ?? process.env;
5745
+ return !shouldDisableTelemetry({ env, productEnvPrefix: input.product.productEnvPrefix }) && getTelemetryApiKey(env, input.product.defaultApiKey).length > 0;
5746
5746
  }
5747
5747
  function createTelemetryClient(input) {
5748
5748
  if (!isTelemetryClientEnabled(input)) {
@@ -5797,17 +5797,17 @@ function createTelemetryClient(input) {
5797
5797
  };
5798
5798
  }
5799
5799
  function createTransport(input) {
5800
- const env2 = input.env ?? process.env;
5800
+ const env = input.env ?? process.env;
5801
5801
  const factory = input.transportFactory ?? createDefaultPostHogTransport;
5802
5802
  try {
5803
- return factory(getTelemetryApiKey(env2, input.product.defaultApiKey), {
5803
+ return factory(getTelemetryApiKey(env, input.product.defaultApiKey), {
5804
5804
  enableExceptionAutocapture: false,
5805
5805
  enableLocalEvaluation: false,
5806
5806
  strictLocalEvaluation: true,
5807
5807
  disableRemoteConfig: true,
5808
5808
  flushAt: 1,
5809
5809
  flushInterval: 0,
5810
- host: getTelemetryHost(env2, input.product.defaultHost),
5810
+ host: getTelemetryHost(env, input.product.defaultHost),
5811
5811
  disableGeoip: false
5812
5812
  });
5813
5813
  } catch (error) {
@@ -5886,11 +5886,7 @@ var init_posthog_client = __esm(() => {
5886
5886
  });
5887
5887
 
5888
5888
  // packages/telemetry-core/src/record-daily-active.ts
5889
- var init_record_daily_active = __esm(() => {
5890
- init_activity_state();
5891
- init_posthog_client();
5892
- init_machine_id();
5893
- });
5889
+ var init_record_daily_active = () => {};
5894
5890
 
5895
5891
  // packages/telemetry-core/src/index.ts
5896
5892
  var init_src = __esm(() => {
@@ -5907,7 +5903,7 @@ var package_default;
5907
5903
  var init_package = __esm(() => {
5908
5904
  package_default = {
5909
5905
  name: "@oh-my-opencode/omo-codex",
5910
- version: "4.15.1",
5906
+ version: "4.16.0",
5911
5907
  type: "module",
5912
5908
  private: true,
5913
5909
  description: "Codex harness adapter for oh-my-openagent. Vendored Codex plugin namespace (omo) + TypeScript installer + telemetry.",
@@ -6127,7 +6123,7 @@ var init_telemetry = __esm(() => {
6127
6123
 
6128
6124
  // packages/omo-codex/src/install/install-local-cli.ts
6129
6125
  import { readFile as readFile20 } from "node:fs/promises";
6130
- import { dirname as dirname11, join as join36, resolve as resolve12 } from "node:path";
6126
+ import { dirname as dirname11, join as join36, resolve as resolve10 } from "node:path";
6131
6127
  import { fileURLToPath as fileURLToPath2 } from "node:url";
6132
6128
 
6133
6129
  // packages/utils/src/runtime/spawn.ts
@@ -6284,6 +6280,7 @@ function spawn(cmdOrOpts, opts) {
6284
6280
  throw new Error("spawn requires a command");
6285
6281
  return wrapNodeProcess(nodeSpawn(bin, args, createNodeSpawnOptions(options)));
6286
6282
  }
6283
+
6287
6284
  // packages/utils/src/runtime/which.ts
6288
6285
  import { accessSync, constants } from "node:fs";
6289
6286
  import { delimiter, join } from "node:path";
@@ -6348,6 +6345,7 @@ function bunWhich(commandName) {
6348
6345
  }
6349
6346
  return null;
6350
6347
  }
6348
+
6351
6349
  // packages/utils/src/runtime/git-bash.ts
6352
6350
  import { execFileSync } from "node:child_process";
6353
6351
  import { existsSync } from "node:fs";
@@ -6458,7 +6456,7 @@ var defaultRunCommand = async (command, args, options) => {
6458
6456
  };
6459
6457
 
6460
6458
  // packages/omo-codex/src/install/install-codex.ts
6461
- import { join as join32, resolve as resolve11 } from "node:path";
6459
+ import { join as join32, resolve as resolve9 } from "node:path";
6462
6460
  import { existsSync as existsSync7 } from "node:fs";
6463
6461
  import { homedir as homedir2 } from "node:os";
6464
6462
 
@@ -7261,10 +7259,10 @@ function isNodeExecutableName(filePath) {
7261
7259
  function looksLikePath(command) {
7262
7260
  return command.includes("/") || command.includes("\\") || /^[a-zA-Z]:/.test(command);
7263
7261
  }
7264
- function resolveConfiguredNodeRuntime(configured, fileExists, which2) {
7262
+ function resolveConfiguredNodeRuntime(configured, fileExists, which) {
7265
7263
  if (looksLikePath(configured))
7266
7264
  return fileExists(configured) ? configured : null;
7267
- return which2(configured);
7265
+ return which(configured);
7268
7266
  }
7269
7267
  function supportsCodegraphNodeRuntime(nodePath, env, nodeVersion) {
7270
7268
  const version = nodeVersion(nodePath);
@@ -7272,15 +7270,15 @@ function supportsCodegraphNodeRuntime(nodePath, env, nodeVersion) {
7272
7270
  return false;
7273
7271
  return evaluateCodegraphNodeSupport({ env, nodeVersion: version }).supported;
7274
7272
  }
7275
- function defaultNodeRuntime(env, fileExists, which2, nodeVersion) {
7273
+ function defaultNodeRuntime(env, fileExists, which, nodeVersion) {
7276
7274
  const configured = env[CODEGRAPH_NODE_BIN_ENV]?.trim();
7277
7275
  if (configured !== undefined && configured.length > 0) {
7278
- const resolved = resolveConfiguredNodeRuntime(configured, fileExists, which2);
7276
+ const resolved = resolveConfiguredNodeRuntime(configured, fileExists, which);
7279
7277
  return resolved !== null && supportsCodegraphNodeRuntime(resolved, env, nodeVersion) ? resolved : null;
7280
7278
  }
7281
7279
  const candidates = [
7282
7280
  ...isNodeExecutableName(process.execPath) ? [process.execPath] : [],
7283
- ...CODEGRAPH_NODE_CANDIDATES.map((commandName) => which2(commandName)).filter((candidate) => candidate !== null),
7281
+ ...CODEGRAPH_NODE_CANDIDATES.map((commandName) => which(commandName)).filter((candidate) => candidate !== null),
7284
7282
  ...CODEGRAPH_NODE_PATH_CANDIDATES.filter((candidate) => fileExists(candidate))
7285
7283
  ];
7286
7284
  const seen = new Set;
@@ -8711,9 +8709,14 @@ function readBooleanSetting(sectionText, key) {
8711
8709
  // packages/omo-codex/src/install/codex-config-toml.ts
8712
8710
  async function updateCodexConfig(input) {
8713
8711
  await mkdir5(dirname7(input.configPath), { recursive: true });
8714
- let config = "";
8715
- if (await exists(input.configPath))
8712
+ let config;
8713
+ try {
8716
8714
  config = await readFile11(input.configPath, "utf8");
8715
+ } catch (error) {
8716
+ if (!isMissingFileError(error))
8717
+ throw error;
8718
+ config = "";
8719
+ }
8717
8720
  const pluginSet = new Set(input.pluginNames);
8718
8721
  for (const legacyMarketplaceName of legacyMarketplaceNames(input.marketplaceName)) {
8719
8722
  config = removeMarketplaceBlock(config, legacyMarketplaceName);
@@ -8747,15 +8750,8 @@ async function updateCodexConfig(input) {
8747
8750
  await writeFileAtomic(input.configPath, `${config.trimEnd()}
8748
8751
  `);
8749
8752
  }
8750
- async function exists(path) {
8751
- try {
8752
- await readFile11(path, "utf8");
8753
- return true;
8754
- } catch (error) {
8755
- if (error instanceof Error)
8756
- return false;
8757
- return false;
8758
- }
8753
+ function isMissingFileError(error) {
8754
+ return error instanceof Error && "code" in error && error.code === "ENOENT";
8759
8755
  }
8760
8756
 
8761
8757
  // packages/omo-codex/src/install/codex-hook-trust.ts
@@ -8776,7 +8772,7 @@ var EVENT_LABELS = new Map([
8776
8772
  ]);
8777
8773
  async function trustedHookStatesForPlugin(input) {
8778
8774
  const manifestPath = join18(input.pluginRoot, ".codex-plugin", "plugin.json");
8779
- if (!await exists2(manifestPath))
8775
+ if (!await exists(manifestPath))
8780
8776
  return [];
8781
8777
  const manifest = JSON.parse(await readFile12(manifestPath, "utf8"));
8782
8778
  if (!isPlainRecord(manifest))
@@ -8784,7 +8780,7 @@ async function trustedHookStatesForPlugin(input) {
8784
8780
  const states = [];
8785
8781
  for (const hookPath of hookManifestPaths2(manifest.hooks)) {
8786
8782
  const hooksPath = join18(input.pluginRoot, hookPath);
8787
- if (!await exists2(hooksPath))
8783
+ if (!await exists(hooksPath))
8788
8784
  continue;
8789
8785
  const parsed = JSON.parse(await readFile12(hooksPath, "utf8"));
8790
8786
  if (!isPlainRecord(parsed) || !isPlainRecord(parsed.hooks))
@@ -8867,7 +8863,7 @@ function canonicalJson(value) {
8867
8863
  function stripDotSlash2(value) {
8868
8864
  return value.startsWith("./") ? value.slice(2) : value;
8869
8865
  }
8870
- async function exists2(path) {
8866
+ async function exists(path) {
8871
8867
  try {
8872
8868
  await readFile12(path, "utf8");
8873
8869
  return true;
@@ -8926,11 +8922,11 @@ var RETIRED_MANAGED_AGENT_FILES = [
8926
8922
  ];
8927
8923
  async function purgeRetiredManagedAgentFiles(input) {
8928
8924
  const agentsDir = join19(input.codexHome, "agents");
8929
- if (!await exists3(agentsDir))
8925
+ if (!await exists2(agentsDir))
8930
8926
  return;
8931
8927
  for (const retiredAgent of RETIRED_MANAGED_AGENT_FILES) {
8932
8928
  const agentPath = join19(agentsDir, retiredAgent.fileName);
8933
- if (!await exists3(agentPath))
8929
+ if (!await exists2(agentPath))
8934
8930
  continue;
8935
8931
  const agentStat = await lstat7(agentPath);
8936
8932
  if (agentStat.isDirectory() && !agentStat.isSymbolicLink())
@@ -8953,7 +8949,7 @@ async function readTextIfExists(path) {
8953
8949
  throw error;
8954
8950
  }
8955
8951
  }
8956
- async function exists3(path) {
8952
+ async function exists2(path) {
8957
8953
  try {
8958
8954
  await lstat7(path);
8959
8955
  return true;
@@ -8973,7 +8969,7 @@ function nodeErrorCode(error) {
8973
8969
  var MANIFEST_FILE = ".installed-agents.json";
8974
8970
  async function capturePreservedAgentReasoning(input) {
8975
8971
  const agentsDir = join20(input.codexHome, "agents");
8976
- if (!await exists4(agentsDir))
8972
+ if (!await exists3(agentsDir))
8977
8973
  return new Map;
8978
8974
  const preserved = new Map;
8979
8975
  const agentEntries = await readdir6(agentsDir, { withFileTypes: true });
@@ -8991,7 +8987,7 @@ async function capturePreservedAgentReasoning(input) {
8991
8987
  }
8992
8988
  async function capturePreservedAgentServiceTier(input) {
8993
8989
  const agentsDir = join20(input.codexHome, "agents");
8994
- if (!await exists4(agentsDir))
8990
+ if (!await exists3(agentsDir))
8995
8991
  return new Map;
8996
8992
  const preserved = new Map;
8997
8993
  const agentEntries = await readdir6(agentsDir, { withFileTypes: true });
@@ -9049,7 +9045,7 @@ async function restorePreservedServiceTier(input) {
9049
9045
  }
9050
9046
  async function discoverBundledAgents(pluginRoot) {
9051
9047
  const componentsRoot = join20(pluginRoot, "components");
9052
- if (!await exists4(componentsRoot))
9048
+ if (!await exists3(componentsRoot))
9053
9049
  return [];
9054
9050
  const componentEntries = await readdir6(componentsRoot, { withFileTypes: true });
9055
9051
  const agents = [];
@@ -9057,13 +9053,13 @@ async function discoverBundledAgents(pluginRoot) {
9057
9053
  if (!entry.isDirectory())
9058
9054
  continue;
9059
9055
  const agentsRoot = join20(componentsRoot, entry.name, "agents");
9060
- if (!await exists4(agentsRoot))
9056
+ if (!await exists3(agentsRoot))
9061
9057
  continue;
9062
9058
  const agentEntries = await readdir6(agentsRoot, { withFileTypes: true });
9063
- for (const file2 of agentEntries) {
9064
- if (!file2.isFile() || !file2.name.endsWith(".toml"))
9059
+ for (const file of agentEntries) {
9060
+ if (!file.isFile() || !file.name.endsWith(".toml"))
9065
9061
  continue;
9066
- agents.push(join20(agentsRoot, file2.name));
9062
+ agents.push(join20(agentsRoot, file.name));
9067
9063
  }
9068
9064
  }
9069
9065
  agents.sort();
@@ -9074,7 +9070,7 @@ async function replaceWithCopy(linkPath, target) {
9074
9070
  await copyFile(target, linkPath);
9075
9071
  }
9076
9072
  async function prepareReplacement(linkPath) {
9077
- if (!await exists4(linkPath))
9073
+ if (!await exists3(linkPath))
9078
9074
  return;
9079
9075
  const entryStat = await lstat8(linkPath);
9080
9076
  if (entryStat.isDirectory() && !entryStat.isSymbolicLink()) {
@@ -9193,7 +9189,7 @@ function parseJsonString(value) {
9193
9189
  return null;
9194
9190
  }
9195
9191
  }
9196
- async function exists4(path) {
9192
+ async function exists3(path) {
9197
9193
  try {
9198
9194
  await lstat8(path);
9199
9195
  return true;
@@ -9607,7 +9603,7 @@ async function findProjectLocalCodexConfigs(startDirectory, codexHome) {
9607
9603
  configPathsFromCwd.push(configPath);
9608
9604
  }
9609
9605
  }
9610
- if (await exists5(join24(current, ".git"))) {
9606
+ if (await exists4(join24(current, ".git"))) {
9611
9607
  return configPathsFromCwd.length === 0 ? null : {
9612
9608
  projectRoot: current,
9613
9609
  configPaths: [...configPathsFromCwd].reverse(),
@@ -9688,7 +9684,7 @@ async function maybeLstat(path) {
9688
9684
  throw error;
9689
9685
  }
9690
9686
  }
9691
- async function exists5(path) {
9687
+ async function exists4(path) {
9692
9688
  return await maybeLstat(path) !== null;
9693
9689
  }
9694
9690
  function nodeErrorCode3(error) {
@@ -9826,3815 +9822,124 @@ async function seedAndMigrateOmoSot(input) {
9826
9822
  // packages/omo-codex/src/install/install-ast-grep-sg.ts
9827
9823
  import { join as join29 } from "node:path";
9828
9824
 
9829
- // packages/utils/src/deep-merge.ts
9830
- var DANGEROUS_KEYS = new Set(["__proto__", "constructor", "prototype"]);
9831
- // packages/utils/src/record-type-guard.ts
9832
- function isRecord(value) {
9833
- return typeof value === "object" && value !== null;
9834
- }
9835
- // node_modules/.bun/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
9836
- /*! js-yaml 4.2.0 https://github.com/nodeca/js-yaml @license MIT */
9837
- var __create = Object.create;
9838
- var __defProp2 = Object.defineProperty;
9839
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9840
- var __getOwnPropNames = Object.getOwnPropertyNames;
9841
- var __getProtoOf = Object.getPrototypeOf;
9842
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9843
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9844
- var __copyProps = (to, from, except, desc) => {
9845
- if (from && typeof from === "object" || typeof from === "function")
9846
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key;i < n; i++) {
9847
- key = keys[i];
9848
- if (!__hasOwnProp.call(to, key) && key !== except)
9849
- __defProp2(to, key, {
9850
- get: ((k) => from[k]).bind(null, key),
9851
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9852
- });
9853
- }
9854
- return to;
9855
- };
9856
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", {
9857
- value: mod,
9858
- enumerable: true
9859
- }) : target, mod));
9860
- var require_common = /* @__PURE__ */ __commonJSMin((exports, module) => {
9861
- function isNothing(subject) {
9862
- return typeof subject === "undefined" || subject === null;
9863
- }
9864
- function isObject(subject) {
9865
- return typeof subject === "object" && subject !== null;
9866
- }
9867
- function toArray(sequence) {
9868
- if (Array.isArray(sequence))
9869
- return sequence;
9870
- else if (isNothing(sequence))
9871
- return [];
9872
- return [sequence];
9873
- }
9874
- function extend(target, source) {
9875
- if (source) {
9876
- const sourceKeys = Object.keys(source);
9877
- for (let index = 0, length = sourceKeys.length;index < length; index += 1) {
9878
- const key = sourceKeys[index];
9879
- target[key] = source[key];
9880
- }
9881
- }
9882
- return target;
9883
- }
9884
- function repeat(string, count) {
9885
- let result = "";
9886
- for (let cycle = 0;cycle < count; cycle += 1)
9887
- result += string;
9888
- return result;
9889
- }
9890
- function isNegativeZero(number) {
9891
- return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
9892
- }
9893
- module.exports.isNothing = isNothing;
9894
- module.exports.isObject = isObject;
9895
- module.exports.toArray = toArray;
9896
- module.exports.repeat = repeat;
9897
- module.exports.isNegativeZero = isNegativeZero;
9898
- module.exports.extend = extend;
9899
- });
9900
- var require_exception = /* @__PURE__ */ __commonJSMin((exports, module) => {
9901
- function formatError(exception, compact) {
9902
- let where = "";
9903
- const message = exception.reason || "(unknown reason)";
9904
- if (!exception.mark)
9905
- return message;
9906
- if (exception.mark.name)
9907
- where += 'in "' + exception.mark.name + '" ';
9908
- where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
9909
- if (!compact && exception.mark.snippet)
9910
- where += `
9911
-
9912
- ` + exception.mark.snippet;
9913
- return message + " " + where;
9914
- }
9915
- function YAMLException(reason, mark) {
9916
- Error.call(this);
9917
- this.name = "YAMLException";
9918
- this.reason = reason;
9919
- this.mark = mark;
9920
- this.message = formatError(this, false);
9921
- if (Error.captureStackTrace)
9922
- Error.captureStackTrace(this, this.constructor);
9923
- else
9924
- this.stack = (/* @__PURE__ */ new Error()).stack || "";
9925
- }
9926
- YAMLException.prototype = Object.create(Error.prototype);
9927
- YAMLException.prototype.constructor = YAMLException;
9928
- YAMLException.prototype.toString = function toString(compact) {
9929
- return this.name + ": " + formatError(this, compact);
9930
- };
9931
- module.exports = YAMLException;
9932
- });
9933
- var require_snippet = /* @__PURE__ */ __commonJSMin((exports, module) => {
9934
- var common = require_common();
9935
- function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
9936
- let head = "";
9937
- let tail = "";
9938
- const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
9939
- if (position - lineStart > maxHalfLength) {
9940
- head = " ... ";
9941
- lineStart = position - maxHalfLength + head.length;
9942
- }
9943
- if (lineEnd - position > maxHalfLength) {
9944
- tail = " ...";
9945
- lineEnd = position + maxHalfLength - tail.length;
9946
- }
9947
- return {
9948
- str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
9949
- pos: position - lineStart + head.length
9950
- };
9951
- }
9952
- function padStart(string, max) {
9953
- return common.repeat(" ", max - string.length) + string;
9954
- }
9955
- function makeSnippet(mark, options) {
9956
- options = Object.create(options || null);
9957
- if (!mark.buffer)
9958
- return null;
9959
- if (!options.maxLength)
9960
- options.maxLength = 79;
9961
- if (typeof options.indent !== "number")
9962
- options.indent = 1;
9963
- if (typeof options.linesBefore !== "number")
9964
- options.linesBefore = 3;
9965
- if (typeof options.linesAfter !== "number")
9966
- options.linesAfter = 2;
9967
- const re = /\r?\n|\r|\0/g;
9968
- const lineStarts = [0];
9969
- const lineEnds = [];
9970
- let match;
9971
- let foundLineNo = -1;
9972
- while (match = re.exec(mark.buffer)) {
9973
- lineEnds.push(match.index);
9974
- lineStarts.push(match.index + match[0].length);
9975
- if (mark.position <= match.index && foundLineNo < 0)
9976
- foundLineNo = lineStarts.length - 2;
9977
- }
9978
- if (foundLineNo < 0)
9979
- foundLineNo = lineStarts.length - 1;
9980
- let result = "";
9981
- const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
9982
- const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
9983
- for (let i = 1;i <= options.linesBefore; i++) {
9984
- if (foundLineNo - i < 0)
9985
- break;
9986
- const line2 = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
9987
- result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line2.str + `
9988
- ` + result;
9989
- }
9990
- const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
9991
- result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
9992
- `;
9993
- result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + `^
9994
- `;
9995
- for (let i = 1;i <= options.linesAfter; i++) {
9996
- if (foundLineNo + i >= lineEnds.length)
9997
- break;
9998
- const line2 = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
9999
- result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line2.str + `
10000
- `;
10001
- }
10002
- return result.replace(/\n$/, "");
10003
- }
10004
- module.exports = makeSnippet;
10005
- });
10006
- var require_type = /* @__PURE__ */ __commonJSMin((exports, module) => {
10007
- var YAMLException = require_exception();
10008
- var TYPE_CONSTRUCTOR_OPTIONS = [
10009
- "kind",
10010
- "multi",
10011
- "resolve",
10012
- "construct",
10013
- "instanceOf",
10014
- "predicate",
10015
- "represent",
10016
- "representName",
10017
- "defaultStyle",
10018
- "styleAliases"
10019
- ];
10020
- var YAML_NODE_KINDS = [
10021
- "scalar",
10022
- "sequence",
10023
- "mapping"
10024
- ];
10025
- function compileStyleAliases(map) {
10026
- const result = {};
10027
- if (map !== null)
10028
- Object.keys(map).forEach(function(style) {
10029
- map[style].forEach(function(alias) {
10030
- result[String(alias)] = style;
10031
- });
10032
- });
10033
- return result;
10034
- }
10035
- function Type(tag, options) {
10036
- options = options || {};
10037
- Object.keys(options).forEach(function(name) {
10038
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1)
10039
- throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
10040
- });
10041
- this.options = options;
10042
- this.tag = tag;
10043
- this.kind = options["kind"] || null;
10044
- this.resolve = options["resolve"] || function() {
10045
- return true;
10046
- };
10047
- this.construct = options["construct"] || function(data) {
10048
- return data;
10049
- };
10050
- this.instanceOf = options["instanceOf"] || null;
10051
- this.predicate = options["predicate"] || null;
10052
- this.represent = options["represent"] || null;
10053
- this.representName = options["representName"] || null;
10054
- this.defaultStyle = options["defaultStyle"] || null;
10055
- this.multi = options["multi"] || false;
10056
- this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
10057
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1)
10058
- throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
10059
- }
10060
- module.exports = Type;
10061
- });
10062
- var require_schema = /* @__PURE__ */ __commonJSMin((exports, module) => {
10063
- var YAMLException = require_exception();
10064
- var Type = require_type();
10065
- function compileList(schema, name) {
10066
- const result = [];
10067
- schema[name].forEach(function(currentType) {
10068
- let newIndex = result.length;
10069
- result.forEach(function(previousType, previousIndex) {
10070
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi)
10071
- newIndex = previousIndex;
10072
- });
10073
- result[newIndex] = currentType;
10074
- });
10075
- return result;
10076
- }
10077
- function compileMap() {
10078
- const result = {
10079
- scalar: {},
10080
- sequence: {},
10081
- mapping: {},
10082
- fallback: {},
10083
- multi: {
10084
- scalar: [],
10085
- sequence: [],
10086
- mapping: [],
10087
- fallback: []
10088
- }
9825
+ // packages/utils/src/ast-grep/sg-manifest.ts
9826
+ function normalizeRuntimePlatform(platform = process.platform) {
9827
+ if (platform === "darwin" || platform === "linux" || platform === "win32")
9828
+ return platform;
9829
+ return "linux";
9830
+ }
9831
+ function normalizeRuntimeArch(arch = process.arch) {
9832
+ if (arch === "arm64" || arch === "aarch64")
9833
+ return "arm64";
9834
+ return "x64";
9835
+ }
9836
+ function runtimeSlug(platform = process.platform, arch = process.arch) {
9837
+ return `${normalizeRuntimePlatform(platform)}-${normalizeRuntimeArch(arch)}`;
9838
+ }
9839
+
9840
+ // packages/utils/src/ast-grep/install-script.ts
9841
+ import { spawn as spawn2 } from "node:child_process";
9842
+ import { existsSync as existsSync4 } from "node:fs";
9843
+ import { join as join28 } from "node:path";
9844
+ var AST_GREP_BIN_DIR_ENV_KEY = "OMO_AST_GREP_BIN_DIR";
9845
+ var AST_GREP_INSTALL_TIMEOUT_MS = 30000;
9846
+ function astGrepRuntimeDir(baseDir, platform = process.platform, arch = process.arch) {
9847
+ return join28(baseDir, "runtime", "ast-grep", runtimeSlug(platform, arch));
9848
+ }
9849
+ function isMissingExecutable(error) {
9850
+ if (!("code" in error))
9851
+ return false;
9852
+ return error.code === "ENOENT";
9853
+ }
9854
+ function defaultSpawnProcess(command, args, options) {
9855
+ const child = spawn2(command, args, {
9856
+ cwd: options.cwd,
9857
+ env: options.env,
9858
+ stdio: "ignore",
9859
+ windowsHide: true
9860
+ });
9861
+ let settled = false;
9862
+ const outcome = new Promise((resolve9) => {
9863
+ const settle = (result) => {
9864
+ if (settled)
9865
+ return;
9866
+ settled = true;
9867
+ resolve9(result);
10089
9868
  };
10090
- function collectType(type) {
10091
- if (type.multi) {
10092
- result.multi[type.kind].push(type);
10093
- result.multi["fallback"].push(type);
10094
- } else
10095
- result[type.kind][type.tag] = result["fallback"][type.tag] = type;
10096
- }
10097
- for (let index = 0, length = arguments.length;index < length; index += 1)
10098
- arguments[index].forEach(collectType);
10099
- return result;
10100
- }
10101
- function Schema(definition) {
10102
- return this.extend(definition);
10103
- }
10104
- Schema.prototype.extend = function extend(definition) {
10105
- let implicit = [];
10106
- let explicit = [];
10107
- if (definition instanceof Type)
10108
- explicit.push(definition);
10109
- else if (Array.isArray(definition))
10110
- explicit = explicit.concat(definition);
10111
- else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
10112
- if (definition.implicit)
10113
- implicit = implicit.concat(definition.implicit);
10114
- if (definition.explicit)
10115
- explicit = explicit.concat(definition.explicit);
10116
- } else
10117
- throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
10118
- implicit.forEach(function(type) {
10119
- if (!(type instanceof Type))
10120
- throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
10121
- if (type.loadKind && type.loadKind !== "scalar")
10122
- throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
10123
- if (type.multi)
10124
- throw new YAMLException("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
9869
+ child.once("error", (error) => {
9870
+ settle({ kind: "spawn-error", error, missingExecutable: isMissingExecutable(error) });
10125
9871
  });
10126
- explicit.forEach(function(type) {
10127
- if (!(type instanceof Type))
10128
- throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
9872
+ child.once("exit", (code, signal) => {
9873
+ settle({ kind: "exit", code, signal });
10129
9874
  });
10130
- const result = Object.create(Schema.prototype);
10131
- result.implicit = (this.implicit || []).concat(implicit);
10132
- result.explicit = (this.explicit || []).concat(explicit);
10133
- result.compiledImplicit = compileList(result, "implicit");
10134
- result.compiledExplicit = compileList(result, "explicit");
10135
- result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
10136
- return result;
10137
- };
10138
- module.exports = Schema;
10139
- });
10140
- var require_str = /* @__PURE__ */ __commonJSMin((exports, module) => {
10141
- module.exports = new (require_type())("tag:yaml.org,2002:str", {
10142
- kind: "scalar",
10143
- construct: function(data) {
10144
- return data !== null ? data : "";
10145
- }
10146
- });
10147
- });
10148
- var require_seq = /* @__PURE__ */ __commonJSMin((exports, module) => {
10149
- module.exports = new (require_type())("tag:yaml.org,2002:seq", {
10150
- kind: "sequence",
10151
- construct: function(data) {
10152
- return data !== null ? data : [];
10153
- }
10154
- });
10155
- });
10156
- var require_map = /* @__PURE__ */ __commonJSMin((exports, module) => {
10157
- module.exports = new (require_type())("tag:yaml.org,2002:map", {
10158
- kind: "mapping",
10159
- construct: function(data) {
10160
- return data !== null ? data : {};
10161
- }
10162
- });
10163
- });
10164
- var require_failsafe = /* @__PURE__ */ __commonJSMin((exports, module) => {
10165
- module.exports = new (require_schema())({ explicit: [
10166
- require_str(),
10167
- require_seq(),
10168
- require_map()
10169
- ] });
10170
- });
10171
- var require_null = /* @__PURE__ */ __commonJSMin((exports, module) => {
10172
- var Type = require_type();
10173
- function resolveYamlNull(data) {
10174
- if (data === null)
10175
- return true;
10176
- const max = data.length;
10177
- return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
10178
- }
10179
- function constructYamlNull() {
10180
- return null;
10181
- }
10182
- function isNull(object) {
10183
- return object === null;
10184
- }
10185
- module.exports = new Type("tag:yaml.org,2002:null", {
10186
- kind: "scalar",
10187
- resolve: resolveYamlNull,
10188
- construct: constructYamlNull,
10189
- predicate: isNull,
10190
- represent: {
10191
- canonical: function() {
10192
- return "~";
10193
- },
10194
- lowercase: function() {
10195
- return "null";
10196
- },
10197
- uppercase: function() {
10198
- return "NULL";
10199
- },
10200
- camelcase: function() {
10201
- return "Null";
10202
- },
10203
- empty: function() {
10204
- return "";
10205
- }
10206
- },
10207
- defaultStyle: "lowercase"
10208
9875
  });
10209
- });
10210
- var require_bool = /* @__PURE__ */ __commonJSMin((exports, module) => {
10211
- var Type = require_type();
10212
- function resolveYamlBoolean(data) {
10213
- if (data === null)
10214
- return false;
10215
- const max = data.length;
10216
- return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
10217
- }
10218
- function constructYamlBoolean(data) {
10219
- return data === "true" || data === "True" || data === "TRUE";
10220
- }
10221
- function isBoolean(object) {
10222
- return Object.prototype.toString.call(object) === "[object Boolean]";
10223
- }
10224
- module.exports = new Type("tag:yaml.org,2002:bool", {
10225
- kind: "scalar",
10226
- resolve: resolveYamlBoolean,
10227
- construct: constructYamlBoolean,
10228
- predicate: isBoolean,
10229
- represent: {
10230
- lowercase: function(object) {
10231
- return object ? "true" : "false";
10232
- },
10233
- uppercase: function(object) {
10234
- return object ? "TRUE" : "FALSE";
10235
- },
10236
- camelcase: function(object) {
10237
- return object ? "True" : "False";
10238
- }
9876
+ return {
9877
+ kill: () => {
9878
+ if (!child.killed)
9879
+ child.kill();
10239
9880
  },
10240
- defaultStyle: "lowercase"
10241
- });
10242
- });
10243
- var require_int = /* @__PURE__ */ __commonJSMin((exports, module) => {
10244
- var common = require_common();
10245
- var Type = require_type();
10246
- function isHexCode(c) {
10247
- return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
10248
- }
10249
- function isOctCode(c) {
10250
- return c >= 48 && c <= 55;
10251
- }
10252
- function isDecCode(c) {
10253
- return c >= 48 && c <= 57;
9881
+ outcome
9882
+ };
9883
+ }
9884
+ function scriptPathForPlatform(skillDir, platform) {
9885
+ return join28(skillDir, platform === "win32" ? "install.ps1" : "install.sh");
9886
+ }
9887
+ function invocationsForPlatform(scriptPath, platform) {
9888
+ if (platform !== "win32")
9889
+ return [{ command: "bash", args: [scriptPath] }];
9890
+ const args = ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", scriptPath];
9891
+ return [{ command: "pwsh", args }, { command: "powershell.exe", args }];
9892
+ }
9893
+ async function runInvocation(input) {
9894
+ const child = input.spawnProcess(input.invocation.command, input.invocation.args, { cwd: input.skillDir, env: input.env });
9895
+ let timedOut = false;
9896
+ const timeout = setTimeout(() => {
9897
+ timedOut = true;
9898
+ child.kill();
9899
+ }, input.timeoutMs);
9900
+ timeout.unref?.();
9901
+ try {
9902
+ const outcome = await child.outcome;
9903
+ return timedOut ? { kind: "timed-out" } : outcome;
9904
+ } finally {
9905
+ clearTimeout(timeout);
10254
9906
  }
10255
- function resolveYamlInteger(data) {
10256
- if (data === null)
10257
- return false;
10258
- const max = data.length;
10259
- let index = 0;
10260
- let hasDigits = false;
10261
- if (!max)
10262
- return false;
10263
- let ch = data[index];
10264
- if (ch === "-" || ch === "+")
10265
- ch = data[++index];
10266
- if (ch === "0") {
10267
- if (index + 1 === max)
10268
- return true;
10269
- ch = data[++index];
10270
- if (ch === "b") {
10271
- index++;
10272
- for (;index < max; index++) {
10273
- ch = data[index];
10274
- if (ch !== "0" && ch !== "1")
10275
- return false;
10276
- hasDigits = true;
10277
- }
10278
- return hasDigits && Number.isFinite(parseYamlInteger(data));
10279
- }
10280
- if (ch === "x") {
10281
- index++;
10282
- for (;index < max; index++) {
10283
- if (!isHexCode(data.charCodeAt(index)))
10284
- return false;
10285
- hasDigits = true;
10286
- }
10287
- return hasDigits && Number.isFinite(parseYamlInteger(data));
10288
- }
10289
- if (ch === "o") {
10290
- index++;
10291
- for (;index < max; index++) {
10292
- if (!isOctCode(data.charCodeAt(index)))
10293
- return false;
10294
- hasDigits = true;
10295
- }
10296
- return hasDigits && Number.isFinite(parseYamlInteger(data));
10297
- }
10298
- }
10299
- for (;index < max; index++) {
10300
- if (!isDecCode(data.charCodeAt(index)))
10301
- return false;
10302
- hasDigits = true;
10303
- }
10304
- if (!hasDigits)
10305
- return false;
10306
- return Number.isFinite(parseYamlInteger(data));
10307
- }
10308
- function parseYamlInteger(data) {
10309
- let value = data;
10310
- let sign = 1;
10311
- let ch = value[0];
10312
- if (ch === "-" || ch === "+") {
10313
- if (ch === "-")
10314
- sign = -1;
10315
- value = value.slice(1);
10316
- ch = value[0];
10317
- }
10318
- if (value === "0")
10319
- return 0;
10320
- if (ch === "0") {
10321
- if (value[1] === "b")
10322
- return sign * parseInt(value.slice(2), 2);
10323
- if (value[1] === "x")
10324
- return sign * parseInt(value.slice(2), 16);
10325
- if (value[1] === "o")
10326
- return sign * parseInt(value.slice(2), 8);
10327
- }
10328
- return sign * parseInt(value, 10);
10329
- }
10330
- function constructYamlInteger(data) {
10331
- return parseYamlInteger(data);
10332
- }
10333
- function isInteger(object) {
10334
- return Object.prototype.toString.call(object) === "[object Number]" && object % 1 === 0 && !common.isNegativeZero(object);
10335
- }
10336
- module.exports = new Type("tag:yaml.org,2002:int", {
10337
- kind: "scalar",
10338
- resolve: resolveYamlInteger,
10339
- construct: constructYamlInteger,
10340
- predicate: isInteger,
10341
- represent: {
10342
- binary: function(obj) {
10343
- return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
10344
- },
10345
- octal: function(obj) {
10346
- return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
10347
- },
10348
- decimal: function(obj) {
10349
- return obj.toString(10);
10350
- },
10351
- hexadecimal: function(obj) {
10352
- return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
9907
+ }
9908
+ function failedReason(outcome) {
9909
+ return outcome.error.message;
9910
+ }
9911
+ async function runAstGrepSkillInstall(options) {
9912
+ const platform = options.platform ?? process.platform;
9913
+ const fileExists = options.fileExists ?? existsSync4;
9914
+ const scriptPath = scriptPathForPlatform(options.skillDir, platform);
9915
+ if (!fileExists(scriptPath))
9916
+ return { kind: "skipped", reason: `missing ${scriptPath}` };
9917
+ const env = { ...options.env ?? process.env, [AST_GREP_BIN_DIR_ENV_KEY]: options.targetDir };
9918
+ const spawnProcess = options.spawnProcess ?? defaultSpawnProcess;
9919
+ const timeoutMs = options.timeoutMs ?? AST_GREP_INSTALL_TIMEOUT_MS;
9920
+ const invocations = invocationsForPlatform(scriptPath, platform);
9921
+ try {
9922
+ for (const invocation of invocations) {
9923
+ const outcome = await runInvocation({ env, invocation, skillDir: options.skillDir, spawnProcess, timeoutMs });
9924
+ if (outcome.kind === "timed-out")
9925
+ return { kind: "timed-out" };
9926
+ if (outcome.kind === "exit") {
9927
+ if (outcome.code === 0)
9928
+ return { kind: "succeeded" };
9929
+ return { kind: "failed", reason: `${invocation.command} exited ${outcome.code ?? outcome.signal ?? "without status"}` };
10353
9930
  }
10354
- },
10355
- defaultStyle: "decimal",
10356
- styleAliases: {
10357
- binary: [2, "bin"],
10358
- octal: [8, "oct"],
10359
- decimal: [10, "dec"],
10360
- hexadecimal: [16, "hex"]
9931
+ if (platform === "win32" && outcome.missingExecutable && invocation.command === "pwsh")
9932
+ continue;
9933
+ return { kind: "failed", reason: failedReason(outcome) };
10361
9934
  }
10362
- });
10363
- });
10364
- var require_float = /* @__PURE__ */ __commonJSMin((exports, module) => {
10365
- var common = require_common();
10366
- var Type = require_type();
10367
- var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
10368
- var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
10369
- function resolveYamlFloat(data) {
10370
- if (data === null)
10371
- return false;
10372
- if (!YAML_FLOAT_PATTERN.test(data))
10373
- return false;
10374
- if (Number.isFinite(parseFloat(data, 10)))
10375
- return true;
10376
- return YAML_FLOAT_SPECIAL_PATTERN.test(data);
10377
- }
10378
- function constructYamlFloat(data) {
10379
- let value = data.toLowerCase();
10380
- const sign = value[0] === "-" ? -1 : 1;
10381
- if ("+-".indexOf(value[0]) >= 0)
10382
- value = value.slice(1);
10383
- if (value === ".inf")
10384
- return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
10385
- else if (value === ".nan")
10386
- return NaN;
10387
- return sign * parseFloat(value, 10);
10388
- }
10389
- var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
10390
- function representYamlFloat(object, style) {
10391
- if (isNaN(object))
10392
- switch (style) {
10393
- case "lowercase":
10394
- return ".nan";
10395
- case "uppercase":
10396
- return ".NAN";
10397
- case "camelcase":
10398
- return ".NaN";
10399
- }
10400
- else if (Number.POSITIVE_INFINITY === object)
10401
- switch (style) {
10402
- case "lowercase":
10403
- return ".inf";
10404
- case "uppercase":
10405
- return ".INF";
10406
- case "camelcase":
10407
- return ".Inf";
10408
- }
10409
- else if (Number.NEGATIVE_INFINITY === object)
10410
- switch (style) {
10411
- case "lowercase":
10412
- return "-.inf";
10413
- case "uppercase":
10414
- return "-.INF";
10415
- case "camelcase":
10416
- return "-.Inf";
10417
- }
10418
- else if (common.isNegativeZero(object))
10419
- return "-0.0";
10420
- const res = object.toString(10);
10421
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
10422
- }
10423
- function isFloat(object) {
10424
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
10425
- }
10426
- module.exports = new Type("tag:yaml.org,2002:float", {
10427
- kind: "scalar",
10428
- resolve: resolveYamlFloat,
10429
- construct: constructYamlFloat,
10430
- predicate: isFloat,
10431
- represent: representYamlFloat,
10432
- defaultStyle: "lowercase"
10433
- });
10434
- });
10435
- var require_json = /* @__PURE__ */ __commonJSMin((exports, module) => {
10436
- module.exports = require_failsafe().extend({ implicit: [
10437
- require_null(),
10438
- require_bool(),
10439
- require_int(),
10440
- require_float()
10441
- ] });
10442
- });
10443
- var require_core = /* @__PURE__ */ __commonJSMin((exports, module) => {
10444
- module.exports = require_json();
10445
- });
10446
- var require_timestamp = /* @__PURE__ */ __commonJSMin((exports, module) => {
10447
- var Type = require_type();
10448
- var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
10449
- var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
10450
- function resolveYamlTimestamp(data) {
10451
- if (data === null)
10452
- return false;
10453
- if (YAML_DATE_REGEXP.exec(data) !== null)
10454
- return true;
10455
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
10456
- return true;
10457
- return false;
10458
- }
10459
- function constructYamlTimestamp(data) {
10460
- let fraction = 0;
10461
- let delta = null;
10462
- let match = YAML_DATE_REGEXP.exec(data);
10463
- if (match === null)
10464
- match = YAML_TIMESTAMP_REGEXP.exec(data);
10465
- if (match === null)
10466
- throw new Error("Date resolve error");
10467
- const year = +match[1];
10468
- const month = +match[2] - 1;
10469
- const day = +match[3];
10470
- if (!match[4])
10471
- return new Date(Date.UTC(year, month, day));
10472
- const hour = +match[4];
10473
- const minute = +match[5];
10474
- const second = +match[6];
10475
- if (match[7]) {
10476
- fraction = match[7].slice(0, 3);
10477
- while (fraction.length < 3)
10478
- fraction += "0";
10479
- fraction = +fraction;
10480
- }
10481
- if (match[9]) {
10482
- const tzHour = +match[10];
10483
- const tzMinute = +(match[11] || 0);
10484
- delta = (tzHour * 60 + tzMinute) * 60000;
10485
- if (match[9] === "-")
10486
- delta = -delta;
10487
- }
10488
- const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
10489
- if (delta)
10490
- date.setTime(date.getTime() - delta);
10491
- return date;
10492
- }
10493
- function representYamlTimestamp(object) {
10494
- return object.toISOString();
10495
- }
10496
- module.exports = new Type("tag:yaml.org,2002:timestamp", {
10497
- kind: "scalar",
10498
- resolve: resolveYamlTimestamp,
10499
- construct: constructYamlTimestamp,
10500
- instanceOf: Date,
10501
- represent: representYamlTimestamp
10502
- });
10503
- });
10504
- var require_merge = /* @__PURE__ */ __commonJSMin((exports, module) => {
10505
- var Type = require_type();
10506
- function resolveYamlMerge(data) {
10507
- return data === "<<" || data === null;
10508
- }
10509
- module.exports = new Type("tag:yaml.org,2002:merge", {
10510
- kind: "scalar",
10511
- resolve: resolveYamlMerge
10512
- });
10513
- });
10514
- var require_binary = /* @__PURE__ */ __commonJSMin((exports, module) => {
10515
- var Type = require_type();
10516
- var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
10517
- \r`;
10518
- function resolveYamlBinary(data) {
10519
- if (data === null)
10520
- return false;
10521
- let bitlen = 0;
10522
- const max = data.length;
10523
- const map = BASE64_MAP;
10524
- for (let idx = 0;idx < max; idx++) {
10525
- const code = map.indexOf(data.charAt(idx));
10526
- if (code > 64)
10527
- continue;
10528
- if (code < 0)
10529
- return false;
10530
- bitlen += 6;
10531
- }
10532
- return bitlen % 8 === 0;
10533
- }
10534
- function constructYamlBinary(data) {
10535
- const input = data.replace(/[\r\n=]/g, "");
10536
- const max = input.length;
10537
- const map = BASE64_MAP;
10538
- let bits = 0;
10539
- const result = [];
10540
- for (let idx = 0;idx < max; idx++) {
10541
- if (idx % 4 === 0 && idx) {
10542
- result.push(bits >> 16 & 255);
10543
- result.push(bits >> 8 & 255);
10544
- result.push(bits & 255);
10545
- }
10546
- bits = bits << 6 | map.indexOf(input.charAt(idx));
10547
- }
10548
- const tailbits = max % 4 * 6;
10549
- if (tailbits === 0) {
10550
- result.push(bits >> 16 & 255);
10551
- result.push(bits >> 8 & 255);
10552
- result.push(bits & 255);
10553
- } else if (tailbits === 18) {
10554
- result.push(bits >> 10 & 255);
10555
- result.push(bits >> 2 & 255);
10556
- } else if (tailbits === 12)
10557
- result.push(bits >> 4 & 255);
10558
- return new Uint8Array(result);
10559
- }
10560
- function representYamlBinary(object) {
10561
- let result = "";
10562
- let bits = 0;
10563
- const max = object.length;
10564
- const map = BASE64_MAP;
10565
- for (let idx = 0;idx < max; idx++) {
10566
- if (idx % 3 === 0 && idx) {
10567
- result += map[bits >> 18 & 63];
10568
- result += map[bits >> 12 & 63];
10569
- result += map[bits >> 6 & 63];
10570
- result += map[bits & 63];
10571
- }
10572
- bits = (bits << 8) + object[idx];
10573
- }
10574
- const tail = max % 3;
10575
- if (tail === 0) {
10576
- result += map[bits >> 18 & 63];
10577
- result += map[bits >> 12 & 63];
10578
- result += map[bits >> 6 & 63];
10579
- result += map[bits & 63];
10580
- } else if (tail === 2) {
10581
- result += map[bits >> 10 & 63];
10582
- result += map[bits >> 4 & 63];
10583
- result += map[bits << 2 & 63];
10584
- result += map[64];
10585
- } else if (tail === 1) {
10586
- result += map[bits >> 2 & 63];
10587
- result += map[bits << 4 & 63];
10588
- result += map[64];
10589
- result += map[64];
10590
- }
10591
- return result;
10592
- }
10593
- function isBinary(obj) {
10594
- return Object.prototype.toString.call(obj) === "[object Uint8Array]";
10595
- }
10596
- module.exports = new Type("tag:yaml.org,2002:binary", {
10597
- kind: "scalar",
10598
- resolve: resolveYamlBinary,
10599
- construct: constructYamlBinary,
10600
- predicate: isBinary,
10601
- represent: representYamlBinary
10602
- });
10603
- });
10604
- var require_omap = /* @__PURE__ */ __commonJSMin((exports, module) => {
10605
- var Type = require_type();
10606
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
10607
- var _toString = Object.prototype.toString;
10608
- function resolveYamlOmap(data) {
10609
- if (data === null)
10610
- return true;
10611
- const objectKeys = [];
10612
- const object = data;
10613
- for (let index = 0, length = object.length;index < length; index += 1) {
10614
- const pair = object[index];
10615
- let pairHasKey = false;
10616
- if (_toString.call(pair) !== "[object Object]")
10617
- return false;
10618
- let pairKey;
10619
- for (pairKey in pair)
10620
- if (_hasOwnProperty.call(pair, pairKey))
10621
- if (!pairHasKey)
10622
- pairHasKey = true;
10623
- else
10624
- return false;
10625
- if (!pairHasKey)
10626
- return false;
10627
- if (objectKeys.indexOf(pairKey) === -1)
10628
- objectKeys.push(pairKey);
10629
- else
10630
- return false;
10631
- }
10632
- return true;
10633
- }
10634
- function constructYamlOmap(data) {
10635
- return data !== null ? data : [];
10636
- }
10637
- module.exports = new Type("tag:yaml.org,2002:omap", {
10638
- kind: "sequence",
10639
- resolve: resolveYamlOmap,
10640
- construct: constructYamlOmap
10641
- });
10642
- });
10643
- var require_pairs = /* @__PURE__ */ __commonJSMin((exports, module) => {
10644
- var Type = require_type();
10645
- var _toString = Object.prototype.toString;
10646
- function resolveYamlPairs(data) {
10647
- if (data === null)
10648
- return true;
10649
- const object = data;
10650
- const result = new Array(object.length);
10651
- for (let index = 0, length = object.length;index < length; index += 1) {
10652
- const pair = object[index];
10653
- if (_toString.call(pair) !== "[object Object]")
10654
- return false;
10655
- const keys = Object.keys(pair);
10656
- if (keys.length !== 1)
10657
- return false;
10658
- result[index] = [keys[0], pair[keys[0]]];
10659
- }
10660
- return true;
10661
- }
10662
- function constructYamlPairs(data) {
10663
- if (data === null)
10664
- return [];
10665
- const object = data;
10666
- const result = new Array(object.length);
10667
- for (let index = 0, length = object.length;index < length; index += 1) {
10668
- const pair = object[index];
10669
- const keys = Object.keys(pair);
10670
- result[index] = [keys[0], pair[keys[0]]];
10671
- }
10672
- return result;
10673
- }
10674
- module.exports = new Type("tag:yaml.org,2002:pairs", {
10675
- kind: "sequence",
10676
- resolve: resolveYamlPairs,
10677
- construct: constructYamlPairs
10678
- });
10679
- });
10680
- var require_set = /* @__PURE__ */ __commonJSMin((exports, module) => {
10681
- var Type = require_type();
10682
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
10683
- function resolveYamlSet(data) {
10684
- if (data === null)
10685
- return true;
10686
- const object = data;
10687
- for (const key in object)
10688
- if (_hasOwnProperty.call(object, key)) {
10689
- if (object[key] !== null)
10690
- return false;
10691
- }
10692
- return true;
10693
- }
10694
- function constructYamlSet(data) {
10695
- return data !== null ? data : {};
10696
- }
10697
- module.exports = new Type("tag:yaml.org,2002:set", {
10698
- kind: "mapping",
10699
- resolve: resolveYamlSet,
10700
- construct: constructYamlSet
10701
- });
10702
- });
10703
- var require_default = /* @__PURE__ */ __commonJSMin((exports, module) => {
10704
- module.exports = require_core().extend({
10705
- implicit: [require_timestamp(), require_merge()],
10706
- explicit: [
10707
- require_binary(),
10708
- require_omap(),
10709
- require_pairs(),
10710
- require_set()
10711
- ]
10712
- });
10713
- });
10714
- var require_loader = /* @__PURE__ */ __commonJSMin((exports, module) => {
10715
- var common = require_common();
10716
- var YAMLException = require_exception();
10717
- var makeSnippet = require_snippet();
10718
- var DEFAULT_SCHEMA = require_default();
10719
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
10720
- var CONTEXT_FLOW_IN = 1;
10721
- var CONTEXT_FLOW_OUT = 2;
10722
- var CONTEXT_BLOCK_IN = 3;
10723
- var CONTEXT_BLOCK_OUT = 4;
10724
- var CHOMPING_CLIP = 1;
10725
- var CHOMPING_STRIP = 2;
10726
- var CHOMPING_KEEP = 3;
10727
- var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
10728
- var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
10729
- var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
10730
- var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
10731
- var PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;
10732
- function _class(obj) {
10733
- return Object.prototype.toString.call(obj);
10734
- }
10735
- function isEol(c) {
10736
- return c === 10 || c === 13;
10737
- }
10738
- function isWhiteSpace(c) {
10739
- return c === 9 || c === 32;
10740
- }
10741
- function isWsOrEol(c) {
10742
- return c === 9 || c === 32 || c === 10 || c === 13;
10743
- }
10744
- function isFlowIndicator(c) {
10745
- return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
10746
- }
10747
- function fromHexCode(c) {
10748
- if (c >= 48 && c <= 57)
10749
- return c - 48;
10750
- const lc = c | 32;
10751
- if (lc >= 97 && lc <= 102)
10752
- return lc - 97 + 10;
10753
- return -1;
10754
- }
10755
- function escapedHexLen(c) {
10756
- if (c === 120)
10757
- return 2;
10758
- if (c === 117)
10759
- return 4;
10760
- if (c === 85)
10761
- return 8;
10762
- return 0;
10763
- }
10764
- function fromDecimalCode(c) {
10765
- if (c >= 48 && c <= 57)
10766
- return c - 48;
10767
- return -1;
10768
- }
10769
- function simpleEscapeSequence(c) {
10770
- switch (c) {
10771
- case 48:
10772
- return "\x00";
10773
- case 97:
10774
- return "\x07";
10775
- case 98:
10776
- return "\b";
10777
- case 116:
10778
- return "\t";
10779
- case 9:
10780
- return "\t";
10781
- case 110:
10782
- return `
10783
- `;
10784
- case 118:
10785
- return "\v";
10786
- case 102:
10787
- return "\f";
10788
- case 114:
10789
- return "\r";
10790
- case 101:
10791
- return "\x1B";
10792
- case 32:
10793
- return " ";
10794
- case 34:
10795
- return '"';
10796
- case 47:
10797
- return "/";
10798
- case 92:
10799
- return "\\";
10800
- case 78:
10801
- return "…";
10802
- case 95:
10803
- return " ";
10804
- case 76:
10805
- return "\u2028";
10806
- case 80:
10807
- return "\u2029";
10808
- default:
10809
- return "";
10810
- }
10811
- }
10812
- function charFromCodepoint(c) {
10813
- if (c <= 65535)
10814
- return String.fromCharCode(c);
10815
- return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
10816
- }
10817
- function setProperty(object, key, value) {
10818
- if (key === "__proto__")
10819
- Object.defineProperty(object, key, {
10820
- configurable: true,
10821
- enumerable: true,
10822
- writable: true,
10823
- value
10824
- });
10825
- else
10826
- object[key] = value;
10827
- }
10828
- var simpleEscapeCheck = new Array(256);
10829
- var simpleEscapeMap = new Array(256);
10830
- for (let i = 0;i < 256; i++) {
10831
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
10832
- simpleEscapeMap[i] = simpleEscapeSequence(i);
10833
- }
10834
- function State(input, options) {
10835
- this.input = input;
10836
- this.filename = options["filename"] || null;
10837
- this.schema = options["schema"] || DEFAULT_SCHEMA;
10838
- this.onWarning = options["onWarning"] || null;
10839
- this.legacy = options["legacy"] || false;
10840
- this.json = options["json"] || false;
10841
- this.listener = options["listener"] || null;
10842
- this.maxDepth = typeof options["maxDepth"] === "number" ? options["maxDepth"] : 100;
10843
- this.maxMergeSeqLength = typeof options["maxMergeSeqLength"] === "number" ? options["maxMergeSeqLength"] : 20;
10844
- this.implicitTypes = this.schema.compiledImplicit;
10845
- this.typeMap = this.schema.compiledTypeMap;
10846
- this.length = input.length;
10847
- this.position = 0;
10848
- this.line = 0;
10849
- this.lineStart = 0;
10850
- this.lineIndent = 0;
10851
- this.depth = 0;
10852
- this.firstTabInLine = -1;
10853
- this.documents = [];
10854
- this.anchorMapTransactions = [];
10855
- }
10856
- function generateError(state, message) {
10857
- const mark = {
10858
- name: state.filename,
10859
- buffer: state.input.slice(0, -1),
10860
- position: state.position,
10861
- line: state.line,
10862
- column: state.position - state.lineStart
10863
- };
10864
- mark.snippet = makeSnippet(mark);
10865
- return new YAMLException(message, mark);
10866
- }
10867
- function throwError(state, message) {
10868
- throw generateError(state, message);
10869
- }
10870
- function throwWarning(state, message) {
10871
- if (state.onWarning)
10872
- state.onWarning.call(null, generateError(state, message));
10873
- }
10874
- function storeAnchor(state, name, value) {
10875
- const transactions = state.anchorMapTransactions;
10876
- if (transactions.length !== 0) {
10877
- const transaction = transactions[transactions.length - 1];
10878
- if (!_hasOwnProperty.call(transaction, name))
10879
- transaction[name] = {
10880
- existed: _hasOwnProperty.call(state.anchorMap, name),
10881
- value: state.anchorMap[name]
10882
- };
10883
- }
10884
- state.anchorMap[name] = value;
10885
- }
10886
- function beginAnchorTransaction(state) {
10887
- state.anchorMapTransactions.push(Object.create(null));
10888
- }
10889
- function commitAnchorTransaction(state) {
10890
- const transaction = state.anchorMapTransactions.pop();
10891
- const transactions = state.anchorMapTransactions;
10892
- if (transactions.length === 0)
10893
- return;
10894
- const parent = transactions[transactions.length - 1];
10895
- const names = Object.keys(transaction);
10896
- for (let index = 0, length = names.length;index < length; index += 1) {
10897
- const name = names[index];
10898
- if (!_hasOwnProperty.call(parent, name))
10899
- parent[name] = transaction[name];
10900
- }
10901
- }
10902
- function rollbackAnchorTransaction(state) {
10903
- const transaction = state.anchorMapTransactions.pop();
10904
- const names = Object.keys(transaction);
10905
- for (let index = names.length - 1;index >= 0; index -= 1) {
10906
- const entry = transaction[names[index]];
10907
- if (entry.existed)
10908
- state.anchorMap[names[index]] = entry.value;
10909
- else
10910
- delete state.anchorMap[names[index]];
10911
- }
10912
- }
10913
- function snapshotState(state) {
10914
- return {
10915
- position: state.position,
10916
- line: state.line,
10917
- lineStart: state.lineStart,
10918
- lineIndent: state.lineIndent,
10919
- firstTabInLine: state.firstTabInLine,
10920
- tag: state.tag,
10921
- anchor: state.anchor,
10922
- kind: state.kind,
10923
- result: state.result
10924
- };
10925
- }
10926
- function restoreState(state, snapshot) {
10927
- state.position = snapshot.position;
10928
- state.line = snapshot.line;
10929
- state.lineStart = snapshot.lineStart;
10930
- state.lineIndent = snapshot.lineIndent;
10931
- state.firstTabInLine = snapshot.firstTabInLine;
10932
- state.tag = snapshot.tag;
10933
- state.anchor = snapshot.anchor;
10934
- state.kind = snapshot.kind;
10935
- state.result = snapshot.result;
10936
- }
10937
- var directiveHandlers = {
10938
- YAML: function handleYamlDirective(state, name, args) {
10939
- if (state.version !== null)
10940
- throwError(state, "duplication of %YAML directive");
10941
- if (args.length !== 1)
10942
- throwError(state, "YAML directive accepts exactly one argument");
10943
- const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
10944
- if (match === null)
10945
- throwError(state, "ill-formed argument of the YAML directive");
10946
- const major = parseInt(match[1], 10);
10947
- const minor = parseInt(match[2], 10);
10948
- if (major !== 1)
10949
- throwError(state, "unacceptable YAML version of the document");
10950
- state.version = args[0];
10951
- state.checkLineBreaks = minor < 2;
10952
- if (minor !== 1 && minor !== 2)
10953
- throwWarning(state, "unsupported YAML version of the document");
10954
- },
10955
- TAG: function handleTagDirective(state, name, args) {
10956
- let prefix;
10957
- if (args.length !== 2)
10958
- throwError(state, "TAG directive accepts exactly two arguments");
10959
- const handle = args[0];
10960
- prefix = args[1];
10961
- if (!PATTERN_TAG_HANDLE.test(handle))
10962
- throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
10963
- if (_hasOwnProperty.call(state.tagMap, handle))
10964
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
10965
- if (!PATTERN_TAG_URI.test(prefix))
10966
- throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
10967
- try {
10968
- prefix = decodeURIComponent(prefix);
10969
- } catch (err) {
10970
- throwError(state, "tag prefix is malformed: " + prefix);
10971
- }
10972
- state.tagMap[handle] = prefix;
10973
- }
10974
- };
10975
- function captureSegment(state, start, end, checkJson) {
10976
- if (start < end) {
10977
- const _result = state.input.slice(start, end);
10978
- if (checkJson)
10979
- for (let _position = 0, _length = _result.length;_position < _length; _position += 1) {
10980
- const _character = _result.charCodeAt(_position);
10981
- if (!(_character === 9 || _character >= 32 && _character <= 1114111))
10982
- throwError(state, "expected valid JSON character");
10983
- }
10984
- else if (PATTERN_NON_PRINTABLE.test(_result))
10985
- throwError(state, "the stream contains non-printable characters");
10986
- state.result += _result;
10987
- }
10988
- }
10989
- function mergeMappings(state, destination, source, overridableKeys) {
10990
- if (!common.isObject(source))
10991
- throwError(state, "cannot merge mappings; the provided source object is unacceptable");
10992
- const sourceKeys = Object.keys(source);
10993
- for (let index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
10994
- const key = sourceKeys[index];
10995
- if (!_hasOwnProperty.call(destination, key)) {
10996
- setProperty(destination, key, source[key]);
10997
- overridableKeys[key] = true;
10998
- }
10999
- }
11000
- }
11001
- function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
11002
- if (Array.isArray(keyNode)) {
11003
- keyNode = Array.prototype.slice.call(keyNode);
11004
- for (let index = 0, quantity = keyNode.length;index < quantity; index += 1) {
11005
- if (Array.isArray(keyNode[index]))
11006
- throwError(state, "nested arrays are not supported inside keys");
11007
- if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]")
11008
- keyNode[index] = "[object Object]";
11009
- }
11010
- }
11011
- if (typeof keyNode === "object" && _class(keyNode) === "[object Object]")
11012
- keyNode = "[object Object]";
11013
- keyNode = String(keyNode);
11014
- if (_result === null)
11015
- _result = {};
11016
- if (keyTag === "tag:yaml.org,2002:merge")
11017
- if (Array.isArray(valueNode)) {
11018
- if (valueNode.length > state.maxMergeSeqLength)
11019
- throwError(state, "merge sequence length exceeded maxMergeSeqLength (" + state.maxMergeSeqLength + ")");
11020
- const seen = /* @__PURE__ */ new Set;
11021
- for (let index = 0, quantity = valueNode.length;index < quantity; index += 1) {
11022
- const src = valueNode[index];
11023
- if (seen.has(src))
11024
- continue;
11025
- seen.add(src);
11026
- mergeMappings(state, _result, src, overridableKeys);
11027
- }
11028
- } else
11029
- mergeMappings(state, _result, valueNode, overridableKeys);
11030
- else {
11031
- if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
11032
- state.line = startLine || state.line;
11033
- state.lineStart = startLineStart || state.lineStart;
11034
- state.position = startPos || state.position;
11035
- throwError(state, "duplicated mapping key");
11036
- }
11037
- setProperty(_result, keyNode, valueNode);
11038
- delete overridableKeys[keyNode];
11039
- }
11040
- return _result;
11041
- }
11042
- function readLineBreak(state) {
11043
- const ch = state.input.charCodeAt(state.position);
11044
- if (ch === 10)
11045
- state.position++;
11046
- else if (ch === 13) {
11047
- state.position++;
11048
- if (state.input.charCodeAt(state.position) === 10)
11049
- state.position++;
11050
- } else
11051
- throwError(state, "a line break is expected");
11052
- state.line += 1;
11053
- state.lineStart = state.position;
11054
- state.firstTabInLine = -1;
11055
- }
11056
- function skipSeparationSpace(state, allowComments, checkIndent) {
11057
- let lineBreaks = 0;
11058
- let ch = state.input.charCodeAt(state.position);
11059
- while (ch !== 0) {
11060
- while (isWhiteSpace(ch)) {
11061
- if (ch === 9 && state.firstTabInLine === -1)
11062
- state.firstTabInLine = state.position;
11063
- ch = state.input.charCodeAt(++state.position);
11064
- }
11065
- if (allowComments && ch === 35)
11066
- do
11067
- ch = state.input.charCodeAt(++state.position);
11068
- while (ch !== 10 && ch !== 13 && ch !== 0);
11069
- if (isEol(ch)) {
11070
- readLineBreak(state);
11071
- ch = state.input.charCodeAt(state.position);
11072
- lineBreaks++;
11073
- state.lineIndent = 0;
11074
- while (ch === 32) {
11075
- state.lineIndent++;
11076
- ch = state.input.charCodeAt(++state.position);
11077
- }
11078
- } else
11079
- break;
11080
- }
11081
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent)
11082
- throwWarning(state, "deficient indentation");
11083
- return lineBreaks;
11084
- }
11085
- function testDocumentSeparator(state) {
11086
- let _position = state.position;
11087
- let ch = state.input.charCodeAt(_position);
11088
- if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
11089
- _position += 3;
11090
- ch = state.input.charCodeAt(_position);
11091
- if (ch === 0 || isWsOrEol(ch))
11092
- return true;
11093
- }
11094
- return false;
11095
- }
11096
- function writeFoldedLines(state, count) {
11097
- if (count === 1)
11098
- state.result += " ";
11099
- else if (count > 1)
11100
- state.result += common.repeat(`
11101
- `, count - 1);
11102
- }
11103
- function readPlainScalar(state, nodeIndent, withinFlowCollection) {
11104
- let captureStart;
11105
- let captureEnd;
11106
- let hasPendingContent;
11107
- let _line;
11108
- let _lineStart;
11109
- let _lineIndent;
11110
- const _kind = state.kind;
11111
- const _result = state.result;
11112
- let ch = state.input.charCodeAt(state.position);
11113
- if (isWsOrEol(ch) || isFlowIndicator(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96)
11114
- return false;
11115
- if (ch === 63 || ch === 45) {
11116
- const following = state.input.charCodeAt(state.position + 1);
11117
- if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following))
11118
- return false;
11119
- }
11120
- state.kind = "scalar";
11121
- state.result = "";
11122
- captureStart = captureEnd = state.position;
11123
- hasPendingContent = false;
11124
- while (ch !== 0) {
11125
- if (ch === 58) {
11126
- const following = state.input.charCodeAt(state.position + 1);
11127
- if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following))
11128
- break;
11129
- } else if (ch === 35) {
11130
- if (isWsOrEol(state.input.charCodeAt(state.position - 1)))
11131
- break;
11132
- } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && isFlowIndicator(ch))
11133
- break;
11134
- else if (isEol(ch)) {
11135
- _line = state.line;
11136
- _lineStart = state.lineStart;
11137
- _lineIndent = state.lineIndent;
11138
- skipSeparationSpace(state, false, -1);
11139
- if (state.lineIndent >= nodeIndent) {
11140
- hasPendingContent = true;
11141
- ch = state.input.charCodeAt(state.position);
11142
- continue;
11143
- } else {
11144
- state.position = captureEnd;
11145
- state.line = _line;
11146
- state.lineStart = _lineStart;
11147
- state.lineIndent = _lineIndent;
11148
- break;
11149
- }
11150
- }
11151
- if (hasPendingContent) {
11152
- captureSegment(state, captureStart, captureEnd, false);
11153
- writeFoldedLines(state, state.line - _line);
11154
- captureStart = captureEnd = state.position;
11155
- hasPendingContent = false;
11156
- }
11157
- if (!isWhiteSpace(ch))
11158
- captureEnd = state.position + 1;
11159
- ch = state.input.charCodeAt(++state.position);
11160
- }
11161
- captureSegment(state, captureStart, captureEnd, false);
11162
- if (state.result)
11163
- return true;
11164
- state.kind = _kind;
11165
- state.result = _result;
11166
- return false;
11167
- }
11168
- function readSingleQuotedScalar(state, nodeIndent) {
11169
- let captureStart;
11170
- let captureEnd;
11171
- let ch = state.input.charCodeAt(state.position);
11172
- if (ch !== 39)
11173
- return false;
11174
- state.kind = "scalar";
11175
- state.result = "";
11176
- state.position++;
11177
- captureStart = captureEnd = state.position;
11178
- while ((ch = state.input.charCodeAt(state.position)) !== 0)
11179
- if (ch === 39) {
11180
- captureSegment(state, captureStart, state.position, true);
11181
- ch = state.input.charCodeAt(++state.position);
11182
- if (ch === 39) {
11183
- captureStart = state.position;
11184
- state.position++;
11185
- captureEnd = state.position;
11186
- } else
11187
- return true;
11188
- } else if (isEol(ch)) {
11189
- captureSegment(state, captureStart, captureEnd, true);
11190
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
11191
- captureStart = captureEnd = state.position;
11192
- } else if (state.position === state.lineStart && testDocumentSeparator(state))
11193
- throwError(state, "unexpected end of the document within a single quoted scalar");
11194
- else {
11195
- state.position++;
11196
- if (!isWhiteSpace(ch))
11197
- captureEnd = state.position;
11198
- }
11199
- throwError(state, "unexpected end of the stream within a single quoted scalar");
11200
- }
11201
- function readDoubleQuotedScalar(state, nodeIndent) {
11202
- let captureStart;
11203
- let captureEnd;
11204
- let tmp;
11205
- let ch = state.input.charCodeAt(state.position);
11206
- if (ch !== 34)
11207
- return false;
11208
- state.kind = "scalar";
11209
- state.result = "";
11210
- state.position++;
11211
- captureStart = captureEnd = state.position;
11212
- while ((ch = state.input.charCodeAt(state.position)) !== 0)
11213
- if (ch === 34) {
11214
- captureSegment(state, captureStart, state.position, true);
11215
- state.position++;
11216
- return true;
11217
- } else if (ch === 92) {
11218
- captureSegment(state, captureStart, state.position, true);
11219
- ch = state.input.charCodeAt(++state.position);
11220
- if (isEol(ch))
11221
- skipSeparationSpace(state, false, nodeIndent);
11222
- else if (ch < 256 && simpleEscapeCheck[ch]) {
11223
- state.result += simpleEscapeMap[ch];
11224
- state.position++;
11225
- } else if ((tmp = escapedHexLen(ch)) > 0) {
11226
- let hexLength = tmp;
11227
- let hexResult = 0;
11228
- for (;hexLength > 0; hexLength--) {
11229
- ch = state.input.charCodeAt(++state.position);
11230
- if ((tmp = fromHexCode(ch)) >= 0)
11231
- hexResult = (hexResult << 4) + tmp;
11232
- else
11233
- throwError(state, "expected hexadecimal character");
11234
- }
11235
- state.result += charFromCodepoint(hexResult);
11236
- state.position++;
11237
- } else
11238
- throwError(state, "unknown escape sequence");
11239
- captureStart = captureEnd = state.position;
11240
- } else if (isEol(ch)) {
11241
- captureSegment(state, captureStart, captureEnd, true);
11242
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
11243
- captureStart = captureEnd = state.position;
11244
- } else if (state.position === state.lineStart && testDocumentSeparator(state))
11245
- throwError(state, "unexpected end of the document within a double quoted scalar");
11246
- else {
11247
- state.position++;
11248
- if (!isWhiteSpace(ch))
11249
- captureEnd = state.position;
11250
- }
11251
- throwError(state, "unexpected end of the stream within a double quoted scalar");
11252
- }
11253
- function readFlowCollection(state, nodeIndent) {
11254
- let readNext = true;
11255
- let _line;
11256
- let _lineStart;
11257
- let _pos;
11258
- const _tag = state.tag;
11259
- let _result;
11260
- const _anchor = state.anchor;
11261
- let terminator;
11262
- let isPair;
11263
- let isExplicitPair;
11264
- let isMapping;
11265
- const overridableKeys = Object.create(null);
11266
- let keyNode;
11267
- let keyTag;
11268
- let valueNode;
11269
- let ch = state.input.charCodeAt(state.position);
11270
- if (ch === 91) {
11271
- terminator = 93;
11272
- isMapping = false;
11273
- _result = [];
11274
- } else if (ch === 123) {
11275
- terminator = 125;
11276
- isMapping = true;
11277
- _result = {};
11278
- } else
11279
- return false;
11280
- if (state.anchor !== null)
11281
- storeAnchor(state, state.anchor, _result);
11282
- ch = state.input.charCodeAt(++state.position);
11283
- while (ch !== 0) {
11284
- skipSeparationSpace(state, true, nodeIndent);
11285
- ch = state.input.charCodeAt(state.position);
11286
- if (ch === terminator) {
11287
- state.position++;
11288
- state.tag = _tag;
11289
- state.anchor = _anchor;
11290
- state.kind = isMapping ? "mapping" : "sequence";
11291
- state.result = _result;
11292
- return true;
11293
- } else if (!readNext)
11294
- throwError(state, "missed comma between flow collection entries");
11295
- else if (ch === 44)
11296
- throwError(state, "expected the node content, but found ','");
11297
- keyTag = keyNode = valueNode = null;
11298
- isPair = isExplicitPair = false;
11299
- if (ch === 63) {
11300
- if (isWsOrEol(state.input.charCodeAt(state.position + 1))) {
11301
- isPair = isExplicitPair = true;
11302
- state.position++;
11303
- skipSeparationSpace(state, true, nodeIndent);
11304
- }
11305
- }
11306
- _line = state.line;
11307
- _lineStart = state.lineStart;
11308
- _pos = state.position;
11309
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
11310
- keyTag = state.tag;
11311
- keyNode = state.result;
11312
- skipSeparationSpace(state, true, nodeIndent);
11313
- ch = state.input.charCodeAt(state.position);
11314
- if ((isExplicitPair || state.line === _line) && ch === 58) {
11315
- isPair = true;
11316
- ch = state.input.charCodeAt(++state.position);
11317
- skipSeparationSpace(state, true, nodeIndent);
11318
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
11319
- valueNode = state.result;
11320
- }
11321
- if (isMapping)
11322
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
11323
- else if (isPair)
11324
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
11325
- else
11326
- _result.push(keyNode);
11327
- skipSeparationSpace(state, true, nodeIndent);
11328
- ch = state.input.charCodeAt(state.position);
11329
- if (ch === 44) {
11330
- readNext = true;
11331
- ch = state.input.charCodeAt(++state.position);
11332
- } else
11333
- readNext = false;
11334
- }
11335
- throwError(state, "unexpected end of the stream within a flow collection");
11336
- }
11337
- function readBlockScalar(state, nodeIndent) {
11338
- let folding;
11339
- let chomping = CHOMPING_CLIP;
11340
- let didReadContent = false;
11341
- let detectedIndent = false;
11342
- let textIndent = nodeIndent;
11343
- let emptyLines = 0;
11344
- let atMoreIndented = false;
11345
- let tmp;
11346
- let ch = state.input.charCodeAt(state.position);
11347
- if (ch === 124)
11348
- folding = false;
11349
- else if (ch === 62)
11350
- folding = true;
11351
- else
11352
- return false;
11353
- state.kind = "scalar";
11354
- state.result = "";
11355
- while (ch !== 0) {
11356
- ch = state.input.charCodeAt(++state.position);
11357
- if (ch === 43 || ch === 45)
11358
- if (CHOMPING_CLIP === chomping)
11359
- chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
11360
- else
11361
- throwError(state, "repeat of a chomping mode identifier");
11362
- else if ((tmp = fromDecimalCode(ch)) >= 0)
11363
- if (tmp === 0)
11364
- throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
11365
- else if (!detectedIndent) {
11366
- textIndent = nodeIndent + tmp - 1;
11367
- detectedIndent = true;
11368
- } else
11369
- throwError(state, "repeat of an indentation width identifier");
11370
- else
11371
- break;
11372
- }
11373
- if (isWhiteSpace(ch)) {
11374
- do
11375
- ch = state.input.charCodeAt(++state.position);
11376
- while (isWhiteSpace(ch));
11377
- if (ch === 35)
11378
- do
11379
- ch = state.input.charCodeAt(++state.position);
11380
- while (!isEol(ch) && ch !== 0);
11381
- }
11382
- while (ch !== 0) {
11383
- readLineBreak(state);
11384
- state.lineIndent = 0;
11385
- ch = state.input.charCodeAt(state.position);
11386
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
11387
- state.lineIndent++;
11388
- ch = state.input.charCodeAt(++state.position);
11389
- }
11390
- if (!detectedIndent && state.lineIndent > textIndent)
11391
- textIndent = state.lineIndent;
11392
- if (isEol(ch)) {
11393
- emptyLines++;
11394
- continue;
11395
- }
11396
- if (!detectedIndent && textIndent === 0)
11397
- throwError(state, "missing indentation for block scalar");
11398
- if (state.lineIndent < textIndent) {
11399
- if (chomping === CHOMPING_KEEP)
11400
- state.result += common.repeat(`
11401
- `, didReadContent ? 1 + emptyLines : emptyLines);
11402
- else if (chomping === CHOMPING_CLIP) {
11403
- if (didReadContent)
11404
- state.result += `
11405
- `;
11406
- }
11407
- break;
11408
- }
11409
- if (folding)
11410
- if (isWhiteSpace(ch)) {
11411
- atMoreIndented = true;
11412
- state.result += common.repeat(`
11413
- `, didReadContent ? 1 + emptyLines : emptyLines);
11414
- } else if (atMoreIndented) {
11415
- atMoreIndented = false;
11416
- state.result += common.repeat(`
11417
- `, emptyLines + 1);
11418
- } else if (emptyLines === 0) {
11419
- if (didReadContent)
11420
- state.result += " ";
11421
- } else
11422
- state.result += common.repeat(`
11423
- `, emptyLines);
11424
- else
11425
- state.result += common.repeat(`
11426
- `, didReadContent ? 1 + emptyLines : emptyLines);
11427
- didReadContent = true;
11428
- detectedIndent = true;
11429
- emptyLines = 0;
11430
- const captureStart = state.position;
11431
- while (!isEol(ch) && ch !== 0)
11432
- ch = state.input.charCodeAt(++state.position);
11433
- captureSegment(state, captureStart, state.position, false);
11434
- }
11435
- return true;
11436
- }
11437
- function readBlockSequence(state, nodeIndent) {
11438
- const _tag = state.tag;
11439
- const _anchor = state.anchor;
11440
- const _result = [];
11441
- let detected = false;
11442
- if (state.firstTabInLine !== -1)
11443
- return false;
11444
- if (state.anchor !== null)
11445
- storeAnchor(state, state.anchor, _result);
11446
- let ch = state.input.charCodeAt(state.position);
11447
- while (ch !== 0) {
11448
- if (state.firstTabInLine !== -1) {
11449
- state.position = state.firstTabInLine;
11450
- throwError(state, "tab characters must not be used in indentation");
11451
- }
11452
- if (ch !== 45)
11453
- break;
11454
- if (!isWsOrEol(state.input.charCodeAt(state.position + 1)))
11455
- break;
11456
- detected = true;
11457
- state.position++;
11458
- if (skipSeparationSpace(state, true, -1)) {
11459
- if (state.lineIndent <= nodeIndent) {
11460
- _result.push(null);
11461
- ch = state.input.charCodeAt(state.position);
11462
- continue;
11463
- }
11464
- }
11465
- const _line = state.line;
11466
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
11467
- _result.push(state.result);
11468
- skipSeparationSpace(state, true, -1);
11469
- ch = state.input.charCodeAt(state.position);
11470
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0)
11471
- throwError(state, "bad indentation of a sequence entry");
11472
- else if (state.lineIndent < nodeIndent)
11473
- break;
11474
- }
11475
- if (detected) {
11476
- state.tag = _tag;
11477
- state.anchor = _anchor;
11478
- state.kind = "sequence";
11479
- state.result = _result;
11480
- return true;
11481
- }
11482
- return false;
11483
- }
11484
- function readBlockMapping(state, nodeIndent, flowIndent) {
11485
- let allowCompact;
11486
- let _keyLine;
11487
- let _keyLineStart;
11488
- let _keyPos;
11489
- const _tag = state.tag;
11490
- const _anchor = state.anchor;
11491
- const _result = {};
11492
- const overridableKeys = Object.create(null);
11493
- let keyTag = null;
11494
- let keyNode = null;
11495
- let valueNode = null;
11496
- let atExplicitKey = false;
11497
- let detected = false;
11498
- if (state.firstTabInLine !== -1)
11499
- return false;
11500
- if (state.anchor !== null)
11501
- storeAnchor(state, state.anchor, _result);
11502
- let ch = state.input.charCodeAt(state.position);
11503
- while (ch !== 0) {
11504
- if (!atExplicitKey && state.firstTabInLine !== -1) {
11505
- state.position = state.firstTabInLine;
11506
- throwError(state, "tab characters must not be used in indentation");
11507
- }
11508
- const following = state.input.charCodeAt(state.position + 1);
11509
- const _line = state.line;
11510
- if ((ch === 63 || ch === 58) && isWsOrEol(following)) {
11511
- if (ch === 63) {
11512
- if (atExplicitKey) {
11513
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
11514
- keyTag = keyNode = valueNode = null;
11515
- }
11516
- detected = true;
11517
- atExplicitKey = true;
11518
- allowCompact = true;
11519
- } else if (atExplicitKey) {
11520
- atExplicitKey = false;
11521
- allowCompact = true;
11522
- } else
11523
- throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
11524
- state.position += 1;
11525
- ch = following;
11526
- } else {
11527
- _keyLine = state.line;
11528
- _keyLineStart = state.lineStart;
11529
- _keyPos = state.position;
11530
- if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true))
11531
- break;
11532
- if (state.line === _line) {
11533
- ch = state.input.charCodeAt(state.position);
11534
- while (isWhiteSpace(ch))
11535
- ch = state.input.charCodeAt(++state.position);
11536
- if (ch === 58) {
11537
- ch = state.input.charCodeAt(++state.position);
11538
- if (!isWsOrEol(ch))
11539
- throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
11540
- if (atExplicitKey) {
11541
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
11542
- keyTag = keyNode = valueNode = null;
11543
- }
11544
- detected = true;
11545
- atExplicitKey = false;
11546
- allowCompact = false;
11547
- keyTag = state.tag;
11548
- keyNode = state.result;
11549
- } else if (detected)
11550
- throwError(state, "can not read an implicit mapping pair; a colon is missed");
11551
- else {
11552
- state.tag = _tag;
11553
- state.anchor = _anchor;
11554
- return true;
11555
- }
11556
- } else if (detected)
11557
- throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
11558
- else {
11559
- state.tag = _tag;
11560
- state.anchor = _anchor;
11561
- return true;
11562
- }
11563
- }
11564
- if (state.line === _line || state.lineIndent > nodeIndent) {
11565
- if (atExplicitKey) {
11566
- _keyLine = state.line;
11567
- _keyLineStart = state.lineStart;
11568
- _keyPos = state.position;
11569
- }
11570
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact))
11571
- if (atExplicitKey)
11572
- keyNode = state.result;
11573
- else
11574
- valueNode = state.result;
11575
- if (!atExplicitKey) {
11576
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
11577
- keyTag = keyNode = valueNode = null;
11578
- }
11579
- skipSeparationSpace(state, true, -1);
11580
- ch = state.input.charCodeAt(state.position);
11581
- }
11582
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0)
11583
- throwError(state, "bad indentation of a mapping entry");
11584
- else if (state.lineIndent < nodeIndent)
11585
- break;
11586
- }
11587
- if (atExplicitKey)
11588
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
11589
- if (detected) {
11590
- state.tag = _tag;
11591
- state.anchor = _anchor;
11592
- state.kind = "mapping";
11593
- state.result = _result;
11594
- }
11595
- return detected;
11596
- }
11597
- function readTagProperty(state) {
11598
- let isVerbatim = false;
11599
- let isNamed = false;
11600
- let tagHandle;
11601
- let tagName;
11602
- let ch = state.input.charCodeAt(state.position);
11603
- if (ch !== 33)
11604
- return false;
11605
- if (state.tag !== null)
11606
- throwError(state, "duplication of a tag property");
11607
- ch = state.input.charCodeAt(++state.position);
11608
- if (ch === 60) {
11609
- isVerbatim = true;
11610
- ch = state.input.charCodeAt(++state.position);
11611
- } else if (ch === 33) {
11612
- isNamed = true;
11613
- tagHandle = "!!";
11614
- ch = state.input.charCodeAt(++state.position);
11615
- } else
11616
- tagHandle = "!";
11617
- let _position = state.position;
11618
- if (isVerbatim) {
11619
- do
11620
- ch = state.input.charCodeAt(++state.position);
11621
- while (ch !== 0 && ch !== 62);
11622
- if (state.position < state.length) {
11623
- tagName = state.input.slice(_position, state.position);
11624
- ch = state.input.charCodeAt(++state.position);
11625
- } else
11626
- throwError(state, "unexpected end of the stream within a verbatim tag");
11627
- } else {
11628
- while (ch !== 0 && !isWsOrEol(ch)) {
11629
- if (ch === 33)
11630
- if (!isNamed) {
11631
- tagHandle = state.input.slice(_position - 1, state.position + 1);
11632
- if (!PATTERN_TAG_HANDLE.test(tagHandle))
11633
- throwError(state, "named tag handle cannot contain such characters");
11634
- isNamed = true;
11635
- _position = state.position + 1;
11636
- } else
11637
- throwError(state, "tag suffix cannot contain exclamation marks");
11638
- ch = state.input.charCodeAt(++state.position);
11639
- }
11640
- tagName = state.input.slice(_position, state.position);
11641
- if (PATTERN_FLOW_INDICATORS.test(tagName))
11642
- throwError(state, "tag suffix cannot contain flow indicator characters");
11643
- }
11644
- if (tagName && !PATTERN_TAG_URI.test(tagName))
11645
- throwError(state, "tag name cannot contain such characters: " + tagName);
11646
- try {
11647
- tagName = decodeURIComponent(tagName);
11648
- } catch (err) {
11649
- throwError(state, "tag name is malformed: " + tagName);
11650
- }
11651
- if (isVerbatim)
11652
- state.tag = tagName;
11653
- else if (_hasOwnProperty.call(state.tagMap, tagHandle))
11654
- state.tag = state.tagMap[tagHandle] + tagName;
11655
- else if (tagHandle === "!")
11656
- state.tag = "!" + tagName;
11657
- else if (tagHandle === "!!")
11658
- state.tag = "tag:yaml.org,2002:" + tagName;
11659
- else
11660
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
11661
- return true;
11662
- }
11663
- function readAnchorProperty(state) {
11664
- let ch = state.input.charCodeAt(state.position);
11665
- if (ch !== 38)
11666
- return false;
11667
- if (state.anchor !== null)
11668
- throwError(state, "duplication of an anchor property");
11669
- ch = state.input.charCodeAt(++state.position);
11670
- const _position = state.position;
11671
- while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch))
11672
- ch = state.input.charCodeAt(++state.position);
11673
- if (state.position === _position)
11674
- throwError(state, "name of an anchor node must contain at least one character");
11675
- state.anchor = state.input.slice(_position, state.position);
11676
- return true;
11677
- }
11678
- function readAlias(state) {
11679
- let ch = state.input.charCodeAt(state.position);
11680
- if (ch !== 42)
11681
- return false;
11682
- ch = state.input.charCodeAt(++state.position);
11683
- const _position = state.position;
11684
- while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch))
11685
- ch = state.input.charCodeAt(++state.position);
11686
- if (state.position === _position)
11687
- throwError(state, "name of an alias node must contain at least one character");
11688
- const alias = state.input.slice(_position, state.position);
11689
- if (!_hasOwnProperty.call(state.anchorMap, alias))
11690
- throwError(state, 'unidentified alias "' + alias + '"');
11691
- state.result = state.anchorMap[alias];
11692
- skipSeparationSpace(state, true, -1);
11693
- return true;
11694
- }
11695
- function tryReadBlockMappingFromProperty(state, propertyStart, nodeIndent, flowIndent) {
11696
- const fallbackState = snapshotState(state);
11697
- beginAnchorTransaction(state);
11698
- restoreState(state, propertyStart);
11699
- state.tag = null;
11700
- state.anchor = null;
11701
- state.kind = null;
11702
- state.result = null;
11703
- if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === "mapping") {
11704
- commitAnchorTransaction(state);
11705
- return true;
11706
- }
11707
- rollbackAnchorTransaction(state);
11708
- restoreState(state, fallbackState);
11709
- return false;
11710
- }
11711
- function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
11712
- let allowBlockScalars;
11713
- let allowBlockCollections;
11714
- let indentStatus = 1;
11715
- let atNewLine = false;
11716
- let hasContent = false;
11717
- let propertyStart = null;
11718
- let type;
11719
- let flowIndent;
11720
- let blockIndent;
11721
- if (state.depth >= state.maxDepth)
11722
- throwError(state, "nesting exceeded maxDepth (" + state.maxDepth + ")");
11723
- state.depth += 1;
11724
- if (state.listener !== null)
11725
- state.listener("open", state);
11726
- state.tag = null;
11727
- state.anchor = null;
11728
- state.kind = null;
11729
- state.result = null;
11730
- const allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
11731
- if (allowToSeek) {
11732
- if (skipSeparationSpace(state, true, -1)) {
11733
- atNewLine = true;
11734
- if (state.lineIndent > parentIndent)
11735
- indentStatus = 1;
11736
- else if (state.lineIndent === parentIndent)
11737
- indentStatus = 0;
11738
- else if (state.lineIndent < parentIndent)
11739
- indentStatus = -1;
11740
- }
11741
- }
11742
- if (indentStatus === 1)
11743
- while (true) {
11744
- const ch = state.input.charCodeAt(state.position);
11745
- const propertyState = snapshotState(state);
11746
- if (atNewLine && (ch === 33 && state.tag !== null || ch === 38 && state.anchor !== null))
11747
- break;
11748
- if (!readTagProperty(state) && !readAnchorProperty(state))
11749
- break;
11750
- if (propertyStart === null)
11751
- propertyStart = propertyState;
11752
- if (skipSeparationSpace(state, true, -1)) {
11753
- atNewLine = true;
11754
- allowBlockCollections = allowBlockStyles;
11755
- if (state.lineIndent > parentIndent)
11756
- indentStatus = 1;
11757
- else if (state.lineIndent === parentIndent)
11758
- indentStatus = 0;
11759
- else if (state.lineIndent < parentIndent)
11760
- indentStatus = -1;
11761
- } else
11762
- allowBlockCollections = false;
11763
- }
11764
- if (allowBlockCollections)
11765
- allowBlockCollections = atNewLine || allowCompact;
11766
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
11767
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext)
11768
- flowIndent = parentIndent;
11769
- else
11770
- flowIndent = parentIndent + 1;
11771
- blockIndent = state.position - state.lineStart;
11772
- if (indentStatus === 1)
11773
- if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent))
11774
- hasContent = true;
11775
- else {
11776
- const ch = state.input.charCodeAt(state.position);
11777
- if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62 && tryReadBlockMappingFromProperty(state, propertyStart, propertyStart.position - propertyStart.lineStart, flowIndent))
11778
- hasContent = true;
11779
- else if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent))
11780
- hasContent = true;
11781
- else if (readAlias(state)) {
11782
- hasContent = true;
11783
- if (state.tag !== null || state.anchor !== null)
11784
- throwError(state, "alias node should not have any properties");
11785
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
11786
- hasContent = true;
11787
- if (state.tag === null)
11788
- state.tag = "?";
11789
- }
11790
- if (state.anchor !== null)
11791
- storeAnchor(state, state.anchor, state.result);
11792
- }
11793
- else if (indentStatus === 0)
11794
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
11795
- }
11796
- if (state.tag === null) {
11797
- if (state.anchor !== null)
11798
- storeAnchor(state, state.anchor, state.result);
11799
- } else if (state.tag === "?") {
11800
- if (state.result !== null && state.kind !== "scalar")
11801
- throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
11802
- for (let typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
11803
- type = state.implicitTypes[typeIndex];
11804
- if (type.resolve(state.result)) {
11805
- state.result = type.construct(state.result);
11806
- state.tag = type.tag;
11807
- if (state.anchor !== null)
11808
- storeAnchor(state, state.anchor, state.result);
11809
- break;
11810
- }
11811
- }
11812
- } else if (state.tag !== "!") {
11813
- if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag))
11814
- type = state.typeMap[state.kind || "fallback"][state.tag];
11815
- else {
11816
- type = null;
11817
- const typeList = state.typeMap.multi[state.kind || "fallback"];
11818
- for (let typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1)
11819
- if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
11820
- type = typeList[typeIndex];
11821
- break;
11822
- }
11823
- }
11824
- if (!type)
11825
- throwError(state, "unknown tag !<" + state.tag + ">");
11826
- if (state.result !== null && type.kind !== state.kind)
11827
- throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
11828
- if (!type.resolve(state.result, state.tag))
11829
- throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
11830
- else {
11831
- state.result = type.construct(state.result, state.tag);
11832
- if (state.anchor !== null)
11833
- storeAnchor(state, state.anchor, state.result);
11834
- }
11835
- }
11836
- if (state.listener !== null)
11837
- state.listener("close", state);
11838
- state.depth -= 1;
11839
- return state.tag !== null || state.anchor !== null || hasContent;
11840
- }
11841
- function readDocument(state) {
11842
- const documentStart = state.position;
11843
- let hasDirectives = false;
11844
- let ch;
11845
- state.version = null;
11846
- state.checkLineBreaks = state.legacy;
11847
- state.tagMap = Object.create(null);
11848
- state.anchorMap = Object.create(null);
11849
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
11850
- skipSeparationSpace(state, true, -1);
11851
- ch = state.input.charCodeAt(state.position);
11852
- if (state.lineIndent > 0 || ch !== 37)
11853
- break;
11854
- hasDirectives = true;
11855
- ch = state.input.charCodeAt(++state.position);
11856
- let _position = state.position;
11857
- while (ch !== 0 && !isWsOrEol(ch))
11858
- ch = state.input.charCodeAt(++state.position);
11859
- const directiveName = state.input.slice(_position, state.position);
11860
- const directiveArgs = [];
11861
- if (directiveName.length < 1)
11862
- throwError(state, "directive name must not be less than one character in length");
11863
- while (ch !== 0) {
11864
- while (isWhiteSpace(ch))
11865
- ch = state.input.charCodeAt(++state.position);
11866
- if (ch === 35) {
11867
- do
11868
- ch = state.input.charCodeAt(++state.position);
11869
- while (ch !== 0 && !isEol(ch));
11870
- break;
11871
- }
11872
- if (isEol(ch))
11873
- break;
11874
- _position = state.position;
11875
- while (ch !== 0 && !isWsOrEol(ch))
11876
- ch = state.input.charCodeAt(++state.position);
11877
- directiveArgs.push(state.input.slice(_position, state.position));
11878
- }
11879
- if (ch !== 0)
11880
- readLineBreak(state);
11881
- if (_hasOwnProperty.call(directiveHandlers, directiveName))
11882
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
11883
- else
11884
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
11885
- }
11886
- skipSeparationSpace(state, true, -1);
11887
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
11888
- state.position += 3;
11889
- skipSeparationSpace(state, true, -1);
11890
- } else if (hasDirectives)
11891
- throwError(state, "directives end mark is expected");
11892
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
11893
- skipSeparationSpace(state, true, -1);
11894
- if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position)))
11895
- throwWarning(state, "non-ASCII line breaks are interpreted as content");
11896
- state.documents.push(state.result);
11897
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
11898
- if (state.input.charCodeAt(state.position) === 46) {
11899
- state.position += 3;
11900
- skipSeparationSpace(state, true, -1);
11901
- }
11902
- return;
11903
- }
11904
- if (state.position < state.length - 1)
11905
- throwError(state, "end of the stream or a document separator is expected");
11906
- }
11907
- function loadDocuments(input, options) {
11908
- input = String(input);
11909
- options = options || {};
11910
- if (input.length !== 0) {
11911
- if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13)
11912
- input += `
11913
- `;
11914
- if (input.charCodeAt(0) === 65279)
11915
- input = input.slice(1);
11916
- }
11917
- const state = new State(input, options);
11918
- const nullpos = input.indexOf("\x00");
11919
- if (nullpos !== -1) {
11920
- state.position = nullpos;
11921
- throwError(state, "null byte is not allowed in input");
11922
- }
11923
- state.input += "\x00";
11924
- while (state.input.charCodeAt(state.position) === 32) {
11925
- state.lineIndent += 1;
11926
- state.position += 1;
11927
- }
11928
- while (state.position < state.length - 1)
11929
- readDocument(state);
11930
- return state.documents;
11931
- }
11932
- function loadAll(input, iterator, options) {
11933
- if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
11934
- options = iterator;
11935
- iterator = null;
11936
- }
11937
- const documents = loadDocuments(input, options);
11938
- if (typeof iterator !== "function")
11939
- return documents;
11940
- for (let index = 0, length = documents.length;index < length; index += 1)
11941
- iterator(documents[index]);
11942
- }
11943
- function load(input, options) {
11944
- const documents = loadDocuments(input, options);
11945
- if (documents.length === 0)
11946
- return;
11947
- else if (documents.length === 1)
11948
- return documents[0];
11949
- throw new YAMLException("expected a single document in the stream, but found more");
11950
- }
11951
- module.exports.loadAll = loadAll;
11952
- module.exports.load = load;
11953
- });
11954
- var require_dumper = /* @__PURE__ */ __commonJSMin((exports, module) => {
11955
- var common = require_common();
11956
- var YAMLException = require_exception();
11957
- var DEFAULT_SCHEMA = require_default();
11958
- var _toString = Object.prototype.toString;
11959
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
11960
- var CHAR_BOM = 65279;
11961
- var CHAR_TAB = 9;
11962
- var CHAR_LINE_FEED = 10;
11963
- var CHAR_CARRIAGE_RETURN = 13;
11964
- var CHAR_SPACE = 32;
11965
- var CHAR_EXCLAMATION = 33;
11966
- var CHAR_DOUBLE_QUOTE = 34;
11967
- var CHAR_SHARP = 35;
11968
- var CHAR_PERCENT = 37;
11969
- var CHAR_AMPERSAND = 38;
11970
- var CHAR_SINGLE_QUOTE = 39;
11971
- var CHAR_ASTERISK = 42;
11972
- var CHAR_COMMA = 44;
11973
- var CHAR_MINUS = 45;
11974
- var CHAR_COLON = 58;
11975
- var CHAR_EQUALS = 61;
11976
- var CHAR_GREATER_THAN = 62;
11977
- var CHAR_QUESTION = 63;
11978
- var CHAR_COMMERCIAL_AT = 64;
11979
- var CHAR_LEFT_SQUARE_BRACKET = 91;
11980
- var CHAR_RIGHT_SQUARE_BRACKET = 93;
11981
- var CHAR_GRAVE_ACCENT = 96;
11982
- var CHAR_LEFT_CURLY_BRACKET = 123;
11983
- var CHAR_VERTICAL_LINE = 124;
11984
- var CHAR_RIGHT_CURLY_BRACKET = 125;
11985
- var ESCAPE_SEQUENCES = {};
11986
- ESCAPE_SEQUENCES[0] = "\\0";
11987
- ESCAPE_SEQUENCES[7] = "\\a";
11988
- ESCAPE_SEQUENCES[8] = "\\b";
11989
- ESCAPE_SEQUENCES[9] = "\\t";
11990
- ESCAPE_SEQUENCES[10] = "\\n";
11991
- ESCAPE_SEQUENCES[11] = "\\v";
11992
- ESCAPE_SEQUENCES[12] = "\\f";
11993
- ESCAPE_SEQUENCES[13] = "\\r";
11994
- ESCAPE_SEQUENCES[27] = "\\e";
11995
- ESCAPE_SEQUENCES[34] = "\\\"";
11996
- ESCAPE_SEQUENCES[92] = "\\\\";
11997
- ESCAPE_SEQUENCES[133] = "\\N";
11998
- ESCAPE_SEQUENCES[160] = "\\_";
11999
- ESCAPE_SEQUENCES[8232] = "\\L";
12000
- ESCAPE_SEQUENCES[8233] = "\\P";
12001
- var DEPRECATED_BOOLEANS_SYNTAX = [
12002
- "y",
12003
- "Y",
12004
- "yes",
12005
- "Yes",
12006
- "YES",
12007
- "on",
12008
- "On",
12009
- "ON",
12010
- "n",
12011
- "N",
12012
- "no",
12013
- "No",
12014
- "NO",
12015
- "off",
12016
- "Off",
12017
- "OFF"
12018
- ];
12019
- var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
12020
- function compileStyleMap(schema, map) {
12021
- if (map === null)
12022
- return {};
12023
- const result = {};
12024
- const keys = Object.keys(map);
12025
- for (let index = 0, length = keys.length;index < length; index += 1) {
12026
- let tag = keys[index];
12027
- let style = String(map[tag]);
12028
- if (tag.slice(0, 2) === "!!")
12029
- tag = "tag:yaml.org,2002:" + tag.slice(2);
12030
- const type = schema.compiledTypeMap["fallback"][tag];
12031
- if (type && _hasOwnProperty.call(type.styleAliases, style))
12032
- style = type.styleAliases[style];
12033
- result[tag] = style;
12034
- }
12035
- return result;
12036
- }
12037
- function encodeHex(character) {
12038
- let handle;
12039
- let length;
12040
- const string = character.toString(16).toUpperCase();
12041
- if (character <= 255) {
12042
- handle = "x";
12043
- length = 2;
12044
- } else if (character <= 65535) {
12045
- handle = "u";
12046
- length = 4;
12047
- } else if (character <= 4294967295) {
12048
- handle = "U";
12049
- length = 8;
12050
- } else
12051
- throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
12052
- return "\\" + handle + common.repeat("0", length - string.length) + string;
12053
- }
12054
- var QUOTING_TYPE_SINGLE = 1;
12055
- var QUOTING_TYPE_DOUBLE = 2;
12056
- function State(options) {
12057
- this.schema = options["schema"] || DEFAULT_SCHEMA;
12058
- this.indent = Math.max(1, options["indent"] || 2);
12059
- this.noArrayIndent = options["noArrayIndent"] || false;
12060
- this.skipInvalid = options["skipInvalid"] || false;
12061
- this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
12062
- this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
12063
- this.sortKeys = options["sortKeys"] || false;
12064
- this.lineWidth = options["lineWidth"] || 80;
12065
- this.noRefs = options["noRefs"] || false;
12066
- this.noCompatMode = options["noCompatMode"] || false;
12067
- this.condenseFlow = options["condenseFlow"] || false;
12068
- this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
12069
- this.forceQuotes = options["forceQuotes"] || false;
12070
- this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
12071
- this.implicitTypes = this.schema.compiledImplicit;
12072
- this.explicitTypes = this.schema.compiledExplicit;
12073
- this.tag = null;
12074
- this.result = "";
12075
- this.duplicates = [];
12076
- this.usedDuplicates = null;
12077
- }
12078
- function indentString(string, spaces) {
12079
- const ind = common.repeat(" ", spaces);
12080
- let position = 0;
12081
- let result = "";
12082
- const length = string.length;
12083
- while (position < length) {
12084
- let line;
12085
- const next = string.indexOf(`
12086
- `, position);
12087
- if (next === -1) {
12088
- line = string.slice(position);
12089
- position = length;
12090
- } else {
12091
- line = string.slice(position, next + 1);
12092
- position = next + 1;
12093
- }
12094
- if (line.length && line !== `
12095
- `)
12096
- result += ind;
12097
- result += line;
12098
- }
12099
- return result;
12100
- }
12101
- function generateNextLine(state, level) {
12102
- return `
12103
- ` + common.repeat(" ", state.indent * level);
12104
- }
12105
- function testImplicitResolving(state, str) {
12106
- for (let index = 0, length = state.implicitTypes.length;index < length; index += 1)
12107
- if (state.implicitTypes[index].resolve(str))
12108
- return true;
12109
- return false;
12110
- }
12111
- function isWhitespace(c) {
12112
- return c === CHAR_SPACE || c === CHAR_TAB;
12113
- }
12114
- function isPrintable(c) {
12115
- return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
12116
- }
12117
- function isNsCharOrWhitespace(c) {
12118
- return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
12119
- }
12120
- function isPlainSafe(c, prev, inblock) {
12121
- const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
12122
- const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
12123
- return (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar;
12124
- }
12125
- function isPlainSafeFirst(c) {
12126
- return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
12127
- }
12128
- function isPlainSafeLast(c) {
12129
- return !isWhitespace(c) && c !== CHAR_COLON;
12130
- }
12131
- function codePointAt(string, pos) {
12132
- const first = string.charCodeAt(pos);
12133
- let second;
12134
- if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
12135
- second = string.charCodeAt(pos + 1);
12136
- if (second >= 56320 && second <= 57343)
12137
- return (first - 55296) * 1024 + second - 56320 + 65536;
12138
- }
12139
- return first;
12140
- }
12141
- function needIndentIndicator(string) {
12142
- return /^\n* /.test(string);
12143
- }
12144
- var STYLE_PLAIN = 1;
12145
- var STYLE_SINGLE = 2;
12146
- var STYLE_LITERAL = 3;
12147
- var STYLE_FOLDED = 4;
12148
- var STYLE_DOUBLE = 5;
12149
- function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
12150
- let i;
12151
- let char = 0;
12152
- let prevChar = null;
12153
- let hasLineBreak = false;
12154
- let hasFoldableLine = false;
12155
- const shouldTrackWidth = lineWidth !== -1;
12156
- let previousLineBreak = -1;
12157
- let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
12158
- if (singleLineOnly || forceQuotes)
12159
- for (i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
12160
- char = codePointAt(string, i);
12161
- if (!isPrintable(char))
12162
- return STYLE_DOUBLE;
12163
- plain = plain && isPlainSafe(char, prevChar, inblock);
12164
- prevChar = char;
12165
- }
12166
- else {
12167
- for (i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
12168
- char = codePointAt(string, i);
12169
- if (char === CHAR_LINE_FEED) {
12170
- hasLineBreak = true;
12171
- if (shouldTrackWidth) {
12172
- hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
12173
- previousLineBreak = i;
12174
- }
12175
- } else if (!isPrintable(char))
12176
- return STYLE_DOUBLE;
12177
- plain = plain && isPlainSafe(char, prevChar, inblock);
12178
- prevChar = char;
12179
- }
12180
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
12181
- }
12182
- if (!hasLineBreak && !hasFoldableLine) {
12183
- if (plain && !forceQuotes && !testAmbiguousType(string))
12184
- return STYLE_PLAIN;
12185
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
12186
- }
12187
- if (indentPerLevel > 9 && needIndentIndicator(string))
12188
- return STYLE_DOUBLE;
12189
- if (!forceQuotes)
12190
- return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
12191
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
12192
- }
12193
- function writeScalar(state, string, level, iskey, inblock) {
12194
- state.dump = function() {
12195
- if (string.length === 0)
12196
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
12197
- if (!state.noCompatMode) {
12198
- if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string))
12199
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
12200
- }
12201
- const indent = state.indent * Math.max(1, level);
12202
- const lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
12203
- const singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
12204
- function testAmbiguity(string2) {
12205
- return testImplicitResolving(state, string2);
12206
- }
12207
- switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
12208
- case STYLE_PLAIN:
12209
- return string;
12210
- case STYLE_SINGLE:
12211
- return "'" + string.replace(/'/g, "''") + "'";
12212
- case STYLE_LITERAL:
12213
- return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
12214
- case STYLE_FOLDED:
12215
- return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
12216
- case STYLE_DOUBLE:
12217
- return '"' + escapeString(string, lineWidth) + '"';
12218
- default:
12219
- throw new YAMLException("impossible error: invalid scalar style");
12220
- }
12221
- }();
12222
- }
12223
- function blockHeader(string, indentPerLevel) {
12224
- const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
12225
- const clip = string[string.length - 1] === `
12226
- `;
12227
- return indentIndicator + (clip && (string[string.length - 2] === `
12228
- ` || string === `
12229
- `) ? "+" : clip ? "" : "-") + `
12230
- `;
12231
- }
12232
- function dropEndingNewline(string) {
12233
- return string[string.length - 1] === `
12234
- ` ? string.slice(0, -1) : string;
12235
- }
12236
- function foldString(string, width) {
12237
- const lineRe = /(\n+)([^\n]*)/g;
12238
- let result = function() {
12239
- let nextLF = string.indexOf(`
12240
- `);
12241
- nextLF = nextLF !== -1 ? nextLF : string.length;
12242
- lineRe.lastIndex = nextLF;
12243
- return foldLine(string.slice(0, nextLF), width);
12244
- }();
12245
- let prevMoreIndented = string[0] === `
12246
- ` || string[0] === " ";
12247
- let moreIndented;
12248
- let match;
12249
- while (match = lineRe.exec(string)) {
12250
- const prefix = match[1];
12251
- const line = match[2];
12252
- moreIndented = line[0] === " ";
12253
- result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
12254
- ` : "") + foldLine(line, width);
12255
- prevMoreIndented = moreIndented;
12256
- }
12257
- return result;
12258
- }
12259
- function foldLine(line, width) {
12260
- if (line === "" || line[0] === " ")
12261
- return line;
12262
- const breakRe = / [^ ]/g;
12263
- let match;
12264
- let start = 0;
12265
- let end;
12266
- let curr = 0;
12267
- let next = 0;
12268
- let result = "";
12269
- while (match = breakRe.exec(line)) {
12270
- next = match.index;
12271
- if (next - start > width) {
12272
- end = curr > start ? curr : next;
12273
- result += `
12274
- ` + line.slice(start, end);
12275
- start = end + 1;
12276
- }
12277
- curr = next;
12278
- }
12279
- result += `
12280
- `;
12281
- if (line.length - start > width && curr > start)
12282
- result += line.slice(start, curr) + `
12283
- ` + line.slice(curr + 1);
12284
- else
12285
- result += line.slice(start);
12286
- return result.slice(1);
12287
- }
12288
- function escapeString(string) {
12289
- let result = "";
12290
- let char = 0;
12291
- for (let i = 0;i < string.length; char >= 65536 ? i += 2 : i++) {
12292
- char = codePointAt(string, i);
12293
- const escapeSeq = ESCAPE_SEQUENCES[char];
12294
- if (!escapeSeq && isPrintable(char)) {
12295
- result += string[i];
12296
- if (char >= 65536)
12297
- result += string[i + 1];
12298
- } else
12299
- result += escapeSeq || encodeHex(char);
12300
- }
12301
- return result;
12302
- }
12303
- function writeFlowSequence(state, level, object) {
12304
- let _result = "";
12305
- const _tag = state.tag;
12306
- for (let index = 0, length = object.length;index < length; index += 1) {
12307
- let value = object[index];
12308
- if (state.replacer)
12309
- value = state.replacer.call(object, String(index), value);
12310
- if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
12311
- if (_result !== "")
12312
- _result += "," + (!state.condenseFlow ? " " : "");
12313
- _result += state.dump;
12314
- }
12315
- }
12316
- state.tag = _tag;
12317
- state.dump = "[" + _result + "]";
12318
- }
12319
- function writeBlockSequence(state, level, object, compact) {
12320
- let _result = "";
12321
- const _tag = state.tag;
12322
- for (let index = 0, length = object.length;index < length; index += 1) {
12323
- let value = object[index];
12324
- if (state.replacer)
12325
- value = state.replacer.call(object, String(index), value);
12326
- if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
12327
- if (!compact || _result !== "")
12328
- _result += generateNextLine(state, level);
12329
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0))
12330
- _result += "-";
12331
- else
12332
- _result += "- ";
12333
- _result += state.dump;
12334
- }
12335
- }
12336
- state.tag = _tag;
12337
- state.dump = _result || "[]";
12338
- }
12339
- function writeFlowMapping(state, level, object) {
12340
- let _result = "";
12341
- const _tag = state.tag;
12342
- const objectKeyList = Object.keys(object);
12343
- for (let index = 0, length = objectKeyList.length;index < length; index += 1) {
12344
- let pairBuffer = "";
12345
- if (_result !== "")
12346
- pairBuffer += ", ";
12347
- if (state.condenseFlow)
12348
- pairBuffer += '"';
12349
- const objectKey = objectKeyList[index];
12350
- let objectValue = object[objectKey];
12351
- if (state.replacer)
12352
- objectValue = state.replacer.call(object, objectKey, objectValue);
12353
- if (!writeNode(state, level, objectKey, false, false))
12354
- continue;
12355
- if (state.dump.length > 1024)
12356
- pairBuffer += "? ";
12357
- pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
12358
- if (!writeNode(state, level, objectValue, false, false))
12359
- continue;
12360
- pairBuffer += state.dump;
12361
- _result += pairBuffer;
12362
- }
12363
- state.tag = _tag;
12364
- state.dump = "{" + _result + "}";
12365
- }
12366
- function writeBlockMapping(state, level, object, compact) {
12367
- let _result = "";
12368
- const _tag = state.tag;
12369
- const objectKeyList = Object.keys(object);
12370
- if (state.sortKeys === true)
12371
- objectKeyList.sort();
12372
- else if (typeof state.sortKeys === "function")
12373
- objectKeyList.sort(state.sortKeys);
12374
- else if (state.sortKeys)
12375
- throw new YAMLException("sortKeys must be a boolean or a function");
12376
- for (let index = 0, length = objectKeyList.length;index < length; index += 1) {
12377
- let pairBuffer = "";
12378
- if (!compact || _result !== "")
12379
- pairBuffer += generateNextLine(state, level);
12380
- const objectKey = objectKeyList[index];
12381
- let objectValue = object[objectKey];
12382
- if (state.replacer)
12383
- objectValue = state.replacer.call(object, objectKey, objectValue);
12384
- if (!writeNode(state, level + 1, objectKey, true, true, true))
12385
- continue;
12386
- const explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
12387
- if (explicitPair)
12388
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0))
12389
- pairBuffer += "?";
12390
- else
12391
- pairBuffer += "? ";
12392
- pairBuffer += state.dump;
12393
- if (explicitPair)
12394
- pairBuffer += generateNextLine(state, level);
12395
- if (!writeNode(state, level + 1, objectValue, true, explicitPair))
12396
- continue;
12397
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0))
12398
- pairBuffer += ":";
12399
- else
12400
- pairBuffer += ": ";
12401
- pairBuffer += state.dump;
12402
- _result += pairBuffer;
12403
- }
12404
- state.tag = _tag;
12405
- state.dump = _result || "{}";
12406
- }
12407
- function detectType(state, object, explicit) {
12408
- const typeList = explicit ? state.explicitTypes : state.implicitTypes;
12409
- for (let index = 0, length = typeList.length;index < length; index += 1) {
12410
- const type = typeList[index];
12411
- if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
12412
- if (explicit)
12413
- if (type.multi && type.representName)
12414
- state.tag = type.representName(object);
12415
- else
12416
- state.tag = type.tag;
12417
- else
12418
- state.tag = "?";
12419
- if (type.represent) {
12420
- const style = state.styleMap[type.tag] || type.defaultStyle;
12421
- let _result;
12422
- if (_toString.call(type.represent) === "[object Function]")
12423
- _result = type.represent(object, style);
12424
- else if (_hasOwnProperty.call(type.represent, style))
12425
- _result = type.represent[style](object, style);
12426
- else
12427
- throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
12428
- state.dump = _result;
12429
- }
12430
- return true;
12431
- }
12432
- }
12433
- return false;
12434
- }
12435
- function writeNode(state, level, object, block, compact, iskey, isblockseq) {
12436
- state.tag = null;
12437
- state.dump = object;
12438
- if (!detectType(state, object, false))
12439
- detectType(state, object, true);
12440
- const type = _toString.call(state.dump);
12441
- const inblock = block;
12442
- if (block)
12443
- block = state.flowLevel < 0 || state.flowLevel > level;
12444
- const objectOrArray = type === "[object Object]" || type === "[object Array]";
12445
- let duplicateIndex;
12446
- let duplicate;
12447
- if (objectOrArray) {
12448
- duplicateIndex = state.duplicates.indexOf(object);
12449
- duplicate = duplicateIndex !== -1;
12450
- }
12451
- if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0)
12452
- compact = false;
12453
- if (duplicate && state.usedDuplicates[duplicateIndex])
12454
- state.dump = "*ref_" + duplicateIndex;
12455
- else {
12456
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex])
12457
- state.usedDuplicates[duplicateIndex] = true;
12458
- if (type === "[object Object]")
12459
- if (block && Object.keys(state.dump).length !== 0) {
12460
- writeBlockMapping(state, level, state.dump, compact);
12461
- if (duplicate)
12462
- state.dump = "&ref_" + duplicateIndex + state.dump;
12463
- } else {
12464
- writeFlowMapping(state, level, state.dump);
12465
- if (duplicate)
12466
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
12467
- }
12468
- else if (type === "[object Array]")
12469
- if (block && state.dump.length !== 0) {
12470
- if (state.noArrayIndent && !isblockseq && level > 0)
12471
- writeBlockSequence(state, level - 1, state.dump, compact);
12472
- else
12473
- writeBlockSequence(state, level, state.dump, compact);
12474
- if (duplicate)
12475
- state.dump = "&ref_" + duplicateIndex + state.dump;
12476
- } else {
12477
- writeFlowSequence(state, level, state.dump);
12478
- if (duplicate)
12479
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
12480
- }
12481
- else if (type === "[object String]") {
12482
- if (state.tag !== "?")
12483
- writeScalar(state, state.dump, level, iskey, inblock);
12484
- } else if (type === "[object Undefined]")
12485
- return false;
12486
- else {
12487
- if (state.skipInvalid)
12488
- return false;
12489
- throw new YAMLException("unacceptable kind of an object to dump " + type);
12490
- }
12491
- if (state.tag !== null && state.tag !== "?") {
12492
- let tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
12493
- if (state.tag[0] === "!")
12494
- tagStr = "!" + tagStr;
12495
- else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:")
12496
- tagStr = "!!" + tagStr.slice(18);
12497
- else
12498
- tagStr = "!<" + tagStr + ">";
12499
- state.dump = tagStr + " " + state.dump;
12500
- }
12501
- }
12502
- return true;
12503
- }
12504
- function getDuplicateReferences(object, state) {
12505
- const objects = [];
12506
- const duplicatesIndexes = [];
12507
- inspectNode(object, objects, duplicatesIndexes);
12508
- const length = duplicatesIndexes.length;
12509
- for (let index = 0;index < length; index += 1)
12510
- state.duplicates.push(objects[duplicatesIndexes[index]]);
12511
- state.usedDuplicates = new Array(length);
12512
- }
12513
- function inspectNode(object, objects, duplicatesIndexes) {
12514
- if (object !== null && typeof object === "object") {
12515
- const index = objects.indexOf(object);
12516
- if (index !== -1) {
12517
- if (duplicatesIndexes.indexOf(index) === -1)
12518
- duplicatesIndexes.push(index);
12519
- } else {
12520
- objects.push(object);
12521
- if (Array.isArray(object))
12522
- for (let i = 0, length = object.length;i < length; i += 1)
12523
- inspectNode(object[i], objects, duplicatesIndexes);
12524
- else {
12525
- const objectKeyList = Object.keys(object);
12526
- for (let i = 0, length = objectKeyList.length;i < length; i += 1)
12527
- inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes);
12528
- }
12529
- }
12530
- }
12531
- }
12532
- function dump(input, options) {
12533
- options = options || {};
12534
- const state = new State(options);
12535
- if (!state.noRefs)
12536
- getDuplicateReferences(input, state);
12537
- let value = input;
12538
- if (state.replacer)
12539
- value = state.replacer.call({ "": value }, "", value);
12540
- if (writeNode(state, 0, value, true, true))
12541
- return state.dump + `
12542
- `;
12543
- return "";
12544
- }
12545
- module.exports.dump = dump;
12546
- });
12547
- var import_js_yaml = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin((exports, module) => {
12548
- var loader = require_loader();
12549
- var dumper = require_dumper();
12550
- function renamed(from, to) {
12551
- return function() {
12552
- throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
12553
- };
12554
- }
12555
- module.exports.Type = require_type();
12556
- module.exports.Schema = require_schema();
12557
- module.exports.FAILSAFE_SCHEMA = require_failsafe();
12558
- module.exports.JSON_SCHEMA = require_json();
12559
- module.exports.CORE_SCHEMA = require_core();
12560
- module.exports.DEFAULT_SCHEMA = require_default();
12561
- module.exports.load = loader.load;
12562
- module.exports.loadAll = loader.loadAll;
12563
- module.exports.dump = dumper.dump;
12564
- module.exports.YAMLException = require_exception();
12565
- module.exports.types = {
12566
- binary: require_binary(),
12567
- float: require_float(),
12568
- map: require_map(),
12569
- null: require_null(),
12570
- pairs: require_pairs(),
12571
- set: require_set(),
12572
- timestamp: require_timestamp(),
12573
- bool: require_bool(),
12574
- int: require_int(),
12575
- merge: require_merge(),
12576
- omap: require_omap(),
12577
- seq: require_seq(),
12578
- str: require_str()
12579
- };
12580
- module.exports.safeLoad = renamed("safeLoad", "load");
12581
- module.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
12582
- module.exports.safeDump = renamed("safeDump", "dump");
12583
- }))(), 1);
12584
- var { Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, load, loadAll, dump, YAMLException, types, safeLoad, safeLoadAll, safeDump } = import_js_yaml.default;
12585
- var index_vite_proxy_tmp_default = import_js_yaml.default;
12586
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
12587
- var CharacterCodes;
12588
- (function(CharacterCodes2) {
12589
- CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
12590
- CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
12591
- CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
12592
- CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
12593
- CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
12594
- CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
12595
- CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
12596
- CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
12597
- CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
12598
- CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
12599
- CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
12600
- CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
12601
- CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
12602
- CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
12603
- CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
12604
- CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
12605
- CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
12606
- CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
12607
- CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
12608
- CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
12609
- CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
12610
- CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
12611
- CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
12612
- CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
12613
- CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
12614
- CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
12615
- CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
12616
- CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
12617
- CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
12618
- CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
12619
- CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
12620
- CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
12621
- CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
12622
- CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
12623
- CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
12624
- CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
12625
- CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
12626
- CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
12627
- CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
12628
- CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
12629
- CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
12630
- CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
12631
- CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
12632
- CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
12633
- CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
12634
- CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
12635
- CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
12636
- CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
12637
- CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
12638
- CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
12639
- CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
12640
- CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
12641
- CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
12642
- CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
12643
- CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
12644
- CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
12645
- CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
12646
- CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
12647
- CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
12648
- CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
12649
- CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
12650
- CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
12651
- CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
12652
- CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
12653
- CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
12654
- CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
12655
- CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
12656
- CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
12657
- CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
12658
- CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
12659
- CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
12660
- CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
12661
- CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
12662
- CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
12663
- CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
12664
- CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
12665
- CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
12666
- CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
12667
- CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
12668
- CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
12669
- })(CharacterCodes || (CharacterCodes = {}));
12670
-
12671
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
12672
- var cachedSpaces = new Array(20).fill(0).map((_, index) => {
12673
- return " ".repeat(index);
12674
- });
12675
- var maxCachedValues = 200;
12676
- var cachedBreakLinesWithSpaces = {
12677
- " ": {
12678
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
12679
- return `
12680
- ` + " ".repeat(index);
12681
- }),
12682
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
12683
- return "\r" + " ".repeat(index);
12684
- }),
12685
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
12686
- return `\r
12687
- ` + " ".repeat(index);
12688
- })
12689
- },
12690
- "\t": {
12691
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
12692
- return `
12693
- ` + "\t".repeat(index);
12694
- }),
12695
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
12696
- return "\r" + "\t".repeat(index);
12697
- }),
12698
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
12699
- return `\r
12700
- ` + "\t".repeat(index);
12701
- })
12702
- }
12703
- };
12704
-
12705
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
12706
- var ParseOptions;
12707
- (function(ParseOptions2) {
12708
- ParseOptions2.DEFAULT = {
12709
- allowTrailingComma: false
12710
- };
12711
- })(ParseOptions || (ParseOptions = {}));
12712
-
12713
- // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
12714
- var ScanError;
12715
- (function(ScanError2) {
12716
- ScanError2[ScanError2["None"] = 0] = "None";
12717
- ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
12718
- ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
12719
- ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
12720
- ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
12721
- ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
12722
- ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
12723
- })(ScanError || (ScanError = {}));
12724
- var SyntaxKind;
12725
- (function(SyntaxKind2) {
12726
- SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
12727
- SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
12728
- SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
12729
- SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
12730
- SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
12731
- SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
12732
- SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
12733
- SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
12734
- SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
12735
- SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
12736
- SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
12737
- SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
12738
- SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
12739
- SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
12740
- SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
12741
- SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
12742
- SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
12743
- })(SyntaxKind || (SyntaxKind = {}));
12744
- var ParseErrorCode;
12745
- (function(ParseErrorCode2) {
12746
- ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
12747
- ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
12748
- ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
12749
- ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
12750
- ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
12751
- ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
12752
- ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
12753
- ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
12754
- ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
12755
- ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
12756
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
12757
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
12758
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
12759
- ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
12760
- ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
12761
- ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
12762
- })(ParseErrorCode || (ParseErrorCode = {}));
12763
-
12764
- // packages/utils/src/jsonc-parser.ts
12765
- var pluginConfigFileDetectionCache = new Map;
12766
-
12767
- // packages/utils/src/index.ts
12768
- init_xdg_data_dir();
12769
- init_atomic_write();
12770
-
12771
- // packages/utils/src/logging/logger.ts
12772
- var DEFAULT_MAX_LOG_FILE_SIZE_BYTES = 50 * 1024 * 1024;
12773
- // packages/utils/src/logger.ts
12774
- var sharedSubunitLogger = () => {};
12775
- function log(message, data) {
12776
- sharedSubunitLogger(message, data);
12777
- }
12778
- // packages/utils/src/omo-config.ts
12779
- var HARNESS_IDS = ["codex", "opencode", "omo"];
12780
- // packages/utils/src/omo-config/loader.ts
12781
- var HARNESS_BLOCK_KEYS = HARNESS_IDS.map((harness) => `[${harness}]`);
12782
- // packages/utils/src/ast-grep/sg-manifest.ts
12783
- function normalizeRuntimePlatform(platform = process.platform) {
12784
- if (platform === "darwin" || platform === "linux" || platform === "win32")
12785
- return platform;
12786
- return "linux";
12787
- }
12788
- function normalizeRuntimeArch(arch = process.arch) {
12789
- if (arch === "arm64" || arch === "aarch64")
12790
- return "arm64";
12791
- return "x64";
12792
- }
12793
- function runtimeSlug(platform = process.platform, arch = process.arch) {
12794
- return `${normalizeRuntimePlatform(platform)}-${normalizeRuntimeArch(arch)}`;
12795
- }
12796
- // packages/utils/src/ast-grep/install-script.ts
12797
- import { spawn as spawn3 } from "node:child_process";
12798
- import { existsSync as existsSync4 } from "node:fs";
12799
- import { join as join28 } from "node:path";
12800
- var AST_GREP_BIN_DIR_ENV_KEY = "OMO_AST_GREP_BIN_DIR";
12801
- var AST_GREP_INSTALL_TIMEOUT_MS = 30000;
12802
- function astGrepRuntimeDir(baseDir, platform = process.platform, arch = process.arch) {
12803
- return join28(baseDir, "runtime", "ast-grep", runtimeSlug(platform, arch));
12804
- }
12805
- function isMissingExecutable(error) {
12806
- if (!("code" in error))
12807
- return false;
12808
- return error.code === "ENOENT";
12809
- }
12810
- function defaultSpawnProcess(command, args, options) {
12811
- const child = spawn3(command, args, {
12812
- cwd: options.cwd,
12813
- env: options.env,
12814
- stdio: "ignore",
12815
- windowsHide: true
12816
- });
12817
- let settled = false;
12818
- const outcome = new Promise((resolve9) => {
12819
- const settle = (result) => {
12820
- if (settled)
12821
- return;
12822
- settled = true;
12823
- resolve9(result);
12824
- };
12825
- child.once("error", (error) => {
12826
- settle({ kind: "spawn-error", error, missingExecutable: isMissingExecutable(error) });
12827
- });
12828
- child.once("exit", (code, signal) => {
12829
- settle({ kind: "exit", code, signal });
12830
- });
12831
- });
12832
- return {
12833
- kill: () => {
12834
- if (!child.killed)
12835
- child.kill();
12836
- },
12837
- outcome
12838
- };
12839
- }
12840
- function scriptPathForPlatform(skillDir, platform) {
12841
- return join28(skillDir, platform === "win32" ? "install.ps1" : "install.sh");
12842
- }
12843
- function invocationsForPlatform(scriptPath, platform) {
12844
- if (platform !== "win32")
12845
- return [{ command: "bash", args: [scriptPath] }];
12846
- const args = ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", scriptPath];
12847
- return [{ command: "pwsh", args }, { command: "powershell.exe", args }];
12848
- }
12849
- async function runInvocation(input) {
12850
- const child = input.spawnProcess(input.invocation.command, input.invocation.args, { cwd: input.skillDir, env: input.env });
12851
- let timedOut = false;
12852
- const timeout = setTimeout(() => {
12853
- timedOut = true;
12854
- child.kill();
12855
- }, input.timeoutMs);
12856
- timeout.unref?.();
12857
- try {
12858
- const outcome = await child.outcome;
12859
- return timedOut ? { kind: "timed-out" } : outcome;
12860
- } finally {
12861
- clearTimeout(timeout);
12862
- }
12863
- }
12864
- function failedReason(outcome) {
12865
- return outcome.error.message;
12866
- }
12867
- async function runAstGrepSkillInstall(options) {
12868
- const platform = options.platform ?? process.platform;
12869
- const fileExists = options.fileExists ?? existsSync4;
12870
- const scriptPath = scriptPathForPlatform(options.skillDir, platform);
12871
- if (!fileExists(scriptPath))
12872
- return { kind: "skipped", reason: `missing ${scriptPath}` };
12873
- const env = { ...options.env ?? process.env, [AST_GREP_BIN_DIR_ENV_KEY]: options.targetDir };
12874
- const spawnProcess = options.spawnProcess ?? defaultSpawnProcess;
12875
- const timeoutMs = options.timeoutMs ?? AST_GREP_INSTALL_TIMEOUT_MS;
12876
- const invocations = invocationsForPlatform(scriptPath, platform);
12877
- try {
12878
- for (const invocation of invocations) {
12879
- const outcome = await runInvocation({ env, invocation, skillDir: options.skillDir, spawnProcess, timeoutMs });
12880
- if (outcome.kind === "timed-out")
12881
- return { kind: "timed-out" };
12882
- if (outcome.kind === "exit") {
12883
- if (outcome.code === 0)
12884
- return { kind: "succeeded" };
12885
- return { kind: "failed", reason: `${invocation.command} exited ${outcome.code ?? outcome.signal ?? "without status"}` };
12886
- }
12887
- if (platform === "win32" && outcome.missingExecutable && invocation.command === "pwsh")
12888
- continue;
12889
- return { kind: "failed", reason: failedReason(outcome) };
12890
- }
12891
- return { kind: "failed", reason: "no ast-grep install shell was available" };
12892
- } catch (error) {
12893
- if (error instanceof Error)
12894
- return { kind: "failed", reason: error.message };
12895
- return { kind: "failed", reason: String(error) };
12896
- }
12897
- }
12898
- // packages/utils/src/codegraph/env.ts
12899
- var SAFE_AMBIENT_ENV_KEYS = new Set([
12900
- "APPDATA",
12901
- "CI",
12902
- "CODEX_HOME",
12903
- "ComSpec",
12904
- "HOME",
12905
- "HOMEDRIVE",
12906
- "HOMEPATH",
12907
- "LANG",
12908
- "LC_ALL",
12909
- "LC_CTYPE",
12910
- "LOCALAPPDATA",
12911
- "PATH",
12912
- "PATHEXT",
12913
- "Path",
12914
- "SystemRoot",
12915
- "TEMP",
12916
- "TMP",
12917
- "TMPDIR",
12918
- "USERPROFILE",
12919
- "WINDIR",
12920
- "XDG_CACHE_HOME",
12921
- "XDG_CONFIG_HOME",
12922
- "XDG_DATA_HOME",
12923
- "XDG_STATE_HOME"
12924
- ]);
12925
- var SAFE_CODEGRAPH_RUNTIME_ENV_KEYS = new Set([
12926
- "CODEGRAPH_ALLOW_UNSAFE_NODE",
12927
- "CODEGRAPH_BIN",
12928
- "CODEGRAPH_FAKE_LOG",
12929
- "CODEGRAPH_NODE_BIN",
12930
- "OMO_CODEGRAPH_BIN",
12931
- "OMO_CODEGRAPH_PROJECT_CWD",
12932
- "OMO_CODEGRAPH_SESSION_START_CWD"
12933
- ]);
12934
- // packages/utils/src/codegraph/provision.ts
12935
- import { execFile } from "node:child_process";
12936
- import { promisify } from "node:util";
12937
- var execFileAsync = promisify(execFile);
12938
- // packages/utils/src/command-executor/execute-command.ts
12939
- import { exec } from "node:child_process";
12940
- import { promisify as promisify2 } from "node:util";
12941
- var execAsync = promisify2(exec);
12942
- // packages/utils/src/internal-initiator-marker.ts
12943
- var INTERNAL_INITIATOR_MARKER_DETECT_PATTERN = /<!--\s*OMO_INTERNAL_INITIATOR\s*-->/;
12944
- var INTERNAL_NOREPLY_MARKER_DETECT_PATTERN = /<!--\s*OMO_INTERNAL_NOREPLY\s*-->/;
12945
- function hasInternalInitiatorMarker(text) {
12946
- return INTERNAL_INITIATOR_MARKER_DETECT_PATTERN.test(text);
12947
- }
12948
- function hasInternalNoReplyMarker(text) {
12949
- return INTERNAL_NOREPLY_MARKER_DETECT_PATTERN.test(text);
12950
- }
12951
- function isTextPartLike(part) {
12952
- return part.type === "text" && typeof part.text === "string";
12953
- }
12954
- function isSyntheticOrInternalTextPart(part) {
12955
- return isTextPartLike(part) && (part.synthetic === true || hasInternalInitiatorMarker(part.text));
12956
- }
12957
- function isSyntheticOrInternalOnlyTextParts(parts) {
12958
- const textParts = (parts ?? []).filter(isTextPartLike);
12959
- return textParts.length > 0 && textParts.every(isSyntheticOrInternalTextPart);
12960
- }
12961
- function isSyntheticOrInternalUserMessage(message) {
12962
- const role = message.info?.role ?? message.role;
12963
- return role === "user" && isSyntheticOrInternalOnlyTextParts(message.parts);
12964
- }
12965
- function isNoReplyTextPart(part) {
12966
- return isTextPartLike(part) && hasInternalNoReplyMarker(part.text);
12967
- }
12968
- function isTerminalNoReplyUserMessage(message) {
12969
- const role = message.info?.role ?? message.role;
12970
- if (role !== "user") {
12971
- return false;
12972
- }
12973
- const textParts = (message.parts ?? []).filter(isTextPartLike);
12974
- return textParts.some(isNoReplyTextPart);
12975
- }
12976
- // packages/utils/src/migration/agent-names.ts
12977
- var BUILTIN_AGENT_NAMES = new Set([
12978
- "sisyphus",
12979
- "oracle",
12980
- "librarian",
12981
- "explore",
12982
- "multimodal-looker",
12983
- "metis",
12984
- "momus",
12985
- "prometheus",
12986
- "atlas",
12987
- "build"
12988
- ]);
12989
- // packages/utils/src/migration/model-versions.ts
12990
- var CURRENT_USER_SELECTABLE_MODELS = new Set([
12991
- "anthropic/claude-opus-4-5",
12992
- "anthropic/claude-opus-4-6",
12993
- "anthropic/claude-sonnet-4-5"
12994
- ]);
12995
- // packages/utils/src/write-file-atomically.ts
12996
- init_atomic_write();
12997
- // packages/utils/src/session-idle-settle.ts
12998
- var DEFAULT_SESSION_IDLE_SETTLE_MS = 150;
12999
- var DEFAULT_SESSION_STATUS_TIMEOUT_MS = 5000;
13000
- function settleAfterSessionIdle(ms = DEFAULT_SESSION_IDLE_SETTLE_MS) {
13001
- return ms > 0 ? new Promise((resolve10) => setTimeout(resolve10, ms)) : Promise.resolve();
13002
- }
13003
- function withStatusTimeout(promise, timeoutMs) {
13004
- let timeoutID;
13005
- const timeoutPromise = new Promise((_resolve, reject) => {
13006
- timeoutID = setTimeout(() => {
13007
- reject(new Error(`session.status() timed out after ${timeoutMs}ms`));
13008
- }, timeoutMs);
13009
- });
13010
- return Promise.race([promise, timeoutPromise]).finally(() => {
13011
- if (timeoutID !== undefined) {
13012
- clearTimeout(timeoutID);
13013
- }
13014
- });
13015
- }
13016
- var ACTIVE_SESSION_STATUSES = new Set(["busy", "retry", "running"]);
13017
- function getSessionStatusPayload(response) {
13018
- if (isRecord(response) && isRecord(response.data)) {
13019
- return response.data;
13020
- }
13021
- if (isRecord(response)) {
13022
- return response;
13023
- }
13024
- return {};
13025
- }
13026
- function isActiveSessionStatusType(statusType) {
13027
- return ACTIVE_SESSION_STATUSES.has(statusType);
13028
- }
13029
- async function isSessionActive(client, sessionID, statusTimeoutMs = DEFAULT_SESSION_STATUS_TIMEOUT_MS) {
13030
- if (typeof client.session?.status !== "function") {
13031
- return false;
13032
- }
13033
- try {
13034
- const statusResult = await withStatusTimeout(client.session.status(), statusTimeoutMs);
13035
- const status = getSessionStatusPayload(statusResult)[sessionID];
13036
- if (!isRecord(status)) {
13037
- return false;
13038
- }
13039
- const statusType = status.type;
13040
- return typeof statusType === "string" && isActiveSessionStatusType(statusType);
13041
- } catch (error) {
13042
- if (error instanceof Error) {
13043
- return false;
13044
- }
13045
- return false;
13046
- }
13047
- }
13048
-
13049
- // packages/utils/src/prompt-async-gate/prompt-message-state.ts
13050
- function messageRole(message) {
13051
- if (!isRecord(message)) {
13052
- return;
13053
- }
13054
- const info = message.info;
13055
- if (isRecord(info) && typeof info.role === "string") {
13056
- return info.role;
13057
- }
13058
- return typeof message.role === "string" ? message.role : undefined;
13059
- }
13060
- function messageFinish(message) {
13061
- if (!isRecord(message)) {
13062
- return;
13063
- }
13064
- const info = message.info;
13065
- if (isRecord(info)) {
13066
- if (info.finish === true) {
13067
- return true;
13068
- }
13069
- if (typeof info.finish === "string" && info.finish.length > 0) {
13070
- return info.finish;
13071
- }
13072
- }
13073
- if (message.finish === true) {
13074
- return true;
13075
- }
13076
- return typeof message.finish === "string" && message.finish.length > 0 ? message.finish : undefined;
13077
- }
13078
- function messageCompleted(message) {
13079
- if (!isRecord(message)) {
13080
- return false;
13081
- }
13082
- const info = message.info;
13083
- const time = isRecord(info) && isRecord(info.time) ? info.time : undefined;
13084
- const completed = time?.completed;
13085
- if (typeof completed === "number" && Number.isFinite(completed)) {
13086
- return true;
13087
- }
13088
- return typeof completed === "string" && completed.length > 0;
13089
- }
13090
- function messageHasTerminalError(message) {
13091
- if (!isRecord(message)) {
13092
- return false;
13093
- }
13094
- const info = message.info;
13095
- if (isRecord(info) && info.error !== undefined && info.error !== null) {
13096
- return true;
13097
- }
13098
- return message.error !== undefined && message.error !== null;
13099
- }
13100
- function toInternalInitiatorTextPartLike(part) {
13101
- const result = {};
13102
- if (!isRecord(part)) {
13103
- return result;
13104
- }
13105
- if (typeof part.type === "string") {
13106
- result.type = part.type;
13107
- }
13108
- if (typeof part.text === "string") {
13109
- result.text = part.text;
13110
- }
13111
- if (typeof part.synthetic === "boolean") {
13112
- result.synthetic = part.synthetic;
13113
- }
13114
- return result;
13115
- }
13116
- function toInternalInitiatorMessageLike(message) {
13117
- if (!isRecord(message)) {
13118
- return;
13119
- }
13120
- const result = {};
13121
- const info = message.info;
13122
- if (isRecord(info) && typeof info.role === "string") {
13123
- result.info = { role: info.role };
13124
- }
13125
- if (typeof message.role === "string") {
13126
- result.role = message.role;
13127
- }
13128
- if (Array.isArray(message.parts)) {
13129
- result.parts = message.parts.map(toInternalInitiatorTextPartLike);
13130
- }
13131
- return result;
13132
- }
13133
- function messageIsSyntheticOrInternalUser(message) {
13134
- const initiatorMessage = toInternalInitiatorMessageLike(message);
13135
- return initiatorMessage !== undefined && isSyntheticOrInternalUserMessage(initiatorMessage);
13136
- }
13137
- function messageIsTerminalNoReplyUser(message) {
13138
- const initiatorMessage = toInternalInitiatorMessageLike(message);
13139
- return initiatorMessage !== undefined && isTerminalNoReplyUserMessage(initiatorMessage);
13140
- }
13141
- function messageHasInternalInitiatorMarker(message) {
13142
- const initiatorMessage = toInternalInitiatorMessageLike(message);
13143
- if (initiatorMessage === undefined) {
13144
- return false;
13145
- }
13146
- return (initiatorMessage.parts ?? []).some((part) => part.type === "text" && typeof part.text === "string" && hasInternalInitiatorMarker(part.text));
13147
- }
13148
- var QUESTION_TOOL_NAMES = new Set(["question", "ask_user_question", "askuserquestion"]);
13149
- function partToolName(part) {
13150
- if (typeof part.name === "string") {
13151
- return part.name;
13152
- }
13153
- if (typeof part.tool === "string") {
13154
- return part.tool;
13155
- }
13156
- return typeof part.toolName === "string" ? part.toolName : undefined;
13157
- }
13158
- function partIsToolCall(part) {
13159
- return part.type === "tool" || part.type === "tool_use" || part.type === "tool-call" || part.type === "tool-invocation";
13160
- }
13161
- function partIsQuestionTool(part) {
13162
- if (!isRecord(part) || !partIsToolCall(part)) {
13163
- return false;
13164
- }
13165
- const toolName = partToolName(part);
13166
- return toolName !== undefined && QUESTION_TOOL_NAMES.has(toolName.toLowerCase());
13167
- }
13168
- function partIsUnansweredQuestionTool(part) {
13169
- if (!partIsQuestionTool(part) || !isRecord(part)) {
13170
- return false;
13171
- }
13172
- const state = part.state;
13173
- if (!isRecord(state)) {
13174
- return true;
13175
- }
13176
- return state.status !== "completed";
13177
- }
13178
- function partIsWaitingOnTool(part) {
13179
- if (!isRecord(part)) {
13180
- return false;
13181
- }
13182
- if (!partIsToolCall(part)) {
13183
- return false;
13184
- }
13185
- const state = part.state;
13186
- if (!isRecord(state)) {
13187
- return false;
13188
- }
13189
- return state.status === "pending" || state.status === "running";
13190
- }
13191
- function partIsUnresolvedTool(part) {
13192
- if (!isRecord(part) || !partIsToolCall(part)) {
13193
- return false;
13194
- }
13195
- const state = part.state;
13196
- if (!isRecord(state)) {
13197
- return true;
13198
- }
13199
- return state.status !== "completed";
13200
- }
13201
- function partHasSubstantiveAssistantOutput(part) {
13202
- if (!isRecord(part)) {
13203
- return false;
13204
- }
13205
- if (part.type === "step-start" || part.type === "step-finish") {
13206
- return false;
13207
- }
13208
- if (part.type === "text") {
13209
- return typeof part.text === "string" && part.text.trim().length > 0;
13210
- }
13211
- return typeof part.type === "string" && part.type.length > 0;
13212
- }
13213
- function messageHasQuestionTool(message) {
13214
- return isRecord(message) && Array.isArray(message.parts) && message.parts.some(partIsUnansweredQuestionTool);
13215
- }
13216
- function messageHasWaitingTool(message) {
13217
- return isRecord(message) && Array.isArray(message.parts) && message.parts.some(partIsWaitingOnTool);
13218
- }
13219
- function messageHasUnresolvedTool(message) {
13220
- return isRecord(message) && Array.isArray(message.parts) && message.parts.some(partIsUnresolvedTool);
13221
- }
13222
- function messageHasSubstantiveAssistantOutput(message) {
13223
- return isRecord(message) && Array.isArray(message.parts) && message.parts.some(partHasSubstantiveAssistantOutput);
13224
- }
13225
-
13226
- // packages/utils/src/prompt-async-gate/message-inspection-error.ts
13227
- function isPromptMessageInspectionAborted(error) {
13228
- if (error instanceof Error && error.name === "MessageAbortedError") {
13229
- return true;
13230
- }
13231
- return isRecord(error) && error.name === "MessageAbortedError";
13232
- }
13233
-
13234
- // packages/utils/src/prompt-async-gate/timing.ts
13235
- var DEFAULT_PROMPT_GATE_MESSAGES_FETCH_TIMEOUT_MS = 5000;
13236
- var promptGateMessagesFetchTimeoutMsForTesting;
13237
- function getPromptGateMessagesFetchTimeoutMs() {
13238
- return promptGateMessagesFetchTimeoutMsForTesting ?? DEFAULT_PROMPT_GATE_MESSAGES_FETCH_TIMEOUT_MS;
13239
- }
13240
- async function withDispatchTimeout(operation, dispatchTimeoutMs, operationName) {
13241
- if (dispatchTimeoutMs <= 0) {
13242
- return operation;
13243
- }
13244
- let timeoutID;
13245
- const timeoutPromise = new Promise((_, reject) => {
13246
- timeoutID = setTimeout(() => {
13247
- reject(new Error(`${operationName} timed out after ${dispatchTimeoutMs}ms`));
13248
- }, dispatchTimeoutMs);
13249
- });
13250
- try {
13251
- return await Promise.race([operation, timeoutPromise]);
13252
- } finally {
13253
- if (timeoutID !== undefined) {
13254
- clearTimeout(timeoutID);
13255
- }
13256
- }
13257
- }
13258
-
13259
- // packages/utils/src/prompt-async-gate/pending-tool-turn.ts
13260
- function getPromptQuery(input) {
13261
- if (!isRecord(input)) {
13262
- return { directory: "" };
13263
- }
13264
- const query = input.query;
13265
- if (!isRecord(query)) {
13266
- return { directory: "" };
13267
- }
13268
- const promptQuery = { directory: "" };
13269
- if (typeof query.directory === "string") {
13270
- return typeof query.limit === "number" ? { directory: query.directory, limit: query.limit } : { directory: query.directory };
13271
- }
13272
- if (typeof query.limit === "number") {
13273
- return { ...promptQuery, limit: query.limit };
13274
- }
13275
- return promptQuery;
13276
- }
13277
- function getMessagesData(response) {
13278
- if (isRecord(response) && Array.isArray(response.data)) {
13279
- return response.data;
13280
- }
13281
- return Array.isArray(response) ? response : [];
13282
- }
13283
- function latestAssistantTurnBlocksInternalPrompt(messages) {
13284
- let sawAssistantAfterLatestUser = false;
13285
- for (let index = messages.length - 1;index >= 0; index--) {
13286
- const message = messages[index];
13287
- const role = messageRole(message);
13288
- if (role === "assistant") {
13289
- sawAssistantAfterLatestUser = true;
13290
- if (messageHasQuestionTool(message)) {
13291
- return true;
13292
- }
13293
- const finish = messageFinish(message);
13294
- if (finish === "tool-calls") {
13295
- return !isRecord(message) || !Array.isArray(message.parts) || messageHasUnresolvedTool(message);
13296
- }
13297
- if ((finish === undefined || finish === "unknown") && !messageHasSubstantiveAssistantOutput(message)) {
13298
- return !(messageCompleted(message) && messageHasTerminalError(message));
13299
- }
13300
- if (messageCompleted(message)) {
13301
- return false;
13302
- }
13303
- if (finish === true) {
13304
- return false;
13305
- }
13306
- if (finish === undefined || finish === "unknown") {
13307
- return true;
13308
- }
13309
- if (!isRecord(message) || !Array.isArray(message.parts)) {
13310
- return finish === "tool-calls";
13311
- }
13312
- return messageHasWaitingTool(message);
13313
- }
13314
- if (role === "user") {
13315
- if (messageIsSyntheticOrInternalUser(message)) {
13316
- if (messageIsTerminalNoReplyUser(message)) {
13317
- continue;
13318
- }
13319
- if (!sawAssistantAfterLatestUser) {
13320
- if (messageHasInternalInitiatorMarker(message)) {
13321
- continue;
13322
- }
13323
- return true;
13324
- }
13325
- continue;
13326
- }
13327
- return false;
13328
- }
13329
- }
13330
- return false;
13331
- }
13332
- async function sessionLatestAssistantBlocksInternalPrompt(args) {
13333
- const session = args.client.session;
13334
- if (typeof session?.messages !== "function") {
13335
- return false;
13336
- }
13337
- const messages = session.messages.bind(session);
13338
- try {
13339
- const response = await withDispatchTimeout(messages({
13340
- path: { id: args.sessionID },
13341
- query: getPromptQuery(args.input)
13342
- }), args.timeoutMs, `[prompt-async-gate] ${args.sessionName} session.messages`);
13343
- return latestAssistantTurnBlocksInternalPrompt(getMessagesData(response));
13344
- } catch (error) {
13345
- log("[prompt-async-gate] latest assistant prompt-block check failed", {
13346
- sessionID: args.sessionID,
13347
- source: args.source,
13348
- error: String(error)
13349
- });
13350
- return !isPromptMessageInspectionAborted(error);
13351
- }
13352
- }
13353
-
13354
- // packages/utils/src/prompt-async-gate/recent-dispatches.ts
13355
- var recentPromptDispatches = new Map;
13356
- function recentDispatchKey(sessionID, dedupeKey) {
13357
- return `${sessionID}\x00${dedupeKey}`;
13358
- }
13359
- function pruneRecentPromptDispatches(now = Date.now()) {
13360
- for (const [key, dispatch] of recentPromptDispatches) {
13361
- if (dispatch.expiresAt <= now) {
13362
- recentPromptDispatches.delete(key);
13363
- }
13364
- }
13365
- }
13366
- function rememberRecentPromptDispatch(args) {
13367
- pruneRecentPromptDispatches();
13368
- if (args.holdMs <= 0) {
13369
- return;
13370
- }
13371
- recentPromptDispatches.set(recentDispatchKey(args.sessionID, args.dedupeKey), {
13372
- source: args.source,
13373
- expiresAt: Date.now() + args.holdMs
13374
- });
13375
- log("[prompt-async-gate] remembered semantic prompt dispatch", {
13376
- sessionID: args.sessionID,
13377
- source: args.source,
13378
- holdMs: args.holdMs
13379
- });
13380
- }
13381
-
13382
- // packages/utils/src/prompt-async-gate/reservations.ts
13383
- var promptAsyncReservations = new Map;
13384
- var expiredReservationHandler;
13385
- function setExpiredReservationHandler(handler) {
13386
- expiredReservationHandler = handler;
13387
- }
13388
- function notifyExpiredReservation(sessionID) {
13389
- expiredReservationHandler?.(sessionID);
13390
- }
13391
- function pruneExpiredReservations(now = Date.now()) {
13392
- const expiredSessionIDs = [];
13393
- for (const [sessionID, reservation] of promptAsyncReservations) {
13394
- if (typeof reservation.expiresAt === "number" && reservation.expiresAt <= now) {
13395
- promptAsyncReservations.delete(sessionID);
13396
- expiredSessionIDs.push(sessionID);
13397
- log("[prompt-async-gate] expired reservation released", {
13398
- sessionID,
13399
- source: reservation.source
13400
- });
13401
- }
13402
- }
13403
- for (const sessionID of expiredSessionIDs) {
13404
- notifyExpiredReservation(sessionID);
13405
- }
13406
- }
13407
- function getActiveReservation(sessionID) {
13408
- pruneExpiredReservations();
13409
- return promptAsyncReservations.get(sessionID);
13410
- }
13411
- function setPromptReservation(sessionID, reservation) {
13412
- promptAsyncReservations.set(sessionID, reservation);
13413
- }
13414
- function finishPromptReservation(sessionID, reservation, dispatchAttempted, postDispatchHoldMs) {
13415
- const current = promptAsyncReservations.get(sessionID);
13416
- if (current?.token !== reservation.token) {
13417
- return;
13418
- }
13419
- if (dispatchAttempted && postDispatchHoldMs > 0) {
13420
- promptAsyncReservations.set(sessionID, {
13421
- ...reservation,
13422
- expiresAt: Date.now() + postDispatchHoldMs
13423
- });
13424
- return;
13425
- }
13426
- promptAsyncReservations.delete(sessionID);
13427
- }
13428
-
13429
- // packages/utils/src/prompt-async-gate/session-idle-dispatch.ts
13430
- async function dispatchAfterSessionIdle(args) {
13431
- const {
13432
- sessionName,
13433
- client,
13434
- sessionID,
13435
- input,
13436
- source,
13437
- dedupeKey,
13438
- settleMs,
13439
- postDispatchHoldMs,
13440
- semanticDedupeHoldMs,
13441
- dispatchTimeoutMs,
13442
- checkStatus,
13443
- checkToolState,
13444
- dispatch
13445
- } = args;
13446
- const existing = getActiveReservation(sessionID);
13447
- if (existing) {
13448
- log(`[prompt-async-gate] ${sessionName} skipped because session is reserved`, {
13449
- sessionID,
13450
- source,
13451
- reservedBy: existing.source,
13452
- reservedAgeMs: Date.now() - existing.reservedAt
13453
- });
13454
- return { status: "reserved", reservedBy: existing.source };
13455
- }
13456
- const reservation = {
13457
- source,
13458
- dedupeKey,
13459
- reservedAt: Date.now(),
13460
- token: Symbol(source)
13461
- };
13462
- setPromptReservation(sessionID, reservation);
13463
- let dispatchAttempted = false;
13464
- try {
13465
- const canReadStatus = checkStatus && typeof client.session?.status === "function";
13466
- if (settleMs > 0) {
13467
- await settleAfterSessionIdle(settleMs);
13468
- }
13469
- let sessionActive = false;
13470
- if (canReadStatus) {
13471
- try {
13472
- sessionActive = await withDispatchTimeout(isSessionActive(client, sessionID), Math.min(dispatchTimeoutMs, 5000), `[prompt-async-gate] ${sessionName} isSessionActive`);
13473
- } catch (error) {
13474
- if (error instanceof Error) {
13475
- sessionActive = false;
13476
- }
13477
- sessionActive = false;
13478
- }
13479
- }
13480
- if (sessionActive) {
13481
- log(`[prompt-async-gate] ${sessionName} skipped because session is active`, { sessionID, source });
13482
- return { status: "active" };
13483
- }
13484
- if (checkToolState && typeof client.session?.messages === "function" && await sessionLatestAssistantBlocksInternalPrompt({
13485
- client,
13486
- sessionID,
13487
- input,
13488
- sessionName,
13489
- source,
13490
- timeoutMs: Math.min(dispatchTimeoutMs, getPromptGateMessagesFetchTimeoutMs())
13491
- })) {
13492
- log(`[prompt-async-gate] ${sessionName} skipped because latest assistant is still active`, {
13493
- sessionID,
13494
- source
13495
- });
13496
- return { status: "active" };
13497
- }
13498
- log(`[prompt-async-gate] ${sessionName} dispatching`, { sessionID, source });
13499
- dispatchAttempted = true;
13500
- const response = await withDispatchTimeout(dispatch(input), dispatchTimeoutMs, `[prompt-async-gate] ${sessionName} dispatch`);
13501
- rememberRecentPromptDispatch({
13502
- sessionID,
13503
- dedupeKey,
13504
- source,
13505
- holdMs: semanticDedupeHoldMs
13506
- });
13507
- log(`[prompt-async-gate] ${sessionName} dispatched`, { sessionID, source });
13508
- return { status: "dispatched", response };
13509
- } catch (error) {
13510
- if (dispatchAttempted) {
13511
- rememberRecentPromptDispatch({
13512
- sessionID,
13513
- dedupeKey,
13514
- source,
13515
- holdMs: semanticDedupeHoldMs
13516
- });
13517
- }
13518
- const errorText = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
13519
- log(`[prompt-async-gate] ${sessionName} failed`, { sessionID, source, error: errorText });
13520
- return { status: "failed", error, dispatchAttempted };
13521
- } finally {
13522
- finishPromptReservation(sessionID, reservation, dispatchAttempted, postDispatchHoldMs);
9935
+ return { kind: "failed", reason: "no ast-grep install shell was available" };
9936
+ } catch (error) {
9937
+ if (error instanceof Error)
9938
+ return { kind: "failed", reason: error.message };
9939
+ return { kind: "failed", reason: String(error) };
13523
9940
  }
13524
9941
  }
13525
9942
 
13526
- // packages/utils/src/prompt-async-gate/queue.ts
13527
- var promptQueues = new Map;
13528
- var promptQueueDraining = new Set;
13529
- var promptQueueInFlight = new Map;
13530
- var promptQueueTimers = new Map;
13531
- setExpiredReservationHandler((sessionID) => {
13532
- schedulePromptQueueDrain(sessionID, 0);
13533
- });
13534
- function setPromptQueue(sessionID, queue) {
13535
- if (queue.length === 0) {
13536
- promptQueues.delete(sessionID);
13537
- return;
13538
- }
13539
- promptQueues.set(sessionID, queue);
13540
- }
13541
- function queuedResult(entry, position, queuedBy = entry.source) {
13542
- return {
13543
- status: "queued",
13544
- queuedBy,
13545
- position
13546
- };
13547
- }
13548
- function clearPromptQueueTimer(sessionID) {
13549
- const timer = promptQueueTimers.get(sessionID);
13550
- if (timer !== undefined) {
13551
- clearTimeout(timer);
13552
- promptQueueTimers.delete(sessionID);
13553
- }
13554
- }
13555
- function schedulePromptQueueDrain(sessionID, delayMs) {
13556
- const queue = promptQueues.get(sessionID);
13557
- if (!queue || queue.length === 0) {
13558
- clearPromptQueueTimer(sessionID);
13559
- return;
13560
- }
13561
- clearPromptQueueTimer(sessionID);
13562
- const timer = setTimeout(() => {
13563
- promptQueueTimers.delete(sessionID);
13564
- drainPromptQueue(sessionID).catch((error) => {
13565
- log("[prompt-async-gate] queued prompt drain failed", {
13566
- sessionID,
13567
- error: String(error)
13568
- });
13569
- });
13570
- }, Math.max(0, delayMs));
13571
- promptQueueTimers.set(sessionID, timer);
13572
- }
13573
- function removePromptQueueEntry(sessionID, entry) {
13574
- const queue = promptQueues.get(sessionID);
13575
- if (!queue) {
13576
- return;
13577
- }
13578
- const nextQueue = queue.filter((queued) => queued.id !== entry.id);
13579
- setPromptQueue(sessionID, nextQueue);
13580
- }
13581
- async function drainPromptQueue(sessionID, awaitedEntry) {
13582
- if (promptQueueDraining.has(sessionID)) {
13583
- return awaitedEntry ? queuedResult(awaitedEntry, 1) : undefined;
13584
- }
13585
- promptQueueDraining.add(sessionID);
13586
- clearPromptQueueTimer(sessionID);
13587
- let awaitedResult;
13588
- try {
13589
- while (true) {
13590
- const queue = promptQueues.get(sessionID);
13591
- const entry = queue?.[0];
13592
- if (!entry) {
13593
- break;
13594
- }
13595
- promptQueueInFlight.set(sessionID, entry);
13596
- const result = await dispatchAfterSessionIdle({
13597
- sessionName: entry.sessionName,
13598
- client: entry.client,
13599
- sessionID: entry.sessionID,
13600
- input: entry.input,
13601
- source: entry.source,
13602
- dedupeKey: entry.dedupeKey,
13603
- settleMs: entry.settleMs,
13604
- postDispatchHoldMs: entry.postDispatchHoldMs,
13605
- semanticDedupeHoldMs: entry.semanticDedupeHoldMs,
13606
- dispatchTimeoutMs: entry.dispatchTimeoutMs,
13607
- checkStatus: entry.checkStatus,
13608
- checkToolState: entry.checkToolState,
13609
- dispatch: entry.dispatch
13610
- });
13611
- if (promptQueueInFlight.get(sessionID)?.id === entry.id) {
13612
- promptQueueInFlight.delete(sessionID);
13613
- }
13614
- if (result.status === "active" || result.status === "reserved") {
13615
- const queued = queuedResult(entry, 1, result.status === "reserved" ? result.reservedBy : entry.source);
13616
- if (awaitedEntry?.id === entry.id) {
13617
- awaitedResult = queued;
13618
- }
13619
- schedulePromptQueueDrain(sessionID, entry.queueRetryMs);
13620
- break;
13621
- }
13622
- removePromptQueueEntry(sessionID, entry);
13623
- if (awaitedEntry?.id === entry.id) {
13624
- awaitedResult = result;
13625
- }
13626
- const remainingQueue = promptQueues.get(sessionID);
13627
- if (!remainingQueue || remainingQueue.length === 0) {
13628
- break;
13629
- }
13630
- schedulePromptQueueDrain(sessionID, entry.postDispatchHoldMs);
13631
- break;
13632
- }
13633
- } finally {
13634
- promptQueueDraining.delete(sessionID);
13635
- }
13636
- return awaitedResult;
13637
- }
13638
9943
  // packages/omo-codex/src/install/install-ast-grep-sg.ts
13639
9944
  function describeResult(result) {
13640
9945
  if (result.kind === "succeeded")
@@ -13679,21 +9984,21 @@ async function trackCodexInstallTelemetry() {
13679
9984
  // packages/omo-codex/src/install/install-codex.ts
13680
9985
  var SISYPHUS_LEGACY_CACHE_MARKETPLACES = ["lazycodex", "code-yeongyu-codex-plugins"];
13681
9986
  async function runCodexInstaller(options = {}) {
13682
- const env3 = options.env ?? process.env;
9987
+ const env2 = options.env ?? process.env;
13683
9988
  const platform = options.platform ?? process.platform;
13684
- const repoRoot = resolve11(options.repoRoot ?? findRepoRoot({ importerDir: import.meta.dir, env: env3 }));
13685
- const codexHome = resolve11(options.codexHome ?? env3.CODEX_HOME ?? join32(homedir2(), ".codex"));
13686
- const projectDirectory = resolve11(options.projectDirectory ?? env3.OMO_CODEX_PROJECT ?? process.cwd());
13687
- const binDir = resolveCodexInstallerBinDir({ binDir: options.binDir, codexHome, env: env3 });
9989
+ const repoRoot = resolve9(options.repoRoot ?? findRepoRoot({ importerDir: import.meta.dir, env: env2 }));
9990
+ const codexHome = resolve9(options.codexHome ?? env2.CODEX_HOME ?? join32(homedir2(), ".codex"));
9991
+ const projectDirectory = resolve9(options.projectDirectory ?? env2.OMO_CODEX_PROJECT ?? process.cwd());
9992
+ const binDir = resolveCodexInstallerBinDir({ binDir: options.binDir, codexHome, env: env2 });
13688
9993
  const runCommand = options.runCommand ?? defaultRunCommand;
13689
- const log2 = options.log ?? (() => {
9994
+ const log = options.log ?? (() => {
13690
9995
  return;
13691
9996
  });
13692
9997
  const buildSource = await shouldBuildSourcePackages(repoRoot);
13693
9998
  const gitBashResolution = await prepareGitBashForInstall({
13694
9999
  platform,
13695
- env: env3,
13696
- resolveGitBash: platform === "win32" ? options.gitBashResolver ?? (() => resolveGitBashForCurrentProcess2({ platform, env: env3 })) : undefined
10000
+ env: env2,
10001
+ resolveGitBash: platform === "win32" ? options.gitBashResolver ?? (() => resolveGitBashForCurrentProcess2({ platform, env: env2 })) : undefined
13697
10002
  });
13698
10003
  if (!gitBashResolution.found) {
13699
10004
  throw new Error(gitBashResolution.installHint);
@@ -13719,7 +10024,7 @@ async function runCodexInstaller(options = {}) {
13719
10024
  distributionManifest
13720
10025
  });
13721
10026
  validatePathSegment(version2, "plugin version");
13722
- log2(`Building ${entry.name}@${version2}`);
10027
+ log(`Building ${entry.name}@${version2}`);
13723
10028
  const plugin = await installCachedPlugin({
13724
10029
  buildSource,
13725
10030
  codexHome,
@@ -13735,14 +10040,14 @@ async function runCodexInstaller(options = {}) {
13735
10040
  }
13736
10041
  const links = await linkCachedPluginBins({ binDir, pluginRoot: plugin.path, platform });
13737
10042
  for (const link of links) {
13738
- log2(`Linked ${link.name} -> ${link.target}`);
10043
+ log(`Linked ${link.name} -> ${link.target}`);
13739
10044
  }
13740
10045
  if (marketplace.name === "sisyphuslabs" && plugin.name === "omo") {
13741
10046
  const runtimeLink = await linkRootRuntimeBin({ binDir, codexHome, repoRoot, platform });
13742
10047
  if (runtimeLink !== null)
13743
- log2(`Linked ${runtimeLink.name} -> ${runtimeLink.target}`);
10048
+ log(`Linked ${runtimeLink.name} -> ${runtimeLink.target}`);
13744
10049
  else
13745
- log2(`Warning: skipped the omo runtime wrapper because ${join32(repoRoot, "dist", "cli", "index.js")} is missing; omo ulw-loop commands will be unavailable until a package shipping dist/cli is installed`);
10050
+ log(`Warning: skipped the omo runtime wrapper because ${join32(repoRoot, "dist", "cli", "index.js")} is missing; omo ulw-loop commands will be unavailable until a package shipping dist/cli is installed`);
13746
10051
  }
13747
10052
  pluginSources.push({ name: entry.name, sourcePath });
13748
10053
  installed.push(plugin);
@@ -13751,7 +10056,7 @@ async function runCodexInstaller(options = {}) {
13751
10056
  codexHome,
13752
10057
  installed,
13753
10058
  installer: options.astGrepInstaller,
13754
- log: log2,
10059
+ log,
13755
10060
  platform
13756
10061
  });
13757
10062
  const preservedReasoning = await capturePreservedAgentReasoning({ codexHome });
@@ -13772,7 +10077,7 @@ async function runCodexInstaller(options = {}) {
13772
10077
  preservedServiceTier
13773
10078
  });
13774
10079
  for (const link of agentLinks) {
13775
- log2(`Linked agent ${link.name} -> ${link.target}`);
10080
+ log(`Linked agent ${link.name} -> ${link.target}`);
13776
10081
  const agentName = agentNameFromToml2(link.name);
13777
10082
  agentConfigs.set(agentName, { name: agentName, configFile: `./agents/${link.name}` });
13778
10083
  }
@@ -13810,25 +10115,25 @@ async function runCodexInstaller(options = {}) {
13810
10115
  marketplaceSource: codexMarketplaceSource(marketplaceRoot),
13811
10116
  pluginNames: marketplace.plugins.map((plugin) => plugin.name),
13812
10117
  platform,
13813
- codegraphMcpEnabled: options.codegraphMcpEnabled ?? resolveCodegraphNodeSupport({ env: env3 }).supported,
10118
+ codegraphMcpEnabled: options.codegraphMcpEnabled ?? resolveCodegraphNodeSupport({ env: env2 }).supported,
13814
10119
  gitBashEnabled: platform === "win32" && gitBashResolution.found,
13815
10120
  trustedHookStates,
13816
10121
  agentConfigs: [...agentConfigs.values()].sort((left, right) => left.name.localeCompare(right.name)),
13817
10122
  autonomousPermissions: options.autonomousPermissions !== false
13818
10123
  });
13819
- await seedAndMigrateOmoSot({ env: env3, log: log2, repoRoot, runCommand });
10124
+ await seedAndMigrateOmoSot({ env: env2, log, repoRoot, runCommand });
13820
10125
  const projectCleanup = await repairProjectLocalCodexArtifactsBestEffort({
13821
10126
  startDirectory: projectDirectory,
13822
10127
  codexHome,
13823
- log: log2
10128
+ log
13824
10129
  });
13825
10130
  for (const configCleanup of projectCleanup.configs) {
13826
10131
  if (!configCleanup.changed)
13827
10132
  continue;
13828
- log2(`Repaired project Codex config ${configCleanup.configPath} (backup: ${configCleanup.backupPath})`);
10133
+ log(`Repaired project Codex config ${configCleanup.configPath} (backup: ${configCleanup.backupPath})`);
13829
10134
  }
13830
10135
  for (const artifact of projectCleanup.artifacts) {
13831
- log2(`Found project-local legacy artifact ${artifact.path}; left in place`);
10136
+ log(`Found project-local legacy artifact ${artifact.path}; left in place`);
13832
10137
  }
13833
10138
  await trackCodexInstallTelemetry();
13834
10139
  return {
@@ -13866,14 +10171,14 @@ function findRepoRootFromImporter(importerDir) {
13866
10171
  if (isRepoRootWithCodexPlugin(wrapperPackageRoot))
13867
10172
  return wrapperPackageRoot;
13868
10173
  }
13869
- current = resolve11(current, "..");
10174
+ current = resolve9(current, "..");
13870
10175
  }
13871
10176
  throw new Error("Unable to locate vendored Codex plugin: expected packages/omo-codex/plugin/.codex-plugin/plugin.json in this package or sibling oh-my-openagent package within 7 parent levels");
13872
10177
  }
13873
10178
  function findRepoRoot(input) {
13874
10179
  const wrapperPackageRoot = input.env?.OMO_WRAPPER_PACKAGE_ROOT;
13875
10180
  if (wrapperPackageRoot !== undefined && wrapperPackageRoot.trim().length > 0) {
13876
- const resolvedWrapperPackageRoot = resolve11(wrapperPackageRoot);
10181
+ const resolvedWrapperPackageRoot = resolve9(wrapperPackageRoot);
13877
10182
  if (isRepoRootWithCodexPlugin(resolvedWrapperPackageRoot))
13878
10183
  return resolvedWrapperPackageRoot;
13879
10184
  }
@@ -14067,8 +10372,8 @@ async function runDelegatedOmoCommand(parsed, options) {
14067
10372
  options.log(formatShellCommand(invocation.command, invocation.args));
14068
10373
  return;
14069
10374
  }
14070
- const env3 = invocation.delegatesToOmo ? { ...process.env, OMO_INVOCATION_NAME: "omo", ...invocation.env } : { ...process.env, ...invocation.env };
14071
- await options.runCommand(invocation.command, invocation.args, { cwd: options.cwd, env: env3 });
10375
+ const env2 = invocation.delegatesToOmo ? { ...process.env, OMO_INVOCATION_NAME: "omo", ...invocation.env } : { ...process.env, ...invocation.env };
10376
+ await options.runCommand(invocation.command, invocation.args, { cwd: options.cwd, env: env2 });
14072
10377
  }
14073
10378
  function buildDelegatedOmoInvocation(parsed) {
14074
10379
  if (parsed.command === "doctor")
@@ -14191,7 +10496,7 @@ function shellQuote(value) {
14191
10496
  }
14192
10497
 
14193
10498
  // packages/omo-codex/src/install/lazycodex-manual-update.ts
14194
- import { spawn as spawn4, spawnSync as spawnSync3 } from "node:child_process";
10499
+ import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
14195
10500
  import { readFileSync as readFileSync3 } from "node:fs";
14196
10501
  import { dirname as dirname10, join as join34 } from "node:path";
14197
10502
  import { createInterface as createInterface2 } from "node:readline/promises";
@@ -14199,15 +10504,15 @@ import { fileURLToPath } from "node:url";
14199
10504
 
14200
10505
  // packages/omo-codex/src/install/lazycodex-bun-global-paths.ts
14201
10506
  import { join as join33 } from "node:path";
14202
- function isBunGlobalEntrypointPath(invokedPath, env3) {
10507
+ function isBunGlobalEntrypointPath(invokedPath, env2) {
14203
10508
  if (typeof invokedPath !== "string" || invokedPath.trim().length === 0)
14204
10509
  return false;
14205
10510
  const normalizedPath = normalizePathForPrefix(invokedPath);
14206
- return resolveBunGlobalRoots(env3).some((root) => normalizedPath.startsWith(root));
10511
+ return resolveBunGlobalRoots(env2).some((root) => normalizedPath.startsWith(root));
14207
10512
  }
14208
- function resolveBunGlobalRoots(env3) {
14209
- const bunInstallRoot = env3.BUN_INSTALL?.trim();
14210
- const homeRoot = env3.HOME?.trim();
10513
+ function resolveBunGlobalRoots(env2) {
10514
+ const bunInstallRoot = env2.BUN_INSTALL?.trim();
10515
+ const homeRoot = env2.HOME?.trim();
14211
10516
  return [
14212
10517
  ...bunInstallRoot ? [join33(bunInstallRoot, "bin"), join33(bunInstallRoot, "install", "global", "node_modules")] : [],
14213
10518
  ...homeRoot ? [join33(homeRoot, ".bun", "bin"), join33(homeRoot, ".bun", "install", "global", "node_modules")] : []
@@ -14236,39 +10541,39 @@ var KNOWN_LAZYCODEX_BUN_TRUST_PACKAGES = new Set([
14236
10541
  ]);
14237
10542
  var KNOWN_LAZYCODEX_BUN_TRUST_PREFIXES = ["@oh-my-opencode/", "oh-my-openagent-", "oh-my-opencode-"];
14238
10543
  async function runLazyCodexManualUpdate(input = {}) {
14239
- const env3 = input.env ?? process.env;
14240
- const log2 = input.log ?? console.log;
10544
+ const env2 = input.env ?? process.env;
10545
+ const log = input.log ?? console.log;
14241
10546
  const commandRunner = input.runCommand ?? defaultRunCommandForManualUpdate;
14242
- const currentVersion = resolveCurrentVersion(env3);
14243
- const latestVersion = resolveLatestVersion(env3);
10547
+ const currentVersion = resolveCurrentVersion(env2);
10548
+ const latestVersion = resolveLatestVersion(env2);
14244
10549
  const plan = resolveLazyCodexUpdatePlan({
14245
10550
  currentVersion,
14246
10551
  latestVersion,
14247
- command: resolveCommand2(env3),
14248
- args: resolveArgs(env3),
14249
- env: env3,
10552
+ command: resolveCommand2(env2),
10553
+ args: resolveArgs(env2),
10554
+ env: env2,
14250
10555
  invokedPath: input.invokedPath ?? process.argv[1]
14251
10556
  });
14252
10557
  if (!plan.shouldUpdate) {
14253
10558
  const printableVersion = currentVersion ?? "unknown";
14254
- log2(plan.reason === "up-to-date" ? `lazycodex-ai ${printableVersion} is already up to date.` : `Unable to check lazycodex-ai updates (${plan.reason}).`);
10559
+ log(plan.reason === "up-to-date" ? `lazycodex-ai ${printableVersion} is already up to date.` : `Unable to check lazycodex-ai updates (${plan.reason}).`);
14255
10560
  return plan.reason === "up-to-date" ? 0 : 1;
14256
10561
  }
14257
10562
  if (input.dryRun) {
14258
- log2(`${plan.command} ${plan.args.join(" ")}`);
10563
+ log(`${plan.command} ${plan.args.join(" ")}`);
14259
10564
  if (plan.postUpdate === "bun-global-trust")
14260
- log2(`${DEFAULT_UPDATE_COMMAND} ${DEFAULT_UPDATE_ARGS.join(" ")}`);
10565
+ log(`${DEFAULT_UPDATE_COMMAND} ${DEFAULT_UPDATE_ARGS.join(" ")}`);
14261
10566
  return 0;
14262
10567
  }
14263
- await commandRunner(plan.command, plan.args, { cwd: process.cwd(), env: env3 });
10568
+ await commandRunner(plan.command, plan.args, { cwd: process.cwd(), env: env2 });
14264
10569
  if (plan.postUpdate === "bun-global-trust") {
14265
10570
  await handleBunGlobalTrust({
14266
- env: env3,
14267
- log: log2,
10571
+ env: env2,
10572
+ log,
14268
10573
  commandRunner,
14269
10574
  isInteractive: input.isInteractive ?? (process.stdin.isTTY === true && process.stdout.isTTY === true)
14270
10575
  });
14271
- await commandRunner(DEFAULT_UPDATE_COMMAND, DEFAULT_UPDATE_ARGS, { cwd: process.cwd(), env: env3 });
10576
+ await commandRunner(DEFAULT_UPDATE_COMMAND, DEFAULT_UPDATE_ARGS, { cwd: process.cwd(), env: env2 });
14272
10577
  }
14273
10578
  return 0;
14274
10579
  }
@@ -14286,12 +10591,12 @@ function resolveLazyCodexUpdatePlan(input = {}) {
14286
10591
  }
14287
10592
  return { shouldUpdate: true, command: input.command ?? DEFAULT_UPDATE_COMMAND, args: input.args ?? DEFAULT_UPDATE_ARGS, postUpdate: "none" };
14288
10593
  }
14289
- function resolveCommand2(env3) {
14290
- return env3.LAZYCODEX_AUTO_UPDATE_COMMAND?.trim() || DEFAULT_UPDATE_COMMAND;
10594
+ function resolveCommand2(env2) {
10595
+ return env2.LAZYCODEX_AUTO_UPDATE_COMMAND?.trim() || DEFAULT_UPDATE_COMMAND;
14291
10596
  }
14292
- function resolveArgs(env3) {
14293
- if (env3.LAZYCODEX_AUTO_UPDATE_ARGS_JSON) {
14294
- const parsed = JSON.parse(env3.LAZYCODEX_AUTO_UPDATE_ARGS_JSON);
10597
+ function resolveArgs(env2) {
10598
+ if (env2.LAZYCODEX_AUTO_UPDATE_ARGS_JSON) {
10599
+ const parsed = JSON.parse(env2.LAZYCODEX_AUTO_UPDATE_ARGS_JSON);
14295
10600
  if (!Array.isArray(parsed) || parsed.some((value) => typeof value !== "string")) {
14296
10601
  throw new TypeError("LAZYCODEX_AUTO_UPDATE_ARGS_JSON must be a JSON string array");
14297
10602
  }
@@ -14299,15 +10604,15 @@ function resolveArgs(env3) {
14299
10604
  }
14300
10605
  return DEFAULT_UPDATE_ARGS;
14301
10606
  }
14302
- function resolveCurrentVersion(env3) {
14303
- if (env3.LAZYCODEX_CURRENT_VERSION?.trim())
14304
- return env3.LAZYCODEX_CURRENT_VERSION.trim();
10607
+ function resolveCurrentVersion(env2) {
10608
+ if (env2.LAZYCODEX_CURRENT_VERSION?.trim())
10609
+ return env2.LAZYCODEX_CURRENT_VERSION.trim();
14305
10610
  const pluginRoot = dirname10(dirname10(fileURLToPath(import.meta.url)));
14306
- return readVersionManifest(resolveInstalledVersionPath(env3, pluginRoot)) ?? readVersionManifest(join34(pluginRoot, "..", "..", "..", "package.json")) ?? readVersionManifest(join34(pluginRoot, ".codex-plugin", "plugin.json"));
10611
+ return readVersionManifest(resolveInstalledVersionPath(env2, pluginRoot)) ?? readVersionManifest(join34(pluginRoot, "..", "..", "..", "package.json")) ?? readVersionManifest(join34(pluginRoot, ".codex-plugin", "plugin.json"));
14307
10612
  }
14308
- function resolveLatestVersion(env3) {
14309
- if (env3.LAZYCODEX_LATEST_VERSION?.trim())
14310
- return env3.LAZYCODEX_LATEST_VERSION.trim();
10613
+ function resolveLatestVersion(env2) {
10614
+ if (env2.LAZYCODEX_LATEST_VERSION?.trim())
10615
+ return env2.LAZYCODEX_LATEST_VERSION.trim();
14311
10616
  const result = spawnSync3("npm", ["view", "lazycodex-ai", "version", "--silent"], {
14312
10617
  encoding: "utf8",
14313
10618
  stdio: ["ignore", "pipe", "ignore"]
@@ -14335,10 +10640,10 @@ ${trustCommand}`);
14335
10640
  input.log(`Skipped Bun postinstall trust. To run it later:
14336
10641
  ${trustCommand}`);
14337
10642
  }
14338
- function resolveKnownBunGlobalUntrustedPackages(env3) {
10643
+ function resolveKnownBunGlobalUntrustedPackages(env2) {
14339
10644
  const result = spawnSync3(BUN_UPDATE_COMMAND, BUN_GLOBAL_UNTRUSTED_ARGS, {
14340
10645
  encoding: "utf8",
14341
- env: env3,
10646
+ env: env2,
14342
10647
  stdio: ["ignore", "pipe", "ignore"]
14343
10648
  });
14344
10649
  if (result.status !== 0)
@@ -14365,12 +10670,12 @@ async function confirmBunGlobalTrust(packageNames) {
14365
10670
  function isKnownLazyCodexBunTrustPackage(packageName) {
14366
10671
  return KNOWN_LAZYCODEX_BUN_TRUST_PACKAGES.has(packageName) || KNOWN_LAZYCODEX_BUN_TRUST_PREFIXES.some((prefix) => packageName.startsWith(prefix));
14367
10672
  }
14368
- function isBunGlobalEntrypoint(invokedPath, env3) {
14369
- return isBunGlobalEntrypointPath(invokedPath, env3);
10673
+ function isBunGlobalEntrypoint(invokedPath, env2) {
10674
+ return isBunGlobalEntrypointPath(invokedPath, env2);
14370
10675
  }
14371
10676
  function defaultRunCommandForManualUpdate(command, args, options) {
14372
- return new Promise((resolve12, reject) => {
14373
- const child = spawn4(command, args, {
10677
+ return new Promise((resolve10, reject) => {
10678
+ const child = spawn3(command, args, {
14374
10679
  cwd: options.cwd,
14375
10680
  env: options.env,
14376
10681
  stdio: "inherit",
@@ -14379,7 +10684,7 @@ function defaultRunCommandForManualUpdate(command, args, options) {
14379
10684
  child.once("error", reject);
14380
10685
  child.once("close", (code) => {
14381
10686
  if (code === 0) {
14382
- resolve12();
10687
+ resolve10();
14383
10688
  return;
14384
10689
  }
14385
10690
  reject(new Error(`${command} ${args.join(" ")} exited with ${code ?? "unknown status"}`));
@@ -14416,9 +10721,9 @@ function compareVersions(left, right) {
14416
10721
  }
14417
10722
  return 0;
14418
10723
  }
14419
- function resolveInstalledVersionPath(env3, pluginRoot) {
14420
- if (env3.LAZYCODEX_INSTALLED_VERSION_FILE?.trim())
14421
- return env3.LAZYCODEX_INSTALLED_VERSION_FILE.trim();
10724
+ function resolveInstalledVersionPath(env2, pluginRoot) {
10725
+ if (env2.LAZYCODEX_INSTALLED_VERSION_FILE?.trim())
10726
+ return env2.LAZYCODEX_INSTALLED_VERSION_FILE.trim();
14422
10727
  return join34(pluginRoot, INSTALLED_VERSION_FILE);
14423
10728
  }
14424
10729
  function readVersionManifest(path2) {
@@ -14482,7 +10787,7 @@ async function installMarketplaceLocally(options = {}) {
14482
10787
  return runCodexInstaller(options);
14483
10788
  }
14484
10789
  function resolveDefaultRepoRootForEntrypoint(entrypointPath) {
14485
- return resolve12(dirname11(entrypointPath), "..", "..", "..");
10790
+ return resolve10(dirname11(entrypointPath), "..", "..", "..");
14486
10791
  }
14487
10792
  function resolveDefaultRepoRoot() {
14488
10793
  return resolveDefaultRepoRootForEntrypoint(fileURLToPath2(import.meta.url));
@@ -14510,7 +10815,7 @@ async function runLazyCodexInstallLocalCli(input) {
14510
10815
  return 0;
14511
10816
  }
14512
10817
  const result2 = await installMarketplaceLocally({
14513
- repoRoot: resolve12(parsed.repoRoot),
10818
+ repoRoot: resolve10(parsed.repoRoot),
14514
10819
  autonomousPermissions: true,
14515
10820
  env: input.env
14516
10821
  });
@@ -14519,7 +10824,7 @@ async function runLazyCodexInstallLocalCli(input) {
14519
10824
  }
14520
10825
  return runLazyCodexManualUpdate({ env: input.env, dryRun: parsed.dryRun, log: input.log, invokedPath: input.invokedPath });
14521
10826
  }
14522
- const repoRoot = parsed.repoRoot ? resolve12(parsed.repoRoot) : input.defaultRepoRoot;
10827
+ const repoRoot = parsed.repoRoot ? resolve10(parsed.repoRoot) : input.defaultRepoRoot;
14523
10828
  const result = await installMarketplaceLocally({
14524
10829
  repoRoot,
14525
10830
  autonomousPermissions: parsed.autonomousPermissions,