Skip to content

Commit c52b408

Browse files
committed
refactor: unify build commands by replacing analyze and index references with build and add knowcode_telemetry.jsonl to gitignore
1 parent 9e0f403 commit c52b408

10 files changed

Lines changed: 25 additions & 24 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ __marimo__/
206206

207207
# KnowCode generated files
208208
knowcode_knowledge.json
209+
knowcode_telemetry.jsonl
209210
CHANGELOG.md
210211
docs_test/
211212
#aimodels.yaml

src/knowcode/cli/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def query(query_type: str, target: str, store: str, as_json: bool) -> None:
224224
try:
225225
service = KnowCodeService(store_path=store)
226226
except FileNotFoundError:
227-
click.echo("Error: Knowledge store not found. Run 'knowcode analyze' first.", err=True)
227+
click.echo("Error: Knowledge store not found. Run 'knowcode build' first.", err=True)
228228
sys.exit(1)
229229

230230
results: list[dict[str, Any]] = []
@@ -355,7 +355,7 @@ def context(target: str, store: str, max_tokens: int) -> None:
355355
try:
356356
service = KnowCodeService(store_path=store)
357357
except FileNotFoundError:
358-
click.echo("Error: Knowledge store not found. Run 'knowcode analyze' first.", err=True)
358+
click.echo("Error: Knowledge store not found. Run 'knowcode build' first.", err=True)
359359
sys.exit(1)
360360

361361
try:
@@ -387,7 +387,7 @@ def export(store: str, output: str) -> None:
387387
try:
388388
service = KnowCodeService(store_path=store)
389389
except FileNotFoundError:
390-
click.echo("Error: Knowledge store not found. Run 'knowcode analyze' first.", err=True)
390+
click.echo("Error: Knowledge store not found. Run 'knowcode build' first.", err=True)
391391
sys.exit(1)
392392

393393
output_dir = Path(output)
@@ -413,7 +413,7 @@ def stats(store: str) -> None:
413413
try:
414414
service = KnowCodeService(store_path=store)
415415
except FileNotFoundError:
416-
click.echo("Error: Knowledge store not found. Run 'knowcode analyze' first.", err=True)
416+
click.echo("Error: Knowledge store not found. Run 'knowcode build' first.", err=True)
417417
sys.exit(1)
418418

419419
s = service.get_stats()
@@ -560,7 +560,7 @@ def history(target: Optional[str], store: str, limit: int) -> None:
560560
try:
561561
service = KnowCodeService(store_path=store)
562562
except FileNotFoundError:
563-
click.echo("Error: Knowledge store not found. Run 'knowcode analyze' first.", err=True)
563+
click.echo("Error: Knowledge store not found. Run 'knowcode build' first.", err=True)
564564
sys.exit(1)
565565

566566
knowledge = service.store
@@ -708,7 +708,7 @@ def mcp_server(store: str, config: Optional[str]) -> None:
708708
store_file = store_path / KnowledgeStore.DEFAULT_FILENAME if store_path.is_dir() else store_path
709709
if not store_file.exists():
710710
click.echo(
711-
"Error: Knowledge store not found. Run `knowcode analyze <dir>` first.",
711+
"Error: Knowledge store not found. Run `knowcode build <dir>` first.",
712712
err=True,
713713
)
714714
sys.exit(1)

src/knowcode/doctor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _check_knowledge_store(store_file: Path, checks: list[DoctorCheck]) -> None:
216216
name="Knowledge store",
217217
status="fail",
218218
message=f"Knowledge store not found: {store_file}",
219-
hint="Run `knowcode analyze <dir>` first.",
219+
hint="Run `knowcode build <dir>` first.",
220220
)
221221
)
222222
return
@@ -230,7 +230,7 @@ def _check_knowledge_store(store_file: Path, checks: list[DoctorCheck]) -> None:
230230
name="Knowledge store",
231231
status="fail",
232232
message=f"Could not load {store_file}: {exc}",
233-
hint="Re-run `knowcode analyze <dir>` to rebuild the store.",
233+
hint="Re-run `knowcode build <dir>` to rebuild the store.",
234234
)
235235
)
236236
return
@@ -245,7 +245,7 @@ def _check_knowledge_store(store_file: Path, checks: list[DoctorCheck]) -> None:
245245
f"Loaded {store_file} via schema migration "
246246
f"({len(store.entities)} entities)."
247247
),
248-
hint="Re-run `knowcode analyze <dir>` to persist the current schema.",
248+
hint="Re-run `knowcode build <dir>` to persist the current schema.",
249249
)
250250
)
251251
return
@@ -275,7 +275,7 @@ def _check_semantic_index(
275275
name="Semantic index",
276276
status="fail",
277277
message=f"Semantic index not found: {index_path}",
278-
hint="Run `knowcode index <dir>` first.",
278+
hint="Run `knowcode build <dir>` first.",
279279
)
280280
)
281281
return
@@ -375,7 +375,7 @@ def _check_semantic_index(
375375
name="Semantic index",
376376
status="fail",
377377
message=f"{index_path}: {'; '.join(failures)}.",
378-
hint="Rebuild the semantic index with `knowcode index <dir>`.",
378+
hint="Rebuild the semantic index with `knowcode build <dir>`.",
379379
)
380380
)
381381
return
@@ -720,7 +720,7 @@ def _check_freshness(store_path: str | Path, config_path: str | Path | None, che
720720
name="Freshness",
721721
status="warn",
722722
message=f"Store/index may be stale. Reasons: {', '.join(freshness['stale_reasons'])}.",
723-
hint="Re-run `knowcode analyze` and `knowcode index` to rebuild artifacts.",
723+
hint="Re-run `knowcode build` to rebuild artifacts.",
724724
)
725725
)
726726
else:

