@anarchitects/governance-cli 0.0.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.
- package/README.md +137 -0
- package/dist/agov.d.ts +71 -0
- package/dist/agov.d.ts.map +1 -0
- package/dist/bin/agov.d.ts +3 -0
- package/dist/bin/agov.d.ts.map +1 -0
- package/dist/bin/agov.js +792 -0
- package/dist/check-_APXAvpi.js +1568 -0
- package/dist/check.d.ts +21 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/internal/health-engine/calculate-health.d.ts +9 -0
- package/dist/internal/health-engine/calculate-health.d.ts.map +1 -0
- package/dist/internal/manual-workspace/capability.d.ts +10 -0
- package/dist/internal/manual-workspace/capability.d.ts.map +1 -0
- package/dist/internal/manual-workspace/load-workspace.d.ts +49 -0
- package/dist/internal/manual-workspace/load-workspace.d.ts.map +1 -0
- package/dist/internal/metric-engine/aggregate-signals.d.ts +18 -0
- package/dist/internal/metric-engine/aggregate-signals.d.ts.map +1 -0
- package/dist/internal/metric-engine/calculate-metrics.d.ts +7 -0
- package/dist/internal/metric-engine/calculate-metrics.d.ts.map +1 -0
- package/dist/internal/policy-engine/evaluate-policies.d.ts +3 -0
- package/dist/internal/policy-engine/evaluate-policies.d.ts.map +1 -0
- package/dist/internal/profile/load-standalone-profile.d.ts +24 -0
- package/dist/internal/profile/load-standalone-profile.d.ts.map +1 -0
- package/dist/internal/reporting/render-cli.d.ts +3 -0
- package/dist/internal/reporting/render-cli.d.ts.map +1 -0
- package/dist/internal/reporting/render-json.d.ts +3 -0
- package/dist/internal/reporting/render-json.d.ts.map +1 -0
- package/dist/internal/signal-engine/builders.d.ts +41 -0
- package/dist/internal/signal-engine/builders.d.ts.map +1 -0
- package/dist/internal/signal-engine/index.d.ts +3 -0
- package/dist/internal/signal-engine/index.d.ts.map +1 -0
- package/dist/internal/signal-engine/types.d.ts +2 -0
- package/dist/internal/signal-engine/types.d.ts.map +1 -0
- package/dist/render-report.d.ts +5 -0
- package/dist/render-report.d.ts.map +1 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# `@anarchitects/governance-cli`
|
|
2
|
+
|
|
3
|
+
Standalone Governance CLI and runtime host for running Governance checks outside Nx.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@anarchitects/governance-cli` provides the packaged `agov` executable and the programmatic host APIs for running Governance checks against canonical workspace documents or dynamically loaded adapters.
|
|
8
|
+
|
|
9
|
+
The package depends on `@anarchitects/governance-core` and stays adapter-agnostic. Concrete adapters are loaded by package name and validated against Core-owned contracts at runtime.
|
|
10
|
+
|
|
11
|
+
## Responsibilities
|
|
12
|
+
|
|
13
|
+
This package is responsible for:
|
|
14
|
+
|
|
15
|
+
- exposing the `agov` command surface
|
|
16
|
+
- parsing arguments and resolving option precedence
|
|
17
|
+
- loading config, profile, and canonical workspace inputs
|
|
18
|
+
- discovering generic adapter candidates from config or package metadata
|
|
19
|
+
- dynamically loading adapter packages and selecting them through Core-owned probe contracts
|
|
20
|
+
- rendering table, markdown, text, and JSON output
|
|
21
|
+
- mapping runtime outcomes to stable exit codes
|
|
22
|
+
|
|
23
|
+
This package is not responsible for:
|
|
24
|
+
|
|
25
|
+
- canonical Governance contracts
|
|
26
|
+
- concrete adapter implementations
|
|
27
|
+
- TypeScript-specific adapter detection heuristics
|
|
28
|
+
- Nx graph loading
|
|
29
|
+
- Nx plugin runtime behavior
|
|
30
|
+
- Nx executors or generators
|
|
31
|
+
|
|
32
|
+
## Public API
|
|
33
|
+
|
|
34
|
+
The public package surface is intentionally small:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import {
|
|
38
|
+
runAgovCheck,
|
|
39
|
+
type AgovCheckOptions,
|
|
40
|
+
type AgovCheckResult,
|
|
41
|
+
type AgovCheckWithAdapterOptions,
|
|
42
|
+
type AgovCheckWithWorkspacePathOptions,
|
|
43
|
+
} from '@anarchitects/governance-cli';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The root export currently includes:
|
|
47
|
+
|
|
48
|
+
- `runAgovCheck(...)`
|
|
49
|
+
- `AgovCheckOptions`
|
|
50
|
+
- `AgovCheckResult`
|
|
51
|
+
- `AgovCheckWithAdapterOptions`
|
|
52
|
+
- `AgovCheckWithWorkspacePathOptions`
|
|
53
|
+
|
|
54
|
+
The executable command parser and runtime host internals remain internal modules.
|
|
55
|
+
|
|
56
|
+
## Executable Usage
|
|
57
|
+
|
|
58
|
+
This package publishes an `agov` executable through `package.json#bin`.
|
|
59
|
+
|
|
60
|
+
Current command surface:
|
|
61
|
+
|
|
62
|
+
- `agov --help`
|
|
63
|
+
- `agov --version`
|
|
64
|
+
- `agov check`
|
|
65
|
+
- `agov check --workspace <path> --profile <path>`
|
|
66
|
+
- `agov check --adapter <package> --root <path> --profile <path>`
|
|
67
|
+
|
|
68
|
+
The CLI resolves values in this order:
|
|
69
|
+
|
|
70
|
+
- explicit flags
|
|
71
|
+
- config file
|
|
72
|
+
- conventional file discovery
|
|
73
|
+
- generic adapter candidate discovery and probe-based selection
|
|
74
|
+
- error with guidance
|
|
75
|
+
|
|
76
|
+
## Runtime Modes
|
|
77
|
+
|
|
78
|
+
The standalone host currently supports:
|
|
79
|
+
|
|
80
|
+
- canonical workspace documents in `.json`, `.yaml`, or `.yml`
|
|
81
|
+
- standalone profile documents in `.json`
|
|
82
|
+
- explicit adapter mode through `--adapter <package> --root <path>`
|
|
83
|
+
- generic adapter candidate discovery through config or package metadata
|
|
84
|
+
- output formats `table`, `markdown`, and `json`
|
|
85
|
+
- `text` as a compatibility alias for `table`
|
|
86
|
+
|
|
87
|
+
Example programmatic usage:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { runAgovCheck } from '@anarchitects/governance-cli';
|
|
91
|
+
|
|
92
|
+
const result = runAgovCheck({
|
|
93
|
+
workspacePath: './governance.workspace.json',
|
|
94
|
+
profilePath: './governance.profile.json',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
console.log(result.success);
|
|
98
|
+
console.log(result.assessment.health.status);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Adapter Model
|
|
102
|
+
|
|
103
|
+
`@anarchitects/governance-cli` is adapter-agnostic.
|
|
104
|
+
|
|
105
|
+
That means:
|
|
106
|
+
|
|
107
|
+
- the package depends on `@anarchitects/governance-core`, not on concrete adapter packages
|
|
108
|
+
- concrete adapters implement Core-owned contracts
|
|
109
|
+
- adapters may be injected, discovered, or dynamically loaded by package name
|
|
110
|
+
- future adapters must not require CLI package dependency changes
|
|
111
|
+
|
|
112
|
+
If you want to use a concrete adapter such as `@anarchitects/governance-adapter-typescript`, that adapter must be installed separately in the consuming workspace.
|
|
113
|
+
|
|
114
|
+
For detailed package-boundary rules and adapter-loading expectations, see
|
|
115
|
+
[ADR 0001: Governance Package Boundaries for Core, CLI, Adapters, and Extensions](../../../docs/adr/0001-governance-package-boundaries.md).
|
|
116
|
+
|
|
117
|
+
## Package Boundaries
|
|
118
|
+
|
|
119
|
+
`@anarchitects/governance-cli` is a standalone runtime host.
|
|
120
|
+
|
|
121
|
+
It should:
|
|
122
|
+
|
|
123
|
+
- orchestrate Core-owned contracts
|
|
124
|
+
- own command behavior, configuration, and output
|
|
125
|
+
- remain reusable outside Nx
|
|
126
|
+
|
|
127
|
+
It should not:
|
|
128
|
+
|
|
129
|
+
- become the home of canonical Governance contracts
|
|
130
|
+
- statically import concrete adapter packages
|
|
131
|
+
- own adapter-specific detection heuristics
|
|
132
|
+
- take on Nx-only responsibilities
|
|
133
|
+
|
|
134
|
+
## Related Packages
|
|
135
|
+
|
|
136
|
+
- `@anarchitects/governance-core` owns canonical Governance contracts and deterministic evaluation logic
|
|
137
|
+
- `@anarchitects/governance-adapter-typescript` is a sibling concrete adapter package for TypeScript workspace discovery
|
package/dist/agov.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Violation } from '@anarchitects/governance-core';
|
|
2
|
+
import { AgovCheckOptions, AgovCheckResult } from './check.js';
|
|
3
|
+
import { AgovOutputFormat } from './render-report.js';
|
|
4
|
+
export interface AgovCliIo {
|
|
5
|
+
stdout(message: string): void;
|
|
6
|
+
stderr(message: string): void;
|
|
7
|
+
}
|
|
8
|
+
export interface AgovCliEnvironment {
|
|
9
|
+
cwd(): string;
|
|
10
|
+
moduleLoader(specifier: string): Promise<unknown>;
|
|
11
|
+
packageVersion(): string;
|
|
12
|
+
}
|
|
13
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
14
|
+
export interface AgovCliRuntime {
|
|
15
|
+
runAgovCheck<TInput = unknown>(options: AgovCheckOptions<TInput>): MaybePromise<AgovCheckResult>;
|
|
16
|
+
}
|
|
17
|
+
export interface AgovCliConfig {
|
|
18
|
+
profile?: string;
|
|
19
|
+
adapter?: string;
|
|
20
|
+
adapters?: string[];
|
|
21
|
+
root?: string;
|
|
22
|
+
workspace?: string;
|
|
23
|
+
format?: string;
|
|
24
|
+
output?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ParsedAgovCheckOptions {
|
|
27
|
+
command: 'check';
|
|
28
|
+
configPath?: string;
|
|
29
|
+
profilePath?: string;
|
|
30
|
+
workspacePath?: string;
|
|
31
|
+
adapterPackage?: string;
|
|
32
|
+
rootPath?: string;
|
|
33
|
+
format?: AgovOutputFormat;
|
|
34
|
+
outputPath?: string;
|
|
35
|
+
showHelp: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface AgovResolvedCheckCommand {
|
|
38
|
+
command: 'check';
|
|
39
|
+
rootPath: string;
|
|
40
|
+
profilePath: string;
|
|
41
|
+
format: AgovOutputFormat;
|
|
42
|
+
outputPath?: string;
|
|
43
|
+
configPath?: string;
|
|
44
|
+
mode: 'workspace' | 'adapter' | 'adapter-discovery';
|
|
45
|
+
workspacePath?: string;
|
|
46
|
+
adapterPackage?: string;
|
|
47
|
+
adapterCandidates?: string[];
|
|
48
|
+
}
|
|
49
|
+
export declare const AGOV_EXIT_SUCCESS = 0;
|
|
50
|
+
export declare const AGOV_EXIT_GOVERNANCE_FAILURE = 1;
|
|
51
|
+
export declare const AGOV_EXIT_CONFIGURATION_FAILURE = 2;
|
|
52
|
+
export declare const AGOV_EXIT_RUNTIME_FAILURE = 3;
|
|
53
|
+
export declare class AgovCliUsageError extends Error {
|
|
54
|
+
readonly code: 'agov.cli.unknown_command' | 'agov.cli.unknown_option' | 'agov.cli.missing_option_value' | 'agov.cli.unsupported_format' | 'agov.cli.missing_profile' | 'agov.cli.missing_workspace_or_adapter' | 'agov.cli.ambiguous_workspace_and_adapter' | 'agov.cli.invalid_config' | 'agov.cli.invalid_json';
|
|
55
|
+
constructor(message: string, code: 'agov.cli.unknown_command' | 'agov.cli.unknown_option' | 'agov.cli.missing_option_value' | 'agov.cli.unsupported_format' | 'agov.cli.missing_profile' | 'agov.cli.missing_workspace_or_adapter' | 'agov.cli.ambiguous_workspace_and_adapter' | 'agov.cli.invalid_config' | 'agov.cli.invalid_json');
|
|
56
|
+
}
|
|
57
|
+
export declare class AgovCliOutputError extends Error {
|
|
58
|
+
readonly code: 'agov.cli.output_write_failed';
|
|
59
|
+
readonly filePath: string;
|
|
60
|
+
constructor(message: string, code: 'agov.cli.output_write_failed', filePath: string);
|
|
61
|
+
}
|
|
62
|
+
export declare class AgovCliRuntimeError extends Error {
|
|
63
|
+
readonly code: 'agov.cli.adapter_not_found' | 'agov.cli.adapter_contract_mismatch' | 'agov.cli.no_supported_adapter' | 'agov.cli.unhandled_error';
|
|
64
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
65
|
+
constructor(message: string, code: 'agov.cli.adapter_not_found' | 'agov.cli.adapter_contract_mismatch' | 'agov.cli.no_supported_adapter' | 'agov.cli.unhandled_error', details?: Record<string, unknown> | undefined);
|
|
66
|
+
}
|
|
67
|
+
export declare function runAgovCli(argv: string[], io?: AgovCliIo, runtime?: AgovCliRuntime, environment?: AgovCliEnvironment): Promise<number>;
|
|
68
|
+
export declare function resolveAgovCheckCommand(options: ParsedAgovCheckOptions, environment: Pick<AgovCliEnvironment, 'cwd'>): AgovResolvedCheckCommand;
|
|
69
|
+
export declare function compareViolationsForBlocking(violations: readonly Violation[]): boolean;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=agov.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agov.d.ts","sourceRoot":"","sources":["../src/agov.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAIV,SAAS,EACV,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,oBAAoB,CAAC;AAuB5B,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,IAAI,MAAM,CAAC;IACd,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,cAAc,IAAI,MAAM,CAAC;CAC1B;AAED,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,MAAM,GAAG,OAAO,EAC3B,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAChC,YAAY,CAAC,eAAe,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,M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