create-theokit 0.4.0-beta.0 → 0.5.1

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 (108) hide show
  1. package/dist/cli.js +4 -3
  2. package/dist/cli.js.map +1 -1
  3. package/package.json +8 -4
  4. package/templates/default/.env.example +5 -0
  5. package/templates/default/README.md.tmpl +71 -57
  6. package/templates/default/_gitignore +2 -3
  7. package/templates/default/app/layout.tsx +51 -82
  8. package/templates/default/app/page.tsx +169 -271
  9. package/templates/default/app.ts +29 -0
  10. package/templates/default/package.json.tmpl +9 -23
  11. package/templates/default/public/index.html +70 -0
  12. package/templates/default/server/agents/assistant.agent.ts +46 -0
  13. package/templates/default/server/controllers/tasks.controller.ts +70 -0
  14. package/templates/default/server/filters/http-error.filter.ts +20 -0
  15. package/templates/default/server/guards/auth.guard.ts +47 -0
  16. package/templates/default/server/interceptors/timing.interceptor.ts +14 -0
  17. package/templates/default/server/middleware/logger.middleware.ts +12 -0
  18. package/templates/default/server/store.ts +46 -0
  19. package/templates/default/server/toolboxes/task.tools.ts +58 -0
  20. package/templates/default/tsconfig.json +7 -7
  21. package/LICENSE +0 -201
  22. package/templates/api-only/.nvmrc +0 -1
  23. package/templates/api-only/README.md.tmpl +0 -78
  24. package/templates/api-only/_gitignore +0 -5
  25. package/templates/api-only/app/page.tsx +0 -3
  26. package/templates/api-only/index.html +0 -12
  27. package/templates/api-only/package.json.tmpl +0 -28
  28. package/templates/api-only/public/.gitkeep +0 -0
  29. package/templates/api-only/public/favicon.ico +0 -0
  30. package/templates/api-only/server/routes/health.ts +0 -5
  31. package/templates/api-only/server/routes/users.ts +0 -27
  32. package/templates/api-only/server/routes/webhooks/echo.ts +0 -34
  33. package/templates/api-only/theo.config.ts +0 -3
  34. package/templates/api-only/tsconfig.json +0 -15
  35. package/templates/dashboard/.nvmrc +0 -1
  36. package/templates/dashboard/README.md.tmpl +0 -76
  37. package/templates/dashboard/_gitignore +0 -5
  38. package/templates/dashboard/app/about/page.tsx +0 -3
  39. package/templates/dashboard/app/dashboard/layout.tsx +0 -10
  40. package/templates/dashboard/app/dashboard/page.tsx +0 -3
  41. package/templates/dashboard/app/layout.tsx +0 -14
  42. package/templates/dashboard/app/page.tsx +0 -8
  43. package/templates/dashboard/index.html +0 -12
  44. package/templates/dashboard/package.json.tmpl +0 -28
  45. package/templates/dashboard/public/.gitkeep +0 -0
  46. package/templates/dashboard/public/favicon.ico +0 -0
  47. package/templates/dashboard/server/crons/cleanup-conversations.ts +0 -59
  48. package/templates/dashboard/server/routes/health.ts +0 -5
  49. package/templates/dashboard/theo.config.ts +0 -3
  50. package/templates/dashboard/tsconfig.json +0 -15
  51. package/templates/default/.nvmrc +0 -1
  52. package/templates/default/index.html +0 -12
  53. package/templates/default/public/.gitkeep +0 -0
  54. package/templates/default/public/favicon.ico +0 -0
  55. package/templates/default/server/crons/cleanup-conversations.ts +0 -59
  56. package/templates/default/server/routes/chat.ts +0 -69
  57. package/templates/default/server/routes/health.ts +0 -5
  58. package/templates/default/theo.config.ts +0 -3
  59. package/templates/default/types/jobs.d.ts +0 -25
  60. package/templates/postgres/.env.example +0 -5
  61. package/templates/postgres/.nvmrc +0 -1
  62. package/templates/postgres/README.md.tmpl +0 -83
  63. package/templates/postgres/_gitignore +0 -5
  64. package/templates/postgres/app/layout.tsx +0 -14
  65. package/templates/postgres/app/page.tsx +0 -8
  66. package/templates/postgres/db/index.ts +0 -7
  67. package/templates/postgres/db/schema.ts +0 -8
  68. package/templates/postgres/drizzle.config.ts +0 -10
  69. package/templates/postgres/index.html +0 -12
  70. package/templates/postgres/package.json.tmpl +0 -36
  71. package/templates/postgres/public/.gitkeep +0 -0
  72. package/templates/postgres/public/favicon.ico +0 -0
  73. package/templates/postgres/server/context.ts +0 -5
  74. package/templates/postgres/server/jobs/log-message.ts +0 -26
  75. package/templates/postgres/server/routes/health.ts +0 -5
  76. package/templates/postgres/server/routes/users.ts +0 -22
  77. package/templates/postgres/theo.config.ts +0 -3
  78. package/templates/postgres/tsconfig.json +0 -15
  79. package/templates/saas/.env.example +0 -7
  80. package/templates/saas/.nvmrc +0 -1
  81. package/templates/saas/README.md.tmpl +0 -103
  82. package/templates/saas/_gitignore +0 -5
  83. package/templates/saas/app/layout.tsx +0 -5
  84. package/templates/saas/app/page.tsx +0 -104
  85. package/templates/saas/db/index.ts +0 -6
  86. package/templates/saas/db/schema.ts +0 -20
  87. package/templates/saas/drizzle.config.ts +0 -10
  88. package/templates/saas/index.html +0 -12
  89. package/templates/saas/package.json.tmpl +0 -38
  90. package/templates/saas/public/.gitkeep +0 -0
  91. package/templates/saas/public/favicon.ico +0 -0
  92. package/templates/saas/server/context.ts +0 -37
  93. package/templates/saas/server/routes/agent.ts +0 -49
  94. package/templates/saas/server/routes/billing/stripe-webhook.ts +0 -49
  95. package/templates/saas/server/routes/login.ts +0 -25
  96. package/templates/saas/server/routes/logout.ts +0 -10
  97. package/templates/saas/server/routes/me.ts +0 -10
  98. package/templates/saas/theo.config.ts +0 -5
  99. package/templates/saas/tsconfig.json +0 -15
  100. package/templates/services/agent-node/Dockerfile.tmpl +0 -20
  101. package/templates/services/agent-node/README.md +0 -38
  102. package/templates/services/agent-node/package.json.tmpl +0 -18
  103. package/templates/services/agent-node/src/index.ts +0 -58
  104. package/templates/services/agent-node/tsconfig.json +0 -13
  105. package/templates/services/agent-python/Dockerfile.tmpl +0 -20
  106. package/templates/services/agent-python/README.md +0 -37
  107. package/templates/services/agent-python/main.py +0 -77
  108. package/templates/services/agent-python/pyproject.toml.tmpl +0 -16
