ceulen 0.27.0 → 0.28.1

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,104 @@
1
1
  # Changelog
2
+ ## 0.28.1 — 2026-11-18
3
+
4
+ **Serena actually works, and models actually reach for it.** Two independent
5
+ faults sat behind "serena tools are never used": the module was never able to
6
+ run on serena-agent 2.x, and its tools were unreachable in practice.
7
+
8
+ - **serena-agent 2.x compatibility** (probed live against 2.1.0; the bridge was
9
+ written for 1.2.x, so every path below failed). `LanguageBackend.from_str` is
10
+ gone — resolution moved to `LanguageBackendRegistry.get_instance().resolve`;
11
+ `resolve_language_backend` accepts both, and an invalid
12
+ `SERENA_LANGUAGE_BACKEND` now reports the offending value plus the valid keys
13
+ instead of an opaque `AttributeError`. New configs default to the **REPL**
14
+ agent interface (one `serena_repl` tool), which broke every
15
+ `get_tool_by_name(...).apply_ex(...)` call with "Tool 'x' is not active" —
16
+ `load_bridge_config` now forces `AgentInterface.TOOLS`. The
17
+ `LanguageServerSymbolRetriever` must be built inside `agent.execute_task` or
18
+ it raises "language server manager is not initialized". And
19
+ `check_onboarding_performed` was DELETED upstream, so that worker action
20
+ derives the answer from the `memory_maintenance` memory instead.
21
+ `serena_status`/`serena_list_tools` no longer crash on the missing enum
22
+ `.value`.
23
+ - **Navigation tier promoted to direct.** The seven navigation tools
24
+ (`get_symbols_overview`, `find_symbol`, `find_referencing_symbols`,
25
+ `find_declaration`, `find_implementations`, `search_for_pattern`,
26
+ `get_diagnostics_for_file`) are declared from request #1; the editing tail
27
+ and ops helpers stay deferred. Across 56 recorded sessions the `tool_search`
28
+ gate was crossed 8 times and `serena_*` invoked **once** — and Serena-first
29
+ runs BEFORE read/grep, so the tools it replaces can never be the discovery
30
+ trigger. `SERENA_FIRST_GUIDANCE` no longer tells the model to go load them
31
+ (it claimed the tier was deferred long after that stopped being the
32
+ workaround); a test pins the wording and `registry.test.ts` guards the tier
33
+ split.
34
+
35
+ Verified in fresh sessions: 37 declared tools including exactly the 7, deferred
36
+ tail still loadable via `tool_search`, guidance injected without the
37
+ tool_search instruction, and unprompted behavior calling `serena_find_symbol`
38
+ then `serena_find_referencing_symbols`. Bridge actions 10/10 pass end-to-end
39
+ through the real `SerenaWorkerClient`; `tsc --noEmit` clean; `npm test`
40
+ **3020 pass / 0 fail / 3 env-gated skips**.
41
+
42
+
43
+ ## 0.28.0 — 2026-11-18
44
+
45
+ **Rex is now a first-class subagent delegation backend.** ceulen's visible-pane
46
+ delegation knew the herdr TUI (`HERDR_ENV`) and the Herdr desktop app
47
+ (`HC_TERMINAL_ID`, herdr-app + `hc`) — inside **Rex** (the `rex` CLI + server,
48
+ `REX_SESSION`) every dispatch silently fell back to the in-process SDK runner
49
+ and the `herdr` control tool refused to run at all. New
50
+ `subagent/lib/rex.ts` plus a runner/control-tool rewire fixes that: one WINDOW
51
+ per agent type (`rex window new`, adopted when already labelled), one PANE per
52
+ instance (`rex split` beside the window's last tiled block), the child pi
53
+ started by the block's command with the same persona/model/thinking/tools
54
+ contract, and reports through the same file/inline delivery contract.
55
+
56
+ - **Auto-detection, no new settings.** `REX_SESSION` plus a `rex` binary that
57
+ answers `rex version` (Rex has no `--version`) selects the backend.
58
+ Resolution order is herdr TUI → rex → herdr-app → sdk, and an explicit
59
+ `runner:"herdr"` still keeps its "not running inside herdr" error instead of
60
+ silently re-routing. `subagent.herdr:"off"` and the `PI_SUBAGENT_HERDR=off`
61
+ child guard disable delegation on all three backends.
62
+ - **No turn-following primitive, so the turn proof is a timestamp.** `rex wait`
63
+ waits for a block to EXIT, which is useless for a long-lived pi, so
64
+ `promptRexAndWait` is built from `program_status` polling (OSC 7501, which pi
65
+ publishes): readiness gate → `block send` + `block send-key enter` → poll.
66
+ With no turn counter, a settle is accepted only when the ROOT status record's
67
+ `updated_at` moved past the pre-paste baseline (or the child was seen
68
+ working), so a paste that never submitted reports "pasted but never
69
+ submitted" instead of being collected as a success.
70
+ - **`format` answers a head slice.** Any reply carrying a blob `id` is re-read
71
+ from `total - N` via `blob_read`; asking for the whole scrollback would park
72
+ megabytes in the parent's context, and trusting the head silently returned
73
+ boot chrome instead of the child's reply (found live while gating this
74
+ release).
75
+ - **Rex children DO get environment variables** by way of a `/usr/bin/env`
76
+ command wrapper — unlike herdr-app — so they carry the advisor review marker
77
+ (the parent waits for the child's own advisor before collecting) *and* the
78
+ `PI_SUBAGENT_HERDR=off` recursion guard plus `CEULEN_THINK_GATE_OFF=1`.
79
+ - **Echo is never a report.** A pane capture is cut to the text after the
80
+ delivery contract (falling back to the task echo), and an echo-only pane
81
+ yields no output, so the dispatch fails loudly.
82
+ - **Full control surface, scoped.** The `herdr` tool gained a rex branch for
83
+ list/status/read/prompt/cancel/focus/close-tab/forget. Mutating actions only
84
+ touch agents this session delegated, `close-tab` closes the rex WINDOW and
85
+ refuses while a sibling is busy or its state is unverifiable, and adopted
86
+ windows (label match) are never close-eligible. `RunnerKind`,
87
+ `SubagentDetails.runner` and the widget's pane-label gate all carry `rex`.
88
+ - **CLI quirks encoded, each with a regression test:** `rex block call` takes
89
+ SHORT method names (the fully-qualified name is rejected), and
90
+ `rex session inspect` takes the session POSITIONALLY and rejects the global
91
+ `-s` prefix (the prefixed form made every window adoption fail with "window
92
+ has no block to split beside").
93
+
94
+ Verified: `tsc --noEmit` clean; full `npm test` **3019 pass / 0 fail / 3
95
+ env-gated skips** (32 of them in the new `test/rex.test.ts`); `npm pack
96
+ --dry-run` ships `lib/rex.ts` + its suite. Live-verified against a running Rex
97
+ server: single dispatch, window adoption, write-capable report-file agents,
98
+ parallel (multi-agent-type) and chain (`{previous}`) modes, read-only inline
99
+ collection, the full `herdr` control surface (including the busy-sibling
100
+ refusal and stale-entry `forget`), `runner:"sdk"` pinning, and
101
+ `background:true` correctly staying in-process with an honest receipt.
2
102
 
3
103
  ## 0.27.0 — 2026-11-17
4
104
 
@@ -61,6 +61,25 @@ describe("deferredTools tiers", () => {
61
61
  assert.equal(allDeferred.has(hot), false, `${hot} must stay direct`);
62
62
  }
63
63
  });
64
+
65
+ // 2026-11-18 usage re-eval: the seven serena navigation tools were promoted
66
+ // direct — 56 sessions crossed the tool_search gate 8 times and invoked
67
+ // serena_* ONCE. Serena-first navigation runs BEFORE read/grep, so the tools
68
+ // it replaces can never surface it. A registry edit reverting this must fail.
69
+ it("keeps serena's navigation tools direct, its editing tail deferred", async () => {
70
+ const { MODULES } = await import("./registry.js");
71
+ const allDeferred = new Set(MODULES.flatMap((m) => m.deferredTools ?? []));
72
+ for (const nav of [
73
+ "serena_get_symbols_overview", "serena_find_symbol", "serena_find_referencing_symbols",
74
+ "serena_find_declaration", "serena_find_implementations",
75
+ "serena_search_for_pattern", "serena_get_diagnostics_for_file",
76
+ ]) {
77
+ assert.equal(allDeferred.has(nav), false, `${nav} must stay direct`);
78
+ }
79
+ for (const cold of ["serena_rename_symbol", "serena_replace_symbol_body", "serena_onboarding"]) {
80
+ assert.equal(allDeferred.has(cold), true, `${cold} stays deferred`);
81
+ }
82
+ });
64
83
  });
