diff --git a/.demohunter/.gitignore b/.demohunter/.gitignore new file mode 100644 index 0000000..63c8969 --- /dev/null +++ b/.demohunter/.gitignore @@ -0,0 +1,3 @@ +# Managed by DemoHunter. Delete this file and the directory to opt out. +* +!.gitignore diff --git a/.env.example b/.env.example index b0f3052..f255077 100644 --- a/.env.example +++ b/.env.example @@ -52,3 +52,10 @@ SPOTIFY_CLIENT_ID=your_spotify_client_id_here SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here SPOTIFY_REFRESH_TOKEN=your_spotify_refresh_token_here # Get this once, use forever +# Private Life UI (server-only; provision all six together) +LIFE_API_BASE_URL=https://life-api.example.com +LIFE_USER_TOKEN=replace_with_a_dedicated_high_entropy_owner_token +LIFE_EXPECTED_OWNER_ID=00000000-0000-4000-8000-000000000000 +LIFE_UI_PASSWORD_HASH=$scrypt$v=1$N=32768,r=8,p=1$base64url_salt$base64url_hash +LIFE_UI_SESSION_SECRET=replace_with_at_least_32_random_characters +LIFE_UI_ORIGIN=https://addcommitpush.io diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d29d3a3..7853373 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Deploy to Vercel +name: Deploy on: push: @@ -7,16 +7,20 @@ on: pull_request: concurrency: - group: vercel-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: deploy-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read - pull-requests: write jobs: - deploy: + deploy-preview: + name: Vercel preview + if: github.event_name == 'pull_request' runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write env: VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} @@ -34,17 +38,15 @@ jobs: uses: actions/setup-node@v4 with: node-version: '20' - cache: 'pnpm' + cache: pnpm - - name: Deploy Preview (PR) - if: github.event_name == 'pull_request' + - name: Deploy preview id: deploy_preview run: | bash scripts/deploy-vercel.sh preview --output .vercel/preview-url.txt echo "url=$(tail -n1 .vercel/preview-url.txt | tr -d '\n')" >> "$GITHUB_OUTPUT" - - name: Comment Preview URL on PR - if: github.event_name == 'pull_request' + - name: Comment preview URL uses: actions/github-script@v7 with: script: | @@ -59,7 +61,174 @@ jobs: env: url: ${{ steps.deploy_preview.outputs.url }} - - name: Deploy Production (main push) - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + deploy-backend: + name: GCP backend + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + timeout-minutes: 45 + permissions: + contents: read + id-token: write + outputs: + api_url: ${{ steps.deployment_outputs.outputs.api_url }} + owner_id: ${{ steps.deployment_outputs.outputs.owner_id }} + env: + GCP_PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} + GCP_REGION: ${{ vars.GCP_REGION }} + PULUMI_BACKEND_URL: ${{ vars.PULUMI_BACKEND_URL }} + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.33.2 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Authenticate to Google Cloud + id: gcp_auth + uses: google-github-actions/auth@v3 + with: + project_id: ${{ vars.GCP_PROJECT_ID }} + workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ vars.GCP_DEPLOY_SERVICE_ACCOUNT }} + token_format: access_token + access_token_lifetime: 3600s + + - name: Setup Google Cloud + uses: google-github-actions/setup-gcloud@v3 + + - name: Configure Artifact Registry authentication + run: gcloud auth configure-docker "$GCP_REGION-docker.pkg.dev" --quiet + env: + CLOUDSDK_AUTH_ACCESS_TOKEN: ${{ steps.gcp_auth.outputs.access_token }} + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Setup Pulumi + uses: pulumi/actions@v7 + with: + pulumi-version: 3.254.0 + + - name: Apply infrastructure and deploy image + working-directory: infra + env: + CLOUDSDK_AUTH_ACCESS_TOKEN: ${{ steps.gcp_auth.outputs.access_token }} + GOOGLE_OAUTH_ACCESS_TOKEN: ${{ steps.gcp_auth.outputs.access_token }} + run: | + pulumi login "$PULUMI_BACKEND_URL" + pulumi stack select production + pulumi up --yes --skip-preview --suppress-outputs + + - name: Read deployment outputs + id: deployment_outputs + working-directory: infra + env: + GOOGLE_OAUTH_ACCESS_TOKEN: ${{ steps.gcp_auth.outputs.access_token }} + run: | + { + echo "api_url=$(pulumi stack output lifeApiUrl)" + echo "owner_id=$(pulumi stack output lifeOwnerId)" + echo "provision_job=$(pulumi stack output lifeProvisionJob)" + } >> "$GITHUB_OUTPUT" + + - name: Migrate and provision owner + env: + CLOUDSDK_AUTH_ACCESS_TOKEN: ${{ steps.gcp_auth.outputs.access_token }} + run: | + gcloud run jobs execute "${{ steps.deployment_outputs.outputs.provision_job }}" \ + --project="$GCP_PROJECT_ID" \ + --region="$GCP_REGION" \ + --wait + + - name: Verify deployed API + env: + CLOUDSDK_AUTH_ACCESS_TOKEN: ${{ steps.gcp_auth.outputs.access_token }} + LIFE_API_BASE_URL: ${{ steps.deployment_outputs.outputs.api_url }} + LIFE_EXPECTED_OWNER_ID: ${{ steps.deployment_outputs.outputs.owner_id }} run: | - bash scripts/deploy-vercel.sh production + curl \ + --fail \ + --silent \ + --show-error \ + --retry 10 \ + --retry-all-errors \ + --retry-delay 5 \ + --max-time 300 \ + "$LIFE_API_BASE_URL/readyz" >/dev/null + life_user_token="$(gcloud secrets versions access latest \ + --project="$GCP_PROJECT_ID" --secret=life-user-token)" + actual_owner_id="$(curl \ + --fail \ + --silent \ + --show-error \ + --retry 5 \ + --retry-all-errors \ + --retry-delay 2 \ + --max-time 120 \ + --header "Authorization: Bearer $life_user_token" \ + "$LIFE_API_BASE_URL/v1/owner" | jq --raw-output '.id')" + unset life_user_token + test "$actual_owner_id" = "$LIFE_EXPECTED_OWNER_ID" + + deploy-production: + name: Vercel production + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: deploy-backend + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + env: + GCP_PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} + LIFE_API_BASE_URL: ${{ needs.deploy-backend.outputs.api_url }} + LIFE_EXPECTED_OWNER_ID: ${{ needs.deploy-backend.outputs.owner_id }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.33.2 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: pnpm + + - name: Authenticate to Google Cloud + id: gcp_auth + uses: google-github-actions/auth@v3 + with: + project_id: ${{ vars.GCP_PROJECT_ID }} + workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ vars.GCP_DEPLOY_SERVICE_ACCOUNT }} + token_format: access_token + access_token_lifetime: 3600s + + - name: Setup Google Cloud + uses: google-github-actions/setup-gcloud@v3 + + - name: Synchronize Life server configuration + env: + CLOUDSDK_AUTH_ACCESS_TOKEN: ${{ steps.gcp_auth.outputs.access_token }} + run: bash scripts/sync-life-vercel-env.sh + + - name: Deploy production + run: bash scripts/deploy-vercel.sh production diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..05f5358 --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,95 @@ +name: Quality + +on: + pull_request: + push: + branches: + - main + +concurrency: + group: quality-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + web: + name: Web checks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.33.2 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Check formatting + run: pnpm format:check + + - name: Lint + run: pnpm lint + + - name: Typecheck + run: pnpm typecheck + + - name: Check Life contracts + run: pnpm check:life-contracts + + - name: Check Life Realtime protocol + run: pnpm check:life-realtime + + life-backend: + name: Life backend checks + runs-on: ubuntu-latest + services: + postgres: + image: pgvector/pgvector:pg18 + env: + POSTGRES_DB: postgres + POSTGRES_USER: life + POSTGRES_PASSWORD: life + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U life -d postgres" + --health-interval 2s + --health-timeout 3s + --health-retries 20 + defaults: + run: + working-directory: life + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: 1.96.0 + components: rustfmt, clippy + + - name: Check formatting + run: cargo fmt --check + + - name: Lint + run: cargo clippy --all-targets --all-features --locked -- -D warnings + + - name: Test with PostgreSQL + env: + LIFE_TEST_DATABASE_URL: postgres://life:life@localhost:5432/postgres + run: cargo test --all-targets --all-features --locked + + - name: Build release container + run: docker build --tag life-agent:test . diff --git a/.gitignore b/.gitignore index 9bcecf0..fbd429c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ # testing /coverage +/.context/ +/.playwright-cli/ # next.js /.next/ @@ -23,6 +25,7 @@ # misc .DS_Store *.pem +gha-creds-*.json # debug npm-debug.log* @@ -68,3 +71,5 @@ tmp # Rust build output dr/target/ +/life/target/ +/life/.env diff --git a/Makefile b/Makefile index e59e8f9..1de0c5b 100644 --- a/Makefile +++ b/Makefile @@ -107,7 +107,7 @@ check: format-check lint test build ## Run all checks (format, lint, test, build # Utility Commands # ============================================================================ -.PHONY: clean setup run-researcher start-blog install-dr +.PHONY: clean setup life run-researcher start-blog install-dr clean: ## Clean build artifacts cd $(RESEARCHER_DIR) && rm -f research research-* *.test @@ -118,6 +118,9 @@ setup: ## Set up the project (install dependencies) pnpm install cd $(RESEARCHER_DIR) && go mod download +life: ## Run the Life UI locally against the live Cloud Run backend + bash scripts/run-life-local.sh + run-researcher: ## Run researcher application cd $(RESEARCHER_DIR) && go run ./cmd/research diff --git a/app/(life)/life/(authenticated)/conversations/[id]/page.tsx b/app/(life)/life/(authenticated)/conversations/[id]/page.tsx new file mode 100644 index 0000000..e780dfe --- /dev/null +++ b/app/(life)/life/(authenticated)/conversations/[id]/page.tsx @@ -0,0 +1,73 @@ +import Link from 'next/link'; +import { ConversationComposer } from '@/components/life/conversation-composer'; +import { LifePageHeader } from '@/components/life/page-header'; +import { MarkdownContent } from '@/components/life/markdown-content'; +import { Badge } from '@/components/ui/badge'; +import { uuidSchema } from '@/lib/life/contracts'; +import { enumLabel, formatInOwnerTimezone } from '@/lib/life/formatting'; +import { getConversationDetail, getOwner } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function ConversationDetailPage({ + params, +}: { + params: Promise<{ id: string }>; +}) { + const id = uuidSchema.parse((await params).id); + const [owner, detail] = await Promise.all([getOwner(), getConversationDetail(id)]); + const { conversation, messages } = detail; + + return ( +
+ {enumLabel(conversation.status)}} + /> +
+ {messages.map((message) => ( +
+
+ + {enumLabel(message.role)} · {enumLabel(message.input_modality)} + + +
+ {message.content} + {message.cited_memory_ids.length > 0 && ( +
+

Cited memories

+
+ {message.cited_memory_ids.map((memoryId) => ( + + {memoryId} + + ))} +
+
+ )} +
+ ))} + {messages.length === 0 && ( +

+ This conversation has no committed messages. +

+ )} +
+ {conversation.status === 'active' && ( + + )} +
+ ); +} diff --git a/app/(life)/life/(authenticated)/conversations/page.tsx b/app/(life)/life/(authenticated)/conversations/page.tsx new file mode 100644 index 0000000..198223f --- /dev/null +++ b/app/(life)/life/(authenticated)/conversations/page.tsx @@ -0,0 +1,39 @@ +import Link from 'next/link'; +import { LifePageHeader } from '@/components/life/page-header'; +import { formatInOwnerTimezone } from '@/lib/life/formatting'; +import { getOwner, listConversations } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function ConversationsPage() { + const [owner, conversations] = await Promise.all([getOwner(), listConversations()]); + return ( +
+ +
+ {conversations.map((conversation) => ( + +

{conversation.title}

+

+ Created {formatInOwnerTimezone(conversation.created_at, owner.timezone)} · Updated{' '} + {formatInOwnerTimezone(conversation.updated_at, owner.timezone)} +

+ + ))} + {conversations.length === 0 && ( +

No durable conversations yet.

+ )} +
+
+ ); +} diff --git a/app/(life)/life/(authenticated)/layout.tsx b/app/(life)/life/(authenticated)/layout.tsx new file mode 100644 index 0000000..7ffa8ae --- /dev/null +++ b/app/(life)/life/(authenticated)/layout.tsx @@ -0,0 +1,19 @@ +import type React from 'react'; +import { redirect } from 'next/navigation'; +import { LifeShell } from '@/components/life/life-shell'; +import { LifeSessionError, requireLifeSession } from '@/lib/life/session.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function AuthenticatedLifeLayout({ + children, +}: Readonly<{ children: React.ReactNode }>) { + try { + await requireLifeSession(); + } catch (error) { + if (error instanceof LifeSessionError) redirect('/life/login'); + throw error; + } + return {children}; +} diff --git a/app/(life)/life/(authenticated)/memories/[id]/page.tsx b/app/(life)/life/(authenticated)/memories/[id]/page.tsx new file mode 100644 index 0000000..298bb15 --- /dev/null +++ b/app/(life)/life/(authenticated)/memories/[id]/page.tsx @@ -0,0 +1,47 @@ +import { EpistemicBadge } from '@/components/life/badges'; +import { LifePageHeader } from '@/components/life/page-header'; +import { MarkdownContent } from '@/components/life/markdown-content'; +import { MemoryActions } from '@/components/life/memory-actions'; +import { uuidSchema } from '@/lib/life/contracts'; +import { enumLabel, formatInOwnerTimezone, formatMemoryTime } from '@/lib/life/formatting'; +import { getMemory, getOwner } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function MemoryDetailPage({ params }: { params: Promise<{ id: string }> }) { + const id = uuidSchema.parse((await params).id); + const [owner, memory] = await Promise.all([getOwner(), getMemory(id)]); + + return ( +
+ } + /> + +
+ {memory.body_markdown} +
+ +
+ + + +
+ + +
+ ); +} + +function Meta({ label, value }: { label: string; value: string }) { + return ( +
+
{label}
+
{value}
+
+ ); +} diff --git a/app/(life)/life/(authenticated)/memories/page.tsx b/app/(life)/life/(authenticated)/memories/page.tsx new file mode 100644 index 0000000..7b4abd0 --- /dev/null +++ b/app/(life)/life/(authenticated)/memories/page.tsx @@ -0,0 +1,74 @@ +import Link from 'next/link'; +import { LifePageHeader } from '@/components/life/page-header'; +import { MemoryCard } from '@/components/life/memory-card'; +import { MemoryForm } from '@/components/life/memory-form'; +import { MemorySearch } from '@/components/life/memory-search'; +import { getOwner, listMemories } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +function first(value: string | string[] | undefined): string | undefined { + return typeof value === 'string' ? value : undefined; +} + +export default async function MemoriesPage({ + searchParams, +}: { + searchParams: Promise>; +}) { + const parameters = await searchParams; + const offsetValue = Number(first(parameters.offset) ?? '0'); + const offset = Number.isInteger(offsetValue) && offsetValue >= 0 ? offsetValue : 0; + const [owner, page] = await Promise.all([getOwner(), listMemories({ limit: 24, offset })]); + + return ( +
+ + + + +
+

All memories

+
+ {page.map((memory) => ( + + ))} +
+ {page.length === 0 && ( +

No memories yet.

+ )} +
+ {offset > 0 ? ( + + Previous page + + ) : ( + + )} + {page.length === 24 && ( + + Next page + + )} +
+
+ +
+ + Create a manual memory + +

+ Times are interpreted in {owner.timezone}. +

+
+ +
+
+
+ ); +} diff --git a/app/(life)/life/(authenticated)/page.tsx b/app/(life)/life/(authenticated)/page.tsx new file mode 100644 index 0000000..cb6bbee --- /dev/null +++ b/app/(life)/life/(authenticated)/page.tsx @@ -0,0 +1,8 @@ +import { redirect } from 'next/navigation'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default function LifePage() { + redirect('/life/voice'); +} diff --git a/app/(life)/life/(authenticated)/settings/connectors/page.tsx b/app/(life)/life/(authenticated)/settings/connectors/page.tsx new file mode 100644 index 0000000..fb1b841 --- /dev/null +++ b/app/(life)/life/(authenticated)/settings/connectors/page.tsx @@ -0,0 +1,32 @@ +import { ConnectorList } from '@/components/life/connector-list'; +import { LifePageHeader } from '@/components/life/page-header'; +import type { ConnectorView } from '@/lib/life/contracts'; +import { getOwner, listConnectors } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function ConnectorsPage() { + const [owner, connectors] = await Promise.all([getOwner(), listConnectors()]); + const views: ConnectorView[] = connectors + .filter((connector) => connector.status !== 'revoked') + .map((connector) => ({ + id: connector.id, + provider: connector.provider, + label: connector.label, + external_account_name: connector.external_account_name, + status: connector.status, + last_synced_at: connector.last_synced_at, + has_error: connector.last_error !== null, + })); + return ( +
+ + +
+ ); +} diff --git a/app/(life)/life/(authenticated)/settings/data/page.tsx b/app/(life)/life/(authenticated)/settings/data/page.tsx new file mode 100644 index 0000000..8069070 --- /dev/null +++ b/app/(life)/life/(authenticated)/settings/data/page.tsx @@ -0,0 +1,18 @@ +import { DataExport } from '@/components/life/data-export'; +import { LifePageHeader } from '@/components/life/page-header'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default function DataSettingsPage() { + return ( +
+ + +
+ ); +} diff --git a/app/(life)/life/(authenticated)/settings/page.tsx b/app/(life)/life/(authenticated)/settings/page.tsx new file mode 100644 index 0000000..06b0d49 --- /dev/null +++ b/app/(life)/life/(authenticated)/settings/page.tsx @@ -0,0 +1,62 @@ +import Link from 'next/link'; +import { Database, Plug } from 'lucide-react'; +import { LifePageHeader } from '@/components/life/page-header'; +import { SettingsForm } from '@/components/life/settings-form'; +import { getOwner } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function SettingsPage() { + const owner = await getOwner(); + return ( +
+ + + +
+ ); +} + +function SettingsLink({ + href, + title, + description, + icon: Icon, +}: { + href: string; + title: string; + description: string; + icon: typeof Plug; +}) { + return ( + + + + {description} + + ); +} diff --git a/app/(life)/life/(authenticated)/timeline/page.tsx b/app/(life)/life/(authenticated)/timeline/page.tsx new file mode 100644 index 0000000..7338f5f --- /dev/null +++ b/app/(life)/life/(authenticated)/timeline/page.tsx @@ -0,0 +1,21 @@ +import { LifePageHeader } from '@/components/life/page-header'; +import { TimelineRail } from '@/components/life/timeline-rail'; +import { getOwner, getTimeline } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function TimelinePage() { + const [owner, memories] = await Promise.all([getOwner(), getTimeline({ limit: 500 })]); + + return ( +
+ + +
+ ); +} diff --git a/app/(life)/life/(authenticated)/voice/page.tsx b/app/(life)/life/(authenticated)/voice/page.tsx new file mode 100644 index 0000000..844f5f8 --- /dev/null +++ b/app/(life)/life/(authenticated)/voice/page.tsx @@ -0,0 +1,29 @@ +import { LifePageHeader } from '@/components/life/page-header'; +import { VoiceSession } from '@/components/life/voice/voice-session'; +import { getOwner } from '@/lib/life/queries.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export default async function VoicePage() { + const owner = await getOwner(); + const hour = Number( + new Intl.DateTimeFormat('en-US', { + timeZone: owner.timezone, + hour: '2-digit', + hourCycle: 'h23', + }).format(new Date()) + ); + const defaultTitle = + hour < 12 ? 'Morning reflection' : hour < 18 ? 'Afternoon conversation' : 'Evening reflection'; + return ( +
+ + +
+ ); +} diff --git a/app/(life)/life/error.tsx b/app/(life)/life/error.tsx new file mode 100644 index 0000000..0215bbd --- /dev/null +++ b/app/(life)/life/error.tsx @@ -0,0 +1,20 @@ +'use client'; + +import { LifeErrorPanel } from '@/components/life/error-panel'; +import { Button } from '@/components/ui/button'; + +export default function LifeError({ reset }: { reset: () => void }) { + return ( +
+ +
+ + +
+
+ ); +} diff --git a/app/(life)/life/layout.tsx b/app/(life)/life/layout.tsx new file mode 100644 index 0000000..57acc50 --- /dev/null +++ b/app/(life)/life/layout.tsx @@ -0,0 +1,15 @@ +import type { Metadata } from 'next'; +import type React from 'react'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export const metadata: Metadata = { + title: 'Life', + description: 'Private Life workspace', + robots: { index: false, follow: false, nocache: true }, +}; + +export default function LifeLayout({ children }: Readonly<{ children: React.ReactNode }>) { + return
{children}
; +} diff --git a/app/(life)/life/login/page.tsx b/app/(life)/life/login/page.tsx new file mode 100644 index 0000000..152ea90 --- /dev/null +++ b/app/(life)/life/login/page.tsx @@ -0,0 +1,37 @@ +import { redirect } from 'next/navigation'; +import { LifeLoginForm } from '@/components/life/login-form'; +import { getLifeSession } from '@/lib/life/session.server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +function safeNextPath(value: string | string[] | undefined): string { + if (typeof value !== 'string' || value.startsWith('//')) return '/life'; + const parsed = new URL(value, 'https://life.invalid'); + if ( + parsed.origin !== 'https://life.invalid' || + (parsed.pathname !== '/life' && !parsed.pathname.startsWith('/life/')) + ) { + return '/life'; + } + return `${parsed.pathname}${parsed.search}${parsed.hash}`; +} + +export default async function LifeLoginPage({ + searchParams, +}: { + searchParams: Promise<{ next?: string | string[] }>; +}) { + const nextPath = safeNextPath((await searchParams).next); + if (await getLifeSession()) redirect(nextPath); + + return ( +
+
+

