code-foundry 0.31.17 → 0.32.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.
@@ -48,7 +48,7 @@ docs/* test/* refactor/* │ │
48
48
  | `staging` | Integration branch | Target normal pull requests here. Required checks must pass before merge. |
49
49
  | `feat/*`, `fix/*`, `chore/*`, `refactor/*`, `docs/*`, `test/*` | Focused work | Branch from `staging`; keep changes small and reviewable. |
50
50
 
51
- The default Git workflow is `staging-release`: topic branches merge into `staging`, then a promotion PR moves validated changes into `main`, followed by the versioned release PR. The default merge strategy is `rebase`, which preserves the linear Conventional Commit history. Configure `merge_strategy` as `squash` or `merge` in `.github/code-foundry.yml` when the repository intentionally uses another policy. Re-align `staging` with `main` after a release when needed.
51
+ The default Git workflow is `staging-release`: topic branches merge into `staging` (typically after rebasing), then a promotion PR moves validated changes into `main`, followed by the versioned release PR. The default release merge strategy is `merge`, matching your preference for merge-commit promotions from staging to main. Configure `merge_strategy` as `rebase` or `squash` in `.github/code-foundry.yml` if a repository intentionally differs. Re-align `staging` with `main` after a release when needed.
52
52
 
53
53
  ## Before you start
54
54
 
@@ -163,7 +163,7 @@ Keep pull requests focused and reviewable. Include screenshots or recordings for
163
163
 
164
164
  The workflows use separate concurrency groups keyed by the commit under test. A newer run for the same commit cancels a duplicate event-triggered run, while newer commits cancel older runs and independent CI, Test, Security, and CodeQL workflows continue in parallel.
165
165
 
166
- Required checks are enforced by branch protection. Do not duplicate their checklists in the pull request description; document validation commands and results instead.
166
+ Required checks are enforced by branch protection rulesets/branch protection. Do not duplicate their checklists in the pull request description; document validation commands and results instead.
167
167
 
168
168
  ### Release conventions
169
169
 
@@ -16,7 +16,7 @@ release_type: node
16
16
  npm_publish: true
17
17
  license: agpl-3.0-or-later
18
18
  git_workflow: staging-release
19
- merge_strategy: rebase
19
+ merge_strategy: merge
20
20
  runner: ubuntu-latest
21
21
  unit_runner: ubuntu-slim
22
22
  cache_packages: auto
@@ -344,7 +344,7 @@ jobs:
344
344
  set -euo pipefail
345
345
  scope="$RUST_SCOPE"
346
346
  scope_id="$(node -e 'process.stdout.write(require("node:crypto").createHash("sha256").update(process.argv[1]).digest("hex").slice(0, 12))' "$scope")"
347
- config_file="$RUNNER_TEMP/codeql-rust-$scope_id.yml"
347
+ config_file="$GITHUB_WORKSPACE/.github/codeql-rust-$scope_id.yml"
348
348
  cat > "$config_file" <<'EOF'
349
349
  name: code-foundry-rust
350
350
  EOF
@@ -36,12 +36,36 @@ jobs:
36
36
  if: steps.check-pr.outputs.existing == '0'
37
37
  run: |
38
38
  BRANCH="${{ github.ref_name }}"
39
+ PREFIX="${BRANCH%%/*}"
40
+ SUFFIX="${BRANCH#*/}"
41
+ PR_TITLE=""
42
+
43
+ case "$PREFIX" in
44
+ feat|fix|chore|refactor|docs|test|style|ci|build)
45
+ if [ "$SUFFIX" != "$BRANCH" ] && [ -n "$SUFFIX" ]; then
46
+ PR_TITLE="${PREFIX}: ${SUFFIX}"
47
+ fi
48
+ ;;
49
+ *)
50
+ ;;
51
+ esac
52
+
53
+ PR_TITLE="${PR_TITLE//[\/_]/ }"
54
+ PR_TITLE="$(printf '%s' "$PR_TITLE" | tr -s ' ' | sed 's/^ *//; s/ *$//')"
55
+
56
+ if [ -z "$PR_TITLE" ]; then
57
+ PR_TITLE=$(git log -1 --pretty=%s 2>/dev/null || true)
58
+ fi
59
+ if [ -z "$PR_TITLE" ]; then
60
+ PR_TITLE="$BRANCH"
61
+ fi
62
+
39
63
  gh pr create \
40
64
  --repo "$GITHUB_REPOSITORY" \
41
65
  --base staging \
42
66
  --head "$BRANCH" \
43
67
  --draft \
44
- --title "[WIP] $BRANCH" \
68
+ --title "$PR_TITLE" \
45
69
  --body "Draft PR created automatically by CI.