65
84
 
66
85
  describe("MODULES load order", () => {
@@ -152,7 +152,7 @@ export const MODULES: ModuleEntry[] = [
152
152
  // Subagent after ponytail: ponytail's tool_call hook injects into the
153
153
  // `subagent` tool's instructions param — hooks resolve at call time, so
154
154
  // order is not load-bearing; this is grouping readability.
155
- { name: "subagent", category: "Tasks", describe: "In-process subagents: scout/tester/worker/planner/reviewer agents, role-based model pools, classifier tier+thinking routing, background tasks with liveness, herdr delegation.", load: subagentModule, config: subagentConfig },
155
+ { name: "subagent", category: "Tasks", describe: "In-process subagents: scout/tester/worker/planner/reviewer agents, role-based model pools, classifier tier+thinking routing, background tasks with liveness, herdr/rex pane delegation.", load: subagentModule, config: subagentConfig },
156
156
  // Plan after subagent: its tool gating reads subagent agent frontmatter
157
157
  // (sandbox: read-only) and its before_agent_start must compose BEFORE
158
158
  // steering (the last prompt rewriter — see its entry below).
@@ -176,13 +176,20 @@ export const MODULES: ModuleEntry[] = [
176
176
  // on top (no load-order dependency — hooks resolve at call time).
177
177
  { name: "repair", category: "Tools", describe: "Tool-call hardening: schema argument repair, edit mismatch retry, destructive-command guard. Wraps the built-in tools once; adds apply_patch + str_replace_editor.", load: repairModule, config: repairConfig },
178
178
  { name: "serena", category: "Tools", describe: "Serena semantic code tools via a persistent Python worker.", load: serenaModule, deferredTools: [
179
- "serena_status", "serena_list_tools", "serena_get_symbols_overview", "serena_find_symbol",
180
- "serena_find_referencing_symbols", "serena_find_declaration", "serena_find_implementations",
179
+ // The 2026-11-18 usage re-eval promoted the SEVEN navigation tools direct
180
+ // (same rationale as ux_audit/github/munin_search on 2026-10-08): a
181
+ // deferred tier is only reachable by asking tool_search about a tool you
182
+ // have not seen, and across 56 sessions that gate was crossed 8 times —
183
+ // serena_* was invoked ONCE (a failing status probe). Serena-first
184
+ // navigation must happen BEFORE read/grep, so the tools it replaces can
185
+ // never be the discovery trigger. Cost: ~1.1k tokens/request for the 7.
186
+ // The editing tail + ops stay cold; they are reached AFTER a symbol is
187
+ // already known, where tool_search is a natural step.
188
+ "serena_status", "serena_list_tools",
181
189
  "serena_replace_symbol_body", "serena_insert_before_symbol", "serena_insert_after_symbol",
182
- "serena_rename_symbol", "serena_safe_delete_symbol", "serena_search_for_pattern",
190
+ "serena_rename_symbol", "serena_safe_delete_symbol",
183
191
  "serena_replace_content", "serena_restart_language_server", "serena_restart_worker",
184
192
  "serena_get_current_config", "serena_check_onboarding_performed", "serena_onboarding",
185
- "serena_get_diagnostics_for_file",
186
193
  ] },
187
194
  { name: "fff", category: "Tools", describe: "FFF fuzzy file/content search (ffgrep, fffind) + @-mention completions.", load: fffModule, deferredTools: [
188
195
  "fff_multi_grep", "resolve_file", "related_files",
@@ -1,16 +1,17 @@
1
1
  import { commandLooksLikeSemanticCodeSearch, pathLooksLikeCode, pathLooksNonSemantic } from "./detect";
2
2
 
3
- export const SERENA_FIRST_GUIDANCE = "Serena-first code navigation: before reading whole code files for code navigation, call Serena first (serena tools are deferred — if not yet declared, load them with one tool_search call for \"serena\"). For named source files, start with serena_get_symbols_overview(relative_path=...). For named functions/classes/methods/variables, use serena_find_symbol. Use serena_find_referencing_symbols before behavior changes or renames, and serena_find_declaration / serena_find_implementations for definitions, interfaces, and implementations. Use read/grep/find for docs, configs, non-code files, exact text checks, or narrow code ranges after Serena identifies the target.";
3
+ export const SERENA_FIRST_GUIDANCE = "Serena-first code navigation: before reading whole code files for code navigation, call Serena first — its navigation tools are declared. For named source files, start with serena_get_symbols_overview(relative_path=...). For named functions/classes/methods/variables, use serena_find_symbol. Use serena_find_referencing_symbols before behavior changes or renames, and serena_find_declaration / serena_find_implementations for definitions, interfaces, and implementations. Use read/grep/find for docs, configs, non-code files, exact text checks, or narrow code ranges after Serena identifies the target.";
4
4
 
5
5
  export const SERENA_MISS_GUIDANCE = "Use serena_get_symbols_overview for source-file outlines or serena_find_symbol for named symbols before reading/searching code. Use read after Serena identifies the relevant region, or for docs/config/non-code files.";
6
6
 
7
7
  /**
8
8
  * Is Serena's tool surface actually usable in this session? Serena tools
9
- * register DEFERRED (registry deferredTools) — they load on the first
10
- * tool_search call and stay declared for the rest of the session. Active
11
- * `serena_find_symbol` means loaded; active `tool_search` means one search
12
- * away. Exported pure predicate so the hook and its tests share one
13
- * definition.
9
+ * The seven NAVIGATION tools register DIRECT (2026-11-18 usage re-eval) so
10
+ * they are declared from request #1; the editing tail stays deferred and
11
+ * loads on a tool_search call. Active `serena_find_symbol` means the direct
12
+ * tier is live; active `tool_search` means one search away (the pre-2026-11-18
13
+ * state, still honored for a plan-mode/older-server session). Exported pure
14
+ * predicate so the hook and its tests share one definition.
14
15
  */
15
16
  export function isSerenaActive(activeTools: readonly string[] | undefined): boolean {
16
17
  if (!Array.isArray(activeTools)) return false;
@@ -47,6 +47,9 @@ describe("Serena tool-selection guidance", () => {
47
47
  assert.ok((guidance).includes("serena_get_symbols_overview"));
48
48
  assert.ok((guidance).includes("serena_find_symbol"));
49
49
  assert.ok((guidance).includes("Use read/grep/find for docs, configs, non-code files"));
50
+ // 2026-11-18: the navigation tier is direct, so the guidance must not tell
51
+ // the model to go load it (that wording survived a deferred→direct move).
52
+ assert.ok(!guidance.includes("tool_search"), "navigation tier is declared, not search-gated");
50
53
  });
51
54
 
52
55
  it("detects strict-mode semantic misses for code reads and code searches", () => {
@@ -66,11 +66,29 @@ os.environ.setdefault("SERENA_USAGE_REPORTING", "false")
66
66
  try:
67
67
  from serena.agent import SerenaAgent
68
68
  from serena.config.context_mode import SerenaAgentContext
69
- from serena.config.serena_config import SerenaConfig, LanguageBackend
69
+ from serena.config.serena_config import AgentInterface, SerenaConfig, LanguageBackend
70
70
  except Exception as exc:
71
71
  print(json.dumps({"id": None, "ok": False, "error": f"Failed to import Serena: {type(exc).__name__}: {exc}"}), flush=True)
72
72
  raise
73
73
 
74
+ try:
75
+ from serena.language_backend import LanguageBackendRegistry
76
+ except Exception:
77
+ LanguageBackendRegistry = None # type: ignore
78
+
79
+
80
+ def resolve_language_backend(name: str) -> Any:
81
+ """Resolve a SERENA_LANGUAGE_BACKEND value to a backend instance.
82
+
83
+ serena-agent 2.x resolves through LanguageBackendRegistry; 1.2.x exposed
84
+ LanguageBackend.from_str. Accept both so a pinned older venv keeps working,
85
+ and let the failure surface (never silently fall back to LSP) — an
86
+ intentionally configured backend must not degrade without a word.
87
+ """
88
+ if LanguageBackendRegistry is not None:
89
+ return LanguageBackendRegistry.get_instance().resolve(name)
90
+ return LanguageBackend.from_str(name)
91
+
74
92
  try:
75
93
  from serena import serena_version
76
94
  except Exception:
@@ -108,11 +126,20 @@ def load_bridge_config() -> SerenaConfig:
108
126
  config.web_dashboard = env_flag("SERENA_BRIDGE_WEB_DASHBOARD", True)
109
127
  config.web_dashboard_open_on_launch = env_flag("SERENA_BRIDGE_OPEN_DASHBOARD", False)
110
128
  # SERENA_LANGUAGE_BACKEND selects the code-intelligence backend at worker startup.
111
- # Unset = Serena's default (LSP). Invalid values raise LanguageBackend.from_str's
112
- # ValueError, surfaced on worker start rather than silently falling back.
129
+ # Unset = Serena's default (LSP). Invalid values raise the registry's ValueError,
130
+ # surfaced on worker start rather than silently falling back.
131
+ # serena-agent 2.x moved backend resolution onto the registry; the 1.2.x
132
+ # LanguageBackend.from_str static is GONE (live 2026-11-18 against 2.1.0).
113
133
  backend = os.environ.get("SERENA_LANGUAGE_BACKEND")
114
134
  if backend:
115
- config.language_backend = LanguageBackend.from_str(backend)
135
+ config.language_backend = resolve_language_backend(backend)
136
+ # serena-agent 2.x defaults NEW configs to the REPL agent interface, which
137
+ # exposes one serena_repl tool instead of the classic per-tool surface this
138
+ # bridge drives (get_tool_by_name + apply_ex). Force TOOLS: the pi-facing
139
+ # tool contract is per-operation, and a REPL-only agent fails every call
140
+ # with "Tool '<name>' is not active". Live-probed 2026-11-18 on 2.1.0.
141
+ # A project.yml agent_interface still wins (determine_agent_interface).
142
+ config.agent_interface = AgentInterface.TOOLS
116
143
  return config
117
144
 
118
145
 
@@ -209,7 +236,10 @@ def handle(req: dict[str, Any]) -> dict[str, Any]:
209
236
  data["activeTools"] = agent.get_active_tool_names()
210
237
  active_project = agent.get_active_project()
211
238
  data["activeProject"] = str(active_project.project_root) if active_project else None
212
- data["languageBackend"] = agent.get_language_backend().value
239
+ # serena-agent 2.x returns a LanguageBackend instance whose key is
240
+ # str(backend)/get_key(); the 1.2.x enum's .value is gone.
241
+ backend_obj = agent.get_language_backend()
242
+ data["languageBackend"] = getattr(backend_obj, "value", None) or str(backend_obj)
213
243
  data["dashboardUrl"] = agent.get_dashboard_url()
214
244
  return data
215
245
 
@@ -268,6 +298,27 @@ def handle(req: dict[str, Any]) -> dict[str, Any]:
268
298
  if action in ("find_declaration", "find_implementations"):
269
299
  return _handle_find_symbol_action(req_id, action, req)
270
300
 
301
+ if action == "check_onboarding_performed":
302
+ # serena-agent 2.x DELETED the check_onboarding_performed tool (listed in
303
+ # ToolRegistry._deleted_tools). Derive the same answer from the project's
304
+ # memory list: onboarding counts as done once the memory_maintenance
305
+ # memory exists — that is the file serena init / onboarding seeds.
306
+ project = str(req.get("project") or os.getcwd())
307
+ context = str(req.get("context") or "ide")
308
+ try:
309
+ project_obj = get_agent(project, context).get_active_project_or_raise()
310
+ names = project_obj.memory_manager.list_project_memories().get_full_list()
311
+ except Exception as exc:
312
+ return {"id": req_id, "ok": False, "tool": "check_onboarding_performed", "errorType": "project_error", "error": f"{type(exc).__name__}: {exc}"}
313
+ performed = any(str(n).split("/")[-1] == "memory_maintenance" for n in names)
314
+ return {
315
+ "id": req_id,
316
+ "ok": True,
317
+ "tool": "check_onboarding_performed",
318
+ "performed": performed,
319
+ "result": json.dumps({"onboarding_performed": performed, "memories": names}),
320
+ }
321
+
271
322
  if action == "get_diagnostics_for_file":
272
323
  return _handle_diagnostics(req_id, req)
273
324
 
@@ -275,9 +326,20 @@ def handle(req: dict[str, Any]) -> dict[str, Any]:
275
326
 
276
327
 
277
328
  def _get_symbol_retriever(agent: SerenaAgent):
329
+ """Return (project, retriever) for the active project.
330
+
331
+ The retriever's constructor reaches for the language server manager, which
332
+ Serena only exposes inside its own task context (execute_task). Calling
333
+ it directly raises "The language server manager is not initialized" — live
334
+ against serena-agent 2.1.0, 2026-11-18.
335
+ """
278
336
  from serena.symbol import LanguageServerSymbolRetriever
279
- project = agent.get_active_project_or_raise()
280
- return project, LanguageServerSymbolRetriever(project)
337
+
338
+ def build():
339
+ project = agent.get_active_project_or_raise()
340
+ return project, LanguageServerSymbolRetriever(project)
341
+
342
+ return agent.execute_task(build, name="get_symbol_retriever")
281
343
 
282
344
 
283
345
  def _jb_declaration_regexes(name_path: str) -> list[str]: