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
8 changes: 7 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ updates:
directory: /
schedule:
interval: weekly
cooldown:
default-days: 14
groups:
tanstack:
patterns: ['@tanstack/*']
patterns: ["@tanstack/*"]
minor-and-patch:
update-types: [minor, patch]
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
cooldown:
default-days: 14
- package-ecosystem: docker
directory: /
schedule:
interval: monthly
cooldown:
default-days: 14
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
name: CI

on:
push:
branches: [main]
tags: ['v*']
tags: ["v*"]
pull_request:

permissions:
Expand All @@ -18,9 +17,9 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
cache: pnpm
Expand All @@ -31,7 +30,7 @@ jobs:
- run: pnpm test
- run: pnpm build
- name: Install Playwright browser
run: pnpm --filter @cnotes/web exec playwright install --with-deps chromium
run: pnpm --filter @cnotes/frontend exec playwright install --with-deps chromium
- run: pnpm test:e2e

docker:
Expand All @@ -41,23 +40,23 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- uses: docker/login-action@v3
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
platforms: linux/amd64
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/commit-messages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Commit messages

on:
pull_request:

permissions:
contents: read

concurrency:
group: commit-messages-${{ github.ref }}
cancel-in-progress: true

jobs:
no-ai-attribution:
name: No AI attribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
persist-credentials: false
- name: Reject AI sign-offs and Claude-Session trailers
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
shopt -s nocasematch

# Names and domains that mark a trailer as written for an AI tool.
# Each must start a word, so "Haider" doesn't match "aider".
ai='\b(claude|anthropic|copilot|openai|chatgpt|gpt|codex|gemini|cursoragent|devin-ai|aider)'
# A model version: a number standing as its own word ("Claude Opus 5.5",
# "Gemini 2") or a dotted version ("Qwen2.5"). Checked against the name
# only, never the email; handles like "jsmith92" pass.
version='(^|[[:space:]])[0-9]+(\.[0-9]+)*([[:space:]]|$)|[0-9]\.[0-9]'
trailer='^[[:space:]]*[a-z-]+-by:(.*)'
session='^[[:space:]]*claude-session:'
footer='generated with \[?claude code'

# Prints "number:line" for each attribution line of the message on stdin:
# 1. Any "*-by:" trailer (Co-Authored-By, Signed-off-by, Assisted-by, ...)
# whose name or email names an AI, or whose name has a model version.
# 2. Any Claude-Session trailer.
# 3. The "Generated with Claude Code" footer.
attribution_lines() {
local n=0 line value name
while IFS= read -r line; do
n=$((n + 1))
if [[ $line =~ $session || $line =~ $footer ]]; then
echo "$n:$line"
elif [[ $line =~ $trailer ]]; then
value=${BASH_REMATCH[1]}
# The name is what's left after removing "<email>" and bare emails.
name=$(sed -E 's/<[^>]*>//g; s/[^[:space:]]+@[^[:space:]]+//g' <<<"$value")
if [[ $value =~ $ai || $name =~ $version ]]; then
echo "$n:$line"
fi
fi
done
}

total=0
flagged=0
report=''
# Oldest first, the same order "git rebase -i" lists them in.
for sha in $(git rev-list --reverse "${BASE_SHA}..${HEAD_SHA}"); do
total=$((total + 1))
matches=$(git log -1 --format=%B "$sha" | attribution_lines)
[ -n "$matches" ] || continue
flagged=$((flagged + 1))
# Every line is indented, so nothing from a commit message can
# start a workflow command.
report+=" ${sha:0:7} $(git log -1 --format=%s "$sha")"$'\n'
report+=$(sed -E 's/^([0-9]+):/ line \1: /' <<<"$matches")$'\n\n'
done

if [ "$flagged" -eq 0 ]; then
echo "No AI attribution found in ${total} commit(s)."
exit 0
fi

echo "::error title=AI attribution in commit messages::${flagged} of ${total} commit(s) in this pull request credit an AI tool in the commit message. Reword those commits to delete the attribution lines, then force-push. The job log lists the lines and the exact steps."
cat <<EOF

This project doesn't accept AI attribution in commit messages: no
Co-Authored-By or Signed-off-by lines naming an AI tool or model, no
Claude-Session links, and no "Generated with Claude Code" footers.

These commits have lines like that:

${report}How to fix it (your code changes stay exactly as they are):

1. Start an interactive rebase from where your branch begins:

git fetch origin
git rebase -i \$(git merge-base HEAD origin/${BASE_REF})

2. In the editor, change "pick" to "reword" (or just "r") on each
commit listed above, then save and close.

3. Git then opens each of those commit messages in turn. Delete the
lines listed above, then save and close.

4. Update the pull request:

git push --force-with-lease

