code-foundry 0.21.1 → 0.22.0

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/README.md CHANGED
@@ -3,229 +3,133 @@
3
3
  [![npm version](https://img.shields.io/npm/v/code-foundry?logo=npm&logoColor=white)](https://www.npmjs.com/package/code-foundry)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/code-foundry?logo=npm&logoColor=white)](https://www.npmjs.com/package/code-foundry)
5
5
  [![CI](../../actions/workflows/ci.yml/badge.svg?branch=main)](../../actions/workflows/ci.yml)
6
- [![Latest GitHub release](https://img.shields.io/badge/GitHub%20release-latest-181717?logo=github)](../../releases/latest)
6
+ [![Latest release](https://img.shields.io/github/v/release/0xPlayerOne/code-foundry?logo=github)](../../releases/latest)
7
7
 
8
- `code-foundry` is a repository factory for TypeScript, Rust, Python, Solidity,
9
- and mixed-language projects. It installs agent-ready instructions, fast native
10
- testing, security automation, release workflows, hooks, and repository policy
11
- from one versioned package.
8
+ `code-foundry` is a versioned repository baseline for TypeScript, Rust, Python,
9
+ Solidity, and mixed-language projects. It provides language-aware workflows,
10
+ native testing, security automation, releases, hooks, repository policy, and
11
+ agent instructions from one initializer.
12
12
 
13
13
  ## Quick start
14
14
 
15
- ```bash
16
- npx code-foundry init
17
- ```
18
-
19
- Or select the project profile explicitly:
20
-
21
- ```bash
22
- npx code-foundry init \
23
- --languages typescript,python \
24
- --features all \
25
- --package-manager bun
26
- ```
27
-
28
- Use `code-foundry sync` to update an existing repository and
29
- `code-foundry doctor` to validate it. Add `--dry-run` to preview changes.
30
-
31
- Choose the license during initialization without editing generated files:
32
-
33
- ```bash
34
- npx code-foundry init --license mit
35
- npx code-foundry init --license agpl-3.0-or-later
36
- npx code-foundry init --license-file ./legal/LICENSE.txt
37
- ```
38
-
39
- Reusable workflow callers use the source template's runtime automatically. For
40
- example, initializing from `NiftyLeague/template-repo` selects that fork's
41
- runtime without extra flags. Use `--runtime-repository OWNER/REPO` (or
42
- `REPO_FOUNDRY_RUNTIME_REPOSITORY`) only when you want to override it. The
43
- selected repository is saved in `.github/template.yml` and rendered into the
44
- small CI, Test, Security, CodeQL, Draft PR, and Release PR wrappers
45
- automatically. Use `--runtime-ref REF` (or `REPO_FOUNDRY_RUNTIME_REF`) to pin
46
- those callers to a fork's release tag or branch; the selected ref is persisted
47
- alongside the runtime repository.
48
-
49
- Normal synchronization imports only the local hook, agent-facing command,
50
- profile/release, initializer, doctor, ownership, and protection entrypoints.
51
- Workflow-only actions and Security/CodeQL analyzers stay in the versioned
52
- runtime package and are not duplicated in consumer repositories.
53
-
54
- The standard Security wrapper uses the same runtime contract, so dependency
55
- audits and the public-only Dependency Review policy can be upgraded centrally
56
- without copying security scripts into every consumer repository.
57
-
58
- CodeQL is also independently reusable through the same contract. It retains
59
- GitHub's native security-event permissions and language-specific analysis while
60
- keeping CodeQL separate from CI and dependency security checks.
61
-
62
- Release automation follows the same model: the consumer keeps a short
63
- main-branch wrapper while the shared runtime handles Release Please, GitHub
64
- release metadata, optional npm publication, provenance, and token/trusted
65
- publishing fallback.
66
-
67
- The promotion runtimes for Draft PR and Release PR are maintained in the same
68
- versioned repository and are released before their short consumer callers move
69
- to a new tag, avoiding a bootstrap cycle.
70
-
71
- Initialization defaults to AGPL for new repositories. Synchronization defaults
72
- to `--license preserve`, so an existing repository's license is never replaced
73
- unless you explicitly select a license or provide `--license-file`.
74
-
75
- The generated Git hook is intentionally a small launcher. It points at the
76
- package-managed `.github/scripts/pre-commit.sh`, so repositories do not need to
77
- maintain a second copy of the language-aware hook logic.
78
-
79
- ## Setup
80
-
81
- 1. Install [mise](https://mise.jdx.dev/).
82
- 2. Run `bash .github/scripts/bootstrap.sh` to install the pinned toolchain, enable hooks, and validate the repository.
83
- 3. Add the repository's standard scripts (`format:check`, `lint`, `type-check`, `build`, `test:unit`, `test:integration`, `test:e2e`, and `test:smoke`) when available. The shared scripts also recognize legacy aliases and skip checks that do not apply to the repository's languages or package manager.
84
-
85
- ## Applying the baseline to an existing repository
86
-
87
- Run the package entrypoint from the repository root. It updates shared
88
- workflows, GitHub forms, hooks, policy files, and tool configuration while
89
- preserving the repository's README, `.mise.toml` selections, extra workflows,
90
- licenses, and application code.
15
+ Run this from the root of a repository:
91
16
 
92
17
  ```bash
93
18
  npx code-foundry init
94
19
  ```
95
20
 
96
- Use `bash .github/scripts/sync-template.sh --source ... --check` to preview differences. For local template development, pass the template checkout as `--source` and `--ref staging`.
97
-
98
- The initializer is intentionally flag-driven so the same baseline can be used as a small repository package. Language selection controls CodeQL and records the repository profile; feature selection controls which standard workflows are installed. `auto` detects supported languages, while `all` enables every standard workflow. The resolver profiles the repository for language, package manager, project shape, release type, runners, and cache policy.
99
-
100
- Existing authored documentation and issue/PR templates are preserved by
101
- default. Pass `--force` when intentionally refreshing those files from the
102
- baseline; repository-specific workflows and application files remain protected.
21
+ Useful variants:
103
22
 
104
23
  ```bash
105
- # Preview a TypeScript + Python repository without changing files
106
- bash .github/scripts/init-repo.sh \
107
- --languages typescript,python \
108
- --features all \
109
- --dry-run
110
-
111
- # Initialize a Rust repository with only the core automation
112
- bash .github/scripts/init-repo.sh \
113
- --languages rust \
114
- --features ci,codeql,security,test
115
- ```
116
-
117
- Supported profiles are `application`, `monorepo`, and `minimal`; use `auto` to detect one. Supported languages are `typescript`, `rust`, `python`, and `solidity`. Supported feature flags are `ci`, `codeql`, `security`, `test`, `draft-pr`, `release-pr`, `release`, and `dependabot`. Use `--prune` only when you explicitly want disabled standard workflows removed; custom workflows are always preserved. The selected profile is stored in `.github/template.yml`, which makes later syncs repeatable and lets workflows consume repository-specific settings without duplicating the template scripts.
118
-
119
- Profile precedence is consistent everywhere: explicit CLI flags, then `REPO_FOUNDRY_*` GitHub repository variables/environment values, then `.github/template.yml`, then automatic detection and standard defaults. Useful repository variables include `REPO_FOUNDRY_PROFILE`, `REPO_FOUNDRY_LANGUAGES`, `REPO_FOUNDRY_FEATURES`, `REPO_FOUNDRY_PACKAGE_MANAGER`, `REPO_FOUNDRY_RUNTIME_REPOSITORY`, `REPO_FOUNDRY_RUNTIME_REF`, `REPO_FOUNDRY_RUNNER`, `REPO_FOUNDRY_UNIT_RUNNER`, `REPO_FOUNDRY_CACHE_PACKAGES`, `REPO_FOUNDRY_CACHE_BUILD`, `REPO_FOUNDRY_COVERAGE_MINIMUM`, and `REPO_FOUNDRY_TURBO_REMOTE`. Use CLI flags for one-off initialization; use repository variables for local overrides that should not be committed.
120
-
121
- Inspect the resolved profile at any time with `bash .github/scripts/profile.sh detect`; use `profile.sh get KEY` when another script needs one setting.
122
-
123
- ## Releases and publishing
124
-
125
- The standard release workflow uses [Release Please](https://github.com/googleapis/release-please) after changes reach `main`. It opens or updates a versioned release pull request, maintains `CHANGELOG.md`, creates the GitHub release after that PR is merged, and applies semantic version bumps from Conventional Commits. The reusable `release-please-config.json` groups feature, fix, performance, dependency, documentation, test, CI, and maintenance changes in generated notes:
24
+ # Choose languages and the package manager
25
+ npx code-foundry init --languages typescript,python --package-manager bun
126
26
 
127
- - `fix:` patch, such as `1.2.3` → `1.2.4`
128
- - `feat:` minor, such as `1.2.3` → `1.3.0`
129
- - `feat!:`, `fix!:`, or `BREAKING CHANGE:` → major, such as `1.2.3` → `2.0.0`
130
-
131
- Before `1.0.0`, `feat:` intentionally increments the minor version. This keeps pre-1.0 releases useful without treating every feature as a breaking major.
132
-
133
- Use `Release-As: 2.0.0` in a commit or pull request body when a specific version is required. Existing `CHANGELOG.md` files are preserved by sync and remain repository-owned.
134
-
135
- Release behavior is configured in `.github/template.yml`:
27
+ # Choose a license
28
+ npx code-foundry init --license mit
136
29
 
137
- ```yaml
138
- release_type: auto # auto, node, python, rust, simple, or none
139
- npm_publish: false # true only for a package published to npm
30
+ # Preview without changing files
31
+ npx code-foundry init --dry-run
140
32
  ```
141
33
 
142
- `auto` selects the first matching package type (`package.json`, `pyproject.toml`, `Cargo.toml`, or `version.txt`). Use `none` when the repository should not release automatically. Solidity-only repositories use `simple` with a root `version.txt`. For a repository containing multiple independently released packages, add a Release Please manifest/configuration and select the appropriate Release Please strategy rather than treating the repository as one package.
143
-
144
- GitHub Actions needs permission to open release pull requests. Configure a repository or organization secret named `RELEASE_PLEASE_TOKEN` containing a narrowly scoped token or GitHub App token if the default `GITHUB_TOKEN` is not allowed to create pull requests. Keep `contents`, `issues`, and `pull-requests` permissions enabled for the release workflow.
145
-
146
- For npm publication, set `npm_publish: true` and configure npm trusted publishing (recommended) for this repository’s `release.yml` workflow, or provide an `NPM_TOKEN` secret. The workflow detects which method is configured, and publication occurs only after Release Please creates a release tag, so ordinary pushes cannot publish packages. Keep `publishConfig.access` in `package.json` aligned with the package’s intended visibility; the baseline publishes public packages. If npm publication is enabled without either configuration, the publish job fails instead of silently skipping the release.
147
-
148
- The release flow is: promote `staging` into `main`; let Release Please open or update the version/changelog PR; merge that PR to create the GitHub release and tag; then publish to npm only when `npm_publish: true`.
149
-
150
- For a repository that does not yet contain the scripts, the initializer can be invoked directly from the published package or a downloaded copy of `init-repo.sh`; it fetches the matching sync helper automatically. The generated `.github/template.yml` is the stable configuration contract used by the package and later syncs.
151
-
152
- CI formatting and linting use the preloaded `ubuntu-latest` runner by default because dependency setup is usually faster there. Set `REPO_FOUNDRY_FAST_RUNNER=ubuntu-slim` only after measuring a repository where the lean image is faster; use `ubuntu-latest` for dependency-heavy or native-toolchain projects.
153
-
154
- Rust Build and Type-Check jobs keep compiler caches enabled. JavaScript-only Build and Type-Check jobs skip framework cache archives by default because hosted-runner compression can exceed the build time; opt in with `REPO_FOUNDRY_CACHE_BUILD=true` when a repository’s measurements show a repeatable warm-cache win.
155
-
156
- Branch protection is an administrator operation and is opt-in:
157
-
158
- ```bash
159
- bash .github/scripts/init-repo.sh --protection
34
+ For an existing installation, use `npx code-foundry sync`. Run
35
+ `npx code-foundry doctor` to inspect the resulting repository configuration.
36
+
37
+ If `.github/code-foundry.yml` already exists, initialization uses it automatically.
38
+ You can also supply a different file with `--config PATH`; after changing the
39
+ file, run `npx code-foundry sync` to render the selected configuration.
40
+
41
+ ## What it installs
42
+
43
+ - Short workflow callers for CI, Test, Security, CodeQL, Draft PR, Release PR,
44
+ and Release.
45
+ - A small `.githooks/pre-commit` launcher with language-aware formatting and
46
+ linting.
47
+ - `.mise.toml`, optional `mise.lock`, repository profile configuration, and
48
+ standard GitHub forms and policy files.
49
+ - AGENTS instructions, CODEOWNERS, license/notice files, and reusable release
50
+ configuration.
51
+
52
+ The workflow implementation lives in the versioned runtime repository. A
53
+ consumer repository keeps only the callers and the small local entrypoints it
54
+ needs. Custom workflows—such as deployment, indexing, Slither, or search—are
55
+ preserved and can coexist with the standard baseline.
56
+
57
+ ## Configuration
58
+
59
+ Initialization is flag-driven. The most important options are:
60
+
61
+ ```text
62
+ --profile auto|application|monorepo|minimal
63
+ --languages auto|typescript,rust,python,solidity
64
+ --features all|ci,codeql,security,test,draft-pr,release-pr,release,dependabot
65
+ --package-manager auto|bun|pnpm|yarn|npm
66
+ --runtime-repository OWNER/REPO
67
+ --runtime-ref TAG_OR_BRANCH
68
+ --release-type auto|node|python|rust|simple|none
69
+ --license agpl-3.0-or-later|mit|preserve|none
70
+ --license-file PATH
160
71
  ```
161
72
 
162
- The protection helper preserves unrelated provider checks, replaces stale template check names, and skips CodeQL analysis checks for private repositories where the workflow is intentionally skipped.
163
-
164
- The repository name, owner, branch names, and release metadata are resolved by GitHub Actions at runtime through `${{ github.* }}` values. Keep organization-specific details out of this baseline.
165
-
166
- `CODEOWNERS` is repository-aware. Initialization queries the target GitHub repository and writes its personal owner or repository administrators into the default rule. For organization repositories, administrator discovery requires an authenticated `gh` session with collaborator visibility; if discovery is unavailable, the file retains an `@OWNER` placeholder that should be replaced before merging protected changes.
167
-
168
- CI and hooks use Prettier and ESLint for JavaScript/TypeScript, default `rustfmt` and Clippy with warnings-as-errors for Rust, and Ruff formatting/linting for Python.
169
-
170
- The initializer generates a minimal `.mise.toml` from the selected language and package-manager profile instead of installing every supported tool on every runner. TypeScript/Solidity profiles always pin Node and add Bun only for Bun projects; npm, pnpm, and Yarn use Node/Corepack. CI and Security also honor an explicit `package_manager` profile before inspecting lockfiles. Existing `.mise.toml` files are preserved. Initialization also generates a committed `mise.lock` when mise is available; CI then installs exact tool URLs and checksums without repeating registry/API resolution. Workflow setup restores lockfile-keyed package caches for Bun/npm/pnpm/Yarn, Cargo, and pip; cache misses remain safe because dependencies are always re-created from their lockfiles or manifests. Set `REPO_FOUNDRY_CACHE_PACKAGES=true` when a large Bun project has a measured warm-cache win; the default `auto` policy skips oversized archives.
73
+ The selected profile is saved in `.github/code-foundry.yml`. Explicit flags take
74
+ precedence over `REPO_FOUNDRY_*` environment/repository variables, which take
75
+ precedence over that file and automatic detection. See
76
+ [Configuration reference](docs/CONFIGURATION.md) for the visual configuration
77
+ guide and [Initialization and synchronization](docs/INITIALIZATION.md) for
78
+ the safety and precedence rules.
171
79
 
172
- Rust profiles declare `rustfmt` and `clippy` as mise components, so they are installed once with the cached toolchain instead of being added separately by each formatting or lint job. Rust Build jobs cache only reusable debug dependency/build-script artifacts plus Cargo fingerprints; Test jobs disable build and materialized-environment caches to avoid restoring and saving large incremental trees or Python virtual environments in parallel. Cargo’s advisory database and audit tools remain separate caches whose keys follow the security script, so dependency updates do not redownload the scanner. Cargo fingerprints invalidate stale objects safely, while keeping build caches separate prevents a large Rust build from displacing dependency-download caches or parallel jobs from racing to save one partial cache.
80
+ New repositories default to AGPL-3.0-or-later. Synchronization preserves an
81
+ existing license unless a replacement is explicitly selected. Authored
82
+ documentation, application files, custom workflows, and existing `.mise.toml`
83
+ files are preserved by default; use `--force` or `--prune` only intentionally.
173
84
 
174
- The shared cache action separates restore-only jobs from jobs allowed to save a cache after completion. Standard parallel CI and Test jobs pass `cache-save: false`, so they can reuse warm data without paying for redundant post-job archive uploads; the Unit and Security paths retain saving where it improves later runs. Repository-specific workflows can use the same local action when they need the same restore-only behavior.
85
+ ## Workflow model
175
86
 
176
- When an exact `Cargo.lock` dependency cache is restored, CI enables Cargo offline mode for compilation and tests, eliminating avoidable registry/index checks. Cache misses continue using normal online resolution. npm projects intentionally skip the installed-`node_modules` cache because `npm ci` removes that directory before installation; they still reuse the package-download cache.
87
+ The standard workflow triggers are:
177
88
 
178
- Applicable jobs cache installed JavaScript dependencies only when a lockfile, workspace, or dependency entry exists; dependency-free package manifests skip both the cache lookup and install. Installed JavaScript dependencies use an `auto` policy: compact pnpm/Yarn layouts are reusable, while Bun recreates its potentially large `node_modules` tree from the cached package store. Package-store caching also defaults to `auto`: normal projects retain it, while Bun repositories with more than 512 KiB of tracked lockfiles skip the large archive when a clean registry install is typically faster. Set `cache-packages: true` or `false` to override that heuristic. Set `cache-installed: true` on the setup action when a specific Bun repository benefits from restoring its materialized tree, or `false` to force lockfile installation for any manager. Jobs also cache Corepack package-manager shims, generic fallback ESLint/Prettier state, and Python virtual environments by manifest/dependency configuration hash. Repository-owned format/lint scripts skip those fallback cache paths entirely, avoiding recursive cache scans and post-job archive work when the script does not create the cache. Formatter and linter configuration is isolated to lint-state caches, so changing formatting rules does not invalidate installed dependencies. Mutable installed environments use exact-key restores only, preventing a lockfile change from downloading stale `node_modules` or a stale virtual environment that must then be replaced. Corepack remains warm even when an installed-dependency cache is already a hit; npm and pnpm installs prefer restored package stores and npm skips redundant audit/funding work because Security runs the authoritative dependency audit separately. The generic ESLint and Prettier fallbacks enable content-based built-in caches so restored lint/format state survives fresh Git checkouts; repository-defined scripts remain authoritative. Cache misses always fall back to a clean install; cached environments must never contain credentials or generated secrets.
89
+ - Pushes to `main` and `staging`.
90
+ - Pull requests targeting `staging`.
91
+ - Draft PR automation for supported feature/fix branches.
179
92
 
180
- When a repository uses multiple supported ecosystems, JavaScript, Rust, and Python dependency installation runs concurrently inside each setup job. A failure in any installer still fails the job after all active installers finish, preserving complete diagnostics without making network waits additive. CI disables Turbo and Next.js telemetry so framework jobs do not spend time on nonessential telemetry startup or network work.
93
+ Jobs are language-aware and skip irrelevant setup while remaining visible as
94
+ successful required checks. TypeScript uses ESLint, Prettier, and Bun's native
95
+ test runner. Rust uses `rustfmt`, Clippy with warnings as errors, and native
96
+ Cargo tests. Python uses Ruff, uv/pip-compatible setup, and native Python
97
+ tests. Solidity projects retain their native toolchain and test runner.
181
98
 
182
- Installers also short-circuit cleanly: JavaScript projects without dependency entries do not run a package install, and Python source-only projects reuse the shared Ruff tool without creating a virtual environment. Workspace manifests and project dependency files still take the normal locked-install path.
99
+ CodeQL remains separate from CI and Security. Dependency Review is isolated in
100
+ Security and is skipped where GitHub does not support it, while JavaScript,
101
+ Python, and Rust audits remain available without GitHub Advanced Security.
183
102
 
184
- E2E jobs cache Playwright, Cypress, and Puppeteer browser directories by dependency/configuration hash, avoiding repeated browser downloads while invalidating safely when the browser configuration or lockfiles change. Coverage artifacts are uploaded only when a test actually produces coverage output.
103
+ See [Workflow and CI conventions](docs/WORKFLOWS.md) for triggers, required
104
+ checks, runners, coverage, caching, and custom workflow extensions.
185
105
 
186
- Repositories with Turborepo automatically cache local `.turbo/cache` results per workflow job and dependency/configuration hash when remote caching is unavailable. Fallback restores can reuse valid artifacts produced by another workflow job, while Turbo’s task hashes discard stale results. Vercel Remote Caching remains available through `TURBO_TOKEN` and `TURBO_TEAM`; when both are set, the default path passes Turbo’s `--cache=remote:rw` mode to repository scripts so local archive work is avoided. The lint, type-check, and build jobs first perform a conservative manifest-only remote-cache probe for Bun projects; when every executable task is already a hit, they install only the pinned toolchain and restore results without installing project dependencies. Any miss falls back automatically to the normal locked install. Set `cache-turbo: true` when a repository intentionally wants both local and remote caching.
187
-
188
- New Python profiles include pinned `uv` as an accelerated, pip-compatible installer and pinned Ruff as the shared formatter/linter. Repositories with `pyproject.toml` and `uv.lock` use `uv sync --frozen` to materialize the exact environment without repeat resolution; requirements-file projects continue using the uv/pip-compatible fallback. Existing repositories without `uv` continue using pip automatically, while existing custom tool selections and dependency-file formats remain supported.
189
-
190
- Python Security audits use an isolated cache for `uv tool run` environments containing `pip-audit` when uv is available, so application lockfile changes do not redownload the scanner. They retain the same pip fallback used by CI installation. Independent `requirements.txt` and `requirements-dev.txt` audits run concurrently and aggregate failures. JavaScript, Rust, and Python audit jobs run concurrently when their ecosystems are present. The Python matrix is profile-gated so repositories without applicable Python inputs avoid a no-op runner; JavaScript and Rust retain independent detection so active audits start without waiting for the profile job. Every active ecosystem still reports a failure if its audit fails.
191
-
192
- CI and Test jobs perform a source-only applicability check before setup. Empty integration, E2E, smoke, or language-specific jobs remain visible as successful required checks but skip runner tool installation and dependency setup.
193
-
194
- On pull requests and ordinary pushes, CI, Test, and Security also recognize governance-only changes (README, license, issue/PR templates, CODEOWNERS, Code of Conduct, CONTRIBUTING, and SECURITY) and leave the required jobs successful without installing tools or running unrelated checks. Any source, dependency, workflow, profile, or build configuration change runs the full applicable checks; an unavailable diff always falls back to running them.
195
-
196
- Security dependency audits apply the same fail-open change detection per ecosystem: JavaScript, Rust, and Python audits skip setup for source-only pushes and pull requests that do not change that ecosystem's manifests, lockfiles, audit allowlist, or shared tool configuration. Scheduled scans, manual runs, and uncertain diffs always audit normally.
197
-
198
- The shared setup action accepts `install-javascript`, `install-python`, and `install-rust` switches. They default to `true` for compatibility, while the standard CI jobs disable ecosystems that their task cannot use: formatting skips project Cargo/Python installs, and lint, type-check, and build skip Python dependency installation. Test jobs pass their task profile (`unit`, `integration`, `e2e`, or `smoke`) and disable unrelated ecosystem caches, dependency installs, and mise tools; mixed-language repositories therefore pay only for languages used by that suite. Mise tool installation defaults to `auto`, so each job installs only configured tools for languages actually detected in the repository. Repositories without `.mise.toml` skip mise entirely and use the runner/project environment; callers can use `mise-scope: all` when a task intentionally spans every configured ecosystem.
199
-
200
- It also accepts `mise-scope` (`auto`, `all`, `javascript`, `python`, or `rust`). Security's parallel ecosystem matrix uses this to install only the active language toolchain and restore only its package caches; callers that omit it get automatic profile-based tool selection, while `all` remains available for tasks that intentionally span every configured ecosystem.
201
-
202
- Lightweight orchestration jobs use GitHub's `ubuntu-slim` runner: Draft PR, Release PR, release detection, Release Please, npm publication, dependency review, CodeQL language detection, and dependency audits. Build, format, lint, type-check, integration/E2E/smoke tests, and active CodeQL analysis use full `ubuntu-latest` runners because toolchain initialization, native libraries, browsers, and source analysis may benefit from full runner resources. Unit tests default to `ubuntu-slim` for small projects, but dependency-heavy or native suites should set the repository variable `REPO_FOUNDRY_UNIT_RUNNER=ubuntu-latest`; measurements across the maintained monorepos showed materially faster installs and test execution on the full runner.
203
-
204
- Release and Security metadata jobs also use blobless checkouts where a checkout is needed, reducing source transfer while preserving on-demand manifest access.
205
-
206
- CodeQL keeps every configured language check visible but skips analyzers whose source, dependencies, or configuration were untouched by a push or pull request. Unchanged analyzer jobs use `ubuntu-slim` and skip both checkout and analysis while remaining visible to branch protection; changed analyzers use full `ubuntu-latest` runners. Its detection job uses a blobless, sparse checkout because it only needs Git paths, metadata, and repository manifests; analyzer jobs still use full checkouts. Scheduled and manually dispatched CodeQL runs remain full scans.
207
-
208
- CodeQL uploads SARIF findings for GitHub code scanning but does not archive the intermediate database in the reusable baseline; this keeps coverage and alert processing while avoiding an unnecessary database transfer. The required workflow check gates on successful SARIF upload acknowledgment and does not wait for GitHub’s asynchronous post-upload processing, shortening the CI critical path while retaining the uploaded findings.
209
-
210
- Coverage is enforced at 80% for Python and Bun test suites when those ecosystems expose coverage support. Rust projects must keep their native test suites green; repositories with `cargo-llvm-cov` should enforce the same 80% line target in their Cargo coverage configuration.
211
-
212
- ## Test runner standard
106
+ ## Releases and publishing
213
107
 
214
- For TypeScript and JavaScript tests, use Bun's native test runner by default. Do not add Vitest to projects based on this template. Preserve specialized native runners such as Matchstick for The Graph and Hardhat for smart contracts.
108
+ The standard flow promotes `staging` into `main`, lets Release Please open a
109
+ versioned release PR, and creates a GitHub release after that PR is merged.
110
+ npm publication is opt-in through `npm_publish: true` and supports npm trusted
111
+ publishing or an `NPM_TOKEN` fallback.
215
112
 
216
- ## Optional Turborepo remote caching
113
+ Read [Release management](docs/RELEASES.md) and
114
+ [Publishing packages](docs/PUBLISHING.md) before enabling automated
115
+ publishing. They are intentionally written with placeholders so they can be
116
+ copied into other repositories.
217
117
 
218
- Turborepo repositories can use Vercel Remote Caching without changing the workflows. Add these repository settings:
118
+ ## Documentation and extensions
219
119
 
220
- - Secret: `TURBO_TOKEN`
221
- - Repository variable: `TURBO_TEAM`
120
+ The `docs/` directory contains generalized operational guides. Add
121
+ repository-specific documentation there as well; synchronization does not
122
+ replace files in `docs/`.
222
123
 
223
- CI and Test pass those values to every job. Non-Turborepo repositories and repositories without the settings simply use their normal local cache behavior. This does not require the repository to deploy to Vercel.
124
+ - [Documentation index](docs/README.md)
125
+ - [Initialization and synchronization](docs/INITIALIZATION.md)
126
+ - [Workflow and CI conventions](docs/WORKFLOWS.md)
127
+ - [Release management](docs/RELEASES.md)
128
+ - [Publishing packages](docs/PUBLISHING.md)
129
+ - [Caching and remote caching](docs/CACHING.md)
224
130
 
225
131
  ## License
226
132
 
227
- Unless a repository says otherwise, new material is licensed under the GNU Affero General Public License v3.0-or-later. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
228
-
229
- ## GitHub security behavior
230
-
231
- The CodeQL workflow uses GitHub's official CodeQL actions, detects Actions, TypeScript, Python, and Rust automatically, and runs each language in parallel. It runs automatically for public repositories and skips itself for private repositories unless GitHub Code Security is enabled. Dependency Review is isolated in the Security workflow and runs only for public pull requests. If GitHub's Code Scanning default setup is enabled, disable that generated `dynamic/github-code-scanning/codeql` workflow after installing this checked-in workflow; otherwise GitHub will run two CodeQL analyzers. The default setup can be disabled with `gh api --method PATCH repos/OWNER/REPO/code-scanning/default-setup -f state=not-configured` when Code Security is available.
133
+ Unless a repository says otherwise, new material is licensed under the GNU
134
+ Affero General Public License v3.0-or-later. See [LICENSE](LICENSE) and
135
+ [NOTICE](NOTICE).
@@ -0,0 +1,29 @@
1
+ # Caching and remote caching
2
+
3
+ ## Local workflow caching
4
+
5
+ The standard runtime uses lockfile- and configuration-keyed caches for package
6
+ stores, Cargo, pip/uv, browser binaries, and applicable build artifacts. Cache
7
+ misses always fall back to a clean locked install. Do not cache credentials,
8
+ generated secrets, or mutable environments without an exact dependency key.
9
+
10
+ Repositories should measure before enabling large installed-tree or build
11
+ caches. Set repository variables such as `REPO_FOUNDRY_CACHE_PACKAGES` and
12
+ `REPO_FOUNDRY_CACHE_BUILD` only when a repeatable warm-cache benefit is proven.
13
+
14
+ ## Turborepo and Vercel Remote Caching
15
+
16
+ Turborepo repositories can opt into Vercel Remote Caching with:
17
+
18
+ - Secret: `TURBO_TOKEN`
19
+ - Repository variable: `TURBO_TEAM`
20
+
21
+ Non-Turborepo repositories do not need either setting. Deployment to Vercel is
22
+ not required. Custom workflows can pass these values to Turbo directly when
23
+ the repository's task graph benefits from remote reuse.
24
+
25
+ ## Runner selection
26
+
27
+ Lightweight detection, orchestration, audits, and release metadata jobs can use
28
+ `ubuntu-slim`. Toolchain-heavy builds, native compilation, browsers, and active
29
+ CodeQL analysis should use `ubuntu-latest` unless measurements show otherwise.
@@ -0,0 +1,87 @@
1
+ # Configuration reference
2
+
3
+ `.github/code-foundry.yml` is the repository's single Code Foundry control plane.
4
+ Initialize from it with:
5
+
6
+ ```bash
7
+ npx code-foundry init --config .github/code-foundry.yml
8
+ ```
9
+
10
+ After initialization, edit the file and run `npx code-foundry sync` to render
11
+ the selected callers and refresh the local baseline. Existing authored files
12
+ and custom workflows remain protected.
13
+
14
+ ## Configuration flow
15
+
16
+ ```text
17
+ code-foundry.yml
18
+ |
19
+ +--> profile and language detection
20
+ +--> enabled standard workflow callers
21
+ +--> runtime repository and ref
22
+ +--> workflow runner selection
23
+ +--> release, license, cache, and coverage policy
24
+ ```
25
+
26
+ ## Core settings
27
+
28
+ | Key | Values | Purpose |
29
+ | --- | --- | --- |
30
+ | `profile` | `auto`, `application`, `monorepo`, `minimal` | Repository shape |
31
+ | `languages` | `auto` or comma-separated languages | Toolchain and CodeQL scope |
32
+ | `package_manager` | `auto`, `bun`, `pnpm`, `yarn`, `npm` | Locked JavaScript setup |
33
+ | `features` | `all` or comma-separated names | Standard callers to install |
34
+ | `prune_standard` | `true` or `false` | Remove disabled standard callers on sync |
35
+ | `runtime_repository` | `OWNER/REPO` or blank | Reusable workflow source |
36
+ | `runtime_ref` | tag or branch | Reusable workflow version |
37
+ | `release_type` | `auto`, `node`, `python`, `rust`, `simple`, `none` | Release Please strategy |
38
+ | `npm_publish` | `true` or `false` | Opt into npm publication |
39
+ | `license` | license name, `preserve`, `none` | License generation policy |
40
+ | `license_file` | path | Optional exact license source |
41
+
42
+ Supported languages are TypeScript, Rust, Python, and Solidity. Supported
43
+ features are `ci`, `codeql`, `security`, `test`, `draft-pr`, `release-pr`,
44
+ `release`, and `dependabot`.
45
+
46
+ ## Workflow runners
47
+
48
+ Each caller can select its default runner without editing workflow YAML:
49
+
50
+ | Key | Default | Controls |
51
+ | --- | --- | --- |
52
+ | `runner` | `ubuntu-latest` | Shared fallback |
53
+ | `unit_runner` | `ubuntu-slim` | Unit tests |
54
+ | `ci_runner` | `ubuntu-latest` | Format, lint, type-check, build |
55
+ | `test_runner` | `ubuntu-latest` | Integration, E2E, smoke |
56
+ | `security_runner` | `ubuntu-slim` | Profile and dependency security jobs |
57
+ | `codeql_runner` | `ubuntu-latest` | CodeQL detection and analyzers |
58
+ | `pr_runner` | `ubuntu-slim` | Draft and Release PR automation |
59
+ | `release_runner` | `ubuntu-slim` | Release and package publication |
60
+
61
+ Use the full runner for native toolchains, browsers, or measured dependency
62
+ workloads. Use `ubuntu-slim` for lightweight orchestration and small projects.
63
+
64
+ ## Performance and quality
65
+
66
+ | Key | Default | Purpose |
67
+ | --- | --- | --- |
68
+ | `cache_packages` | `auto` | Package-store caching policy |
69
+ | `cache_build` | `auto` | Build-cache policy |
70
+ | `coverage_minimum` | `80` | Shared Bun/Python coverage target |
71
+ | `turbo_remote` | `auto` | Turborepo remote-cache policy |
72
+
73
+ Turborepo remote caching still requires the repository secret `TURBO_TOKEN` and
74
+ the variable `TURBO_TEAM`; the file controls policy, not credentials.
75
+
76
+ ## Precedence
77
+
78
+ The resolved value order is:
79
+
80
+ ```text
81
+ explicit CLI flag -> REPO_FOUNDRY_* variable -> code-foundry.yml -> detection/default
82
+ ```
83
+
84
+ Use variables for temporary CI overrides. Keep durable repository policy in
85
+ `.github/code-foundry.yml` so humans and agents have one discoverable source of
86
+ truth. The example file is a commented starter guide; it is intentionally not
87
+ a second generated configuration.
@@ -0,0 +1,67 @@
1
+ # Initialization and synchronization
2
+
3
+ ## Commands
4
+
5
+ Run the package from a repository root:
6
+
7
+ ```bash
8
+ npx code-foundry init [options]
9
+ npx code-foundry sync [options]
10
+ npx code-foundry doctor
11
+ ```
12
+
13
+ When `.github/code-foundry.yml` already exists, `init` treats it as the primary
14
+ configuration and does not replace its values with CLI defaults. To use another
15
+ file, pass it explicitly:
16
+
17
+ ```bash
18
+ npx code-foundry init --config ./configs/code-foundry.yml
19
+ ```
20
+
21
+ The file is copied to `.github/code-foundry.yml`, normalized, and used to render
22
+ the standard callers. Later edits can be applied with `npx code-foundry sync`.
23
+
24
+ Use `--dry-run` to preview changes. Use `--no-bootstrap` when the repository is
25
+ being initialized in CI or on a machine without mise. Run
26
+ `bash .github/scripts/bootstrap.sh` later to install tools, enable hooks, and
27
+ run the repository doctor.
28
+
29
+ ## Profiles and features
30
+
31
+ Supported languages are `typescript`, `rust`, `python`, and `solidity`.
32
+ `--languages auto` detects them from manifests and source files. Profiles are
33
+ `auto`, `application`, `monorepo`, and `minimal`.
34
+
35
+ Standard features are `ci`, `codeql`, `security`, `test`, `draft-pr`,
36
+ `release-pr`, `release`, and `dependabot`. `all` enables every standard
37
+ feature. `--prune` removes disabled standard workflows only; it never removes
38
+ custom workflows.
39
+
40
+ ## Runtime selection
41
+
42
+ Reusable workflow callers require a literal repository and ref. By default,
43
+ the initializer derives the runtime repository from the source template. Use
44
+ these options for a fork or a staged runtime:
45
+
46
+ ```bash
47
+ npx code-foundry init \
48
+ --runtime-repository OWNER/REPO \
49
+ --runtime-ref v1.2.3
50
+ ```
51
+
52
+ Both values are persisted in `.github/code-foundry.yml` and rendered into the
53
+ standard callers. `REPO_FOUNDRY_RUNTIME_REPOSITORY` and
54
+ `REPO_FOUNDRY_RUNTIME_REF` provide equivalent environment/repository-variable
55
+ overrides.
56
+
57
+ ## Safety rules
58
+
59
+ Synchronization preserves authored README and policy documents, existing
60
+ `.mise.toml` selections, application code, custom workflows, and repository
61
+ documentation. Existing licenses are preserved unless a license or license
62
+ file is explicitly selected. Use `--force` only when intentionally refreshing
63
+ protected standard documents.
64
+
65
+ The initializer generates `.github/code-foundry.yml` as the repository-owned
66
+ configuration contract. Keep project-specific settings there rather than
67
+ editing generated workflow callers by hand.
@@ -0,0 +1,49 @@
1
+ # Publishing packages
2
+
3
+ ## npm
4
+
5
+ Set `npm_publish: true` only when the repository owns an npm package. Configure
6
+ npm trusted publishing for the repository's `release.yml` workflow whenever
7
+ possible. An `NPM_TOKEN` secret is the fallback for registries or repositories
8
+ that cannot use trusted publishing.
9
+
10
+ The package should define its intended visibility explicitly:
11
+
12
+ ```json
13
+ {
14
+ "publishConfig": {
15
+ "access": "public"
16
+ }
17
+ }
18
+ ```
19
+
20
+ Publication occurs only from a Release Please tag; ordinary pushes do not
21
+ publish. The release workflow fails clearly when npm publication is enabled but
22
+ neither trusted publishing nor a token is configured.
23
+
24
+ After enabling publication, make one controlled release and verify both the
25
+ registry version and the provenance link before treating the repository as
26
+ fully configured.
27
+
28
+ ## GitHub Releases and GitHub Packages
29
+
30
+ A GitHub Release is release metadata attached to a Git tag. It is independent
31
+ of the npm registry and of GitHub Packages.
32
+
33
+ Publishing to npm does not populate the repository's GitHub Packages section.
34
+ If a repository also needs a GitHub Container Registry or npm-compatible
35
+ GitHub Package, add a repository-owned publishing workflow and credentials;
36
+ that is an optional extension rather than part of the universal baseline.
37
+
38
+ ## Provenance and verification
39
+
40
+ Prefer trusted publishing because it provides short-lived credentials and
41
+ provenance. After a release, verify:
42
+
43
+ ```bash
44
+ npm view PACKAGE_NAME version dist-tags
45
+ gh release view vVERSION
46
+ ```
47
+
48
+ For private or non-npm repositories, leave `npm_publish: false` and retain the
49
+ GitHub Release portion of the standard flow if versioned releases are useful.
package/docs/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # Documentation
2
+
3
+ These guides describe the reusable repository baseline in provider-neutral
4
+ terms. They are suitable for copying into another repository and adapting with
5
+ its own names, environments, and deployment details.
6
+
7
+ ## Guides
8
+
9
+ - [Initialization and synchronization](INITIALIZATION.md)
10
+ - [Configuration reference](CONFIGURATION.md)
11
+ - [Workflow and CI conventions](WORKFLOWS.md)
12
+ - [Release management](RELEASES.md)
13
+ - [Publishing packages](PUBLISHING.md)
14
+ - [Caching and remote caching](CACHING.md)
15
+
16
+ ## Repository-specific documentation
17
+
18
+ Add project-specific guides, architecture notes, runbooks, and deployment
19
+ instructions to this directory. The Code Foundry initializer preserves `docs/`
20
+ files during synchronization. Prefer clear, task-oriented filenames and link
21
+ new documents from this index when they become part of the supported workflow.