Skip to content

[Fix] Add experimental.hook schema support for file linting #131

@randomm

Description

@randomm

Problem

oclite fails to start with ConfigInvalidError when opencode.work.json contains an experimental.hook section.

Error:

ConfigInvalidError: ConfigInvalidError
 data: {
  path: "/Users/janni/.config/opencode/opencode.work.json",
  issues: [[Object ...], [Object ...]]
 }

Root Cause

The experimental schema in packages/opencode/src/config/config.ts (lines 1120-1191) uses .strict() and doesn't include hook as a valid field.

Config in Use

"experimental": {
  "hook": {
    "file_edited": {
      "python_linter": [{"command": ["ruff", "check", "--fix", "."], "environment": {}}],
      ...
    }
  }
}

Solution

Add hook to the experimental schema:

// In packages/opencode/src/config/config.ts, add to experimental schema:
hook: z
  .object({
    file_edited: z.record(z.string(), z.array(
      z.object({
        command: z.array(z.string()),
        environment: z.record(z.string(), z.string()).optional(),
      })
    )).optional()
  })
  .optional()

Files

  • packages/opencode/src/config/config.ts - lines 1120-1191

Acceptance Criteria

  • experimental.hook.file_edited is a valid config option
  • oclite starts without ConfigInvalidError when hook config present
  • Tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions