Skip to content
Open
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
93 changes: 37 additions & 56 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ name: Release
# native compilation, so cross-packaging is fine),
# 4. creates the GitHub Release (tag v<version>) with all archives, using the
# release notes from CHANGELOG.md,
# 5. publishes the npm thin-installer (shim + per-platform packages).
# 5. publishes the npm thin-installer (shim + per-platform packages) to
# the GitHub Packages npm registry under the owning user.
#
# Fork release path: packages are scoped to the repo owner (from
# GITHUB_REPOSITORY at pack time) and authenticated with the workflow's
# GITHUB_TOKEN (`packages: write` below) — no OIDC trusted publishing and
# no npmjs.com involvement. Appending to the existing package requires the
# token to have that package write access, which it keeps for packages
# created from this repo's own releases.
#
# Before triggering: bump package.json. CHANGELOG.md entries can live under
# `## [Unreleased]` — step 2 takes care of moving them.
#
# npm auth is OIDC trusted publishing (no NPM_TOKEN): every published package
# (@colbymchenry/codegraph + the per-platform bundles) has this repo +
# release.yml configured as its trusted publisher on npmjs.com. Adding a new
# platform package means configuring its trusted publisher there before the
# first release that includes it.
on:
workflow_dispatch: {}

permissions:
contents: write # create the GitHub Release + tag, push the CHANGELOG promote
id-token: write # OIDC token for npm --provenance and Sigstore signing
id-token: write # Sigstore signing of the bundle attestations
attestations: write # store the GitHub artifact attestations for the bundles
packages: write # publish the npm packages to GitHub Packages

jobs:
# Native extraction-kernel prebuilds (docs/design/rust-kernel-migration-plan.md).
Expand Down Expand Up @@ -77,29 +80,17 @@ jobs:
# Default checkout is detached at a SHA; we need an actual branch
# so the CHANGELOG-promote commit knows where to push.
ref: ${{ github.ref }}
# Authenticate as the maintainer (admin), not as github-actions[bot].
# The "Require PR approval for main branch" ruleset only lets the
# Admin repo role bypass — and GitHub blocks adding the GitHub
# Actions integration to bypass_actors on user-owned (non-org)
# repos with "Actor GitHub Actions integration must be part of
# the ruleset source or owner organization." So the auto-promote
# and auto-sync `git push origin HEAD:main` steps below both fail
# under the default GITHUB_TOKEN. Using a fine-grained PAT owned
# by the admin makes the push go through cleanly. Set the
# RELEASE_PAT secret with: contents:write on this repo, no other
# scopes. Rotate per your token policy; the workflow only runs
# on manual dispatch so the blast radius is small.
token: ${{ secrets.RELEASE_PAT }}
# The fork has no branch rulesets, so the default GITHUB_TOKEN
# (contents: write) pushes the CHANGELOG-promote / lock-sync
# commits straight to main. (Upstream used an admin PAT here
# because its ruleset blocked the Actions integration.)
- uses: actions/setup-node@v6
with:
node-version: 22
# No registry-url here: it writes an .npmrc that requires a
# NODE_AUTH_TOKEN env var to exist, and we publish via OIDC
# trusted publishing instead of a token.

- name: Upgrade npm for OIDC trusted publishing
# Trusted publishing needs npm >= 11.5; Node 22 bundles npm 10.
run: npm install -g npm@11 && npm --version
# Point npm at the GitHub Packages npm registry; the publish and
# verify steps feed it a token through NODE_AUTH_TOKEN (which
# this .npmrc line costily requires).
registry-url: https://npm.pkg.github.com

- name: Sync package-lock.json if version drifted
# When the maintainer bumps the version on package.json only — for
Expand Down Expand Up @@ -213,7 +204,7 @@ jobs:
# was built by this workflow from this repo — SHA256SUMS alone only
# proves integrity, not origin, since it ships next to the bundles.
# Verify any downloaded artifact with:
# gh attestation verify <file> -R colbymchenry/codegraph
# gh attestation verify <file> -R "$GITHUB_REPOSITORY"
uses: actions/attest-build-provenance@v4
with:
subject-path: |
Expand All @@ -226,8 +217,12 @@ jobs:
# never be needed in practice. Kept for defense-in-depth.
run: |
V="${{ steps.ver.outputs.version }}"
node scripts/extract-release-notes.mjs "$V" > notes.md 2>/dev/null \
|| node scripts/extract-release-notes.mjs Unreleased > notes.md 2>/dev/null || true
# GitHub Releases caps a release body at 125,000 characters and
# returns HTTP 422 past it; the [Unreleased] backlog can exceed
# that. --max-chars 124000 trims bullet-granular, never mid-bullet,
# and appends a pointer to CHANGELOG.md for the rest.
node scripts/extract-release-notes.mjs "$V" --max-chars 124000 > notes.md 2>/dev/null \
|| node scripts/extract-release-notes.mjs Unreleased --max-chars 124000 > notes.md 2>/dev/null || true
if [ ! -s notes.md ]; then
echo "::error::No release notes in CHANGELOG.md for [$V] or [Unreleased]."
exit 1
Expand All @@ -246,12 +241,14 @@ jobs:
gh release create "$TAG" release/codegraph-* release/SHA256SUMS --title "$TAG" --notes-file notes.md
fi

