@alint-js/cli 0.7.0 → 0.7.1

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.
@@ -1,17 +1,54 @@
1
1
  #!/usr/bin/env node
2
- import { t as executeCli } from "../cli-BsBgbtds.mjs";
2
+ import { t as executeCli } from "../cli-F44RJ972.mjs";
3
3
  import process from "node:process";
4
+ //#region src/cli/runtime/interrupt.ts
5
+ /** Binds one graceful process interrupt to an abort signal for the active CLI run. */
6
+ function bindInterruptSignal(source) {
7
+ const controller = new AbortController();
8
+ /**
9
+ * Aborts active CLI work when the process receives its first interrupt signal.
10
+ *
11
+ * Triggering workflow:
12
+ *
13
+ * {@link bindInterruptSignal}
14
+ * -> `InterruptSignalSource.once('SIGINT' | 'SIGTERM')`
15
+ * -> `handleInterrupt`
16
+ * -> `AbortController.abort()`
17
+ *
18
+ * Upstream:
19
+ * - {@link bindInterruptSignal} registers this handler for `SIGINT` and `SIGTERM`.
20
+ *
21
+ * Downstream:
22
+ * - Aborts {@link InterruptSignalBinding.signal}, which the lint command passes to `runAlint`.
23
+ */
24
+ const handleInterrupt = () => {
25
+ controller.abort();
26
+ };
27
+ source.once("SIGINT", handleInterrupt);
28
+ source.once("SIGTERM", handleInterrupt);
29
+ return {
30
+ dispose: () => {
31
+ source.off("SIGINT", handleInterrupt);
32
+ source.off("SIGTERM", handleInterrupt);
33
+ },
34
+ signal: controller.signal
35
+ };
36
+ }
37
+ //#endregion
4
38
  //#region src/bin/index.ts
39
+ const interrupt = bindInterruptSignal(process);
5
40
  executeCli(process.argv, {
6
41
  cwd: process.cwd(),
7
42
  stderr: process.stderr,
8
43
  stdin: process.stdin,
9
44
  stdout: process.stdout
10
- }).then((exitCode) => {
45
+ }, { signal: interrupt.signal }).then((exitCode) => {
11
46
  process.exitCode = exitCode;
12
47
  }).catch((error) => {
13
48
  process.stderr.write(`${formatError(error)}\n`);
14
49
  process.exitCode = 2;
50
+ }).finally(() => {
51
+ interrupt.dispose();
15
52
  });
16
53
  function formatError(error) {
17
54
  if (error instanceof Error) return error.message;
@@ -24,7 +24,7 @@ import { Minimatch, minimatch } from "minimatch";
24
24
  import fastStringTruncatedWidth from "fast-string-truncated-width";
25
25
  import { formatDuration, intervalToDuration } from "date-fns";
26
26
  //#region package.json
27
- var version = "0.7.0";
27
+ var version = "0.7.1";
28
28
  //#endregion
29
29
  //#region src/cli/output.ts
30
30
  function escapeLineValue(value) {
@@ -3498,7 +3498,7 @@ async function executeLint(options) {
3498
3498
  outputLanguage: options.outputLanguage,
3499
3499
  progress: mergeProgressReporters(options.progress, statsCollector?.reporter),
3500
3500
  runner,
3501
- signal: options.createSignal?.()
3501
+ signal: options.signal ?? options.createSignal?.()
3502
3502
  });
3503
3503
  } catch (error) {
3504
3504
  if (error instanceof AlintRunError || error instanceof AlintRunCancelledError || error instanceof AlintCachePersistenceError) await persistStats(error.result);
@@ -4253,55 +4253,29 @@ function createCliProgressReporter(options) {
4253
4253
  };
4254
4254
  }
