@animus-ui/cli 0.1.11 → 0.1.14

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.
@@ -0,0 +1,23 @@
1
+ /** Listeners run on the event loop, so a handler never lands inside the
2
+ * writer's synchronous swap; with none the kernel kills mid-publish. */
3
+ /** Signal exit conventions (128 + signal number). */
4
+ export declare const EXIT_SIGINT = 130;
5
+ export declare const EXIT_SIGTERM = 143;
6
+ /** `abandoned` means a second signal cut an unfinished drain short. */
7
+ export interface ShutdownOutcome {
8
+ exitCode: number;
9
+ signal: string;
10
+ abandoned: boolean;
11
+ }
12
+ export interface ShutdownHandlers {
13
+ /** Called once. An abandoned outcome must give up the SAME claims as a
14
+ * drained one, or `lock.json` outlives the process. */
15
+ release: (outcome: ShutdownOutcome) => void;
16
+ /** Bounded work that must finish before the claim is given up; a second
17
+ * signal during it abandons the drain and exits at once. */
18
+ drain?: (exitCode: number, signal: string) => Promise<void>;
19
+ }
20
+ /** Removal is mandatory on the normal path: `main()` is re-enterable in
21
+ * process, so a listener left behind accumulates one per call. */
22
+ export declare function installShutdownSignals({ release, drain, }: ShutdownHandlers): () => void;
23
+ //# sourceMappingURL=signals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAAA;yEACyE;AAEzE,qDAAqD;AACrD,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,YAAY,MAAM,CAAC;AAShC,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B;4DACwD;IACxD,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5C;iEAC6D;IAC7D,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED;mEACmE;AACnE,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,KAAK,GACN,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAmC/B"}
package/dist/watch.d.ts CHANGED
@@ -1,70 +1,21 @@
1
- /**
2
- * `animus watch` — the session's watcher loop as a long-lived foreground
3
- * process (openspec: standalone-extraction-cli, design D5 watch half).
4
- *
5
- * Contract:
6
- * - Readiness is an explicit observable event distinct from idle: ONE
7
- * structured stderr `watch ready` line after the first complete,
8
- * consistent publication (plus the session status artifact's additive
9
- * monotonic `ready` field, schema-bumped compatibly).
10
- * - Mid-run failures keep last-good output and report per-cycle on stderr;
11
- * every publication goes through the SAME deterministic CLI writer as
12
- * `animus build` (design D3) and the advisory lock is held for the
13
- * watch's lifetime.
14
- * - Watch-capability degradation is loud and names roots: a persistent
15
- * stderr warning per unwatched root at every publication, and
16
- * `--fail-on-degraded` for orchestrators that would rather die (exit 3).
17
- * - The process stays alive on purpose: the session watcher unrefs every
18
- * handle (it must never hold a plugin host's process open), so the CLI
19
- * holds its own ref'd keepalive. SIGINT exits 130, SIGTERM 143, both
20
- * releasing the lock and removing the session tree — a watch keeps its
21
- * session tree alive WHILE RUNNING (transform consumers may exist) and
22
- * removes it on clean shutdown, unlike build's publish-then-remove.
23
- *
24
- * COORDINATION: `external-source-watch-ingestion` owns watch-ingestion
25
- * semantics — this verb consumes `startTurbopackWatcher` and
26
- * `handleWatchUpdate` as-is (the per-cycle wrapper below only observes
27
- * cycle boundaries to drive publication policy; it forks no ingestion
28
- * behavior).
29
- */
30
1
  import type { ResolvedCliConfig } from './config';
31
2
  export interface WatchFlags {
32
- /** Exit (code 3) instead of running degraded when any root is unwatched. */
33
3
  failOnDegraded: boolean;
34
4
  }
35
5
  export interface DegradedRoot {
36
6
  root: string;
37
7
  reason: string;
38
8
  }
39
- /**
40
- * The degradation list for one publication — every root whose edits the
41
- * watch will NOT observe, with the reason. Sources:
42
- * - the project root itself when the platform watcher could not start
43
- * (recursive fs.watch unavailable / registration failed — the session
44
- * degrades to no-watch with a warning and returns no handle);
45
- * - external roots resolved through node_modules (documented unwatchable —
46
- * the orchestrator never registers them; its own guardrail-G2 comment on
47
- * `openExternalWatcher`'s early return);
48
- * - external roots whose watcher failed after registration (the session's
49
- * sticky `external-watch:` diagnostics, which carry the reason).
50
- */
9
+ export type ProjectWatchState = 'active' | 'unavailable' | 'already-watched';
51
10
  export declare function collectDegradedRoots(inputs: {
52
11
  projectRoot: string;
53
- projectWatchActive: boolean;
12
+ projectWatch: ProjectWatchState;
54
13
  externalWatchRoots: readonly string[];
55
14
  stickyDiagnostics: ReadonlyMap<string, string>;
56
15
  }): DegradedRoot[];
57
- /** One persistent stderr warning per unwatched root (design D5: loud,
58
- * names the root and the consequence, repeated at every publication —
59
- * never a one-shot). */
60
16
  export declare function formatDegradedRootLine(entry: DegradedRoot): string;
61
- /**
62
- * Run the watch loop. Resolves with the process exit code on shutdown
63
- * (130 SIGINT / 143 SIGTERM / 3 --fail-on-degraded trip). Startup
64
- * failures — preflight, first pipeline, first publication — THROW with
65
- * the same taxonomy as build: readiness is a contract (NS3), so a
66
- * supervisor either observes the ready event or observes a nonzero exit,
67
- * never a silent hang with no first publication.
68
- */
17
+ export declare function formatCyclePublishFailure<Thrown>(outDir: string, error: Thrown): string;
18
+ /** Resolves with the process exit code at shutdown. Startup failures throw,
19
+ * so a supervisor sees either `watch ready` or a nonzero exit, never a hang. */
69
20
  export declare function runWatch(config: ResolvedCliConfig, flags: WatchFlags): Promise<number>;
