@cosyte/cli 0.0.1 → 0.0.3

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/dist/mcp.d.cts CHANGED
@@ -20,7 +20,7 @@ import 'node:stream';
20
20
  /** The MCP server identity advertised to a client on connect. */
21
21
  declare const SERVER_INFO: {
22
22
  readonly name: "cosyte";
23
- readonly version: "0.0.0";
23
+ readonly version: string;
24
24
  };
25
25
  /**
26
26
  * Build the cosyte MCP {@link Server} with its two request handlers wired to the shared tool surface:
package/dist/mcp.d.ts CHANGED
@@ -20,7 +20,7 @@ import 'node:stream';
20
20
  /** The MCP server identity advertised to a client on connect. */
21
21
  declare const SERVER_INFO: {
22
22
  readonly name: "cosyte";
23
- readonly version: "0.0.0";
23
+ readonly version: string;
24
24
  };
25
25
  /**
26
26
  * Build the cosyte MCP {@link Server} with its two request handlers wired to the shared tool surface:
package/dist/mcp.mjs CHANGED
@@ -6,7 +6,7 @@ import { parseArgs } from 'util';
6
6
  // src/mcp/server.ts
7
7
 
8
8
  // src/core/version.ts
9
- var VERSION = "0.0.0";
9
+ var VERSION = "0.0.3";
10
10
 
11
11
  // src/core/exit-codes.ts
12
12
  var EXIT = {
@@ -22,7 +22,7 @@ var EXIT = {
22
22
  DATAERR: 65,
23
23
  /** No input: the named file does not exist or is unreadable (`EX_NOINPUT`). */
24
24
  NOINPUT: 66,
25
- /** Unavailable: a required capability is not yet built (e.g. `redact` before `@cosyte/deid`), a
25
+ /** Unavailable: a required capability is not yet wired (e.g. `redact` before `@cosyte/deid`), a
26
26
  * distinct non-zero signal that is never a fake success (`EX_UNAVAILABLE`). */
27
27
  UNAVAILABLE: 69,
28
28
  /** Internal error: an unexpected exception (a bug), distinct from a handled bad input (`EX_SOFTWARE`). */
@@ -50,8 +50,8 @@ var CLI_CODES = {
50
50
  CLI_PARSER_UNAVAILABLE: "CLI_PARSER_UNAVAILABLE",
51
51
  /** The wrapped parser rejected the input. Positional context only, never the offending bytes. Exit `65`. */
52
52
  CLI_PARSE_FAILED: "CLI_PARSE_FAILED",
53
- /** A command whose ground-layer library is not yet built (e.g. `redact` before `@cosyte/deid`
54
- * ships). Never a fake success: a distinct, value-free "unavailable" signal. Exit `69`. */
53
+ /** A command whose ground-layer library is not yet wired (e.g. `redact` before `@cosyte/deid` is
54
+ * wired). Never a fake success: a distinct, value-free "unavailable" signal. Exit `69`. */
55
55
  CLI_NOT_IMPLEMENTED: "CLI_NOT_IMPLEMENTED",
56
56
  /** An unexpected internal error (a bug). Exit `70`. */
57
57
  CLI_INTERNAL: "CLI_INTERNAL"
@@ -227,19 +227,25 @@ function anyError(findings) {
227
227
  return findings.some((f) => ERROR_SEVERITIES.has(f.severity));
228
228
  }
229
229
  async function loadOptional(format, load) {
230
+ return loadOptionalPackage(
231
+ `the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`,
232
+ load
233
+ );
234
+ }
235
+ async function loadOptionalPackage(detail, load) {
230
236
  try {
231
237
  return await load();
232
238
  } catch (e) {
233
239
  if (isModuleNotFound(e)) {
234
- throw new CliError(
235
- CLI_CODES.CLI_PARSER_UNAVAILABLE,
236
- EXIT.UNAVAILABLE,
237
- `the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`
238
- );
240
+ throw new CliError(CLI_CODES.CLI_PARSER_UNAVAILABLE, EXIT.UNAVAILABLE, detail);
239
241
  }
240
242
  throw e;
241
243
  }
242
244
  }
245
+ var FHIR_UNAVAILABLE = "the @cosyte/fhir parser is not installed, and it is not currently on the npm registry, so it cannot be installed from there; FHIR support is unavailable in this install";
246
+ async function loadFhir() {
247
+ return loadOptionalPackage(FHIR_UNAVAILABLE, () => import('@cosyte/fhir'));
248
+ }
243
249
  function isModuleNotFound(e) {
244
250
  if (typeof e !== "object" || e === null) return false;
245
251
  const code = "code" in e ? e.code : void 0;
@@ -258,7 +264,7 @@ async function parseFormat(format, bytes) {
258
264
  };
259
265
  }
260
266
  case "fhir": {
261
- const { parseResource, serializeResource } = await import('@cosyte/fhir');
267
+ const { parseResource, serializeResource } = await loadFhir();
262
268
  const text = decode(bytes);
263
269
  const { resource, issues } = parseResource(text);
264
270
  const model = JSON.parse(serializeResource(resource));
@@ -319,7 +325,7 @@ async function inspectFormat(format, bytes) {
319
325
  };
320
326
  }
321
327
  case "fhir": {
322
- const { parseResource, resourceType, readBundle } = await import('@cosyte/fhir');
328
+ const { parseResource, resourceType, readBundle } = await loadFhir();
323
329
  const { resource, issues } = parseResource(decode(bytes));
324
330
  const rt = resourceType(resource) ?? null;
325
331
  if (rt === "Bundle") {
@@ -424,7 +430,7 @@ async function inspectFormat(format, bytes) {
424
430
  async function validateFormat(format, bytes) {
425
431
  switch (format) {
426
432
  case "fhir": {
427
- const { parseResource, validateResource } = await import('@cosyte/fhir');
433
+ const { parseResource, validateResource } = await loadFhir();
428
434
  const { resource, issues } = parseResource(decode(bytes));
429
435
  const validation = validateResource(resource);
430
436
  const findings = [
@@ -672,11 +678,12 @@ async function convertCommand(args, deps, posture = VALUE_FREE) {
672
678
  return { stdout: `${conversion.bundleText}
673
679
  `, stderr, exit };
674
680
  }
681
+ var TRANSFORM_UNAVAILABLE = "the @cosyte/transform conversion library is not installed, so convert is unavailable; it requires @cosyte/fhir, which is not currently on the npm registry, so npm skips transform as an unresolvable optional dependency and installing it directly fails for the same reason";
675
682
  async function runConvert(bytes, posture) {
676
683
  const [{ parseHL7 }, { toFhir }, { serializeResource }] = await Promise.all([
677
684
  import('@cosyte/hl7'),
678
- import('@cosyte/transform'),
679
- import('@cosyte/fhir')
685
+ loadOptionalPackage(TRANSFORM_UNAVAILABLE, () => import('@cosyte/transform')),
686
+ loadFhir()
680
687
  ]);
681
688
  let msg;
682
689
  try {