coding-agent-adapters 0.2.17 → 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.d.cts CHANGED
@@ -39,6 +39,31 @@ interface ModelRecommendations {
39
39
  /** Fastest/cheapest model for simple tasks */
40
40
  fast: string;
41
41
  }
42
+ /**
43
+ * Describes a file that a coding agent CLI reads from the workspace.
44
+ * Orchestration systems use this to write instructions/config before spawning agents.
45
+ */
46
+ interface AgentFileDescriptor {
47
+ /** File path relative to workspace root (e.g., "CLAUDE.md", ".aider.conf.yml") */
48
+ relativePath: string;
49
+ /** Human-readable description of what this file does */
50
+ description: string;
51
+ /** Whether the CLI reads this file automatically on startup */
52
+ autoLoaded: boolean;
53
+ /** File category */
54
+ type: 'memory' | 'config' | 'rules';
55
+ /** File format */
56
+ format: 'markdown' | 'yaml' | 'json' | 'text';
57
+ }
58
+ /**
59
+ * Options for writing a memory file into a workspace
60
+ */
61
+ interface WriteMemoryOptions {
62
+ /** Custom file name override (default: adapter's primary memory file) */
63
+ fileName?: string;
64
+ /** Append to existing file instead of overwriting */
65
+ append?: boolean;
66
+ }
42
67
  /**
43
68
  * Extended config with credentials and mode support
44
69
  */
