add github
This commit is contained in:
		
							
								
								
									
										137
									
								
								my-blog/content/posts/2025-06-06-ailog.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								my-blog/content/posts/2025-06-06-ailog.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,137 @@
 | 
			
		||||
---
 | 
			
		||||
title: "静的サイトジェネレータを作った"
 | 
			
		||||
slug: "ailog-system-introduction"
 | 
			
		||||
date: "2025-06-12"
 | 
			
		||||
tags: ["blog", "rust", "mcp", "atp"]
 | 
			
		||||
language: ["ja", "en"]
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
rustで静的サイトジェネレータを作ることにしました。[ailog](https://git.syui.ai/ai/log)といいます。`hugo`からの移行になります。
 | 
			
		||||
 | 
			
		||||
ブログを書く環境もこれから変わってくると思っていて、例えば、`docs`, `readme`, `blog`などはAIが生成、または支援することになるだろうと予測しています。langの自動生成もAIが担当することになるでしょう。
 | 
			
		||||
 | 
			
		||||
これは、音声に限らず、プログラミング言語から、osなど、様々なtranslateがAIの自動生成になるかもしれません。
 | 
			
		||||
 | 
			
		||||
`ailog`は、最初にatproto-comment-system(oauth)とask-AIというAI機能をつけました。
 | 
			
		||||
 | 
			
		||||
## quick start
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
$ git clone https://git.syui.ai/ai/log
 | 
			
		||||
$ cd log
 | 
			
		||||
$ cargo build
 | 
			
		||||
$ ./target/debug/ailog init my-blog
 | 
			
		||||
$ ./target/debug/ailog server my-blog
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## install
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
$ cargo install --path .
 | 
			
		||||
---
 | 
			
		||||
$ export CARGO_HOME="$HOME/.cargo"
 | 
			
		||||
$ export RUSTUP_HOME="$HOME/.rustup"
 | 
			
		||||
$ export PATH="$HOME/.cargo/bin:$PATH"
 | 
			
		||||
---
 | 
			
		||||
$ which ailog
 | 
			
		||||
$ ailog
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## build deploy
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
$ cd my-blog
 | 
			
		||||
$ vim config.toml
 | 
			
		||||
$ ailog new test
 | 
			
		||||
$ vim content/posts/`date +"%Y-%m-%d"`.md
 | 
			
		||||
$ ailog build
 | 
			
		||||
 | 
			
		||||
# publicの中身をweb-serverにdeploy
 | 
			
		||||
$ cp -rf ./public/* ./web-server/root/
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## atproto-comment-system
 | 
			
		||||
 | 
			
		||||
### example
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
$ cd ./oauth
 | 
			
		||||
$ npm i
 | 
			
		||||
$ npm run build
 | 
			
		||||
$ npm run preview
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
# Production environment variables
 | 
			
		||||
VITE_APP_HOST=https://example.com
 | 
			
		||||
VITE_OAUTH_CLIENT_ID=https://example.com/client-metadata.json
 | 
			
		||||
VITE_OAUTH_REDIRECT_URI=https://example.com/oauth/callback
 | 
			
		||||
VITE_ADMIN_DID=did:plc:uqzpqmrjnptsxezjx4xuh2mn
 | 
			
		||||
 | 
			
		||||
# Collection names for OAuth app
 | 
			
		||||
VITE_COLLECTION_COMMENT=ai.syui.log
 | 
			
		||||
VITE_COLLECTION_USER=ai.syui.log.user
 | 
			
		||||
VITE_COLLECTION_CHAT=ai.syui.log.chat
 | 
			
		||||
 | 
			
		||||
# Collection names for ailog (backward compatibility)
 | 
			
		||||
AILOG_COLLECTION_COMMENT=ai.syui.log
 | 
			
		||||
AILOG_COLLECTION_USER=ai.syui.log.user
 | 
			
		||||
 | 
			
		||||
# API Configuration
 | 
			
		||||
VITE_BSKY_PUBLIC_API=https://public.api.bsky.app
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 解説
 | 
			
		||||
 | 
			
		||||
簡単に説明すると、`./oauth`で生成するのが`atproto-comment-system`です。
 | 
			
		||||
 | 
			
		||||
```html
 | 
			
		||||
<script type="module" crossorigin src="/assets/comment-atproto-${hash}}.js"></script>
 | 
			
		||||
<link rel="stylesheet" crossorigin href="/assets/comment-atproto-${hash}.css">
 | 
			
		||||
<section class="comment-section"> <div id="comment-atproto"></div> </section>
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
ただし、oauthであるため、色々と大変です。本番環境(もしくは近い形)でテストを行いましょう。cf, tailscale, ngrokなど。
 | 
			
		||||
 | 
			
		||||
```yml:cloudflared-config.yml
 | 
			
		||||
tunnel: ${hash}
 | 
			
		||||
credentials-file: ${path}.json
 | 
			
		||||
 | 
			
		||||
ingress:
 | 
			
		||||
  - hostname: example.com
 | 
			
		||||
    service: http://localhost:4173
 | 
			
		||||
    originRequest:
 | 
			
		||||
      noHappyEyeballs: true
 | 
			
		||||
      
 | 
			
		||||
  - service: http_status:404
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
# tunnel list, dnsに登録が必要です
 | 
			
		||||
$ cloudflared tunnel list
 | 
			
		||||
$ cloudflared tunnel --config cloudflared-config.yml run
 | 
			
		||||
$ cloudflared tunnel route dns ${uuid} example.com
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
以下の2つのcollection recordを生成します。ユーザーには`ai.syui.log`が生成され、ここにコメントが記録されます。それを取得して表示しています。`ai.syui.log.user`は管理者である`VITE_ADMIN_DID`用です。
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
VITE_COLLECTION_COMMENT=ai.syui.log
 | 
			
		||||
VITE_COLLECTION_USER=ai.syui.log.user
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
$ ailog auth login
 | 
			
		||||
$ ailog stream server
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
このコマンドで`ai.syui.log`を`jetstream`から監視して、書き込みがあれば、管理者の`ai.syui.log.user`に記録され、そのuser-listに基づいて、コメント一覧を取得します。
 | 
			
		||||
 | 
			
		||||
つまり、コメント表示のアカウントを手動で設定するか、自動化するか。自動化するならserverで`ailog stream server`を動かさなければいけません。
 | 
			
		||||
 | 
			
		||||
## ask-AI
 | 
			
		||||
 | 
			
		||||
`ask-AI`の仕組みは割愛します。後に変更される可能性が高いと思います。
 | 
			
		||||
 | 
			
		||||
local llm, mcp, atprotoと組み合わせです。
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user