Add restart staleness warnings and resource listing improvements

write_file notes when agent.md or command files change; lazy stderr
warning (once per class per lifetime); /status reports stale fields;
resource listing adds parent entries for modules/ and connections/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
bernatsampera
2026-08-10 09:27:35 +02:00
co-authored by Claude Opus 4.6
parent 07c8b76906
commit d7226fce03
4 changed files with 151 additions and 6 deletions
+20
View File
@@ -83,6 +83,26 @@ def test_api_tree_excludes_machine_and_secret_files(client):
assert not any(p.startswith(".venv") for p in paths)
def test_status_reports_staleness(client, project):
import os
server.snapshot_startup_files()
stale = client.get("/status").json()["stale"]
assert stale == {"agent_md": False, "commands": False}
agent_md = project / "agent.md"
os.utime(agent_md, (agent_md.stat().st_mtime + 10,) * 2)
stale = client.get("/status").json()["stale"]
assert stale["agent_md"] is True
assert stale["commands"] is False
cmd = project / "modules" / "notes" / "commands" / "report.md"
cmd.parent.mkdir(parents=True)
cmd.write_text("---\ndescription: d\n---\nbody\n")
stale = client.get("/status").json()["stale"]
assert stale["commands"] is True
def test_api_events_limit_since_and_ring_cap(client):
for i in range(350):
server.record_event("s", "tool", f"tool{i}")
+26
View File
@@ -98,6 +98,32 @@ def test_new_file_without_parent_index_does_not_warn(project):
assert "Warning" not in out
def test_agent_md_write_notes_restart(project):
out = server.write_file("agent.md", "# Agent\nbe useful\n")
assert "Note: agent.md is pushed at connect" in out
assert "restart" in out
assert "Warning" not in out # agent.md stays exempt from the index check
def test_command_write_notes_restart(project):
out = server.write_file(
"connections/gmail/commands/send.md", "---\ndescription: d\n---\nbody\n"
)
assert "Note: commands are registered at server start" in out
out = server.write_file(
"modules/notes/commands/report.py", "# ---\n# description: d\n# ---\n"
)
assert "Note: commands are registered at server start" in out
# Not a command file: wrong folder or wrong extension.
assert "Note:" not in server.write_file("modules/notes/scripts/report.py", "x")
assert "Note:" not in server.write_file("modules/notes/commands/notes.txt", "x")
def test_ordinary_write_has_no_restart_note(project):
out = server.write_file("modules/notes/index.md", "summary")
assert "Note:" not in out
def test_write_new_file_reports_size_and_lines(project):
out = server.write_file("modules/notes/note.md", "one\ntwo\n")
assert out.startswith("Created: modules/notes/note.md")