From c8a238c7d75721a858a9df0b7ffa498affd8034a Mon Sep 17 00:00:00 2001 From: "James L. Cowan Jr." <112015792+jameslcowan@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:52:02 -0300 Subject: [PATCH 1/2] feat(cli): install the complex command beside complex-md Intent: give the CLI a 1 word command that matches the project name. The only command was complex-md. The package now installs complex, complex.md and complex-md, and all 3 run bin/complex-md.js. complex-md stays because hooks and CI files from earlier versions call it. complex.md is the bin that npx picks when the package is published as complex.md, since npx runs the bin named like the package. Verify: cd cli && npm test, 840 pass, 0 fail. npm pack, then a global install into a scratch prefix: all 3 commands print 0.11.0. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++++ cli/package.json | 2 ++ cli/test/bin-names.test.js | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 cli/test/bin-names.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 05b153b..c5a5e1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ format. ## Unreleased +**Intent:** the command was `complex-md`, 10 characters, and the project is named complex.md. A short command is easier to type and to remember. + +**Change:** the package installs 3 commands that run the same entry: `complex`, `complex.md` and `complex-md`. `complex-md` stays, so the hooks, CI files and AGENTS.md lines that earlier versions wrote keep working. The `complex.md` command lets `npx complex.md` pick the entry once the package is also published under that name. `cli/test/bin-names.test.js` checks the 3 names. + **Intent:** a key that a commit added stays in every clone of the history after a later commit deletes it, and the map had no way to show it. The bundle redaction also had its own 11 rules in code, so a second detector would drift from it. **Change:** new opt in command `complex-md exposure` (E1). It scans the tracked files and every line that a commit reachable from HEAD added (`--all-refs` for every ref, `--no-history` for the files only), with `git log -p` streamed and lockfiles, `node_modules`, `vendor` and minified files excluded in the git command. A partial clone skips the history and says so, since git would fetch each old blob. The 54 rules are data in `cli/rules/exposure.json` (53 known shapes, CWE ids, a severity, a confidence and a directive each, and 1 heuristic, `generic-assignment`, at low confidence); every quantifier is bounded and a rule names predicates, never code. The bundle redaction now uses the same rules. Output: `.complex-md/exposure-report.json` and with `--sarif` a SARIF 2.1.0 file with `partialFingerprints`; no output holds a value, only rule, path, line, commits, length, entropy and a fingerprint. `.complex-md/exposure.json` holds disabled rules, allows with a reason and an expiry compared with the commit date of HEAD, a baseline (`--baseline` writes it) and own rules; `--config-ref` reads it from a commit for CI; a comment `complex-md: allow ` allows 1 rule on its line. A finding in a test path is labelled and 1 severity step lower. `--strict` exits 1 on a new finding and 2 on a broken config. A `.gitignore` entry written before this release gets `!.complex-md/exposure.json` once. Measured on a development set of 9 snapshots of 4 public repositories with hard-coded credential advisories: 61 distinct findings (2 exact, 59 heuristic), 46 credentials, 14 unclear, 1 not, labelled by the author; every value that left a file was reported with the commit that removed it. The full history of django (35,052 commits) took 99 s, of which `git log -p` took 41 s. `cli/test/exposure.test.js`, `cli/test/exposure-rules.test.js`, `cli/test/partial-clone.test.js` and `cli/test/gitignore.test.js` cover it with fake keys built from fragments. diff --git a/cli/package.json b/cli/package.json index fcba769..af6715d 100644 --- a/cli/package.json +++ b/cli/package.json @@ -12,6 +12,8 @@ }, "type": "module", "bin": { + "complex": "bin/complex-md.js", + "complex.md": "bin/complex-md.js", "complex-md": "bin/complex-md.js" }, "files": [ diff --git a/cli/test/bin-names.test.js b/cli/test/bin-names.test.js new file mode 100644 index 0000000..fbe542a --- /dev/null +++ b/cli/test/bin-names.test.js @@ -0,0 +1,25 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { spawnSync } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; + +const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')); + +test('complex, complex.md and complex-md all run the one CLI entry', () => { + assert.deepEqual(Object.keys(pkg.bin).sort(), ['complex', 'complex-md', 'complex.md']); + for (const name of Object.keys(pkg.bin)) assert.equal(pkg.bin[name], 'bin/complex-md.js', name); +}); + +test('npx finds a bin named like the package under both published names', () => { + // npx runs the bin whose name equals the package name when a package has more than one bin. + assert.ok(pkg.bin[pkg.name], `no bin named ${pkg.name}`); + assert.ok(pkg.bin['complex.md'], 'no bin named complex.md for the complex.md package'); +}); + +test('the entry prints its version', () => { + const entry = fileURLToPath(new URL('../bin/complex-md.js', import.meta.url)); + const r = spawnSync(process.execPath, [entry, '--version'], { encoding: 'utf8' }); + assert.equal(r.status, 0, r.stderr); + assert.match(r.stdout + r.stderr, new RegExp(pkg.version.replace(/\./g, '\\.'))); +}); From e9f548e29e0fc2fd6de60697045fdd5233da6eda Mon Sep 17 00:00:00 2001 From: "James L. Cowan Jr." <112015792+jameslcowan@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:52:24 -0300 Subject: [PATCH 2/2] ci(release): also publish the CLI as complex.md Intent: let a release reach npm under the project's own name. npm runs `npx complex.md` only if a package has that name. The release job now publishes the same build a second time with the name set to complex.md. Trusted publishing needs the package to exist first, so the step checks the registry and skips until the first manual publish. Verify: the workflow parses; npm pack --dry-run with the name set gives complex.md-0.11.0.tgz with 47 files. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4baa723..f16adf8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,3 +32,14 @@ jobs: - run: npm run build - run: cd cli && npm publish --access public --provenance - run: cd packages/complex-md-mcp && npm publish --access public --provenance + # The same CLI build under the name complex.md, so `npx complex.md` works. + # Trusted publishing needs a package that exists: the maintainer makes the + # first publish by hand and adds this workflow as its trusted publisher. + # Until then the step skips and the release stays green. + - name: publish complex.md + run: | + if npm view complex.md version >/dev/null 2>&1; then + cd cli && npm pkg set name=complex.md && npm publish --access public --provenance + else + echo "complex.md is not on npm yet; skipped" + fi