Skip to content
Draft
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
46 changes: 44 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
shell: bash

- name: Prettier
run: npm run format:check
run: make format/check
shell: bash

build:
Expand All @@ -46,5 +46,47 @@ jobs:
shell: bash

- name: Build
run: npm run build
run: make build
shell: bash

type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: npm

- name: Install Packages
run: npm ci
shell: bash

- name: Type Check
run: make type-check
shell: bash

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: npm

- name: Install Packages
run: npm ci
shell: bash

- name: Lint
run: make lint
shell: bash
45 changes: 45 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# AGENTS.md

## 概要

SV-Markerは、日本の英語教育で使われる英文構造図を作成するためのWebアプリケーションです。英文構造に関する情報と、英文構造図の表記規約をもとに、英文構造図を生成します。

## ディレクトリ構造

- `apps/frontend`: 英文構造に関する情報の入力、英文構造図の表記規約の切り替え、英文構造図の表示などを扱う
- `apps/backend`: フロントエンドからのAPI呼び出しを受け、Stanzaサーバーにリクエストを送り、その解析結果をもとに英文構造に関する情報を生成する
- `apps/stanza-server`: FastAPIベースのStanzaのサーバー。英文を解析し、dependency parseやconstituency parseの結果などを返す
- `packages/sentence-structure-document`: 英文構造に関する情報の定義、検証、操作、入出力を扱う
- `packages/sentence-structure-diagram-notation`: 英文構造図の表記規約の定義、検証、表記規約のプリセットの定義、入出力を扱う
- `packages/sentence-structure-diagram`: 英文構造に関する情報と英文構造図の表記規約から、英文構造図のデータやSVGを生成する
- `packages/sentence-structure-document-from-stanza`: Stanzaの解析結果を英文構造に関する情報に変換する
- `evals`: 自動生成の評価用コード

## コマンド

Node側はnpm workspacesで管理している。`apps/stanza-server`だけはPythonとなっている。

### 変更内容の確認

```bash
npm run format:check
npm run build
```

特定のworkspaceだけ確認したいときは、`npm run build --workspace=<workspace>`を使う。

### 開発用サーバーの起動

```bash
npm run dev --workspace=apps/frontend
npm run dev --workspace=apps/backend
cd apps/stanza-server && uv run fastapi dev
```

### 型定義の更新

```bash
npm run stanza-server:generate --workspace=apps/backend
```

実行前に`apps/stanza-server`が`http://127.0.0.1:8000`で起動している必要がある。
65 changes: 65 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
format:
npm run format

format/check:
npm run format:check

build:
npm run build

type-check:
npm run type-check --workspaces

lint:
npm run lint

clean:
npm run clean

build/packages:
npm run build:packages

stanza-server/generate:
cd apps/stanza-server && uv run python -c "import main; import json; print(json.dumps(main.app.openapi()))" > ../../openapi/stanza-server/openapi.json && npx prettier --write ../../openapi/stanza-server/openapi.json

stanza-server/generate/check:
make stanza-server/generate && git diff --exit-code -- openapi/stanza-server/openapi.json

backend/generate:
npm run stanza-server:generate --workspace=backend

backend/dev:
npm run dev --workspace=backend

backend/build:
npm run build --workspace=backend

backend/type-check:
npm run type-check --workspace=backend

backend/clean:
npm run clean --workspace=backend

frontend/dev:
npm run dev --workspace=frontend

frontend/build:
npm run build --workspace=frontend

frontend/type-check:
npm run type-check --workspace=frontend

frontend/clean:
npm run clean --workspace=frontend

evals/generate:
npm run stanza-server:generate --workspace=evals

evals/build:
npm run build --workspace=evals

evals/type-check:
npm run type-check --workspace=evals

evals/clean:
npm run clean --workspace=evals
3 changes: 3 additions & 0 deletions apps/backend/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
WEB_ORIGIN=http://localhost:5173
STANZA_SERVER_ORIGIN=http://127.0.0.1:8000
GEMINI_API_KEY=
1 change: 1 addition & 0 deletions packages/backend/.gitignore → apps/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/dist
/.env
/generated
39 changes: 39 additions & 0 deletions apps/backend/_app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { publicProcedure, router } from "./trpc.js";
import * as z from "zod";
import { SimplifiedSentenceStructureDocumentSchema } from "@sv-marker/sentence-structure-document";
import { generateSimplifiedSentenceStructureDocumentWithStanza } from "./generate-simplified-sentence-structure-document-with-stanza.js";
import { reviseSimplifiedSentenceStructureDocumentWithGemini } from "./revise-simplified-sentence-structure-document-with-gemini.js";

export const appRouter = router({
status: publicProcedure
.output(z.object({ status: z.literal("ok") }))
.query(() => ({ status: "ok" })),
generateSimplifiedSentenceStructureDocument: publicProcedure
.input(
z.object({
text: z.string(),
}),
)
.output(SimplifiedSentenceStructureDocumentSchema)
.mutation(async (opts) => {
const text = opts.input.text;
console.log(`Input text: ${text}`);

return await generateSimplifiedSentenceStructureDocumentWithStanza(text);
}),
reviseSimplifiedSentenceStructureDocument: publicProcedure
.input(
z.object({
userRevisionInstruction: z.string(),
baseSimplifiedSentenceStructureDocument:
SimplifiedSentenceStructureDocumentSchema,
}),
)
.output(SimplifiedSentenceStructureDocumentSchema)
.mutation(async (opts) =>
reviseSimplifiedSentenceStructureDocumentWithGemini(
opts.input.userRevisionInstruction,
opts.input.baseSimplifiedSentenceStructureDocument,
),
),
});
Loading