'use strict';

var util = require('util');

// src/platform/core/string-helpers.ts
function shellQuote(value) {
  return `'${value.replace(/'/g, `'\\''`)}'`;
}
function safeExcerpt(content, limit = 3e3) {
  if (!content) {
    return "";
  }
  if (content.length <= limit) {
    return content;
  }
  return `${content.slice(0, limit)}
... (truncated ${content.length - limit} chars)`;
}
function normalizePromptPathInput(value) {
  let normalized = value.trim();
  while (normalized.length >= 2 && (normalized.startsWith("`") && normalized.endsWith("`") || normalized.startsWith('"') && normalized.endsWith('"') || normalized.startsWith("'") && normalized.endsWith("'"))) {
    normalized = normalized.slice(1, -1).trim();
  }
  return normalized;
}
function stringifyUnknown(value) {
  if (value === void 0 || value === null) {
    return "";
  }
  if (typeof value === "string") {
    return value;
  }
  if (Buffer.isBuffer(value)) {
    return value.toString("utf8");
  }
  if (value instanceof Error) {
    return value.stack || value.message;
  }
  return util.inspect(value, { depth: 6, breakLength: 120 });
}
function isNodeError(error) {
  return error instanceof Error && typeof error.code === "string";
}
function getErrorSummary(error) {
  if (error instanceof Error) {
    return `${error.name}: ${error.message}`;
  }
  return stringifyUnknown(error) || "Unknown error";
}

exports.getErrorSummary = getErrorSummary;
exports.isNodeError = isNodeError;
exports.normalizePromptPathInput = normalizePromptPathInput;
exports.safeExcerpt = safeExcerpt;
exports.shellQuote = shellQuote;
exports.stringifyUnknown = stringifyUnknown;
