coding-agent-adapters 0.2.16 → 0.2.18

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 CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var promises = require('fs/promises');
4
+ var path = require('path');
3
5
  var ptyManager = require('pty-manager');
4
6
 
5
7
  // src/base-coding-adapter.ts
@@ -8,6 +10,17 @@ var BaseCodingAdapter = class extends ptyManager.BaseCLIAdapter {
8
10
  * Coding agent CLIs use TUI menus that require arrow-key navigation.
9
11
  */
10
12
  usesTuiMenus = true;
13
+ /**
14
+ * The primary memory file for this CLI (the one it reads for project instructions).
15
+ * Returns the relativePath of the first 'memory' type file from getWorkspaceFiles().
16
+ */
17
+ get memoryFilePath() {
18
+ const memoryFile = this.getWorkspaceFiles().find((f) => f.type === "memory");
19
+ if (!memoryFile) {
20
+ throw new Error(`${this.displayName} adapter has no memory file defined`);
21
+ }
22
+ return memoryFile.relativePath;
23
+ }
11
24
  /**
12
25
  * Get credentials from config
13
26
  */
@@ -101,6 +114,26 @@ Docs: ${this.installation.docsUrl}`
101
114
  content = content.trim();
102
115
  return content;
103
116
  }
117
+ /**
118
+ * Write content to this agent's memory file in a workspace.
119
+ * Creates parent directories as needed.
120
+ *
121
+ * @param workspacePath - Absolute path to the workspace root
122
+ * @param content - The memory/instructions content to write
123
+ * @param options - Optional: custom fileName, append mode
124
+ * @returns The absolute path of the written file
125
+ */
126
+ async writeMemoryFile(workspacePath, content, options) {
127
+ const relativePath = options?.fileName ?? this.memoryFilePath;
128
+ const fullPath = path.join(workspacePath, relativePath);
129
+ await promises.mkdir(path.dirname(fullPath), { recursive: true });
130
+ if (options?.append) {
131
+ await promises.appendFile(fullPath, content, "utf-8");
132
+ } else {
133
+ await promises.writeFile(fullPath, content, "utf-8");
134
+ }
135
+ return fullPath;
136
+ }
104
137
  };
105
138
 
106
139
  // src/claude-adapter.ts
@@ -173,6 +206,31 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
173
206
  safe: true
174
207
  }
175
208
  ];
209
+ getWorkspaceFiles() {
210
+ return [
211
+ {
212
+ relativePath: "CLAUDE.md",
213
+ description: "Project-level instructions read automatically on startup",
214
+ autoLoaded: true,
215
+ type: "memory",
216
+ format: "markdown"
217
+ },
218
+ {
219
+ relativePath: ".claude/settings.json",
220
+ description: "Project-scoped settings (allowed tools, permissions)",
221
+ autoLoaded: true,
222
+ type: "config",
223
+ format: "json"
224
+ },
225
+ {
226
+ relativePath: ".claude/commands",
227
+ description: "Custom slash commands directory",
228
+ autoLoaded: false,
229
+ type: "config",
230
+ format: "markdown"
231
+ }
232
+ ];
233
+ }
176
234
  getRecommendedModels(_credentials) {
177
235
  return {
178
236
  powerful: "claude-sonnet-4-20250514",
@@ -379,6 +437,31 @@ var GeminiAdapter = class extends BaseCodingAdapter {
379
437
  once: true
380
438
  }
381
439
  ];
440
+ getWorkspaceFiles() {
441
+ return [
442
+ {
443
+ relativePath: "GEMINI.md",
444
+ description: "Project-level instructions read automatically on startup",
445
+ autoLoaded: true,
446
+ type: "memory",
447
+ format: "markdown"
448
+ },
449
+ {
450
+ relativePath: ".gemini/settings.json",
451
+ description: "Project-scoped settings (tool permissions, sandbox config)",
452
+ autoLoaded: true,
453
+ type: "config",
454
+ format: "json"
455
+ },
456
+ {
457
+ relativePath: ".gemini/styles",
458
+ description: "Custom style/persona definitions directory",
459
+ autoLoaded: false,
460
+ type: "config",
461
+ format: "markdown"
462
+ }
463
+ ];
464
+ }
382
465
  getRecommendedModels(_credentials) {
383
466
  return {
384
467
  powerful: "gemini-3-pro",
@@ -525,12 +608,12 @@ var GeminiAdapter = class extends BaseCodingAdapter {
525
608
  }
526
609
  detectReady(output) {
527
610
  const stripped = this.stripAnsi(output);
528
- if (/do.?you.?trust.?this.?folder/i.test(stripped) || /how.?would.?you.?like.?to.?authenticate/i.test(stripped) || /waiting.?for.?auth/i.test(stripped) || /allow.?google.?to.?use.?this.?data/i.test(stripped)) {
529
- return false;
530
- }
531
611
  if (/type.?your.?message/i.test(stripped)) {
532
612
  return true;
533
613
  }
614
+ if (/do.?you.?trust.?this.?folder/i.test(stripped) || /how.?would.?you.?like.?to.?authenticate/i.test(stripped) || /waiting.?for.?auth/i.test(stripped) || /allow.?google.?to.?use.?this.?data/i.test(stripped)) {
615
+ return false;
616
+ }
534
617
  if (/^\s*[>!*]\s+/m.test(stripped) || /\(r:\)/.test(stripped)) {
535
618
  return true;
536
619
  }
@@ -659,6 +742,31 @@ var CodexAdapter = class extends BaseCodingAdapter {
659
742
  safe: true
660
743
  }
661
744
  ];
745
+ getWorkspaceFiles() {
746
+ return [
747
+ {
748
+ relativePath: "AGENTS.md",
749
+ description: "Project-level instructions read automatically on startup",
750
+ autoLoaded: true,
751
+ type: "memory",
752
+ format: "markdown"
753
+ },
754
+ {
755
+ relativePath: "codex.md",
756
+ description: "Additional project context file",
757
+ autoLoaded: true,
758
+ type: "memory",
759
+ format: "markdown"
760
+ },
761
+ {
762
+ relativePath: ".codex/config.json",
763
+ description: "Project-scoped Codex configuration",
764
+ autoLoaded: true,
765
+ type: "config",
766
+ format: "json"
767
+ }
768
+ ];
769
+ }
662
770
  getRecommendedModels(_credentials) {
663
771
  return {
664
772
  powerful: "o3",
@@ -1032,6 +1140,31 @@ var AiderAdapter = class extends BaseCodingAdapter {
1032
1140
  safe: true
1033
1141
  }
1034
1142
  ];
1143
+ getWorkspaceFiles() {
1144
+ return [
1145
+ {
1146
+ relativePath: ".aider.conventions.md",
1147
+ description: "Project conventions and instructions read on startup (--read flag)",
1148
+ autoLoaded: true,
1149
+ type: "memory",
1150
+ format: "markdown"
1151
+ },
1152
+ {
1153
+ relativePath: ".aider.conf.yml",
1154
+ description: "Project-scoped Aider configuration (model, flags, options)",
1155
+ autoLoaded: true,
1156
+ type: "config",
1157
+ format: "yaml"
1158
+ },
1159
+ {
1160
+ relativePath: ".aiderignore",
1161
+ description: "Gitignore-style file listing paths Aider should not edit",
1162
+ autoLoaded: true,
1163
+ type: "rules",
1164
+ format: "text"
1165
+ }
1166
+ ];
1167
+ }
1035
1168
  getRecommendedModels(credentials) {
1036
1169
  if (credentials?.anthropicKey) {
1037
1170
  return {
@@ -1067,6 +1200,7 @@ var AiderAdapter = class extends BaseCodingAdapter {
1067
1200
  args.push("--no-show-diffs");
1068
1201
  }
1069
1202
  const provider = config.adapterConfig?.provider;
1203
+ const credentials = this.getCredentials(config);
1070
1204
  if (config.env?.AIDER_MODEL) {
1071
1205
  args.push("--model", config.env.AIDER_MODEL);
1072
1206
  } else if (provider === "anthropic") {
@@ -1075,8 +1209,13 @@ var AiderAdapter = class extends BaseCodingAdapter {
1075
1209
  args.push("--model", "4o");
1076
1210
  } else if (provider === "google") {
1077
1211
  args.push("--model", "gemini");
1212
+ } else if (credentials.anthropicKey) {
1213
+ args.push("--model", "sonnet");
1214
+ } else if (credentials.openaiKey) {
1215
+ args.push("--model", "4o");
1216
+ } else if (credentials.googleKey) {
1217
+ args.push("--model", "gemini");
1078
1218
  }
1079
- const credentials = this.getCredentials(config);
1080
1219
  if (credentials.anthropicKey) args.push("--api-key", `anthropic=${credentials.anthropicKey}`);
1081
1220
  if (credentials.openaiKey) args.push("--api-key", `openai=${credentials.openaiKey}`);
1082
1221
  if (credentials.googleKey) args.push("--api-key", `gemini=${credentials.googleKey}`);