4255
4255
  function createRenderingProgressReporter(summary, renderer) {
4256
+ /**
4257
+ * Resets the summary and starts its bounded TTY render interval.
4258
+ *
4259
+ * Triggering workflow:
4260
+ *
4261
+ * `runAlint`
4262
+ * -> `ProgressReporter.onPrepareStart`
4263
+ * -> `handlePrepareStart`
4264
+ * -> `TtyProgressRenderer.start`
4265
+ *
4266
+ * Upstream:
4267
+ * - `runAlint` emits `onPrepareStart` before source discovery.
4268
+ *
4269
+ * Downstream:
4270
+ * - Delegates state reset to `summary.onPrepareStart` and starts the renderer interval.
4271
+ */
4272
+ const handlePrepareStart = (payload) => {
4273
+ summary.onPrepareStart?.(payload);
4274
+ renderer.start();
4275
+ };
4256
4276
  return {
4257
- onDiagnostic: (payload) => {
4258
- summary.onDiagnostic?.(payload);
4259
- renderer.render();
4260
- },
4261
- onExecuteEnd: (payload) => {
4262
- summary.onExecuteEnd?.(payload);
4263
- renderer.render();
4264
- },
4265
- onExecuteStart: (payload) => {
4266
- summary.onExecuteStart?.(payload);
4267
- renderer.render();
4268
- },
4269
- onFileReady: (payload) => {
4270
- summary.onFileReady?.(payload);
4271
- renderer.render();
4272
- },
4273
- onJobEnd: (payload) => {
4274
- summary.onJobEnd?.(payload);
4275
- renderer.render();
4276
- },
4277
- onJobQueued: (payload) => {
4278
- summary.onJobQueued?.(payload);
4279
- renderer.render();
4280
- },
4281
- onJobRetry: (payload) => {
4282
- summary.onJobRetry?.(payload);
4283
- renderer.render();
4284
- },
4285
- onJobStart: (payload) => {
4286
- summary.onJobStart?.(payload);
4287
- renderer.render();
4288
- },
4289
- onPrepareEnd: (payload) => {
4290
- summary.onPrepareEnd?.(payload);
4291
- renderer.render();
4292
- },
4293
- onPrepareStart: (payload) => {
4294
- summary.onPrepareStart?.(payload);
4295
- renderer.start();
4296
- },
4297
- onRunEnd: (payload) => {
4298
- summary.onRunEnd?.(payload);
4299
- renderer.render();
4300
- },
4301
- onUsage: (payload) => {
4302
- summary.onUsage?.(payload);
4303
- renderer.render();
4304
- }
4277
+ ...summary,
4278
+ onPrepareStart: handlePrepareStart
4305
4279
  };
4306
4280
  }
4307
4281
  //#endregion
@@ -4376,7 +4350,7 @@ const lint = defineCommand({
4376
4350
  action: (context, files = [], options) => runLintCommand(files, {
4377
4351
  ...options,
4378
4352
  outputLanguage: options.lang ?? context.globalOptions.outputLanguage
4379
- }, context.io, context.interceptConsoleOutput),
4353
+ }, context.io, context.interceptConsoleOutput, context.signal),
4380
4354
  alias: ["!"],
4381
4355
  arguments: "[...files]",
4382
4356
  default: true,
@@ -4396,7 +4370,7 @@ async function assertConfigExists(cwd, configPath) {
4396
4370
  throw error;
4397
4371
  }
4398
4372
  }