Private workspace

+

Life

+ +
+
+ ); +} diff --git a/app/(pages)/about/page.tsx b/app/(public)/about/page.tsx similarity index 100% rename from app/(pages)/about/page.tsx rename to app/(public)/about/page.tsx diff --git a/app/blog/[slug]/page.tsx b/app/(public)/blog/[slug]/page.tsx similarity index 100% rename from app/blog/[slug]/page.tsx rename to app/(public)/blog/[slug]/page.tsx diff --git a/app/brain/[slug]/page.tsx b/app/(public)/brain/[slug]/page.tsx similarity index 100% rename from app/brain/[slug]/page.tsx rename to app/(public)/brain/[slug]/page.tsx diff --git a/app/brain/page.tsx b/app/(public)/brain/page.tsx similarity index 100% rename from app/brain/page.tsx rename to app/(public)/brain/page.tsx diff --git a/app/(public)/layout.tsx b/app/(public)/layout.tsx new file mode 100644 index 0000000..1ead1b6 --- /dev/null +++ b/app/(public)/layout.tsx @@ -0,0 +1,80 @@ +import type { Metadata } from 'next'; +import type React from 'react'; +import { Suspense } from 'react'; +import { PostHogPageView } from '@/app/posthog-pageview'; +import { PHProvider } from '@/app/providers'; +import { Navigation } from '@/components/navigation'; +import { feedAlternates, siteConfig } from '@/lib/site'; + +export const metadata: Metadata = { + metadataBase: new URL(siteConfig.url), + title: { + default: siteConfig.title, + template: '%s | addcommitpush.io', + }, + description: siteConfig.description, + alternates: { types: feedAlternates }, + icons: { + icon: [{ url: '/icon' }], + apple: [{ url: '/apple-icon' }], + }, + openGraph: { + title: siteConfig.title, + description: siteConfig.description, + siteName: siteConfig.name, + type: 'website', + }, + twitter: { + card: 'summary', + title: siteConfig.title, + description: siteConfig.description, + }, +}; + +const personJsonLd = { + '@context': 'https://schema.org', + '@type': 'Person', + name: 'Emil Wåreus', + url: `${siteConfig.url}/about`, + jobTitle: 'Head of Engineering and Research', + sameAs: [ + 'https://github.com/emilwareus', + 'https://twitter.com/emilwareus', + 'https://www.linkedin.com/in/emilwareus/', + ], +}; + +const websiteJsonLd = { + '@context': 'https://schema.org', + '@type': 'WebSite', + name: siteConfig.name, + url: siteConfig.url, + author: { + '@type': 'Person', + name: 'Emil Wåreus', + }, +}; + +export default function PublicLayout({ children }: Readonly<{ children: React.ReactNode }>) { + return ( + <> +