@dexto/agent-management 1.2.6 → 1.3.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.
package/dist/writer.cjs CHANGED
@@ -70,9 +70,13 @@ async function writeLLMPreferences(configPath, preferences, overrides) {
70
70
  error instanceof Error ? error.message : String(error)
71
71
  );
72
72
  }
73
- let config;
73
+ let doc;
74
74
  try {
75
- config = (0, import_yaml.parse)(fileContent);
75
+ doc = (0, import_yaml.parseDocument)(fileContent);
76
+ if (doc.errors && doc.errors.length > 0) {
77
+ throw new Error(doc.errors.map((e) => e.message).join("; "));
78
+ }
79
+ const config = doc.toJS();
76
80
  import_core.logger.debug(`Successfully parsed YAML config`, {
77
81
  hasLlmSection: Boolean(config.llm),
78
82
  existingProvider: config.llm?.provider,
@@ -94,17 +98,15 @@ async function writeLLMPreferences(configPath, preferences, overrides) {
94
98
  hasApiKey: Boolean(apiKey),
95
99
  source: overrides ? "CLI overrides + preferences" : "preferences only"
96
100
  });
97
- config.llm = {
98
- ...config.llm,
99
- // Preserve temperature, router, maxTokens, etc.
100
- provider,
101
- // Write user preference
102
- model,
103
- // Write user preference
104
- apiKey
105
- // Write user preference
106
- };
107
- await writeConfigFile(configPath, config);
101
+ let llmNode = doc.get("llm");
102
+ if (!llmNode || typeof llmNode !== "object") {
103
+ doc.set("llm", { provider, model, apiKey });
104
+ } else {
105
+ doc.setIn(["llm", "provider"], provider);
106
+ doc.setIn(["llm", "model"], model);
107
+ doc.setIn(["llm", "apiKey"], apiKey);
108
+ }
109
+ await import_fs.promises.writeFile(configPath, doc.toString(), "utf-8");
108
110
  import_core.logger.info(`\u2713 Applied preferences to: ${path.basename(configPath)} (${provider}/${model})`);
109
111
  }
110
112
  async function writePreferencesToAgent(installedPath, preferences, overrides) {
@@ -1 +1 @@
1
- {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE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,CAAC,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAwEf;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CACzC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
package/dist/writer.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { promises as fs } from "fs";
2
- import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
2
+ import { parseDocument, stringify as stringifyYaml } from "yaml";
3
3
  import * as path from "path";
4
4
  import { logger } from "@dexto/core";
5
5
  import { ConfigError } from "./config/index.js";
@@ -35,9 +35,13 @@ async function writeLLMPreferences(configPath, preferences, overrides) {
35
35
  error instanceof Error ? error.message : String(error)
36
36
  );
37
37
  }
38
- let config;
38
+ let doc;
39
39
  try {
40
- config = parseYaml(fileContent);
40
+ doc = parseDocument(fileContent);
41
+ if (doc.errors && doc.errors.length > 0) {
42
+ throw new Error(doc.errors.map((e) => e.message).join("; "));
43
+ }
44
+ const config = doc.toJS();
41
45
  logger.debug(`Successfully parsed YAML config`, {
42
46
  hasLlmSection: Boolean(config.llm),
43
47
  existingProvider: config.llm?.provider,
@@ -59,17 +63,15 @@ async function writeLLMPreferences(configPath, preferences, overrides) {
59
63
  hasApiKey: Boolean(apiKey),
60
64
  source: overrides ? "CLI overrides + preferences" : "preferences only"
61
65
  });
62
- config.llm = {
63
- ...config.llm,
64
- // Preserve temperature, router, maxTokens, etc.
65
- provider,
66
- // Write user preference
67
- model,
68
- // Write user preference
69
- apiKey
70
- // Write user preference
71
- };
72
- await writeConfigFile(configPath, config);
66
+ let llmNode = doc.get("llm");
67
+ if (!llmNode || typeof llmNode !== "object") {
68
+ doc.set("llm", { provider, model, apiKey });
69
+ } else {
70
+ doc.setIn(["llm", "provider"], provider);
71
+ doc.setIn(["llm", "model"], model);
72
+ doc.setIn(["llm", "apiKey"], apiKey);
73
+ }
74
+ await fs.writeFile(configPath, doc.toString(), "utf-8");
73
75
  logger.info(`\u2713 Applied preferences to: ${path.basename(configPath)} (${provider}/${model})`);
74
76
  }
75
77
  async function writePreferencesToAgent(installedPath, preferences, overrides) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/agent-management",
3
- "version": "1.2.6",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "yaml": "^2.7.1",
18
18
  "zod": "^3.25.0",
19
- "@dexto/core": "1.2.6"
19
+ "@dexto/core": "1.3.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^22.13.5"