octto 0.1.3 → 0.1.4

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.
@@ -1,5 +1,5 @@
1
1
  import type { AgentConfig } from "@opencode-ai/sdk";
2
- import type { AGENTS } from "@/agents";
2
+ import { AGENTS } from "@/agents";
3
3
  export type { AgentOverride, OcttoConfig } from "./schema";
4
4
  /**
5
5
  * Load user configuration and merge with plugin agents.
package/dist/index.js CHANGED
@@ -800,20 +800,61 @@ var OcttoConfigSchema = object({
800
800
  });
801
801
 
802
802
  // src/config/loader.ts
803
+ var VALID_AGENT_NAMES = Object.values(AGENTS);
804
+ function formatValidationErrors(issues) {
805
+ return issues.map((issue) => {
806
+ const path = issue.path?.map((p) => p.key).join(".") ?? "root";
807
+ return ` - ${path}: ${issue.message}`;
808
+ }).join(`
809
+ `);
810
+ }
803
811
  async function load(configDir) {
804
812
  const baseDir = configDir ?? join(homedir(), ".config", "opencode");
805
813
  const configPath = join(baseDir, "octto.json");
814
+ let parsed;
806
815
  try {
807
816
  const content = await readFile(configPath, "utf-8");
808
- const parsed = JSON.parse(content);
809
- const result = safeParse(OcttoConfigSchema, parsed);
810
- if (!result.success) {
811
- return null;
812
- }
813
- return result.output;
817
+ parsed = JSON.parse(content);
814
818
  } catch {
815
819
  return null;
816
820
  }
821
+ const result = safeParse(OcttoConfigSchema, parsed);
822
+ if (result.success) {
823
+ return result.output;
824
+ }
825
+ console.warn(`[octto] Config validation errors in ${configPath}:`);
826
+ console.warn(formatValidationErrors(result.issues));
827
+ if (typeof parsed !== "object" || parsed === null || !("agents" in parsed)) {
828
+ console.warn("[octto] No valid agents found in config, using defaults");
829
+ return null;
830
+ }
831
+ const rawAgents = parsed.agents;
832
+ if (typeof rawAgents !== "object" || rawAgents === null) {
833
+ console.warn("[octto] Invalid agents format, using defaults");
834
+ return null;
835
+ }
836
+ const validAgents = {};
837
+ let hasValidAgent = false;
838
+ for (const [name, override] of Object.entries(rawAgents)) {
839
+ if (!VALID_AGENT_NAMES.includes(name)) {
840
+ console.warn(`[octto] Unknown agent "${name}" - valid names: ${VALID_AGENT_NAMES.join(", ")}`);
841
+ continue;
842
+ }
843
+ const agentResult = safeParse(AgentOverrideSchema, override);
844
+ if (agentResult.success) {
845
+ validAgents[name] = agentResult.output;
846
+ hasValidAgent = true;
847
+ } else {
848
+ console.warn(`[octto] Invalid config for agent "${name}":`);
849
+ console.warn(formatValidationErrors(agentResult.issues));
850
+ }
851
+ }
852
+ if (!hasValidAgent) {
853
+ console.warn("[octto] No valid agent overrides found, using defaults");
854
+ return null;
855
+ }
856
+ console.warn("[octto] Partial config loaded - some overrides applied despite errors");
857
+ return { agents: validAgents };
817
858
  }
818
859
  async function loadCustomConfig(agents2, configDir) {
819
860
  const config = await load(configDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octto",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "OpenCode plugin that turns rough ideas into designs through branch-based exploration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",