@quolu/lattice 0.60.0 → 0.60.2

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.
package/bin/lattice.mjs CHANGED
@@ -1,24 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { fileURLToPath } from 'node:url';
4
3
  import { installPipeCloseGuard } from '../src/cli-stdio.mjs';
5
- import { runRuntimeCli } from '../src/runtime-cli.mjs';
6
4
  import { renderCliHelp } from '../src/cli-help.mjs';
7
- import { relaunchSensorForNode22IfNeeded } from '../src/sensor-node-runtime.mjs';
5
+ import { installNode22SqliteWarningFilter } from '../src/sensor-node-runtime.mjs';
8
6
  import packageJson from '../package.json' with { type: 'json' };
9
7
 
10
8
  installPipeCloseGuard();
11
9
 
12
10
  const args = process.argv.slice(2);
13
- const sensorRelaunchStatus = relaunchSensorForNode22IfNeeded({
14
- args,
15
- scriptPath: fileURLToPath(import.meta.url),
16
- });
11
+ const restoreWarningHandler = installNode22SqliteWarningFilter();
17
12
  const help = renderCliHelp(args);
18
13
 
19
- if (sensorRelaunchStatus !== null) {
20
- process.exitCode = sensorRelaunchStatus;
21
- } else if (help !== null) {
14
+ if (help !== null) {
22
15
  process.stdout.write(help);
23
16
  } else if (args.length === 1 && args[0] === '--version') {
24
17
  process.stdout.write(`${packageJson.version}\n`);
@@ -125,6 +118,7 @@ if (sensorRelaunchStatus !== null) {
125
118
  });
126
119
  } else {
127
120
  try {
121
+ const { runRuntimeCli } = await import('../src/runtime-cli.mjs');
128
122
  process.exitCode = await runRuntimeCli({
129
123
  argv: args,
130
124
  cwd: process.cwd(),
@@ -151,6 +145,8 @@ if (sensorRelaunchStatus !== null) {
151
145
  }
152
146
  }
153
147
 
148
+ restoreWarningHandler();
149
+
154
150
  async function runRuntimeErrorsCli(rest) {
155
151
  const runtimeErrors = await import('../src/runtime-errors.mjs');
156
152
  const usage = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.60.0",
3
+ "version": "0.60.2",
4
4
  "description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
5
5
  "author": {
6
6
  "name": "Quo / クオ at kitepon.dev",
@@ -1,53 +1,32 @@
1
- import { spawnSync } from 'node:child_process';
2
-
3
1
  export const SQLITE_EXPERIMENTAL_WARNING_FLAG = '--disable-warning=ExperimentalWarning';
4
- const RELAUNCH_GUARD_ENV = 'LATTICE_SENSOR_SQLITE_WARNING_RELAUNCHED';
2
+ export const SQLITE_EXPERIMENTAL_WARNING_MESSAGE =
3
+ 'SQLite is an experimental feature and might change at any time';
5
4
 
6
5
  export function sensorNodeRuntimeFlags(nodeVersion = process.versions.node) {
7
6
  const major = Number(nodeVersion.split('.')[0]);
8
7
  return major === 22 ? [SQLITE_EXPERIMENTAL_WARNING_FLAG] : [];
9
8
  }
10
9
 
11
- export function sensorRelaunchArgv(
12
- scriptPath,
13
- args,
14
- execArgv = process.execArgv,
15
- nodeVersion = process.versions.node,
16
- ) {
17
- const flags = sensorNodeRuntimeFlags(nodeVersion)
18
- .filter((flag) => !execArgv.includes(flag));
19
- return [...flags, ...execArgv, scriptPath, ...args];
20
- }
21
-
22
10
  /**
23
- * Node 22 prints node:sqlite's ExperimentalWarning to stderr. Sensor commands
24
- * have a strict JSON-only stderr contract, so relaunch only that command
25
- * surface with Node's warning-category flag before node:sqlite is imported.
11
+ * Node 22 prints node:sqlite's ExperimentalWarning to stderr. The CLI has a
12
+ * JSON-only output contract, so suppress that exact warning while node:sqlite loads.
13
+ * Every other process warning keeps Node's original behavior.
26
14
  */
27
- export function relaunchSensorForNode22IfNeeded({ args, scriptPath, env = process.env }) {
28
- const flags = sensorNodeRuntimeFlags();
29
- if (args[0] !== 'sensor'
30
- || flags.length === 0
31
- || flags.every((flag) => process.execArgv.includes(flag))
32
- || env[RELAUNCH_GUARD_ENV] === '1') return null;
15
+ export function installNode22SqliteWarningFilter({
16
+ nodeVersion = process.versions.node,
17
+ processObject = process,
18
+ } = {}) {
19
+ if (sensorNodeRuntimeFlags(nodeVersion).length === 0) return () => {};
20
+
21
+ const originalEmitWarning = processObject.emitWarning;
22
+ processObject.emitWarning = function filteredEmitWarning(warning, ...args) {
23
+ const type = typeof args[0] === 'string' ? args[0] : args[0]?.type;
24
+ const message = typeof warning === 'string' ? warning : warning?.message;
25
+ if (type === 'ExperimentalWarning' && message === SQLITE_EXPERIMENTAL_WARNING_MESSAGE) return;
26
+ return Reflect.apply(originalEmitWarning, processObject, [warning, ...args]);
27
+ };
33
28
 
34
- const result = spawnSync(
35
- process.execPath,
36
- sensorRelaunchArgv(scriptPath, args),
37
- {
38
- cwd: process.cwd(),
39
- env: { ...env, [RELAUNCH_GUARD_ENV]: '1' },
40
- stdio: 'inherit',
41
- windowsHide: true,
42
- },
43
- );
44
- if (result.error) {
45
- process.stderr.write(`${JSON.stringify({
46
- schema: 'lattice.cli_error.v2',
47
- code: 'LATTICE_SENSOR_RELAUNCH_FAILED',
48
- message: result.error.message,
49
- })}\n`);
50
- return 1;
51
- }
52
- return result.status ?? 1;
29
+ return () => {
30
+ processObject.emitWarning = originalEmitWarning;
31
+ };
53
32
  }