Skip to content

Commit 44d8474

Browse files
committed
fix: update all _-prefix function names in the project
1 parent 19f643b commit 44d8474

20 files changed

Lines changed: 108 additions & 136 deletions

api/workspaces.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,13 @@
2222
)
2323
from utils.workspace_descriptor import read_json_file
2424
from services.workspace_resolver import (
25-
determine_project_for_conversation,
26-
infer_invalid_workspace_aliases,
2725
infer_workspace_name_from_context,
2826
lookup_workspace_display_name,
2927
)
3028
from services.cli_tabs import get_cli_workspace_tabs
3129
from services.workspace_listing import list_workspace_projects
3230
from services.workspace_tabs import assemble_workspace_tabs
3331

34-
# Re-exported for back-compat with tests that import from api.workspaces directly.
35-
_determine_project_for_conversation = determine_project_for_conversation # noqa: F401
36-
_infer_invalid_workspace_aliases = infer_invalid_workspace_aliases # noqa: F401
37-
_get_workspace_display_name = lookup_workspace_display_name # noqa: F401
38-
_infer_workspace_name_from_context = infer_workspace_name_from_context # noqa: F401
39-
4032
# Re-exported for tests/test_models_wired_at_read_sites.py — the typed-model
4133
# spy harness patches `workspaces_mod.Bubble` / `.Composer` / `.Workspace` to
4234
# verify that production read paths actually call from_dict. The classes

scripts/export.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@
5555
)
5656
from models import ExportEntry, SchemaError # noqa: E402
5757
from services.workspace_db import ( # noqa: E402
58-
_build_composer_id_to_workspace_id,
59-
_collect_invalid_workspace_ids,
60-
_collect_workspace_entries,
58+
build_composer_id_to_workspace_id,
59+
collect_invalid_workspace_ids,
60+
collect_workspace_entries,
6161
load_bubble_map,
6262
load_code_block_diff_map,
6363
load_project_layouts_map,
64-
_open_global_db,
64+
open_global_db,
6565
)
6666
from services.workspace_resolver import ( # noqa: E402
67-
_determine_project_for_conversation,
68-
_get_workspace_display_name,
69-
_infer_invalid_workspace_aliases,
70-
_create_project_name_to_workspace_id_map,
71-
_create_workspace_path_to_id_map,
67+
create_project_name_to_workspace_id_map,
68+
create_workspace_path_to_id_map,
69+
determine_project_for_conversation,
70+
infer_invalid_workspace_aliases,
71+
lookup_workspace_display_name,
7272
)
7373

7474
_logger = logging.getLogger(__name__)
7575

7676

77-
def _configure_cli_logging() -> None:
77+
def configure_cli_logging() -> None:
7878
"""Route log records to stderr so stdout stays for export progress lines."""
7979
root = logging.getLogger()
8080
if root.handlers:
@@ -86,15 +86,15 @@ def _configure_cli_logging() -> None:
8686
)
8787

8888

89-
def _json_dump_safe(value) -> str:
89+
def json_dump_safe(value) -> str:
9090
"""Best-effort JSON serialization for exclusion matching."""
9191
try:
9292
return json.dumps(value, ensure_ascii=False, sort_keys=True)
9393
except Exception:
9494
return str(value) if value is not None else ""
9595

9696

97-
def _load_manifest_entries(manifest_path: str) -> dict:
97+
def load_manifest_entries(manifest_path: str) -> dict:
9898
"""Load manifest entries keyed by log_id from a JSONL file."""
9999
existing: dict = {}
100100
if not os.path.isfile(manifest_path):
@@ -117,7 +117,7 @@ def _load_manifest_entries(manifest_path: str) -> dict:
117117
return existing
118118

119119

120-
def _write_manifest_entries(manifest_path: str, entries_by_id: dict):
120+
def write_manifest_entries(manifest_path: str, entries_by_id: dict):
121121
"""Write manifest entries to JSONL."""
122122
os.makedirs(os.path.dirname(manifest_path), exist_ok=True)
123123
with open(manifest_path, "w", encoding="utf-8") as f:
@@ -177,7 +177,7 @@ def parse_args():
177177

178178

179179
def main():
180-
_configure_cli_logging()
180+
configure_cli_logging()
181181
opts = parse_args()
182182
since = opts["since"]
183183
out_dir = os.path.abspath(opts["out_dir"])
@@ -201,11 +201,11 @@ def main():
201201
pass
202202

