KScript docs
EN

Coding agents

JSON diagnostics

kscript check --output json prints one JSON document, so an agent can fix problems without parsing text:

JSON
{
  "files": 1,
  "errors": 0,
  "warnings": 1,
  "problems": [
    {
      "file": "main.kscript",
      "line": 2, "column": 8, "end_line": 2, "end_column": 15,
      "severity": "warning",
      "code": "KS6005",
      "message": "slugify is imported but never used.",
      "fixes": [
        { "title": "Remove the import", "edits": [ { "line": 2, "column": 1, "end_line": 2, "end_column": 43, "new_text": "" } ] }
      ]
    }
  ]
}

Lines and columns count from 1, and each range ends just past its last character. A fix is the same quick fix the editor offers: apply its edits from the last to the first, so the earlier positions stay right. A fix that reaches other files, such as moving a type to types/, also has files: each is { "action": "create", "path": ..., "contents": ... }, { "action": "edit", "path": ..., "edits": [...] } or { "action": "rename", "path": ..., "new_path": ... }, to apply before its own edits. The exit code is the same as for text: 0 with no errors, 1 with errors (or warnings with --warnings-as-errors), and 2 for bad usage, where the JSON is { "error": "..." }.