@@ -69,6 +94,17 @@ declare abstract class BaseCodingAdapter extends BaseCLIAdapter {
69
94
  * Installation information for this CLI tool
70
95
  */
71
96
  abstract readonly installation: InstallationInfo;
97
+ /**
98
+ * Workspace files this CLI reads automatically.
99
+ * Orchestration systems use this to know where to write instructions/config
100
+ * before spawning an agent.
101
+ */
102
+ abstract getWorkspaceFiles(): AgentFileDescriptor[];
103
+ /**
104
+ * The primary memory file for this CLI (the one it reads for project instructions).
105
+ * Returns the relativePath of the first 'memory' type file from getWorkspaceFiles().
106
+ */
107
+ get memoryFilePath(): string;
72
108
  /**
73
109
  * Get credentials from config
74
110
  */
@@ -110,6 +146,16 @@ declare abstract class BaseCodingAdapter extends BaseCLIAdapter {
110
146
  * Extract the main content from CLI output, removing common artifacts
111
147
  */
112
148
  protected extractContent(output: string, promptPattern: RegExp): string;
149
+ /**
150
+ * Write content to this agent's memory file in a workspace.
151
+ * Creates parent directories as needed.
152
+ *
153
+ * @param workspacePath - Absolute path to the workspace root
154
+ * @param content - The memory/instructions content to write
155
+ * @param options - Optional: custom fileName, append mode
156
+ * @returns The absolute path of the written file
157
+ */
158
+ writeMemoryFile(workspacePath: string, content: string, options?: WriteMemoryOptions): Promise<string>;
113
159
  }
114
160
 
115
161
  /**
@@ -128,6 +174,7 @@ declare class ClaudeAdapter extends BaseCodingAdapter {
128
174
  * Explicit responseType: 'text' prevents the usesTuiMenus default from kicking in.
129
175
  */
130
176
  readonly autoResponseRules: AutoResponseRule[];
177
+ getWorkspaceFiles(): AgentFileDescriptor[];
131
178
  getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
132
179
  getCommand(): string;
133
180
  getArgs(config: SpawnConfig): string[];
@@ -159,6 +206,7 @@ declare class GeminiAdapter extends BaseCodingAdapter {
159
206
  * Source: FolderTrustDialog.tsx, MultiFolderTrustDialog.tsx, CloudFreePrivacyNotice.tsx
160
207
  */
161
208
  readonly autoResponseRules: AutoResponseRule[];
209
+ getWorkspaceFiles(): AgentFileDescriptor[];
162
210
  getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
163
211
  getCommand(): string;
164
212
  getArgs(config: SpawnConfig): string[];
@@ -196,6 +244,7 @@ declare class CodexAdapter extends BaseCodingAdapter {
196
244
  * Source: trust_directory.rs, update_prompt.rs, model_migration.rs, cwd_prompt.rs, chatwidget.rs, main.rs
197
245
  */
198
246
  readonly autoResponseRules: AutoResponseRule[];
247
+ getWorkspaceFiles(): AgentFileDescriptor[];
199
248
  getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
200
249
  getCommand(): string;
201
250
  getArgs(config: SpawnConfig): string[];
@@ -244,6 +293,7 @@ declare class AiderAdapter extends BaseCodingAdapter {
244
293
  * Decline rules come first to override the generic accept patterns.
245
294
  */
246
295
  readonly autoResponseRules: AutoResponseRule[];
296
+ getWorkspaceFiles(): AgentFileDescriptor[];
247
297
  getRecommendedModels(credentials?: AgentCredentials): ModelRecommendations;
248
298
  getCommand(): string;
249
299
  getArgs(config: SpawnConfig): string[];
@@ -431,4 +481,4 @@ declare function checkAllAdapters(): Promise<PreflightResult[]>;
431
481
  */
432
482
  declare function printMissingAdapters(types?: AdapterType[]): Promise<void>;
433
483
 
434
- export { ADAPTER_TYPES, type AdapterPatterns, type AdapterType, type AgentCredentials, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type ModelRecommendations, type PreflightResult, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
484
+ export { ADAPTER_TYPES, type AdapterPatterns, type AdapterType, type AgentCredentials, type AgentFileDescriptor, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type ModelRecommendations, type PreflightResult, type WriteMemoryOptions, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
package/dist/index.d.ts CHANGED
@@ -39,6 +39,31 @@ interface ModelRecommendations {
39
39
  /** Fastest/cheapest model for simple tasks */
40
40
  fast: string;
41
41
  }
42
+ /**
43
+ * Describes a file that a coding agent CLI reads from the workspace.
44
+ * Orchestration systems use this to write instructions/config before spawning agents.
45
+ */
46
+ interface AgentFileDescriptor {
47
+ /** File path relative to workspace root (e.g., "CLAUDE.md", ".aider.conf.yml") */
48
+ relativePath: string;
49
+ /** Human-readable description of what this file does */
50
+ description: string;
51
+ /** Whether the CLI reads this file automatically on startup */
52
+ autoLoaded: boolean;
53
+ /** File category */
54
+ type: 'memory' | 'config' | 'rules';
55
+ /** File format */
56
+ format: 'markdown' | 'yaml' | 'json' | 'text';
57
+ }
58
+ /**
59
+ * Options for writing a memory file into a workspace
60
+ */
61
+ interface WriteMemoryOptions {
62
+ /** Custom file name override (default: adapter's primary memory file) */
63
+ fileName?: string;
64
+ /** Append to existing file instead of overwriting */
65
+ append?: boolean;
66
+ }
42
67
  /**
43
68
  * Extended config with credentials and mode support
44
69
  */
@@ -69,6 +94,17 @@ declare abstract class BaseCodingAdapter extends BaseCLIAdapter {
69
94
  * Installation information for this CLI tool
70
95
  */
71
96
  abstract readonly installation: InstallationInfo;
97
+ /**
98
+ * Workspace files this CLI reads automatically.
99
+ * Orchestration systems use this to know where to write instructions/config
100
+ * before spawning an agent.
101
+ */
102
+ abstract getWorkspaceFiles(): AgentFileDescriptor[];
103
+ /**
104
+ * The primary memory file for this CLI (the one it reads for project instructions).
105
+ * Returns the relativePath of the first 'memory' type file from getWorkspaceFiles().
106
+ */
107
+ get memoryFilePath(): string;
72
108
  /**
73
109
  * Get credentials from config
74
110
  */
@@ -110,6 +146,16 @@ declare abstract class BaseCodingAdapter extends BaseCLIAdapter {
110
146
  * Extract the main content from CLI output, removing common artifacts
111
147
  */
112
148
  protected extractContent(output: string, promptPattern: RegExp): string;
149
+ /**
150
+ * Write content to this agent's memory file in a workspace.
151
+ * Creates parent directories as needed.
152
+ *
153
+ * @param workspacePath - Absolute path to the workspace root
154
+ * @param content - The memory/instructions content to write
155
+ * @param options - Optional: custom fileName, append mode
156
+ * @returns The absolute path of the written file
157
+ */
158
+ writeMemoryFile(workspacePath: string, content: string, options?: WriteMemoryOptions): Promise<string>;
113
159
  }
114
160
 
115
161
  /**
@@ -128,6 +174,7 @@ declare class ClaudeAdapter extends BaseCodingAdapter {
128
174
  * Explicit responseType: 'text' prevents the usesTuiMenus default from kicking in.
129
175
  */
130
176
  readonly autoResponseRules: AutoResponseRule[];
177
+ getWorkspaceFiles(): AgentFileDescriptor[];
131
178
  getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
132
179
  getCommand(): string;
133
180
  getArgs(config: SpawnConfig): string[];
@@ -159,6 +206,7 @@ declare class GeminiAdapter extends BaseCodingAdapter {
159
206
  * Source: FolderTrustDialog.tsx, MultiFolderTrustDialog.tsx, CloudFreePrivacyNotice.tsx
160
207
  */
161
208
  readonly autoResponseRules: AutoResponseRule[];
209
+ getWorkspaceFiles(): AgentFileDescriptor[];
162
210
  getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
163
211
  getCommand(): string;
164
212
  getArgs(config: SpawnConfig): string[];
@@ -196,6 +244,7 @@ declare class CodexAdapter extends BaseCodingAdapter {
196
244
  * Source: trust_directory.rs, update_prompt.rs, model_migration.rs, cwd_prompt.rs, chatwidget.rs, main.rs
197
245
  */
198
246
  readonly autoResponseRules: AutoResponseRule[];
247
+ getWorkspaceFiles(): AgentFileDescriptor[];
199
248
  getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
200
249
  getCommand(): string;
201
250
  getArgs(config: SpawnConfig): string[];
@@ -244,6 +293,7 @@ declare class AiderAdapter extends BaseCodingAdapter {
244
293
  * Decline rules come first to override the generic accept patterns.
245
294
  */
246
295
  readonly autoResponseRules: AutoResponseRule[];
296
+ getWorkspaceFiles(): AgentFileDescriptor[];
247
297
  getRecommendedModels(credentials?: AgentCredentials): ModelRecommendations;
248
298
  getCommand(): string;
249
299
  getArgs(config: SpawnConfig): string[];
@@ -431,4 +481,4 @@ declare function checkAllAdapters(): Promise<PreflightResult[]>;
431
481
  */
432
482
  declare function printMissingAdapters(types?: AdapterType[]): Promise<void>;
433
483
 
434
- export { ADAPTER_TYPES, type AdapterPatterns, type AdapterType, type AgentCredentials, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type ModelRecommendations, type PreflightResult, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
484
+ export { ADAPTER_TYPES, type AdapterPatterns, type AdapterType, type AgentCredentials, type AgentFileDescriptor, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type ModelRecommendations, type PreflightResult, type WriteMemoryOptions, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { mkdir, appendFile, writeFile } from 'fs/promises';
2
+ import { join, dirname } from 'path';
1
3
  import { BaseCLIAdapter } from 'pty-manager';
2
4
 
3
5
  // src/base-coding-adapter.ts
@@ -6,6 +8,17 @@ var BaseCodingAdapter = class extends BaseCLIAdapter {
6
8
  * Coding agent CLIs use TUI menus that require arrow-key navigation.
7
9
  */
8
10
  usesTuiMenus = true;
11
+ /**
12
+ * The primary memory file for this CLI (the one it reads for project instructions).
13
+ * Returns the relativePath of the first 'memory' type file from getWorkspaceFiles().
14
+ */
15
+ get memoryFilePath() {
16
+ const memoryFile = this.getWorkspaceFiles().find((f) => f.type === "memory");
17
+ if (!memoryFile) {
18
+ throw new Error(`${this.displayName} adapter has no memory file defined`);
19
+ }
20
+ return memoryFile.relativePath;
21
+ }
9
22
  /**
10
23
  * Get credentials from config
11
24
  */
@@ -99,6 +112,26 @@ Docs: ${this.installation.docsUrl}`
99
112
  content = content.trim();
100
113
  return content;
101
114
  }
115
+ /**
116
+ * Write content to this agent's memory file in a workspace.
117
+ * Creates parent directories as needed.
118
+ *
119
+ * @param workspacePath - Absolute path to the workspace root
120
+ * @param content - The memory/instructions content to write
121
+ * @param options - Optional: custom fileName, append mode
122
+ * @returns The absolute path of the written file
123
+ */
124
+ async writeMemoryFile(workspacePath, content, options) {
125
+ const relativePath = options?.fileName ?? this.memoryFilePath;
126
+ const fullPath = join(workspacePath, relativePath);
127
+ await mkdir(dirname(fullPath), { recursive: true });
128
+ if (options?.append) {
129
+ await appendFile(fullPath, content, "utf-8");
130
+ } else {
131
+ await writeFile(fullPath, content, "utf-8");
132
+ }
133
+ return fullPath;
134
+ }
102
135
  };
103
136
 
104
137
  // src/claude-adapter.ts
@@ -171,6 +204,31 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
171
204
  safe: true
172
205
  }
173
206
  ];
207
+ getWorkspaceFiles() {
208
+ return [
209
+ {
210
+ relativePath: "CLAUDE.md",
211
+ description: "Project-level instructions read automatically on startup",
212
+ autoLoaded: true,
213
+ type: "memory",
214
+ format: "markdown"
215
+ },
216
+ {
217
+ relativePath: ".claude/settings.json",
218
+ description: "Project-scoped settings (allowed tools, permissions)",
219
+ autoLoaded: true,
220
+ type: "config",
221
+ format: "json"
222
+ },
223
+ {
224
+ relativePath: ".claude/commands",
225
+ description: "Custom slash commands directory",
226
+ autoLoaded: false,
227
+ type: "config",
228
+ format: "markdown"
229
+ }
230
+ ];
231
+ }
174
232
  getRecommendedModels(_credentials) {
175
233
  return {
176
234
  powerful: "claude-sonnet-4-20250514",
@@ -377,6 +435,31 @@ var GeminiAdapter = class extends BaseCodingAdapter {
377
435
  once: true
378
436
  }
379
437
  ];
438
+ getWorkspaceFiles() {
439
+ return [
440
+ {
441
+ relativePath: "GEMINI.md",
442
+ description: "Project-level instructions read automatically on startup",
443
+ autoLoaded: true,
444
+ type: "memory",
445
+ format: "markdown"
446
+ },
447
+ {
448
+ relativePath: ".gemini/settings.json",
449
+ description: "Project-scoped settings (tool permissions, sandbox config)",
450
+ autoLoaded: true,
451
+ type: "config",
452
+ format: "json"
453
+ },
454
+ {
455
+ relativePath: ".gemini/styles",
456
+ description: "Custom style/persona definitions directory",
457
+ autoLoaded: false,
458
+ type: "config",
459
+ format: "markdown"
460
+ }
461
+ ];
462
+ }
380
463
  getRecommendedModels(_credentials) {
381
464
  return {
382
465
  powerful: "gemini-3-pro",
@@ -657,6 +740,31 @@ var CodexAdapter = class extends BaseCodingAdapter {
657
740
  safe: true
658
741
  }
659
742
  ];
743
+ getWorkspaceFiles() {
744
+ return [
745
+ {
746
+ relativePath: "AGENTS.md",
747
+ description: "Project-level instructions read automatically on startup",
748
+ autoLoaded: true,
749
+ type: "memory",
750
+ format: "markdown"
751
+ },
752
+ {
753
+ relativePath: "codex.md",
754
+ description: "Additional project context file",
755
+ autoLoaded: true,
756
+ type: "memory",
757
+ format: "markdown"
758
+ },
759
+ {
760
+ relativePath: ".codex/config.json",
761
+ description: "Project-scoped Codex configuration",
762
+ autoLoaded: true,
763
+ type: "config",
764
+ format: "json"
765
+ }
766
+ ];
767
+ }
660
768
  getRecommendedModels(_credentials) {
661
769
  return {
662
770
  powerful: "o3",
@@ -1030,6 +1138,31 @@ var AiderAdapter = class extends BaseCodingAdapter {
1030
1138
  safe: true
1031
1139
  }
1032
1140
  ];
1141
+ getWorkspaceFiles() {
1142
+ return [
1143
+ {
1144
+ relativePath: ".aider.conventions.md",
1145
+ description: "Project conventions and instructions read on startup (--read flag)",
1146
+ autoLoaded: true,
1147
+ type: "memory",
1148
+ format: "markdown"
1149
+ },
1150
+ {
1151
+ relativePath: ".aider.conf.yml",
1152
+ description: "Project-scoped Aider configuration (model, flags, options)",
1153
+ autoLoaded: true,
1154
+ type: "config",
1155
+ format: "yaml"
1156
+ },
1157
+ {
1158
+ relativePath: ".aiderignore",
1159
+ description: "Gitignore-style file listing paths Aider should not edit",
1160
+ autoLoaded: true,
1161
+ type: "rules",
1162
+ format: "text"
1163
+ }
1164
+ ];
1165
+ }
1033
1166
  getRecommendedModels(credentials) {
1034
1167
  if (credentials?.anthropicKey) {
1035
1168
  return {