@corbat-tech/coco 2.25.8 → 2.25.10
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/cli/index.js +179 -39
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +42 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -519,6 +519,7 @@ declare const CocoConfigSchema: z.ZodObject<{
|
|
|
519
519
|
temperature: z.ZodDefault<z.ZodNumber>;
|
|
520
520
|
timeout: z.ZodDefault<z.ZodNumber>;
|
|
521
521
|
}, z.core.$strip>>;
|
|
522
|
+
providerModels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
522
523
|
quality: z.ZodDefault<z.ZodObject<{
|
|
523
524
|
minScore: z.ZodDefault<z.ZodNumber>;
|
|
524
525
|
minCoverage: z.ZodDefault<z.ZodNumber>;
|
package/dist/index.js
CHANGED
|
@@ -868,6 +868,7 @@ function createDefaultConfigObject(projectName, language = "typescript") {
|
|
|
868
868
|
temperature: 0,
|
|
869
869
|
timeout: 12e4
|
|
870
870
|
},
|
|
871
|
+
providerModels: {},
|
|
871
872
|
quality: {
|
|
872
873
|
minScore: 85,
|
|
873
874
|
minCoverage: 80,
|
|
@@ -1047,6 +1048,7 @@ var init_schema = __esm({
|
|
|
1047
1048
|
temperature: 0,
|
|
1048
1049
|
timeout: 12e4
|
|
1049
1050
|
}),
|
|
1051
|
+
providerModels: z.record(z.string(), z.string()).optional(),
|
|
1050
1052
|
quality: QualityConfigSchema.default({
|
|
1051
1053
|
minScore: 85,
|
|
1052
1054
|
minCoverage: 80,
|
|
@@ -1183,6 +1185,7 @@ function deepMergeConfig(base, override) {
|
|
|
1183
1185
|
...override,
|
|
1184
1186
|
project: { ...base.project, ...override.project },
|
|
1185
1187
|
provider: { ...base.provider, ...override.provider },
|
|
1188
|
+
providerModels: { ...base.providerModels, ...override.providerModels },
|
|
1186
1189
|
quality: { ...base.quality, ...override.quality },
|
|
1187
1190
|
persistence: { ...base.persistence, ...override.persistence },
|
|
1188
1191
|
// Merge optional sections only if present in either base or override
|
|
@@ -1448,7 +1451,7 @@ function getDefaultModel(provider) {
|
|
|
1448
1451
|
case "codex":
|
|
1449
1452
|
return process.env["CODEX_MODEL"] ?? "codex-mini-latest";
|
|
1450
1453
|
case "copilot":
|
|
1451
|
-
return process.env["COPILOT_MODEL"] ?? "
|
|
1454
|
+
return process.env["COPILOT_MODEL"] ?? "claude-sonnet-4.6";
|
|
1452
1455
|
case "groq":
|
|
1453
1456
|
return process.env["GROQ_MODEL"] ?? "llama-3.3-70b-versatile";
|
|
1454
1457
|
case "openrouter":
|
|
@@ -15894,6 +15897,11 @@ var CONTEXT_WINDOWS4 = {
|
|
|
15894
15897
|
"gemini-2.5-pro": 1048576
|
|
15895
15898
|
};
|
|
15896
15899
|
var DEFAULT_MODEL4 = "claude-sonnet-4.6";
|
|
15900
|
+
function normalizeModel(model) {
|
|
15901
|
+
if (typeof model !== "string") return void 0;
|
|
15902
|
+
const trimmed = model.trim();
|
|
15903
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
15904
|
+
}
|
|
15897
15905
|
var COPILOT_HEADERS = {
|
|
15898
15906
|
"Copilot-Integration-Id": "vscode-chat",
|
|
15899
15907
|
"Editor-Version": "vscode/1.99.0",
|
|
@@ -15917,7 +15925,7 @@ var CopilotProvider = class extends OpenAIProvider {
|
|
|
15917
15925
|
async initialize(config) {
|
|
15918
15926
|
this.config = {
|
|
15919
15927
|
...config,
|
|
15920
|
-
model: config.model ?? DEFAULT_MODEL4
|
|
15928
|
+
model: normalizeModel(config.model) ?? DEFAULT_MODEL4
|
|
15921
15929
|
};
|
|
15922
15930
|
const tokenResult = await getValidCopilotToken();
|
|
15923
15931
|
if (tokenResult) {
|
|
@@ -16803,12 +16811,17 @@ function createResilientProvider(provider, config) {
|
|
|
16803
16811
|
init_copilot();
|
|
16804
16812
|
init_errors();
|
|
16805
16813
|
init_env();
|
|
16814
|
+
function normalizeProviderModel(model) {
|
|
16815
|
+
if (typeof model !== "string") return void 0;
|
|
16816
|
+
const trimmed = model.trim();
|
|
16817
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
16818
|
+
}
|
|
16806
16819
|
async function createProvider(type, config = {}) {
|
|
16807
16820
|
let provider;
|
|
16808
16821
|
const mergedConfig = {
|
|
16809
16822
|
apiKey: config.apiKey ?? getApiKey(type),
|
|
16810
16823
|
baseUrl: config.baseUrl ?? getBaseUrl(type),
|
|
16811
|
-
model: config.model ?? getDefaultModel(type),
|
|
16824
|
+
model: normalizeProviderModel(config.model) ?? getDefaultModel(type),
|
|
16812
16825
|
maxTokens: config.maxTokens,
|
|
16813
16826
|
temperature: config.temperature,
|
|
16814
16827
|
timeout: config.timeout
|
|
@@ -17577,9 +17590,20 @@ function hasNullByte(str) {
|
|
|
17577
17590
|
}
|
|
17578
17591
|
function normalizePath(filePath) {
|
|
17579
17592
|
let normalized = filePath.replace(/\0/g, "");
|
|
17593
|
+
const home = process.env.HOME || process.env.USERPROFILE;
|
|
17594
|
+
if (home && normalized.startsWith("~")) {
|
|
17595
|
+
if (normalized === "~") {
|
|
17596
|
+
normalized = home;
|
|
17597
|
+
} else if (normalized.startsWith("~/") || normalized.startsWith(`~${path17__default.sep}`)) {
|
|
17598
|
+
normalized = path17__default.join(home, normalized.slice(2));
|
|
17599
|
+
}
|
|
17600
|
+
}
|
|
17580
17601
|
normalized = path17__default.normalize(normalized);
|
|
17581
17602
|
return normalized;
|
|
17582
17603
|
}
|
|
17604
|
+
function resolveUserPath(filePath) {
|
|
17605
|
+
return path17__default.resolve(normalizePath(filePath));
|
|
17606
|
+
}
|
|
17583
17607
|
function isWithinDirectory(targetPath, baseDir) {
|
|
17584
17608
|
const normalizedTarget = path17__default.normalize(targetPath);
|
|
17585
17609
|
const normalizedBase = path17__default.normalize(baseDir);
|
|
@@ -17612,7 +17636,7 @@ function isPathAllowed(filePath, operation) {
|
|
|
17612
17636
|
return { allowed: false, reason: "Path contains invalid characters" };
|
|
17613
17637
|
}
|
|
17614
17638
|
const normalized = normalizePath(filePath);
|
|
17615
|
-
const absolute =
|
|
17639
|
+
const absolute = resolveUserPath(normalized);
|
|
17616
17640
|
const cwd = process.cwd();
|
|
17617
17641
|
for (const blocked of BLOCKED_PATHS) {
|
|
17618
17642
|
const normalizedBlocked = path17__default.normalize(blocked);
|
|
@@ -17671,7 +17695,7 @@ function isENOENT(error) {
|
|
|
17671
17695
|
return error.code === "ENOENT";
|
|
17672
17696
|
}
|
|
17673
17697
|
async function enrichENOENT(filePath, operation) {
|
|
17674
|
-
const absPath =
|
|
17698
|
+
const absPath = resolveUserPath(filePath);
|
|
17675
17699
|
const suggestions = await suggestSimilarFilesDeep(absPath, process.cwd());
|
|
17676
17700
|
const hint = formatSuggestions(suggestions, path17__default.dirname(absPath));
|
|
17677
17701
|
const action = operation === "read" ? "Use glob or list_dir to find the correct path." : "Check that the parent directory exists.";
|
|
@@ -17679,7 +17703,7 @@ async function enrichENOENT(filePath, operation) {
|
|
|
17679
17703
|
${action}`;
|
|
17680
17704
|
}
|
|
17681
17705
|
async function enrichDirENOENT(dirPath) {
|
|
17682
|
-
const absPath =
|
|
17706
|
+
const absPath = resolveUserPath(dirPath);
|
|
17683
17707
|
const suggestions = await suggestSimilarDirsDeep(absPath, process.cwd());
|
|
17684
17708
|
const hint = formatSuggestions(suggestions, path17__default.dirname(absPath));
|
|
17685
17709
|
return `Directory not found: ${dirPath}${hint}
|
|
@@ -17702,7 +17726,7 @@ Examples:
|
|
|
17702
17726
|
async execute({ path: filePath, encoding, maxSize }) {
|
|
17703
17727
|
validatePath(filePath, "read");
|
|
17704
17728
|
try {
|
|
17705
|
-
const absolutePath =
|
|
17729
|
+
const absolutePath = resolveUserPath(filePath);
|
|
17706
17730
|
const stats = await fs16__default.stat(absolutePath);
|
|
17707
17731
|
const maxBytes = maxSize ?? DEFAULT_MAX_FILE_SIZE;
|
|
17708
17732
|
let truncated = false;
|
|
@@ -17761,7 +17785,7 @@ Examples:
|
|
|
17761
17785
|
async execute({ path: filePath, content, createDirs, dryRun }) {
|
|
17762
17786
|
validatePath(filePath, "write");
|
|
17763
17787
|
try {
|
|
17764
|
-
const absolutePath =
|
|
17788
|
+
const absolutePath = resolveUserPath(filePath);
|
|
17765
17789
|
let wouldCreate = false;
|
|
17766
17790
|
try {
|
|
17767
17791
|
await fs16__default.access(absolutePath);
|
|
@@ -17823,7 +17847,7 @@ Examples:
|
|
|
17823
17847
|
async execute({ path: filePath, oldText, newText, all, dryRun }) {
|
|
17824
17848
|
validatePath(filePath, "write");
|
|
17825
17849
|
try {
|
|
17826
|
-
const absolutePath =
|
|
17850
|
+
const absolutePath = resolveUserPath(filePath);
|
|
17827
17851
|
let content = await fs16__default.readFile(absolutePath, "utf-8");
|
|
17828
17852
|
let replacements = 0;
|
|
17829
17853
|
if (all) {
|
|
@@ -17944,7 +17968,7 @@ Examples:
|
|
|
17944
17968
|
}),
|
|
17945
17969
|
async execute({ path: filePath }) {
|
|
17946
17970
|
try {
|
|
17947
|
-
const absolutePath =
|
|
17971
|
+
const absolutePath = resolveUserPath(filePath);
|
|
17948
17972
|
const stats = await fs16__default.stat(absolutePath);
|
|
17949
17973
|
return {
|
|
17950
17974
|
exists: true,
|
|
@@ -17975,7 +17999,7 @@ Examples:
|
|
|
17975
17999
|
}),
|
|
17976
18000
|
async execute({ path: dirPath, recursive }) {
|
|
17977
18001
|
try {
|
|
17978
|
-
const absolutePath =
|
|
18002
|
+
const absolutePath = resolveUserPath(dirPath);
|
|
17979
18003
|
const entries = [];
|
|
17980
18004
|
async function listDir(dir, prefix = "") {
|
|
17981
18005
|
const items = await fs16__default.readdir(dir, { withFileTypes: true });
|
|
@@ -18035,7 +18059,7 @@ Examples:
|
|
|
18035
18059
|
}
|
|
18036
18060
|
validatePath(filePath, "delete");
|
|
18037
18061
|
try {
|
|
18038
|
-
const absolutePath =
|
|
18062
|
+
const absolutePath = resolveUserPath(filePath);
|
|
18039
18063
|
const stats = await fs16__default.stat(absolutePath);
|
|
18040
18064
|
if (stats.isDirectory()) {
|
|
18041
18065
|
if (!recursive) {
|
|
@@ -18051,7 +18075,7 @@ Examples:
|
|
|
18051
18075
|
} catch (error) {
|
|
18052
18076
|
if (error instanceof ToolError) throw error;
|
|
18053
18077
|
if (error.code === "ENOENT") {
|
|
18054
|
-
return { deleted: false, path:
|
|
18078
|
+
return { deleted: false, path: resolveUserPath(filePath) };
|
|
18055
18079
|
}
|
|
18056
18080
|
throw new FileSystemError(`Failed to delete: ${filePath}`, {
|
|
18057
18081
|
path: filePath,
|
|
@@ -18079,8 +18103,8 @@ Examples:
|
|
|
18079
18103
|
validatePath(source, "read");
|
|
18080
18104
|
validatePath(destination, "write");
|
|
18081
18105
|
try {
|
|
18082
|
-
const srcPath =
|
|
18083
|
-
const destPath =
|
|
18106
|
+
const srcPath = resolveUserPath(source);
|
|
18107
|
+
const destPath = resolveUserPath(destination);
|
|
18084
18108
|
if (!overwrite) {
|
|
18085
18109
|
try {
|
|
18086
18110
|
await fs16__default.access(destPath);
|
|
@@ -18140,8 +18164,8 @@ Examples:
|
|
|
18140
18164
|
validatePath(source, "delete");
|
|
18141
18165
|
validatePath(destination, "write");
|
|
18142
18166
|
try {
|
|
18143
|
-
const srcPath =
|
|
18144
|
-
const destPath =
|
|
18167
|
+
const srcPath = resolveUserPath(source);
|
|
18168
|
+
const destPath = resolveUserPath(destination);
|
|
18145
18169
|
if (!overwrite) {
|
|
18146
18170
|
try {
|
|
18147
18171
|
await fs16__default.access(destPath);
|
|
@@ -18227,7 +18251,7 @@ Examples:
|
|
|
18227
18251
|
}),
|
|
18228
18252
|
async execute({ path: dirPath, depth, showHidden, dirsOnly }) {
|
|
18229
18253
|
try {
|
|
18230
|
-
const absolutePath =
|
|
18254
|
+
const absolutePath = resolveUserPath(dirPath ?? ".");
|
|
18231
18255
|
let totalFiles = 0;
|
|
18232
18256
|
let totalDirs = 0;
|
|
18233
18257
|
const lines = [path17__default.basename(absolutePath) + "/"];
|