@@ -1,5 +0,0 @@
1
- import { defineConfig } from 'theokit'
2
-
3
- export default defineConfig({
4
- ui: { theme: 'violet-forge', fonts: 'bundled' },
5
- })
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "strict": true,
8
- "jsx": "react-jsx",
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "noEmit": true,
12
- "allowImportingTsExtensions": false
13
- },
14
- "include": ["app", "server", "db"]
15
- }
@@ -1,20 +0,0 @@
1
- FROM node:22-alpine
2
-
3
- WORKDIR /app
4
-
5
- # Install pnpm (or use npm if pnpm not available in image)
6
- RUN corepack enable && corepack prepare pnpm@latest --activate || true
7
-
8
- # Copy manifest and install
9
- COPY package.json ./
10
- RUN pnpm install --frozen-lockfile || npm install
11
-
12
- # Copy source
13
- COPY . .
14
-
15
- EXPOSE 8002
16
-
17
- HEALTHCHECK --interval=10s --timeout=5s --retries=3 \
18
- CMD wget --spider -q http://localhost:8002/health || exit 1
19
-
20
- CMD ["pnpm", "start"]
@@ -1,38 +0,0 @@
1
- # Agent service (Node / Hono)
2
-
3
- This is a TheoKit polyglot sidecar generated by `create-theokit --backend node`.
4
-
5
- ## Requirements
6
-
7
- - **Node.js 22+** (matches TheoKit's floor)
8
- - **pnpm** or **npm** (TheoKit's CLI prefers pnpm)
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-node
18
- pnpm install
19
- pnpm dev
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
- - Native fetch handler via Hono (works on TheoCloud and local)
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>', ...)` handler. From the TheoKit TS side,
37
- `services.worker.<name>({...})` is auto-typed when an OpenAPI URL is reachable
38
- (Hey API integration — Phase 5).
@@ -1,18 +0,0 @@
1
- {
2
- "name": "{{name}}-agent-node",
3
- "private": true,
4
- "type": "module",
5
- "scripts": {
6
- "dev": "tsx watch src/index.ts",
7
- "start": "tsx src/index.ts",
8
- "build": "echo 'no build step; tsx runs TS directly'"
9
- },
10
- "dependencies": {
11
- "hono": "^4.6.0",
12
- "@hono/node-server": "^1.13.0"
13
- },
14
- "devDependencies": {
15
- "tsx": "^4.19.0",
16
- "typescript": "^5.7.0"
17
- }
18
- }
@@ -1,58 +0,0 @@
1
- /**
2
- * TheoKit polyglot agent service — Hono sidecar.
3
- *
4
- * Conforms to the Like-Vercel runtime contract (ADR-0015):
5
- * - Fetch-handler entry (native fetch handler from Hono)
6
- * - GET /health convention (200 / 503)
7
- * - JSON-line stdout logs
8
- * - W3C traceparent propagation
9
- * - Env vars at runtime
10
- *
11
- * Generated by `create-theokit --backend node`.
12
- */
13
- import { Hono } from 'hono'
14
- import { serve } from '@hono/node-server'
15
-
16
- const SERVICE_NAME = process.env.THEOKIT_SERVICE_NAME ?? 'agent-node'
17
- const SERVICE_PORT = Number.parseInt(process.env.THEOKIT_SERVICE_PORT ?? '8002', 10)
18
-
19
- function log(
20
- level: 'info' | 'warn' | 'error',
21
- message: string,
22
- extra: Record<string, unknown> = {},
23
- ) {
24
- // eslint-disable-next-line no-console -- structured stdout per ADR-0015 invariant #5
25
- console.log(
26
- JSON.stringify({
27
- timestamp: new Date().toISOString(),
28
- level,
29
- message,
30
- service: SERVICE_NAME,
31
- ...extra,
32
- }),
33
- )
34
- }
35
-
36
- const app = new Hono()
37
-
38
- // ADR-0015 invariant #6 — W3C traceparent propagation
39
- app.use(async (c, next) => {
40
- const tp = c.req.header('traceparent')
41
- if (tp) {
42
- log('info', 'request', { traceparent: tp, path: c.req.path })
43
- }
44
- await next()
45
- })
46
-
47
- // ADR-0015 invariant #4 — healthcheck convention
48
- app.get('/health', (c) => c.json({ status: 'ok' }))
49
-
50
- // Example endpoint — TheoKit proxies /api/worker/* to this service.
51
- app.post('/echo', async (c) => {
52
- const body = (await c.req.json()) as { message: string }
53
- return c.json({ echo: body.message })
54
- })
55
-
56
- serve({ fetch: app.fetch, port: SERVICE_PORT }, () => {
57
- log('info', `agent-node listening on :${String(SERVICE_PORT)}`)
58
- })
@@ -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
- ]