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: 8 additions & 0 deletions .codex/bootstrap/tests-docs.v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"contract": "tests-docs-bootstrap-v1",
"adapter": "node-ts",
"branch": "codex/bootstrap-tests-docs-v1",
"generated_at": "2026-02-17T05:41:48.224Z",
"generated_by": "/Users/d/.codex/scripts/bootstrap/global_tests_docs_bootstrap.mjs",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The generated_by field contains a hardcoded absolute path to a user's local directory. This is not portable and exposes details about the local machine setup. It's better to use just the script name to improve portability and avoid leaking local machine details.

Suggested change
"generated_by": "/Users/d/.codex/scripts/bootstrap/global_tests_docs_bootstrap.mjs",
"generated_by": "global_tests_docs_bootstrap.mjs",

"changed_files": []
}
14 changes: 14 additions & 0 deletions .codex/prompts/test-critic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
You are a QA Test Critic reviewing only changed files and related tests.

Review criteria:
1. Tests assert behavior outcomes, not implementation details.
2. Each changed behavior includes edge/error/boundary coverage.
3. Mocks are used only at external boundaries.
4. UI tests cover loading/empty/error/success and disabled/focus-visible states.
5. Assertions would fail under realistic regressions.
6. Flag brittle selectors, snapshot spam, and tautological assertions.
7. Flag missing docs updates for API/command or architecture changes.

Output:
- Emit ReviewFindingV1 findings only.
- Priority order: critical, high, medium, low.
21 changes: 21 additions & 0 deletions .codex/scripts/run_verify_commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

VERIFY_FILE="${1:-.codex/verify.commands}"
if [[ ! -f "$VERIFY_FILE" ]]; then
echo "missing verify commands file: $VERIFY_FILE" >&2
exit 1
fi

