Skip to content
项目

关于

RewritePal - Make sure your writing is flawless.

人工智能与机器学习

这些数字如何统计

实测星标增长

24小时
0
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

RewritePal

CI Tests

RewritePal is a focused AI writing assistant that rewrites supplied text while preserving its intent and applying optional tone, role, and language choices. This repository contains the standalone, MIT-licensed web rewriter. Hosted RewritePal also offers additional writing tools.

RewritePal interface

Stack

  • Next.js 16, React 19, TypeScript, and React Compiler
  • Tailwind CSS 4 with shadcn/Radix UI primitives
  • Vercel AI SDK with OpenAI
  • Upstash Redis for rate limiting and the public rewrite counter
  • Biome, Bun Test, Playwright, and Bun

Local development

Use Bun 1.3.14 or newer and Node.js 22 or newer.

bun install --frozen-lockfile
cp .env.example .env.local

Configure .env.local to enable live rewrites.

  • OPENAI_API_KEY comes from your OpenAI account.
  • UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN come from the same Upstash Redis database. The app uses Redis for rate limiting and the rewrite counter.
  • RATE_LIMIT_HASH_SECRET can be blank when running bun dev. For a production runtime, generate a unique secret with openssl rand -hex 32 and keep it stable across deploys. Changing it resets active rate-limit identities.

Run bun dev and open localhost:3000. Use sample text to try a rewrite with a tone or output language. Keep .env.local out of Git.

Try the rewrite flow without service credentials

The Playwright suite starts a local server and mocks the rewrite and counter endpoints. Install Chromium and run the suite after installing dependencies.

bunx playwright install chromium
bun run test:e2e

The suite covers tone and language selection, copying a result, and stopping a rewrite.

Quality checks

bun run check       # lint, formatting, and safe static checks
bun run typecheck   # TypeScript without emitting files
bun run test        # unit and route contracts, including rate limits and counters
bun run test:e2e    # mocked browser journey through the rewrite flow
bun run eval        # paid, manual AI-quality evaluation; writes a local report
bun run build       # production build
bun audit --prod    # production dependency advisories

GitHub Actions runs a frozen install, dependency audit, static checks, type check, tests, and production build on pull requests and pushes to master.

Architecture decisions

  • The homepage and root layout remain Server Components. Client boundaries are limited to the rewrite experience, theme controls, and mobile navigation.
  • A shared Zod contract validates every rewrite request before prompt creation. Prompt construction is a pure function with focused unit tests.
  • Form choices use local React state because they belong to one screen. This avoids global-state machinery for temporary UI state.
  • The completed-rewrite counter remains visible as a non-critical client/server metric. Only a completed generation schedules its server-side increment; the browser can only read the displayed count.
  • Redis and environment configuration are lazy server-only modules; routes fail safely when required deployment variables are absent.
  • Playwright mocks provider and counter endpoints, so the core browser journey is deterministic and does not spend API credits in CI.
  • The committed rewrite eval set shares production generation settings, then scores real outputs with deterministic checks and a structured LLM rubric. See the eval guide.
  • The PostCSS override keeps Next.js and Tailwind on the same patched release. The minimatch override covers shadcn’s development tooling until its ts-morph dependency accepts the patched major version.

Project structure

app/                  routes, metadata, and API route handlers
components/rewrite/   interactive rewrite feature
components/ui/        reusable shadcn/Radix primitives
docs/                 focused supporting documentation
e2e/                  realistic mocked browser journeys
evals/                paid, opt-in rewrite-quality evaluations
lib/constants/        shared rewrite options
lib/rewrite/          request contract and prompt construction
lib/server/           server-only integrations and request handling
public/               static product assets

Security and privacy

The rewrite endpoint rate limits a keyed digest derived from Vercel’s trusted proxy header; the raw address is not used as the Redis key. Submitted text is sent to OpenAI to generate a rewrite and is not intentionally written to the application database or logs. See the in-product privacy notice for the provider and infrastructure boundary.

Contributing

Keep changes small and accessible, run the quality checks above, and describe any environment-variable or user-facing behavior changes in the pull request.

探索相关项目

加载中…