Skip to content
Merged
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
47 changes: 35 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,55 @@
# 依赖
# ============================================================
# Monolith .gitignore — 什么该推送,什么不该推送
# ============================================================

# ────────────────────── 依赖目录(不推送)──────────────────────
node_modules/
.next/

# 构建产出
# ────────────────────── 构建产出(不推送)──────────────────────
dist/
.wrangler/
.turbo/

# 环境变量
# ────────────────────── 环境变量与密钥(绝不推送)──────────────────
# 所有 .env 文件都可能含密钥,禁止推送
.env
.env.local
.env.*
.env.*.local
.env.production
!.env.example

# Wrangler 本地密钥(含 ADMIN_PASSWORD / JWT_SECRET 等)
.dev.vars

# 系统文件
# ────────────────────── 系统与编辑器临时文件(不推送)──────────────
.DS_Store
Thumbs.db
*.swp
*.swo
*~

# IDE
# IDE 配置
.idea/
.vscode/
*.code-workspace

# Wrangler 本地数据
.wrangler/

# AI 助手记忆库(含私人配置、密码等,禁止推送)
# ────────────────────── AI 工具私有数据(绝不推送)──────────────────
# 记忆库含密码、PAT、私人偏好等敏感信息
.agents/

# 编辑器/AI 全局配置(Antigravity、Gemini、OpenCode 等)
GEMINI.md

# ────────────────────── 日志与调试产物(不推送)──────────────────
*.log
npm-debug.log*

# ────────────────────── 必须推送的重要文件 ──────────────────────
# 以下文件虽然常被误加 gitignore,但必须跟踪:
# ✅ package-lock.json — 锁定依赖版本,CI 的 npm ci 依赖它
# ✅ client/functions/ — Pages Functions 反向代理,漏掉则 /api/* 回退为首页 HTML
# ✅ scripts/ — 部署脚本 (deploy-cloudflare.mjs)
# ✅ AGENTS.md — OpenCode 项目规则(不含密钥)
# ✅ opencode.json — OpenCode 项目配置(含 MCP 远程服务,不含本地密钥)
# ✅ .github/ — CI/CD workflows、Issue/PR 模板、分支保护
# ✅ SECURITY.md — 安全政策
# ✅ PRIVACY.md — 隐私政策
115 changes: 0 additions & 115 deletions .kilo/package-lock.json

This file was deleted.

2 changes: 0 additions & 2 deletions .playwright-mcp/console-2026-04-19T04-35-34-885Z.log

This file was deleted.

1 change: 0 additions & 1 deletion .playwright-mcp/page-2026-04-19T04-35-40-096Z.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .playwright-mcp/page-2026-04-19T04-35-49-532Z.yml

This file was deleted.

Binary file removed .playwright-mcp/page-2026-04-19T04-35-58-544Z.png
Binary file not shown.
63 changes: 63 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Monolith 项目规则

