Skip to content
Draft
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
56 changes: 29 additions & 27 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --no-frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Cache pnpm modules
uses: actions/cache@v3
Expand All @@ -41,31 +39,35 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-

- name: Format code with Prettier
id: format
- name: Find files changed by this pull request
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
pnpm exec prettier --write "**/*.{js,jsx,ts,tsx,json,md}"
if [ -n "$(git status --porcelain)" ]; then
echo "FORMAT_HAS_CHANGES=true" >> $GITHUB_ENV
fi
git add .
git diff --name-only --diff-filter=ACMR -z "$BASE_SHA...$HEAD_SHA" -- \
'*.js' '*.jsx' '*.ts' '*.tsx' '*.json' '*.md' > "$RUNNER_TEMP/codefox-format-files"
git diff --name-only --diff-filter=ACMR -z "$BASE_SHA...$HEAD_SHA" -- \
'*.js' '*.jsx' '*.ts' '*.tsx' > "$RUNNER_TEMP/codefox-lint-files"

- name: Run ESLint fix
id: lint
continue-on-error: true
- name: Format changed files with Prettier
run: |
pnpm exec eslint . --ext .js,.jsx,.ts,.tsx --fix
if [ -n "$(git status --porcelain)" ]; then
echo "LINT_HAS_CHANGES=true" >> $GITHUB_ENV
mapfile -d '' files < "$RUNNER_TEMP/codefox-format-files"
if (( ${#files[@]} )); then
pnpm exec prettier --write --ignore-unknown "${files[@]}"
git add -- "${files[@]}"
fi
# Run ESLint again to check remaining issues
pnpm exec eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 || echo "LINT_HAS_ERRORS=true" >> $GITHUB_ENV
git add .

- name: Check TypeScript
- name: Run ESLint fix on changed files
run: |
pnpm exec tsc --noEmit
if [ $? -ne 0 ]; then
echo "TS_HAS_ERRORS=true" >> $GITHUB_ENV
mapfile -d '' files < "$RUNNER_TEMP/codefox-lint-files"
if (( ${#files[@]} )); then
pnpm exec eslint --resolve-plugins-relative-to backend --fix "${files[@]}"
git add -- "${files[@]}"
fi
- uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a

- name: Check frontend TypeScript
run: pnpm exec tsc --project frontend/tsconfig.json --noEmit

- name: Check backend TypeScript
run: pnpm exec tsc --project backend/tsconfig.json --noEmit
- uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a
19 changes: 9 additions & 10 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ on:
branches: [ main ]
paths:
- 'backend/**'
- 'codefox-common/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'patches/**'
- '.github/workflows/backend-ci.yml'
- 'scripts/**'
workflow_dispatch:
jobs:
Expand All @@ -19,12 +23,11 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'

- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
run_install: false

- name: Get pnpm store directory
Expand All @@ -41,12 +44,8 @@ jobs:
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --no-frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Build codefox-common
working-directory: ./codefox-common
run: pnpm build

- name: Build backend
working-directory: ./backend
run: pnpm build
Expand All @@ -66,4 +65,4 @@ jobs:
./backend/node_modules
key: ${{ runner.os }}-backend-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-backend-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-backend-${{ hashFiles('**/pnpm-lock.yaml') }}-
14 changes: 5 additions & 9 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ jobs:
with:
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'pnpm'

- name: Get pnpm store directory
Expand All @@ -39,9 +37,7 @@ jobs:
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: |
cd backend
pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Run tests
run: |
Expand All @@ -55,4 +51,4 @@ jobs:
directory: ./backend/coverage
flags: backend
fail_ci_if_error: true
verbose: true
verbose: true
32 changes: 22 additions & 10 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ on:
branches: [ main ]
paths:
- 'frontend/**'
- 'codefox-common/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'patches/**'
- '.github/workflows/frontend-ci.yml'
- 'scripts/**'
workflow_dispatch:
jobs:
Expand All @@ -19,12 +23,11 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'

- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
run_install: false

- name: Get pnpm store directory
Expand All @@ -41,12 +44,21 @@ jobs:
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --no-frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Build codefox-common
working-directory: ./codefox-common
run: pnpm build

- name: Run focused frontend tests
working-directory: ./frontend
shell: bash
run: |
shopt -s nullglob
configs=(jest.*.config.js)
if (( ${#configs[@]} == 0 )); then
echo "No focused frontend test configurations in this revision"
fi
for config in "${configs[@]}"; do
pnpm exec jest --config "$config" --runInBand
done

- name: Build frontend
working-directory: ./frontend
run: pnpm build
Expand All @@ -62,4 +74,4 @@ jobs:
./frontend/node_modules
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
2 changes: 1 addition & 1 deletion frontend/src/config/common-path.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { existsSync, mkdirSync, promises as fsPromises } from 'fs-extra';
import { existsSync, mkdirSync, promises as fsPromises } from 'node:fs';
import { createHash } from 'crypto';

// Constants for the frontend root directory
Expand Down
123 changes: 123 additions & 0 deletions scripts/check-ci-workflows.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env node
/**
* CI must exercise the workspaces that actually exist. The old jobs built a
* deleted package, installed an incompatible pnpm, and ran tsc without a
* project. Keep those failures from hiding the product's checks again.
*/
import assert from 'node:assert/strict';
import { existsSync, readFileSync } from 'node:fs';

const read = (p) => readFileSync(new URL(`../${p}`, import.meta.url), 'utf8');
const workflows = Object.fromEntries(
['frontend-ci', 'backend-ci', 'autofix', 'codecov'].map((name) => [
name,
read(`.github/workflows/${name}.yml`),
])
);

for (const [name, source] of Object.entries(workflows)) {
assert.match(
source,
/pnpm\/action-setup@v4/,
`${name} uses an obsolete pnpm setup`
);
assert.doesNotMatch(
source,
/version: 8\b/,
`${name} overrides the declared pnpm`
);
assert.match(
source,
/node-version: '22'/,
`${name} cannot run the locked AI SDK`
);
assert.match(
source,
/pnpm install --frozen-lockfile/,
`${name} ignores the lockfile`
);
assert.doesNotMatch(
source,
/codefox-common/,
`${name} builds a deleted workspace`
);
for (const [, dir] of source.matchAll(/working-directory: (\S+)/g)) {
assert.ok(
existsSync(new URL(`../${dir}/package.json`, import.meta.url)),
`${name}: ${dir} is not a workspace`
);
}
}

for (const name of ['frontend-ci', 'backend-ci']) {
const source = workflows[name];
for (const path of [
'package.json',
'pnpm-lock.yaml',
'pnpm-workspace.yaml',
'patches/**',
`.github/workflows/${name}.yml`,
]) {
assert.ok(
source.includes(`- '${path}'`),
`${name} skips changes to ${path}`
);
}
assert.match(
source,
/run: pnpm check/,
`${name} no longer runs the source guards`
);
}

const frontend = workflows['frontend-ci'];
assert.match(
frontend,
/configs=\(jest\.\*\.config\.js\)/,
'focused frontend suites are not discovered'
);
assert.match(
frontend,
/for config in "\$\{configs\[@\]\}"/,
'only one frontend suite is run'
);
assert.match(
frontend,
/pnpm exec jest --config "\$config" --runInBand/,
'focused frontend suites are not executed'
);

const autofix = workflows.autofix;
for (const workspace of ['frontend', 'backend']) {
assert.ok(
autofix.includes(
`pnpm exec tsc --project ${workspace}/tsconfig.json --noEmit`
),
`autofix skips the ${workspace} typecheck`
);
}
assert.doesNotMatch(
autofix,
/continue-on-error/,
'autofix hides a failed check'
);
assert.match(
autofix,
/git diff --name-only --diff-filter=ACMR -z "\$BASE_SHA\.\.\.\$HEAD_SHA"/,
'autofix no longer scopes files to the pull request'
);
assert.match(
autofix,
/prettier --write --ignore-unknown "\$\{files\[@\]\}"/,
'formatting includes unrelated files'
);
assert.match(
autofix,
/eslint --resolve-plugins-relative-to backend --fix "\$\{files\[@\]\}"/,
'lint fixes include unrelated files'
);
assert.doesNotMatch(autofix, /git add \./, 'autofix stages unrelated changes');

console.log(
'ok — CI targets current workspaces, locked tools, source guards and focused tests'
);
23 changes: 22 additions & 1 deletion scripts/check-lint-feedback.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,16 @@ assert.equal(

// ── The wiring, which is what actually breaks ──────────────────────
const agent = read('backend/src/chat/project-agent.ts');
const instructions = read('backend/src/chat/instructions.ts');
// Assembly moved out of the harness module. Guard both the caller and the
// callee: checking the helper alone would pass if the agent stopped using it.
assert.match(
agent,
/const prompt = assemblePrompt\(\{\s*notes,\s*history,\s*handEdits,\s*lint,\s*asked,?\s*\}\)/,
'the agent no longer passes live findings to the prompt assembler'
);
assert.match(
instructions.slice(instructions.indexOf('export const assemblePrompt')),
/\$\{lintNote\(lint\)\}\$\{asked\}/,
'lint findings are no longer in the prompt, or no longer sit last before the request'
);
Expand All @@ -130,9 +138,22 @@ const controller = read('backend/src/chat/chat.controller.ts');
// restyle, a restore or a hand edit has since changed.
assert.match(
controller,
/lint:\s*\n?\s*project\.template === 'html'\s*\n?\s*\?\s*await this\.lintPage\(project\.projectPath\)/,
/const lint\s*=\s*project\.template === 'html'\s*\?\s*await this\.lintPage\(project\.projectPath\)/,
'the turn no longer lints the page before running the agent'
);
const agentOptions = controller.match(
/await runProjectAgent\(\{([\s\S]*?)\}\)/
)?.[1];
assert.match(
agentOptions ?? '',
/\blint,/,
'the freshly computed findings never reach the agent'
);
assert.ok(
controller.search(/\bconst lint\s*=/) <
controller.indexOf('await runProjectAgent('),
'the page is linted only after the agent has already run'
);
// The end-of-turn lint is what feeds the panel; both halves have to stay.
assert.match(
controller,
Expand Down
Loading
Loading