diff --git a/.github/scripts/spdx.mjs b/.github/scripts/spdx.mjs new file mode 100644 index 0000000..d74b699 --- /dev/null +++ b/.github/scripts/spdx.mjs @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// Checks that hand-written source files carry an SPDX license header, or adds it. +// Usage: node .github/scripts/spdx.mjs . [--check] +import { execFileSync } from "node:child_process"; +import { readFileSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; + +const repo = process.argv[2]; +const check = process.argv.includes("--check"); +const ID = "SPDX-License-Identifier: AGPL-3.0-or-later"; + +const files = execFileSync("git", ["ls-files", "--cached", "--others", "--exclude-standard"], { + cwd: repo, + encoding: "utf8", +}) + .split("\n") + .filter((f) => /\.(go|ts|vue|dart|js|mjs|rs|sh|css)$/.test(f)) + .filter((f) => !f.endsWith(".d.ts")) + .filter((f) => !f.startsWith("Desktop-App/build/") && !f.startsWith("Desktop-App/frontend/bindings/")) + .filter((f) => !f.includes("node_modules/") && !f.startsWith("Phone-App/build/")); + +const missing = []; +for (const f of files) { + const path = join(repo, f); + let src = readFileSync(path, "utf8"); + if (src.includes("SPDX-License-Identifier")) continue; + if (/^\/\/ Code generated .* DO NOT EDIT\.$/m.test(src)) continue; + missing.push(f); + if (check) continue; + const ext = f.split(".").pop(); + if (ext === "vue") src = `\n${src}`; + else if (ext === "css") src = `/* ${ID} */\n\n${src}`; + else if (ext === "sh") { + if (src.startsWith("#!")) { + const nl = src.indexOf("\n"); + src = `${src.slice(0, nl + 1)}# ${ID}\n${src.slice(nl + 1)}`; + } else src = `# ${ID}\n\n${src}`; + } else src = `// ${ID}\n\n${src}`; + writeFileSync(path, src); +} +console.log(`${check ? "missing" : "added"}: ${missing.length}`); +if (check && missing.length) { + console.log(missing.join("\n")); + process.exit(1); +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 284783e..2fd0a60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,14 @@ jobs: run: | rustup target add wasm32-wasip1 go generate ./internal/ycrdt + - name: Go types are up to date + if: matrix.module == 'Server' + working-directory: Server + env: + GOWORK: "off" + run: | + go generate ./internal/api + git diff --exit-code internal/api - name: Vet and test working-directory: ${{ matrix.module }} env: @@ -30,6 +38,13 @@ jobs: test -z "$(gofmt -l .)" || (gofmt -l . && exit 1) go vet ./... go test -race ./... + - name: Lint + uses: golangci/golangci-lint-action@v8 + env: + GOWORK: "off" + with: + version: v2.14 + working-directory: ${{ matrix.module }} frontend: runs-on: ubuntu-latest @@ -40,6 +55,10 @@ jobs: node-version: 24 cache: npm - run: npm ci + - name: License headers + run: node .github/scripts/spdx.mjs . --check + - run: npm run lint + - run: npm run format:check - name: API types are up to date run: | npm run generate -w @docwell/api-client @@ -74,6 +93,14 @@ jobs: run: | go test ./... go build -o bin/ . + - name: Lint + if: runner.os == 'Linux' + uses: golangci/golangci-lint-action@v8 + env: + GOWORK: "off" + with: + version: v2.14 + working-directory: Desktop-App mobile: runs-on: ubuntu-latest @@ -86,6 +113,11 @@ jobs: with: channel: stable - run: flutter pub get + - name: Dart models are up to date + run: | + dart run tool/generate_api.dart + git diff --exit-code lib/api/generated + - run: dart format --set-exit-if-changed lib test tool - run: flutter analyze - run: flutter test diff --git a/.gitignore b/.gitignore index 68dd08a..fc806e0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,8 @@ coverage.out # Local design kit and planning docs (not part of the build) /Design/ /docs/ + +# Editor page built by Packages/editor-bridge and copied into the apps +/Phone-App/assets/editor/* +!/Phone-App/assets/editor/.gitkeep +/Phone-App/android/build/ diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..25733c9 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,34 @@ +# golangci-lint v2, shared by every Go module (run from the module folder). +version: "2" + +linters: + default: standard + enable: + - bodyclose + - errorlint + - gosec + - misspell + - unconvert + settings: + errcheck: + exclude-functions: + # Writing a response body fails only when the client went away. + - (net/http.ResponseWriter).Write + - (*encoding/json.Encoder).Encode + - (*github.com/coder/websocket.Conn).CloseNow + gosec: + excludes: + - G104 # unchecked errors: errcheck covers these, with the exclusions above + exclusions: + presets: + - std-error-handling + paths: + # Wails project template, regenerated by the Wails CLI. + - build/ + rules: + - path: _test\.go + linters: [errcheck, gosec] + # yrs.wasm is wasm32: its pointers and lengths are 32-bit by definition. + - path: internal/ycrdt/ + text: G115 + linters: [gosec] diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..3023a28 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,17 @@ +node_modules/ +dist/ +Phone-App/ +Spikes/ +Desktop-App/build/ +Desktop-App/frontend/bindings/ +Packages/api-client/src/schema.d.ts +*.md +*.yaml +*.yml +package-lock.json +target/ +pb_data/ +Database/ +Docker*/ +api/ +.claude/ diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..963354f --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,3 @@ +{ + "printWidth": 120 +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..9b5f963 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,44 @@ +# Code of Conduct + +Docwell follows the [Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). This page summarizes it; the linked text is the one that applies. + +## Our pledge + +We want taking part in Docwell to be a harassment-free experience for everyone, whatever their age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation. + +## Expected behaviour + +- Be kind and patient with other people. +- Respect differing opinions, viewpoints and experiences. +- Give constructive feedback, and accept it gracefully. +- Take responsibility for your mistakes, apologise to the people they affected, and learn from them. +- Focus on what is best for the community as a whole. + +## Unacceptable behaviour + +- Sexualized language or imagery, and sexual attention or advances of any kind. +- Trolling, insulting or derogatory comments, and personal or political attacks. +- Public or private harassment. +- Publishing someone else's private information, such as a physical or email address, without their explicit permission. +- Any other conduct that could reasonably be considered inappropriate in a professional setting. + +## Scope + +This applies in every project space (issues, pull requests, discussions, chat) and when someone officially represents the project in public. + +## Reporting + +Report unacceptable behaviour to the maintainers privately through GitHub (a direct message to a maintainer, or a private security advisory for anything sensitive). Every report is reviewed promptly and fairly, and maintainers keep the reporter's identity private. + +## Enforcement + +Maintainers decide what action to take, following the Covenant's enforcement guidelines: + +1. **Correction**: a private, written warning explaining what was inappropriate. +2. **Warning**: a warning with consequences for continued behaviour, including no interaction with the people involved for a set time. +3. **Temporary ban**: no interaction with the community for a set time. +4. **Permanent ban**: no interaction with the community at all. + +## Attribution + +Adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1, licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..889bb49 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,61 @@ +# Contributing to Docwell + +Thanks for helping. This page covers how to set up the repository, the checks a change has to pass, and how to send it. + +By taking part you agree to follow the [Code of Conduct](CODE_OF_CONDUCT.md). + +## Before you start + +- For anything bigger than a small fix, open an issue first so we can agree on the approach. +- Feature priorities (MVP, v1, v2) are fixed per phase. Work outside the current phase is unlikely to be merged yet. +- Report security problems privately to the maintainers, not in a public issue. + +## Setup + +Follow **Development** in the [README](README.md): Go 1.26+, Node 22+, Rust with the `wasm32-wasip1` target, Flutter 3.44+, the Wails v3 CLI and the PocketBase binary. + +```bash +npm install +``` + +## Checks + +CI runs all of these. Run the ones for the parts you touched before you push. + +| Area | Commands | +|---|---| +| Go (`Server/`, `Web-App/`, `Desktop-App/`) | `gofmt -l .`, `go vet ./...`, `golangci-lint run`, `go test ./...` (from each module) | +| Frontend (`Packages/`, `Server/admin/`, `Web-App/frontend/`, `Desktop-App/frontend/`) | `npm run lint`, `npm run format:check`, `npm run typecheck`, `npm test` (from the repo root) | +| Mobile (`Phone-App/`) | `dart format --set-exit-if-changed lib test`, `flutter analyze`, `flutter test` | +| API contract | `npm run generate` (from the repo root) after editing `api/openapi.yaml`, and commit the regenerated files | +| License headers | `node .github/scripts/spdx.mjs . --check` | + +`npm run format` and `npm run lint:fix` fix most frontend problems for you. + +## API changes + +`api/openapi.yaml` is the source of truth for every client. Change it first, then regenerate: + +- TypeScript types: `Packages/api-client/src/schema.d.ts` +- Go types: `Server/internal/api/api.gen.go` +- Dart models: `Phone-App/lib/api/generated/` + +`npm run generate` regenerates all three. CI fails if the committed files differ from what the contract generates. + +## Code style + +- Match the code around your change: naming, comment density and idiom. +- Authorization rules belong in `Server/internal/access` as pure functions with tests. +- Every new source file starts with `SPDX-License-Identifier: AGPL-3.0-or-later` in a comment. `node .github/scripts/spdx.mjs .` adds it. +- Comments and docs are in plain English: short sentences, and explain why rather than what. + +## Commits and pull requests + +- Keep each pull request to one change. Split refactors from behaviour changes. +- Write commit subjects in the imperative ("Add page trash", not "Added page trash"). +- Describe what changed, why, and how you tested it. Include screenshots for UI changes. +- Add or update tests for behaviour changes. + +## License + +Docwell is licensed under the [GNU AGPL v3.0 or later](LICENSE). By sending a contribution you agree that it is licensed under the same terms. diff --git a/Database/entrypoint.sh b/Database/entrypoint.sh index 9a3ba5e..89d0929 100644 --- a/Database/entrypoint.sh +++ b/Database/entrypoint.sh @@ -1,4 +1,5 @@ #!/bin/sh +# SPDX-License-Identifier: AGPL-3.0-or-later set -eu : "${PB_ADMIN_EMAIL:?PB_ADMIN_EMAIL is required}" diff --git a/Database/pb_hooks/docwell.pb.js b/Database/pb_hooks/docwell.pb.js index 927020b..2a495e6 100644 --- a/Database/pb_hooks/docwell.pb.js +++ b/Database/pb_hooks/docwell.pb.js @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + /// // Token check used by docwell-server: returns the "users" record that owns the diff --git a/Database/pb_migrations/1761850000_initial_schema.js b/Database/pb_migrations/1761850000_initial_schema.js index 5ebb3af..2ece767 100644 --- a/Database/pb_migrations/1761850000_initial_schema.js +++ b/Database/pb_migrations/1761850000_initial_schema.js @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + /// // Initial Docwell schema. All record API rules stay null (superuser only): PocketBase diff --git a/Database/pb_migrations/1761900000_organizations.js b/Database/pb_migrations/1761900000_organizations.js index 71828ed..37649ab 100644 --- a/Database/pb_migrations/1761900000_organizations.js +++ b/Database/pb_migrations/1761900000_organizations.js @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + /// // Organizations and the role hierarchy (same model as DriverVault): diff --git a/Database/pb_migrations/1762000000_collab.js b/Database/pb_migrations/1762000000_collab.js index 93a4e99..2ea9527 100644 --- a/Database/pb_migrations/1762000000_collab.js +++ b/Database/pb_migrations/1762000000_collab.js @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + /// // Collaboration storage. The server talks to PocketBase over JSON only, so the diff --git a/Desktop-App/build/config.yml b/Desktop-App/build/config.yml index aefeea7..3858107 100644 --- a/Desktop-App/build/config.yml +++ b/Desktop-App/build/config.yml @@ -67,6 +67,11 @@ dev_mode: type: primary exit_policy: shutdown +# URL schemes the installers register with the OS (deeplink.go handles them). +protocols: + - scheme: docwell + description: Docwell link + # File Associations # More information at: https://v3.wails.io/noit/done/yet fileAssociations: diff --git a/Desktop-App/build/darwin/Info.dev.plist b/Desktop-App/build/darwin/Info.dev.plist index 8065bda..2074df5 100644 --- a/Desktop-App/build/darwin/Info.dev.plist +++ b/Desktop-App/build/darwin/Info.dev.plist @@ -1,34 +1,46 @@ + - - CFBundlePackageType - APPL - CFBundleName - My Product - CFBundleExecutable - docwell-desktop.exe - CFBundleIdentifier - com.example.docwelldesktop - CFBundleVersion - 0.1.0 - CFBundleGetInfoString - This is a comment - CFBundleShortVersionString - 0.1.0 - CFBundleIconFile - icons - CFBundleIconName - appicon - LSMinimumSystemVersion - 12.0.0 - NSHighResolutionCapable - true - NSHumanReadableCopyright - © 2026, My Company - NSAppTransportSecurity - - NSAllowsLocalNetworking - - - + + CFBundleExecutable + docwell-desktop + CFBundleGetInfoString + Docwell desktop app + CFBundleIconFile + icons + CFBundleIconName + appicon + CFBundleIdentifier + app.docwell.desktop + CFBundleName + Docwell + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.1 + CFBundleURLTypes + + + CFBundleURLName + wails.com.docwell + CFBundleURLSchemes + + docwell + + + + CFBundleVersion + 0.0.1 + LSMinimumSystemVersion + 12.0.0 + NSAppTransportSecurity + + NSAllowsLocalNetworking + + + NSHighResolutionCapable + true + NSHumanReadableCopyright + Copyright (c) 2026 Docwell contributors + \ No newline at end of file diff --git a/Desktop-App/build/darwin/Info.plist b/Desktop-App/build/darwin/Info.plist index 86ffe83..272ef52 100644 --- a/Desktop-App/build/darwin/Info.plist +++ b/Desktop-App/build/darwin/Info.plist @@ -1,29 +1,41 @@ + - - CFBundlePackageType - APPL - CFBundleName - My Product - CFBundleExecutable - docwell-desktop.exe - CFBundleIdentifier - com.example.docwelldesktop - CFBundleVersion - 0.1.0 - CFBundleGetInfoString - This is a comment - CFBundleShortVersionString - 0.1.0 - CFBundleIconFile - icons - CFBundleIconName - appicon - LSMinimumSystemVersion - 12.0.0 - NSHighResolutionCapable - true - NSHumanReadableCopyright - © 2026, My Company - + + CFBundleExecutable + docwell-desktop + CFBundleGetInfoString + Docwell desktop app + CFBundleIconFile + icons + CFBundleIconName + appicon + CFBundleIdentifier + app.docwell.desktop + CFBundleName + Docwell + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.1 + CFBundleURLTypes + + + CFBundleURLName + wails.com.docwell + CFBundleURLSchemes + + docwell + + + + CFBundleVersion + 0.0.1 + LSMinimumSystemVersion + 12.0.0 + NSHighResolutionCapable + true + NSHumanReadableCopyright + Copyright (c) 2026 Docwell contributors + \ No newline at end of file diff --git a/Desktop-App/build/ios/Info.dev.plist b/Desktop-App/build/ios/Info.dev.plist index 69e11d4..2ef756d 100644 --- a/Desktop-App/build/ios/Info.dev.plist +++ b/Desktop-App/build/ios/Info.dev.plist @@ -1,61 +1,56 @@ - - CFBundleExecutable - docwell-desktop.exe - CFBundleIdentifier - com.example.docwelldesktop.dev - CFBundleName - My Product (Dev) - CFBundleDisplayName - My Product (Dev) - CFBundlePackageType - APPL - CFBundleShortVersionString - 0.1.0-dev - CFBundleVersion - 0.1.0 - LSRequiresIPhoneOS - - MinimumOSVersion - 15.0 - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - arm64 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSAllowsLocalNetworking - - - - WailsDevelopmentMode - - - NSHumanReadableCopyright - © 2026, My Company - - - CFBundleGetInfoString - This is a comment - - + + CFBundleDisplayName + Docwell (Dev) + CFBundleExecutable + docwell-desktop + CFBundleGetInfoString + Docwell desktop app + CFBundleIdentifier + app.docwell.desktop.dev + CFBundleName + Docwell (Dev) + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.1-dev + CFBundleVersion + 0.0.1 + LSRequiresIPhoneOS + + MinimumOSVersion + 15.0 + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSAllowsLocalNetworking + + + NSHumanReadableCopyright + Copyright (c) 2026 Docwell contributors + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + WailsDevelopmentMode + + \ No newline at end of file diff --git a/Desktop-App/build/ios/Info.plist b/Desktop-App/build/ios/Info.plist index 8c775f0..3031591 100644 --- a/Desktop-App/build/ios/Info.plist +++ b/Desktop-App/build/ios/Info.plist @@ -1,59 +1,54 @@ - - CFBundleExecutable - docwell-desktop.exe - CFBundleIdentifier - com.example.docwelldesktop - CFBundleName - My Product - CFBundleDisplayName - My Product - CFBundlePackageType - APPL - CFBundleShortVersionString - 0.1.0 - CFBundleVersion - 0.1.0 - LSRequiresIPhoneOS - - MinimumOSVersion - 15.0 - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - arm64 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSAllowsLocalNetworking - - - - - NSHumanReadableCopyright - © 2026, My Company - - - CFBundleGetInfoString - This is a comment - - + + CFBundleDisplayName + Docwell + CFBundleExecutable + docwell-desktop + CFBundleGetInfoString + Docwell desktop app + CFBundleIdentifier + app.docwell.desktop + CFBundleName + Docwell + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.1 + CFBundleVersion + 0.0.1 + LSRequiresIPhoneOS + + MinimumOSVersion + 15.0 + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSAllowsLocalNetworking + + + NSHumanReadableCopyright + Copyright (c) 2026 Docwell contributors + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + \ No newline at end of file diff --git a/Desktop-App/build/ios/LaunchScreen.storyboard b/Desktop-App/build/ios/LaunchScreen.storyboard index 6938944..6980009 100644 --- a/Desktop-App/build/ios/LaunchScreen.storyboard +++ b/Desktop-App/build/ios/LaunchScreen.storyboard @@ -16,14 +16,14 @@ -