Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 4b19ca5

Browse files
greynewellclaude
andcommitted
fix: address CodeRabbit review comments
- Add idempotent npm publish check to release workflow - Add 20s timeout and remove latest fallback in npm install script - Use execFileSync to avoid shell quoting issues in install script - Handle signals in npm run wrapper - Add final hard-budget guard in render logic to ensure token limit - Update README npx example to be non-mutating Co-Authored-By: Grey Newell <greyshipscode@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Made-with: Cursor
1 parent 502e757 commit 4b19ca5

5 files changed

Lines changed: 38 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ jobs:
4949
npm version "$VERSION" --no-git-tag-version --allow-same-version
5050
5151
- name: Publish to npm
52-
run: npm publish --access public
52+
run: |
53+
VERSION="${GITHUB_REF_NAME#v}"
54+
if npm view "uncompact@$VERSION" version >/dev/null 2>&1; then
55+
echo "uncompact@$VERSION already exists on npm; skipping publish."
56+
exit 0
57+
fi
58+
npm publish --access public
5359
env:
5460
NODE_AUTH_TOKEN: ${{ secrets.SUPERMODEL_NPM_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ npm install -g uncompact
7676
Or run without installing:
7777

7878
```bash
79-
npx uncompact install
79+
npx uncompact --help
8080
```
8181

8282
**Via Go:**

internal/template/render.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,21 @@ func Render(graph *api.ProjectGraph, projectName string, opts RenderOptions) (st
193193
}
194194
result += note
195195
resultTokens = CountTokens(result)
196+
197+
// Final hard-budget guard: if the appended note still pushes it over
198+
if opts.MaxTokens > 0 && resultTokens > opts.MaxTokens {
199+
noteTokens := CountTokens(buildNote(resultTokens))
200+
budget := opts.MaxTokens - noteTokens
201+
if budget < 1 {
202+
budget = 1
203+
}
204+
truncated, truncatedTokens, truncErr := truncateToTokenBudget(graph, projectName, budget, graph.Stats.CircularDependencyCycles, opts.WorkingMemory, opts.SessionSnapshot, opts.ClaudeMD, opts.LocalMode, opts.Stale, staleDuration)
205+
if truncErr != nil {
206+
return "", 0, truncErr
207+
}
208+
result = truncated + buildNote(truncatedTokens)
209+
resultTokens = CountTokens(result)
210+
}
196211
}
197212

198213
return result, resultTokens, nil

npm/install.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const https = require("https");
44
const fs = require("fs");
55
const path = require("path");
6-
const { execSync } = require("child_process");
6+
const { execSync, execFileSync } = require("child_process");
77
const os = require("os");
88

99
const REPO_OWNER = "supermodeltools";
@@ -56,6 +56,10 @@ function httpsGet(url) {
5656
response.on("end", () => resolve(Buffer.concat(chunks)));
5757
response.on("error", reject);
5858
});
59+
request.setTimeout(20000, () => {
60+
request.destroy();
61+
reject(new Error(`Request timed out: ${url}`));
62+
});
5963
request.on("error", reject);
6064
});
6165
}
@@ -68,11 +72,7 @@ async function getRelease(version) {
6872
if (version && version !== "0.0.0") {
6973
const tag = version.startsWith("v") ? version : `v${version}`;
7074
const url = `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/tags/${tag}`;
71-
try {
72-
return await httpsGetJson(url);
73-
} catch (err) {
74-
console.log(`[uncompact] Release ${tag} not found, falling back to latest`);
75-
}
75+
return await httpsGetJson(url);
7676
}
7777
const url = `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest`;
7878
return httpsGetJson(url);
@@ -81,7 +81,7 @@ async function getRelease(version) {
8181
function extractTarGz(buffer, destDir, binaryName) {
8282
const tarPath = path.join(destDir, "archive.tar.gz");
8383
fs.writeFileSync(tarPath, buffer);
84-
execSync(`tar -xzf "${tarPath}" -C "${destDir}"`, { stdio: "pipe" });
84+
execFileSync("tar", ["-xzf", tarPath, "-C", destDir], { stdio: "pipe" });
8585
fs.unlinkSync(tarPath);
8686

8787
const extracted = path.join(destDir, binaryName);
@@ -96,9 +96,9 @@ function extractZip(buffer, destDir, binaryName) {
9696
fs.writeFileSync(zipPath, buffer);
9797

9898
if (process.platform === "win32") {
99-
execSync(`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`, { stdio: "pipe" });
99+
execFileSync("powershell", ["-Command", `Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force`], { stdio: "pipe" });
100100
} else {
101-
execSync(`unzip -o "${zipPath}" -d "${destDir}"`, { stdio: "pipe" });
101+
execFileSync("unzip", ["-o", zipPath, "-d", destDir], { stdio: "pipe" });
102102
}
103103
fs.unlinkSync(zipPath);
104104

npm/run.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ function main() {
5151
process.exit(1);
5252
});
5353

54-
child.on("close", (code) => {
55-
process.exit(code ?? 0);
54+
child.on("close", (code, signal) => {
55+
if (code === null && signal) {
56+
process.kill(process.pid, signal);
57+
} else {
58+
process.exit(code ?? 0);
59+
}
5660
});
5761
}
5862

0 commit comments

Comments
 (0)