ubiquity-os / ubiquity-os-kernel

1 stars 13 forks source link

Parsing Org config #41

Open Keyrxng opened 4 months ago

Keyrxng commented 4 months ago

It used to be the case that the org config was parsed as well. In refactoring /research it relies on keys.openAi which cannot be set at the repo level. Perhaps I'm doing something wrong but I don't think I am although insight would be appreciated

Changes I had to make:

const _orgConfig = parseYaml(
    await download({
      context,
      repository: ".ubiquibot-config",
      owner: payload.repository.owner.login,
      path: ".github/ubiquibot-config.yml",
    })
  );

  /**
   * @TODO update config package to support this, right now
   *       it's pulling a hardcoded org config from it's own repo
   *
   * const merged = await generateConfiguration(_repoConfig, _orgConfig)
   */

  let merged = { ..._repoConfig, ..._orgConfig };

Also generateConfiguration() I think needs updated so that it can be passed both configs and have it return a correctly merged config

import orgConfig from "../../.github/.ubiquibot-config.yml";
import { BotConfig, botConfigSchema, validateBotConfig } from "../types";
import { githubPluginType } from "../types/configuration/plugin-configuration";

export function generateConfiguration(repoConfig?: BotConfig): BotConfig {
  const defaultConfig = Value.Default(botConfigSchema, {}) as BotConfig;

  const merged = mergeWith(defaultConfig, orgConfig, repoConfig, (objValue: unknown, srcValue: unknown) => {
    if (Array.isArray(objValue) && Array.isArray(srcValue)) {