Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(context): add the skeleton+ view: every signature with its lines and all non-function code (#3097)

Raghav Chamadiya4d49c89cca94
diff --git a/docs/reference/CONFIG.md b/docs/reference/CONFIG.md
index f1fd9d1c8..f17393872 100644
--- a/docs/reference/CONFIG.md
+++ b/docs/reference/CONFIG.md
@@ -317,6 +317,7 @@ means every key below is off.
```yaml
hooks:
read_skeleton: false # serve large indexed files as skeletons
+ read_skeleton_mode: smart # smart, or plus to keep all non-function code
read_reread: false # serve unchanged re-reads as a pointer
search_digest: false # serve multi-file grep floods as a digest
coverage_reingest: false # re-ingest coverage after an agent's full test run
@@ -348,6 +349,10 @@ hooks:
markers carrying 1-indexed ranges, so any elided span can be pulled back with
a ranged Read — and reading the file a second time returns it whole.
Savings land in `repowise saved` under the `read_skeleton` filter.
+- `read_skeleton_mode: plus` keeps every line outside a function or method
+ body (imports, constants, class fields, decorators, comments) and elides
+ only the bodies. Default `smart`. `REPOWISE_HOOK_READ_SKELETON_MODE=plus`
+ overrides the file for one session.
- **Written by the rewrite-hook question in `repowise init`.** Saying yes there
turns this on too; `--no-editor-setup` and `--no-distill-hook` turn it off
with everything else. There is no separate prompt, because that question
diff --git a/packages/cli/src/repowise/cli/commands/augment_cmd/read_skeleton.py b/packages/cli/src/repowise/cli/commands/augment_cmd/read_skeleton.py
index d5cd537ca..c63450f57 100644
--- a/packages/cli/src/repowise/cli/commands/augment_cmd/read_skeleton.py
+++ b/packages/cli/src/repowise/cli/commands/augment_cmd/read_skeleton.py
@@ -64,6 +64,10 @@ _SAVINGS_FILTER = "read_skeleton"
CONFIG_FLAG = "read_skeleton"
+#: ``hooks.read_skeleton_mode: plus`` serves the plus view (all non-function
+#: code kept, bodies elided); anything else, or absent, serves smart.
+MODE_KEY = "read_skeleton_mode"
+
def enabled(repo_path: Path) -> bool:
"""True when this repo opted into read replacement. Fails closed.
@@ -77,6 +81,33 @@ def enabled(repo_path: Path) -> bool:
return hook_flag_enabled(repo_path, CONFIG_FLAG)
+def configured_mode(repo_path: Path) -> str:
+ """``"plus"`` when ``hooks.read_skeleton_mode`` says so, else ``"smart"``.
+
+ A non-empty ``REPOWISE_HOOK_READ_SKELETON_MODE`` overrides the file for one
+ session. An unknown value, or any read or parse failure, keeps the default.
+ """
+ import os
+
+ value = (os.environ.get(f"REPOWISE_HOOK_{MODE_KEY.upper()}") or "").strip()
+ if not value:
+ try:
+ text = (repo_path / ".repowise" / "config.yaml").read_text(encoding="utf-8")
+ except (OSError, ValueError):
+ return "smart"
+ if MODE_KEY not in text:
+ return "smart"
+ import yaml
+
+ try:
+ data = yaml.safe_load(text)
+ except yaml.YAMLError:
+ return "smart"
+ hooks = data.get("hooks") if isinstance(data, dict) else None
+ value = hooks.get(MODE_KEY) if isinstance(hooks, dict) else None
+ return "plus" if str(value).strip().lower() == "plus" else "smart"
+
+
def is_unbounded_read(tool_input: dict) -> bool:
"""True for a Read with neither offset nor limit — the whole file."""
if not isinstance(tool_input, dict):
@@ -119,7 +150,7 @@ def skeleton_replacement(
# each signature. Its body-budget machinery is inert here on purpose: no
# PageRank is persisted on wiki_symbols, so every importance is 0.0 and no
# body is ever kept. That is the intended output — a map, not an excerpt.
- result = build_skeleton(source, symbols, mode="smart")
+ result = build_skeleton(source, symbols, mode=configured_mode(repo_path))
if result.mode == "raw": # no usable bounds — the index cannot help here
return None
if result.skeleton_tokens > result.full_tokens * min_ratio_gain:
diff --git a/packages/cli/src/repowise/cli/commands/context_cmd.py b/packages/cli/src/repowise/cli/commands/context_cmd.py
index fc62ad265..f068054b3 100644
--- a/packages/cli/src/repowise/cli/commands/context_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/context_cmd.py
@@ -19,6 +19,7 @@ _INCLUDE_BLOCKS = (
"decisions",
"health",
"skeleton",
+ "skeleton+",
"doc_drift",
"symbols",
)
diff --git a/packages/core/src/repowise/core/distill/skeleton.py b/packages/core/src/repowise/core/distill/skeleton.py
index 657db1b7f..5ae8d7447 100644
--- a/packages/core/src/repowise/core/distill/skeleton.py
+++ b/packages/core/src/repowise/core/distill/skeleton.py
@@ -18,6 +18,11 @@ Two modes:
per-symbol line budget proportional to importance, all under a total token
budget. A hotspot file gets a larger budget — high-churn code is where
body-level context pays off.
+- ``"plus"``: every line outside a function or method body kept verbatim
+ (imports, constants, class fields, decorators, comments), every signature
+ kept, and each function/method body elided to one marker carrying its line
+ range. Classes are containers: their methods' bodies are elided, the rest
+ of the class stays.
This module is pure: it sees source text and symbol records, never a
database. Callers (MCP tools, hooks, tests) fetch the rows and pass them in.
@@ -78,6 +83,13 @@ _DECOR_RE = re.compile(r"^\s*(?:#|//)\s*[-=~*#_]{4,}\s*$")
_DOCSTRING_DELIMS = ('"""', "'''")
+#: Symbol kinds whose body plus mode elides; every other kind is kept whole.
+_CALLABLE_KINDS = frozenset({"function", "method"})
+
+#: A body's last line that only closes it (``}``, ``});``, ``end``) stays in
+#: plus mode, so the elision sits inside a well-formed block.
+_CLOSER_RE = re.compile(r"\s*(?:[})\];,]+|end)\s*")
+
@dataclass(frozen=True)
class SkeletonSymbol:
@@ -101,7 +113,7 @@ class SkeletonResult:
"""Outcome of one skeletonization."""
text: str
- mode: str # "smart" | "signatures" | "raw"
+ mode: str # "smart" | "signatures" | "plus" | "raw"
full_tokens: int
skeleton_tokens: int
symbol_count: int
@@ -143,6 +155,18 @@ def build_skeleton(
symbol_count=0,
)
+ if mode == "plus":
+ keep = [True] * total
+ _elide_callable_bodies(lines, usable, keep)
+ text = _render(lines, keep)
+ return SkeletonResult(
+ text=text,
+ mode="plus",
+ full_tokens=full_tokens,
+ skeleton_tokens=estimate_tokens(text),
+ symbol_count=len(usable),
+ )
+
keep = [False] * total
# Preamble: module docstring + imports + leading module code.
@@ -264,6 +288,8 @@ def _signature_end(lines: list[str], start: int, end: int) -> int:
continue
if stripped.endswith((":", "{", ";", "=>")):
return i
+ if stripped.startswith(("@", "#[")):
+ continue # annotation/attribute line a symbol's bounds may start on
# Signature closed without a body opener — check for an Allman brace.
j = i + 1
if j <= end and lines[j].strip().startswith("{"):
@@ -272,6 +298,25 @@ def _signature_end(lines: list[str], start: int, end: int) -> int:
return start
+def _elide_callable_bodies(
+ lines: list[str], symbols: list[SkeletonSymbol], keep: list[bool]
+) -> None:
+ """Plus mode: unmark each outermost function/method body below its signature.
+
+ A callable nested in an elided body (a closure) is part of that body.
+ """
+ covered_until = -1
+ for sym in symbols:
+ start, end = sym.start_line - 1, sym.end_line - 1
+ if sym.kind not in _CALLABLE_KINDS or start <= covered_until:
+ continue
+ covered_until = end
+ body_start = _signature_end(lines, start, end) + 1
+ body_end = end - 1 if end >= body_start and _CLOSER_RE.fullmatch(lines[end]) else end
+ for i in range(body_start, body_end + 1):
+ keep[i] = False
+
+
def _docstring_lines(lines: list[str], start: int, end: int) -> list[int]:
"""Indices of a docstring block directly under a signature, capped.
diff --git a/packages/server/src/repowise/server/mcp_server/tool_context/context.py b/packages/server/src/repowise/server/mcp_server/tool_context/context.py
index f4a86a9ff..d3f784667 100644
--- a/packages/server/src/repowise/server/mcp_server/tool_context/context.py
+++ b/packages/server/src/repowise/server/mcp_server/tool_context/context.py
@@ -25,6 +25,7 @@ Optional ``include`` parameter widens the response:
two appear only when non-empty, and are capped.
A dismissed record is in none of them.
- include=["skeleton"] → body-elided file rendering (signatures + top-PageRank bodies)
+ - include=["skeleton+"] → all non-function code kept, every function/method body elided
- include=["health"] → code-health scores and biomarkers for the target
- include=["doc_drift"] → documents that name this file, and their drift
- include=["symbols"] → every symbol in a file card, not the ranked top 15
@@ -82,6 +83,7 @@ _INCLUDE_BLOCKS = frozenset(
"community",
"decisions",
"skeleton",
+ "skeleton+",
"health",
"doc_drift",
"symbols",
@@ -129,7 +131,7 @@ async def get_context(
Args:
targets: file paths, module paths, or "path::Symbol" ids.
include: opt-in blocks: full_doc | ownership | last_change | callers
- | callees | metrics | community | decisions | skeleton | health
+ | callees | metrics | community | decisions | skeleton | skeleton+ | health
| doc_drift (documents naming this file) | symbols (all of a
file's symbols; the default lists the top 15, classes and
functions first).
diff --git a/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.py b/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.py
index 86cf75f35..76edd7712 100644
--- a/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.py
+++ b/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.py
@@ -905,12 +905,15 @@ async def _resolve_skeleton(
result_data: dict[str, Any],
*,
repo_root: Any = None,
+ mode: str = "smart",
) -> None:
"""Resolve ``include=["skeleton"]`` — a body-elided rendering of one file.
Slices the on-disk source on the line bounds persisted at index time
(zero parsing), keeping every signature and the bodies of the
- highest-PageRank symbols under a token budget. File targets only —
+ highest-PageRank symbols under a token budget. ``include=["skeleton+"]``
+ passes ``mode="plus"``: all non-function code kept, every function and
+ method body elided. File targets only:
a symbol's "skeleton" is just its signature, which the triage card
already carries.
"""
@@ -991,7 +994,7 @@ async def _resolve_skeleton(
result = build_skeleton(
source,
symbols,
- mode="smart",
+ mode=mode,
hotspot=bool(result_data.get("hotspot")),
)
result_data["skeleton"] = {
diff --git a/packages/server/src/repowise/server/mcp_server/tool_context/targets.py b/packages/server/src/repowise/server/mcp_server/tool_context/targets.py
index 35a1887c9..d7b869c12 100644
--- a/packages/server/src/repowise/server/mcp_server/tool_context/targets.py
+++ b/packages/server/src/repowise/server/mcp_server/tool_context/targets.py
@@ -695,7 +695,9 @@ async def _resolve_one_target(
"section": parent.section_number,
}
- want_skeleton = bool(include and "skeleton" in include)
+ # Asking for both skeleton and skeleton+ renders one block, the plus view.
+ skeleton_plus = bool(include and "skeleton+" in include)
+ want_skeleton = skeleton_plus or bool(include and "skeleton" in include)
want_all_symbols = bool(include and "symbols" in include)
# --- Docs ---
@@ -1294,7 +1296,13 @@ async def _resolve_one_target(
# --- Skeleton (distill) — opt-in only, see the module note ---
if want_skeleton:
await _resolve_skeleton(
- session, repository, target, target_type, result_data, repo_root=repo_root
+ session,
+ repository,
+ target,
+ target_type,
+ result_data,
+ repo_root=repo_root,
+ mode="plus" if skeleton_plus else "smart",
)
return result_data
diff --git a/tests/unit/cli/test_augment_read_skeleton.py b/tests/unit/cli/test_augment_read_skeleton.py
index ebd99652f..87f4db023 100644
--- a/tests/unit/cli/test_augment_read_skeleton.py
+++ b/tests/unit/cli/test_augment_read_skeleton.py
@@ -738,3 +738,56 @@ def test_the_reread_notice_no_longer_fires(repo: Path) -> None:
for _ in range(3):
result = _read(repo)
assert "You already read" not in (result.context or "")
+
+
+def test_the_mode_switch_serves_plus_and_defaults_to_smart(repo: Path, monkeypatch) -> None:
+ """``hooks.read_skeleton_mode: plus`` keeps module code that smart elides."""
+ from repowise.cli.commands.augment_cmd.read_skeleton import (
+ configured_mode,
+ skeleton_replacement,
+ )
+
+ table = "TABLE = {\n" + "".join(f" 'k{i}': {i},\n" for i in range(8)) + "}\n"
+ source = _source() + table
+ (repo / "pkg" / "table.py").write_text(source, encoding="utf-8")
+ _write_index(repo, "pkg/table.py", source)
+
+ def serve() -> str:
+ offer = skeleton_replacement(repo, "pkg/table.py", min_ratio_gain=1.0, min_saved_tokens=0)
+ assert offer is not None
+ return offer.text
+
+ assert configured_mode(repo) == "smart"
+ assert "'k5': 5," not in serve()
+
+ (repo / ".repowise" / "config.yaml").write_text(
+ "hooks:\n read_skeleton: true\n read_skeleton_mode: plus\n", encoding="utf-8"
+ )
+ assert configured_mode(repo) == "plus"
+ plus = serve()
+ assert "'k5': 5," in plus
+ assert "def func_3(argument_one, argument_two):" in plus
+ assert "value_20 = argument_one" not in plus
+
+ monkeypatch.setenv("REPOWISE_HOOK_READ_SKELETON_MODE", "smart")
+ assert configured_mode(repo) == "smart"
+
+
+def test_the_mode_env_override_ignores_blank_and_unknown_values(repo: Path, monkeypatch) -> None:
+ from repowise.cli.commands.augment_cmd.read_skeleton import configured_mode
+
+ (repo / ".repowise" / "config.yaml").write_text(
+ "hooks:\n read_skeleton: true\n read_skeleton_mode: plus\n", encoding="utf-8"
+ )
+ monkeypatch.setenv("REPOWISE_HOOK_READ_SKELETON_MODE", " ")
+ assert configured_mode(repo) == "plus" # blank counts as unset
+ monkeypatch.setenv("REPOWISE_HOOK_READ_SKELETON_MODE", "everything")
+ assert configured_mode(repo) == "smart"
+
+ monkeypatch.delenv("REPOWISE_HOOK_READ_SKELETON_MODE")
+ (repo / ".repowise" / "config.yaml").write_text(
+ "hooks: [read_skeleton_mode: plus\n", encoding="utf-8"
+ )
+ assert configured_mode(repo) == "smart"
+ (repo / ".repowise" / "config.yaml").write_text("- read_skeleton_mode\n", encoding="utf-8")
+ assert configured_mode(repo) == "smart"
diff --git a/tests/unit/distill/test_skeleton.py b/tests/unit/distill/test_skeleton.py
index c02d492a1..f4eb66b50 100644
--- a/tests/unit/distill/test_skeleton.py
+++ b/tests/unit/distill/test_skeleton.py
@@ -216,3 +216,33 @@ class TestResultShape:
text="x", mode="signatures", full_tokens=200, skeleton_tokens=30, symbol_count=3
)
assert r.pct_of_full == 15.0
+
+
+# Bounds that start on an annotation line, as some parsers persist them.
+_ANNOTATED = [
+ (
+ "@decorator\ndef run(a, b):\n x = a\n y = b\n z = x + y\n return z\n",
+ "def run(a, b):",
+ ),
+ (
+ "@Override\npublic String toString() {\n String s = \"x\";\n s = s + 1;\n"
+ " s = s + 2;\n return s;\n}\n",
+ "public String toString() {",
+ ),
+ (
+ "#[inline]\nfn top(a: u32) -> u32 {\n let s = a;\n let t = s * 2;\n"
+ " let u = t + 1;\n u\n}\n",
+ "fn top(a: u32) -> u32 {",
+ ),
+]
+
+
[email protected]("mode", ["smart", "signatures"])
[email protected](("source", "signature"), _ANNOTATED)
+def test_a_signature_after_an_annotation_line_is_kept(mode, source, signature) -> None:
+ total = len(source.splitlines())
+ sym = SkeletonSymbol(name="f", kind="function", start_line=1, end_line=total)
+ result = build_skeleton(source, [sym], mode=mode)
+ assert result.text.splitlines()[:2] == source.splitlines()[:2]
+ assert signature in result.text
+ assert "... " in result.text # the body itself is still elided
diff --git a/tests/unit/distill/test_skeleton_plus.py b/tests/unit/distill/test_skeleton_plus.py
new file mode 100644
index 000000000..475e82ab7
--- /dev/null
+++ b/tests/unit/distill/test_skeleton_plus.py
@@ -0,0 +1,251 @@
+"""Plus mode: every line outside a function body kept, every body elided.
+
+Sources are parsed at test time so the bounds are the ones the index would
+persist. Each function/method body line is tagged ``BODY``; that tag is the
+oracle, independent of the parser and of the skeleton.
+"""
+
+from __future__ import annotations
+
+import re
+
+import pytest
+
+from repowise.core.distill.skeleton import SkeletonSymbol, build_skeleton
+from repowise.core.ingestion.parser import ASTParser
+from tests.unit.ingestion.parser._helpers import _make_file_info
+
+_MARKER_RE = re.compile(r"^\s*\.\.\. (\d+) lines \((\d+)-(\d+)\)$")
+
+_SOURCES = {
+ "a.py": ("python", '''"""Mod doc."""
+import os
+
+LIMIT = 3
+
+
+@decorator
+def top(a, b):
+ x = 1 # BODY
+ y = 2 # BODY
+ return x + y # BODY
+
+
+class Box:
+ """Box doc."""
+
+ size: int = 0
+ COLOR = "red"
+
+ @property
+ def area(
+ self,
+ ) -> int:
+ v = self.size # BODY
+ w = v * v # BODY
+ return w # BODY
+
+ def inner(self):
+ def helper(): # BODY
+ return 1 # BODY
+ return helper() # BODY
+
+
+# trailing comment
+REGISTRY = {"a": top}
+'''),
+ "a.ts": ("typescript", '''import { x } from "./x";
+
+export const LIMIT = 3;
+
+export function top(a: number, b: number): number {
+ const s = a + b; // BODY
+ const t = s * 2; // BODY
+ return t; // BODY
+}
+
+export class Box {
+ size = 0;
+ private color: string = "red";
+
+ constructor(size: number) {
+ this.size = size; // BODY
+ this.color = "blue"; // BODY
+ console.log(size); // BODY
+ }
+
+ area(): number {
+ const v = this.size; // BODY
+ const w = v * v; // BODY
+ return w; // BODY
+ }
+}
+
+export interface Shape {
+ area(): number;
+ name: string;
+}
+
+export const arrow = (a: number) => {
+ const r = a; // BODY
+ const q = r + 1; // BODY
+ return q; // BODY
+};
+'''),
+ "a.go": ("go", '''package main
+
+import "fmt"
+
+const Limit = 3
+
+type Box struct {
+ Size int
+ Color string
+}
+
+func (b *Box) Area() int {
+ v := b.Size // BODY
+ w := v * v // BODY
+ return w // BODY
+}
+
+// Top adds.
+func Top(a, b int) int {
+ s := a + b // BODY
+ fmt.Println(s) // BODY
+ return s // BODY
+}
+
+var registry = map[string]int{"a": 1}
+'''),
+ "A.java": ("java", '''package demo;
+
+import java.util.List;
+
+public class A {
+ private static final int LIMIT = 3;
+ private int size;
+
+ @Override
+ public String toString() {
+ String s = "x"; // BODY
+ s = s + size; // BODY
+ return s; // BODY
+ }
+
+ public A(int size) {
+ this.size = size; // BODY
+ int t = size * 2; // BODY
+ System.out.println(t); // BODY
+ }
+}
+'''),
+ "a.rs": ("rust", '''use std::fmt;
+
+const LIMIT: u32 = 3;
+
+pub struct Box {
+ pub size: u32,
+ color: String,
+}
+
+impl Box {
+ pub fn area(&self) -> u32 {
+ let v = self.size; // BODY
+ let w = v * v; // BODY
+ w // BODY
+ }
+}
+
+#[inline]
+fn top(a: u32, b: u32) -> u32 {
+ let s = a + b; // BODY
+ let t = s * 2; // BODY
+ t // BODY
+}
+'''),
+}
+
+
+def _runs(indices: list[int]) -> list[tuple[int, int]]:
+ runs: list[tuple[int, int]] = []
+ for i in indices:
+ if runs and runs[-1][1] == i - 1:
+ runs[-1] = (runs[-1][0], i)
+ else:
+ runs.append((i, i))
+ return runs
+
+
[email protected]("path", sorted(_SOURCES))
+def test_plus_keeps_everything_but_function_bodies(path: str) -> None:
+ language, source = _SOURCES[path]
+ parsed = ASTParser().parse_file(_make_file_info(path, language), source.encode())
+ symbols = [
+ SkeletonSymbol(name=s.name, kind=s.kind, start_line=s.start_line, end_line=s.end_line)
+ for s in parsed.symbols
+ ]
+ result = build_skeleton(source, symbols, mode="plus")
+ assert result.mode == "plus"
+
+ lines = source.splitlines()
+ kept: list[int] = [] # 1-indexed source lines present verbatim
+ elided: list[tuple[int, int]] = []
+ line_no = 1
+ for out in result.text.splitlines():
+ match = _MARKER_RE.match(out)
+ if match:
+ a, b = int(match.group(2)), int(match.group(3))
+ assert a == line_no and int(match.group(1)) == b - a + 1
+ elided.append((a, b))
+ line_no = b + 1
+ continue
+ assert out == lines[line_no - 1]
+ kept.append(line_no)
+ line_no += 1
+ assert line_no - 1 == len(lines)
+
+ body = [i for i, ln in enumerate(lines, 1) if "BODY" in ln]
+ assert kept == [i for i in range(1, len(lines) + 1) if i not in body]
+ assert elided == _runs(body)
+ for sym in parsed.symbols:
+ if sym.kind in ("function", "method"):
+ assert any(i in kept for i in range(sym.start_line, sym.start_line + 2)), sym.name
+
+
+def test_an_unknown_mode_still_reports_signatures() -> None:
+ source = "def f():\n a = 1\n b = 2\n return a + b\n"
+ sym = SkeletonSymbol(name="f", kind="function", start_line=1, end_line=4)
+ assert build_skeleton(source, [sym], mode="bogus").mode == "signatures"
+
+
+def test_ts_arrow_consts_with_one_line_bodies(monkeypatch) -> None:
+ """A one-line body is marked as body but rendered verbatim: a marker is not shorter."""
+ import repowise.core.distill.skeleton as skeleton
+
+ source = (
+ "export const inc = (a: number): number => a + 1;\n"
+ "\n"
+ "export const twice = (a: number) => {\n"
+ " return a * 2;\n"
+ "};\n"
+ "\n"
+ "export const LIMIT = 3;\n"
+ )
+ parsed = ASTParser().parse_file(_make_file_info("b.ts", "typescript"), source.encode())
+ symbols = [
+ SkeletonSymbol(name=s.name, kind=s.kind, start_line=s.start_line, end_line=s.end_line)
+ for s in parsed.symbols
+ ]
+ masks: list[list[bool]] = []
+ real_render = skeleton._render
+
+ def capture(lines, keep):
+ masks.append(list(keep))
+ return real_render(lines, keep)
+
+ monkeypatch.setattr(skeleton, "_render", capture)
+ result = build_skeleton(source, symbols, mode="plus")
+ assert result.mode == "plus"
+ assert result.text == source
+ assert masks == [[True, True, True, False, True, True, True]]
diff --git a/tests/unit/server/mcp/test_context_skeleton.py b/tests/unit/server/mcp/test_context_skeleton.py
index 8fdf9cbaa..98ecc8384 100644
--- a/tests/unit/server/mcp/test_context_skeleton.py
+++ b/tests/unit/server/mcp/test_context_skeleton.py
@@ -236,3 +236,36 @@ async def test_default_card_survives_a_missing_source_file(setup_mcp, tmp_path,
card = result["targets"]["src/auth/service.py"]
assert "skeleton" not in card
assert card["docs"]["symbols"]
+
+
+async def test_skeleton_plus_keeps_class_code_and_elides_method_bodies(
+ setup_mcp, tmp_path, monkeypatch
+):
+ from repowise.server.mcp_server import _state, get_context
+
+ _write_source(tmp_path)
+ monkeypatch.setattr(_state, "_repo_path", str(tmp_path))
+
+ result = await get_context(["src/auth/service.py"], include=["skeleton+"])
+ assert "ignored_arguments" not in result
+ sk = result["targets"]["src/auth/service.py"]["skeleton"]
+ assert sk["mode"] == "plus"
+ text = sk["text"]
+ # Class-level code outside the method stays, the method body does not.
+ assert " setup_15 = 15" in text
+ assert " tail_90 = 90" in text
+ assert "async def login" in text
+ assert "step_30" not in text
+ assert " ... 20 lines (21-40)" in text
+
+
+async def test_skeleton_and_skeleton_plus_together_render_plus(setup_mcp, tmp_path, monkeypatch):
+ from repowise.server.mcp_server import _state, get_context
+
+ _write_source(tmp_path)
+ monkeypatch.setattr(_state, "_repo_path", str(tmp_path))
+
+ result = await get_context(["src/auth/service.py"], include=["skeleton", "skeleton+"])
+ assert result["targets"]["src/auth/service.py"]["skeleton"]["mode"] == "plus"