Skip to content

Commit f84259b

Browse files
Paul Kyleclaude
andcommitted
polish: fix CLI display keys, safe git staging, FastAPI lifespan
- CLI save: read file_path (not file) from API response - CLI trigger list: read memory_file (not file) from store - git_tools push(): stage only *.md instead of git add -A - Migrate @app.on_event('startup') to lifespan context manager - Tests: 92 passed, 0 warnings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 06ce489 commit f84259b

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

palinode/api/server.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from datetime import UTC, datetime
2121
from typing import Any
2222

23+
from contextlib import asynccontextmanager
24+
2325
from fastapi import FastAPI, HTTPException
2426
from pydantic import BaseModel
2527

@@ -51,7 +53,13 @@ def format(self, record: logging.LogRecord) -> str:
5153
fh.setFormatter(JsonlFormatter())
5254
logger.addHandler(fh)
5355

54-
app = FastAPI(title="Palinode API")
56+
@asynccontextmanager
57+
async def lifespan(app: FastAPI):
58+
"""Initialize database on startup."""
59+
store.init_db()
60+
yield
61+
62+
app = FastAPI(title="Palinode API", lifespan=lifespan)
5563

5664
# ── Auto-summary helpers ──────────────────────────────────────────────────────
5765

@@ -145,11 +153,6 @@ def _inject_summary(file_path: str, summary: str) -> None:
145153

146154
# ─────────────────────────────────────────────────────────────────────────────
147155

148-
@app.on_event("startup")
149-
def on_startup() -> None:
150-
"""Initializes local filesystem database routines during FastAPI boot."""
151-
store.init_db()
152-
153156

154157
class SearchRequest(BaseModel):
155158
query: str

palinode/cli/save.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def save(content, memory_type, entities, file_path, title, source, fmt):
3030
if output_fmt == OutputFormat.JSON:
3131
print_result(result, fmt=output_fmt)
3232
else:
33-
filename = result.get("file", "unknown")
33+
filename = result.get("file_path", result.get("file", "unknown"))
3434
id_str = result.get("id", "unknown")
3535
console.print(f"[green]Saved:[/green] {filename} (id: {id_str})")
3636

palinode/cli/trigger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def trigger_list(fmt):
5252
table.add_row(
5353
t['id'],
5454
t['description'],
55-
t['file'],
55+
t.get('memory_file', t.get('file', '')),
5656
f"{t['threshold']:.2f}"
5757
)
5858

palinode/core/git_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ def push() -> str:
289289
# Check if there are unpushed commits
290290
status = _run_git("status", "--porcelain")
291291
if status.stdout.strip():
292-
# Auto-commit any uncommitted changes first
293-
_run_git("add", "-A")
292+
# Auto-commit any uncommitted changes first (only markdown, not journals)
293+
_run_git("add", "*.md", "**/*.md")
294294
_run_git("commit", "-m", f"palinode: auto-commit before push ({_utc_now().strftime('%Y-%m-%d %H:%M')})")
295295

296296
result = _run_git("push", "origin", "main")

0 commit comments

Comments
 (0)