create-theokit 0.2.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/package.json +5 -1
  2. package/templates/default/.env.example +5 -0
  3. package/templates/default/README.md.tmpl +71 -57
  4. package/templates/default/_gitignore +2 -3
  5. package/templates/default/app/layout.tsx +51 -82
  6. package/templates/default/app/page.tsx +169 -271
  7. package/templates/default/app.ts +23 -0
  8. package/templates/default/package.json.tmpl +10 -23
  9. package/templates/default/server/agents/assistant.agent.ts +46 -0
  10. package/templates/default/server/controllers/tasks.controller.ts +70 -0
  11. package/templates/default/server/filters/http-error.filter.ts +20 -0
  12. package/templates/default/server/guards/auth.guard.ts +47 -0
  13. package/templates/default/server/interceptors/timing.interceptor.ts +14 -0
  14. package/templates/default/server/middleware/logger.middleware.ts +12 -0
  15. package/templates/default/server/store.ts +46 -0
  16. package/templates/default/server/toolboxes/task.tools.ts +58 -0
  17. package/templates/default/tsconfig.json +7 -7
  18. package/templates/api-only/.nvmrc +0 -1
  19. package/templates/api-only/README.md.tmpl +0 -78
  20. package/templates/api-only/_gitignore +0 -5
  21. package/templates/api-only/app/page.tsx +0 -3
  22. package/templates/api-only/index.html +0 -12
  23. package/templates/api-only/package.json.tmpl +0 -28
  24. package/templates/api-only/public/.gitkeep +0 -0
  25. package/templates/api-only/public/favicon.ico +0 -0
  26. package/templates/api-only/server/routes/health.ts +0 -5
  27. package/templates/api-only/server/routes/users.ts +0 -27
  28. package/templates/api-only/server/routes/webhooks/echo.ts +0 -34
  29. package/templates/api-only/theo.config.ts +0 -3
  30. package/templates/api-only/tsconfig.json +0 -15
  31. package/templates/dashboard/.nvmrc +0 -1
  32. package/templates/dashboard/README.md.tmpl +0 -76
  33. package/templates/dashboard/_gitignore +0 -5
  34. package/templates/dashboard/app/about/page.tsx +0 -3
  35. package/templates/dashboard/app/dashboard/layout.tsx +0 -10
  36. package/templates/dashboard/app/dashboard/page.tsx +0 -3
  37. package/templates/dashboard/app/layout.tsx +0 -14
  38. package/templates/dashboard/app/page.tsx +0 -8
  39. package/templates/dashboard/index.html +0 -12
  40. package/templates/dashboard/package.json.tmpl +0 -28
  41. package/templates/dashboard/public/.gitkeep +0 -0
  42. package/templates/dashboard/public/favicon.ico +0 -0
  43. package/templates/dashboard/server/crons/cleanup-conversations.ts +0 -59
  44. package/templates/dashboard/server/routes/health.ts +0 -5
  45. package/templates/dashboard/theo.config.ts +0 -3
  46. package/templates/dashboard/tsconfig.json +0 -15
  47. package/templates/default/.nvmrc +0 -1
  48. package/templates/default/index.html +0 -12
  49. package/templates/default/public/.gitkeep +0 -0
  50. package/templates/default/public/favicon.ico +0 -0
  51. package/templates/default/server/crons/cleanup-conversations.ts +0 -59
  52. package/templates/default/server/routes/chat.ts +0 -69
  53. package/templates/default/server/routes/health.ts +0 -5
  54. package/templates/default/theo.config.ts +0 -3
  55. package/templates/default/types/jobs.d.ts +0 -25
  56. package/templates/postgres/.env.example +0 -5
  57. package/templates/postgres/.nvmrc +0 -1
  58. package/templates/postgres/README.md.tmpl +0 -83
  59. package/templates/postgres/_gitignore +0 -5
  60. package/templates/postgres/app/layout.tsx +0 -14
  61. package/templates/postgres/app/page.tsx +0 -8
  62. package/templates/postgres/db/index.ts +0 -7
  63. package/templates/postgres/db/schema.ts +0 -8
  64. package/templates/postgres/drizzle.config.ts +0 -10
  65. package/templates/postgres/index.html +0 -12
  66. package/templates/postgres/package.json.tmpl +0 -36
  67. package/templates/postgres/public/.gitkeep +0 -0
  68. package/templates/postgres/public/favicon.ico +0 -0
  69. package/templates/postgres/server/context.ts +0 -5
  70. package/templates/postgres/server/jobs/log-message.ts +0 -26
  71. package/templates/postgres/server/routes/health.ts +0 -5
  72. package/templates/postgres/server/routes/users.ts +0 -22
  73. package/templates/postgres/theo.config.ts +0 -3
  74. package/templates/postgres/tsconfig.json +0 -15
  75. package/templates/saas/.env.example +0 -7
  76. package/templates/saas/.nvmrc +0 -1
  77. package/templates/saas/README.md.tmpl +0 -103
  78. package/templates/saas/_gitignore +0 -5
  79. package/templates/saas/app/layout.tsx +0 -5
  80. package/templates/saas/app/page.tsx +0 -104
  81. package/templates/saas/db/index.ts +0 -6
  82. package/templates/saas/db/schema.ts +0 -20
  83. package/templates/saas/drizzle.config.ts +0 -10
  84. package/templates/saas/index.html +0 -12
  85. package/templates/saas/package.json.tmpl +0 -38
  86. package/templates/saas/public/.gitkeep +0 -0
  87. package/templates/saas/public/favicon.ico +0 -0
  88. package/templates/saas/server/context.ts +0 -37
  89. package/templates/saas/server/routes/agent.ts +0 -49
  90. package/templates/saas/server/routes/billing/stripe-webhook.ts +0 -49
  91. package/templates/saas/server/routes/login.ts +0 -25
  92. package/templates/saas/server/routes/logout.ts +0 -10
  93. package/templates/saas/server/routes/me.ts +0 -10
  94. package/templates/saas/theo.config.ts +0 -5
  95. package/templates/saas/tsconfig.json +0 -15
  96. package/templates/services/agent-node/Dockerfile.tmpl +0 -20
  97. package/templates/services/agent-node/README.md +0 -38
  98. package/templates/services/agent-node/package.json.tmpl +0 -18
  99. package/templates/services/agent-node/src/index.ts +0 -58
  100. package/templates/services/agent-node/tsconfig.json +0 -13
  101. package/templates/services/agent-python/Dockerfile.tmpl +0 -20
  102. package/templates/services/agent-python/README.md +0 -37
  103. package/templates/services/agent-python/main.py +0 -77
  104. package/templates/services/agent-python/pyproject.toml.tmpl +0 -16
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "lib": ["ES2022"],
10
- "types": ["node"]
11
- },
12
- "include": ["src/**/*.ts"]
13
- }
@@ -1,20 +0,0 @@
1
- FROM python:3.12-slim
2
-
3
- WORKDIR /app
4
-
5
- # Install uv (fast pip replacement)
6
- RUN pip install --no-cache-dir uv
7
-
8
- # Copy dependency manifest first (cache layer)
9
- COPY pyproject.toml ./
10
- RUN uv sync --no-dev --frozen || uv sync --no-dev
11
-
12
- # Copy source
13
- COPY . .
14
-
15
- EXPOSE 8001
16
-
17
- HEALTHCHECK --interval=10s --timeout=5s --retries=3 \
18
- CMD curl -f http://localhost:8001/health || exit 1
19
-
20
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8001", "--workers", "4"]
@@ -1,37 +0,0 @@
1
- # Agent service (Python / FastAPI)
2
-
3
- This is a TheoKit polyglot sidecar generated by `create-theokit --backend python`.
4
-
5
- ## Requirements
6
-
7
- - **Python 3.11+** (`pyproject.toml` requires it)
8
- - **uv** in PATH (https://github.com/astral-sh/uv)
9
-
10
- ## Run it
11
-
12
- The TheoKit app boots this service automatically via `pnpm dev` (per `theo.config.ts > services`).
13
-
14
- To run standalone:
15
-
16
- ```bash
17
- cd services/agent-python
18
- uv sync
19
- uv run uvicorn main:app --reload --port 8001
20
- ```
21
-
22
- ## Endpoints
23
-
24
- - `GET /health` — healthcheck (returns `{"status":"ok"}`)
25
- - `POST /echo` — example: `{ "message": "..." }` → `{ "echo": "..." }`
26
-
27
- ## What is wired
28
-
29
- - ASGI fetch-handler (works on TheoCloud K8s and local uvicorn)
30
- - JSON-line stdout logs
31
- - W3C `traceparent` propagation from incoming headers
32
- - TheoKit injects `THEOKIT_SERVICE_NAME` + `THEOKIT_SERVICE_PORT` env vars
33
-
34
- ## Add a tool the TheoKit agent can call
35
-
36
- Add another `@app.post("/tool/<name>")` endpoint. From the TheoKit TS side,
37
- `services.agent.<name>({...})` is auto-typed when the OpenAPI URL is reachable.
@@ -1,77 +0,0 @@
1
- """
2
- TheoKit polyglot agent service — FastAPI sidecar.
3
-
4
- Conforms to the Like-Vercel runtime contract (ADR-0015):
5
- - Fetch-handler entry (ASGI via uvicorn)
6
- - GET /health convention (200 / 503)
7
- - JSON-line stdout logs
8
- - W3C traceparent propagation
9
- - Env vars at runtime (not bundled)
10
-
11
- Generated by `create-theokit --backend python`.
12
- """
13
- import json
14
- import logging
15
- import os
16
- import sys
17
- from datetime import datetime, timezone
18
-
19
- from fastapi import FastAPI, Request
20
- from pydantic import BaseModel
21
-
22
-
23
- SERVICE_NAME = os.environ.get("THEOKIT_SERVICE_NAME", "agent-python")
24
- SERVICE_PORT = os.environ.get("THEOKIT_SERVICE_PORT", "8001")
25
-
26
-
27
- class JsonFormatter(logging.Formatter):
28
- """ADR-0015 invariant #5 — JSON-line stdout logging."""
29
-
30
- def format(self, record: logging.LogRecord) -> str:
31
- log_obj = {
32
- "timestamp": datetime.now(tz=timezone.utc).isoformat(),
33
- "level": record.levelname.lower(),
34
- "message": record.getMessage(),
35
- "service": SERVICE_NAME,
36
- }
37
- if hasattr(record, "traceparent"):
38
- log_obj["traceparent"] = getattr(record, "traceparent")
39
- return json.dumps(log_obj)
40
-
41
-
42
- handler = logging.StreamHandler(sys.stdout)
43
- handler.setFormatter(JsonFormatter())
44
- logging.basicConfig(level=logging.INFO, handlers=[handler])
45
- log = logging.getLogger("theokit.service")
46
-
47
-
48
- app = FastAPI(title=f"{SERVICE_NAME} agent service")
49
-
50
-
51
- @app.middleware("http")
52
- async def trace_middleware(request: Request, call_next):
53
- """ADR-0015 invariant #6 — W3C traceparent propagation."""
54
- traceparent = request.headers.get("traceparent")
55
- if traceparent:
56
- log.info(
57
- "request",
58
- extra={"traceparent": traceparent, "path": request.url.path},
59
- )
60
- response = await call_next(request)
61
- return response
62
-
63
-
64
- @app.get("/health")
65
- async def health() -> dict[str, str]:
66
- """ADR-0015 invariant #4 — healthcheck convention."""
67
- return {"status": "ok"}
68
-
69
-
70
- class EchoRequest(BaseModel):
71
- message: str
72
-
73
-
74
- @app.post("/echo")
75
- async def echo(req: EchoRequest) -> dict[str, str]:
76
- """Example endpoint — TheoKit proxies /api/agent/* to this service."""
77
- return {"echo": req.message}
@@ -1,16 +0,0 @@
1
- [project]
2
- name = "{{name}}-agent-python"
3
- version = "0.1.0"
4
- description = "TheoKit polyglot agent service (FastAPI sidecar)"
5
- requires-python = ">=3.11"
6
- dependencies = [
7
- "fastapi>=0.115",
8
- "uvicorn[standard]>=0.32",
9
- "pydantic>=2.9",
10
- ]
11
-
12
- [tool.uv]
13
- dev-dependencies = [
14
- "pytest>=8.0",
15
- "httpx>=0.28",
16
- ]