agent-yes 1.48.0 → 1.49.0

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.
@@ -10118,7 +10118,7 @@ const globalAgentRegistry = new AgentRegistry();
10118
10118
 
10119
10119
  //#endregion
10120
10120
  //#region ts/index.ts
10121
- const config = await import("./agent-yes.config-DgkhZ7eQ.js").then((mod) => mod.default || mod);
10121
+ const config = await import("./agent-yes.config-BJbInLnS.js").then((mod) => mod.default || mod);
10122
10122
  const CLIS_CONFIG = config.clis;
10123
10123
  /**
10124
10124
  * Main function to run agent-cli with automatic yes/no responses
@@ -10735,4 +10735,4 @@ const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
10735
10735
 
10736
10736
  //#endregion
10737
10737
  export { AgentContext as a, config as i, CLIS_CONFIG as n, PidStore as o, agentYes as r, removeControlCharacters as s, SUPPORTED_CLIS as t };
10738
- //# sourceMappingURL=SUPPORTED_CLIS-OBl9bioJ.js.map
10738
+ //# sourceMappingURL=SUPPORTED_CLIS-CGHhOLoD.js.map
@@ -1,5 +1,5 @@
1
1
  import { t as logger } from "./logger-DH1Rx9HI.js";
2
- import { access, mkdir, readFile } from "node:fs/promises";
2
+ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { parse } from "yaml";
@@ -32,6 +32,8 @@ const CONFIG_EXTENSIONS = [
32
32
  ".yml",
33
33
  ".yaml"
34
34
  ];
35
+ const SCHEMA_URL = "https://raw.githubusercontent.com/snomiao/agent-yes/main/agent-yes.config.schema.json";
36
+ const YAML_SCHEMA_COMMENT = `# yaml-language-server: $schema=${SCHEMA_URL}`;
35
37
  /**
36
38
  * Check if a file exists
37
39
  */
@@ -108,10 +110,86 @@ async function loadCascadingConfig(options = {}) {
108
110
  logger.debug("[config] Merged config from", nonEmptyConfigs.length, "sources");
109
111
  return merged;
110
112
  }
113
+ /**
114
+ * Check if a config file has a schema reference
115
+ */
116
+ function hasSchemaReference(content, ext) {
117
+ if (ext === ".json") try {
118
+ return "$schema" in JSON.parse(content);
119
+ } catch {
120
+ return false;
121
+ }
122
+ return content.includes("yaml-language-server:") && content.includes("$schema");
123
+ }
124
+ /**
125
+ * Add schema reference to a config file content
126
+ */
127
+ function addSchemaReference(content, ext) {
128
+ if (ext === ".json") try {
129
+ const parsed = JSON.parse(content);
130
+ if ("$schema" in parsed) return content;
131
+ const withSchema = {
132
+ $schema: SCHEMA_URL,
133
+ ...parsed
134
+ };
135
+ return JSON.stringify(withSchema, null, 2) + "\n";
136
+ } catch {
137
+ return content;
138
+ }
139
+ if (hasSchemaReference(content, ext)) return content;
140
+ const lines = content.split("\n");
141
+ let insertIndex = 0;
142
+ for (let i = 0; i < lines.length; i++) {
143
+ const line = lines[i].trim();
144
+ if (line && !line.startsWith("#")) {
145
+ insertIndex = i;
146
+ break;
147
+ }
148
+ insertIndex = i + 1;
149
+ }
150
+ lines.splice(insertIndex, 0, YAML_SCHEMA_COMMENT, "");
151
+ return lines.join("\n");
152
+ }
153
+ /**
154
+ * Ensure schema reference exists in config files
155
+ * Modifies files in-place if they don't have a schema reference
156
+ */
157
+ async function ensureSchemaInConfigFiles(options = {}) {
158
+ const projectDir = options.projectDir ?? process.cwd();
159
+ const homeDir = options.homeDir ?? os.homedir();
160
+ const modified = [];
161
+ const skipped = [];
162
+ for (const dir of [homeDir, projectDir]) {
163
+ const filepath = await findConfigInDir(dir);
164
+ if (!filepath) continue;
165
+ try {
166
+ const content = await readFile(filepath, "utf-8");
167
+ const ext = path.extname(filepath).toLowerCase();
168
+ if (hasSchemaReference(content, ext)) {
169
+ skipped.push(filepath);
170
+ logger.debug(`[config] Schema already present in: ${filepath}`);
171
+ continue;
172
+ }
173
+ const newContent = addSchemaReference(content, ext);
174
+ if (newContent !== content) {
175
+ await writeFile(filepath, newContent, "utf-8");
176
+ modified.push(filepath);
177
+ logger.info(`[config] Added schema reference to: ${filepath}`);
178
+ }
179
+ } catch (error) {
180
+ logger.warn(`[config] Failed to update schema in ${filepath}:`, error);
181
+ }
182
+ }
183
+ return {
184
+ modified,
185
+ skipped
186
+ };
187
+ }
111
188
 
