Skip to content

Commit be66727

Browse files
committed
不要なファイルの削除とフロントエンドを中心としたリファクタリング
1 parent fc5186d commit be66727

151 files changed

Lines changed: 18717 additions & 10579 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
shell: bash
2626

2727
- name: Prettier
28-
run: npm run format:check
28+
run: make format/check
2929
shell: bash
3030

3131
build:
@@ -46,5 +46,47 @@ jobs:
4646
shell: bash
4747

4848
- name: Build
49-
run: npm run build
49+
run: make build
50+
shell: bash
51+
52+
type-check:
53+
name: Type Check
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout Code
57+
uses: actions/checkout@v6
58+
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v6
61+
with:
62+
node-version-file: .nvmrc
63+
cache: npm
64+
65+
- name: Install Packages
66+
run: npm ci
67+
shell: bash
68+
69+
- name: Type Check
70+
run: make type-check
71+
shell: bash
72+
73+
lint:
74+
name: Lint
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout Code
78+
uses: actions/checkout@v6
79+
80+
- name: Setup Node.js
81+
uses: actions/setup-node@v6
82+
with:
83+
node-version-file: .nvmrc
84+
cache: npm
85+
86+
- name: Install Packages
87+
run: npm ci
88+
shell: bash
89+
90+
- name: Lint
91+
run: make lint
5092
shell: bash

AGENTS.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# AGENTS.md
2+
3+
## 概要
4+
5+
SV-Markerは、日本の英語教育で使われる英文構造図を作成するためのWebアプリケーションです。英文構造に関する情報と、英文構造図の表記規約をもとに、英文構造図を生成します。
6+
7+
## ディレクトリ構造
8+
9+
- `apps/frontend`: 英文構造に関する情報の入力、英文構造図の表記規約の切り替え、英文構造図の表示などを扱う
10+
- `apps/backend`: フロントエンドからのAPI呼び出しを受け、Stanzaサーバーにリクエストを送り、その解析結果をもとに英文構造に関する情報を生成する
11+
- `apps/stanza-server`: FastAPIベースのStanzaのサーバー。英文を解析し、dependency parseやconstituency parseの結果などを返す
12+
- `packages/sentence-structure-document`: 英文構造に関する情報の定義、検証、操作、入出力を扱う
13+
- `packages/sentence-structure-diagram-notation`: 英文構造図の表記規約の定義、検証、表記規約のプリセットの定義、入出力を扱う
14+
- `packages/sentence-structure-diagram`: 英文構造に関する情報と英文構造図の表記規約から、英文構造図のデータやSVGを生成する
15+
- `packages/sentence-structure-document-from-stanza`: Stanzaの解析結果を英文構造に関する情報に変換する
16+
- `evals`: 自動生成の評価用コード
17+
18+
## コマンド
19+
20+
Node側はnpm workspacesで管理している。`apps/stanza-server`だけはPythonとなっている。
21+
22+
### 変更内容の確認
23+
24+
```bash
25+
npm run format:check
26+
npm run build
27+
```
28+
29+
特定のworkspaceだけ確認したいときは、`npm run build --workspace=<workspace>`を使う。
30+
31+
### 開発用サーバーの起動
32+
33+
```bash
34+
npm run dev --workspace=apps/frontend
35+
npm run dev --workspace=apps/backend
36+
cd apps/stanza-server && uv run fastapi dev
37+
```
38+
39+
### 型定義の更新
40+
41+
```bash
42+
npm run stanza-server:generate --workspace=apps/backend
43+
```
44+
45+
実行前に`apps/stanza-server``http://127.0.0.1:8000`で起動している必要がある。

Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
format:
2+
npm run format
3+
4+
format/check:
5+
npm run format:check
6+
7+
build:
8+
npm run build
9+
10+
type-check:
11+
npm run type-check --workspaces
12+
13+
lint:
14+
npm run lint
15+
16+
clean:
17+
npm run clean
18+
19+
build/packages:
20+
npm run build:packages
21+
22+
stanza-server/generate:
23+
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
24+
25+
stanza-server/generate/check:
26+
make stanza-server/generate && git diff --exit-code -- openapi/stanza-server/openapi.json
27+
28+
backend/generate:
29+
npm run stanza-server:generate --workspace=backend
30+
31+
backend/dev:
32+
npm run dev --workspace=backend
33+
34+
backend/build:
35+
npm run build --workspace=backend
36+
37+
backend/type-check:
38+
npm run type-check --workspace=backend
39+
40+
backend/clean:
41+
npm run clean --workspace=backend
42+
43+
frontend/dev:
44+
npm run dev --workspace=frontend
45+
46+
frontend/build:
47+
npm run build --workspace=frontend
48+
49+
frontend/type-check:
50+
npm run type-check --workspace=frontend
51+
52+
frontend/clean:
53+
npm run clean --workspace=frontend
54+
55+
evals/generate:
56+
npm run stanza-server:generate --workspace=evals
57+
58+
evals/build:
59+
npm run build --workspace=evals
60+
61+
evals/type-check:
62+
npm run type-check --workspace=evals
63+
64+
evals/clean:
65+
npm run clean --workspace=evals
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
WEB_ORIGIN=http://localhost:5173
2-
2+
STANZA_SERVER_ORIGIN=http://127.0.0.1:8000
33
GEMINI_API_KEY=
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/dist
22
/.env
3+
/generated

apps/backend/_app.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { publicProcedure, router } from "./trpc.js";
2+
import * as z from "zod";
3+
import { SimplifiedSentenceStructureDocumentSchema } from "@sv-marker/sentence-structure-document";
4+
import { generateSimplifiedSentenceStructureDocumentWithStanza } from "./generate-simplified-sentence-structure-document-with-stanza.js";
5+
import { reviseSimplifiedSentenceStructureDocumentWithGemini } from "./revise-simplified-sentence-structure-document-with-gemini.js";
6+
7+
export const appRouter = router({
8+
status: publicProcedure
9+
.output(z.object({ status: z.literal("ok") }))
10+
.query(() => ({ status: "ok" })),
11+
generateSimplifiedSentenceStructureDocument: publicProcedure
12+
.input(
13+
z.object({
14+
text: z.string(),
15+
}),
16+
)
17+
.output(SimplifiedSentenceStructureDocumentSchema)
18+
.mutation(async (opts) => {
19+
const text = opts.input.text;
20+
console.log(`Input text: ${text}`);
21+
22+
return await generateSimplifiedSentenceStructureDocumentWithStanza(text);
23+
}),
24+
reviseSimplifiedSentenceStructureDocument: publicProcedure
25+
.input(
26+
z.object({
27+
userRevisionInstruction: z.string(),
28+
baseSimplifiedSentenceStructureDocument:
29+
SimplifiedSentenceStructureDocumentSchema,
30+
}),
31+
)
32+
.output(SimplifiedSentenceStructureDocumentSchema)
33+
.mutation(async (opts) =>
34+
reviseSimplifiedSentenceStructureDocumentWithGemini(
35+
opts.input.userRevisionInstruction,
36+
opts.input.baseSimplifiedSentenceStructureDocument,
37+
),
38+
),
39+
});

0 commit comments

Comments
 (0)