diff --git a/README.md b/README.md index b49c02f..625ebd9 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ updateproject # every part updateproject backend # one part ``` -`newproject` asks for the parts, the backend language, the frontend framework and how the frontend is served, then hands over to each template's own questions. Every prompt has a flag for non-interactive use: +`newproject` asks for the description, the parts, the backend language, the frontend framework, how the frontend is served and the MCP servers for `.mcp.json`, then hands over to each template's own questions. Every prompt has a flag for non-interactive use: ```sh -newproject ~/projects/my-thing --parts backend,frontend,caddy --backend python --frontend svelte --serve bun --defaults +newproject ~/projects/my-thing --parts backend,frontend,caddy --backend python --frontend svelte --serve bun --mcp context7,svelte --defaults ``` `other` as the backend or the frontend renders the `blank` template: the part's compose files, Makefile and `.env.example` with no code, for a stack that has no template of its own, next to any other part. diff --git a/templates.py b/templates.py index 8b0bbf8..47ff170 100644 --- a/templates.py +++ b/templates.py @@ -18,6 +18,7 @@ BLANK = "blank" BACKENDS = {"python": "backend-python", "other": BLANK} FRONTENDS = {"svelte": "frontend-svelte", "other": BLANK} SERVE = ["bun", "static", "api"] +MCP = ["context7", "svelte"] def template(name: str) -> str: @@ -59,6 +60,7 @@ def new(args: argparse.Namespace) -> None: dest = Path(args.dest).resolve() name = args.name or ask_text("Project name", dest.name) slug = args.slug or ask_text("Slug", slugify(name)) + description = args.description if args.description is not None else ask_text("Description", name) parts = args.parts.split(",") if args.parts else ask_checkbox("Parts", ["backend", "frontend", "caddy"], ["backend", "frontend", "caddy"]) backend = frontend = None if "backend" in parts: @@ -69,6 +71,9 @@ def new(args: argparse.Namespace) -> None: if frontend and FRONTENDS[frontend] != BLANK: options = SERVE if backend else SERVE[:-1] serve = args.serve or ask_select("Frontend served by", options, "bun") + mcp_default = ["svelte"] if frontend and FRONTENDS[frontend] == "frontend-svelte" else [] + mcp = args.mcp.split(",") if args.mcp is not None else ask_checkbox("MCP servers", MCP, mcp_default) + mcp = [m for m in mcp if m] stack = [p for p in ("backend", "frontend") if p in parts] single = len(stack) == 1 routes = [r for r, ok in (("api", backend), ("frontend", frontend and serve != "api")) if ok] @@ -85,10 +90,12 @@ def new(args: argparse.Namespace) -> None: dest.mkdir(parents=True, exist_ok=True) identity = {"project_name": name, "project_slug": slug} - copy("infra", {"project_name": name, "layout": "single" if single else "parts", "parts": [] if single else stack}) + copy("infra", {"project_name": name, "project_description": description, "layout": "single" if single else "parts", + "parts": [] if single else stack, "mcp_servers": mcp}) layout = "root" if single else "part" if backend: - copy_part("backend", BACKENDS[backend], {"serve_spa": serve == "api", "author_name": git_config("user.name"), + copy_part("backend", BACKENDS[backend], {"project_description": description, "serve_spa": serve == "api", + "author_name": git_config("user.name"), "author_email": git_config("user.email")}) if frontend: copy_part("frontend", FRONTENDS[frontend], {"serve": serve}) @@ -240,10 +247,12 @@ def main() -> None: n.add_argument("dest") n.add_argument("--name") n.add_argument("--slug") + n.add_argument("--description") n.add_argument("--parts", help="comma-separated: backend,frontend,caddy") n.add_argument("--backend", choices=list(BACKENDS)) n.add_argument("--frontend", choices=list(FRONTENDS)) n.add_argument("--serve", choices=SERVE) + n.add_argument("--mcp", help="comma-separated: context7,svelte; empty for none") n.add_argument("--defaults", action="store_true", help="accept template defaults without asking") n.set_defaults(func=new) u = sub.add_parser("update", help="Update every part from its template")