{
  "isError" : false,
  "request" : {
    "verbosity" : "summary"
  },
  "response" : {
    "categories" : {
      "editor" : {
        "categoryRules" : [ "After a sequence of editor calls, run ek9_compile (or ek9_run_tests) to verify.", "Call with dryRun:true first to preview the changeset — status is ready / would-fail / conflicts — then re-issue the SAME args with dryRun:false to apply.", "Control response size with verbosity: \"full\" (default — every edit's before/after bodies), \"summary\" (keep each edit's file/type/line range, drop the bodies), or \"none\" (just editCount + the risk block). On an apply after a dry-run already showed the render, verbosity:\"summary\" — or its retained alias terse:true — keeps what changed where without paying for the content twice.", "Pass terseErrors:true to collapse would-be diagnostics to one line each (code/file/line/message); recover the full explanation for any code with ek9_explain_error <code>." ],
        "description" : "Mutate source or package directive. Produce a reviewable changeset; default policy is confirm-on-write.",
        "tools" : [ {
          "description" : "Answers first: status (applied | ready | would-fail | conflicts), written, edits[{file, type:create|overwrite, bytesWritten}] and contentHash; a .ek9 write carries wouldBeDiagnostics from the verifying compile, any other file is written as-is.",
          "idePrecedent" : "fs.writeFile / Write tool (Claude Code) / IDE write-back",
          "name" : "ek9_write_file"
        }, {
          "description" : "Answers first: status (applied | ready | conflicts | would-fail), written and, on a refusal, referenceCount + referencingFiles[] before the per-site conflicts[]; edits[{file, type:delete, disposition}].",
          "idePrecedent" : "IntelliJ Safe Delete (file-level) / shell rm",
          "name" : "ek9_delete_file"
        }, {
          "description" : "Answers first: status (applied | ready | conflicts), written and edits[{file, type:delete, kind:directory}] - removes an EMPTY workspace directory, never a populated tree.",
          "idePrecedent" : "IntelliJ \"Delete\" on an empty directory / shell rmdir",
          "name" : "ek9_delete_directory"
        }, {
          "description" : "Answers first: status (applied | ready | conflicts), written and edits[{file, newFile, type:move}] - a pure file-system relocation of any workspace file, contents untouched.",
          "idePrecedent" : "IntelliJ \"Refactor → Move\" (file-level) / shell mv",
          "name" : "ek9_move_file"
        }, {
          "description" : "Answers first: status (applied | ready | conflicts), written and edits[{file, newFile, type:move}] - a pure file-system rename of a .ek9 source, contents and module identity untouched.",
          "idePrecedent" : "IntelliJ \"Refactor → Rename File\"",
          "name" : "ek9_rename_file"
        }, {
          "description" : "Answers first: status (applied | ready | would-fail | conflicts), written, edits[{file, startLine, endLine, before, after}], wouldBeDiagnostics from the verifying compile and contentHash on an applied edit - an atomic batch of text edits to one file, or to several as one apply.",
          "idePrecedent" : "Claude Code Edit tool / IntelliJ Find-and-Replace in File / sed -i",
          "name" : "ek9_edit_file"
        }, {
          "description" : "Scaffolds one top-level construct (class/record/trait/component/function/type/constant/service) into an EXISTING module file, or a new package.ek9 for mode:'package'; answers status, edits[] (one INSERT, or one CREATE for a package), stubs[] to fill with ek9_insert_statements, added[] and nextStep.",
          "idePrecedent" : "File → New Package… / IntelliJ New… / Cargo new",
          "name" : "ek9_new_construct"
        }, {
          "description" : "Deletes a contiguous statement range from one method/function/operator body; answers status and edits[] (one DELETE per line), or conflicts[] (range-straddles-method-boundary, range-not-on-statement-boundary, removed-statement-declares-used-local, removal-is-a-replacement, range-empties-body).",
          "idePrecedent" : "IntelliJ Cmd+Backspace delete-lines / LSP code action \"Remove statements\"",
          "name" : "ek9_remove_statements"
        }, {
          "description" : "Deletes one whole-line comment block (//, <!- -!>, <!-- --> or <?- -?>) in full; answers status and edits[] (one DELETE per line), or conflicts[] (kind 'comment-shares-line-with-code') when a boundary line also carries code.",
          "idePrecedent" : "IntelliJ Cmd+Shift+/ delete-block-comment / LSP code action \"Remove comment\"",
          "name" : "ek9_remove_comments"
        }, {
          "description" : "Splices EK9 statement(s) into a named method/function/operator body at anchor top, bottom, replace or a body line, re-indented by the tool; answers status, edits[] (one INSERT), insertedLineRange and resultingBodySnippet, or error.problems[] naming the entry that does not parse.",
          "idePrecedent" : "IntelliJ \"Generate\" menu / LSP code action \"Insert at cursor\"",
          "name" : "ek9_insert_statements"
        }, {
          "description" : "Inserts `variableName <- (captures) is|extends Base as [pure] function` with its body (or an inline `(expr)`, or an //AI: stub) after the line; answers status, edits[] and summary, with a would-fail carrying the compiler's own diagnostics.",
          "idePrecedent" : "IntelliJ \"Introduce Lambda\" / anonymous-class generate action",
          "name" : "ek9_create_dynamic_function"
        }, {
          "description" : "Inserts `variableName <- (captures) trait of T as class` (or the tuple / generic form) with its members after the line, auto-adding `default operator ?` for captures; answers status, edits[] and summary, with a would-fail carrying the compiler's own diagnostics (unimplemented abstract methods named).",
          "idePrecedent" : "IntelliJ \"Convert to anonymous class\" / anonymous-class generate action",
          "name" : "ek9_create_dynamic_class"
        }, {
          "description" : "Inserts the field declaration at the construct's canonical field position; answers status, edits[] and summary, a clashing name as conflicts[] (name-collision).",
          "idePrecedent" : "Generate Field (IntelliJ) / Quick Fix - Add Field",
          "name" : "ek9_add_field"
        }, {
          "description" : "Renames a private field and every use inside its owning construct body in one atomic edit; answers status and edits[] (one REPLACE per rewritten line).",
          "idePrecedent" : "Refactor → Rename (IntelliJ, field scope)",
          "name" : "ek9_rename_field"
        }, {
          "description" : "Deletes a field from a class/record/component; answers status and edits[] (one DELETE), or conflicts[] with every in-body reference classified by 'kind' and a suggestedRepair for the mechanical ones.",
          "idePrecedent" : "Refactor → Safe Delete (IntelliJ, field scope)",
          "name" : "ek9_remove_field"
        }, {
          "description" : "Lifts a local and its initialiser to a same-named field of the enclosing class/record/component and deletes the local (adding `default operator ?` when it is the first field); answers status, edits[] and conflicts[] (no-promotable-declaration, not-inside-fielded-aggregate, field-name-collision).",
          "idePrecedent" : "Refactor → Introduce Field (from local variable)",
          "name" : "ek9_introduce_field"
        }, {
          "description" : "Appends a new parameter to the enclosing method/function, replaces the selected in-body expression with it and passes the ORIGINAL expression at every call site (Fowler \"Introduce Parameter\"); answers status, edits[] and conflicts[] (value-expression-not-a-single-expression, type-not-inferable, ...).",
          "idePrecedent" : "Refactor → Introduce Parameter (IntelliJ)",
          "name" : "ek9_introduce_parameter"
        }, {
          "description" : "Deletes a top-level construct or a class/record/component member - or several as one change - after a workspace-wide reference check; answers status and edits[] (one DELETE per line), or conflicts[] with one 'construct-still-referenced' entry per citing site.",
          "idePrecedent" : "Refactor → Safe Delete (IntelliJ)",
          "name" : "ek9_safe_delete"
        }, {
          "description" : "Inserts the new method (parameters and return inferred from variable data-flow) and replaces the block with a call to it; answers status, edits[] and summary, an ambiguous or boundary-crossing block as conflicts[].",
          "idePrecedent" : "Refactor → Extract → Method (IntelliJ) / LSP Extract Method",
          "name" : "ek9_extract_method"
        }, {
          "description" : "Inserts `name <- expression` before the first occurrence and replaces every matching occurrence in the enclosing block with the name; answers status, edits[] and summary, a side-effecting multi-occurrence expression as conflicts[].",
          "idePrecedent" : "Refactor → Extract → Variable (IntelliJ) / LSP Extract Variable",
          "name" : "ek9_extract_variable"
        }, {
          "description" : "Appends `name <- literal` to the module's `defines constant` block (created if absent) and replaces every occurrence of the literal in the file with the name; answers status, edits[] and summary with the occurrence count, a clashing name as conflicts[] (constant-name-collision).",
          "idePrecedent" : "Refactor → Extract → Constant (IntelliJ) / LSP Extract Constant",
          "name" : "ek9_extract_constant"
        }, {
          "description" : "Moves a `name <- literal` declaration into the module's `defines constant` block (same name, original deleted); answers status, edits[] and conflicts[] (no-promotable-declaration, initialiser-not-a-literal, constant-name-collision).",
          "idePrecedent" : "Refactor → Introduce Constant (from field) — declaration-level",
          "name" : "ek9_promote_to_constant"
        }, {
          "description" : "Moves every `defines constant` declaration of one module into one block in one file (created when targetFile is new); answers status, edits[] (one INSERT + one DELETE per moved declaration) and conflicts[] (comments-in-block, module-ambiguous, target-file-ambiguous, pre-existing-duplicate-constant).",
          "idePrecedent" : "NEW IDE surface — Refactor menu → \"Organize Constants…\". Nearest analogues are IntelliJ \"Move Members…\" (but constant-block-aware) and \"Optimize Imports\" (a whole-module tidy with no per-site decisions).",
          "name" : "ek9_organize_constants"
        }, {
          "description" : "Writes the requirement nodes as flat markdown files under .ek9-ai/requirements/ (one atomic batch, each keyed by its frozen slug) and answers the editor envelope: status (applied | ready | conflicts), written, edits[] and summary naming the ids created.",
          "idePrecedent" : "Requirement navigator → New Requirement… (planned)",
          "name" : "ek9_create_requirement"
        }, {
          "description" : "Rewrites one existing requirement node's markdown file (body, title, meta, position, retirement) or deletes it, and answers the editor envelope: status (applied | ready | conflicts), written, edits[] and summary naming the mode applied.",
          "idePrecedent" : "Requirement navigator → right-click Edit / Retire / Reparent (planned)",
          "name" : "ek9_update_requirement"
        }, {
          "description" : "Deletes a single-assignment local's declaration and substitutes its initialiser at every use site (including `${...}` holes); answers status, edits[] and conflicts[] (variable-reassigned, impure-initialiser-multi-use, ...).",
          "idePrecedent" : "Refactor → Inline Variable (IntelliJ) / LSP Inline Variable",
          "name" : "ek9_inline_variable"
        }, {
          "description" : "Replaces every call to a FUNCTION or METHOD with its parameter-substituted body and deletes the declaration; answers status, edits[] (one REPLACE per call site + the DELETE) and conflicts[] (kind 'variable-clash' with {name, suggestedName}).",
          "idePrecedent" : "Refactor → Inline Function (IntelliJ) / LSP Inline Function",
          "name" : "ek9_inline_function"
        }, {
          "description" : "Renames a symbol and every workspace reference to it atomically across all files (references blocks and `${...}` holes included); answers status, edits[] per site and conflicts[] (name-collision-in-target-scope, convention-mismatch, symbol-not-renameable).",
          "idePrecedent" : "Refactor → Rename (IntelliJ) / LSP Rename Symbol",
          "name" : "ek9_rename_symbol"
        }, {
          "description" : "Rewrites the declaration and EVERY call site atomically (add / remove / reorder parameters, change the return type, toggle 'as pure'); answers status, edits[] and summary with the call-site count, a blocking call site as conflicts[] (callsite-incompatible-with-new-signature).",
          "idePrecedent" : "Refactor → Change Signature (IntelliJ)",
          "name" : "ek9_change_signature"
        }, {
          "description" : "Adds or removes 'as pure' on the callable the diagnostic names, with the override cascade applied; answers status, edits[] and summary, the horizontal cascade as advisories[] and a mode/diagnosis mismatch as conflicts[].",
          "idePrecedent" : "IDE quick-fix: reconcile purity contract (design-by-contract)",
          "name" : "ek9_fix_purity_contract"
        }, {
          "description" : "Rewrites the method's declaration line with the new access modifier (public = none); answers status, edits[] and summary, an unchanged method as conflicts[] (already-<visibility>).",
          "idePrecedent" : "Refactor → Change Signature (visibility) (IntelliJ) / Change Method Visibility (Eclipse)",
          "name" : "ek9_change_visibility"
        }, {
          "description" : "Appends 'as open' to the declaration so the construct can be extended; answers status and edits[] (one REPLACE on the declaration line), or conflicts[] when it is already open.",
          "idePrecedent" : "Refactor → Make Class Open",
          "name" : "ek9_make_open"
        }, {
          "description" : "Strips 'as open' from the declaration so the construct can no longer be extended; answers status, edits[] and conflicts[] naming every subtype (kind 'subtype') that would break with E05030.",
          "idePrecedent" : "Refactor → Make Class Closed / Final",
          "name" : "ek9_make_closed"
        }, {
          "description" : "Rewrites the declaration to 'as abstract' (replacing any 'as open') so the construct can no longer be instantiated; answers status, edits[] and wouldBeDiagnostics with every direct construction site (E10030).",
          "idePrecedent" : "Refactor → Make Class Abstract",
          "name" : "ek9_make_abstract"
        }, {
          "description" : "Removes 'as abstract' from the declaration (keeping 'as open' unless keepOpen:false) so the construct can be instantiated; answers status, edits[] and conflicts[] listing every remaining abstract member (kind 'abstract-method').",
          "idePrecedent" : "Refactor → Make Class Concrete",
          "name" : "ek9_make_concrete"
        }, {
          "description" : "Adds 'allow only A, B, C' to a class or trait declaration (plus 'as open' on a class that has no extensibility modifier); answers status, edits[] and conflicts[] naming any entry that does not extend the target or any existing subtype left off the list.",
          "idePrecedent" : "Kotlin \"Make sealed\" (loose analogue)",
          "name" : "ek9_seal_type",
          "rules" : [ "allowOnly must name EVERY subtype in the target's hierarchy at ANY depth — a grandchild that extends a permitted subtype must still be listed, because EK9 rejects an unlisted concrete transitive descendant with E05240. Query the full subtype set first (e.g. ek9_query_type_hierarchy); any you omit come back as an 'existing-subtypes-not-in-allowlist' conflict." ]
        }, {
          "description" : "Removes the 'allow only A, B, C' clause from a sealed class or trait, keeping its 'as open' / 'as abstract'; answers status and edits[] (one REPLACE on the declaration line), or conflicts[] (kind 'already-unsealed') when there is no clause.",
          "idePrecedent" : "Remove sealed modifier (no direct IDE precedent)",
          "name" : "ek9_unseal_type"
        }, {
          "description" : "Rewrites the sealed type's 'allow only' line with the new subtypes appended; answers status, edits[] and summary, each bad entry as conflicts[] (target-not-sealed, entry-does-not-extend-target, entry-already-in-allowlist).",
          "idePrecedent" : "Kotlin sealed-hierarchy extension (loose analogue)",
          "name" : "ek9_add_to_sealed_allowlist",
          "rules" : [ "Use only on an ALREADY-sealed target (has an 'allow only' clause) — for initial sealing use ek9_seal_type. The entry must already extend (class) / implement (trait) the target; a not-yet-extending entry returns 'entry-does-not-extend-target'. Adding a subtype to a type dispatched over (as dispatcher) may require a new handler (E05260) — surfaced as a would-fail; follow up with ek9_generate_dispatcher / ek9_add_method." ]
        }, {
          "description" : "Inserts the method (signature, a require-guarded stub body and the return) at the construct's canonical member position; answers status, edits[] and summary, a same-signature method as conflicts[] (signature-collision).",
          "idePrecedent" : "Generate Method (IntelliJ) / Override/Implement Method",
          "name" : "ek9_add_method"
        }, {
          "description" : "Inserts the web operation (`byId() as GET for :/{id}` or `operator += for :/`) with a compiling stub body into the service; answers status, edits[] and summary, a duplicate route as conflicts[] (route-collision).",
          "idePrecedent" : "Add Endpoint / Generate REST Method",
          "name" : "ek9_add_route"
        }, {
          "description" : "Appends the application to the file's 'defines application' block (created if absent), one 'register Component() as Interface' line per registration; answers status, edits[] and summary, with a would-fail carrying the compiler's own diagnostics.",
          "idePrecedent" : "New Application / DI Container",
          "name" : "ek9_add_application"
        }, {
          "description" : "Appends the program (or @Test program) to the file's 'defines program' block, created if absent, with a stub body that references every parameter and injection; answers status, edits[] and summary.",
          "idePrecedent" : "New Program / Main / Test",
          "name" : "ek9_add_program"
        }, {
          "description" : "Rewrites the @Test directive line above the program to '@Test: \"REQ:x\"' (the execution group kept); answers status, edits[] and summary, an unchanged directive as conflicts[] (already-anchored).",
          "idePrecedent" : "Anchor Test to Requirement",
          "name" : "ek9_anchor_test"
        }, {
          "description" : "Inserts the 'require <divisor> <> 0' line guard-first (an inline-initialised return becomes '<- rtn as T?' + ':=?'), re-finding the counterexample server-side, and migrates a pinning @Test to assertPanic in the same changeset; answers status, edits[] and summary.",
          "idePrecedent" : "IDE quick-fix: add precondition (design-by-contract guard)",
          "name" : "ek9_apply_symbolic_fix"
        }, {
          "description" : "Rewrites the construct's head to 'if x <- f()' (or ':=?', or ':=' with an explicit 'then x?', as the source assignment dictates) and deletes the standalone assignment and the redundant 'x?' check; answers status, edits[] and summary, an unsafe or unsupported shape as conflicts[].",
          "idePrecedent" : "IDE quick-fix: convert check-then-use into a guard (design-by-contract null safety)",
          "name" : "ek9_apply_guard_pattern"
        }, {
          "description" : "Inserts one constructor at the construct's canonical member position; answers status, edits[] and summary, a same-shape constructor as conflicts[] (constructor-already-exists, with its line).",
          "idePrecedent" : "Generate Constructor (IntelliJ)",
          "name" : "ek9_add_constructor"
        }, {
          "description" : "Replaces the no-arg constructor with its other spelling - 'default Name()' ↔ an explicit 'this.field :=?",
          "idePrecedent" : "Convert Constructor (collapse/expand)",
          "name" : "ek9_convert_constructor"
        }, {
          "description" : "Inserts the operator declaration (or the bare 'default operator' block) at the construct's canonical operator position; answers status, edits[] and summary - 'unchanged', naming where it is, for a default operator the construct already declares; statements[] for an operator already written by hand replace its body, and body:'explicit' over one names the insert route in conflicts[].",
          "idePrecedent" : "Generate Operator (no direct equivalent — EK9-specific)",
          "name" : "ek9_add_operator"
        }, {
          "description" : "Replaces the operator's declaration and body with the one-line 'default operator <sym>' form (the inverse of ek9_expand_default_operator); answers status, edits[] and summary.",
          "idePrecedent" : "Code Cleanup → Use Default Implementation (no direct equivalent)",
          "name" : "ek9_collapse_to_default_operator"
        }, {
          "description" : "Replaces the 'default operator' declaration with the explicit body the compiler would synthesise from the fields, ready to customise; answers status, edits[] and summary, a missing default line as conflicts[] (target-not-a-default-operator).",
          "idePrecedent" : "Generate Default Implementation (no direct equivalent)",
          "name" : "ek9_expand_default_operator"
        }, {
          "description" : "Appends 'with trait of <Trait>' (or '… by <field>') to the construct's declaration and, when implementing, one override stub per abstract trait method; answers status, edits[] and summary, an already-adopted trait as conflicts[] (trait-already-adopted).",
          "idePrecedent" : "Implement Interface (IntelliJ — Cmd+I) / Generate Delegate",
          "name" : "ek9_adopt_trait"
        }, {
          "description" : "Inserts an 'override' stub for every abstract trait method the class has not implemented; answers status and edits[] (one INSERT block), or an error carrying the resolutions[] a concrete-diamond collision needs.",
          "idePrecedent" : "Implement Methods (IntelliJ)",
          "name" : "ek9_implement_methods"
        }, {
          "description" : "Rewrites the class header's 'with trait of <Trait>' clause to '...",
          "idePrecedent" : "Generate Delegate (IntelliJ)",
          "name" : "ek9_generate_delegation"
        }, {
          "description" : "Inserts the '<name>() as dispatcher' entry with its fallback body plus one same-named handler overload per subtype of the base type; answers status, edits[] and summary naming any existing handlers kept.",
          "idePrecedent" : "Generate (IntelliJ) — visitor/dispatch scaffolding",
          "name" : "ek9_generate_dispatcher"
        }, {
          "description" : "Deletes every .ek9 file that is a bare zero-construct module stub (shebang + 'defines module' + //EOF, line comments allowed); answers status, edits[] (one DELETE per file) and skipped[] with a reason per retained candidate.",
          "idePrecedent" : "NEW IDE surface — Build menu → \"Prune Empty Sources…\" wizard (root picker, module filter, preview pane with two columns: files to delete + retained candidates with reasons). Also wired as a receipts-pane follow-up action on every pure-relocation tool (ek9_organize_localized_text, ek9_extract_to_localized_text, ek9_move_construct).",
          "name" : "ek9_prune_empty_sources"
        }, {
          "description" : "Replaces a selected `\"a\" + var + \"b\"` concat with the equivalent backtick interpolation, escaping backtick and `$` in literal segments; answers status and edits[] (one REPLACE), conflicts[] (selection-not-a-string-expression, operand-has-no-string-operator with a suggestedRepair), or status:unchanged when the selection is already a backtick literal.",
          "idePrecedent" : "IntelliJ \"Convert to template string\" / VS Code \"Convert to template literal\"",
          "name" : "ek9_rewrite_string_concat"
        }, {
          "description" : "Splices `LEFT <op> RIGHT` in place of a selected single-line left operand using one of the EK9 coalescing / elvis operators; answers status, edits[] (one REPLACE) and conflicts[] (kind 'selection-not-an-expression'), with a type-incompatible pairing surfacing as would-fail.",
          "idePrecedent" : "no direct precedent — EK9-specific coalescing / elvis operators",
          "name" : "ek9_insert_coalescing"
        }, {
          "description" : "Folds a contiguous line range under an if / if-else / try-catch / try-catch-finally / for-range / while head, re-indenting the block per EK9's brace-free rules; answers status and edits[] (one REPLACE carrying the head + the re-indented lines, one DELETE per absorbed line).",
          "idePrecedent" : "Surround With… (IntelliJ — Cmd+Alt+T)",
          "name" : "ek9_surround_with"
        }, {
          "description" : "Relocates one top-level construct to another .ek9 file, rewriting every workspace 'references' entry when the move changes module; answers status, edits[] (source DELETE, target INSERT, one rewrite per referring file) and conflicts[].",
          "idePrecedent" : "Move Class (IntelliJ)",
          "name" : "ek9_move_construct"
        }, {
          "description" : "Moves the named methods/operators from a subclass into its superclass, dropping 'override' on the moved declarations; answers status and edits[] (one DELETE per member + one INSERT on the superclass).",
          "idePrecedent" : "Pull Members Up (IntelliJ)",
          "name" : "ek9_pull_up"
        }, {
          "description" : "Removes the named methods/operators from a superclass and copies them into each named direct subclass; answers status, edits[] (one DELETE + one INSERT per subclass) and conflicts[] (subclass-not-direct, target-is-only-source-class).",
          "idePrecedent" : "Push Members Down (IntelliJ)",
          "name" : "ek9_push_down"
        }, {
          "description" : "Appends a new 'defines trait' block declaring the chosen methods as abstract, adds 'with trait of <Name>' to the class header and 'override' to each method; answers status, edits[] and summary, a non-extractable member as conflicts[] (member-not-extractable-to-trait).",
          "idePrecedent" : "Extract Interface (IntelliJ / Eclipse)",
          "name" : "ek9_extract_trait"
        }, {
          "description" : "Wraps a whole-line range in EK9 block-comment markers (<!- ...",
          "idePrecedent" : "Comment with Block Comment (IntelliJ)",
          "name" : "ek9_toggle_block_comment"
        }, {
          "description" : "Rewrites the file in canonical EK9 style (indentation, spacing, blank-line and line-break conventions); answers status, edits[] (one per changed line) and summary, an unparseable file as conflicts[] (source-not-parseable).",
          "idePrecedent" : "Reformat Code (IntelliJ Ctrl+Alt+L)",
          "name" : "ek9_format"
        }, {
          "description" : "Rewrites the `defines text for \"<locale>\"` blocks of one text type in every locale that defines it (one atomic edit, so E07150 locale-completeness holds) and answers the editor envelope: status (applied | ready | would-fail | conflicts | error), written, edits[], summary, and translationDebt[] naming each {textType, locale, method} left placeholder-stubbed.",
          "idePrecedent" : "NEW IDE surface — JavaFX dialog for create-text-type, right-click context menu inside `defines text for` blocks",
          "name" : "ek9_edit_localized_text"
        }, {
          "description" : "Replaces the selected string literal with `<localeAccessor>.<name>(args)` and adds the text method to every locale of the i18n file in one atomic changeset, answering the editor envelope: status (applied | ready | would-fail | conflicts | error), written, edits[], summary and translationDebt[] naming the locales left placeholder-stubbed.",
          "idePrecedent" : "NEW IDE surface — Right-click on a selected string literal (double-quoted or backtick-interpolation) inside an EK9 source file → \"Extract to Localized Text…\"",
          "name" : "ek9_extract_to_localized_text"
        }, {
          "description" : "Moves the `defines text for \"<locale>\"` blocks between files to the chosen layout - block content preserved verbatim, donors kept as residual stubs, never deleted - and answers the editor envelope: status (applied | ready | conflicts | error), written, edits[] and summary; an already-canonical layout is applied with empty edits[].",
          "idePrecedent" : "NEW IDE surface — Build menu → \"Organize Localized Text…\" wizard (mode picker, preview pane, conflict resolver). Pairs with the Translation Completeness panel.",
          "name" : "ek9_organize_localized_text"
        }, {
          "description" : "Deletes the unused entries of one file's 'references' block (usage judged by a scratch compile, so functions, types and name-collisions are all right) and answers the editor envelope: status (applied | ready | error), written, edits[] - one delete per unused line - and summary; an already-clean file is applied with empty edits[].",
          "idePrecedent" : "Optimize Imports (IntelliJ) / Remove Unused Imports",
          "name" : "ek9_organize_references"
        }, {
          "description" : "Rewrites one file's 'references' block - adding the module::Name entry for each cross-module symbol the file uses but has not declared (E50001/E50010) and deleting each entry nothing uses - and answers the editor envelope: status (applied | ready | conflicts | error), written, edits[] and summary ('Added N and removed M reference(s)').",
          "idePrecedent" : "Optimize Imports (IntelliJ) / Organize Imports (VS Code)",
          "name" : "ek9_sync_references"
        }, {
          "description" : "Answers with the edit that appends one runtime or dev dependency to the deps/devDeps Dict of a 'defines package' block - source only, nothing is fetched.",
          "idePrecedent" : "npm install / cargo add / mvn add-dependency",
          "name" : "ek9_add_dependency"
        }, {
          "description" : "Answers with the edit that deletes one entry from the deps or devDeps Dict of a 'defines package' block (the whole Dict when it was the last entry).",
          "idePrecedent" : "npm uninstall / cargo remove / mvn dependency:remove",
          "name" : "ek9_remove_dependency"
        }, {
          "description" : "Answers with the edit that adds an excludeDeps entry (module -> viaModule) to a 'defines package' block, blocking a transitive dependency a parent pulls in.",
          "idePrecedent" : "maven exclusions / npm overrides",
          "name" : "ek9_exclude_transitive_dependency"
        }, {
          "description" : "Answers with the edit that deletes one excludeDeps entry from a 'defines package' block, re-allowing a previously-blocked transitive dependency.",
          "idePrecedent" : "maven exclusion removal",
          "name" : "ek9_remove_transitive_exclusion"
        }, {
          "description" : "Answers with the edit that declares one gated-type capability in the 'capabilities <- [...]' List of a 'defines package' block, plus the resolved capability name.",
          "idePrecedent" : "EK9 IDE - package-block right-click \"Add Capability...\" + the E12010 quick-fix. Concept: Android manifest permissions / iOS entitlements.",
          "name" : "ek9_add_capability"
        }, {
          "description" : "Answers with the edit that revokes one gated-type capability from the 'capabilities <- [...]' List of a 'defines package' block, plus the resolved capability name.",
          "idePrecedent" : "EK9 IDE - package-block right-click \"Remove Capability...\". Concept: Android manifest permission removal.",
          "name" : "ek9_remove_capability"
        } ]
      },
      "enquiry" : {
        "categoryRules" : [ "Control response size with verbosity: \"full\" (default — the complete result), \"summary\" (trim per-item detail — graph/tree tools to depth 1, effective-api to member names), or \"none\" (collapse every list to a <key>Count total). Scan a wide result at summary or none, then re-issue full scoped to the one anchor you care about — cheaper than paging a huge full response into context." ],
        "description" : "Read-only tools. Always safe; no side effects. Free to call without confirmation prompts.",
        "tools" : [ {
          "description" : "Returns the EK9 compiler toolchain version string, e.g.",
          "name" : "ek9_version"
        }, {
          "description" : "Returns the reference page for one keyword, built-in type or topic - hover summary, the full type API for a built-in type, usage examples - or the keyword index when no keyword is given.",
          "name" : "ek9_help"
        }, {
          "description" : "Returns the curated rich explanation for one EK9 error code - [DIAGNOSIS], [EXAMPLES] (as ek9_ask 'Q<id>' routes), the first example's source inlined as [WORKED EXAMPLE Q<id>], [ACTION], [SEE ALSO] and, when tooling is mapped, [REMEDIATION].",
          "name" : "ek9_explain_error"
        }, {
          "description" : "Returns the constant EK9 paradigm summary (syntax that is NOT C/Java/Python, first-attempt traps, concepts with no analogue elsewhere) and working rules - the smallest priming context for an AI about to write EK9 code - and with withExamples:true the compiled inline examples after it.",
          "name" : "ek9_paradigm"
        }, {
          "description" : "Returns the best-matching curated Q&A entries: 'match: strong|weak|id' first, then per entry the id, question, category, Oracle tool, the answer and last the compiled EK9 example (capped by default).",
          "name" : "ek9_ask"
        }, {
          "description" : "Returns the whole EK9 tool inventory grouped by category - toolCount and toolNames per category plus workflowNames by default; verbosity:'summary' adds each tool's description, rules and IDE precedent, 'full' the JSON schemas.",
          "name" : "ek9_query_tool_catalogue"
        }, {
          "description" : "Returns one tool's entry - status, match (exact|single|ambiguous|none), then whenToUse, whenNotToUse, description, examples and inputSchema - by name, intent phrase or the error code it remediates.",
          "name" : "ek9_query_tool_detail"
        }, {
          "description" : "Returns one named multi-tool workflow's ordered steps (tool + one-line reason each), or with no name every workflow with workflowNames first.",
          "name" : "ek9_query_workflow"
        }, {
          "description" : "Returns every named multi-tool workflow - workflowCount, workflowNames, then each workflow's summary and full step sequence.",
          "name" : "ek9_list_workflows"
        }, {
          "description" : "Returns EK9's ENFORCED quality-metric limits (coupling, cohesion, complexity, DI, size) - limitCount and limits[] with ruleCode, metricKey, limitKind, comparator, limit and usableMax - from the single source the checkers fire on.",
          "idePrecedent" : "EK9 IDE — quality-gate settings panel (the enforced quality-metric limits)",
          "name" : "ek9_query_metric_limits"
        }, {
          "description" : "Answers first: source.text with source.file/startLine/endLine from the compiled symbol-table boundaries (no line guessing), construct {name, fullyQualifiedName, kind}, members[{name, kind, signature, startLine, endLine}] and source.contentHash.",
          "idePrecedent" : "IntelliJ \"Show body of method\" / LSP textDocument/definition",
          "name" : "ek9_read_construct"
        }, {
          "description" : "Answers first: content (numbered 'N| ' when lineNumbers:true), contentHash for expectedContentHash, and for .ek9 the structure outline {module, constructs[{kind,name,startLine,endLine,signature}]} - whole file up to 2,000 lines, truncated:true first when cut.",
          "idePrecedent" : "cat / Read tool (Claude Code) / fs.readFile",
          "name" : "ek9_read_file"
        }, {
          "description" : "Answers first: matchCount, files[], sites['file.ek9:LINE'] (truncated:true first when cut), then matches[{file,line,column,snippet}] - a literal or regex grep across the workspace with EK9-aware exclusions (build outputs, .ek9-cache/, dot-directories).",
          "idePrecedent" : "ripgrep / grep / Find in Files",
          "name" : "ek9_search_text"
        }, {
          "description" : "Answers first: entryCount and paths[] (workspace-relative, the value ek9_read_file takes), then entries[{path, name, kind, size, lastModified}] - never content; direct children unless pathPattern recurses.",
          "idePrecedent" : "ls / fs.readdir / Glob (Claude Code)",
          "name" : "ek9_list_files"
        }, {
          "description" : "Answers status (healthy | violations | dangling-anchors) and healthy first, then requirementCount, developedCount, outstandingCount, violations[] (the store is broken), danglingAnchors[] (a @Test names a requirement that does not exist), outstanding[] (the backlog) and unanchoredTests[] (the authoring work-list) - the whole graph, nothing to verify.",
          "idePrecedent" : "Requirement navigator → health view (planned)",
          "name" : "ek9_check_requirements"
        }, {
          "description" : "Answers status (ok | not-found) and requirementId first, then the node(s): each carries authored{title, body, retired, meta} and derived{developed, anchoringTests, parentChain, children} so a computed rollup is never mistaken for a person's assertion; list and outstanding return requirementCount + requirements[], footprint the anchoringTests and reachedSymbols.",
          "idePrecedent" : "Requirement navigator tree + detail pane (planned)",
          "name" : "ek9_query_requirement"
        }, {
          "description" : "Answers status (ok | not-found), requirementId and markdown - the specification document generated from the requirement graph with every section marked authored or derived - plus anchorsResolved saying whether a compile backed the derived sections.",
          "idePrecedent" : "Requirement navigator → Render Specification… preview (planned)",
          "name" : "ek9_render_specification"
        }, {
          "description" : "Answers first: deadNames and deadByOwner (owner -> its dead members), complete workspace-wide - then each finding classified.",
          "idePrecedent" : "Code → Inspect Code → Dead Code (IntelliJ)",
          "name" : "ek9_find_unused_code"
        }, {
          "description" : "Answers candidates[] (file, line, name, tier worth-inlining | safe, useCount) ranked slop-first, with counts{} - every local '<-' declaration in scope examined.",
          "idePrecedent" : "Code → Inspect Code → 'Local variable is redundant' (IntelliJ)",
          "name" : "ek9_find_inline_candidates"
        }, {
          "description" : "Answers status, translationDebtCount and translationDebt[] (every {textType, locale, method} still needing translation) first, then the per-(text type, locale, method) status grid (translated | stubbed | missing-error) and summary totals - the whole module, nothing to verify.",
          "idePrecedent" : "NEW IDE surface — translation completeness panel (Surface 3 of ek9_edit_localized_text); read-only grid showing translated / stubbed / missing per (text type, locale, method)",
          "name" : "ek9_query_translation_completeness"
        }, {
          "description" : "Answers first: summary, branch, ahead/behind, isClean, then stagedFiles / modifiedFiles / untrackedFiles / deletedFiles / conflictFiles names and changedFileCount, then the per-file records with change words.",
          "idePrecedent" : "git status / Git Source Control panel",
          "name" : "ek9_git_status"
        }, {
          "description" : "Answers first: summary, fileCount, additions/deletions and changedFiles names, then per-file hunks with fromLine/toLine and the unified-diff text (dropped at verbosity:'summary').",
          "idePrecedent" : "git diff / Diff view",
          "name" : "ek9_git_diff"
        }, {
          "description" : "Answers first: commitCount and commitTotal with a truncation note, then commits (sha, author, date, subject, body, parents; files with includeFileList:true).",
          "idePrecedent" : "git log / Git History view",
          "name" : "ek9_git_log"
        }, {
          "description" : "Answers first: lineCount and the range, then one record per line (line, sha, author, email, date, subject, text); verbosity:'summary' collapses them to same-commit runs.",
          "idePrecedent" : "git blame / Annotate",
          "name" : "ek9_git_blame"
        }, {
          "description" : "Answers first: current, branchCount and branchNames, then per-branch records (name, current, upstream, ahead/behind, gone, sha).",
          "idePrecedent" : "git branch / Branches",
          "name" : "ek9_git_branch",
          "rules" : [ "Orient before ek9_git_switch: 'current' says where HEAD is, and branchNames says whether a branch exists (switch to it) or not (create:true)." ]
        }, {
          "description" : "Answers with hasCycles, cycleCount and the cycles (closed package paths with their edges) across every package declared in the workspace, plus packagesAnalysed and sccCount.",
          "idePrecedent" : "Package Dependency Cycle Detector",
          "name" : "ek9_check_package_dependency_cycles"
        }, {
          "description" : "Answers with version (the 'defines package' literal) and the line it is on for one .ek9 file; null with an error when the file declares no package.",
          "idePrecedent" : "mvn help:evaluate -Dexpression=project.version",
          "name" : "ek9_query_package_version"
        }, {
          "description" : "Answers first: status, packageCount, then packages[] {name, version, description, license, tags, publishable, deps, devDeps, excludeDeps, capabilities, sourceLocation} - declared, not resolved.",
          "idePrecedent" : "View pom.xml / package.json (most IDEs)",
          "name" : "ek9_query_package"
        }, {
          "description" : "Answers first: status, name, fullyQualifiedName, clashFree, donorLocals, renames (one globally-safe fresh name per clashing local), callSiteCount, then callSites[] with per-site clashes and the summary line.",
          "idePrecedent" : "Refactor → Inline (variable-capture pre-check)",
          "name" : "ek9_query_name_clashes"
        }, {
          "description" : "Answers first: name, fullyQualifiedName, kind, type, state, declaredAt, then the modifiers, flags, scope, purityContext and the type's operators - one symbol, cursor-precise.",
          "idePrecedent" : "Quick Documentation (IntelliJ) / Hover (VSCode)",
          "name" : "ek9_inspect_symbol_at_cursor"
        }, {
          "description" : "Answers first: scopeChain[] innermost to outermost, each scope with its symbols (name, kind, type, state, roles), then activeGuards and purityConstraint.",
          "idePrecedent" : "Variables Panel (debug) / Document Symbols (LSP)",
          "name" : "ek9_list_visible_symbols"
        }, {
          "description" : "Answers first: in view 'totals' the workspace-wide methodCount, averages, maxima and methodsAboveCyclomaticThreshold / methodsAboveCognitiveThreshold; in 'hotspots' hotspotNames[] then hotspots[]; in 'inputVariety' per-callable floor/ceiling (display-only).",
          "idePrecedent" : "Code Inspection / SonarQube Complexity",
          "name" : "ek9_query_complexity"
        }, {
          "description" : "Answers first: fieldNames, methodNames, operatorNames, defaultedOperatorNames, superName, traitNames, then construct{name, fullyQualifiedName, module, genus, isOpen, extends, traits, modifiers} and the full fields/methods/operators/constructors/metrics.",
          "idePrecedent" : "Structure View (IntelliJ) / Outline (VSCode)",
          "name" : "ek9_query_construct"
        }, {
          "description" : "Answers first: status, branchCount, loopCount, guardCount, deadBranchCount, then method{name, fullyQualifiedName, signature, declaredAt}, isPure, metrics (cyclomatic/cognitive), flowNodes (the guard-tracked branch/loop tree) and deepAnalysis (provably dead branches, redundant tri-state checks).",
          "idePrecedent" : "Code Inspection / Control Flow Analyzer (IntelliJ)",
          "name" : "ek9_query_flow"
        }, {
          "description" : "Answers first: directions[] (each with summary such as 'candidate-stream-aggregation' or 'keep-as-loop', candidateShape, confidence), then the loop{} facts, outputs[], resources[] and unknowns[] - read-only.",
          "idePrecedent" : "IntelliJ 'Analyze Data Flow' + inspection hints (advisory, not an auto-fix)",
          "name" : "ek9_advise_loop"
        }, {
          "description" : "Answers first: status, name, verified, then counterexampleCount, counterexamples[] {obligation, witness, suggestedTest, suggestedFix}, provedSafe, deadBranches and nextStep.",
          "idePrecedent" : "Design-by-contract / bounded-model verifier (Dafny, Frama-C, CBMC)",
          "name" : "ek9_verify_method"
        }, {
          "description" : "Answers first: status, module, constructCount, constructNames, then constructs[] with kind, member counts and quality metrics (complexity, coupling, cohesion).",
          "name" : "ek9_query_module"
        }, {
          "description" : "Answers first: status, stageCount, then stages[] in order {operator, kind, consumes, produces}, sourceType, resultType and summary.transformations.",
          "name" : "ek9_query_pipeline"
        }, {
          "description" : "Answers first: status, moduleCount, moduleNames, constructCount, then modules[] {name, constructCount, constructs[] {name, category, genus}}; verbosity:'none' lists modules only, 'full' adds per-construct detail.",
          "name" : "ek9_query_workspace"
        }, {
          "description" : "Answers first: classNames[], then classes[] (name, module, file, line, extends, traits, isOpen, isAbstract, keyMethods, methodCount) and summary counts - workspace-wide or the filtered subset.",
          "idePrecedent" : "Classes outline panel (reuse-discovery)",
          "name" : "ek9_query_classes"
        }, {
          "description" : "Answers first: status, recordCount, recordNames - complete for the workspace or the filters given - then records[] {name, module, file, line, fields, extends, traits, isOpen}.",
          "idePrecedent" : "Records outline panel (reuse-discovery)",
          "name" : "ek9_query_records"
        }, {
          "description" : "Answers first: status, implementedByAll (when asked), traitCount, traitNames - complete for the workspace or the filters given - then traits[] {name, module, file, line, traitOf, implementedBy, implementedByCount, methods, methodCount}.",
          "idePrecedent" : "Traits outline panel (reuse-discovery)",
          "name" : "ek9_query_traits"
        }, {
          "description" : "Answers first: componentNames[], then components[] (name, module, file, line, extends, isOpen, isAbstract, keyMethods, methodCount) and summary counts - the DI-injectable constructs, workspace-wide or the filtered subset.",
          "idePrecedent" : "Components outline panel (DI reuse-discovery)",
          "name" : "ek9_query_components"
        }, {
          "description" : "Answers first: constrainedTypeNames[], then constrainedTypes[] (name, module, file, line, constrains, constraint, admissibleWindow, suffix) and summary counts.",
          "idePrecedent" : "Constrained-types outline panel (reuse-discovery)",
          "name" : "ek9_query_constrained_types"
        }, {
          "description" : "Answers first: status, functionCount, functionNames - complete for the workspace or the filters given - then functions[] {name, module, file, line, signature, parameters, returnType, isPure, isAbstract}.",
          "idePrecedent" : "Functions outline panel (reuse-discovery)",
          "name" : "ek9_query_functions"
        }, {
          "description" : "Answers first: status, programCount, programNames - complete for the workspace or the filters given - then programs[] {name, module, file, line, signature, parameters}.",
          "idePrecedent" : "Constructs navigator (by-genus) — Programs group",
          "name" : "ek9_query_programs"
        }, {
          "description" : "Answers first: enumerationNames[], then enumerations[] (name, module, file, line, values in declaration order, valueCount) and summary counts.",
          "idePrecedent" : "Constructs navigator (by-genus) — Enumerations group",
          "name" : "ek9_query_enumerations"
        }, {
          "description" : "Answers first: status, moduleCount, inconsistencyCount, workspaceLocales, then modules[] {name, locales, percentTranslated, methodCount} and inconsistencies[] {locale, supportedIn, missingIn}.",
          "idePrecedent" : "NEW IDE surface — Localisations Overview panel (locale × module completeness matrix + inconsistency flags)",
          "name" : "ek9_query_localisations"
        }, {
          "description" : "Answers first: names[] (every env-var read), then envVars[] per call site (site, name, accessMethod, sanitization, inConstruct), dynamicAccesses[] and summary counts - type-resolved EnvVars calls, never text matches.",
          "idePrecedent" : "NEW IDE surface — \"Environment Variables\" panel listing every env-var read across the workspace (name + file + line + access method + sanitization), row-click navigate, right-click find-usages-of-name",
          "name" : "ek9_query_env_vars"
        }, {
          "description" : "Answers first: consistent, underDeclared, overDeclared, usedCapabilities, declaredCapabilities and findings, then actualUsage with every call site - the workspace-wide gated-type audit against the package block.",
          "idePrecedent" : "EK9 IDE — \"Capabilities\" navigator (left dock): declared-vs-required gated-type audit; under-declared (compile-blocking) and over-declared (unnecessary attack surface) findings with Add/Remove capability quick-fixes; row-click navigate to each call site",
          "name" : "ek9_query_capability_usage"
        }, {
          "description" : "Answers first: status, revealCount, violationCount, privilegedCount, violationSites as file.ek9:LINE, then reveals[] {file, line, column, module, inConstruct, inConstructFqn, privilege}.",
          "idePrecedent" : "EK9 IDE — \"Sensitive Reveals\" navigator (left dock): every Sensitive.reveal() call grouped by legality (⚠ unprivileged / in-function violations = E11090 first, then ✓ privileged), row-click navigate + Show call graph",
          "name" : "ek9_query_sensitive_reveals"
        }, {
          "description" : "Answers first: status, programState, routeCount, byService, then routes[] {verb, uri, fullPath, parameters with binding + sanitized, securityGate, cors, auditWarnings} and summary counts.",
          "idePrecedent" : "EK9 IDE — \"Service Routes\" diagram (bottom pane): services → routes → params with per-node click-to-source, security gate / CORS shown as cross-file jump targets, unsanitized-input and unguarded-route findings highlighted",
          "name" : "ek9_query_service_routes"
        }, {
          "description" : "Answers first: diagnosticCount, errorCount, warningCount, errorCodes[] and sites[] ('file.ek9:LINE CODE message'), then diagnostics[] in full, byCode and byFile - the Problems View of the last compile.",
          "idePrecedent" : "Problems View (IntelliJ / VSCode)",
          "name" : "ek9_query_diagnostics"
        }, {
          "description" : "Answers first: declaredMethodNames, inheritedMethodNames, overrides as 'method:Trait', operatorNames, traitNames - then every member in full with its source and file/line.",
          "idePrecedent" : "Show Members (IntelliJ) / Class View",
          "name" : "ek9_query_effective_api"
        }, {
          "description" : "Answers first: subtypeNames (implementedBy on a trait), superNames, traitNames, allowedSubtypes for a sealed trait - complete workspace-wide - then the full graph.",
          "idePrecedent" : "Type Hierarchy (IntelliJ)",
          "name" : "ek9_query_type_hierarchy"
        }, {
          "description" : "Answers first: useSiteCount, usedByConstructs, useSites as file.ek9:LINE - then each reference with its source line (omitted above 50 sites unless verbosity:'full').",
          "idePrecedent" : "Find Usages (IntelliJ) / Find All References (VSCode)",
          "name" : "ek9_query_references"
        }, {
          "description" : "Answers first: routing[] - per dispatcher method its dispatchOn type, typesWithOwnHandler, typesUsingInheritedHandler (served by a supertype's handler) and typesFallingBack (to the dispatchOn entry point's own body), with routingCovers when the lists are whole - then the full dispatcherMethods[] with resolutionTable; on a sealed type, allowedSubtypes[].",
          "name" : "ek9_query_dispatchers"
        }, {
          "description" : "Answers first: programState, queriesReliable with its reason, buildOutcome, lastPhaseReached, then sourceCount/sourcesClean/sourcesWithErrors and sources[] with per-file error and warning counts.",
          "name" : "ek9_query_build_status"
        }, {
          "description" : "Answers first: callerNames / calleeNames and callerSites / calleeSites ('file.ek9:LINE') - then the chain to the requested depth.",
          "idePrecedent" : "Call Hierarchy (IntelliJ)",
          "name" : "ek9_query_call_graph"
        }, {
          "description" : "Answers first: matchCount, then matches[] (name, fullyQualifiedName, module, genus, file, line, column) - workspace-wide; matches:[] when no top-level construct has that name.",
          "idePrecedent" : "Search Everywhere (IntelliJ) / Go to Symbol in Workspace (VSCode)",
          "name" : "ek9_find_constructs_by_name"
        }, {
          "description" : "Answers first: symbolCount, symbolNames, withinNames (Type.method each belongs to), siteCount, byKind, byUse, sites as file.ek9:LINE - then each symbol (kind, within, declaredAt, renameable, counts) with its declared/read/written sites.",
          "idePrecedent" : "Find in Project, symbols mode (EK9 IDE) - no direct IntelliJ / VS Code equivalent: Find Usages starts from ONE symbol",
          "name" : "ek9_find_symbols"
        }, {
          "description" : "Answers first: applicationCount and applications[] (registrations, injectionSites, boundPrograms, health incl.",
          "idePrecedent" : "Spring Bean Graph (IntelliJ Ultimate)",
          "name" : "ek9_query_dependency_injection"
        }, {
          "description" : "Answers first: status, moduleCount, edgeCount, hasCycles, then modules[] {name, files, constructCount}, dependencies[] {from, to, referenceCount, kinds} and metrics (fan-in/out, cycles).",
          "idePrecedent" : "Module Dependencies Analyzer (IntelliJ)",
          "name" : "ek9_query_module_dependencies"
        }, {
          "description" : "Answers first: status, programState, moduleCount, moduleNames, then modules[] {name, band, types, metrics as headroom {rule, limit, value, band, enforced}, cycles} ranked worst-first and summary.",
          "idePrecedent" : "EK9 IDE — \"Module Landscape\" pane (health-coloured module map)",
          "name" : "ek9_query_module_landscape"
        }, {
          "description" : "Answers first: status, programState, edgeCount, then edges[] {from, to, types, weight, shape, sites, inCycle, proposals} ranked worst-first, audit (adHocCoupling, overDeclaredReferences candidates) and summary.",
          "idePrecedent" : "EK9 IDE — module coupling diagram (directed typed edges, ranked worst-first)",
          "name" : "ek9_query_module_coupling"
        }, {
          "description" : "Answers first: status, programState, moduleCount, then modules[] {name, moduleCohesion (E11017 disconnected groups), cohesionRatio, lcom4 (E11014 over-limit constructs)}; symbol:'Type' drills to one construct's LCOM4.",
          "idePrecedent" : "EK9 IDE — module cohesion view (disconnected-group split signal + per-construct LCOM4)",
          "name" : "ek9_query_module_cohesion"
        }, {
          "description" : "Answers first: nodeCount, nodes[] (name, fullyQualifiedName, module, genus, file, line, distance), edges[] (from, to, kind) and edgesByKind - the N-hop typed ego graph merging inheritance, calls, composition, references and DI.",
          "idePrecedent" : "EK9 IDE — construct neighbourhood / blast-radius ego graph around the cursor",
          "name" : "ek9_query_construct_neighbourhood"
        }, {
          "description" : "Answers first: status, change, availableChanges, verdict (ready / would-fail / cascade-too-large / blocked-refuse-to-root), callerNames, calleeNames, then anchor, contract, afferent, efferent axes - the same closure ek9_fix_purity_contract applies.",
          "idePrecedent" : "EK9 IDE — blast-radius impact pane (purity change preview)",
          "name" : "ek9_query_purity_impact"
        }, {
          "description" : "Answers first: anchor and verdicts (parameter → untouched | mutates | escapes | ...",
          "idePrecedent" : "EK9 IDE — construct-neighbourhood pane, data-touch lens (planned)",
          "name" : "ek9_query_data_touch"
        }, {
          "description" : "Answers first: status, summary {bodies, contained, mayEscape, unknown}, findingCount, then findings[] {file, line, inConstruct, payloadType, locks, escape, sites[] with via chain and origin}.",
          "idePrecedent" : "EK9 IDE — concurrency lens (planned); closest external analogue is an escape-analysis or thread-safety inspection",
          "name" : "ek9_query_mutex_payload"
        }, {
          "description" : "Answers first: status, direction (the mutation kind), verdict (ready / would-fail), callerSites, then anchor, contract (root + overrides the change cascades to) and afferent (the call sites ek9_change_signature would rewrite, each fixable or breaks).",
          "idePrecedent" : "EK9 IDE — blast-radius impact (signature change preview, detached window)",
          "name" : "ek9_query_signature_impact"
        }, {
          "description" : "Answers first: hasCycles and cycleCount, then cycles[] (each a closed module path with edges[].via naming the source files) and moduleCount - the whole workspace module graph.",
          "idePrecedent" : "Module Dependency Cycle Detector",
          "name" : "ek9_check_module_cycles"
        }, {
          "description" : "Answers first: direction, rootPackage, rootVersion, then tree{} (dependsOn) or deduplicated[] with broughtInBy (broughtInBy), selections[] and summary - the transitive package dependency tree across the workspace.",
          "idePrecedent" : "mvn dependency:tree / npm ls",
          "name" : "ek9_query_dependency_tree"
        }, {
          "description" : "Answers first: status, then deadlockCount, lockIdentityCount, enterSiteCount, keyBodyCount, crossThreadEdgeCount and nextStep (the one drill-down worth calling); lockIdentityCount 0 = no MutexLock anywhere, deadlock structurally impossible.",
          "idePrecedent" : "Lock Catalogue / Deadlock Detective",
          "name" : "ek9_query_lock_analysis"
        }, {
          "description" : "Answers first: chains[] - per detected lock risk its errorCode, path, outerLock/innerLock and ordered steps[] with file/line/column - chains:[] when nothing is at risk.",
          "idePrecedent" : "Lock Catalogue / Deadlock Detective",
          "name" : "ek9_query_deadlock_chain"
        }, {
          "description" : "Answers first: siteCount, then sites[] (stableId, kind, receiver, lockIdentityIds, location, enclosingFunction) - every lock acquisition, workspace-wide.",
          "idePrecedent" : "Lock Catalogue / Deadlock Detective",
          "name" : "ek9_query_enter_sites"
        }, {
          "description" : "Answers first: status, identityCount, then identities[] {stableId, origin, displayName, originSymbol, originLocation, payload}; stableId joins ek9_query_enter_sites and ek9_query_deadlock_chain.",
          "idePrecedent" : "Lock Catalogue / Deadlock Detective",
          "name" : "ek9_query_lock_identity"
        } ]
      },
      "execution" : {
        "categoryRules" : [ ],
        "description" : "Run code or tooling. Most expensive, most side-effecting; default policy is confirm-on-execute.",
        "tools" : [ {
          "description" : "Compiles the workspace and answers status (ok | failed | found-no-sources | blocked), sourceCount, errorCount, warningCount and diagnostics[] - each with file, line, column, severity, errorCode and message, the ek9_query_diagnostics record - for every discovered .ek9 file.",
          "idePrecedent" : "Build Project (IntelliJ)",
          "name" : "ek9_compile",
          "workflows" : [ "release", "feature_branch_start", "investigate_build_failure" ]
        }, {
          "description" : "Wipes the on-disk .ek9/ artefacts the scope names and resets the server JVM's in-memory coverage/profiling runtimes; answers status:ok with cleanedSources[] listing what was wiped or reset, in order.",
          "idePrecedent" : "Build → Clean (IntelliJ) / mvn clean / cargo clean",
          "name" : "ek9_clean",
          "workflows" : [ "release" ]
        }, {
          "description" : "Compiles and runs the project's @Test programs (auto-forcing -Cd -O0 so coverage probes map to source) and answers status (ok | compile-failed | no-tests-found | tests-failed | coverage-low), tests:{passed, failed}, overallCoverage, results[] per test, plus the inputVariety and hex change-risk blocks.",
          "idePrecedent" : "Run All Tests (IntelliJ) / mvn test / cargo test",
          "name" : "ek9_run_tests",
          "workflows" : [ "release", "quality_check" ]
        }, {
          "description" : "Compiles, runs the tests and answers status (ok | compile-failed | no-tests-found | tests-failed | coverage-low) with tests:{passed, failed}, coverage (overall, methods, lines, branches, byModule), complexity.hotspots[], readability, injections, uncoveredMethods[] and the advisory lockPayloads - every quality metric in one call, extracted in-process.",
          "idePrecedent" : "SonarQube dashboard / cargo-tarpaulin / istanbul coverage",
          "name" : "ek9_run_quality_checks",
          "workflows" : [ "release", "quality_check" ]
        }, {
          "description" : "Writes a compile-checked edge-case @Test program file for one .ek9 source and answers status (applied | ready | unchanged | blocked | error), written, testCount, the echoed seed and modifiedFiles[] - every harvested constructor, method, operator and function gets the tri-state UNSET value among its inputs.",
          "idePrecedent" : "Hypothesis (Python) / fast-check (JS) / QuickCheck (Haskell)",
          "name" : "ek9_generate_edge_case_tests",
          "rules" : [ "Generated tests are liveness / edge-case SMOKE tests — they exercise edge + always-unset inputs and assert set-ness / no-crash, NOT business correctness. Read a green result as 'survives edge inputs', not 'behaviour verified'.", "Compile-surviving does NOT mean passing: some generated tests legitimately fail (e.g. asserting on an unset-input result). The flow is generate -> review / curate -> ek9_run_tests, not generate -> trust.", "The output is SCAFFOLDING. Every //AI: assertion is an expectation YOU must set from the REQUIREMENT the code is meant to satisfy — never from what the code currently returns. Do NOT run the tests and keep whichever assertion is green: that codes the test to the implementation and cements existing bugs as passing. A RED test is this tool working — decide whether the expectation or the code is wrong. Where the project tracks requirements, ek9_query_requirement / ek9_check_requirements is where the expectation should come from.", "Capture the echoed seed to regenerate the exact same survivor set after a source edit.", "If status is no-testable-symbols the source compiled but exposes nothing public to test — move on or widen the API surface." ]
        }, {
          "description" : "Reports branch and gitignoreCreated (a .gitignore for the generated .ek9/ directory is scaffolded when absent); refuses when already a repository.",
          "idePrecedent" : "git init / Enable Version Control Integration",
          "name" : "ek9_git_init",
          "rules" : [ "The only git tool valid OUTSIDE a repo. Refuses when already one. After init there are no commits yet - ek9_git_add all:true then ek9_git_commit." ]
        }, {
          "description" : "Reports stagedPaths and stagedPathCount (what this call staged), then indexAfter and indexAfterCount (everything now staged) and a summary line.",
          "idePrecedent" : "git add / Stage Changes",
          "name" : "ek9_git_add",
          "rules" : [ "Stage before ek9_git_commit, or let ek9_git_commit paths:[...] do both. indexAfter is what the next commit will record." ]
        }, {
          "description" : "Reports newSha and previousSha, branch, subject, changedFiles and changedFileCount; local history only, nothing is published until ek9_git_push.",
          "idePrecedent" : "git commit / Commit",
          "name" : "ek9_git_commit",
          "rules" : [ "Stage first (ek9_git_add) or pass paths / all:true. Local history only - run ek9_git_push to publish. nothing-to-commit means the index is clean." ]
        }, {
          "description" : "Reports remote, branch, upstream, upToDate and a summary line, with git's own report under gitReport; outward-facing and not trivially reversible, so confirm intent first.",
          "idePrecedent" : "git push / Push",
          "name" : "ek9_git_push",
          "rules" : [ "Push PUBLISHES and is not trivially reversible - confirm intent before calling. setUpstream:true on the first push of a new branch." ]
        }, {
          "description" : "Reports status (switched or created), branch and previousBranch; a dirty tree that would be overwritten is refused with the route (commit, stash or restore first), never auto-stashed.",
          "idePrecedent" : "git switch / Checkout Branch",
          "name" : "ek9_git_switch",
          "rules" : [ "Switch to an existing branch, or create:true to branch from HEAD (or ref) and switch. Branch BEFORE committing onto the default branch. A refusal names its route in nextStep - this tool never auto-stashes." ]
        }, {
          "description" : "Reports status and outcome (already-up-to-date, fast-forward, clean-merge or conflict), newSha/previousSha, commitsMerged, changedFiles and conflictFiles; a conflicting merge aborts with the tree restored.",
          "idePrecedent" : "git merge / Merge Branch",
          "name" : "ek9_git_merge",
          "rules" : [ "Merges a LOCAL branch (the remote is ek9_git_pull mode:'merge'). Requires a clean tree; a conflicting merge auto-aborts and restores it, so run dryRun:true first and resolve conflicts on a branch." ]
        }, {
          "description" : "Reports mode, paths and pathCount and a summary line; ref restores content from that commit instead of the index or HEAD.",
          "idePrecedent" : "git restore / Revert / Unstage",
          "name" : "ek9_git_restore",
          "rules" : [ "Unstage with mode:'unstage' (safe - working tree untouched). Discard working-tree edits with mode:'discard' (DESTRUCTIVE, uncommitted changes are lost). The inverse of ek9_git_add." ]
        }, {
          "description" : "Reports newSha, revertedSha, previousSha, branch, subject, changedFiles and changedFileCount; a conflicting revert aborts with the tree restored.",
          "idePrecedent" : "git revert / Revert Commit",
          "name" : "ek9_git_revert",
          "rules" : [ "Revert is the push-safe undo: a NEW inverse commit, no history rewrite. On a conflict it auto-aborts and restores the tree - resolve by hand. To revert a merge commit pass mainline." ]
        }, {
          "description" : "Reports updated, upstream, behind and ahead, a summary line and a nextStep when behind; git's own report under gitReport.",
          "idePrecedent" : "git fetch / Fetch",
          "name" : "ek9_git_fetch",
          "rules" : [ "Fetch never touches the working tree - it is the 'how far behind am I?' check. behind > 0 means ek9_git_pull has work to do." ]
        }, {
          "description" : "Reports commitsPulled, newSha and previousSha, changedFiles and changedFileCount; a dirty tree is refused and a rebase/merge conflict is aborted with the tree restored.",
          "idePrecedent" : "git pull / Update Project",
          "name" : "ek9_git_pull",
          "rules" : [ "Default mode:'ff-only' cannot conflict; on divergence it is refused and you choose mode:'rebase' or mode:'merge'. Requires a clean tree; conflicts auto-abort and restore it." ]
        }, {
          "description" : "Reports status (stashed, popped, applied, dropped or nothing-to-stash) and the stash ref; mode:'list' returns stashCount and stashes; a conflicting pop keeps the entry (stashPreserved:true).",
          "idePrecedent" : "git stash / Stash Changes",
          "name" : "ek9_git_stash",
          "rules" : [ "Explicit stash only, never auto-stash. A conflicting pop/apply PRESERVES the entry (stashPreserved:true) - resolve by hand and retry." ]
        }, {
          "description" : "Answers with bundlePath and checksumPath after assembling the publishable SOURCE bundle (.ek9 files + manifest + capabilities + lockfile, not bytecode) of one package.",
          "idePrecedent" : "mvn package / cargo build --release / npm pack",
          "name" : "ek9_package",
          "workflows" : [ "release" ]
        }, {
          "description" : "Answers with installedTo (under ~/.ek9/lib) and bundlePath after packaging one package and installing its SOURCE bundle into the LOCAL library cache - not a remote registry push.",
          "idePrecedent" : "mvn install / cargo install / npm install",
          "name" : "ek9_install_package",
          "workflows" : [ "release" ]
        }, {
          "description" : "Answers with status and bundlePath after publishing one package's SOURCE bundle to the configured remote registry; packages and generates missing signing keys first.",
          "idePrecedent" : "mvn deploy / cargo publish / npm publish",
          "name" : "ek9_deploy_package",
          "workflows" : [ "release" ]
        }, {
          "description" : "Answers with keysGenerated and publicKeyPath after ensuring the user-global signing keypair (~/.ek9/private.pem + public.pem) that ek9_deploy_package signs with exists; an existing pair is never overwritten.",
          "idePrecedent" : "gpg --gen-key / ssh-keygen",
          "name" : "ek9_generate_signing_keys"
        }, {
          "description" : "Answers with the new version and previousVersion after setting the 'defines package' version literal to an explicit MAJOR.MINOR.PATCH (build restarts at 0), plus written and line.",
          "idePrecedent" : "mvn versions:set / npm version <new>",
          "name" : "ek9_set_version"
        }, {
          "description" : "Answers with the new version and previousVersion after setting the 'defines package' version literal to MAJOR.MINOR.PATCH-feature (build restarts at 0), plus written and line.",
          "idePrecedent" : "mvn versions:set with classifier",
          "name" : "ek9_set_feature_version"
        }, {
          "description" : "Answers with the new version and previousVersion after bumping one component of the 'defines package' version literal, plus written and line.",
          "idePrecedent" : "npm version patch / mvn versions:set",
          "name" : "ek9_increment_version",
          "workflows" : [ "release" ]
        }, {
          "description" : "Answers with status after fetching one package's declared dependency tree (ek9 -Dp), which cleans all build artefacts and the local dependency cache first.",
          "idePrecedent" : "mvn dependency:resolve / cargo fetch / npm install (resolve)",
          "name" : "ek9_resolve_dependencies",
          "workflows" : [ "release" ]
        }, {
          "description" : "Answers with programStdout, programStderr and programExitCode after compiling one .ek9 file and running the program it declares, with string args auto-parsed into the program's typed parameters; exitedBy says whether an exit code is the program's own or the EK9 CLI's.",
          "idePrecedent" : "Run (IntelliJ) / cargo run / java -jar",
          "name" : "ek9_run_program"
        }, {
          "description" : "Runs a program under the debugger - several inputs at once with a change journal (sweep), one run to its end, or step by step - and reports, waits on or ends THE debug session (one per server); answers status, runState, sequence, the stops, breakpoints and nextStep.",
          "idePrecedent" : "Debug (IntelliJ) / VS Code launch.json / gdb run",
          "name" : "ek9_debug_session",
          "workflows" : [ "investigate_runtime_defect" ]
        }, {
          "description" : "Continues, pauses, steps or sets breakpoints in the current debug session; answers its new runState, sequence and stops.",
          "idePrecedent" : "Resume / Pause / Step Over / Step Into / Step Out / Toggle Breakpoint (IntelliJ)",
          "name" : "ek9_debug_control"
        }, {
          "description" : "Reads what runs recorded - a failure's account, where a value first went wrong, failing and passing runs compared, a report to share - and the current debug session by field (the recorded stop, a frame's locals, path values, the threads), never running the debuggee.",
          "idePrecedent" : "Variables / Watches / Frames / Threads panes (IntelliJ)",
          "name" : "ek9_debug_inspect",
          "workflows" : [ "investigate_runtime_defect" ]
        }, {
          "description" : "Runs the current debug session until a condition holds or the budget bites, reading the watched paths at every hit of the given lines; answers stoppedBecause, exact hits and the rows.",
          "idePrecedent" : "Logpoints / tracepoints (IntelliJ, VS Code) with a stop condition",
          "name" : "ek9_debug_observe"
        } ]
      }
    },
    "compilerVersion" : "0.0.1-0",
    "meta" : {
      "serverMs" : "<timing>"
    },
    "status" : "ok",
    "toolCount" : 181,
    "version" : "1.0",
    "workflows" : [ {
      "name" : "release",
      "sequence" : [ {
        "reason" : "Bump the appropriate version part (typically patch after a fix).",
        "tool" : "ek9_increment_version"
      }, {
        "reason" : "Verify nothing regressed; produces the coverage report as a side effect.",
        "tool" : "ek9_run_tests"
      }, {
        "reason" : "Run full quality checks — coverage, complexity, readability, DI — to confirm nothing has degraded since the last release.",
        "tool" : "ek9_run_quality_checks"
      }, {
        "reason" : "Build the deployable artefact at the new version.",
        "tool" : "ek9_package"
      }, {
        "reason" : "Install into ~/.ek9/lib so sibling workspaces can pick it up.",
        "tool" : "ek9_install_package"
      }, {
        "reason" : "Verify the installed version matches what was bumped.",
        "tool" : "ek9_query_package_version"
      } ],
      "summary" : "Bump version + run tests with coverage + build artefact + install locally + verify."
    }, {
      "name" : "feature_branch_start",
      "sequence" : [ {
        "reason" : "Mark the package as on a feature branch (e.g. 2.1.0-PAYINTEG-0).",
        "tool" : "ek9_set_feature_version"
      }, {
        "reason" : "Declare each new package dependency the feature requires.",
        "tool" : "ek9_add_dependency"
      }, {
        "reason" : "Pull the new dependencies into ~/.ek9/lib.",
        "tool" : "ek9_resolve_dependencies"
      }, {
        "reason" : "Verify the package still compiles with the new deps.",
        "tool" : "ek9_compile"
      }, {
        "reason" : "Verify existing tests still pass before any feature work begins.",
        "tool" : "ek9_run_tests"
      } ],
      "summary" : "Set feature-branch version + add new dependencies + resolve + verify."
    }, {
      "name" : "investigate_build_failure",
      "sequence" : [ {
        "reason" : "Read the specific compiler/resolver error messages.",
        "tool" : "ek9_query_diagnostics"
      }, {
        "reason" : "See the resolved tree with version selections and any rejection reasons.",
        "tool" : "ek9_query_dependency_tree"
      }, {
        "reason" : "Rule out a transitive cycle in the published-package graph.",
        "tool" : "ek9_check_package_dependency_cycles"
      }, {
        "reason" : "Re-resolve after any fix to the package directive.",
        "tool" : "ek9_resolve_dependencies"
      }, {
        "reason" : "Confirm the build now succeeds.",
        "tool" : "ek9_compile"
      } ],
      "summary" : "Diagnose dependency-resolution or compilation failure: diagnostics → tree → cycles → fix → re-resolve."
    }, {
      "name" : "investigate_runtime_defect",
      "sequence" : [ {
        "reason" : "{action:'launch', run:'toEnd', args:<the failing input>}: reproduce the failure once - its message usually names the value that went wrong (a Panic on 'require total >= NOTHING' in Order.invoice -> watch Order.total).",
        "tool" : "ek9_debug_session"
      }, {
        "reason" : "{action:'sweep', inputs:[...], journal:{property:'Type.property', hypothesis}}: one run per input set, all with ONE seed. Include inputs you expect to PASS as well as the failing one - compare needs both; every change to the value, on every object, is recorded. Its answer already carries compare's top differences, and the investigation id.",
        "tool" : "ek9_debug_session"
      }, {
        "reason" : "{action:'compare', runs, hypothesis}: what only the failing runs did - a step they took, a step they LEFT OUT (onlyInPassing), or none (then the values differ). A tie or thin evidence means more inputs, not a verdict. Cite each difference by its run and ticks.",
        "tool" : "ek9_debug_inspect"
      }, {
        "reason" : "{action:'leadingTo', runId:<a failing run>, hypothesis}: the account - the changes that led to its failure, each with the line, the values and the calls that made it. Cite ticks for every claim.",
        "tool" : "ek9_debug_inspect"
      }, {
        "reason" : "{action:'firstWhere', runId, condition:'total < 0', hypothesis}: the step where the value first went wrong - usually the line to fix.",
        "tool" : "ek9_debug_inspect"
      }, {
        "reason" : "{action:'launch', run:'toEnd', seed:<the sweep's>, args:<one input changed>, journal}: confirm the suspect - the same run with only the suspect's input changed should pass. Without this, a difference is a suspect, not a cause.",
        "tool" : "ek9_debug_session"
      }, {
        "reason" : "{action:'report', runs, hypothesis, finding:'cause and fix, citing t5 and Orders.ek9:36'}: write the investigation up for the person (index.html, report.json); the finding is shown as yours.",
        "tool" : "ek9_debug_inspect"
      } ],
      "summary" : "A runtime failure whose cause is earlier: journal the value over failing AND passing runs -> compare -> leadingTo -> firstWhere -> confirm with one input changed -> report with a finding."
    } ]
  },
  "scenario" : "catalogue_slim_shape",
  "tool" : "query_tool_catalogue"
}
