( ctx context.Context, deps commandDeps, homePaths aghconfig.HomePaths, target aghconfig.WriteTarget, path []string, value any, redacted bool, )
| 1217 | } |
| 1218 | |
| 1219 | func maybeApplyConfigSetViaDaemon( |
| 1220 | ctx context.Context, |
| 1221 | deps commandDeps, |
| 1222 | homePaths aghconfig.HomePaths, |
| 1223 | target aghconfig.WriteTarget, |
| 1224 | path []string, |
| 1225 | value any, |
| 1226 | redacted bool, |
| 1227 | ) (*configSetRecord, error) { |
| 1228 | if !supportsDaemonManagedConfigSet(path, target) { |
| 1229 | return nil, nil |
| 1230 | } |
| 1231 | |
| 1232 | _, running, err := daemonInfo(homePaths, deps) |
| 1233 | if err != nil { |
| 1234 | return nil, fmt.Errorf("cli: inspect daemon state for config set: %w", err) |
| 1235 | } |
| 1236 | if !running { |
| 1237 | return nil, nil |
| 1238 | } |
| 1239 | |
| 1240 | disabledSkills, ok := value.([]string) |
| 1241 | if !ok { |
| 1242 | return nil, fmt.Errorf( |
| 1243 | "cli: config set %q expects a string slice payload, got %T", |
| 1244 | strings.Join(path, "."), |
| 1245 | value, |
| 1246 | ) |
| 1247 | } |
| 1248 | |
| 1249 | cfg, err := deps.loadConfig() |
| 1250 | if err != nil { |
| 1251 | return nil, fmt.Errorf("cli: load current config for daemon-backed config set: %w", err) |
| 1252 | } |
| 1253 | cfg.Skills.DisabledSkills = append([]string(nil), disabledSkills...) |
| 1254 | |
| 1255 | client, err := clientFromDeps(deps) |
| 1256 | if err != nil { |
| 1257 | return nil, fmt.Errorf("cli: create daemon client for config set: %w", err) |
| 1258 | } |
| 1259 | result, err := client.UpdateSettingsSkills(ctx, UpdateSettingsSkillsRequest{ |
| 1260 | Config: settingsSkillsPayloadFromConfig(cfg.Skills), |
| 1261 | }) |
| 1262 | if err != nil { |
| 1263 | return nil, fmt.Errorf("cli: apply %q via daemon settings surface: %w", strings.Join(path, "."), err) |
| 1264 | } |
| 1265 | |
| 1266 | outputValue := value |
| 1267 | if redacted { |
| 1268 | outputValue = aghconfig.RedactedValue() |
| 1269 | } |
| 1270 | return &configSetRecord{ |
| 1271 | Path: strings.Join(path, "."), |
| 1272 | Value: outputValue, |
| 1273 | Scope: string(target.Scope()), |
| 1274 | Target: target.Path(), |
| 1275 | Redacted: redacted, |
| 1276 | Lifecycle: string(result.Lifecycle), |
no test coverage detected