Skip to content

Commit 02d098f

Browse files
Move sync markers outside codeblock and strip codeblock fences in comparison
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/fe83eae1-2e6d-4e23-926b-9f9fdb6fdf37 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
1 parent 15912f3 commit 02d098f

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ External skills can be installed if they are not present — see the `usethis-sk
5959

6060
## Module Structure
6161

62-
```text
6362
<!-- sync:docs/module-tree.txt -->
63+
64+
```text
6465
usethis # usethis: Automate Python project setup and development tasks that are otherwise performed manually.
6566
├── __main__ # The CLI application for usethis.
6667
├── _config # Global configuration state for usethis.
@@ -247,9 +248,10 @@ usethis # usethis: Automate Python project setup and d
247248
├── tool # CLI commands for individual tool management.
248249
├── typecheck # CLI commands for type checking tools.
249250
└── version # CLI commands for displaying version information.
250-
<!-- /sync:docs/module-tree.txt -->
251251
```
252252

253+
<!-- /sync:docs/module-tree.txt -->
254+
253255
## Lessons
254256

255257
When you are working on a problem, you are almost always going to encounter a difficulty. This is great - it's an opportunity for learning. ALWAYS make a note explicitly of what lessons you are drawing as you complete a task or when receiving user feedback. Try and keep this structured: consider the root cause of the difficulty, and how you overcame it. After finishing work on a task, report back all your lessons. Finally, try and update the relevant skills with any new insights you've drawn, to help future agents, and/or create a new skill.

hooks/check-doc-sync.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
_SYNC_START = re.compile(r"^<!--\s*sync:(\S+)\s*-->$")
2020
# Pattern matches <!-- /sync:some/path --> and captures the path.
2121
_SYNC_END = re.compile(r"^<!--\s*/sync:(\S+)\s*-->$")
22+
# Pattern matches a markdown fenced code block opening (e.g. ```text).
23+
_CODEBLOCK_FENCE = re.compile(r"^```\w*$")
24+
25+
26+
def _strip_codeblock(text: str) -> str:
27+
"""Strip a surrounding markdown fenced code block, if present."""
28+
stripped = text.strip()
29+
lines = stripped.splitlines()
30+
if (
31+
len(lines) >= 2
32+
and _CODEBLOCK_FENCE.match(lines[0])
33+
and lines[-1].strip() == "```"
34+
):
35+
return "\n".join(lines[1:-1])
36+
return stripped
2237

2338

2439
def _find_sync_blocks(text: str) -> list[tuple[str, str]]:
@@ -80,7 +95,7 @@ def main() -> int:
8095

8196
expected = source.read_text(encoding="utf-8")
8297

83-
if actual_content.strip() != expected.strip():
98+
if _strip_codeblock(actual_content) != expected.strip():
8499
print(
85100
f"ERROR: Content in {path} between sync:{source_path} markers "
86101
f"is out of sync with {source}.",

0 commit comments

Comments
 (0)