@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/CHANGELOG.md +189 -2
- package/README.md +85 -18
- package/dist/bin/cosyte-mcp.cjs +21 -14
- package/dist/bin/cosyte-mcp.cjs.map +1 -1
- package/dist/bin/cosyte-mcp.mjs +21 -14
- package/dist/bin/cosyte-mcp.mjs.map +1 -1
- package/dist/bin/cosyte.cjs +27 -19
- package/dist/bin/cosyte.cjs.map +1 -1
- package/dist/bin/cosyte.mjs +27 -19
- package/dist/bin/cosyte.mjs.map +1 -1
- package/dist/index.cjs +25 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -17
- package/dist/index.d.ts +51 -17
- package/dist/index.mjs +25 -18
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.cjs +21 -14
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.mjs +21 -14
- package/dist/mcp.mjs.map +1 -1
- package/package.json +13 -13
package/dist/bin/cosyte.cjs
CHANGED
|
@@ -39,7 +39,7 @@ var init_exit_codes = __esm({
|
|
|
39
39
|
DATAERR: 65,
|
|
40
40
|
/** No input: the named file does not exist or is unreadable (`EX_NOINPUT`). */
|
|
41
41
|
NOINPUT: 66,
|
|
42
|
-
/** Unavailable: a required capability is not yet
|
|
42
|
+
/** Unavailable: a required capability is not yet wired (e.g. `redact` before `@cosyte/deid`), a
|
|
43
43
|
* distinct non-zero signal that is never a fake success (`EX_UNAVAILABLE`). */
|
|
44
44
|
UNAVAILABLE: 69,
|
|
45
45
|
/** Internal error: an unexpected exception (a bug), distinct from a handled bad input (`EX_SOFTWARE`). */
|
|
@@ -91,8 +91,8 @@ var init_diagnostics = __esm({
|
|
|
91
91
|
/** The BYO ConceptMap supplied to `map-codes` is not valid JSON or not a loadable FHIR ConceptMap.
|
|
92
92
|
* Names the stable terminology-loader code, never the map's bytes. Exit `65`. */
|
|
93
93
|
CLI_MAP_INVALID: "CLI_MAP_INVALID",
|
|
94
|
-
/** A command whose ground-layer library is not yet
|
|
95
|
-
*
|
|
94
|
+
/** A command whose ground-layer library is not yet wired (e.g. `redact` before `@cosyte/deid` is
|
|
95
|
+
* wired). Never a fake success: a distinct, value-free "unavailable" signal. Exit `69`. */
|
|
96
96
|
CLI_NOT_IMPLEMENTED: "CLI_NOT_IMPLEMENTED",
|
|
97
97
|
/** An unexpected internal error (a bug). Exit `70`. */
|
|
98
98
|
CLI_INTERNAL: "CLI_INTERNAL"
|
|
@@ -255,19 +255,24 @@ function anyError(findings) {
|
|
|
255
255
|
return findings.some((f) => ERROR_SEVERITIES.has(f.severity));
|
|
256
256
|
}
|
|
257
257
|
async function loadOptional(format, load) {
|
|
258
|
+
return loadOptionalPackage(
|
|
259
|
+
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`,
|
|
260
|
+
load
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
async function loadOptionalPackage(detail, load) {
|
|
258
264
|
try {
|
|
259
265
|
return await load();
|
|
260
266
|
} catch (e) {
|
|
261
267
|
if (isModuleNotFound(e)) {
|
|
262
|
-
throw new CliError(
|
|
263
|
-
CLI_CODES.CLI_PARSER_UNAVAILABLE,
|
|
264
|
-
EXIT.UNAVAILABLE,
|
|
265
|
-
`the @cosyte/${format} parser is not installed; install it to use this format (it is an optional dependency)`
|
|
266
|
-
);
|
|
268
|
+
throw new CliError(CLI_CODES.CLI_PARSER_UNAVAILABLE, EXIT.UNAVAILABLE, detail);
|
|
267
269
|
}
|
|
268
270
|
throw e;
|
|
269
271
|
}
|
|
270
272
|
}
|
|
273
|
+
async function loadFhir() {
|
|
274
|
+
return loadOptionalPackage(FHIR_UNAVAILABLE, () => import('@cosyte/fhir'));
|
|
275
|
+
}
|
|
271
276
|
function isModuleNotFound(e) {
|
|
272
277
|
if (typeof e !== "object" || e === null) return false;
|
|
273
278
|
const code = "code" in e ? e.code : void 0;
|
|
@@ -286,7 +291,7 @@ async function parseFormat(format, bytes) {
|
|
|
286
291
|
};
|
|
287
292
|
}
|
|
288
293
|
case "fhir": {
|
|
289
|
-
const { parseResource, serializeResource } = await
|
|
294
|
+
const { parseResource, serializeResource } = await loadFhir();
|
|
290
295
|
const text = decode(bytes);
|
|
291
296
|
const { resource, issues } = parseResource(text);
|
|
292
297
|
const model = JSON.parse(serializeResource(resource));
|
|
@@ -347,7 +352,7 @@ async function inspectFormat(format, bytes) {
|
|
|
347
352
|
};
|
|
348
353
|
}
|
|
349
354
|
case "fhir": {
|
|
350
|
-
const { parseResource, resourceType, readBundle } = await
|
|
355
|
+
const { parseResource, resourceType, readBundle } = await loadFhir();
|
|
351
356
|
const { resource, issues } = parseResource(decode(bytes));
|
|
352
357
|
const rt = resourceType(resource) ?? null;
|
|
353
358
|
if (rt === "Bundle") {
|
|
@@ -457,7 +462,7 @@ async function fmtFormat(format, bytes) {
|
|
|
457
462
|
return { output: msg.toString(), warningCount: msg.warnings.length };
|
|
458
463
|
}
|
|
459
464
|
case "fhir": {
|
|
460
|
-
const { parseResource, serializeResource } = await
|
|
465
|
+
const { parseResource, serializeResource } = await loadFhir();
|
|
461
466
|
const { resource, issues } = parseResource(decode(bytes));
|
|
462
467
|
return { output: serializeResource(resource), warningCount: issues.length };
|
|
463
468
|
}
|
|
@@ -495,7 +500,7 @@ async function fmtFormat(format, bytes) {
|
|
|
495
500
|
async function validateFormat(format, bytes) {
|
|
496
501
|
switch (format) {
|
|
497
502
|
case "fhir": {
|
|
498
|
-
const { parseResource, validateResource } = await
|
|
503
|
+
const { parseResource, validateResource } = await loadFhir();
|
|
499
504
|
const { resource, issues } = parseResource(decode(bytes));
|
|
500
505
|
const validation = validateResource(resource);
|
|
501
506
|
const findings = [
|
|
@@ -588,7 +593,7 @@ function unsupportedInternal(format, op) {
|
|
|
588
593
|
`format '${format}' does not support \`${op}\``
|
|
589
594
|
);
|
|
590
595
|
}
|
|
591
|
-
var OP_SUPPORT, ERROR_SEVERITIES;
|
|
596
|
+
var OP_SUPPORT, ERROR_SEVERITIES, FHIR_UNAVAILABLE;
|
|
592
597
|
var init_parsers = __esm({
|
|
593
598
|
"src/core/parsers.ts"() {
|
|
594
599
|
init_diagnostics();
|
|
@@ -605,6 +610,7 @@ var init_parsers = __esm({
|
|
|
605
610
|
mllp: /* @__PURE__ */ new Set(["parse", "inspect"])
|
|
606
611
|
};
|
|
607
612
|
ERROR_SEVERITIES = /* @__PURE__ */ new Set(["error", "fatal"]);
|
|
613
|
+
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";
|
|
608
614
|
}
|
|
609
615
|
});
|
|
610
616
|
|
|
@@ -781,8 +787,8 @@ async function convertCommand(args, deps2, posture = VALUE_FREE) {
|
|
|
781
787
|
async function runConvert(bytes, posture) {
|
|
782
788
|
const [{ parseHL7 }, { toFhir }, { serializeResource }] = await Promise.all([
|
|
783
789
|
import('@cosyte/hl7'),
|
|
784
|
-
import('@cosyte/transform'),
|
|
785
|
-
|
|
790
|
+
loadOptionalPackage(TRANSFORM_UNAVAILABLE, () => import('@cosyte/transform')),
|
|
791
|
+
loadFhir()
|
|
786
792
|
]);
|
|
787
793
|
let msg;
|
|
788
794
|
try {
|
|
@@ -813,12 +819,13 @@ function convertOutcome(findings) {
|
|
|
813
819
|
`;
|
|
814
820
|
return { hasError: errors > 0, report: lines.join("") + summary };
|
|
815
821
|
}
|
|
816
|
-
var CONVERT_OPTIONS, SUPPORTED_TARGET, ERROR_SEVERITIES2;
|
|
822
|
+
var CONVERT_OPTIONS, SUPPORTED_TARGET, ERROR_SEVERITIES2, TRANSFORM_UNAVAILABLE;
|
|
817
823
|
var init_convert = __esm({
|
|
818
824
|
"src/commands/convert.ts"() {
|
|
819
825
|
init_diagnostics();
|
|
820
826
|
init_exit_codes();
|
|
821
827
|
init_input();
|
|
828
|
+
init_parsers();
|
|
822
829
|
init_phi();
|
|
823
830
|
init_wrap();
|
|
824
831
|
CONVERT_OPTIONS = {
|
|
@@ -830,6 +837,7 @@ var init_convert = __esm({
|
|
|
830
837
|
};
|
|
831
838
|
SUPPORTED_TARGET = "fhir";
|
|
832
839
|
ERROR_SEVERITIES2 = /* @__PURE__ */ new Set(["error", "fatal"]);
|
|
840
|
+
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";
|
|
833
841
|
}
|
|
834
842
|
});
|
|
835
843
|
async function inspectCommand(args, deps2, posture = VALUE_FREE) {
|
|
@@ -1143,7 +1151,7 @@ var init_validate = __esm({
|
|
|
1143
1151
|
var VERSION;
|
|
1144
1152
|
var init_version = __esm({
|
|
1145
1153
|
"src/core/version.ts"() {
|
|
1146
|
-
VERSION = "0.0.
|
|
1154
|
+
VERSION = "0.0.3";
|
|
1147
1155
|
}
|
|
1148
1156
|
});
|
|
1149
1157
|
|
|
@@ -1626,7 +1634,7 @@ init_parse();
|
|
|
1626
1634
|
init_diagnostics();
|
|
1627
1635
|
|
|
1628
1636
|
// src/core/deid.ts
|
|
1629
|
-
var DEID_UNAVAILABLE_REASON = "redact/deid is not yet available. It delegates to @cosyte/deid, which
|
|
1637
|
+
var DEID_UNAVAILABLE_REASON = "redact/deid is not yet available. It delegates to @cosyte/deid, which the CLI does not wire yet. The CLI ships no built-in redactor: a partial Safe-Harbor scrub over only the obvious PHI loci would leave PHI behind and present a false-safety impression, so nothing is emitted. This command will produce a de-identified copy once that integration lands and is vetted.";
|
|
1630
1638
|
function deidStatus() {
|
|
1631
1639
|
return { available: false, reason: DEID_UNAVAILABLE_REASON };
|
|
1632
1640
|
}
|
|
@@ -1674,7 +1682,7 @@ Commands:
|
|
|
1674
1682
|
fmt <file|-> Canonically re-serialize via the parser's spec-clean serializer
|
|
1675
1683
|
convert <file|-> Convert HL7 v2 \u2192 FHIR R4 via @cosyte/transform (use --to fhir)
|
|
1676
1684
|
map-codes <cmap|-> Translate a code through a BYO FHIR ConceptMap via @cosyte/terminology
|
|
1677
|
-
redact <file|-> De-identify a message (alias: deid): gated on @cosyte/deid, not yet
|
|
1685
|
+
redact <file|-> De-identify a message (alias: deid): gated on @cosyte/deid, not yet wired
|
|
1678
1686
|
mcp Start the stdio MCP server (agent front door; also the cosyte-mcp bin)
|
|
1679
1687
|
completion <shell> Print a shell completion script (bash | zsh | fish)
|
|
1680
1688
|
|