@freesyntax/notch-cli 0.4.6 → 0.4.8
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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
autoCompress,
|
|
9
9
|
estimateTokens
|
|
10
10
|
} from "./chunk-MWM5TFY4.js";
|
|
11
|
+
import {
|
|
12
|
+
__require
|
|
13
|
+
} from "./chunk-3RG5ZIWI.js";
|
|
11
14
|
|
|
12
15
|
// src/index.ts
|
|
13
16
|
import { Command } from "commander";
|
|
@@ -3329,23 +3332,23 @@ function formatTokens(n) {
|
|
|
3329
3332
|
import fs12 from "fs/promises";
|
|
3330
3333
|
import path13 from "path";
|
|
3331
3334
|
import os3 from "os";
|
|
3335
|
+
import { execSync as execSync3 } from "child_process";
|
|
3332
3336
|
import chalk7 from "chalk";
|
|
3333
3337
|
var CACHE_FILE = path13.join(os3.homedir(), ".notch", "update-check.json");
|
|
3334
|
-
var CHECK_INTERVAL =
|
|
3335
|
-
var PACKAGE_NAME = "notch-cli";
|
|
3336
|
-
var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
3338
|
+
var CHECK_INTERVAL = 60 * 60 * 1e3;
|
|
3339
|
+
var PACKAGE_NAME = "@freesyntax/notch-cli";
|
|
3340
|
+
var REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
3337
3341
|
async function checkForUpdates(currentVersion) {
|
|
3338
3342
|
try {
|
|
3339
3343
|
const cache = await loadCache();
|
|
3340
3344
|
if (cache && Date.now() - cache.lastCheck < CHECK_INTERVAL) {
|
|
3341
3345
|
if (cache.latestVersion && isNewer(cache.latestVersion, currentVersion)) {
|
|
3342
|
-
return
|
|
3346
|
+
return autoUpdate(currentVersion, cache.latestVersion);
|
|
3343
3347
|
}
|
|
3344
3348
|
return null;
|
|
3345
3349
|
}
|
|
3346
3350
|
const response = await fetch(REGISTRY_URL, {
|
|
3347
|
-
signal: AbortSignal.timeout(
|
|
3348
|
-
// Fast timeout — don't slow down startup
|
|
3351
|
+
signal: AbortSignal.timeout(5e3),
|
|
3349
3352
|
headers: { "Accept": "application/json" }
|
|
3350
3353
|
});
|
|
3351
3354
|
if (!response.ok) {
|
|
@@ -3356,13 +3359,34 @@ async function checkForUpdates(currentVersion) {
|
|
|
3356
3359
|
const latest = data.version;
|
|
3357
3360
|
await saveCache({ lastCheck: Date.now(), latestVersion: latest });
|
|
3358
3361
|
if (isNewer(latest, currentVersion)) {
|
|
3359
|
-
return
|
|
3362
|
+
return autoUpdate(currentVersion, latest);
|
|
3360
3363
|
}
|
|
3361
3364
|
return null;
|
|
3362
3365
|
} catch {
|
|
3363
3366
|
return null;
|
|
3364
3367
|
}
|
|
3365
3368
|
}
|
|
3369
|
+
function autoUpdate(current, latest) {
|
|
3370
|
+
console.log(chalk7.cyan(`
|
|
3371
|
+
\u2B06 Updating Notch CLI: ${current} \u2192 ${latest}...
|
|
3372
|
+
`));
|
|
3373
|
+
try {
|
|
3374
|
+
execSync3(`npm install -g ${PACKAGE_NAME}@${latest}`, {
|
|
3375
|
+
stdio: "inherit",
|
|
3376
|
+
timeout: 6e4
|
|
3377
|
+
});
|
|
3378
|
+
console.log(chalk7.green(`
|
|
3379
|
+
\u2713 Updated to v${latest}. Restarting...
|
|
3380
|
+
`));
|
|
3381
|
+
const args = process.argv.slice(2);
|
|
3382
|
+
const { spawnSync } = __require("child_process");
|
|
3383
|
+
const result = spawnSync("notch", args, { stdio: "inherit" });
|
|
3384
|
+
process.exit(result.status ?? 0);
|
|
3385
|
+
} catch {
|
|
3386
|
+
return chalk7.yellow(` Update available: ${current} \u2192 ${latest}. Run: npm install -g ${PACKAGE_NAME}@latest
|
|
3387
|
+
`);
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3366
3390
|
function isNewer(latest, current) {
|
|
3367
3391
|
const l = latest.split(".").map(Number);
|
|
3368
3392
|
const c = current.split(".").map(Number);
|
|
@@ -3372,10 +3396,6 @@ function isNewer(latest, current) {
|
|
|
3372
3396
|
}
|
|
3373
3397
|
return false;
|
|
3374
3398
|
}
|
|
3375
|
-
function formatUpdateMessage(current, latest) {
|
|
3376
|
-
return chalk7.yellow(` Update available: ${current} -> ${latest}. Run: npm update -g ${PACKAGE_NAME}
|
|
3377
|
-
`);
|
|
3378
|
-
}
|
|
3379
3399
|
async function loadCache() {
|
|
3380
3400
|
try {
|
|
3381
3401
|
const raw = await fs12.readFile(CACHE_FILE, "utf-8");
|
|
@@ -3470,7 +3490,7 @@ function mergePermissions(base, override) {
|
|
|
3470
3490
|
}
|
|
3471
3491
|
|
|
3472
3492
|
// src/hooks/index.ts
|
|
3473
|
-
import { execSync as
|
|
3493
|
+
import { execSync as execSync4 } from "child_process";
|
|
3474
3494
|
import fs14 from "fs/promises";
|
|
3475
3495
|
import path15 from "path";
|
|
3476
3496
|
import os5 from "os";
|
|
@@ -3576,7 +3596,7 @@ async function executeHook(hook, context) {
|
|
|
3576
3596
|
NOTCH_CWD: context.cwd
|
|
3577
3597
|
};
|
|
3578
3598
|
try {
|
|
3579
|
-
const output =
|
|
3599
|
+
const output = execSync4(hook.command, {
|
|
3580
3600
|
cwd: context.cwd,
|
|
3581
3601
|
encoding: "utf-8",
|
|
3582
3602
|
timeout: hook.timeout ?? 1e4,
|
|
@@ -4101,7 +4121,7 @@ async function main() {
|
|
|
4101
4121
|
const creds = await login();
|
|
4102
4122
|
console.log(chalk9.green(`
|
|
4103
4123
|
\u2713 Signed in as ${creds.email}`));
|
|
4104
|
-
console.log(chalk9.gray(` API key stored in ${(await import("./auth-
|
|
4124
|
+
console.log(chalk9.gray(` API key stored in ${(await import("./auth-S3FIB42I.js")).getCredentialsPath()}
|
|
4105
4125
|
`));
|
|
4106
4126
|
} catch (err) {
|
|
4107
4127
|
spinner.stop();
|
|
@@ -4194,9 +4214,8 @@ async function main() {
|
|
|
4194
4214
|
}
|
|
4195
4215
|
const info = MODEL_CATALOG[activeModelId];
|
|
4196
4216
|
printBanner(VERSION, info.label, info.id, info.size, config.projectRoot);
|
|
4197
|
-
checkForUpdates(VERSION)
|
|
4198
|
-
|
|
4199
|
-
});
|
|
4217
|
+
const updateMsg = await checkForUpdates(VERSION);
|
|
4218
|
+
if (updateMsg) console.log(updateMsg);
|
|
4200
4219
|
const hookTrustPrompt = async (commands) => {
|
|
4201
4220
|
console.warn(chalk9.yellow("\n\u26A0 This project contains hooks in .notch.json that will run shell commands:"));
|
|
4202
4221
|
commands.forEach((cmd) => console.warn(chalk9.gray(` \u2022 ${cmd}`)));
|
|
@@ -4498,7 +4517,7 @@ Analyze the above input.`;
|
|
|
4498
4517
|
return;
|
|
4499
4518
|
}
|
|
4500
4519
|
if (input === "/compact") {
|
|
4501
|
-
const { autoCompress: autoCompress2 } = await import("./compression-
|
|
4520
|
+
const { autoCompress: autoCompress2 } = await import("./compression-CXJN2ZYN.js");
|
|
4502
4521
|
const before = messages.length;
|
|
4503
4522
|
const compressed = await autoCompress2(messages, model, MODEL_CATALOG[activeModelId].contextWindow);
|
|
4504
4523
|
messages.length = 0;
|