@animus-ui/cli 0.1.11

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/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @animus-ui/cli
2
+
3
+ Standalone Animus extraction CLI — one-shot builds and artifact emission
4
+ for any build system. `animus build` drives the same extraction session the
5
+ bundler plugins use and publishes a deterministic, fixed-path artifact set
6
+ for CI gates, non-JS orchestrators, and tooling.
7
+
8
+ If you are on a supported bundler, you want a transform driver instead:
9
+ [`@animus-ui/vite-plugin`](../vite-plugin),
10
+ [`@animus-ui/next-plugin`](../next-plugin), or
11
+ [`@animus-ui/unplugin`](../unplugin) (rollup/esbuild/rspack/webpack). The
12
+ CLI's artifacts do not transform your sources — see the
13
+ [standalone extraction contract](https://github.com/codecaaron/animus/blob/main/docs/standalone-extraction.md)
14
+ for why the transform is mandatory.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install --save-dev @animus-ui/cli
20
+ ```
21
+
22
+ Requires Node `>=22.12.0`. Native engine binaries ship for darwin-arm64,
23
+ linux-x64-gnu, and linux-arm64-gnu; the CLI exits 3 with remediation text
24
+ on unsupported platforms.
25
+
26
+ ## Usage
27
+
28
+ <!-- source lane: e2e/rollup-app/package.json `verify:build`; verified by running it in the lane (exit 0: "build complete: 10 components from 15 files") -->
29
+
30
+ ```bash
31
+ animus build --root . --system ./src/ds.ts --strict
32
+ animus watch --root . --system ./src/ds.ts
33
+ animus print-config --root . --system ./src/ds.ts
34
+ ```
35
+
36
+ Configuration lives in `animus.config.{json,mjs,js,ts}` (probed in that
37
+ order; `.ts` needs Node >= 23.6 native type stripping — older runtimes get
38
+ a guided error naming the `.mjs`/`.json` remedy). Flags override file
39
+ values; `--exclude` merges. `animus print-config` prints the fully resolved
40
+ configuration as JSON on stdout with per-key provenance.
41
+
42
+ Stream discipline is a contract: **stdout carries machine output only**;
43
+ every human-facing line goes to stderr.
44
+
45
+ ## Exit codes
46
+
47
+ | Code | Meaning |
48
+ | ---- | ----------------------------------------------------------------------------------------------- |
49
+ | 0 | Success — artifact set published and self-consistent |
50
+ | 1 | Extraction failure (error diagnostics, `--strict` escalation, zero files, structural emptiness) |
51
+ | 2 | Config/usage error (unknown key, unresolvable system path, lock conflict) |
52
+ | 3 | Engine/environment failure (native engine load, consistency-check failure) |
53
+
54
+ `animus watch` adds: 130 on SIGINT, 143 on SIGTERM (lock released,
55
+ last-good artifacts kept), and 3 under `--fail-on-degraded` when any root
56
+ cannot be watched. Watch readiness is an explicit stderr event: wait for
57
+ the `watch ready` line before starting dependent steps.
58
+
59
+ Silent-empty success is impossible: system-load failure, zero discovered
60
+ files, and structural emptiness are fatal in every mode.
61
+
62
+ ## Artifacts
63
+
64
+ `animus build` publishes to `--out-dir` (default `<root>/.animus/` —
65
+ `.gitignore` it) at fixed paths: `styles.css`, `system-props.js`,
66
+ `manifest.json`, and `commit.json` — written last, carrying a content hash
67
+ per payload, so one read verifies set completeness and freshness. Bytes are
68
+ deterministic and identity-free; `lock.json` is a single-writer advisory
69
+ lock that fails loud. The full contract, including the consistency-check
70
+ recipe for non-JS orchestrators, is in the
71
+ [standalone extraction contract](https://github.com/codecaaron/animus/blob/main/docs/standalone-extraction.md).
72
+
73
+ ## License
74
+
75
+ MIT
package/bin/animus.mjs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // Thin shebang shim — the built entry owns everything (arg parsing, exit
3
+ // codes, stream discipline). Kept as a plain file so the bin needs no
4
+ // build-time banner injection.
5
+ import('../dist/index.mjs').then((mod) => mod.main());
@@ -0,0 +1,62 @@
1
+ /**
2
+ * `animus build` — one-shot extraction over the SAME drive loop every
3
+ * driver uses (`ExtractionSession`; NS1/NS4: no second composition), then
4
+ * export of the raw payloads to the fixed-path deterministic artifact
5
+ * contract (design D3) via the CLI writer. The one-shot session tree is
6
+ * removed after export — no session-dir accumulation per CI run.
7
+ *
8
+ * Failure policy (design D5): silent-empty success is impossible —
9
+ * system-load failure, zero discovered files, and structural emptiness are
10
+ * fatal in EVERY mode, independent of `strict`.
11
+ *
12
+ * The preflight, session construction, and shared-state publication steps
13
+ * are exported helpers: `animus watch` (watch.ts) runs the same checks and
14
+ * the same writer path per publication instead of forking them.
15
+ */
16
+ import { ExtractionSession } from '@animus-ui/extract/session';
17
+ import type { ResolvedCliConfig } from './config';
18
+ /** Thrown for failures whose exit class is "extraction failure" (1). */
19
+ export declare class ExtractionFailure extends Error {
20
+ }
21
+ /** Thrown for failures whose exit class is "config/usage error" (2). */
22
+ export declare class UsageFailure extends Error {
23
+ }
24
+ /** Thrown for failures whose exit class is "engine/environment" (3). */
25
+ export declare class EnvironmentFailure extends Error {
26
+ }
27
+ /** The CLI's one stderr prefix convention (stdout stays machine-only) —
28
+ * shared with watch.ts. */
29
+ export declare const err: (...parts: unknown[]) => void;
30
+ export interface BuildResult {
31
+ outDir: string;
32
+ componentCount: number;
33
+ fileCount: number;
34
+ }
35
+ /** Preflight shared by build and watch: root and system-module existence
36
+ * are usage errors (exit 2) decided before any engine work; a missing
37
+ * platform binary is an environment failure (exit 3) surfaced with the
38
+ * loader's own remediation text. */
39
+ export declare function runPreflight(config: ResolvedCliConfig): Promise<void>;
40
+ /** The one CLI session shape: self-ingestion guard applied (an outDir
41
+ * inside the root is force-excluded from discovery, loudly), driver label
42
+ * and root authority set, tsconfig `paths` harvested as the alias source
43
+ * (no live bundler config exists for this driver). */
44
+ export declare function createCliSession(config: ResolvedCliConfig): ExtractionSession;
45
+ export interface PublishOutcome {
46
+ componentCount: number;
47
+ fileCount: number;
48
+ }
49
+ /**
50
+ * Publish the session's shared-state payloads through the deterministic
51
+ * CLI writer (design D3) — the SINGLE publication path for build and every
52
+ * watch cycle. Zero analyzed files, an unreadable manifest, and structural
53
+ * emptiness throw ExtractionFailure (silent-empty success is impossible);
54
+ * a post-publish consistency failure throws EnvironmentFailure.
55
+ */
56
+ export declare function publishSharedPayloads(config: ResolvedCliConfig, session: ExtractionSession): PublishOutcome;
57
+ /** Discovery-outcome report (stderr): per-specifier accounting plus
58
+ * dead-pattern visibility — a user exclusion that matched nothing is
59
+ * named instead of silently inert. */
60
+ export declare function reportDiscoveryOutcomes(config: ResolvedCliConfig, session: ExtractionSession): void;
61
+ export declare function runBuild(config: ResolvedCliConfig): Promise<BuildResult>;
62
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAEL,iBAAiB,EAMlB,MAAM,4BAA4B,CAAC;AAUpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,wEAAwE;AACxE,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAC/C,wEAAwE;AACxE,qBAAa,YAAa,SAAQ,KAAK;CAAG;AAC1C,wEAAwE;AACxE,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD;4BAC4B;AAC5B,eAAO,MAAM,GAAG,aAAc,OAAO,EAAE,KAAG,IACL,CAAC;AAEtC,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;qCAGqC;AACrC,wBAAsB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B3E;AAED;;;uDAGuD;AACvD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CA8B7E;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,iBAAiB,GACzB,cAAc,CAyEhB;AAED;;uCAEuC;AACvC,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,iBAAiB,GACzB,IAAI,CAgBN;AAED,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,WAAW,CAAC,CA6CtB"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * CLI config resolution — the third driver over the shared option core
3
+ * (shared-driver-config): documented precedence flags > config file >
4
+ * defaults, one root authority, explicit emission mode (the CLI never
5
+ * sniffs NODE_ENV), and a fully inspectable resolved projection for
6
+ * `--print-config`.
7
+ */
8
+ import type { AnimusCoreOptions, AnimusMode, OptionProvenance } from '@animus-ui/extract/pipeline';
9
+ /** Config filenames probed in order under the config-search root. */
10
+ export declare const CONFIG_FILENAMES: readonly ['animus.config.json', 'animus.config.mjs', 'animus.config.js', 'animus.config.ts'];
11
+ /** The `cli:` driver namespace of the shared config schema. */
12
+ export interface CliNamespaceOptions {
13
+ /** Artifact output directory, relative to the root. @default '.animus' */
14
+ outDir?: string;
15
+ }
16
+ export interface CliFlags {
17
+ system?: string;
18
+ root?: string;
19
+ config?: string;
20
+ outDir?: string;
21
+ strict?: boolean;
22
+ verbose?: boolean;
23
+ mode?: string;
24
+ targets?: string;
25
+ exclude?: string[];
26
+ }
27
+ export interface ResolvedCliConfig {
28
+ driver: 'cli';
29
+ /** Absolute root every relative input resolves against. */
30
+ root: string;
31
+ /** Absolute path of the config file consulted, or null. */
32
+ configFile: string | null;
33
+ /** The effective core options handed to the session. */
34
+ options: AnimusCoreOptions;
35
+ /** Absolute artifact output directory. */
36
+ outDir: string;
37
+ /** Effective merged exclusion pattern list (defaults ∪ user). */
38
+ excludePatterns: readonly string[];
39
+ mode: AnimusMode;
40
+ provenance: Record<string, OptionProvenance>;
41
+ }
42
+ /**
43
+ * Resolve the effective CLI configuration. Precedence: flags > config file
44
+ * > documented defaults. Scalar flags override; `--exclude` values merge
45
+ * (exclusion semantics are merge-only by contract).
46
+ */
47
+ export declare function resolveCliConfig(flags: CliFlags, cwd: string): Promise<ResolvedCliConfig>;
48
+ /** The `--print-config` projection: everything effective, nothing hidden. */
49
+ export declare function projectResolvedConfig(config: ResolvedCliConfig): Record<string, unknown>;
50
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,YAC3B,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CACV,CAAC;AAEX,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,CAAC;IACd,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wDAAwD;IACxD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C;AAsCD;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,QAAQ,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,iBAAiB,CAAC,CAqI5B;AAED,6EAA6E;AAC7E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,GACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBzB"}