src/knowcode/errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, store_file: Path) -> None:
2121
super().__init__(
2222
f"Knowledge store not found: {store_file}",
2323
code="missing_knowledge_store",
24-
hint="Run `knowcode analyze <dir>` first.",
24+
hint="Run `knowcode build <dir>` first.",
2525
)
2626

2727

@@ -32,5 +32,5 @@ def __init__(self, index_path: Path) -> None:
3232
super().__init__(
3333
f"Semantic index not found: {index_path}",
3434
code="missing_semantic_index",
35-
hint="Run `knowcode index <dir>` first.",
35+
hint="Run `knowcode build <dir>` first.",
3636
)

src/knowcode/indexing/indexer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def _validate_and_migrate_payload_schema(
219219
if legacy_value not in allowed_legacy_values:
220220
raise ValueError(
221221
f"Unsupported legacy {payload_name} version "
222-
f"{legacy_value!r}. Rebuild with `knowcode index`."
222+
f"{legacy_value!r}. Rebuild with `knowcode build`."
223223
)
224224
migrated = dict(payload)
225225
migrated["schema_version"] = cls.SCHEMA_VERSION
@@ -239,7 +239,7 @@ def _validate_and_migrate_payload_schema(
239239
f"Unsupported {payload_name} schema version "
240240
f"{schema_version!r}. Supported versions: "
241241
f"{sorted(cls.SUPPORTED_SCHEMA_VERSIONS)}. "
242-
"Rebuild with `knowcode index`."
242+
"Rebuild with `knowcode build`."
243243
)
244244

245245
@staticmethod

src/knowcode/storage/knowledge_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _migrate_schema(cls, data: dict[str, Any]) -> dict[str, Any]:
143143
return migrated
144144
raise ValueError(
145145
"Unsupported legacy knowledge store format. "
146-
f"Found version={legacy_version!r}. Re-run `knowcode analyze`."
146+
f"Found version={legacy_version!r}. Re-run `knowcode build`."
147147
)
148148

149149
normalized = cls._normalize_schema_version(schema_version)
@@ -160,7 +160,7 @@ def _migrate_schema(cls, data: dict[str, Any]) -> dict[str, Any]:
160160
"Unsupported knowledge store schema version "
161161
f"{schema_version!r}. Supported versions: "
162162
f"{sorted(cls.SUPPORTED_SCHEMA_VERSIONS)}. "
163-
"Re-run `knowcode analyze` to rebuild persisted artifacts."
163+
"Re-run `knowcode build` to rebuild persisted artifacts."
164164
)
165165

166166
@staticmethod

src/knowcode/storage/vector_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def _validate_and_migrate_metadata(cls, data: dict[str, Any]) -> dict[str, Any]:
199199
"Unsupported vector index schema version "
200200
f"{schema_version!r}. Supported versions: "
201201
f"{sorted(cls.SUPPORTED_SCHEMA_VERSIONS)}. "
202-
"Rebuild with `knowcode index`."
202+
"Rebuild with `knowcode build`."
203203
)
204204

205205
@staticmethod

tests/unit/cli/test_doctor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def test_doctor_reports_missing_store_and_index(tmp_path: Path) -> None:
138138
failed = {check["name"]: check for check in payload["checks"] if check["status"] == "fail"}
139139
assert "Knowledge store" in failed
140140
assert "Semantic index" in failed
141-
assert "knowcode analyze" in failed["Knowledge store"]["hint"]
142-
assert "knowcode index" in failed["Semantic index"]["hint"]
141+
assert "knowcode build" in failed["Knowledge store"]["hint"]
142+
assert "knowcode build" in failed["Semantic index"]["hint"]
143143

144144

145145
def test_doctor_fails_on_index_dimension_mismatch(tmp_path: Path) -> None:

tests/unit/mcp/test_mcp_server_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def test_handle_tool_call_reports_missing_prerequisites(tmp_path: Path) -> None:
206206
result = json.loads(server.handle_tool_call("search_codebase", {"query": "Foo"}))
207207

208208
assert result["code"] == "missing_knowledge_store"
209-
assert "knowcode analyze" in result["hint"]
209+
assert "knowcode build" in result["hint"]
210210

211211

212212
def test_mcp_server_initializes_service_with_strict_config(

tests/unit/service/test_retrieve_context_for_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def test_retrieve_context_raises_when_store_missing(tmp_path: Path) -> None:
167167
with pytest.raises(MissingKnowledgeStoreError) as exc:
168168
service.retrieve_context_for_query("Explain e1", verbosity="diagnostic")
169169
assert exc.value.code == "missing_knowledge_store"
170-
assert "knowcode analyze" in exc.value.hint
170+
assert "knowcode build" in exc.value.hint
171171

172172

173173
def test_retrieve_context_raises_when_index_missing(tmp_path: Path) -> None:
@@ -177,7 +177,7 @@ def test_retrieve_context_raises_when_index_missing(tmp_path: Path) -> None:
177177
with pytest.raises(MissingSemanticIndexError) as exc:
178178
service.retrieve_context_for_query("Explain e1", verbosity="diagnostic")
179179
assert exc.value.code == "missing_semantic_index"
180-
assert "knowcode index" in exc.value.hint
180+
assert "knowcode build" in exc.value.hint
181181

182182

183183
def test_ensure_store_builds_only_when_missing(tmp_path: Path) -> None:

0 commit comments

Comments
 (0)