Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Dependencies

node_modules/
.yarn/

# Build outputs

dist/

# Development files

\*.log
.DS_Store

# IDE

.vscode/
.idea/

# Test files

tests/

# Cache files

.gemini-cache.json

# Git

.git/
.gitignore

# Documentation (not needed in image)

\*.md
!README.md

# Dev dependencies files

.prettierrc
.prettierignore

# GitHub workflows

.github/

# K8s config

k8s.yaml
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

calcit.cirru -diff linguist-generated
yarn.lock -diff linguist-generated
Cargo.lock -diff linguist-generated
lib -diff linguist-generated
65 changes: 65 additions & 0 deletions .github/workflows/docker-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Docker Build on PR

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "src/**"
- "package.json"
- "yarn.lock"
- "tsconfig.json"
- "Dockerfile"
- ".dockerignore"
- "store/**"
- "source/**"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=pr
type=sha,prefix=pr-

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Set retention policy
run: |
# This is a placeholder for setting retention policy
# GitHub Container Registry doesn't support direct retention policy via API
# The retention will be handled by GitHub's built-in retention policies
echo "Retention policy: PR images will be retained for 7 days"
58 changes: 58 additions & 0 deletions .github/workflows/docker-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker Build on Release

on:
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Set retention policy
run: |
# Release images are kept indefinitely by default
# This step documents the retention policy
echo "Retention policy: Release images will be retained for at least 1 year"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ dist/
*.log
.env
.DS_Store

source/

# Gemini file cache
.gemini-cache.json
# K8s secrets (contains API keys)
k8s-secrets.yaml
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
node_modules/
.gemini-cache.json
*.md
source/
store/
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 100,
"arrowParens": "always"
}
Empty file added 1
Empty file.
49 changes: 49 additions & 0 deletions APIs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Moonverse HTTP API

A minimal JSON API that replaces the previous MCP server. Supports async query tasks with polling. All responses are JSON.

## Endpoints

### Health

- `GET /healthz`
- **Response**: `{ "ok": true }`

### Create query task

- `POST /query`
- **Body**:

```json
{ "type": "docs" | "source", "query": "<question>" }
```

- **Responses**:
- `202 Accepted`: `{ "id": "<taskId>", "nextPollSec": 2 }`
- `400 Bad Request`: `{ "error": "..." }`

### Get query task status/result

- `GET /query/{id}`
- **Responses**:
- In progress: `{ "status": "queued" | "running", "etaSeconds": <int>, "nextPollSec": 2, "message": "Processing in background. Please poll again." }`
- Completed: `{ "status": "done", "content": "<answer>" }`
- Error: `{ "status": "error", "error": "<message>" }`
- Not found: `404 { "error": "task not found" }`

## Behavior

- Tasks execute asynchronously; clients should poll `GET /query/{id}` every ~2s using `nextPollSec` as a hint.
- Queries run against uploaded MoonBit files: `type=docs` uses `store/` files, `type=source` uses `source/` files.
- Supported file types for upload are `.md`, `.mbt`, `.json`, `.txt`.
- The server streams nothing; results are returned when ready.

## Environment

- `GEMINI_API_KEY` (required): Google Generative AI key.
- `PORT` (optional): defaults to 8080.

## Notes

- Health endpoint is for readiness checks.
- Ensure `store/` and `source/` folders exist with allowed files; otherwise responses will explain missing files.
Loading