203203
# ── Workspace scanning via service layer ──────────────────────────────────
204-
workspace_entries = _collect_workspace_entries(workspace_path)
205-
invalid_workspace_ids = _collect_invalid_workspace_ids(workspace_entries)
206-
project_name_map = _create_project_name_to_workspace_id_map(workspace_entries)
207-
workspace_path_map = _create_workspace_path_to_id_map(workspace_entries)
208-
composer_id_to_ws = _build_composer_id_to_workspace_id(workspace_path, workspace_entries)
204+
workspace_entries = collect_workspace_entries(workspace_path)
205+
invalid_workspace_ids = collect_invalid_workspace_ids(workspace_entries)
206+
project_name_map = create_project_name_to_workspace_id_map(workspace_entries)
207+
workspace_path_map = create_workspace_path_to_id_map(workspace_entries)
208+
composer_id_to_ws = build_composer_id_to_workspace_id(workspace_path, workspace_entries)
209209

210210
# Build display-name and slug maps from workspace entries.
211211
# Entries whose workspace.json cannot be resolved are omitted so the
@@ -214,7 +214,7 @@ def main():
214214
workspace_id_to_display_name: dict[str, str] = {}
215215
workspace_id_to_slug: dict[str, str] = {}
216216
for e in workspace_entries:
217-
display = _get_workspace_display_name(workspace_path, e["name"])
217+
display = lookup_workspace_display_name(workspace_path, e["name"])
218218
if display != e["name"]: # successfully resolved a human-readable name
219219
workspace_id_to_display_name[e["name"]] = display
220220
workspace_id_to_slug[e["name"]] = slug(display)
@@ -226,7 +226,7 @@ def main():
226226
ide_composer_rows: list = []
227227
invalid_workspace_aliases: dict = {}
228228