4399
- async function runLintCommand(files, options, io, interceptConsoleOutput) {
4373
+ async function runLintCommand(files, options, io, interceptConsoleOutput, signal) {
4400
4374
  if (options.dirty && files.length > 0) {
4401
4375
  io.stderr.write("The --dirty option does not accept file arguments.\n");
4402
4376
  return 2;
@@ -4446,7 +4420,8 @@ async function runLintCommand(files, options, io, interceptConsoleOutput) {
4446
4420
  outputLanguage: options.outputLanguage,
4447
4421
  progress: progress?.reporter,
4448
4422
  runnerOptions: options,
4449
- session
4423
+ session,
4424
+ signal
4450
4425
  });
4451
4426
  } catch (error) {
4452
4427
  if (error instanceof NoFilesFoundError) {
@@ -4487,7 +4462,7 @@ function shouldEnableProgress(options, io) {
4487
4462
  //#endregion
4488
4463
  //#region src/cli/commands/lsp/index.ts
4489
4464
  const lsp = defineCommand({
4490
- action: async (context) => (await import("./server-C-kuoGl1.mjs")).startLspServer(context.io),
4465
+ action: async (context) => (await import("./server-JWv5WkGk.mjs")).startLspServer(context.io),
4491
4466
  description: "Run alint as a language server over stdio",
4492
4467
  examples: [["# Point an editor at the project's own alint", "alint lsp"].join("\n")],
4493
4468
  help: ["Serve alint diagnostics over the Language Server Protocol on stdin/stdout.", "The server is cache-first. It publishes diagnostics that are already cached, and it never calls a model on its own. Runs that spend tokens happen only through the `alint.runFile` and `alint.runWorkspace` commands."].join("\n\n"),
@@ -5163,7 +5138,7 @@ const commandTree = [
5163
5138
  ];
5164
5139
  //#endregion
5165
5140
  //#region src/cli/cli.ts
5166
- async function executeCli(argv, io) {
5141
+ async function executeCli(argv, io, runtime = {}) {
5167
5142
  if (argv.includes("--version") || argv.includes("-v")) {
5168
5143
  io.stdout.write(`${version}\n`);
5169
5144
  return 0;
@@ -5181,7 +5156,8 @@ async function executeCli(argv, io) {
5181
5156
  globalOptions,
5182
5157
  interceptConsoleOutput,
5183
5158
  io,
5184
- setupNoInteractive
5159
+ setupNoInteractive,
5160
+ signal: runtime.signal
5185
5161
  }, setPendingResult, {
5186
5162
  examples: [
5187
5163
  ["# Configure a provider interactively", "alint setup"].join("\n"),
package/dist/index.d.mts CHANGED
@@ -27,7 +27,10 @@ interface CliWritable {
27
27
  }
28
28
  //#endregion
29
29
  //#region src/cli/cli.d.ts
30
- declare function executeCli(argv: string[], io: CliIo): Promise<number>;
30
+ interface CliRuntimeOptions {
31
+ signal?: AbortSignal;
32
+ }
33
+ declare function executeCli(argv: string[], io: CliIo, runtime?: CliRuntimeOptions): Promise<number>;
31
34
  //#endregion
32
35
  //#region src/cli/reporters/index.d.ts
33
36
  interface FormatDiagnosticsOptions {
@@ -45,4 +48,4 @@ interface StylishReporterOptions {
45
48
  }
46
49
  declare function formatStylish(input: Diagnostic[] | RunResult, options?: StylishReporterOptions): string;
47
50
  //#endregion
48
- export { type AlintConfig, type AlintConfigItem, type CliIo, type ReporterName, type RunnerConfig, defineConfig, executeCli, formatDiagnostics, formatJson, formatStylish, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated };
51
+ export { type AlintConfig, type AlintConfigItem, type CliIo, type CliRuntimeOptions, type ReporterName, type RunnerConfig, defineConfig, executeCli, formatDiagnostics, formatJson, formatStylish, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-BsBgbtds.mjs";
1
+ import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-F44RJ972.mjs";
2
2
  import { ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated } from "@alint-js/config";
3
3
  import { defineConfig } from "@alint-js/core";
4
4
  export { defineConfig, executeCli, formatDiagnostics, formatJson, formatStylish, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated };
@@ -1,4 +1,4 @@
1
- import { a as createRunSession } from "./cli-BsBgbtds.mjs";
1
+ import { a as createRunSession } from "./cli-F44RJ972.mjs";
2
2
  import { CLEAR_CACHE_COMMAND, RUN_FILE_COMMAND, RUN_WORKSPACE_COMMAND } from "./lsp-commands.mjs";
3
3
  import { realpath, rm } from "node:fs/promises";
4
4
  import { AlintRunCancelledError, AlintRunError } from "@alint-js/core";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alint-js/cli",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.7.1",
5
5
  "description": "Agentic code analysis CLI for model-backed lint rules",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -50,10 +50,10 @@
50
50
  "tinyexec": "^1.2.4",
51
51
  "tinyrainbow": "^3.1.1",
52
52
  "vscode-languageserver": "^10.1.0",
53
- "@alint-js/model-adapter-acp": "0.7.0",
54
- "@alint-js/core": "0.7.0",
55
- "@alint-js/config": "0.7.0",
56
- "@alint-js/utils": "0.7.0"
53
+ "@alint-js/config": "0.7.1",
54
+ "@alint-js/core": "0.7.1",
55
+ "@alint-js/model-adapter-acp": "0.7.1",
56
+ "@alint-js/utils": "0.7.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@pnpm/find-workspace-dir": "^1000.1.5",