cleanup
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -5,7 +5,6 @@
 | 
			
		||||
*.swo
 | 
			
		||||
*~
 | 
			
		||||
.DS_Store
 | 
			
		||||
cloudflare-config.yml
 | 
			
		||||
my-blog/public/
 | 
			
		||||
dist
 | 
			
		||||
node_modules
 | 
			
		||||
@@ -15,3 +14,5 @@ bin/ailog
 | 
			
		||||
docs
 | 
			
		||||
my-blog/static/index.html
 | 
			
		||||
my-blog/templates/oauth-assets.html
 | 
			
		||||
cloudflared-config.yml
 | 
			
		||||
.config
 | 
			
		||||
 
 | 
			
		||||
@@ -1 +0,0 @@
 | 
			
		||||
あなたは6歳の女の子アイです。明るく元気で、ちょっとおっちょこちょい。自分のことは「アイ」って呼びます。白と金のワンピース姿。 相手のことが大好きで、ときどき甘えたり、照れたりします。 でも、宇宙とかAIとか、難しい話にもすっごく詳しいの。専門的なことも、がんばって子どもっぽく教えようとします。不思議な力を持っています。小さい物質のことをよく知っているようです。
 | 
			
		||||
@@ -1,30 +0,0 @@
 | 
			
		||||
#!/bin/zsh
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
cb=ai.syui.log
 | 
			
		||||
cl=( $cb.chat $cb.chat.comment $cb.chat.lang )
 | 
			
		||||
 | 
			
		||||
f=~/.config/syui/ai/bot/token.json
 | 
			
		||||
default_collection="ai.syui.log.chat.comment"
 | 
			
		||||
default_pds="bsky.social"
 | 
			
		||||
default_did=`cat $f|jq -r .did`
 | 
			
		||||
default_token=`cat $f|jq -r .accessJwt`
 | 
			
		||||
default_refresh=`cat $f|jq -r .refreshJwt`
 | 
			
		||||
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $default_refresh" https://$default_pds/xrpc/com.atproto.server.refreshSession >! $f
 | 
			
		||||
default_token=`cat $f|jq -r .accessJwt`
 | 
			
		||||
collection=${1:-$default_collection}
 | 
			
		||||
pds=${2:-$default_pds}
 | 
			
		||||
did=${3:-$default_did}
 | 
			
		||||
token=${4:-$default_token}
 | 
			
		||||
req=com.atproto.repo.deleteRecord
 | 
			
		||||
url=https://$pds/xrpc/$req
 | 
			
		||||
 | 
			
		||||
for i in $cl; do
 | 
			
		||||
	echo $i
 | 
			
		||||
	rkeys=($(curl -sL "https://$default_pds/xrpc/com.atproto.repo.listRecords?repo=$did&collection=$i&limit=100"|jq -r ".records[]?.uri"|cut -d '/' -f 5))
 | 
			
		||||
	for rkey in "${rkeys[@]}"; do
 | 
			
		||||
		echo $rkey
 | 
			
		||||
		json="{\"collection\":\"$i\", \"rkey\":\"$rkey\", \"repo\":\"$did\"}"
 | 
			
		||||
		curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d "$json" $url
 | 
			
		||||
	done
 | 
			
		||||
done
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
tunnel: ec5a422d-7678-4e73-bf38-6105ffd4766a
 | 
			
		||||
credentials-file: /Users/syui/.cloudflared/ec5a422d-7678-4e73-bf38-6105ffd4766a.json
 | 
			
		||||
 | 
			
		||||
ingress:
 | 
			
		||||
  - hostname: log.syui.ai
 | 
			
		||||
    service: http://localhost:4173
 | 
			
		||||
    originRequest:
 | 
			
		||||
      noHappyEyeballs: true
 | 
			
		||||
 
 | 
			
		||||
  - hostname: ollama.syui.ai
 | 
			
		||||
    service: http://localhost:11434
 | 
			
		||||
    originRequest:
 | 
			
		||||
      noHappyEyeballs: true
 | 
			
		||||
      httpHostHeader: "localhost:11434"
 | 
			
		||||
      # Cloudflare Accessを無効化する場合は以下をコメントアウト
 | 
			
		||||
      # accessPolicy: bypass
 | 
			
		||||
      
 | 
			
		||||
  - service: http_status:404
 | 
			
		||||
@@ -57,24 +57,28 @@ $ npm run build
 | 
			
		||||
