Skip to content
Repos

DevPlaceApp

Python 3.1 KB65 lines Opens in site

Directory Raw Download

#!/usr/bin/env python3
# retoor <retoor@molodetz.nl>
"""Create a missing AGENTS.md in every project directory (never overwrites). Spec: SPEC.md DOC-01."""
import os
import sys

DESC = {
    "docs": "documentation: ADRs, inventories (normative sub-specs), runbooks",
    "docs/adr": "architecture decision records, immutable once accepted",
    "docs/inventory": "normative per-area inventories of the iOS app (strings, layout, flows)",
    "docs/runbooks": "operational runbooks (build, capture, release)",
    "docs/spec": "reserved for generated spec mirrors",
    "research": "one slug-named research doc per question with query log",
    "tools": "validators, hooks, smoke and purity scripts",
    "spec": "single-source constants headers (theme, limits, keys, strings)",
    "src": "application sources, layered core > net > model/api/store > ui > screens > app",
    "src/core": "result, json, date, url, log, assets, ui queue, timers",
    "src/net": "NetworkService and SocketSession over aiohttpcpp",
    "src/model": "domain models with tolerant JSON decoding",
    "src/api": "DevPlaceRequest, DevPlaceApi, Prod and Mock implementations",
    "src/store": "SettingsStore, SessionStore, AppState",
    "src/ui": "UI framework: canvas, text, views, layout, host, navigation, controls",
    "src/screens": "one Screen object per iOS screen (presenter plus view)",
    "src/app": "main, DevPlaceApp, routing, CLI",
    "tests": "test tiers mirroring src",
    "tests/unit": "unit tests",
    "tests/api": "tests against a local aiohttpcpp server",
    "tests/e2e": "headless host renders and scripted flows",
    "assets": "fonts, icons, app icon",
    "assets/fonts": "bundled fonts with licenses",
    "assets/icons": "Lucide icon set with license",
}

def main(root):
    skip = {".git", "build", "third_party", "node_modules"}
    made = []
    for base, dirs, _ in os.walk(root):
        dirs[:] = sorted(d for d in dirs if d not in skip and not d.startswith(".") and not d.startswith("build"))
        rel = os.path.relpath(base, root)
        if rel == ".":
            continue
        path = os.path.join(base, "AGENTS.md")
        if os.path.exists(path):
            continue
        parent = os.path.dirname(rel)
        parent_link = "../" * (rel.count("/") + 1) + "AGENTS.md" if parent == "" else "../AGENTS.md"
        parent_link = "../AGENTS.md"
        children = [d for d in dirs]
        lines = [
            "<!-- doc: %s/AGENTS.md | version: 1.0 | updated: 29-11-2026 -->" % rel,
            "# Agent instructions: %s" % rel,
            "",
            "Parent: [%s](%s). Owns: %s." % ("AGENTS.md", parent_link, DESC.get(rel, "files of this directory")),
            "",
            "- [hard] Follow the root rules; keep this directory within its stated purpose. Enforcer: review.",
        ]
        if children:
            lines += ["", "Children: " + ", ".join("[%s](%s/AGENTS.md)" % (c, c) for c in children) + "."]
        with open(path, "w", encoding="utf-8") as fh:
            fh.write("\n".join(lines) + "\n")
        made.append(rel)
    print("created", len(made), "AGENTS.md files")

if __name__ == "__main__":
    main(sys.argv[1] if len(sys.argv) > 1 else os.getcwd())
18.6ms