70
21
  //# sourceMappingURL=watch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAsBH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UA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AE,CA0BjB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAElE;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAC9C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,MAAM,CAKR;AAgBD;iFACiF;AACjF,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,MAAM,CAAC,CAwMjB"}
package/dist/writer.d.ts CHANGED
@@ -1,15 +1,5 @@
1
- /**
2
- * Deterministic fixed-path artifact writer (design D3): raw payload bytes —
3
- * no session envelope, no per-invocation identity — staged into a private
4
- * subdirectory, VERIFIED there, then renamed into place with `commit.json`
5
- * LAST carrying content hashes of every payload (asset files included), so
6
- * a reader holding only the record and the payload bytes can verify set
7
- * completeness and consistency — and a publication that cannot verify
8
- * never replaces the previous generation. A single-writer advisory lock
9
- * fails loud instead of last-writer-wins; the lock never outlives the
10
- * invocation, so repeated identical builds are byte-identical trees.
11
- */
12
- import type { SessionAsset } from '@animus-ui/extract/session';
1
+ import { AnimusConfigError } from '@animus-ui/extract/pipeline';
2
+ import type { CommitRecord, SessionAsset } from '@animus-ui/extract/session';
13
3
  export declare const STYLES_FILE = "styles.css";
14
4
  export declare const SYSTEM_PROPS_FILE = "system-props.js";
15
5
  export declare const MANIFEST_FILE = "manifest.json";
@@ -20,40 +10,33 @@ export interface ArtifactPayloads {
20
10
  stylesCss: string;
21
11
  systemPropsJs: string;
22
12
  manifestJson: string;
23
- /** The session's copied asset() files (`collectSessionAssets` output),
24
- * published under `assets/<name>` beside styles.css — the stylesheet's
13
+ /** Published under `assets/<name>` beside styles.css — the stylesheet's
25
14
  * relative urls dangle without them. */
26
15
  assets?: readonly SessionAsset[];
27
16
  }
28
- export interface CommitRecord {
29
- schema: 1;
30
- payloads: Record<string, {
31
- hash: string;
32
- }>;
33
- }
34
- /** Publication rejected by the pre-swap consistency check: the staged set
35
- * did not verify, and the previous generation was left untouched. */
17
+ /** Rejected by the pre-swap consistency check: the staged set did not
18
+ * verify, and the previous generation was left untouched. */
36
19
  export declare class PublishInconsistencyError extends Error {
37
20
  readonly failures: string[];
38
21
  constructor(failures: string[]);
39
22
  }
40
- /** Take the single-writer advisory lock, failing loud on a live holder.
41
- * Returns a release function. */
23
+ export declare class PublishSwapIncompleteError<Thrown> extends Error {
24
+ readonly outDir: string;
25
+ /** Names replaced before the failure, in swap order. */
26
+ readonly landed: readonly string[];
27
+ readonly failure: Thrown;
28
+ constructor(outDir: string,
29
+ /** Names replaced before the failure, in swap order. */
30
+ landed: readonly string[], failure: Thrown);
31
+ }
32
+ /** A refused claim on the output tree: another process owns it, or its lock
33
+ * cannot be proven dead. Extends `AnimusConfigError`, so it exits 2. */
34
+ export declare class AnimusLockConflictError extends AnimusConfigError {
35
+ constructor(message: string);
36
+ }
37
+ /** Take the single-writer advisory lock; a live holder is a hard failure. */
42
38
  export declare function acquireLock(outDir: string): () => void;
43
- /**
44
- * Publish the payload set. The set is STAGED into a private subdirectory,
45
- * verified there (recompute-and-compare, the same check
46
- * `verifyPublishedSet` runs), and only a verified set is renamed into
47
- * place: payloads first, asset files next, the commit record LAST. A set
48
- * that cannot verify throws `PublishInconsistencyError` with the previous
49
- * generation untouched — "keeping last-good artifacts" must be literally
50
- * true for the watch loop's rejection path. The record carries only
51
- * content-derived data (asset entries sorted by name) so the full tree is
52
- * byte-identical across identical-input runs.
53
- */
39
+ /** Staged, verified, then renamed into place with the commit record LAST. A
40
+ * set that cannot verify throws with the previous generation untouched. */
54
41
  export declare function publishArtifacts(outDir: string, payloads: ArtifactPayloads): CommitRecord;
55
- /** The documented consistency check — the session-shared implementation
56
- * (published-set.ts): recompute every payload hash raw-bytes and compare
57
- * against the commit record. Returns failure lines (empty = consistent). */
58
- export declare function verifyPublishedSet(outDir: string): string[];
59
42
  //# sourceMappingURL=writer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writer.d.ts","s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gBAAgB,GACzB,YAAY,CA8Ed"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.14",
4
4
  "description": "Standalone Animus extraction CLI — one-shot builds and artifact emission for any build system",
5
5
  "keywords": [
6
6
  "animus",
@@ -41,7 +41,7 @@
41
41
  "compile": "tsc --noEmit"
42
42
  },
43
43
  "dependencies": {
44
- "@animus-ui/extract": "0.1.11"
44
+ "@animus-ui/extract": "0.1.14"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=22.12.0"