Skip to content

Commit 4eee534

Browse files
committed
refactor: expose kb helper APIs
1 parent 89a9d04 commit 4eee534

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/adjutant/capabilities/kb/query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ async def kb_query(
160160
Raises:
161161
KBQueryError: If KB not found or query fails.
162162
"""
163-
from adjutant.capabilities.kb.run import KBNotFoundError, _get_kb
163+
from adjutant.capabilities.kb.run import KBNotFoundError, get_kb
164164

165165
try:
166-
entry = _get_kb(adj_dir, kb_name)
166+
entry = get_kb(adj_dir, kb_name)
167167
except KBNotFoundError as exc:
168168
raise KBQueryError(str(exc)) from exc
169169

@@ -251,10 +251,10 @@ def kb_write(
251251
Raises:
252252
KBQueryError: If KB not found or instruction fails validation.
253253
"""
254-
from adjutant.capabilities.kb.run import KBNotFoundError, _get_kb
254+
from adjutant.capabilities.kb.run import KBNotFoundError, get_kb
255255

256256
try:
257-
entry = _get_kb(adj_dir, kb_name)
257+
entry = get_kb(adj_dir, kb_name)
258258
except KBNotFoundError as exc:
259259
raise KBQueryError(str(exc)) from exc
260260

src/adjutant/capabilities/kb/run.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class KBRunError(Exception):
4545
"""Raised when the operation script exits non-zero."""
4646

4747

48-
def _get_kb(adj_dir: Path, kb_name: str) -> dict[str, str]:
48+
def get_kb(adj_dir: Path, kb_name: str) -> dict[str, str]:
4949
"""Return the registry entry for kb_name or raise KBNotFoundError.
5050
5151
Delegates to the canonical registry parser in manage.py and converts
@@ -62,6 +62,11 @@ def _get_kb(adj_dir: Path, kb_name: str) -> dict[str, str]:
6262
return entry.as_dict()
6363

6464

65+
def _get_kb(adj_dir: Path, kb_name: str) -> dict[str, str]:
66+
"""Backward-compatible alias for older call sites and tests."""
67+
return get_kb(adj_dir, kb_name)
68+
69+
6570
_VALID_OPERATION = re.compile(r"^[a-z][a-z0-9_-]*$")
6671

6772

@@ -144,7 +149,7 @@ def get_operation_script(adj_dir: Path, kb_name: str, operation: str) -> Path:
144149
"Use lowercase letters, digits, hyphens, or underscores."
145150
)
146151

147-
entry = _get_kb(adj_dir, kb_name)
152+
entry = get_kb(adj_dir, kb_name)
148153
kb_path_str = entry.get("path", "")
149154
if not kb_path_str:
150155
raise KBNotFoundError(f"KB '{kb_name}' has no path in registry.")
@@ -232,7 +237,7 @@ def kb_run(
232237
"Use lowercase letters, digits, hyphens, or underscores."
233238
)
234239

235-
entry = _get_kb(adj_dir, kb_name)
240+
entry = get_kb(adj_dir, kb_name)
236241
kb_path_str = entry.get("path", "")
237242
if not kb_path_str:
238243
raise KBNotFoundError(f"KB '{kb_name}' has no path in registry.")

0 commit comments

Comments
 (0)