From e7a0e6d9e759557ddf03d7511db1b547ad81247d Mon Sep 17 00:00:00 2001 From: syui Date: Mon, 16 Jun 2025 10:49:29 +0900 Subject: [PATCH] rm templates root --- templates/api.md | 103 ---------------------------------------- templates/changelog.md | 19 -------- templates/readme.md | 76 ----------------------------- templates/structure.md | 39 --------------- workers/ollama-proxy.js | 93 ------------------------------------ workers/wrangler.toml | 20 -------- 6 files changed, 350 deletions(-) delete mode 100644 templates/api.md delete mode 100644 templates/changelog.md delete mode 100644 templates/readme.md delete mode 100644 templates/structure.md delete mode 100644 workers/ollama-proxy.js delete mode 100644 workers/wrangler.toml diff --git a/templates/api.md b/templates/api.md deleted file mode 100644 index ab5ff74..0000000 --- a/templates/api.md +++ /dev/null @@ -1,103 +0,0 @@ -# API Documentation - -## Public Functions - -{{#each api.public_functions}} -### `{{this.name}}` - -{{#if this.docs}} -{{this.docs}} -{{/if}} - -**Visibility:** `{{this.visibility}}` -{{#if this.is_async}}**Async:** Yes{{/if}} - -{{#if this.parameters}} -**Parameters:** -{{#each this.parameters}} -- `{{this.name}}`: `{{this.param_type}}`{{#if this.is_mutable}} (mutable){{/if}} -{{/each}} -{{/if}} - -{{#if this.return_type}} -**Returns:** `{{this.return_type}}` -{{/if}} - ---- - -{{/each}} - -## Public Structs - -{{#each api.public_structs}} -### `{{this.name}}` - -{{#if this.docs}} -{{this.docs}} -{{/if}} - -**Visibility:** `{{this.visibility}}` - -{{#if this.fields}} -**Fields:** -{{#each this.fields}} -- `{{this.name}}`: `{{this.field_type}}` ({{this.visibility}}) -{{#if this.docs}} - {{this.docs}}{{/if}} -{{/each}} -{{/if}} - ---- - -{{/each}} - -## Public Enums - -{{#each api.public_enums}} -### `{{this.name}}` - -{{#if this.docs}} -{{this.docs}} -{{/if}} - -**Visibility:** `{{this.visibility}}` - -{{#if this.variants}} -**Variants:** -{{#each this.variants}} -- `{{this.name}}` -{{#if this.docs}} - {{this.docs}}{{/if}} -{{#if this.fields}} - **Fields:** -{{#each this.fields}} - - `{{this.name}}`: `{{this.field_type}}` -{{/each}} -{{/if}} -{{/each}} -{{/if}} - ---- - -{{/each}} - -## Public Traits - -{{#each api.public_traits}} -### `{{this.name}}` - -{{#if this.docs}} -{{this.docs}} -{{/if}} - -**Visibility:** `{{this.visibility}}` - -{{#if this.methods}} -**Methods:** -{{#each this.methods}} -- `{{this.name}}({{#each this.parameters}}{{this.name}}: {{this.param_type}}{{#unless @last}}, {{/unless}}{{/each}}){{#if this.return_type}} -> {{this.return_type}}{{/if}}` -{{#if this.docs}} - {{this.docs}}{{/if}} -{{/each}} -{{/if}} - ---- - -{{/each}} \ No newline at end of file diff --git a/templates/changelog.md b/templates/changelog.md deleted file mode 100644 index 6ccb27c..0000000 --- a/templates/changelog.md +++ /dev/null @@ -1,19 +0,0 @@ -# Changelog - -## Recent Changes - -{{#each commits}} -### {{this.date}} - -**{{this.hash}}** by {{this.author}} - -{{this.message}} - ---- - -{{/each}} - -## Summary - -- **Total Commits:** {{commits.length}} -- **Contributors:** {{#unique commits "author"}}{{this.author}}{{#unless @last}}, {{/unless}}{{/unique}} \ No newline at end of file diff --git a/templates/readme.md b/templates/readme.md deleted file mode 100644 index 6948b8b..0000000 --- a/templates/readme.md +++ /dev/null @@ -1,76 +0,0 @@ -# {{project.name}} - -{{#if project.description}} -{{project.description}} -{{/if}} - -## Overview - -This project contains {{project.modules.length}} modules with a total of {{project.metrics.total_lines}} lines of code. - -## Installation - -```bash -cargo install {{project.name}} -``` - -## Usage - -```bash -{{project.name}} --help -``` - -## Dependencies - -{{#each project.dependencies}} -- `{{@key}}`: {{this}} -{{/each}} - -## Project Structure - -``` -{{#each project.structure.directories}} -{{this.name}}/ -{{/each}} -``` - -## API Documentation - -{{#each project.modules}} -### {{this.name}} - -{{#if this.docs}} -{{this.docs}} -{{/if}} - -{{#if this.functions}} -**Functions:** {{this.functions.length}} -{{/if}} - -{{#if this.structs}} -**Structs:** {{this.structs.length}} -{{/if}} - -{{/each}} - -## Metrics - -- **Lines of Code:** {{project.metrics.total_lines}} -- **Total Files:** {{project.metrics.total_files}} -- **Test Files:** {{project.metrics.test_files}} -- **Dependencies:** {{project.metrics.dependency_count}} -- **Complexity Score:** {{project.metrics.complexity_score}} - -## License - -{{#if project.license}} -{{project.license}} -{{else}} -MIT -{{/if}} - -## Authors - -{{#each project.authors}} -- {{this}} -{{/each}} \ No newline at end of file diff --git a/templates/structure.md b/templates/structure.md deleted file mode 100644 index 9cce8b3..0000000 --- a/templates/structure.md +++ /dev/null @@ -1,39 +0,0 @@ -# Project Structure - -## Directory Overview - -``` -{{#each structure.directories}} -{{this.name}}/ -{{#each this.subdirectories}} -├── {{this}}/ -{{/each}} -{{#if this.file_count}} -└── ({{this.file_count}} files) -{{/if}} - -{{/each}} -``` - -## File Distribution - -{{#each structure.files}} -- **{{this.name}}** ({{this.language}}) - {{this.lines_of_code}} lines{{#if this.is_test}} [TEST]{{/if}} -{{/each}} - -## Statistics - -- **Total Directories:** {{structure.directories.length}} -- **Total Files:** {{structure.files.length}} -- **Languages Used:** -{{#group structure.files by="language"}} - - {{@key}}: {{this.length}} files -{{/group}} - -{{#if structure.dependency_graph}} -## Dependencies - -{{#each structure.dependency_graph}} -- **{{@key}}** depends on: {{#each this}}{{this}}{{#unless @last}}, {{/unless}}{{/each}} -{{/each}} -{{/if}} \ No newline at end of file diff --git a/workers/ollama-proxy.js b/workers/ollama-proxy.js deleted file mode 100644 index 8df927b..0000000 --- a/workers/ollama-proxy.js +++ /dev/null @@ -1,93 +0,0 @@ -// Cloudflare Worker for secure Ollama proxy -export default { - async fetch(request, env, ctx) { - // CORS preflight - if (request.method === 'OPTIONS') { - return new Response(null, { - headers: { - 'Access-Control-Allow-Origin': 'https://log.syui.ai', - 'Access-Control-Allow-Methods': 'POST, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type, X-User-Token', - 'Access-Control-Max-Age': '86400', - } - }); - } - - // Verify origin - const origin = request.headers.get('Origin'); - const referer = request.headers.get('Referer'); - - // 許可されたオリジンのみ - const allowedOrigins = [ - 'https://log.syui.ai', - 'https://log.pages.dev' // Cloudflare Pages preview - ]; - - if (!origin || !allowedOrigins.some(allowed => origin.startsWith(allowed))) { - return new Response('Forbidden', { status: 403 }); - } - - // ユーザー認証トークン検証(オプション) - const userToken = request.headers.get('X-User-Token'); - if (env.REQUIRE_AUTH && !userToken) { - return new Response('Unauthorized', { status: 401 }); - } - - // リクエストボディを取得 - const body = await request.json(); - - // プロンプトサイズ制限 - if (body.prompt && body.prompt.length > 1000) { - return new Response(JSON.stringify({ - error: 'Prompt too long. Maximum 1000 characters.' - }), { - status: 400, - headers: { 'Content-Type': 'application/json' } - }); - } - - // レート制限(CF Workers KV使用) - if (env.RATE_LIMITER) { - const clientIP = request.headers.get('CF-Connecting-IP'); - const rateLimitKey = `rate:${clientIP}`; - const currentCount = await env.RATE_LIMITER.get(rateLimitKey) || 0; - - if (currentCount >= 20) { - return new Response(JSON.stringify({ - error: 'Rate limit exceeded. Try again later.' - }), { - status: 429, - headers: { 'Content-Type': 'application/json' } - }); - } - - // カウント増加(1時間TTL) - await env.RATE_LIMITER.put(rateLimitKey, currentCount + 1, { - expirationTtl: 3600 - }); - } - - // Ollamaへプロキシ - const ollamaResponse = await fetch(env.OLLAMA_API_URL || 'https://ollama.syui.ai/api/generate', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - // 内部認証ヘッダー(必要に応じて) - 'X-Internal-Token': env.OLLAMA_INTERNAL_TOKEN || '' - }, - body: JSON.stringify(body) - }); - - // レスポンスを返す - const responseData = await ollamaResponse.text(); - - return new Response(responseData, { - status: ollamaResponse.status, - headers: { - 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': origin, - 'Cache-Control': 'no-store' - } - }); - } -}; \ No newline at end of file diff --git a/workers/wrangler.toml b/workers/wrangler.toml deleted file mode 100644 index f7893ca..0000000 --- a/workers/wrangler.toml +++ /dev/null @@ -1,20 +0,0 @@ -name = "ollama-proxy" -main = "ollama-proxy.js" -compatibility_date = "2024-01-01" - -# 環境変数 -[vars] -REQUIRE_AUTH = false - -# 本番環境 -[env.production.vars] -OLLAMA_API_URL = "https://ollama.syui.ai/api/generate" -REQUIRE_AUTH = true - -# KVネームスペース(レート制限用) -[[kv_namespaces]] -binding = "RATE_LIMITER" -id = "your-kv-namespace-id" - -# シークレット(wrangler secret putで設定) -# OLLAMA_INTERNAL_TOKEN = "your-internal-token" \ No newline at end of file