## 项目概览
Monolith 是基于 Cloudflare 边缘计算的全栈博客系统。
- 前端:Vite 6 + React 19 + Tailwind CSS v4 + shadcn/ui + wouter
- 后端:Hono Workers + Drizzle ORM
- 代理层:Pages Functions(反向代理 /api/* /cdn/* /rss.xml)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

修复 Markdown 语法以避免 lint 告警。

/api/* /cdn/* /rss.xml 这类写法容易触发 MD037,建议对 * 转义或整体包裹代码样式,避免 CI 文档检查噪音。

🧰 Tools
🪛 markdownlint-cli2 (0.22.0)

[warning] 7-7: Spaces inside emphasis markers

(MD037, no-space-in-emphasis)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` at line 7, 行内 Markdown 对 `/api/* /cdn/* /rss.xml` 中的星号触发 MD037
报警;在 AGENTS.md 中定位包含文本 "代理层:Pages Functions(反向代理 /api/* /cdn/* /rss.xml)"
的行,然后将每个路径或整个路径序列包裹成代码样式(例如用反引号)或对星号进行转义,以消除 MD037 lint 警告并保持可读性。

- 存储:D1 (SQLite) + R2 (对象存储),支持 Turso/PostgreSQL/S3 切换
- 主题:OKLCH 色彩空间双主题系统(暗色 Slate & Cyan / 亮色模式)

## 架构要点
- 存储层采用适配器模式:路由只依赖 `IDatabase` / `IObjectStorage` 接口,通过 `DB_PROVIDER` / `STORAGE_PROVIDER` 环境变量切换适配器
- Pages Functions 代理层拦截 `/api/*`、`/cdn/*`、`/rss.xml`,转发到 Workers
- Pages Functions 的 `tsconfig.json` 独立引入 `@cloudflare/workers-types`,避免与主项目 DOM 类型冲突
- DOMPurify 净化 Markdown 渲染输出,白名单允许 iframe/video 嵌入
- `searchPosts()` 只搜索 `title + excerpt`,不扫描 `content` 大字段

## 工作区路径
- 项目根目录:`/home/easy/001/Monolith`
- 客户端:`/home/easy/001/Monolith/client`
- 服务端:`/home/easy/001/Monolith/server`

## 分支管理
- 生产分支:`main`(Cloudflare Pages 自动部署绑定)
- 开发分支:`dev`
- 工作流:dev 开发 → commit → push → PR → squash merge 到 main → 部署
- 严禁直接向 main 推送

## 常用命令
- `npm run dev` — 同时启动前后端(client :5173, server :8787)
- `npm run dev:client` / `npm run dev:server` — 单独启动
- `npm run build` — 构建前端
- `npm run deploy:cloudflare` — 一键部署(迁移 + Workers + Pages)
- `npm run db:migrate:local` / `db:migrate:remote` — 数据库迁移
- Node.js 需要 `source $HOME/.nvm/nvm.sh` 后才可用

## 部署铁律
- 使用 `npm run deploy:cloudflare` 一键部署,禁止手动 `wrangler pages deploy`
- 必须从 `client/` 目录部署 `dist`,否则 Pages Functions 会被遗漏
- `package-lock.json` 绝不能放入 `.gitignore`
- CI "Sync Worker secrets" 步骤通过 `wrangler secret put` 注入 ADMIN_PASSWORD / JWT_SECRET

## 踩坑记录(项目特有)
- D1 迁移标记不同步时需手动 `INSERT INTO d1_migrations`
- Cloudflare CDN 有短暂缓存,验证时用部署唯一 URL
- 本地 `client/functions/api/` 目录的 tsconfig 独立,不与主项目混用
- Hono v4 `verify()` 需要 3 个参数:`verify(token, secret, "HS256")`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Hono v4, what is the exact function signature of jwt verify(), and does it require an explicit algorithm argument like "HS256"?

💡 Result:

In Hono v4 (hono/jwt), the jwt verify helper function signature is: verify(token: string, secret: string, alg?: 'HS256'; issuer?: string | RegExp): Promise It does NOT require an explicit algorithm argument like "HS256". Reason: the docs show the alg parameter as optional (alg?: ... ) and note that the default is HS256. In other words, you can call verify(token, secret) and Hono will use the default algorithm.

Citations:


更正 Hono v4 jwt verify() 参数用法。

AGENTS.md 第 47 行声称 verify() 需要 3 个参数,但根据 Hono v4 官方文档,算法参数是可选的。正确签名为 verify(token: string, secret: string, alg?: 'HS256'),默认采用 HS256,可直接调用 verify(token, secret) 而无需传入第三参数。建议更新文档说明,并引用 Hono 当前锁定版本的官方文档链接(https://hono.dev/docs/helpers/jwt)以避免版本更新时的信息偏差。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` at line 47, AGENTS.md 中第 47 行关于 Hono v4 的 verify()
用法不准确;更新该行将声明从“verify() 需要 3 个参数:verify(token, secret, "HS256")”改为说明
verify(token: string, secret: string, alg?: 'HS256'),即算法参数为可选且默认 HS256,因此可以直接调用
verify(token, secret),并在同处添加对 Hono 当前锁定版本官方文档链接
https://hono.dev/docs/helpers/jwt 作为参考以防版本变化。


## 记忆库
项目记忆库路径:`.agents/memory_bank/`
- `README.md` — 索引入口
- `monolith_architecture.md` — 完整架构手册
- `monolith_roadmap.md` — 功能路线图
- `monolith_v1_status.md` — V1 状态报告
- `system_config.md` — 系统配置与凭据
- `ui_design_parameters.md` — UI 排版设计规范
- `typecho_dev_guide.md` — Typecho 开发指南(已弃用项目)

## CI 与安全
- 仓库:`https://github.com/one-ea/Monolith`
- GitHub PAT:已配置在 system_config.md
- 后台密码:`monolith2026`
- 分支保护:main 需要 1 人审批 + 线性历史 + 状态检查
Comment on lines +61 to +63

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

文档中出现敏感信息与明文密码,需立即移除。

GitHub PAT 存放位置说明 + 明文后台密码会直接扩大泄露面。请改为“仅通过密钥管理系统注入”,不要在仓库文档中出现任何可用凭据或固定口令。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` around lines 61 - 63, Remove the sensitive entries in AGENTS.md:
delete the explicit "GitHub PAT:已配置在 system_config.md" line and the plaintext
backend password "monolith2026", and replace them with a short instruction
stating that credentials must never be stored in repo docs and should be
injected at runtime via the organization's secret management solution (e.g.,
"Use secret manager / environment-injected credentials only"). Ensure any
mention of branch protection stays but does not reference credential locations;
also run a repo-wide search for the strings "GitHub PAT" and "monolith2026" and
remove or rotate any other occurrences.

Loading
Loading