code-foundry 1.46.5 → 1.46.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -8
- package/docs/CONFIGURATION.md +6 -2
- package/package.json +1 -1
- package/src/lib/pre-commit.mjs +19 -0
- package/src/runtime-core.mjs +43 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.46.6](https://github.com/0xPlayerOne/code-foundry/compare/v1.46.5...v1.46.6) (2026-10-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **pre-commit:** build before lint and type-check when the gate opts in ([#748](https://github.com/0xPlayerOne/code-foundry/issues/748)) ([f56454f](https://github.com/0xPlayerOne/code-foundry/commit/f56454f313a1a5b802b8a17b09d850902de1ba55)), closes [#691](https://github.com/0xPlayerOne/code-foundry/issues/691)
|
|
9
|
+
|
|
3
10
|
## [1.46.5](https://github.com/0xPlayerOne/code-foundry/compare/v1.46.4...v1.46.5) (2026-10-08)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -133,16 +140,9 @@
|
|
|
133
140
|
|
|
134
141
|
* **ci:** cancel only superseded pull-request runs in managed workflows ([#710](https://github.com/0xPlayerOne/code-foundry/issues/710)) ([f5fead6](https://github.com/0xPlayerOne/code-foundry/commit/f5fead677c032d253f2e1a2a256da4f207ddfa2a))
|
|
135
142
|
|
|
136
|
-
## [1.44.1](https://github.com/0xPlayerOne/code-foundry/compare/v1.44.0...v1.44.1) (2026-10-03)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
### Bug Fixes
|
|
140
|
-
|
|
141
|
-
* **release:** budget the package without the changelog and ship recent history only ([#708](https://github.com/0xPlayerOne/code-foundry/issues/708)) ([ab365e0](https://github.com/0xPlayerOne/code-foundry/commit/ab365e0910472c3596429adc86a1c8f3e19730f9))
|
|
142
|
-
|
|
143
143
|
<!-- code-foundry: packaged changelog -->
|
|
144
144
|
|
|
145
145
|
---
|
|
146
146
|
|
|
147
|
-
This packaged changelog lists the 20 most recent releases;
|
|
147
|
+
This packaged changelog lists the 20 most recent releases; 241 older releases are omitted to keep the package small.
|
|
148
148
|
See the [full changelog](https://github.com/0xPlayerOne/code-foundry/blob/main/CHANGELOG.md) for the complete history.
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -131,7 +131,7 @@ See [Merge queue validation](merge-queues.md) before enabling it.
|
|
|
131
131
|
| `coverage_minimum` | `0`–`100` | Minimum percentage; defaults to `80`. |
|
|
132
132
|
| `coverage_metrics` | `lines`, `functions`, `branches`, `statements` | Metrics checked by the coverage gate. |
|
|
133
133
|
| `coverage_report` | comma-separated repository paths | Istanbul JSON summary or LCOV evidence files. |
|
|
134
|
-
| `pre_commit_build` | `true`, `false` | Run the project's build in the local pre-commit gate. Defaults to `false`; see [Pre-commit gate](#pre-commit-gate).
|
|
134
|
+
| `pre_commit_build` | `true`, `false` | Run the project's build in the local pre-commit gate, before lint and type-check (mirroring CI's ordering). Defaults to `false`; see [Pre-commit gate](#pre-commit-gate). |
|
|
135
135
|
| `filter_<task>` | comma-separated repository path globs | Skip a lane when no changed path matches; see [Lane path filters](#lane-path-filters). |
|
|
136
136
|
| `rust_sccache` | `true`, `false` | Install sccache and wrap rustc so compile artifacts survive manifest/lockfile churn. |
|
|
137
137
|
| `rust_nextest` | `true`, `false` | Install cargo-nextest and prefer `cargo nextest run` over `cargo test` in Rust test lanes. |
|
|
@@ -194,7 +194,11 @@ gate is change-aware and never runs work for code the commit cannot affect:
|
|
|
194
194
|
Clippy.
|
|
195
195
|
- The build does not run at commit time; CI and explicit commands own it. Set
|
|
196
196
|
`pre_commit_build: true` to run the `build` script (or `cargo build`) when
|
|
197
|
-
code is staged.
|
|
197
|
+
code is staged. The build then runs before lint and type-check — mirroring
|
|
198
|
+
CI's ordering — because those tasks read built package output. With the
|
|
199
|
+
build disabled, a lint or type-check failure that a fresh clone's missing
|
|
200
|
+
build output could explain is printed with a one-line note saying so instead
|
|
201
|
+
of a bare error.
|
|
198
202
|
|
|
199
203
|
Tools read working-tree contents, so a partially staged file is checked as it
|
|
200
204
|
exists on disk. Task scripts that declare dependencies of their own, such as a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-foundry",
|
|
3
|
-
"version": "1.46.
|
|
3
|
+
"version": "1.46.6",
|
|
4
4
|
"description": "A fast, language-aware repository factory for agent-ready workflows, testing, security, and release automation.",
|
|
5
5
|
"homepage": "https://github.com/0xPlayerOne/code-foundry#readme",
|
|
6
6
|
"bugs": {
|
package/src/lib/pre-commit.mjs
CHANGED
|
@@ -98,6 +98,25 @@ export function preCommitBuildEnabled(value) {
|
|
|
98
98
|
return resolved === 'true'
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* The one-line explanation printed when lint or type-check fails while the
|
|
103
|
+
* commit-time build is disabled. CI builds before those tasks, so a fresh
|
|
104
|
+
* clone can fail the gate against an unmodified tree — a bare ENOENT trains
|
|
105
|
+
* `--no-verify` unless the gate names the actual problem.
|
|
106
|
+
*
|
|
107
|
+
* @param {{ build: boolean, buildScript: boolean, packageManager: string | null }} options
|
|
108
|
+
* @returns {string | undefined} The hint, or undefined when it cannot apply.
|
|
109
|
+
*/
|
|
110
|
+
export function freshCloneBuildHint({ build, buildScript, packageManager }) {
|
|
111
|
+
if (build || !buildScript) return undefined
|
|
112
|
+
const runner = packageManager ?? 'npm'
|
|
113
|
+
return (
|
|
114
|
+
`note: these checks may be reading missing build output on a fresh clone; ` +
|
|
115
|
+
`run "${runner} run build" once, or set pre_commit_build: true in ` +
|
|
116
|
+
`.github/code-foundry.yml to build before lint and type-check`
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
101
120
|
/**
|
|
102
121
|
* Split a file list so one tool invocation never exceeds the platform's
|
|
103
122
|
* argument-length limit on very large commits.
|
package/src/runtime-core.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
parseStagedFiles,
|
|
26
26
|
planPreCommit,
|
|
27
27
|
preCommitBuildEnabled,
|
|
28
|
+
freshCloneBuildHint,
|
|
28
29
|
} from './lib/pre-commit.mjs'
|
|
29
30
|
import { runNodePackagePerformance } from './lib/node-package-performance.mjs'
|
|
30
31
|
import {
|
|
@@ -428,16 +429,20 @@ function commandExists(command) {
|
|
|
428
429
|
return spawnSync(command, ['--version'], { stdio: 'ignore' }).status === 0
|
|
429
430
|
}
|
|
430
431
|
|
|
431
|
-
/** @param {string} command @param {string[]} [args] @param {
|
|
432
|
+
/** @param {string} command @param {string[]} [args] @param {{ onFailure?: string }} [options] */
|
|
432
433
|
function run(command, args = [], options = {}) {
|
|
434
|
+
const { onFailure, ...spawnOptions } = options
|
|
433
435
|
const result = spawnSync(command, args, {
|
|
434
436
|
cwd: root,
|
|
435
437
|
stdio: 'inherit',
|
|
436
438
|
env: process.env,
|
|
437
|
-
...
|
|
439
|
+
...spawnOptions,
|
|
438
440
|
})
|
|
439
441
|
if (result.error) throw result.error
|
|
440
|
-
if (result.status !== 0)
|
|
442
|
+
if (result.status !== 0) {
|
|
443
|
+
if (onFailure) console.error(onFailure)
|
|
444
|
+
process.exit(result.status ?? 1)
|
|
445
|
+
}
|
|
441
446
|
}
|
|
442
447
|
|
|
443
448
|
// pip-audit can report its clean result with a non-zero status when the
|
|
@@ -494,28 +499,28 @@ function packageCommand(args) {
|
|
|
494
499
|
}
|
|
495
500
|
}
|
|
496
501
|
|
|
497
|
-
/** @param {string[]} names */
|
|
498
|
-
function runScript(names) {
|
|
502
|
+
/** @param {string[]} names @param {{ onFailure?: string }} [options] */
|
|
503
|
+
function runScript(names, options = {}) {
|
|
499
504
|
const name = names.find((candidate) => hasScript(candidate))
|
|
500
505
|
if (!name) return false
|
|
501
506
|
const [manager, args] = packageCommand(['run', name])
|
|
502
507
|
if (!manager) return false
|
|
503
|
-
run(manager, args)
|
|
508
|
+
run(manager, args, options)
|
|
504
509
|
return true
|
|
505
510
|
}
|
|
506
511
|
|
|
507
|
-
/** @param {string} tool @param {string[]} [args] */
|
|
508
|
-
function runTool(tool, args = []) {
|
|
512
|
+
/** @param {string} tool @param {string[]} [args] @param {{ onFailure?: string }} [options] */
|
|
513
|
+
function runTool(tool, args = [], options = {}) {
|
|
509
514
|
if (['ruff', 'pytest', 'pylint'].includes(tool)) {
|
|
510
515
|
const venvTool = resolve(root, `.venv/bin/${tool}`)
|
|
511
|
-
if (existsSync(venvTool)) return run(venvTool, args)
|
|
516
|
+
if (existsSync(venvTool)) return run(venvTool, args, options)
|
|
512
517
|
}
|
|
513
518
|
const [manager] = packageCommand([])
|
|
514
|
-
if (manager === 'bun') return run('bunx', ['--no-install', tool, ...args])
|
|
515
|
-
if (manager === 'pnpm') return run('pnpm', ['exec', tool, ...args])
|
|
516
|
-
if (manager === 'yarn') return run('yarn', ['exec', tool, ...args])
|
|
517
|
-
if (manager === 'npm') return run('npx', ['--no-install', tool, ...args])
|
|
518
|
-
return run(tool, args)
|
|
519
|
+
if (manager === 'bun') return run('bunx', ['--no-install', tool, ...args], options)
|
|
520
|
+
if (manager === 'pnpm') return run('pnpm', ['exec', tool, ...args], options)
|
|
521
|
+
if (manager === 'yarn') return run('yarn', ['exec', tool, ...args], options)
|
|
522
|
+
if (manager === 'npm') return run('npx', ['--no-install', tool, ...args], options)
|
|
523
|
+
return run(tool, args, options)
|
|
519
524
|
}
|
|
520
525
|
|
|
521
526
|
function install() {
|
|
@@ -1193,9 +1198,11 @@ function runToolOnFiles(tool, args, files) {
|
|
|
1193
1198
|
*
|
|
1194
1199
|
* The gate is change-aware: it formats and lints only staged files, runs the
|
|
1195
1200
|
* project's type-check command only when typed sources or compiler config are
|
|
1196
|
-
* staged, and never builds unless `pre_commit_build: true` opts back in
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1201
|
+
* staged, and never builds unless `pre_commit_build: true` opts back in — in
|
|
1202
|
+
* which case the build runs before lint and type-check, mirroring CI's
|
|
1203
|
+
* ordering, because those tasks read built package output. The full suite
|
|
1204
|
+
* still runs in CI. Tools see working-tree contents, so a partially staged
|
|
1205
|
+
* file is checked as it exists on disk.
|
|
1199
1206
|
*/
|
|
1200
1207
|
export function preCommit() {
|
|
1201
1208
|
const staged = parseStagedFiles(
|
|
@@ -1225,9 +1232,22 @@ export function preCommit() {
|
|
|
1225
1232
|
runScript(['format:check', 'format', 'fmt'])
|
|
1226
1233
|
}
|
|
1227
1234
|
}
|
|
1235
|
+
// Mirror CI's prerequisite ordering: lint, boundary, and type-check tasks
|
|
1236
|
+
// read built package output, so the opt-in build runs before them. Format
|
|
1237
|
+
// stays first for the fastest feedback on the most common failure. Without
|
|
1238
|
+
// the opt-in, a failure that CI (which builds first) cannot reproduce gets
|
|
1239
|
+
// the one-line explanation instead of training `--no-verify`.
|
|
1240
|
+
if (plan.build) ci('build')
|
|
1241
|
+
const buildHint = freshCloneBuildHint({
|
|
1242
|
+
build: plan.build,
|
|
1243
|
+
buildScript: hasScript('build'),
|
|
1244
|
+
packageManager: packageCommand([])[0],
|
|
1245
|
+
})
|
|
1246
|
+
|
|
1228
1247
|
if (js && (plan.lintAll || plan.lintFiles.length)) {
|
|
1229
1248
|
if (plan.lintAll) {
|
|
1230
|
-
if (!runScript(['lint']) && hasOxlintSetup())
|
|
1249
|
+
if (!runScript(['lint'], { onFailure: buildHint }) && hasOxlintSetup())
|
|
1250
|
+
runTool('oxlint', ['--deny-warnings'])
|
|
1231
1251
|
} else if (hasOxlintSetup()) {
|
|
1232
1252
|
runToolOnFiles(
|
|
1233
1253
|
'oxlint',
|
|
@@ -1241,8 +1261,11 @@ export function preCommit() {
|
|
|
1241
1261
|
if (js && plan.typeCheck) {
|
|
1242
1262
|
// Use the project's own command so project references, workspaces, and
|
|
1243
1263
|
// path aliases resolve exactly as they do in CI.
|
|
1244
|
-
const scripted = runScript(['type-check', 'typecheck', 'type:check']
|
|
1245
|
-
|
|
1264
|
+
const scripted = runScript(['type-check', 'typecheck', 'type:check'], {
|
|
1265
|
+
onFailure: buildHint,
|
|
1266
|
+
})
|
|
1267
|
+
if (!scripted && existsSync(resolve(root, 'tsconfig.json')))
|
|
1268
|
+
runTool('tsc', ['--noEmit'], { onFailure: buildHint })
|
|
1246
1269
|
}
|
|
1247
1270
|
if (plan.rust) {
|
|
1248
1271
|
run('cargo', ['fmt', '--check'])
|
|
@@ -1255,7 +1278,6 @@ export function preCommit() {
|
|
|
1255
1278
|
runToolOnFiles('ruff', ['format', '--check', '--force-exclude'], plan.pythonFiles)
|
|
1256
1279
|
runToolOnFiles('ruff', ['check', '--force-exclude'], plan.pythonFiles)
|
|
1257
1280
|
}
|
|
1258
|
-
if (plan.build) ci('build')
|
|
1259
1281
|
}
|
|
1260
1282
|
|
|
1261
1283
|
// Only dispatch when this module is the process entry point. The CLI imports
|