@corbat-tech/coco 2.25.8 → 2.25.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1448,7 +1448,7 @@ function getDefaultModel(provider) {
1448
1448
  case "codex":
1449
1449
  return process.env["CODEX_MODEL"] ?? "codex-mini-latest";
1450
1450
  case "copilot":
1451
- return process.env["COPILOT_MODEL"] ?? "gpt-4o-copilot";
1451
+ return process.env["COPILOT_MODEL"] ?? "claude-sonnet-4.6";
1452
1452
  case "groq":
1453
1453
  return process.env["GROQ_MODEL"] ?? "llama-3.3-70b-versatile";
1454
1454
  case "openrouter":
@@ -15894,6 +15894,11 @@ var CONTEXT_WINDOWS4 = {
15894
15894
  "gemini-2.5-pro": 1048576
15895
15895
  };
15896
15896
  var DEFAULT_MODEL4 = "claude-sonnet-4.6";
15897
+ function normalizeModel(model) {
15898
+ if (typeof model !== "string") return void 0;
15899
+ const trimmed = model.trim();
15900
+ return trimmed.length > 0 ? trimmed : void 0;
15901
+ }
15897
15902
  var COPILOT_HEADERS = {
15898
15903
  "Copilot-Integration-Id": "vscode-chat",
15899
15904
  "Editor-Version": "vscode/1.99.0",
@@ -15917,7 +15922,7 @@ var CopilotProvider = class extends OpenAIProvider {
15917
15922
  async initialize(config) {
15918
15923
  this.config = {
15919
15924
  ...config,
15920
- model: config.model ?? DEFAULT_MODEL4
15925
+ model: normalizeModel(config.model) ?? DEFAULT_MODEL4
15921
15926
  };
15922
15927
  const tokenResult = await getValidCopilotToken();
15923
15928
  if (tokenResult) {
@@ -16803,12 +16808,17 @@ function createResilientProvider(provider, config) {
16803
16808
  init_copilot();
16804
16809
  init_errors();
16805
16810
  init_env();
16811
+ function normalizeProviderModel(model) {
16812
+ if (typeof model !== "string") return void 0;
16813
+ const trimmed = model.trim();
16814
+ return trimmed.length > 0 ? trimmed : void 0;
16815
+ }
16806
16816
  async function createProvider(type, config = {}) {
16807
16817
  let provider;
16808
16818
  const mergedConfig = {
16809
16819
  apiKey: config.apiKey ?? getApiKey(type),
16810
16820
  baseUrl: config.baseUrl ?? getBaseUrl(type),
16811
- model: config.model ?? getDefaultModel(type),
16821
+ model: normalizeProviderModel(config.model) ?? getDefaultModel(type),
16812
16822
  maxTokens: config.maxTokens,
16813
16823
  temperature: config.temperature,
16814
16824
  timeout: config.timeout
@@ -17577,9 +17587,20 @@ function hasNullByte(str) {
17577
17587
  }
17578
17588
  function normalizePath(filePath) {
17579
17589
  let normalized = filePath.replace(/\0/g, "");
17590
+ const home = process.env.HOME || process.env.USERPROFILE;
17591
+ if (home && normalized.startsWith("~")) {
17592
+ if (normalized === "~") {
17593
+ normalized = home;
17594
+ } else if (normalized.startsWith("~/") || normalized.startsWith(`~${path17__default.sep}`)) {
17595
+ normalized = path17__default.join(home, normalized.slice(2));
17596
+ }
17597
+ }
17580
17598
  normalized = path17__default.normalize(normalized);
17581
17599
  return normalized;
17582
17600
  }
17601
+ function resolveUserPath(filePath) {
17602
+ return path17__default.resolve(normalizePath(filePath));
17603
+ }
17583
17604
  function isWithinDirectory(targetPath, baseDir) {
17584
17605
  const normalizedTarget = path17__default.normalize(targetPath);
17585
17606
  const normalizedBase = path17__default.normalize(baseDir);
@@ -17612,7 +17633,7 @@ function isPathAllowed(filePath, operation) {
17612
17633
  return { allowed: false, reason: "Path contains invalid characters" };
17613
17634
  }
17614
17635
  const normalized = normalizePath(filePath);
17615
- const absolute = path17__default.resolve(normalized);
17636
+ const absolute = resolveUserPath(normalized);
17616
17637
  const cwd = process.cwd();
17617
17638
  for (const blocked of BLOCKED_PATHS) {
17618
17639
  const normalizedBlocked = path17__default.normalize(blocked);
@@ -17671,7 +17692,7 @@ function isENOENT(error) {
17671
17692
  return error.code === "ENOENT";
17672
17693
  }
17673
17694
  async function enrichENOENT(filePath, operation) {
17674
- const absPath = path17__default.resolve(filePath);
17695
+ const absPath = resolveUserPath(filePath);
17675
17696
  const suggestions = await suggestSimilarFilesDeep(absPath, process.cwd());
17676
17697
  const hint = formatSuggestions(suggestions, path17__default.dirname(absPath));
17677
17698
  const action = operation === "read" ? "Use glob or list_dir to find the correct path." : "Check that the parent directory exists.";
@@ -17679,7 +17700,7 @@ async function enrichENOENT(filePath, operation) {
17679
17700
  ${action}`;
17680
17701
  }
17681
17702
  async function enrichDirENOENT(dirPath) {
17682
- const absPath = path17__default.resolve(dirPath);
17703
+ const absPath = resolveUserPath(dirPath);
17683
17704
  const suggestions = await suggestSimilarDirsDeep(absPath, process.cwd());
17684
17705
  const hint = formatSuggestions(suggestions, path17__default.dirname(absPath));
17685
17706
  return `Directory not found: ${dirPath}${hint}
@@ -17702,7 +17723,7 @@ Examples:
17702
17723
  async execute({ path: filePath, encoding, maxSize }) {
17703
17724
  validatePath(filePath, "read");
17704
17725
  try {
17705
- const absolutePath = path17__default.resolve(filePath);
17726
+ const absolutePath = resolveUserPath(filePath);
17706
17727
  const stats = await fs16__default.stat(absolutePath);
17707
17728
  const maxBytes = maxSize ?? DEFAULT_MAX_FILE_SIZE;
17708
17729
  let truncated = false;
@@ -17761,7 +17782,7 @@ Examples:
17761
17782
  async execute({ path: filePath, content, createDirs, dryRun }) {
17762
17783
  validatePath(filePath, "write");
17763
17784
  try {
17764
- const absolutePath = path17__default.resolve(filePath);
17785
+ const absolutePath = resolveUserPath(filePath);
17765
17786
  let wouldCreate = false;
17766
17787
  try {
17767
17788
  await fs16__default.access(absolutePath);
@@ -17823,7 +17844,7 @@ Examples:
17823
17844
  async execute({ path: filePath, oldText, newText, all, dryRun }) {
17824
17845
  validatePath(filePath, "write");
17825
17846
  try {
17826
- const absolutePath = path17__default.resolve(filePath);
17847
+ const absolutePath = resolveUserPath(filePath);
17827
17848
  let content = await fs16__default.readFile(absolutePath, "utf-8");
17828
17849
  let replacements = 0;
17829
17850
  if (all) {
@@ -17944,7 +17965,7 @@ Examples:
17944
17965
  }),
17945
17966
  async execute({ path: filePath }) {
17946
17967
  try {
17947
- const absolutePath = path17__default.resolve(filePath);
17968
+ const absolutePath = resolveUserPath(filePath);
17948
17969
  const stats = await fs16__default.stat(absolutePath);
17949
17970
  return {
17950
17971
  exists: true,
@@ -17975,7 +17996,7 @@ Examples:
17975
17996
  }),
17976
17997
  async execute({ path: dirPath, recursive }) {
17977
17998
  try {
17978
- const absolutePath = path17__default.resolve(dirPath);
17999
+ const absolutePath = resolveUserPath(dirPath);
17979
18000
  const entries = [];
17980
18001
  async function listDir(dir, prefix = "") {
17981
18002
  const items = await fs16__default.readdir(dir, { withFileTypes: true });
@@ -18035,7 +18056,7 @@ Examples:
18035
18056
  }
18036
18057
  validatePath(filePath, "delete");
18037
18058
  try {
18038
- const absolutePath = path17__default.resolve(filePath);
18059
+ const absolutePath = resolveUserPath(filePath);
18039
18060
  const stats = await fs16__default.stat(absolutePath);
18040
18061
  if (stats.isDirectory()) {
18041
18062
  if (!recursive) {
@@ -18051,7 +18072,7 @@ Examples:
18051
18072
  } catch (error) {
18052
18073
  if (error instanceof ToolError) throw error;
18053
18074
  if (error.code === "ENOENT") {
18054
- return { deleted: false, path: path17__default.resolve(filePath) };
18075
+ return { deleted: false, path: resolveUserPath(filePath) };
18055
18076
  }
18056
18077
  throw new FileSystemError(`Failed to delete: ${filePath}`, {
18057
18078
  path: filePath,
@@ -18079,8 +18100,8 @@ Examples:
18079
18100
  validatePath(source, "read");
18080
18101
  validatePath(destination, "write");
18081
18102
  try {
18082
- const srcPath = path17__default.resolve(source);
18083
- const destPath = path17__default.resolve(destination);
18103
+ const srcPath = resolveUserPath(source);
18104
+ const destPath = resolveUserPath(destination);
18084
18105
  if (!overwrite) {
18085
18106
  try {
18086
18107
  await fs16__default.access(destPath);
@@ -18140,8 +18161,8 @@ Examples:
18140
18161
  validatePath(source, "delete");
18141
18162
  validatePath(destination, "write");
18142
18163
  try {
18143
- const srcPath = path17__default.resolve(source);
18144
- const destPath = path17__default.resolve(destination);
18164
+ const srcPath = resolveUserPath(source);
18165
+ const destPath = resolveUserPath(destination);
18145
18166
  if (!overwrite) {
18146
18167
  try {
18147
18168
  await fs16__default.access(destPath);
@@ -18227,7 +18248,7 @@ Examples:
18227
18248
  }),
18228
18249
  async execute({ path: dirPath, depth, showHidden, dirsOnly }) {
18229
18250
  try {
18230
- const absolutePath = path17__default.resolve(dirPath ?? ".");
18251
+ const absolutePath = resolveUserPath(dirPath ?? ".");
18231
18252
  let totalFiles = 0;
18232
18253
  let totalDirs = 0;
18233
18254
  const lines = [path17__default.basename(absolutePath) + "/"];