@politty/loculus 0.0.0-stage → 0.1.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -2
  3. package/bin/cli.mjs +3 -0
  4. package/dist/agent.d.ts +2 -0
  5. package/dist/agent.js +1 -0
  6. package/dist/argv-parser-BRSUT6IV.js +1 -0
  7. package/dist/cli-main-CoQp6CjD.js +1 -0
  8. package/dist/cli-main-D4rJTFFd.js +2 -0
  9. package/dist/cli-run-DABESHM4.js +1 -0
  10. package/dist/cli.d.ts +1 -0
  11. package/dist/cli.js +2 -0
  12. package/dist/command-BXsTrIgI.js +1 -0
  13. package/dist/compile-cache-6u9hgeWu.js +1 -0
  14. package/dist/compile-cache.d.ts +80 -0
  15. package/dist/compile-cache.js +1 -0
  16. package/dist/completion-BGidlN43.js +1 -0
  17. package/dist/completion-Cyw4RN-l.js +116 -0
  18. package/dist/completion.d.ts +333 -0
  19. package/dist/completion.js +1 -0
  20. package/dist/detect-agent-D7KSeWMh.js +3 -0
  21. package/dist/detect-agent-EHaSY1KW.d.ts +49 -0
  22. package/dist/docs.d.ts +770 -0
  23. package/dist/docs.js +94 -0
  24. package/dist/dynamic-BbeRdUqR.js +1 -0
  25. package/dist/dynamic-Hg5BDHzz.js +6 -0
  26. package/dist/import-meta-resolve-DgKm4LYW.js +3 -0
  27. package/dist/index.d.ts +1088 -0
  28. package/dist/index.js +1 -0
  29. package/dist/log-collector-uhRWYT-z.js +1 -0
  30. package/dist/logger-CoeDrmRr.js +1 -0
  31. package/dist/prompt-clack.d.ts +15 -0
  32. package/dist/prompt-clack.js +1 -0
  33. package/dist/prompt-fl79dWPz.js +1 -0
  34. package/dist/prompt-inquirer.d.ts +15 -0
  35. package/dist/prompt-inquirer.js +1 -0
  36. package/dist/prompt.d.ts +106 -0
  37. package/dist/prompt.js +1 -0
  38. package/dist/register-Ceh-HlVN.js +1 -0
  39. package/dist/registry-BEz5iex_.js +1 -0
  40. package/dist/runner-D-n1xa2K.js +33 -0
  41. package/dist/runner-nPWQnqQ3.js +1 -0
  42. package/dist/schema--6eHVfwR.js +1 -0
  43. package/dist/schema-extractor-DFawzmtj.js +1 -0
  44. package/dist/skill.d.ts +581 -0
  45. package/dist/skill.js +2 -0
  46. package/dist/subcommand-router-iqmWGZyU.js +2 -0
  47. package/dist/types-Dhar1ua6.d.ts +1125 -0
  48. package/dist/with-completion-command-CARvhYvv.d.ts +384 -0
  49. package/dist/with-completion-command-yg7HB6Zu.js +3 -0
  50. package/package.json +101 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 toiroakr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # @politty/loculus
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Politty with [loculus](https://github.com/toiroakr/loculus) flat string-input schemas. Requires Node.js 22.18.0 or newer. Uses the same core command execution, help, docs, completion, prompt, skills and agent functionality as `@politty/zod`.
4
+
5
+ ```ts
6
+ import * as l from "loculus";
7
+ import { arg, defineCommand, runMain } from "@politty/loculus";
8
+
9
+ const command = defineCommand({
10
+ name: "serve",
11
+ args: l.object({
12
+ file: arg(l.string(), { positional: true }),
13
+ port: arg(l.number({ integer: true, gte: 1, lte: 65535, default: 3000 }), {
14
+ alias: "p",
15
+ env: "PORT",
16
+ description: "Listen port",
17
+ }),
18
+ cache: arg(l.boolean({ default: true }), { negation: true }),
19
+ mode: l.enum(["dev", "prod"], { default: "dev" }),
20
+ }),
21
+ run: (args) => console.log(args),
22
+ });
23
+ await runMain(command);
24
+ ```
25
+
26
+ Schema outputs are inferred in `run`. `arg` supports positionals, aliases, hidden aliases, environment fallbacks, completion, prompts, effects and negations. Metadata survives loculus constructor options and transform/refine wrappers. The schema's input kind determines CLI token handling even when a transform changes the output type.
27
+
28
+ Constructor `nullable` / `nullish` flags preserve null output types. A scalar `default` applies to undefined; `default: { nullish: value }` applies to undefined and null. Null-only defaults still require an argument. Help displays only the undefined default, because CLI omission produces undefined.
29
+
30
+ Loculus 0.2.4 supports string, boolean and numeric literal fields with exact output types. Boolean literals use boolean CLI flags; numeric literals accept numeric strings. Literal choices appear in JSON help and completion, and typed literals can select discriminated command branches.
31
+
32
+ Multi-value literals also work as CLI fields: `l.literal([1, 2, 3])`, `l.literal([true, false])` and `l.literal([true, "auto"])` infer their output unions and expose choices to help/completion. Mixed boolean/string fields take an explicit value, for example `--mode true` or `--mode auto`.
33
+
34
+ Numeric discriminators accept the same decimal spellings as numeric fields: `--edition 2`, `--edition 2.0` and `--edition 2e0` select the same branch for execution and dynamic completion. Different branches must have distinct CLI spellings: a numeric `1` and a string `"1"` cannot identify separate branches. Such schemas fail during command metadata extraction.
35
+
36
+ Public subpaths: `docs`, `completion`, `skill`, `agent`, `prompt`, `prompt/clack`, `prompt/inquirer`, `compile-cache`, `cli`. The optional prompt integrations use the same optional peers as `@politty/zod`. No Zod or Valibot runtime is loaded.
37
+
38
+ Flat objects, discriminated unions, ordinary unions, xor and intersections are supported. Loculus 0.2 supports finite nested objects and multidimensional arrays, but Politty CLI arguments remain flat: nested object fields and nested arrays have no dedicated token mapping. Arbitrary recursive schemas and asynchronous validation are outside the supported CLI contract. `arg` replaces Zod-specific `.meta()` augmentation; a Zod `augment` subpath is therefore unnecessary.
39
+
40
+ Composite schemas use their branches' common CLI unknown-flag policy. When the branches have different policies, they use the core's default strip-with-warning policy, independent of branch order.
41
+
42
+ Arrays require array inputs by default in Loculus 0.2. Politty collects repeated CLI values into arrays, so `--tags a` and `--tags a --tags b` work without `wrapScalar`. Environment fallbacks supply strings, so array fields with `env` need `wrapScalar: true`. Non-CLI callers passing scalar values need the same option.
43
+
44
+ ## Build-time optimization
45
+
46
+ Loculus 0.2.5 or newer in the 0.2 line can be used with `@loculus/rolldown` 0.2.3 or newer in the 0.2 line to specialize supported static schemas during the CLI build. The generated validators preserve the metadata used by help, docs, completion and prompts. Dynamic or unsupported definitions retain ordinary validation.
47
+
48
+ ```ts
49
+ import { defineConfig } from "tsdown";
50
+ import { loculusPlugin } from "@loculus/rolldown";
51
+
52
+ export default defineConfig({
53
+ entry: ["src/main.ts"],
54
+ plugins: [loculusPlugin()],
55
+ });
56
+ ```
57
+
58
+ The plugin requires Node.js 22.18.0 or newer at build time and Rolldown `>=1.2.13 <2`. It is optional and belongs in the CLI project's devDependencies.
59
+
60
+ ## Development
61
+
62
+ The adapter uses the published `loculus` 0.2.5 package for development and requires `loculus ^0.2.5` at runtime. No local archive or adjacent loculus checkout is needed.
63
+
64
+ This repository's first-package release procedure in CLAUDE.md applies to `@politty/loculus`.
65
+
66
+ The `dist-compat` CI suite bundles a complete CLI with each Rolldown object strategy and compares post-bundle execution, help, generated docs, completion and prompts against an unoptimized bundle on Linux and Windows.
package/bin/cli.mjs ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // Committed launcher: pnpm only links a bin whose target exists at install time.
3
+ import "../dist/cli.js";
@@ -0,0 +1,2 @@
1
+ import { i as detectAgent, n as DetectAgentOptions, r as KnownAgentId, t as AgentInfo } from "./detect-agent-EHaSY1KW.js";
2
+ export { type AgentInfo, type DetectAgentOptions, type KnownAgentId, detectAgent };
package/dist/agent.js ADDED
@@ -0,0 +1 @@
1
+ import{t as e}from"./detect-agent-D7KSeWMh.js";export{e as detectAgent};
@@ -0,0 +1 @@
1
+ import{i as e,o as t}from"./registry-BEz5iex_.js";const n=/* @__PURE__ */ new Set([`1`,`t`,`T`,`TRUE`,`true`,`True`]),r=/* @__PURE__ */ new Set([`0`,`f`,`F`,`FALSE`,`false`,`False`]);function i(e){return n.has(e)?!0:!r.has(e)&&e}function a(e,t){return t===`boolean`?i(e):e}function o(e){let t=e.indexOf(`=`);return t>=0?e.slice(2,t):e.slice(2)}function s(e,t){let n=o(e);if(!e.includes(`=`)){let e=t.negationMap.get(n);if(e&&t.booleanFlags.has(e))return{resolvedName:e,withoutDashes:n,isNegated:!0,isCustomNegation:!0,isSuppressedNegation:!1}}let r=e.includes(`=`);if(!r&&n.startsWith(`no-`)){let e=n.slice(3);if(e===e.toLowerCase()){let r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}}if(!r&&n.length>2&&n.startsWith(`no`)&&/[A-Z]/.test(n[2])){let e=n[2].toLowerCase()+n.slice(3),r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}return{resolvedName:t.aliasMap.get(n)??n,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!1}}const c=/^-\.?\d/;function l(e){return c.test(e)}function u(e,t={}){let{aliasMap:n=/* @__PURE__ */ new Map,booleanFlags:r=/* @__PURE__ */ new Set,arrayFlags:a=/* @__PURE__ */ new Set,definedNames:o=/* @__PURE__ */ new Set,negationMap:c=/* @__PURE__ */ new Map,defaultNegationDisabledFields:u}=t,d={aliasMap:n,booleanFlags:r,definedNames:o,negationMap:c,defaultNegationDisabledFields:u??new Set(r)},f={options:{},positionals:[],rest:[]},p=0,m=!1,h=(e,t)=>{let r=n.get(e)??e;if(a.has(r)){let e=f.options[r];Array.isArray(e)?e.push(t):e===void 0?f.options[r]=[t]:f.options[r]=[e,t]}else f.options[r]=t};for(;p<e.length;){let t=e[p];if(m){f.rest.push(t),p++;continue}if(t===`--`){m=!0,p++;continue}if(t.startsWith(`--`)){let a=t.slice(2),o=s(t,d);if(o.isSuppressedNegation){h(o.withoutDashes,!0),p++;continue}if(o.isNegated){h(o.resolvedName,!1),p++;continue}let c=a.indexOf(`=`);if(c!==-1){let e=a.slice(0,c),t=a.slice(c+1),o=n.get(e)??e;h(e,r.has(o)?i(t):t),p++}else{let t=a,i=n.get(t)??t;if(r.has(i))h(t,!0),p++;else{let n=e[p+1];n!==void 0&&(!n.startsWith(`-`)||l(n))?(h(t,n),p+=2):(h(t,!0),p++)}}continue}if(t.startsWith(`-`)&&t.length>1&&!t.startsWith(`--`)){let a=t.slice(1),o=a.indexOf(`=`);if(o!==-1){let e=a.slice(0,o),t=a.slice(o+1),s=n.get(e)??e;h(e,r.has(s)?i(t):t),p++}else if(a.length===1){let t=a,i=n.get(t)??t;if(r.has(i))h(t,!0),p++;else{let n=e[p+1];n!==void 0&&(!n.startsWith(`-`)||l(n))?(h(t,n),p+=2):(h(t,!0),p++)}}else{for(let e of a)h(e,!0);p++}continue}f.positionals.push(t),p++}return f}function d(n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Set;for(let e of n.fields)o.add(e.name);for(let l of n.fields){if(!l.named)continue;l.cliName!==l.name&&r.set(l.cliName,l.name);for(let n of e(l))if(r.set(n,l.name),n.length>1&&n.includes(`-`)){let e=t(n);e!==n&&!o.has(e)&&!r.has(e)&&r.set(e,l.name)}let n=t(l.name);if(n!==l.name&&!o.has(n)&&!r.has(n)&&r.set(n,l.name),l.type===`boolean`&&i.add(l.name),l.type===`array`&&a.add(l.name),l.type===`boolean`&&l.negation!==!0&&(c.add(l.name),typeof l.negation==`string`&&(s.set(l.negation,l.name),l.negation.includes(`-`)))){let e=t(l.negation);e!==l.negation&&s.set(e,l.name)}}return{aliasMap:r,booleanFlags:i,arrayFlags:a,definedNames:o,negationMap:s,defaultNegationDisabledFields:c}}function f(e,t){return e.fields.filter(e=>e.positional&&!(e.named&&Object.hasOwn(t,e.name)))}function p(e,t){let n={...e.options},r=t.fields.filter(e=>e.positional),i=e.rest.length>0?[...e.positionals,...e.rest]:e.positionals;for(let e of r)e.named||delete n[e.name];let a=0;for(let r of f(t,e.options)){if(a>=i.length)break;if(r.type===`array`){n[r.name]=i.slice(a);break}n[r.name]=i[a],a++}return n}export{o as a,a as c,f as i,p as n,s as o,u as r,i as s,d as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./cli-main-D4rJTFFd.js";export{e as runPolittyCli};
@@ -0,0 +1,2 @@
1
+ import{d as e,u as t}from"./schema-extractor-DFawzmtj.js";import{n}from"./command-BXsTrIgI.js";import{n as r}from"./runner-D-n1xa2K.js";import{chmodSync as i,existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{basename as l,dirname as u,extname as d,isAbsolute as f,join as p,relative as m,resolve as h}from"node:path";import{fileURLToPath as g}from"node:url";const _=`Generated by politty: compile-cache bin shim`,v=[`./cli.js`,`./cli.mjs`,`./index.js`,`./index.mjs`];function y(e){let t=h(e);for(;;){let e=p(t,`package.json`);if(a(e))return{pkg:JSON.parse(s(e,`utf8`)),dir:t};let n=u(t);if(n===t)return;t=n}}function b(e){if(!e)return[];if(typeof e.bin==`string`&&e.bin){let t=x(e);return t?[[t,e.bin]]:[]}return typeof e.bin==`object`&&e.bin!==null?Object.entries(e.bin).filter(e=>typeof e[1]==`string`&&e[1]!==``):[]}function x(e){if(e){if(typeof e.bin==`object`&&e.bin!==null){let[t]=Object.keys(e.bin);if(t)return t}if(typeof e.name==`string`&&e.name){let t=e.name;return t.startsWith(`@`)?t.split(`/`)[1]??t:t}}}function S(e){let t=u(e),n=l(e);for(let e of v)if(l(e)!==n&&a(p(t,e)))return e}function C(e,t,n){return[`#!/usr/bin/env node`,``,`// ${_}.`,`// Enables the Node.js on-disk compile cache (V8 code cache) before the`,`// CLI module graph is compiled, so warm starts skip recompilation`,`// (Node >= 22.8.0; silent no-op otherwise).`,`try {`,` const { enableCompileCache } = await import(${JSON.stringify(n)});`,` enableCompileCache(${JSON.stringify(e)});`,`} catch {`,` // ${n} is not resolvable from here (e.g. a fully`,` // bundled CLI) — start without the compile cache rather than failing`,` // the CLI.`,`}`,`await import(${JSON.stringify(t)});`,``].join(`
2
+ `)}function w(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function T(e){return(t={})=>E(`${e}/compile-cache`,t)}function E(e,t){let n=t.cwd??process.cwd(),r=y(n),l=r?.pkg,p=w(t.entry),m=w(t.out),T=b(l),E;if(m.length>0){if(p.length>0&&p.length!==m.length)throw Error(`--entry count (${p.length}) does not match --out count (${m.length}); pass one --out per --entry or omit --out entirely.`);E=m.map(e=>f(e)?e:h(n,e))}else{if(T.length===0||r===void 0)throw Error(`Cannot derive the output path: no bin entry in package.json. Pass --out explicitly.`);if(p.length>0&&p.length!==T.length)throw Error(`--entry count (${p.length}) does not match the package's bin entries (${T.length}); pass one --entry per bin (in declaration order) or matching --out paths.`);E=T.map(([,e])=>h(r.dir,e))}if(new Set(E).size!==E.length)throw Error(`Duplicate output paths; each shim needs a distinct output file. Check the --out values (or the bin paths in package.json when --out is omitted).`);let O=/* @__PURE__ */ new Map;if(r)for(let[e,t]of T)O.set(h(r.dir,t),e);let k=[],A=t.compileCacheSpecifier??e;if(/[\r\n\u2028\u2029]/.test(A))throw Error(`Invalid compile-cache specifier ${JSON.stringify(A)}: a module specifier cannot contain a line terminator.`);let j=E.map((e,r)=>{let i=O.get(e),o=t.program??i??x(l);if(!o)throw Error(`Cannot derive a program name: no bin or name in package.json. Pass --program explicitly.`);if(t.program===void 0&&i===void 0&&m.length>0&&k.push(`Warning: ${D(e,n)} does not match any bin path in package.json, so its cache directory uses the program name ${JSON.stringify(o)}. Pass --program to override.`),e.endsWith(`.cjs`))throw Error(`The generated shim is an ES module and cannot be written to a .cjs file. Use a .mjs (or .js in a "type": "module" package) output path.`);if(d(e)===``)throw Error(`The generated shim is an ES module and cannot be written to an extensionless file (it would not load on every supported Node.js version). Use a .mjs (or .js in a "type": "module" package) output path.`);if(e.endsWith(`.js`)&&l?.type!==`module`)throw Error(l===void 0?`The generated shim is an ES module, and no package.json was found to confirm .js files are treated as ESM. Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`:`The generated shim is an ES module, but the package is not "type": "module". Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`);let c=p[r]??S(e);if(c===void 0)throw Error(`Cannot derive an entry: none of ${v.join(`, `)} exist next to ${e}. Pass --entry explicitly.`);if(!c.startsWith(`./`)&&!c.startsWith(`../`)&&!c.startsWith(`file:`))throw Error(`Invalid entry ${c}: pass a specifier relative to the shim file ("./..." or "../...") or a file: URL.`);let f;if(c.startsWith(`file:`))try{f=g(c)}catch{f=void 0}else f=h(u(e),c);if(f===e)throw Error(`The shim at ${e} would import itself (entry ${c}). Point bin at a separate shim path (e.g. dist/bin.js) or pass a different --entry.`);if(a(e)&&!s(e,`utf8`).includes(_))throw Error(`Refusing to overwrite ${e}: it exists and was not generated by politty. If bin currently points at your real CLI entry, point it at a separate shim path (e.g. dist/bin.js) or pass --out explicitly.`);return{outputPath:e,program:o,entry:c,compileCacheSpecifier:A}});for(let e of k)console.warn(e);for(let{outputPath:e,program:t,entry:n}of j)o(u(e),{recursive:!0}),c(e,C(t,n,A)),i(e,493);return j}function D(e,t){let n=m(t,e);return n&&!n.startsWith(`..`)?n:e}const O=t({bin:e.string({description:`CLI binary or built JS entry file to invoke`,placeholder:`PATH`}),program:e.string({description:`Program name embedded in worker metadata`,placeholder:`NAME`}),shell:e.enum([`bash`,`zsh`,`fish`],{description:`Shell worker to generate`,placeholder:`SHELL`}),out:e.optionalString({description:`Output worker path (defaults to dist/completion/<shell>-worker.<ext>)`,placeholder:`PATH`}),verify:e.boolean({description:`Verify __completion-worker-path resolves to the generated worker`})}),k=n({name:`generate-worker`,description:`Generate and verify a bundled shell completion worker`,args:O,async run(e){let{generateBundledCompletionWorker:t}=await import(`./completion-BGidlN43.js`);await t({bin:e.bin,programName:e.program,shell:e.shell,...e.out!==void 0&&{outputPath:e.out},verify:e.verify})}}),A=t({entry:e.optionalStringArray({description:`Module specifier the shim imports, relative to the shim file; repeatable, one per bin/--out (defaults to ./cli.js, ./cli.mjs, ./index.js, or ./index.mjs next to each shim)`,placeholder:`SPECIFIER`}),out:e.optionalStringArray({description:`Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)`,placeholder:`PATH`}),program:e.optionalString({description:`Program name for the cache directory, applied to all shims (defaults per shim to its bin name)`,placeholder:`NAME`}),compileCacheSpecifier:e.optionalString({description:`Module specifier the shim imports enableCompileCache from (defaults to the compile-cache subpath of the politty package running this command)`,placeholder:`SPECIFIER`})});function j(e){let t=T(e),i=n({name:`generate-shim`,description:`Generate a compile-cache bin shim that loads the real CLI via dynamic import`,args:A,run(e){let n=process.cwd(),r=t({...e.entry!==void 0&&{entry:e.entry},...e.out!==void 0&&{out:e.out},...e.program!==void 0&&{program:e.program},...e.compileCacheSpecifier!==void 0&&{compileCacheSpecifier:e.compileCacheSpecifier},cwd:n});for(let e of r)console.log(`Generated compile-cache shim: ${D(e.outputPath,n)} (program: ${e.program}, entry: ${e.entry}, compile-cache: ${e.compileCacheSpecifier})`)}}),a=n({name:`politty`,description:`politty development utilities`,subCommands:{"generate-shim":i,"generate-worker":k}});return r(a).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)})}export{T as n,j as t};
@@ -0,0 +1 @@
1
+ import"./register-Ceh-HlVN.js";const{runPolittyCli:e}=await import(`./cli-main-CoQp6CjD.js`);await e(`@politty/loculus`);export{};
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{n as e}from"./compile-cache-6u9hgeWu.js";e(`politty`),await import(`./cli-run-DABESHM4.js`);export{};
@@ -0,0 +1 @@
1
+ function e(e){return{name:e.name,description:e.description,requiredPackages:e.requiredPackages,aliases:e.aliases,args:e.args,subCommands:e.subCommands,defaultSubCommand:e.defaultSubCommand,setup:e.setup,run:e.run,cleanup:e.cleanup,notes:e.notes,examples:e.examples}}function t(){return e}export{e as n,t};
@@ -0,0 +1 @@
1
+ import*as e from"node:module";import{join as t}from"node:path";import{homedir as n}from"node:os";function r(e){let t=e.replace(/^@/,``).replace(/[/\\]+/g,`-`).trim();if(t&&!/^[.-]+$/.test(t))return t}function i(e){let i=r(e);if(i===void 0)return;let a=process.env.XDG_CACHE_HOME;if(a)return t(a,i,`node-compile-cache`);try{let e=n();return e?t(e,`.cache`,i,`node-compile-cache`):void 0}catch{return}}function a(t){let n=typeof t==`string`?{programName:t}:t??{};try{let t=e.enableCompileCache;if(typeof t!=`function`)return{enabled:!1};let r;process.env.NODE_COMPILE_CACHE||(r=n.cacheDir??(n.programName===void 0?void 0:i(n.programName)));let a=r===void 0?t():t(r),o=e.constants?.compileCacheStatus;return{enabled:o===void 0?a.status===0||a.status===1:a.status===o.ENABLED||a.status===o.ALREADY_ENABLED,...a.directory!==void 0&&{directory:a.directory}}}catch{return{enabled:!1}}}export{a as n,i as t};
@@ -0,0 +1,80 @@
1
+ //#region ../core/src/compile-cache.d.ts
2
+ /**
3
+ * Node.js on-disk compile cache (V8 code cache) helpers.
4
+ *
5
+ * `node:module`'s `enableCompileCache` (Node.js >= 22.8.0) persists compiled
6
+ * bytecode to disk so warm starts skip recompilation. Because ESM static
7
+ * import graphs are compiled during the link phase — before any user code
8
+ * runs — enabling the cache inside `runMain` only covers modules imported
9
+ * *after* the call (e.g. `lazy()` subcommands). To cover the whole CLI,
10
+ * enable it from a minimal bin shim that dynamically imports the real entry:
11
+ *
12
+ * ```ts
13
+ * #!/usr/bin/env node
14
+ * // Import from the `compile-cache` subpath of the politty package your CLI
15
+ * // depends on — `politty generate-shim` writes that specifier for you,
16
+ * // naming whichever package's bin generated the shim.
17
+ * import { enableCompileCache } from "<your-politty-package>/compile-cache";
18
+ *
19
+ * enableCompileCache("my-cli");
20
+ * await import("./cli.js");
21
+ * ```
22
+ *
23
+ * This module must stay dependency-free (node builtins only) so the shim's
24
+ * static graph — the part that can never be cached — stays tiny.
25
+ */
26
+ /**
27
+ * Options for {@link enableCompileCache}.
28
+ */
29
+ export interface CompileCacheOptions {
30
+ /**
31
+ * Program name used to derive the default cache directory
32
+ * (`${XDG_CACHE_HOME:-$HOME/.cache}/<sanitized programName>/node-compile-cache`
33
+ * — see {@link compileCacheDir} for how the name is sanitized).
34
+ * Ignored when `cacheDir` is set.
35
+ */
36
+ programName?: string;
37
+ /** Explicit cache directory (takes precedence over `programName`). */
38
+ cacheDir?: string;
39
+ }
40
+ /**
41
+ * Result of {@link enableCompileCache}.
42
+ */
43
+ export interface CompileCacheResult {
44
+ /** Whether the compile cache is active for this process. */
45
+ enabled: boolean;
46
+ /** Directory the cache is (or was already) persisted to, when known. */
47
+ directory?: string;
48
+ }
49
+ /**
50
+ * Compute the cache directory for a program following the same XDG
51
+ * convention as the shell-completion dispatcher scripts
52
+ * (`src/completion/dispatcher.ts`), so direct CLI runs and completion
53
+ * workers share one warm cache:
54
+ * `${XDG_CACHE_HOME:-$HOME/.cache}/<sanitized programName>/node-compile-cache`.
55
+ * The program name is first reduced to a single safe path segment by
56
+ * {@link sanitizeProgramName} (e.g. `@scope/cli` → `scope-cli`). The
57
+ * dispatcher scripts use the raw name, but a completion program name is a
58
+ * single shell word resolved on PATH and can never contain separators, so
59
+ * for every name that can actually reach both sides the two paths coincide.
60
+ *
61
+ * Returns `undefined` when no home directory can be resolved or the program
62
+ * name does not reduce to a safe path segment; callers fall back to Node's
63
+ * default location (`NODE_COMPILE_CACHE` or the OS tmpdir).
64
+ */
65
+ export declare function compileCacheDir(programName: string): string | undefined;
66
+ /**
67
+ * Enable the Node.js on-disk compile cache for this process.
68
+ *
69
+ * - No-ops (returns `{ enabled: false }`) on runtimes without
70
+ * `module.enableCompileCache` (Node.js < 22.8.0) and never throws.
71
+ * - When the `NODE_COMPILE_CACHE` environment variable is set it always
72
+ * wins, keeping runs spawned by completion scripts (which set the same
73
+ * variable) consistent with direct runs.
74
+ * - Repeat calls are harmless: Node keeps the directory from the first
75
+ * successful call.
76
+ *
77
+ * @param options - Program name (string shorthand) or {@link CompileCacheOptions}.
78
+ */
79
+ export declare function enableCompileCache(options?: string | CompileCacheOptions): CompileCacheResult;
80
+ //#endregion
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./compile-cache-6u9hgeWu.js";export{t as compileCacheDir,e as enableCompileCache};
@@ -0,0 +1 @@
1
+ import"./with-completion-command-yg7HB6Zu.js";import"./dynamic-Hg5BDHzz.js";import{c as e,n as t,r as n,t as r}from"./completion-Cyw4RN-l.js";export{r as createCompletionCommand,t as createCompletionWorkerPathCommand,n as createRefreshCompletionCommand,e as generateBundledCompletionWorker};