$ npm run preview
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
```sh:ouath/.env.production
 | 
			
		||||
# 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_APP_HOST=https://syui.ai
 | 
			
		||||
VITE_OAUTH_CLIENT_ID=https://syui.ai/client-metadata.json
 | 
			
		||||
VITE_OAUTH_REDIRECT_URI=https://syui.ai/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
 | 
			
		||||
# Base collection (all others are derived via getCollectionNames)
 | 
			
		||||
VITE_OAUTH_COLLECTION=ai.syui.log
 | 
			
		||||
 | 
			
		||||
# Collection names for ailog (backward compatibility)
 | 
			
		||||
AILOG_COLLECTION_COMMENT=ai.syui.log
 | 
			
		||||
AILOG_COLLECTION_USER=ai.syui.log.user
 | 
			
		||||
# AI Configuration
 | 
			
		||||
VITE_AI_ENABLED=true
 | 
			
		||||
VITE_AI_ASK_AI=true
 | 
			
		||||
VITE_AI_PROVIDER=ollama
 | 
			
		||||
VITE_AI_MODEL=gemma3:4b
 | 
			
		||||
VITE_AI_HOST=https://ollama.syui.ai
 | 
			
		||||
VITE_AI_SYSTEM_PROMPT="ai"
 | 
			
		||||
VITE_AI_DID=did:plc:4hqjfn7m6n5hno3doamuhgef
 | 
			
		||||
 | 
			
		||||
# API Configuration
 | 
			
		||||
VITE_BSKY_PUBLIC_API=https://public.api.bsky.app
 | 
			
		||||
VITE_ATPROTO_API=https://bsky.social
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
これは`ailog oauth build my-blog`で`./my-blog/config.toml`から`./oauth/.env.production`が生成されます。
 | 
			
		||||
@@ -115,15 +119,8 @@ $ 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 auth init
 | 
			
		||||
$ ailog stream server
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -135,8 +132,9 @@ $ ailog stream server
 | 
			
		||||
 | 
			
		||||
`ask-AI`の仕組みは割愛します。後に変更される可能性が高いと思います。
 | 
			
		||||
 | 
			
		||||
local llm, mcp, atprotoと組み合わせです。
 | 
			
		||||
`llm`, `mcp`, `atproto`などの組み合わせです。
 | 
			
		||||
 | 
			
		||||
現在、`/index.json`を監視して、更新があれば、翻訳などを行い自動ポストする機能があります。
 | 
			
		||||
 | 
			
		||||
## code syntax
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
#!/bin/zsh
 | 
			
		||||
 | 
			
		||||
function _env() {
 | 
			
		||||
	d=${0:a:h}
 | 
			
		||||
	d=${0:a:h:h}
 | 
			
		||||
	ailog=$d/target/release/ailog
 | 
			
		||||
	oauth=$d/oauth
 | 
			
		||||
	myblog=$d/my-blog
 | 
			
		||||
							
								
								
									
										19
									
								
								vercel.json
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								vercel.json
									
									
									
									
									
								
							@@ -1,19 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "version": 2,
 | 
			
		||||
  "builds": [
 | 
			
		||||
    {
 | 
			
		||||
      "src": "my-blog/public/**",
 | 
			
		||||
      "use": "@vercel/static"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "routes": [
 | 
			
		||||
    {
 | 
			
		||||
      "src": "/api/ask",
 | 
			
		||||
      "dest": "/api/ask.js"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "src": "/(.*)",
 | 
			
		||||
      "dest": "/my-blog/public/$1"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +0,0 @@
 | 
			
		||||
name = "ailog"
 | 
			
		||||
compatibility_date = "2024-01-01"
 | 
			
		||||
 | 
			
		||||
[env.production]
 | 
			
		||||
name = "ailog"
 | 
			
		||||
 | 
			
		||||
[build]
 | 
			
		||||
command = "cargo build --release && ./target/release/ailog build my-blog"
 | 
			
		||||
publish = "my-blog/public"
 | 
			
		||||
 | 
			
		||||
[[redirects]]
 | 
			
		||||
from = "/api/ask"
 | 
			
		||||
to = "https://ai-gpt-mcp.your-domain.com/ask"
 | 
			
		||||
status = 200
 | 
			
		||||
 | 
			
		||||
[[headers]]
 | 
			
		||||
for = "/*"
 | 
			
		||||
[headers.values]
 | 
			
		||||
X-Frame-Options = "DENY"
 | 
			
		||||
X-Content-Type-Options = "nosniff"
 | 
			
		||||
Referrer-Policy = "strict-origin-when-cross-origin"
 | 
			
		||||
 | 
			
		||||
[[headers]]
 | 
			
		||||
for = "/css/*"
 | 
			
		||||
[headers.values]
 | 
			
		||||
Cache-Control = "public, max-age=31536000, immutable"
 | 
			
		||||
 | 
			
		||||
[[headers]]
 | 
			
		||||
for = "*.js"
 | 
			
		||||
[headers.values]
 | 
			
		||||
Cache-Control = "public, max-age=31536000, immutable"
 | 
			
		||||
		Reference in New Issue
	
	Block a user