46
70
 
47
71
  This PR is a draft and should not be merged until CI passes and a reviewer (or the Daily Review agent) marks it ready.
@@ -157,7 +157,7 @@ jobs:
157
157
  ### Validation
158
158
 
159
159
  - Required CI, test, security, and CodeQL checks must pass before merge.
160
- - Merge using the repository's configured \`merge_strategy\` (default: **rebase**).
160
+ - Merge using the repository's configured \`merge_strategy\` (default: **merge**).
161
161
  - After merge, Release Please opens a separate versioned release PR with the changelog.
162
162
  EOF
163
163
 
@@ -72,10 +72,12 @@ jobs:
72
72
  : {}
73
73
  let releaseType = config.release_type || 'auto'
74
74
  let npmPublish = config.npm_publish || 'false'
75
+ let releaseMergeStrategy = String(config.merge_strategy || 'merge').trim().toLowerCase()
75
76
  if (releaseType === 'auto') {
76
77
  releaseType = fs.existsSync('package.json') ? 'node' : fs.existsSync('pyproject.toml') ? 'python' : fs.existsSync('Cargo.toml') ? 'rust' : fs.existsSync('version.txt') ? 'simple' : 'none'
77
78
  }
78
79
  if (!['node', 'python', 'rust', 'simple', 'none'].includes(releaseType)) throw new Error(`Unsupported release_type: ${releaseType}`)
80
+ if (!['rebase', 'squash', 'merge'].includes(releaseMergeStrategy)) throw new Error(`Unsupported merge_strategy: ${releaseMergeStrategy}`)
79
81
  if (releaseType === 'none' || !fs.existsSync('package.json')) npmPublish = 'false'
80
82
  let legacyReleaseType = ''
81
83
  if (releaseType !== 'none') {
@@ -88,7 +90,7 @@ jobs:
88
90
  }
89
91
  fs.appendFileSync(
90
92
  process.env.GITHUB_OUTPUT,
91
- `release_type=${releaseType}\nlegacy_release_type=${legacyReleaseType}\nnpm_publish=${npmPublish}\n`,
93
+ `release_type=${releaseType}\nlegacy_release_type=${legacyReleaseType}\nnpm_publish=${npmPublish}\nrelease_merge_strategy=${releaseMergeStrategy}\n`,
92
94
  )
93
95
  NODE
94
96
  - name: Detect release credentials
@@ -161,7 +163,7 @@ jobs:
161
163
  gh pr merge "$pr" \
162
164
  --repo "$GITHUB_REPOSITORY" \
163
165
  --admin \
164
- --rebase \
166
+ --${{ steps.profile.outputs.release_merge_strategy }} \
165
167
  --delete-branch
166
168
  done