112
189
  //#endregion
113
190
  //#region agent-yes.config.ts
114
191
  logger.debug("loading cli-yes.config.ts from " + import.meta.url);
192
+ ensureSchemaInConfigFiles().catch(() => {});
115
193
  const configDir = await (async () => {
116
194
  const homeConfigDir = path.resolve(os.homedir(), ".agent-yes");
117
195
  if (await mkdir(homeConfigDir, { recursive: true }).then(() => true).catch(() => false)) {
@@ -252,4 +330,4 @@ function getDefaultConfig() {
252
330
 
253
331
  //#endregion
254
332
  export { agent_yes_config_default as t };
255
- //# sourceMappingURL=agent-yes.config-CUuciqYW.js.map
333
+ //# sourceMappingURL=agent-yes.config-B0st3al_.js.map
@@ -1,4 +1,4 @@
1
1
  import "./logger-DH1Rx9HI.js";
2
- import { t as agent_yes_config_default } from "./agent-yes.config-CUuciqYW.js";
2
+ import { t as agent_yes_config_default } from "./agent-yes.config-B0st3al_.js";
3
3
 
4
4
  export { agent_yes_config_default as default };
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import { c as __toESM, i as __commonJSMin, r as require_ms, t as logger } from "./logger-DH1Rx9HI.js";
3
- import "./agent-yes.config-CUuciqYW.js";
4
- import { o as PidStore, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-OBl9bioJ.js";
3
+ import "./agent-yes.config-B0st3al_.js";
4
+ import { o as PidStore, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CGHhOLoD.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { argv } from "process";
7
7
  import { spawn } from "child_process";
@@ -4505,7 +4505,7 @@ const Yargs = YargsFactory(esm_default);
4505
4505
  //#endregion
4506
4506
  //#region package.json
4507
4507
  var name = "agent-yes";
4508
- var version = "1.48.0";
4508
+ var version = "1.49.0";
4509
4509
 
4510
4510
  //#endregion
4511
4511
  //#region ts/parseCliArgs.ts
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./logger-DH1Rx9HI.js";
2
- import { a as AgentContext, i as config, n as CLIS_CONFIG, r as agentYes, s as removeControlCharacters } from "./SUPPORTED_CLIS-OBl9bioJ.js";
2
+ import { a as AgentContext, i as config, n as CLIS_CONFIG, r as agentYes, s as removeControlCharacters } from "./SUPPORTED_CLIS-CGHhOLoD.js";
3
3
 
4
4
  export { AgentContext, CLIS_CONFIG, config, agentYes as default, removeControlCharacters };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-yes",
3
- "version": "1.48.0",
3
+ "version": "1.49.0",
4
4
  "description": "A wrapper tool that automates interactions with various AI CLI tools by automatically handling common prompts and responses.",
5
5
  "keywords": [
6
6
  "ai",
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, beforeEach, afterEach } from "bun:test";
2
- import { loadCascadingConfig, getConfigPaths } from "./configLoader.ts";
3
- import { mkdir, writeFile, rm } from "node:fs/promises";
2
+ import { loadCascadingConfig, getConfigPaths, ensureSchemaInConfigFiles } from "./configLoader.ts";
3
+ import { mkdir, writeFile, readFile, rm } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import os from "node:os";
6
6
 
@@ -124,4 +124,69 @@ logsDir: /custom/logs
124
124
  expect(config.configDir).toBe("/project/config"); // Project takes precedence
125
125
  expect(config.logsDir).toBe("/home/logs"); // Home is used when not overridden
126
126
  });
127
+
128
+ it("should add schema reference to JSON config without one", async () => {
129
+ const configPath = path.join(testDir, ".agent-yes.config.json");
130
+ await writeFile(
131
+ configPath,
132
+ JSON.stringify({ configDir: "/test" })
133
+ );
134
+
135
+ const result = await ensureSchemaInConfigFiles({ projectDir: testDir, homeDir: testDir });
136
+ expect(result.modified).toContain(configPath);
137
+
138
+ const content = await readFile(configPath, "utf-8");
139
+ const parsed = JSON.parse(content);
140
+ expect(parsed.$schema).toContain("agent-yes.config.schema.json");
141
+ expect(parsed.configDir).toBe("/test"); // Original content preserved
142
+ });
143
+
144
+ it("should add schema comment to YAML config without one", async () => {
145
+ const configPath = path.join(testDir, ".agent-yes.config.yaml");
146
+ await writeFile(
147
+ configPath,
148
+ `configDir: /test
149
+ clis:
150
+ claude:
151
+ defaultArgs:
152
+ - --verbose
153
+ `
154
+ );
155
+
156
+ const result = await ensureSchemaInConfigFiles({ projectDir: testDir, homeDir: testDir });
157
+ expect(result.modified).toContain(configPath);
158
+
159
+ const content = await readFile(configPath, "utf-8");
160
+ expect(content).toContain("yaml-language-server:");
161
+ expect(content).toContain("$schema=");
162
+ expect(content).toContain("configDir: /test"); // Original content preserved
163
+ });
164
+
165
+ it("should skip JSON config that already has schema", async () => {
166
+ const configPath = path.join(testDir, ".agent-yes.config.json");
167
+ const originalContent = JSON.stringify({
168
+ $schema: "https://example.com/schema.json",
169
+ configDir: "/test",
170
+ }, null, 2);
171
+ await writeFile(configPath, originalContent);
172
+
173
+ const result = await ensureSchemaInConfigFiles({ projectDir: testDir, homeDir: testDir });
174
+ expect(result.skipped).toContain(configPath);
175
+ expect(result.modified).not.toContain(configPath);
176
+
177
+ const content = await readFile(configPath, "utf-8");
178
+ expect(content).toBe(originalContent); // Unchanged
179
+ });
180
+
181
+ it("should skip YAML config that already has schema comment", async () => {
182
+ const configPath = path.join(testDir, ".agent-yes.config.yaml");
183
+ const originalContent = `# yaml-language-server: $schema=https://example.com/schema.json
184
+ configDir: /test
185
+ `;
186
+ await writeFile(configPath, originalContent);
187
+
188
+ const result = await ensureSchemaInConfigFiles({ projectDir: testDir, homeDir: testDir });
189
+ expect(result.skipped).toContain(configPath);
190
+ expect(result.modified).not.toContain(configPath);
191
+ });
127
192
  });
@@ -2,7 +2,7 @@
2
2
  //! Supports JSON, YAML, YML formats
3
3
  //! Priority: project-dir > home-dir > package-dir
4
4
 
5
- import { readFile, access } from "node:fs/promises";
5
+ import { readFile, writeFile, access } from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import os from "node:os";
8
8
  import { parse as parseYaml } from "yaml";
@@ -12,6 +12,8 @@ import { deepMixin } from "./utils.ts";
12
12
 
13
13
  const CONFIG_FILENAME = ".agent-yes.config";
14
14
  const CONFIG_EXTENSIONS = [".json", ".yml", ".yaml"] as const;
15
+ const SCHEMA_URL = "https://raw.githubusercontent.com/snomiao/agent-yes/main/agent-yes.config.schema.json";
16
+ const YAML_SCHEMA_COMMENT = `# yaml-language-server: $schema=${SCHEMA_URL}`;
15
17
 
16
18
  /**
17
19
  * Check if a file exists
@@ -146,3 +148,103 @@ export function getConfigPaths(options: ConfigLoadOptions = {}): string[] {
146
148
 
147
149
  return paths;
148
150
  }
151
+
152
+ /**
153
+ * Check if a config file has a schema reference
154
+ */
155
+ function hasSchemaReference(content: string, ext: string): boolean {
156
+ if (ext === ".json") {
157
+ try {
158
+ const parsed = JSON.parse(content);
159
+ return "$schema" in parsed;
160
+ } catch {
161
+ return false;
162
+ }
163
+ }
164
+ // YAML/YML - check for yaml-language-server comment
165
+ return content.includes("yaml-language-server:") && content.includes("$schema");
166
+ }
167
+
168
+ /**
169
+ * Add schema reference to a config file content
170
+ */
171
+ function addSchemaReference(content: string, ext: string): string {
172
+ if (ext === ".json") {
173
+ try {
174
+ const parsed = JSON.parse(content);
175
+ if ("$schema" in parsed) {
176
+ return content; // Already has schema
177
+ }
178
+ // Add $schema as first property
179
+ const withSchema = { $schema: SCHEMA_URL, ...parsed };
180
+ return JSON.stringify(withSchema, null, 2) + "\n";
181
+ } catch {
182
+ return content; // Can't parse, return as-is
183
+ }
184
+ }
185
+
186
+ // YAML/YML - prepend comment
187
+ if (hasSchemaReference(content, ext)) {
188
+ return content; // Already has schema
189
+ }
190
+
191
+ // Add schema comment at the top, preserving any existing comments
192
+ const lines = content.split("\n");
193
+
194
+ // Find the first non-empty, non-comment line to insert before actual content
195
+ let insertIndex = 0;
196
+ for (let i = 0; i < lines.length; i++) {
197
+ const line = lines[i].trim();
198
+ if (line && !line.startsWith("#")) {
199
+ insertIndex = i;
200
+ break;
201
+ }
202
+ insertIndex = i + 1;
203
+ }
204
+
205
+ // Insert schema comment before the first content line
206
+ lines.splice(insertIndex, 0, YAML_SCHEMA_COMMENT, "");
207
+ return lines.join("\n");
208
+ }
209
+
210
+ /**
211
+ * Ensure schema reference exists in config files
212
+ * Modifies files in-place if they don't have a schema reference
213
+ */
214
+ export async function ensureSchemaInConfigFiles(
215
+ options: ConfigLoadOptions = {}
216
+ ): Promise<{ modified: string[]; skipped: string[] }> {
217
+ const projectDir = options.projectDir ?? process.cwd();
218
+ const homeDir = options.homeDir ?? os.homedir();
219
+
220
+ const modified: string[] = [];
221
+ const skipped: string[] = [];
222
+
223
+ // Check both project and home directories (not package dir - that's read-only)
224
+ for (const dir of [homeDir, projectDir]) {
225
+ const filepath = await findConfigInDir(dir);
226
+ if (!filepath) continue;
227
+
228
+ try {
229
+ const content = await readFile(filepath, "utf-8");
230
+ const ext = path.extname(filepath).toLowerCase();
231
+
232
+ if (hasSchemaReference(content, ext)) {
233
+ skipped.push(filepath);
234
+ logger.debug(`[config] Schema already present in: ${filepath}`);
235
+ continue;
236
+ }
237
+
238
+ const newContent = addSchemaReference(content, ext);
239
+ if (newContent !== content) {
240
+ await writeFile(filepath, newContent, "utf-8");
241
+ modified.push(filepath);
242
+ logger.info(`[config] Added schema reference to: ${filepath}`);
243
+ }
244
+ } catch (error) {
245
+ logger.warn(`[config] Failed to update schema in ${filepath}:`, error);
246
+ }
247
+ }
248
+
249
+ return { modified, skipped };
250
+ }