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

Commit 6a1d707

Browse files
greynewellclaude
andcommitted
feat: postinstall runs auth login for fresh installs, install --yes for upgrades
Previously postinstall ran 'install --yes' then printed a message telling the user to run 'uncompact auth login' separately — two steps. Now: - Fresh install (not authenticated): postinstall runs 'auth login', which handles browser OAuth + hook installation in one flow. npm install -g uncompact is the only command a new user needs to run. - Upgrade (already authenticated): postinstall runs 'install --yes' to ensure hooks are current without re-prompting for auth. Co-Authored-By: Grey Newell <greyshipscode@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent de189b2 commit 6a1d707

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

npm/install.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,27 +187,32 @@ async function main() {
187187
log(`[uncompact] Installed to ${destPath}\n\n`);
188188
}
189189

190-
// Automatically install Claude Code hooks
191-
log("[uncompact] Configuring Claude Code hooks...\n");
190+
// Check if already authenticated so we can decide what to run.
191+
let isAuthenticated = false;
192192
try {
193-
execFileSync(destPath, ["install", "--yes"], { stdio: "inherit" });
193+
const out = execFileSync(destPath, ["auth", "status"], { stdio: "pipe" }).toString();
194+
isAuthenticated = out.includes("authenticated");
194195
} catch (err) {
195-
log("[uncompact] Note: Automatic hook configuration skipped or failed. Run manually if needed:\n");
196-
log(" uncompact install\n");
196+
// binary failed or not runnable — fall through to install
197197
}
198198

199-
// Show status to verify setup
200-
try {
201-
console.log();
202-
execFileSync(destPath, ["status"], { stdio: "inherit" });
203-
} catch (err) {
199+
if (isAuthenticated) {
200+
// Existing user (upgrade): just make sure hooks are current.
201+
log("[uncompact] Already authenticated. Ensuring Claude Code hooks are installed...\n");
204202
try {
205-
execFileSync(destPath, [], { stdio: "inherit" });
206-
} catch (e) {}
203+
execFileSync(destPath, ["install", "--yes"], { stdio: "inherit" });
204+
} catch (err) {
205+
log("[uncompact] Note: hook configuration skipped. Run 'uncompact install' manually if needed.\n");
206+
}
207+
} else {
208+
// Fresh install: auth login handles both authentication and hook installation.
209+
log("[uncompact] Starting setup...\n\n");
210+
try {
211+
execFileSync(destPath, ["auth", "login"], { stdio: "inherit" });
212+
} catch (err) {
213+
log("[uncompact] Setup skipped or failed. Run 'uncompact auth login' to complete setup.\n");
214+
}
207215
}
208-
209-
log("\n");
210-
log("[uncompact] To authenticate: run 'uncompact auth login'\n");
211216
}
212217

213218
main().catch((err) => {

0 commit comments

Comments
 (0)