If only your latest commit is affected, "git commit --amend" followed
by step 4 is enough.

If a tool adds these lines for you, turn off its commit attribution
setting so your next commits don't get them again.
EOF
exit 1
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22
26
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pnpm-lock.yaml
LICENSE
apps/web/src/routeTree.gen.ts
src/frontend/src/routeTree.gen.ts
dist
.output
*.md
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"semi": false,
"singleQuote": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 100
}
19 changes: 19 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Instructions for AI agents

How to build, test and find your way around: [docs/development.md](docs/development.md).

## Before committing

Run `pnpm format` so Prettier formats your changes, then `pnpm lint` and `pnpm typecheck`.
CI runs `pnpm format:check` and fails the pull request if any file isn't formatted.

## Commit messages

Don't credit yourself or any other AI tool in commit messages. Leave out:

- `Co-Authored-By:`, `Signed-off-by:` and other `*-by:` lines that name an AI tool or model, such as `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`
- `Claude-Session:` lines
- "🤖 Generated with Claude Code" footers

This applies even when your tool adds these lines by default. The
[Commit messages](.github/workflows/commit-messages.yml) check fails any pull request with a commit that contains them.
32 changes: 16 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# syntax=docker/dockerfile:1

FROM node:22-bookworm-slim AS base
# Base images are pinned by digest; Dependabot updates the tag and digest together.
FROM node:26-bookworm-slim@sha256:0042e17d232a87a2cd485be1da7900fca4d10a4ad11b29e9285da1d2e54798c9 AS base
ENV PNPM_HOME=/pnpm PATH=/pnpm:$PATH
RUN corepack enable
WORKDIR /src
WORKDIR /app
# Node no longer bundles corepack, so install the pnpm version from package.json
COPY package.json ./
RUN npm install --global "$(node -p 'require("./package.json").packageManager')"

FROM base AS build
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
COPY apps/server/package.json apps/server/
COPY apps/web/package.json apps/web/
COPY src/backend/package.json src/backend/
COPY src/frontend/package.json src/frontend/
COPY packages/shared/package.json packages/shared/
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY . .
ARG CNOTES_VERSION=0.0.0
RUN pnpm build
# Server with production dependencies only
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm deploy --legacy --prod --filter @cnotes/server /out/server
pnpm deploy --legacy --prod --filter @cnotes/backend /out/backend

FROM node:22-bookworm-slim AS runtime
FROM node:26-bookworm-slim@sha256:0042e17d232a87a2cd485be1da7900fca4d10a4ad11b29e9285da1d2e54798c9 AS runtime
ARG CNOTES_VERSION=0.0.0
ENV NODE_ENV=production \
HOST=0.0.0.0 \
PORT=3000 \
DATA_DIR=/data \
WEB_ROOT=/app/web \
WEB_ROOT=/app/frontend \
CNOTES_VERSION=$CNOTES_VERSION
WORKDIR /app/server
COPY --from=build /out/server/node_modules ./node_modules
COPY --from=build /out/server/package.json ./package.json
COPY --from=build /src/apps/server/dist ./dist
COPY --from=build /src/apps/web/dist/client /app/web
WORKDIR /app/backend
COPY --from=build /out/backend/node_modules ./node_modules
COPY --from=build /out/backend/package.json ./package.json
COPY --from=build /app/src/backend/dist ./dist
COPY --from=build /app/src/frontend/dist/client /app/frontend
RUN mkdir -p /data && chown node:node /data
USER node
VOLUME ["/data"]
Expand Down
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Cnotes
# `cnotes` (pronounced _snotes_)

A self-hosted notes and lists app adapted for households. Several people can edit the same pages at once, and it keeps working offline.

- Nested pages with a rich-text editor (Markdown)
- Offline edits merge when the device reconnects.
- Pinned lists (shopping, packing) stay downloaded for use without signal.
- Inline photos (location data removed) and file attachments.
- Installs to the home screen as a web app (PWA) on iPhone and Android.
- Password and two-factor sign-in.
- Daily backups and Markdown export.

**Not a fit if you need:**
- Public sign-up
- Sharing info with guest accounts
- Separate workspaces for different users

## License

Licensed under AGPL-3.0-or-later. See [LICENSE](LICENSE).

## Development

Requires Node 26 and pnpm (`npm install -g corepack && corepack enable`).

```sh
pnpm install
pnpm dev # http://localhost:5173
```

Dev mode skips the setup token and two-factor. Data is stored in `src/backend/data/`.

Checks and builds: [docs/development.md](docs/development.md). Running it on a server: [docs/deployment.md](docs/deployment.md).
15 changes: 0 additions & 15 deletions apps/server/src/index.ts

This file was deleted.

Loading
Loading