167
169
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.32.0](https://github.com/0xPlayerOne/code-foundry/compare/v0.31.18...v0.32.0) (2026-07-31)
4
+
5
+
6
+ ### Features
7
+
8
+ * improve draft PR titles from branch conventions ([#290](https://github.com/0xPlayerOne/code-foundry/issues/290)) ([7b215db](https://github.com/0xPlayerOne/code-foundry/commit/7b215db961347dfdb74241fc2c3489d390b34533))
9
+
10
+ ## [0.31.18](https://github.com/0xPlayerOne/code-foundry/compare/v0.31.17...v0.31.18) (2026-07-30)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **codeql:** keep generated config in workspace ([9ca8f3b](https://github.com/0xPlayerOne/code-foundry/commit/9ca8f3b958e40209727f305bd0c0856f4820e1b6))
16
+
3
17
  ## [0.31.17](https://github.com/0xPlayerOne/code-foundry/compare/v0.31.16...v0.31.17) (2026-07-30)
4
18
 
5
19
 
@@ -48,7 +48,7 @@ repository manifests and source
48
48
  | `npm_publish` | `true` or `false` | Opt into npm publication |
49
49
  | `license` | `gpl-3.0-or-later`, `agpl-3.0-or-later`, `mit`, `preserve`, `none` | License policy; new repositories default to GPLv3 |
50
50
  | `git_workflow` | `staging-release` | Branch/release model; the standard model promotes `staging` into `main` |
51
- | `merge_strategy` | `rebase`, `squash`, `merge` | Preferred merge method for contribution and release PRs; defaults to `rebase` |
51
+ | `merge_strategy` | `rebase`, `squash`, `merge` | Preferred merge method for contribution and release PRs; defaults to `merge` |
52
52
  | `runner` fields | GitHub runner names | Per-workflow runner policy |
53
53
 
54
54
  Supported features are `ci`, `codeql`, `security`, `test`, `draft-pr`,
package/docs/RELEASES.md CHANGED
@@ -12,9 +12,8 @@ Keep commits Conventional Commit-shaped (`feat:`, `fix:`, `docs:`, `ci:`,
12
12
  `chore:`, and so on). Release Please uses them to select patch/minor/major
13
13
  versions and generate grouped changelog notes.
14
14
 
15
- The default `merge_strategy` is `rebase`, matching the repository's linear
16
- history policy. Set it to `squash` or `merge` in `.github/code-foundry.yml` when
17
- that repository intentionally uses a different merge convention. The current
15
+ The default `merge_strategy` is `merge`, matching promotion PRs from `staging` into `main`.
16
+ Configure it to `squash` or `rebase` in `.github/code-foundry.yml` if a repository intentionally differs. The current
18
17
  supported `git_workflow` is `staging-release`.
19
18
 
20
19
  The release workflow opens or updates a versioned PR after changes reach
@@ -54,6 +53,6 @@ the generated version pull request before using the token to merge it.
54
53
 
55
54
  1. Merge tested changes from `staging` into `main`.
56
55
  2. Review the generated Release Please PR and changelog.
57
- 3. Merge the release PR with the repository's normal linear-history policy.
56
+ 3. Merge the release PR with the repository's configured `merge_strategy` (default `merge`).
58
57
  4. Confirm the GitHub Release and any package publication.
59
58
  5. Synchronize `staging` with the new `main` release commit.
package/docs/WORKFLOWS.md CHANGED
@@ -61,13 +61,14 @@ checks disabled.
61
61
 
62
62
  ## Branch protection
63
63
 
64
- Use the repository's GitHub settings or the maintainer's branch-protection
65
- automation after reviewing the repository's enabled features:
64
+ Use repository rulesets (or legacy branch protection settings) to mirror the
65
+ required checks for each protected branch. Review the repository's enabled
66
+ features and enforce only checks that actually run:
66
67
 
67
68
  ```bash
68
69
  Apply only checks for enabled workflows.
69
70
  ```
70
71
 
71
- Keep strict status checks, linear history, and conversation resolution enabled.
72
- For a repository with optional features disabled, do not require checks that
73
- will never run.
72
+ Keep strict status checks, linear history, and conversation resolution enabled
73
+ where required. For a repository with optional features disabled, do not require
74
+ checks that will never run.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-foundry",
3
- "version": "0.31.17",
3
+ "version": "0.32.0",
4
4
  "description": "A fast, language-aware repository factory for agent-ready workflows, testing, security, and release automation.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",
@@ -339,7 +339,7 @@ function createDefaultConfig(root, source) {
339
339
  post_release: 'false', post_release_workflow: '', post_release_mode: 'auto',
340
340
  opencode_security: 'false',
341
341
  sync_mode: 'overlay', custom_workflows: 'preserve',
342
- license: existsSync(join(root, 'LICENSE')) ? 'preserve' : 'gpl-3.0-or-later', git_workflow: 'staging-release', merge_strategy: 'rebase',
342
+ license: existsSync(join(root, 'LICENSE')) ? 'preserve' : 'gpl-3.0-or-later', git_workflow: 'staging-release', merge_strategy: 'merge',
343
343
  }
344
344
  }
345
345
 
@@ -15,23 +15,22 @@ export function doctorGithub(root) {
15
15
  const warnings = []
16
16
  /** @type {Record<string, any>} */
17
17
  const details = { repository }
18
+ const rulesets = hydrateRulesets(repository, ghJson(['api', `repos/${repository}/rulesets`]))
19
+ const mainRulesets = rulesetsForBranch(rulesets, 'main')
18
20
  const protection = ghJson(['api', `repos/${repository}/branches/main/protection`])
19
- if (!protection) warnings.push('main branch protection is not readable or is not configured.')
20
- else {
21
- const required = requiredContexts(protection)
22
- details.requiredChecks = required
23
- const duplicateNames = required.filter((name) => /\b([^/]+) \/ \1\b/i.test(name))
24
- if (duplicateNames.length) errors.push(`required checks contain duplicate workflow prefixes: ${duplicateNames.join(', ')}`)
25
- if (!protection.required_status_checks) warnings.push('main protection has no required status checks.')
26
- }
21
+ const required = mainRulesets.length ? requiredContextsFromRulesets(mainRulesets) : requiredContextsFromProtection(protection)
22
+ details.requiredChecks = required
23
+ if (!protection && !mainRulesets.length) warnings.push('main branch protection or repository rulesets are not readable or are not configured.')
24
+ else if (!required.length) warnings.push(mainRulesets.length ? 'main ruleset has no required status checks.' : 'main protection has no required status checks.')
25
+ const duplicateNames = required.filter((name) => /\b([^/]+) \/ \1\b/i.test(name))
26
+ if (duplicateNames.length) errors.push(`required checks contain duplicate workflow prefixes: ${duplicateNames.join(', ')}`)
27
27
 
28
28
  const sha = String(ghJson(['api', `repos/${repository}/git/ref/heads/main`])?.object?.sha ?? '')
29
29
  const checks = sha ? ghJson(['api', `repos/${repository}/commits/${sha}/check-runs?per_page=100`])?.check_runs ?? [] : []
30
30
  const observed = checks.map(/** @param {any} check */ (check) => check.name).filter(Boolean)
31
31
  details.observedChecks = observed
32
32
  if (!observed.length) warnings.push('no check runs were observed on the current main commit; exact check validation is deferred until CI runs.')
33
- if (protection?.required_status_checks) {
34
- const required = requiredContexts(protection)
33
+ if (required.length) {
35
34
  const missing = required.filter((name) => observed.length && !observed.includes(name))
36
35
  if (missing.length) warnings.push(`required checks not observed on current main: ${missing.join(', ')}`)
37
36
  }
@@ -70,13 +69,62 @@ export function doctorGithub(root) {
70
69
  }
71
70
 
72
71
  /** @param {any} protection @returns {string[]} */
73
- function requiredContexts(protection) {
72
+ function requiredContextsFromProtection(protection) {
74
73
  return [...new Set([
75
- ...(protection.required_status_checks?.contexts ?? []),
76
- ...(protection.required_status_checks?.checks ?? []).map(/** @param {any} check */ (check) => check.context),
74
+ ...(protection?.required_status_checks?.contexts ?? []),
75
+ ...(protection?.required_status_checks?.checks ?? []).map(/** @param {any} check */ (check) => check.context),
77
76
  ].filter(Boolean))]
78
77
  }
79
78
 
79
+ /** @param {any[]} rulesets @returns {string[]} */
80
+ function requiredContextsFromRulesets(rulesets) {
81
+ return [...new Set(
82
+ (Array.isArray(rulesets) ? rulesets : []).flatMap((/** @type {any} */ ruleset) =>
83
+ (ruleset.rules ?? []).flatMap((/** @type {any} */ rule) =>
84
+ rule?.type === 'required_status_checks' ?
85
+ (rule.parameters?.required_status_checks ?? []).map((/** @type {any} */ check) => check?.context).filter(Boolean) :
86
+ []
87
+ ),
88
+ ),
89
+ )]
90
+ }
91
+
92
+ /** @param {string} repository @param {any[] | null} rulesets @returns {any[]} */
93
+ function hydrateRulesets(repository, rulesets) {
94
+ if (!Array.isArray(rulesets)) return []
95
+ return rulesets.map((ruleset) => {
96
+ if (!ruleset?.id) return ruleset
97
+ const details = ghJson(['api', `repos/${repository}/rulesets/${ruleset.id}`])
98
+ return details && typeof details === 'object' ? details : ruleset
99
+ })
100
+ }
101
+
102
+ /** @param {any[] | null} rulesets @param {string} branch @returns {any[]} */
103
+ function rulesetsForBranch(rulesets, branch) {
104
+ if (!Array.isArray(rulesets)) return []
105
+ return rulesets.filter((ruleset) => (
106
+ ruleset?.target === 'branch' &&
107
+ Array.isArray(ruleset?.conditions?.ref_name?.include) &&
108
+ Array.isArray(ruleset?.conditions?.ref_name?.exclude) &&
109
+ includesBranch(ruleset.conditions.ref_name.include, branch) &&
110
+ !includesBranch(ruleset.conditions.ref_name.exclude, branch)
111
+ ))
112
+ }
113
+
114
+ /** @param {(string | null | undefined)[]} patterns @param {string} branch @returns {boolean} */
115
+ function includesBranch(patterns, branch) {
116
+ const target = `refs/heads/${branch}`
117
+ return patterns.some((pattern) => {
118
+ if (!pattern) return false
119
+ if (pattern === '~ALL') return true
120
+ if (pattern === target || pattern === branch) return true
121
+ if (!/[\*?]/.test(pattern)) return false
122
+ const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\\\*/g, '.*').replace(/\\\?/g, '.')
123
+ const regex = new RegExp(`^${escaped}$`)
124
+ return regex.test(target) || regex.test(branch)
125
+ })
126
+ }
127
+
80
128
  /** @param {string} root @returns {{ errors: string[], warnings: string[] }} */
81
129
  function inspectWorkflows(root) {
82
130
  /** @type {string[]} */