failed=0
while IFS= read -r cmd || [[ -n "$cmd" ]]; do
[[ -z "$cmd" ]] && continue
[[ "$cmd" =~ ^# ]] && continue
echo ">>> $cmd"
if ! bash -lc "$cmd"; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-critical critical

This line introduces a critical command injection vulnerability. The cmd variable, read directly from the VERIFY_FILE, is executed without sanitization, allowing arbitrary command injection and potential remote code execution. Additionally, using bash -l makes the script's behavior dependent on the user's login shell configuration, which can lead to non-reproducible behavior. The suggested change addresses both the command injection by properly quoting the command and improves reproducibility.

Suggested change
if ! bash -lc "$cmd"; then
if ! bash -lc "$(printf %q "$cmd")"; then

failed=1
break
fi
done < "$VERIFY_FILE"

exit "$failed"
7 changes: 7 additions & 0 deletions .codex/verify.commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pnpm lint
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace verify command list with existing repo scripts

The verification runner executes .codex/verify.commands verbatim, and the first entry is pnpm lint even though package.json does not define a lint script (same issue for typecheck, test:integration, test:e2e:smoke, and docs:*). pnpm returns Command "lint" not found, so the gate stops immediately and cannot validate the repository as intended.

Useful? React with 👍 / 👎.

pnpm typecheck
pnpm test:coverage
pnpm test:integration
pnpm test:e2e:smoke
pnpm docs:generate
pnpm docs:check
46 changes: 46 additions & 0 deletions .github/workflows/quality-gates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: quality-gates

on:
pull_request:
push:
branches: [main, master]

jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- uses: actions/setup-node@v5
with:
node-version: 22

- uses: pnpm/action-setup@v4

Check warning on line 20 in .github/workflows/quality-gates.yml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/workflows/quality-gates.yml#L20

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
version: 9

- name: Install dependencies
run: pnpm install --frozen-lockfile
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use a lockfile-compatible install command in quality gate

This job installs dependencies with pnpm install --frozen-lockfile, but the repository only contains package-lock.json (no pnpm-lock.yaml), so pnpm exits with ERR_PNPM_NO_LOCKFILE before any checks run. In practice this makes the new quality-gates workflow fail on every run unless a pnpm lockfile is added or the install command is switched to an npm-compatible path.

Useful? React with 👍 / 👎.


- name: Policy checks
run: node scripts/ci/require-tests-and-docs.mjs

- name: Verify commands
run: bash .codex/scripts/run_verify_commands.sh

- name: Diff coverage
run: |
python -m pip install --upgrade pip diff-cover
diff-cover coverage/lcov.info --compare-branch=origin/main --fail-under=90

- name: Upload test artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-artifacts
path: |
playwright-report/
test-results/
coverage/
Comment on lines +10 to +46

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 1 month ago

In general, to fix this class of problem you explicitly define a permissions block at the workflow root or for the specific job, granting only the minimal scopes required (often contents: read for typical CI tasks). This prevents unintended broad access from inherited defaults and makes the workflow’s needs clear.

For this workflow, the simplest and best fix without changing existing functionality is to add a job-level permissions block under jobs.quality, setting contents: read. None of the steps require writing to the repository or modifying issues/PRs via API; they only need to read the code and upload artifacts. GitHub-hosted runners always have network/FS access needed for dependency installation and diff analysis; these do not require extra GITHUB_TOKEN scopes. So we will edit .github/workflows/quality-gates.yml, and directly under quality: (before runs-on:) add:

    permissions:
      contents: read

No additional imports, methods, or definitions are needed since this is a YAML workflow configuration change only.

Suggested changeset 1
.github/workflows/quality-gates.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/quality-gates.yml b/.github/workflows/quality-gates.yml
--- a/.github/workflows/quality-gates.yml
+++ b/.github/workflows/quality-gates.yml
@@ -7,6 +7,8 @@
 
 jobs:
   quality:
+    permissions:
+      contents: read
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v5
EOF
@@ -7,6 +7,8 @@

jobs:
quality:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Copilot is powered by AI and may make mistakes. Always verify output.
13 changes: 13 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Definition of Done: Tests + Docs (Blocking)

- Any production code change must include meaningful test updates in the same PR.
- Meaningful tests must include at least:
- one primary behavior assertion
- two non-happy-path assertions (edge, boundary, invalid input, or failure mode)
- Trivial assertions are forbidden (`expect(true).toBe(true)`, snapshot-only without semantic assertions, render-only smoke tests without behavior checks).
- Mock only external boundaries (network, clock, randomness, third-party SDKs). Do not mock the unit under test.
- UI changes must cover state matrix: loading, empty, error, success, disabled, focus-visible.
- API/command surface changes must update generated contract artifacts and request/response examples.
- Architecture-impacting changes must include an ADR in `/docs/adr/`.
- Required checks are blocking when `fail` or `not-run`: lint, typecheck, tests, coverage, diff coverage, docs check.
- Reviewer -> fixer -> reviewer loop is required before merge.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,49 @@ npm run test:pack-qa
npm run tauri dev
```

### Lean Dev (low disk mode)

Use this when you want to keep local disk usage down while developing:

```bash
npm install
npm run dev:lean
```

What `npm run dev:lean` does:
- Starts the app with the normal `npm run tauri dev` flow.
- Redirects heavy build caches to temporary directories (Cargo target + Vite cache).
- Automatically removes temporary caches and heavy build artifacts when you exit the app.
- Prints before/after disk usage snapshots for major bloat paths.

Disk vs speed tradeoff:
- Lean mode uses less persistent disk.
- Lean mode is usually slower on next startup because caches are rebuilt.
- Normal `npm run tauri dev` keeps caches in-repo for faster repeated starts.

### Cleanup commands

Target heavy build artifacts only:

```bash
npm run clean:heavy
```

This removes:
- `dist/`
- `artifacts/`
- `src-tauri/target/`
- `node_modules/.vite/`

Full local reproducible cleanup:

```bash
npm run clean:all
```

This runs `clean:heavy` and also removes:
- `node_modules/`

## Verification

```bash
Expand Down
16 changes: 16 additions & 0 deletions docs/adr/0000-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 0000. Title

## Status
Proposed | Accepted | Superseded

## Context
What problem or constraint forced this decision?

## Decision
What was chosen?

## Consequences
What improves, what tradeoffs are accepted, what risks remain?

## Alternatives Considered
Option A, Option B, and why they were rejected.
9 changes: 9 additions & 0 deletions openapi/openapi.generated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"openapi": "3.1.0",
"info": {
"title": "API Contract",
"version": "1.0.0"
},
"paths": {},
"components": {}
}
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"dev": "node ./node_modules/vite/bin/vite.js",
"dev:lean": "bash ./scripts/lean-dev.sh",
"build": "node ./node_modules/typescript/bin/tsc && node ./node_modules/vite/bin/vite.js build",
"clean:heavy": "bash ./scripts/clean-heavy.sh",
"clean:all": "bash ./scripts/clean-all.sh",
"check:performance-budget": "node ./scripts/check_performance_budget.mjs",
"test:pack-qa": "node ./scripts/pack_qa.mjs",
"test": "vitest run",
"test:watch": "vitest",
"test:ui": "vitest --ui",
"test:coverage": "vitest run --coverage",
"test": "node ./node_modules/vitest/vitest.mjs run",
"test:watch": "node ./node_modules/vitest/vitest.mjs",
"test:ui": "node ./node_modules/vitest/vitest.mjs --ui",
"test:coverage": "node ./node_modules/vitest/vitest.mjs run --coverage",
"test:rust": "cargo test --manifest-path src-tauri/Cargo.toml",
"test:rust:release": "cargo test --manifest-path src-tauri/Cargo.toml --release",
"test:all": "npm test && npm run test:rust",
"test:smoke": "./scripts/tauri-smoke.sh",
"tauri": "tauri",
"tauri": "node ./node_modules/@tauri-apps/cli/tauri.js",
"test:tauri-preflight": "./scripts/tauri-preflight.sh"
},
"dependencies": {
Expand Down
41 changes: 41 additions & 0 deletions scripts/ci/require-tests-and-docs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { execSync } from 'node:child_process';

Check warning on line 1 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L1

Do not import Node.js builtin module "node:child_process"

Check warning on line 1 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L1

ES2015 modules are forbidden.

const defaultBaseRef = (() => {

Check warning on line 3 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L3

ES2015 arrow function expressions are forbidden.

Check warning on line 3 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L3

ES2015 block-scoped variables are forbidden.

Check warning on line 3 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L3

Function must end with a return statement, so that it doesn't return `undefined`
try {
return execSync('git symbolic-ref refs/remotes/origin/HEAD', { encoding: 'utf8' }).trim().replace('refs/remotes/', '');
} catch {
return 'origin/main';
}
})();

const baseRef = process.env.GITHUB_BASE_REF ? `origin/${process.env.GITHUB_BASE_REF}` : defaultBaseRef;

Check warning on line 11 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L11

ES2015 block-scoped variables are forbidden.

Check warning on line 11 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L11

ES2015 template literals are forbidden.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: ES2015 template literals are forbidden.

Suggested change
const baseRef = process.env.GITHUB_BASE_REF ? `origin/${process.env.GITHUB_BASE_REF}` : defaultBaseRef;
const baseRef = process.env.GITHUB_BASE_REF ? "origin/"+process.env.GITHUB_BASE_REF : defaultBaseRef;

const diff = execSync(`git diff --name-only ${baseRef}...HEAD`, { encoding: 'utf8' })

Check warning on line 12 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L12

ES2015 block-scoped variables are forbidden.

Check warning on line 12 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L12

ES2015 template literals are forbidden.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-critical critical

The baseRef variable, which can be controlled by the GITHUB_BASE_REF environment variable, is directly used in an execSync call without proper sanitization. This allows for command injection if an attacker can control the GITHUB_BASE_REF environment variable.

To remediate this, ensure that baseRef is properly sanitized before being used in the execSync command. Consider using a library that safely escapes shell arguments or strictly validating the input.

Suggested change
const diff = execSync(`git diff --name-only ${baseRef}...HEAD`, { encoding: 'utf8' })
const diff = execSync(`git diff --name-only ${JSON.stringify(baseRef)}...HEAD`, { encoding: 'utf8' })

.split('\n')
.map((line) => line.trim())

Check warning on line 14 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L14

ES2015 arrow function expressions are forbidden.

Check warning on line 14 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L14

Missing "line" parameter type annotation.
.filter(Boolean);

const isProdCode = (file) => /^(src|app|server|api)\//.test(file) && !/\.(test|spec)\.[cm]?[jt]sx?$/.test(file);

Check warning on line 17 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L17

ES2015 arrow function expressions are forbidden.

Check warning on line 17 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L17

ES2015 block-scoped variables are forbidden.

Check warning on line 17 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L17

Missing "file" parameter type annotation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: ES2015 arrow function expressions are forbidden.

Suggested change
const isProdCode = (file) => /^(src|app|server|api)\//.test(file) && !/\.(test|spec)\.[cm]?[jt]sx?$/.test(file);
const isProdCode = function(file) { return /^(src|app|server|api)\//.test(file) && !/\.(test|spec)\.[cm]?[jt]sx?$/.test(file) };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The isProdCode check relies on a whitelist of directories (src, app, server, api). This means if production code is added to a new directory (e.g., lib/, shared/), it will not be covered by this policy check, potentially allowing production code changes without corresponding tests. Consider making this more robust, for example by defining production code as any code that is not part of other explicit categories like tests, docs, or config.

const isTest = (file) => /^tests\//.test(file) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(file);

Check warning on line 18 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L18

ES2015 arrow function expressions are forbidden.

Check warning on line 18 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L18

ES2015 block-scoped variables are forbidden.

Check warning on line 18 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L18

Missing "file" parameter type annotation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: ES2015 arrow function expressions are forbidden.

Suggested change
const isTest = (file) => /^tests\//.test(file) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(file);
const isTest = function(file) { return /^tests\//.test(file) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(file) };

const isDoc = (file) => /^docs\//.test(file) || /^openapi\//.test(file) || file === 'README.md';

Check warning on line 19 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L19

ES2015 arrow function expressions are forbidden.

Check warning on line 19 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L19

ES2015 block-scoped variables are forbidden.

Check warning on line 19 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L19

Missing "file" parameter type annotation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: ES2015 arrow function expressions are forbidden.

Suggested change
const isDoc = (file) => /^docs\//.test(file) || /^openapi\//.test(file) || file === 'README.md';
const isDoc = function(file) { return /^docs\//.test(file) || /^openapi\//.test(file) || file === 'README.md' };

const isApiSurface = (file) => /^(src|app|server|api)\/.*(route|controller|handler|webhook|api|command)/.test(file);

Check warning on line 20 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L20

ES2015 arrow function expressions are forbidden.

Check warning on line 20 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L20

ES2015 block-scoped variables are forbidden.

Check warning on line 20 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L20

Missing "file" parameter type annotation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: ES2015 arrow function expressions are forbidden.

Suggested change
const isApiSurface = (file) => /^(src|app|server|api)\/.*(route|controller|handler|webhook|api|command)/.test(file);
const isApiSurface = function(file) { return /^(src|app|server|api)\/.*(route|controller|handler|webhook|api|command)/.test(file) };

const isArchChange = (file) => /^src\/(auth|db|infra|queue|events|architecture)\//.test(file) || /^infra\//.test(file);

Check warning on line 21 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L21

ES2015 arrow function expressions are forbidden.

Check warning on line 21 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L21

ES2015 block-scoped variables are forbidden.

Check warning on line 21 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L21

Missing "file" parameter type annotation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: ES2015 arrow function expressions are forbidden.

Suggested change
const isArchChange = (file) => /^src\/(auth|db|infra|queue|events|architecture)\//.test(file) || /^infra\//.test(file);
const isArchChange = function(file) { return /^src\/(auth|db|infra|queue|events|architecture)\//.test(file) || /^infra\//.test(file) };

const isAdr = (file) => /^docs\/adr\/\d{4}-.*\.md$/.test(file);

Check warning on line 22 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L22

ES2015 arrow function expressions are forbidden.

Check warning on line 22 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L22

ES2015 block-scoped variables are forbidden.

Check warning on line 22 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L22

Missing "file" parameter type annotation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: ES2015 arrow function expressions are forbidden.

Suggested change
const isAdr = (file) => /^docs\/adr\/\d{4}-.*\.md$/.test(file);
const isAdr = function(file) { return /^docs\/adr\/\d{4}-.*\.md$/.test(file) };


const prodChanged = diff.some(isProdCode);

Check warning on line 24 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L24

ES2015 block-scoped variables are forbidden.
const testsChanged = diff.some(isTest);

Check warning on line 25 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L25

ES2015 block-scoped variables are forbidden.
const apiChanged = diff.some(isApiSurface);

Check warning on line 26 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L26

ES2015 block-scoped variables are forbidden.
const docsChanged = diff.some(isDoc);

Check warning on line 27 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L27

ES2015 block-scoped variables are forbidden.
const archChanged = diff.some(isArchChange);

Check warning on line 28 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L28

ES2015 block-scoped variables are forbidden.
const adrChanged = diff.some(isAdr);

Check warning on line 29 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L29

ES2015 block-scoped variables are forbidden.

const failures = [];

Check warning on line 31 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L31

ES2015 block-scoped variables are forbidden.
if (prodChanged && !testsChanged) failures.push('Policy failure: production code changed without test updates.');
if (apiChanged && !docsChanged) failures.push('Policy failure: API/command changes without docs/OpenAPI updates.');
if (archChanged && !adrChanged) failures.push('Policy failure: architecture-impacting change without ADR.');

if (failures.length > 0) {
for (const failure of failures) console.error(failure);

Check warning on line 37 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L37

ES2015 block-scoped variables are forbidden.

Check warning on line 37 in scripts/ci/require-tests-and-docs.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/ci/require-tests-and-docs.mjs#L37

Variable must be initialized, so that it doesn't evaluate to `undefined`
process.exit(1);
}

console.log('Policy checks passed.');
19 changes: 19 additions & 0 deletions scripts/clean-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

"$ROOT_DIR/scripts/clean-heavy.sh"

ALL_TARGETS=(
"$ROOT_DIR/node_modules"
)

for target in "${ALL_TARGETS[@]}"; do
if [ -e "$target" ]; then
rm -rf "$target"
echo "Removed $target"
else
echo "Skipped $target (not present)"
fi
done
20 changes: 20 additions & 0 deletions scripts/clean-heavy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

TARGETS=(
"$ROOT_DIR/dist"
"$ROOT_DIR/artifacts"
"$ROOT_DIR/src-tauri/target"
"$ROOT_DIR/node_modules/.vite"
)

for target in "${TARGETS[@]}"; do
if [ -e "$target" ]; then
rm -rf "$target"
echo "Removed $target"
else
echo "Skipped $target (not present)"
fi
done
53 changes: 53 additions & 0 deletions scripts/lean-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
LEAN_CACHE_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/desktop-pet-lean.XXXXXX")"

export CARGO_TARGET_DIR="$LEAN_CACHE_ROOT/cargo-target"
export DESKTOPPET_VITE_CACHE_DIR="$LEAN_CACHE_ROOT/vite-cache"
mkdir -p "$CARGO_TARGET_DIR" "$DESKTOPPET_VITE_CACHE_DIR"

print_size_report() {
local label="$1"
echo
echo "[$label] Disk usage snapshot"
for path in \
"$ROOT_DIR/node_modules" \
"$ROOT_DIR/node_modules/.vite" \
"$ROOT_DIR/src-tauri/target" \
"$ROOT_DIR/dist" \
"$ROOT_DIR/artifacts" \
"$CARGO_TARGET_DIR" \
"$DESKTOPPET_VITE_CACHE_DIR"; do
if [ -e "$path" ]; then
du -sh "$path"
else
echo "0B $path (missing)"
fi
done
}

cleanup() {
local exit_code=$?
echo
echo "lean-dev: cleaning temporary caches"
rm -rf "$LEAN_CACHE_ROOT"

if "$ROOT_DIR/scripts/clean-heavy.sh"; then
true
else
echo "lean-dev: warning - heavy cleanup encountered an issue" >&2
fi

print_size_report "After cleanup"
exit "$exit_code"
}
trap cleanup EXIT INT TERM

print_size_report "Before start"
echo

echo "lean-dev: using temporary cache root $LEAN_CACHE_ROOT"
cd "$ROOT_DIR"
npm run tauri dev
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import tailwindcss from "@tailwindcss/vite";
import { resolve } from "path";

const host = process.env.TAURI_DEV_HOST;
const leanCacheDir = process.env.DESKTOPPET_VITE_CACHE_DIR;

export default defineConfig({
plugins: [react(), tailwindcss()],
clearScreen: false,
cacheDir: leanCacheDir || "node_modules/.vite",
server: {
port: 5173,
strictPort: true,
Expand Down
Loading