229-
with _open_global_db(workspace_path) as (global_db, global_db_path):
229+
with open_global_db(workspace_path) as (global_db, global_db_path):
230230
if global_db is None:
231231
_logger.info(
232232
"Cursor IDE global storage not found at %s — skipping IDE chats.",
@@ -245,7 +245,7 @@ def main():
245245
except sqlite3.Error:
246246
pass
247247

248-
invalid_workspace_aliases = _infer_invalid_workspace_aliases(
248+
invalid_workspace_aliases = infer_invalid_workspace_aliases(
249249
composer_rows=ide_composer_rows,
250250
project_layouts_map=project_layouts_map,
251251
project_name_map=project_name_map,
@@ -278,7 +278,7 @@ def main():
278278
continue
279279

280280
# Workspace assignment via service layer
281-
pid = _determine_project_for_conversation(
281+
pid = determine_project_for_conversation(
282282
cd, composer_id, project_layouts_map,
283283
project_name_map, workspace_path_map,
284284
workspace_entries, bubble_map, composer_id_to_ws, invalid_workspace_ids,
@@ -307,9 +307,9 @@ def main():
307307
text = extract_text_from_bubble(b)
308308
if text:
309309
bubble_texts.append(text)
310-
bubble_meta_parts.append(_json_dump_safe(b))
310+
bubble_meta_parts.append(json_dump_safe(b))
311311

312-
code_diff_parts = [_json_dump_safe(d) for d in code_block_diff_map.get(composer_id, [])]
312+
code_diff_parts = [json_dump_safe(d) for d in code_block_diff_map.get(composer_id, [])]
313313
searchable = build_searchable_text(
314314
project_name=ws_display_name,
315315
chat_title=title,
@@ -320,7 +320,7 @@ def main():
320320
bubble_texts
321321
+ bubble_meta_parts
322322
+ code_diff_parts
323-
+ [_json_dump_safe(model_config), _json_dump_safe(cd)]
323+
+ [json_dump_safe(model_config), json_dump_safe(cd)]
324324
)
325325
if p
326326
),
@@ -484,7 +484,7 @@ def main():
484484
f.write(entry["content"])
485485

486486
manifest_path = os.path.join(out_dir, "manifest.jsonl")
487-
existing = _load_manifest_entries(manifest_path)
487+
existing = load_manifest_entries(manifest_path)
488488
for entry in exported:
489489
existing[entry["id"]] = {
490490
"log_id": entry["id"],
@@ -494,10 +494,10 @@ def main():
494494
"updated_at": datetime.fromtimestamp(entry["updatedAt"] / 1000).isoformat() if entry["updatedAt"] else datetime.now().isoformat(),
495495
}
496496
if existing:
497-
_write_manifest_entries(manifest_path, existing)
497+
write_manifest_entries(manifest_path, existing)
498498

499499
global_manifest_path = os.path.join(state_dir, "manifest.jsonl")
500-
global_existing = _load_manifest_entries(global_manifest_path)
500+
global_existing = load_manifest_entries(global_manifest_path)
501501
for entry in exported:
502502
global_existing[entry["id"]] = {
503503
"log_id": entry["id"],
@@ -507,7 +507,7 @@ def main():
507507
"updated_at": datetime.fromtimestamp(entry["updatedAt"] / 1000).isoformat() if entry["updatedAt"] else datetime.now().isoformat(),
508508
}
509509
if global_existing:
510-
_write_manifest_entries(global_manifest_path, global_existing)
510+
write_manifest_entries(global_manifest_path, global_existing)
511511
print(f"Exported {count} chat(s) to {out_dir}")
512512

513513
state = {

services/cli_tabs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,3 @@ def get_cli_workspace_tabs(workspace_id: str):
146146
exc_info=True,
147147
)
148148
return jsonify({"error": "Failed to get CLI workspace tabs"}), 500
149-
150-
151-
# Backward-compatible alias for tests and legacy imports.
152-
_get_cli_workspace_tabs = get_cli_workspace_tabs

services/workspace_db.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,3 @@ def open_global_db(workspace_path: str):
240240
yield conn, global_db_path
241241
finally:
242242
conn.close()
243-
244-
245-
# Backward-compatible aliases for tests and legacy imports.
246-
_collect_workspace_entries = collect_workspace_entries
247-
_collect_invalid_workspace_ids = collect_invalid_workspace_ids
248-
_build_composer_id_to_workspace_id = build_composer_id_to_workspace_id
249-
_open_global_db = open_global_db

services/workspace_resolver.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,3 @@ def infer_invalid_workspace_aliases(
404404
continue
405405
aliases[invalid_id] = max(counts.items(), key=lambda kv: kv[1])[0]
406406
return aliases
407-
408-
409-
# Backward-compatible aliases for tests and legacy imports.
410-
_get_workspace_display_name = lookup_workspace_display_name
411-
_infer_workspace_name_from_context = infer_workspace_name_from_context
412-
_get_project_from_file_path = get_project_from_file_path
413-
_create_project_name_to_workspace_id_map = create_project_name_to_workspace_id_map
414-
_create_workspace_path_to_id_map = create_workspace_path_to_id_map
415-
_determine_project_for_conversation = determine_project_for_conversation
416-
_infer_invalid_workspace_aliases = infer_invalid_workspace_aliases

services/workspace_tabs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
)
1919
from utils.exclusion_rules import build_searchable_text, is_excluded_by_rules
2020
from utils.text_extract import extract_text_from_bubble
21-
from utils.tool_parser import parse_tool_call as _parse_tool_call
21+
from utils.tool_parser import parse_tool_call
2222
from utils.workspace_descriptor import read_json_file
2323
from models import Bubble, Composer, ParseWarningCollector, SchemaError
2424
from services.workspace_db import (
@@ -342,7 +342,7 @@ def _safe_fetchall(query: str, params: tuple = ()) -> list:
342342
tool_calls = None
343343
tfd = raw.get("toolFormerData")
344344
if isinstance(tfd, dict):
345-
tool_call = _parse_tool_call(tfd)
345+
tool_call = parse_tool_call(tfd)
346346
if isinstance(tool_call, dict):
347347
tool_calls = [tool_call]
348348

tests/test_api_endpoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from app import create_app
44
from tests._fixture_ids import HAPPY_BUBBLE_ID, HAPPY_COMPOSER_ID, HAPPY_WORKSPACE_ID
5-
from utils.exclusion_rules import _tokenize_rule
5+
from utils.exclusion_rules import tokenize_rule
66

77

88
# ---------------------------------------------------------------------------
@@ -155,7 +155,7 @@ def _client_with_rules(rule_lines):
155155
overrides the config with parsed rules — exercising the same code path
156156
a real `exclusion-rules.txt` file would.
157157
"""
158-
parsed = [_tokenize_rule(line) for line in rule_lines]
158+
parsed = [tokenize_rule(line) for line in rule_lines]
159159
app = create_app()
160160
app.config["TESTING"] = True
161161
app.config["EXCLUSION_RULES"] = [r for r in parsed if r]

tests/test_cli_chat_reader.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
sys.path.insert(0, str(_root))
2020

2121
from utils.cli_chat_reader import (
22-
_content_to_text,
22+
content_to_text,
2323
extract_blob_refs,
24-
_extract_tool_calls,
25-
_strip_user_info,
24+
extract_tool_calls,
25+
strip_user_info,
2626
aggregate_session_stats,
2727
extract_workspace_path,
2828
iter_sessions,
@@ -106,53 +106,53 @@ def test_partial_tag_at_end_ignored(self):
106106

107107

108108
# ---------------------------------------------------------------------------
109-
# _content_to_text
109+
# content_to_text
110110
# ---------------------------------------------------------------------------
111111

112112
class TestContentToText(unittest.TestCase):
113113
def test_string_passthrough(self):
114-
self.assertEqual(_content_to_text("hello"), "hello")
114+
self.assertEqual(content_to_text("hello"), "hello")
115115

116116
def test_list_with_text_parts(self):
117117
content = [{"type": "text", "text": "foo"}, {"type": "text", "text": "bar"}]
118-
result = _content_to_text(content)
118+
result = content_to_text(content)
119119
self.assertIn("foo", result)
120120
self.assertIn("bar", result)
121121

122122
def test_list_with_tool_result(self):
123123
content = [{"type": "tool-result", "result": "output here"}]
124-
self.assertIn("output here", _content_to_text(content))
124+
self.assertIn("output here", content_to_text(content))
125125

126126
def test_empty_list(self):
127-
self.assertEqual(_content_to_text([]), "")
127+
self.assertEqual(content_to_text([]), "")
128128

129129
def test_unknown_type_ignored(self):
130130
content = [{"type": "image", "url": "http://example.com/img.png"}]
131-
self.assertEqual(_content_to_text(content), "")
131+
self.assertEqual(content_to_text(content), "")
132132

133133
def test_non_string_non_list(self):
134-
self.assertEqual(_content_to_text(None), "")
135-
self.assertEqual(_content_to_text(42), "")
134+
self.assertEqual(content_to_text(None), "")
135+
self.assertEqual(content_to_text(42), "")
136136

137137

138138
# ---------------------------------------------------------------------------
139-
# _extract_tool_calls
139+
# extract_tool_calls
140140
# ---------------------------------------------------------------------------
141141

142142
class TestExtractToolCalls(unittest.TestCase):
143143
def test_non_list_returns_empty(self):
144-
self.assertEqual(_extract_tool_calls("text"), [])
145-
self.assertEqual(_extract_tool_calls(None), [])
144+
self.assertEqual(extract_tool_calls("text"), [])
145+
self.assertEqual(extract_tool_calls(None), [])
146146

147147
def test_list_without_tool_call_type(self):
148148
content = [{"type": "text", "text": "hello"}]
149-
self.assertEqual(_extract_tool_calls(content), [])
149+
self.assertEqual(extract_tool_calls(content), [])
150150

151151
def test_single_tool_call(self):
152152
content = [
153153
{"type": "tool-call", "toolName": "Shell", "args": {"command": "ls"}, "toolCallId": "tc-1"}
154154
]
155-
calls = _extract_tool_calls(content)
155+
calls = extract_tool_calls(content)
156156
self.assertEqual(len(calls), 1)
157157
self.assertEqual(calls[0]["name"], "Shell")
158158
self.assertEqual(calls[0]["args"], {"command": "ls"})
@@ -163,7 +163,7 @@ def test_mixed_content(self):
163163
{"type": "text", "text": "I will run a command."},
164164
{"type": "tool-call", "toolName": "Grep", "args": {"pattern": "foo"}, "toolCallId": "tc-2"},
165165
]
166-
calls = _extract_tool_calls(content)
166+
calls = extract_tool_calls(content)
167167
self.assertEqual(len(calls), 1)
168168
self.assertEqual(calls[0]["name"], "Grep")
169169

@@ -203,22 +203,22 @@ def test_returns_first_match(self):
203203

204204

205205
# ---------------------------------------------------------------------------
206-
# _strip_user_info
206+
# strip_user_info
207207
# ---------------------------------------------------------------------------
208208

209209
class TestStripUserInfo(unittest.TestCase):
210210
def test_extracts_user_query_tag(self):
211211
text = "<user_info>some preamble</user_info>\n<user_query>my actual question</user_query>"
212-
self.assertEqual(_strip_user_info(text), "my actual question")
212+
self.assertEqual(strip_user_info(text), "my actual question")
213213

214214
def test_strips_user_info_block_when_no_query_tag(self):
215215
text = "<user_info>preamble stuff</user_info>\nActual message here."
216-
result = _strip_user_info(text)
216+
result = strip_user_info(text)
217217
self.assertNotIn("<user_info>", result)
218218
self.assertIn("Actual message here.", result)
219219

220220
def test_passthrough_when_no_user_info(self):
221-
self.assertEqual(_strip_user_info("plain text"), "plain text")
221+
self.assertEqual(strip_user_info("plain text"), "plain text")
222222

223223

224224
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)