coding-agent-adapters 0.2.2 → 0.2.5
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.cjs +221 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -11
- package/dist/index.d.ts +94 -11
- package/dist/index.js +216 -22
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
package/dist/index.cjs
CHANGED
|
@@ -143,6 +143,12 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
143
143
|
safe: true
|
|
144
144
|
}
|
|
145
145
|
];
|
|
146
|
+
getRecommendedModels(_credentials) {
|
|
147
|
+
return {
|
|
148
|
+
powerful: "claude-sonnet-4-20250514",
|
|
149
|
+
fast: "claude-haiku-4-5-20251001"
|
|
150
|
+
};
|
|
151
|
+
}
|
|
146
152
|
getCommand() {
|
|
147
153
|
return "claude";
|
|
148
154
|
}
|
|
@@ -206,6 +212,15 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
206
212
|
instructions: loginDetection.instructions
|
|
207
213
|
};
|
|
208
214
|
}
|
|
215
|
+
if (/Do you want to|wants? (your )?permission|needs your permission/i.test(stripped)) {
|
|
216
|
+
return {
|
|
217
|
+
detected: true,
|
|
218
|
+
type: "permission",
|
|
219
|
+
prompt: "Claude tool permission",
|
|
220
|
+
canAutoRespond: false,
|
|
221
|
+
instructions: "Claude is asking permission to use a tool"
|
|
222
|
+
};
|
|
223
|
+
}
|
|
209
224
|
if (/choose.*model|select.*model|available models/i.test(stripped) && /\d+\)|claude-/i.test(stripped)) {
|
|
210
225
|
return {
|
|
211
226
|
detected: true,
|
|
@@ -248,9 +263,8 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
248
263
|
}
|
|
249
264
|
detectReady(output) {
|
|
250
265
|
const stripped = this.stripAnsi(output);
|
|
251
|
-
return stripped.includes("Claude Code") || stripped.includes("How can I help") || stripped.includes("What would you like") || //
|
|
252
|
-
|
|
253
|
-
stripped.includes("Ready");
|
|
266
|
+
return stripped.includes("Claude Code") || stripped.includes("How can I help") || stripped.includes("What would you like") || stripped.includes("Ready") || // Match "claude> " or similar specific prompts, not bare ">"
|
|
267
|
+
/claude>\s*$/i.test(stripped);
|
|
254
268
|
}
|
|
255
269
|
parseOutput(output) {
|
|
256
270
|
const stripped = this.stripAnsi(output);
|
|
@@ -271,7 +285,7 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
271
285
|
};
|
|
272
286
|
}
|
|
273
287
|
getPromptPattern() {
|
|
274
|
-
return /
|
|
288
|
+
return /claude>\s*$/i;
|
|
275
289
|
}
|
|
276
290
|
getHealthCheckCommand() {
|
|
277
291
|
return "claude --version";
|
|
@@ -289,6 +303,12 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
289
303
|
],
|
|
290
304
|
docsUrl: "https://github.com/anthropics/gemini-cli#installation"
|
|
291
305
|
};
|
|
306
|
+
getRecommendedModels(_credentials) {
|
|
307
|
+
return {
|
|
308
|
+
powerful: "gemini-2.5-pro",
|
|
309
|
+
fast: "gemini-2.5-flash"
|
|
310
|
+
};
|
|
311
|
+
}
|
|
292
312
|
getCommand() {
|
|
293
313
|
return "gemini";
|
|
294
314
|
}
|
|
@@ -358,6 +378,15 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
358
378
|
instructions: loginDetection.instructions
|
|
359
379
|
};
|
|
360
380
|
}
|
|
381
|
+
if (/Apply this change\?/i.test(stripped) || /Waiting for user confirmation/i.test(stripped)) {
|
|
382
|
+
return {
|
|
383
|
+
detected: true,
|
|
384
|
+
type: "permission",
|
|
385
|
+
prompt: "Gemini tool execution confirmation",
|
|
386
|
+
canAutoRespond: false,
|
|
387
|
+
instructions: "Gemini is asking to apply a change (file write, shell command, etc.)"
|
|
388
|
+
};
|
|
389
|
+
}
|
|
361
390
|
if (/select.*model|choose.*model|gemini-/i.test(stripped) && /\d+\)/i.test(stripped)) {
|
|
362
391
|
return {
|
|
363
392
|
detected: true,
|
|
@@ -389,8 +418,8 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
389
418
|
}
|
|
390
419
|
detectReady(output) {
|
|
391
420
|
const stripped = this.stripAnsi(output);
|
|
392
|
-
return stripped.includes("
|
|
393
|
-
|
|
421
|
+
return stripped.includes("Ready") || stripped.includes("Type your message") || stripped.includes("How can I help") || stripped.includes("What would you like") || // Match "gemini> " prompt specifically, not bare ">"
|
|
422
|
+
/gemini>\s*$/i.test(stripped);
|
|
394
423
|
}
|
|
395
424
|
parseOutput(output) {
|
|
396
425
|
const stripped = this.stripAnsi(output);
|
|
@@ -412,7 +441,7 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
412
441
|
};
|
|
413
442
|
}
|
|
414
443
|
getPromptPattern() {
|
|
415
|
-
return /
|
|
444
|
+
return /gemini>\s*$/i;
|
|
416
445
|
}
|
|
417
446
|
getHealthCheckCommand() {
|
|
418
447
|
return "gemini --version";
|
|
@@ -463,6 +492,12 @@ var CodexAdapter = class extends BaseCodingAdapter {
|
|
|
463
492
|
safe: true
|
|
464
493
|
}
|
|
465
494
|
];
|
|
495
|
+
getRecommendedModels(_credentials) {
|
|
496
|
+
return {
|
|
497
|
+
powerful: "o3",
|
|
498
|
+
fast: "gpt-4o-mini"
|
|
499
|
+
};
|
|
500
|
+
}
|
|
466
501
|
getCommand() {
|
|
467
502
|
return "codex";
|
|
468
503
|
}
|
|
@@ -625,6 +660,30 @@ var AiderAdapter = class extends BaseCodingAdapter {
|
|
|
625
660
|
safe: true
|
|
626
661
|
}
|
|
627
662
|
];
|
|
663
|
+
getRecommendedModels(credentials) {
|
|
664
|
+
if (credentials?.anthropicKey) {
|
|
665
|
+
return {
|
|
666
|
+
powerful: "anthropic/claude-sonnet-4-20250514",
|
|
667
|
+
fast: "anthropic/claude-haiku-4-5-20251001"
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
if (credentials?.openaiKey) {
|
|
671
|
+
return {
|
|
672
|
+
powerful: "openai/o3",
|
|
673
|
+
fast: "openai/gpt-4o-mini"
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
if (credentials?.googleKey) {
|
|
677
|
+
return {
|
|
678
|
+
powerful: "gemini/gemini-2.5-pro",
|
|
679
|
+
fast: "gemini/gemini-2.5-flash"
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
powerful: "anthropic/claude-sonnet-4-20250514",
|
|
684
|
+
fast: "anthropic/claude-haiku-4-5-20251001"
|
|
685
|
+
};
|
|
686
|
+
}
|
|
628
687
|
getCommand() {
|
|
629
688
|
return "aider";
|
|
630
689
|
}
|
|
@@ -635,27 +694,24 @@ var AiderAdapter = class extends BaseCodingAdapter {
|
|
|
635
694
|
args.push("--no-pretty");
|
|
636
695
|
args.push("--no-show-diffs");
|
|
637
696
|
}
|
|
638
|
-
const
|
|
697
|
+
const provider = config.adapterConfig?.provider;
|
|
639
698
|
if (config.env?.AIDER_MODEL) {
|
|
640
699
|
args.push("--model", config.env.AIDER_MODEL);
|
|
700
|
+
} else if (provider === "anthropic") {
|
|
701
|
+
args.push("--model", "sonnet");
|
|
702
|
+
} else if (provider === "openai") {
|
|
703
|
+
args.push("--model", "4o");
|
|
704
|
+
} else if (provider === "google") {
|
|
705
|
+
args.push("--model", "gemini");
|
|
641
706
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
}
|
|
707
|
+
const credentials = this.getCredentials(config);
|
|
708
|
+
if (credentials.anthropicKey) args.push("--api-key", `anthropic=${credentials.anthropicKey}`);
|
|
709
|
+
if (credentials.openaiKey) args.push("--api-key", `openai=${credentials.openaiKey}`);
|
|
710
|
+
if (credentials.googleKey) args.push("--api-key", `google=${credentials.googleKey}`);
|
|
645
711
|
return args;
|
|
646
712
|
}
|
|
647
713
|
getEnv(config) {
|
|
648
714
|
const env = {};
|
|
649
|
-
const credentials = this.getCredentials(config);
|
|
650
|
-
if (credentials.anthropicKey) {
|
|
651
|
-
env.ANTHROPIC_API_KEY = credentials.anthropicKey;
|
|
652
|
-
}
|
|
653
|
-
if (credentials.openaiKey) {
|
|
654
|
-
env.OPENAI_API_KEY = credentials.openaiKey;
|
|
655
|
-
}
|
|
656
|
-
if (credentials.googleKey) {
|
|
657
|
-
env.GOOGLE_API_KEY = credentials.googleKey;
|
|
658
|
-
}
|
|
659
715
|
if (!this.isInteractive(config)) {
|
|
660
716
|
env.NO_COLOR = "1";
|
|
661
717
|
}
|
|
@@ -757,6 +813,144 @@ var AiderAdapter = class extends BaseCodingAdapter {
|
|
|
757
813
|
}
|
|
758
814
|
};
|
|
759
815
|
|
|
816
|
+
// src/pattern-loader.ts
|
|
817
|
+
var BASELINE_PATTERNS = {
|
|
818
|
+
claude: {
|
|
819
|
+
ready: [
|
|
820
|
+
"Claude Code",
|
|
821
|
+
"How can I help",
|
|
822
|
+
"What would you like",
|
|
823
|
+
"Ready"
|
|
824
|
+
],
|
|
825
|
+
auth: [
|
|
826
|
+
"ANTHROPIC_API_KEY",
|
|
827
|
+
"API key not found",
|
|
828
|
+
"authentication required",
|
|
829
|
+
"Please sign in",
|
|
830
|
+
"Invalid API key"
|
|
831
|
+
],
|
|
832
|
+
blocking: [
|
|
833
|
+
"update available",
|
|
834
|
+
"[y/n]"
|
|
835
|
+
],
|
|
836
|
+
source: "baseline"
|
|
837
|
+
},
|
|
838
|
+
gemini: {
|
|
839
|
+
ready: [
|
|
840
|
+
"Type your message",
|
|
841
|
+
"How can I help",
|
|
842
|
+
"What would you like",
|
|
843
|
+
"Ready"
|
|
844
|
+
],
|
|
845
|
+
auth: [
|
|
846
|
+
"GOOGLE_API_KEY",
|
|
847
|
+
"GEMINI_API_KEY",
|
|
848
|
+
"API key not found",
|
|
849
|
+
"Sign in with Google",
|
|
850
|
+
"gcloud auth",
|
|
851
|
+
"Application Default Credentials"
|
|
852
|
+
],
|
|
853
|
+
blocking: [
|
|
854
|
+
"update available",
|
|
855
|
+
"[y/n]"
|
|
856
|
+
],
|
|
857
|
+
source: "baseline"
|
|
858
|
+
},
|
|
859
|
+
codex: {
|
|
860
|
+
ready: [
|
|
861
|
+
"Codex",
|
|
862
|
+
"How can I help",
|
|
863
|
+
"Ready"
|
|
864
|
+
],
|
|
865
|
+
auth: [
|
|
866
|
+
"OPENAI_API_KEY",
|
|
867
|
+
"API key not found",
|
|
868
|
+
"Unauthorized",
|
|
869
|
+
"Invalid API key"
|
|
870
|
+
],
|
|
871
|
+
blocking: [
|
|
872
|
+
"update available",
|
|
873
|
+
"[y/n]"
|
|
874
|
+
],
|
|
875
|
+
source: "baseline"
|
|
876
|
+
},
|
|
877
|
+
aider: {
|
|
878
|
+
ready: [
|
|
879
|
+
"Aider",
|
|
880
|
+
"What would you like",
|
|
881
|
+
"Ready"
|
|
882
|
+
],
|
|
883
|
+
auth: [
|
|
884
|
+
"API key",
|
|
885
|
+
"OPENAI_API_KEY",
|
|
886
|
+
"ANTHROPIC_API_KEY",
|
|
887
|
+
"No API key"
|
|
888
|
+
],
|
|
889
|
+
blocking: [
|
|
890
|
+
"(Y)es/(N)o",
|
|
891
|
+
"[y/n]"
|
|
892
|
+
],
|
|
893
|
+
source: "baseline"
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
var patternCache = /* @__PURE__ */ new Map();
|
|
897
|
+
async function tryLoadFromMonitor(adapter, version) {
|
|
898
|
+
try {
|
|
899
|
+
const moduleName = "agent-adapter-monitor";
|
|
900
|
+
const monitor = await import(
|
|
901
|
+
/* webpackIgnore: true */
|
|
902
|
+
moduleName
|
|
903
|
+
);
|
|
904
|
+
const patterns = version ? await monitor.getPatternsForVersion(adapter, version) : await monitor.getPatternsForVersion(adapter, "latest");
|
|
905
|
+
if (patterns) {
|
|
906
|
+
return {
|
|
907
|
+
ready: patterns.readyPatterns || [],
|
|
908
|
+
auth: patterns.authPatterns || [],
|
|
909
|
+
blocking: patterns.blockingPatterns || [],
|
|
910
|
+
source: "snapshot",
|
|
911
|
+
version: patterns.version
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
} catch {
|
|
915
|
+
}
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
async function loadPatterns(adapter, version, forceRefresh = false) {
|
|
919
|
+
const cacheKey = `${adapter}:${version || "latest"}`;
|
|
920
|
+
if (!forceRefresh && patternCache.has(cacheKey)) {
|
|
921
|
+
return patternCache.get(cacheKey);
|
|
922
|
+
}
|
|
923
|
+
const monitorPatterns = await tryLoadFromMonitor(adapter, version);
|
|
924
|
+
if (monitorPatterns && monitorPatterns.ready.length > 0) {
|
|
925
|
+
patternCache.set(cacheKey, monitorPatterns);
|
|
926
|
+
return monitorPatterns;
|
|
927
|
+
}
|
|
928
|
+
const baseline = BASELINE_PATTERNS[adapter];
|
|
929
|
+
patternCache.set(cacheKey, baseline);
|
|
930
|
+
return baseline;
|
|
931
|
+
}
|
|
932
|
+
function loadPatternsSync(adapter) {
|
|
933
|
+
const cacheKey = `${adapter}:latest`;
|
|
934
|
+
if (patternCache.has(cacheKey)) {
|
|
935
|
+
return patternCache.get(cacheKey);
|
|
936
|
+
}
|
|
937
|
+
return BASELINE_PATTERNS[adapter];
|
|
938
|
+
}
|
|
939
|
+
async function preloadAllPatterns() {
|
|
940
|
+
const adapters = ["claude", "gemini", "codex", "aider"];
|
|
941
|
+
await Promise.all(adapters.map((adapter) => loadPatterns(adapter)));
|
|
942
|
+
}
|
|
943
|
+
function clearPatternCache() {
|
|
944
|
+
patternCache.clear();
|
|
945
|
+
}
|
|
946
|
+
function getBaselinePatterns(adapter) {
|
|
947
|
+
return BASELINE_PATTERNS[adapter];
|
|
948
|
+
}
|
|
949
|
+
async function hasDynamicPatterns(adapter) {
|
|
950
|
+
const patterns = await tryLoadFromMonitor(adapter);
|
|
951
|
+
return patterns !== null;
|
|
952
|
+
}
|
|
953
|
+
|
|
760
954
|
// src/index.ts
|
|
761
955
|
function createAllAdapters() {
|
|
762
956
|
return [
|
|
@@ -825,8 +1019,14 @@ exports.CodexAdapter = CodexAdapter;
|
|
|
825
1019
|
exports.GeminiAdapter = GeminiAdapter;
|
|
826
1020
|
exports.checkAdapters = checkAdapters;
|
|
827
1021
|
exports.checkAllAdapters = checkAllAdapters;
|
|
1022
|
+
exports.clearPatternCache = clearPatternCache;
|
|
828
1023
|
exports.createAdapter = createAdapter;
|
|
829
1024
|
exports.createAllAdapters = createAllAdapters;
|
|
1025
|
+
exports.getBaselinePatterns = getBaselinePatterns;
|
|
1026
|
+
exports.hasDynamicPatterns = hasDynamicPatterns;
|
|
1027
|
+
exports.loadPatterns = loadPatterns;
|
|
1028
|
+
exports.loadPatternsSync = loadPatternsSync;
|
|
1029
|
+
exports.preloadAllPatterns = preloadAllPatterns;
|
|
830
1030
|
exports.printMissingAdapters = printMissingAdapters;
|
|
831
1031
|
//# sourceMappingURL=index.cjs.map
|
|
832
1032
|
//# sourceMappingURL=index.cjs.map
|