- name: Publish to npm
# Auth is OIDC trusted publishing (id-token: write above) — npm mints
# a short-lived credential from the workflow's identity; there is no
# NPM_TOKEN. Provenance is generated automatically on this path; the
# explicit --provenance keeps the intent visible and fails loudly if
# OIDC is ever unavailable.
- name: Publish to GitHub Packages
# Auth is the workflow's GITHUB_TOKEN with `packages: write`
# (see permissions above), matched to the //npm.pkg.github.com line
# setup-node wrote into ~/.npmrc. GitHub Packages scopes every
# package under the owning user, which pack-npm.sh derives from
# GITHUB_REPOSITORY — provenance/OIDC don't apply on this registry.
env:
NODE_AUTH_TOKEN: ${{ github.token }}
run: |
V="${{ steps.ver.outputs.version }}"
bash scripts/pack-npm.sh "$V"
Expand All @@ -263,14 +260,13 @@ jobs:
echo "skip $name@$V (already published)"
else
echo "publishing $name@$V"
# --provenance: publish with an npm provenance attestation
# (needs the id-token: write permission above and the
# repository field pack-npm.sh writes into each package.json).
( cd "$dir" && npm publish --access public --provenance )
( cd "$dir" && npm publish --registry https://npm.pkg.github.com )
fi
done

- name: Verify every package is actually on the registry
env:
NODE_AUTH_TOKEN: ${{ github.token }}
run: |
V="${{ steps.ver.outputs.version }}"
# npm publish can print success without persisting; confirm against the
Expand All @@ -288,18 +284,3 @@ jobs:
echo "verified $name@$V"
done

- name: Sync packages to npmmirror
# npmmirror/cnpm mirror lazily and frequently never pull the per-platform
# optionalDependencies on their own, so `npm i` there fails with
# "no prebuilt bundle" (issue #303). Nudge a sync now so mirror users get
# the bundle without waiting. Best-effort — the launcher also self-heals
# from GitHub Releases — so a mirror hiccup never fails the release.
continue-on-error: true
run: |
for dir in release/npm/codegraph-* release/npm/main; do
name=$(node -p "require('./$dir/package.json').name")
enc=$(node -p "encodeURIComponent(require('./$dir/package.json').name)")
echo "sync $name"
curl -s -X PUT "https://registry.npmmirror.com/-/package/$enc/syncs" || true
echo
done
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixes

- npm installs of this fork now resolve their platform bundle under the fork's own package scope: the `codegraph` and `require` entries looked for `@colbymchenry/codegraph-<platform>-<arch>` regardless of which scope the packages installed from, so on GitHub Packages as `@malarinv/codegraph` every command reported the bundle "missing" and then failed to fetch a matching upstream release. Both now derive the scope and repository from the installed main package's own `package.json`, with upstream's remaining the fallback, and the self-heal download points at the fork's own releases.
- The self-heal fallback and its guidance lines no longer name the wrong owner when the packages come from a fork, so `npm i -g <pkg> --registry=…` in the fix-it text points at a package that exists.


## [1.7.0] - 2026-11-02

### Security

- CodeGraph's refusal to use a sensitive folder such as `~/.ssh`, `~/.config`, `/etc` or `C:\Windows` as a project can no longer be sidestepped: a link or junction that leads to one, a differently capitalized name on Windows and macOS, a `\\?\` spelling on Windows, and a path to a missing folder inside one are now refused like the folder itself. Before, any of these let an AI agent's query read the files inside. Thanks @mixxer for finding it.
Expand Down Expand Up @@ -51,6 +59,11 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- In Drupal, services from `*.services.yml`, plugin definitions (attributes and docblock annotations, a contrib module's own plugin types included) and `#[Hook]` methods are now part of the graph, and a call through `\Drupal::service('x')` or `$container->get('x')` links to the method on that service's class. Thanks @mikedamoiseau and @marcelovani.
- In Next.js, a route now links to the `proxy.ts` or `middleware.ts` that runs before it, following `config.matcher`, so `codegraph impact`, `codegraph callers` and `codegraph_explore` show which routes a change to it reaches. Thanks @RIGOandre.

### Features

- Kubernetes, Flux, Crossplane and Backstage catalog manifests are now part of the graph. Each YAML document that declares an `apiVersion` and a `kind` becomes a node named after both — `HelmRelease/consensus`, `Kustomization/kustomization`, `Record/www-dev-a-record` — so `codegraph explore`, search and impact can answer questions about manifests the way they do about code. Edges are added only for the keys that point at another document, such as a HelmRelease's `sourceRef` and `dependsOn`, a Kustomization's `spec.path`, its `resources:` list, and a Crossplane claim's `secretRef` or `providerConfigRef`, so what a manifest needs can be followed rather than read. A repository whose YAML is only config, like `mkdocs.yml` or `.gitlab-ci.yml`, is unaffected. Re-index GitOps repositories after upgrading.
- A Rego policy's `data.<file>` reads now link to the data YAML file it reads. A flat YAML file whose name carries an underscore or a digit, such as `policy/data/consensus_bounds.yaml`, is indexed under that name, so the policy's dependency on it shows in callers and impact, and changing it can be followed to the rules that read it.

### Fixes

- In TypeScript, an awaited call with type arguments like `await fetchApi<User>("/me")` or `await api.get<T>(url)` now links to the function it calls. Before, the call was dropped, so typed fetch wrappers looked like they had no callers. (#2586)
Expand Down Expand Up @@ -1806,3 +1819,4 @@ Thanks @andreinknv for the substantive draft this release was based on.
[1.6.0]: https://github.com/colbymchenry/codegraph/releases/tag/v1.6.0
[1.6.1]: https://github.com/colbymchenry/codegraph/releases/tag/v1.6.1
[1.6.2]: https://github.com/colbymchenry/codegraph/releases/tag/v1.6.2
[1.7.0]: https://github.com/colbymchenry/codegraph/releases/tag/v1.7.0
30 changes: 30 additions & 0 deletions __tests__/npm-shim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,36 @@ describe.skipIf(isWindows)('npm-shim launcher', () => {
expect(fs.existsSync(path.join(cache, 'bundles'))).toBe(false);
});

// A fork publishing under its own scope (e.g. GitHub Packages as
// @malarinv/codegraph): the platform optionalDependency resolves from the
// main package's own name, not a hardcoded scope. Before that derivation the
// shim asked for @colbymchenry/codegraph-<target>, reported the installed
// bundle "missing" and 404'd on an upstream release it doesn't own.
it('resolves the platform bundle under the main package\'s own scope', async () => {
const pkg = makePkg('9.9.9-fork');
fs.writeFileSync(path.join(pkg, 'package.json'),
JSON.stringify({
name: '@malarinv/codegraph',
version: '9.9.9-fork',
repository: { type: 'git', url: 'git+https://github.com/malarinv/codegraph.git' },
}) + '\n');
const platformPkg = path.join(pkg, 'node_modules', '@malarinv', `codegraph-${target}`);
writeLauncher(path.join(platformPkg, 'bin'));
fs.writeFileSync(path.join(platformPkg, 'package.json'),
JSON.stringify({ name: `@malarinv/codegraph-${target}`, version: '9.9.9-fork' }) + '\n');
const cache = mkTmp('cache');
const r = await runShim(pkg, ['--probe-fork'], {
CODEGRAPH_INSTALL_DIR: cache,
CODEGRAPH_NO_DOWNLOAD: '1', // a fallback here would mean the fork bundle was not found
});

expect(r.status).toBe(0);
expect(r.stdout).toContain('FAKE_BUNDLE_RAN');
expect(r.stdout).toContain('--probe-fork');
expect(r.stderr).not.toContain('@colbymchenry');
expect(r.stderr).not.toContain('downloading');
});

it('uses an already-cached bundle even when downloads are disabled', async () => {
const pkg = makePkg('1.2.3-cached');
const cache = mkTmp('cache');
Expand Down
28 changes: 22 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"name": "@colbymchenry/codegraph",
"version": "1.6.2",
"name": "@malarinv/codegraph",
"version": "1.7.1",
"description": "Supercharge AI coding agents with semantic code intelligence — surgical context, fewer tool calls, faster answers. 100% local.",
"repository": {
"type": "git",
"url": "git+https://github.com/colbymchenry/codegraph.git"
},
"repository": "https://github.com/malarinv/codegraph.git",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
Expand Down Expand Up @@ -58,7 +55,8 @@
"picomatch": "^4.0.3",
"sisteransi": "^1.0.5",
"tree-sitter-wasms": "^0.1.11",
"web-tree-sitter": "^0.25.3"
"web-tree-sitter": "^0.25.3",
"yaml": "^2.8.1"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^6.2.4",
Expand All @@ -70,5 +68,10 @@
},
"engines": {
"node": ">=20.0.0 <25.0.0"
},
"homepage": "https://github.com/malarinv/codegraph",
"publishConfig": {
"registry": "https://npm.pkg.github.com",
"access": "public"
}
}
Loading