@opensip-cli/config 0.1.0
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +31 -0
- package/dist/capability-preferences.d.ts +39 -0
- package/dist/capability-preferences.d.ts.map +1 -0
- package/dist/capability-preferences.js +61 -0
- package/dist/capability-preferences.js.map +1 -0
- package/dist/composer.d.ts +58 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +111 -0
- package/dist/composer.js.map +1 -0
- package/dist/declaration.d.ts +59 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +15 -0
- package/dist/declaration.js.map +1 -0
- package/dist/document/cli-config.d.ts +102 -0
- package/dist/document/cli-config.d.ts.map +1 -0
- package/dist/document/cli-config.js +150 -0
- package/dist/document/cli-config.js.map +1 -0
- package/dist/document/dashboard.d.ts +21 -0
- package/dist/document/dashboard.d.ts.map +1 -0
- package/dist/document/dashboard.js +21 -0
- package/dist/document/dashboard.js.map +1 -0
- package/dist/document/global-config.d.ts +101 -0
- package/dist/document/global-config.d.ts.map +1 -0
- package/dist/document/global-config.js +163 -0
- package/dist/document/global-config.js.map +1 -0
- package/dist/document/host-declarations.d.ts +44 -0
- package/dist/document/host-declarations.d.ts.map +1 -0
- package/dist/document/host-declarations.js +48 -0
- package/dist/document/host-declarations.js.map +1 -0
- package/dist/document/targeting.d.ts +151 -0
- package/dist/document/targeting.d.ts.map +1 -0
- package/dist/document/targeting.js +71 -0
- package/dist/document/targeting.js.map +1 -0
- package/dist/document/template.d.ts +43 -0
- package/dist/document/template.d.ts.map +1 -0
- package/dist/document/template.js +63 -0
- package/dist/document/template.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +23 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +25 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/namespace-claims.d.ts +29 -0
- package/dist/namespace-claims.d.ts.map +1 -0
- package/dist/namespace-claims.js +62 -0
- package/dist/namespace-claims.js.map +1 -0
- package/dist/precedence.d.ts +47 -0
- package/dist/precedence.d.ts.map +1 -0
- package/dist/precedence.js +103 -0
- package/dist/precedence.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* host-declarations — the document-level config blocks owned by the host
|
|
3
|
+
* (the config package itself), not by any Tool plugin.
|
|
4
|
+
*
|
|
5
|
+
* Each tool contributes a namespaced {@link ToolConfigDeclaration}
|
|
6
|
+
* (`fitness`/`graph`/`simulation`) that the composer strict-validates. The
|
|
7
|
+
* tool-agnostic blocks — `cli`, `dashboard`, `schemaVersion`, `plugins`, and
|
|
8
|
+
* (from Phase 1) `targets`/`globalExcludes`/`checkOverrides` — are owned by no
|
|
9
|
+
* tool. They are returned here as `ToolConfigDeclaration`s and composed BESIDE
|
|
10
|
+
* the tool declarations (the composer is namespace-agnostic), turning the
|
|
11
|
+
* previously-`.catchall`-tolerated top-level keys into claimed, strict
|
|
12
|
+
* namespaces (ADR-0023).
|
|
13
|
+
*
|
|
14
|
+
* `schemaVersion` is claimed as a permissive top-level `number` so the
|
|
15
|
+
* composed document does not reject it — but the version-COMPAT decision
|
|
16
|
+
* (`readConfigSchemaVersion` + `checkSchemaCompat`) stays in `core`, run in the
|
|
17
|
+
* pre-action gate BEFORE validation (ADR-0023 §Amendment).
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { cliConfigSchema } from './cli-config.js';
|
|
21
|
+
import { dashboardConfigSchema } from './dashboard.js';
|
|
22
|
+
import { checkOverridesSchema, createPluginsConfigSchema, globalExcludesSchema, targetsRecordSchema, } from './targeting.js';
|
|
23
|
+
/**
|
|
24
|
+
* The host's document-level declarations. Grows in Phase 1 (targeting).
|
|
25
|
+
*
|
|
26
|
+
* Returned as a fresh array per call (no shared mutable state); the
|
|
27
|
+
* composition root concatenates these with the per-tool declarations.
|
|
28
|
+
*/
|
|
29
|
+
export function hostConfigDeclarations(options = {}) {
|
|
30
|
+
return [
|
|
31
|
+
{ namespace: 'cli', schema: cliConfigSchema },
|
|
32
|
+
{ namespace: 'dashboard', schema: dashboardConfigSchema },
|
|
33
|
+
// Permissive: core owns version-compat; the schema only ensures a present
|
|
34
|
+
// value is a positive integer, never rejecting an absent one.
|
|
35
|
+
{ namespace: 'schemaVersion', schema: z.number().int().min(1) },
|
|
36
|
+
// Shared two-layer scope model — three top-level keys, registered
|
|
37
|
+
// separately so the composed document matches the existing YAML exactly (no
|
|
38
|
+
// `targeting:` wrapper key; no rename).
|
|
39
|
+
{ namespace: 'targets', schema: targetsRecordSchema },
|
|
40
|
+
{ namespace: 'globalExcludes', schema: globalExcludesSchema },
|
|
41
|
+
{ namespace: 'checkOverrides', schema: checkOverridesSchema },
|
|
42
|
+
{
|
|
43
|
+
namespace: 'plugins',
|
|
44
|
+
schema: createPluginsConfigSchema(options.pluginConfigKeys),
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=host-declarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-declarations.js","sourceRoot":"","sources":["../../src/document/host-declarations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,gBAAgB,CAAC;AAqBxB;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAwC,EAAE;IAE1C,OAAO;QACL,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE;QAC7C,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,qBAAqB,EAAE;QACzD,0EAA0E;QAC1E,8DAA8D;QAC9D,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAC/D,kEAAkE;QAClE,4EAA4E;QAC5E,wCAAwC;QACxC,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE;QACrD,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,EAAE;QAC7D,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,EAAE;QAC7D;YACE,SAAS,EAAE,SAAS;YACpB,MAAM,EAAE,yBAAyB,CAAC,OAAO,CAAC,gBAAgB,CAAC;SAC5D;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* targeting — the shared two-layer scope model: the `targets:`,
|
|
3
|
+
* `globalExcludes:`, and `checkOverrides:` document-level blocks of
|
|
4
|
+
* `opensip-cli.config.yml`.
|
|
5
|
+
*
|
|
6
|
+
* This is cross-tool config, not a fitness concern — a project shipping only
|
|
7
|
+
* `graph` resolves its scope through the same model. Relocated here from
|
|
8
|
+
* `@opensip-cli/fitness` under ADR-0023. The data/runtime boundary:
|
|
9
|
+
*
|
|
10
|
+
* - config owns the **document shape** — the types below and the Zod field
|
|
11
|
+
* schemas — so the composed whole-document validation can strict-check the
|
|
12
|
+
* three top-level blocks (the host declarations in {@link ./host-declarations}).
|
|
13
|
+
* - fitness keeps the **runtime** — its `TargetRegistry`, the registry build +
|
|
14
|
+
* the cross-validation that `checkOverrides` references known targets, and
|
|
15
|
+
* `resolveTargetFiles` (glob expansion). It builds those from the schemas
|
|
16
|
+
* here. Moving the registry down would invert the layer (config must not
|
|
17
|
+
* import a fitness runtime type).
|
|
18
|
+
*
|
|
19
|
+
* The `plugins:` block type lives here too (it rides on the loaded
|
|
20
|
+
* `TargetsConfig`). Config owns the document shape + Zod validation; the
|
|
21
|
+
* plugin-discovery runtime still lives with the generic capability loader and
|
|
22
|
+
* each owning tool.
|
|
23
|
+
*/
|
|
24
|
+
import { z } from 'zod';
|
|
25
|
+
/** Configuration for a named target (file set with include/exclude globs). */
|
|
26
|
+
export interface TargetConfig {
|
|
27
|
+
/** Kebab-case identifier, e.g. 'backend', 'module-foundation' */
|
|
28
|
+
readonly name: string;
|
|
29
|
+
/** Human-readable description */
|
|
30
|
+
readonly description: string;
|
|
31
|
+
/** Glob patterns to include */
|
|
32
|
+
readonly include: readonly string[];
|
|
33
|
+
/** Glob patterns to exclude */
|
|
34
|
+
readonly exclude: readonly string[];
|
|
35
|
+
/** Tags for filtering/grouping */
|
|
36
|
+
readonly tags?: readonly string[];
|
|
37
|
+
/** Languages this target contains (e.g. 'typescript', 'tsx', 'json') */
|
|
38
|
+
readonly languages?: readonly string[];
|
|
39
|
+
/** Semantic concerns this target represents (e.g. 'backend', 'server', 'api') */
|
|
40
|
+
readonly concerns?: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
/** A resolved target wrapping its configuration. */
|
|
43
|
+
export interface Target {
|
|
44
|
+
readonly config: TargetConfig;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Per-check target overrides.
|
|
48
|
+
* Maps check slug → target name(s) to restrict which files a check runs against.
|
|
49
|
+
*/
|
|
50
|
+
export type CheckTargetMap = Readonly<Record<string, string | readonly string[]>>;
|
|
51
|
+
/**
|
|
52
|
+
* Project-local plugin declarations — one list per plugin domain.
|
|
53
|
+
*
|
|
54
|
+
* When present in the config file, these override the default user-level
|
|
55
|
+
* plugin directory (`~/.opensip-cli/<domain>/`). Plugins get installed
|
|
56
|
+
* into `<project-root>/.opensip-cli/<domain>/` and are version-pinned
|
|
57
|
+
* by the project rather than by each developer's machine.
|
|
58
|
+
*
|
|
59
|
+
* Each entry is any npm install spec: `@scope/pkg`, `@scope/pkg@^1.2.3`,
|
|
60
|
+
* `./local-path`, `/abs/path/to/pkg.tgz`, `git+https://...`, etc.
|
|
61
|
+
*/
|
|
62
|
+
export interface PluginsConfig {
|
|
63
|
+
readonly fit?: readonly string[];
|
|
64
|
+
readonly sim?: readonly string[];
|
|
65
|
+
/**
|
|
66
|
+
* Explicit list of npm package names to load as check providers
|
|
67
|
+
* (e.g. ['@opensip-cli/checks-python', '@my-org/checks-internal']).
|
|
68
|
+
*
|
|
69
|
+
* Marker-based discovery still runs alongside this list; use this for
|
|
70
|
+
* packages that do not declare `opensipTools.kind: "fit-pack"` yet, or
|
|
71
|
+
* when you want to name a package explicitly in config.
|
|
72
|
+
*/
|
|
73
|
+
readonly checkPackages?: readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* Exact simulation scenario package names to load from project `node_modules`.
|
|
76
|
+
* When present, capability discovery treats the explicit set as the pinned
|
|
77
|
+
* scenario source.
|
|
78
|
+
*/
|
|
79
|
+
readonly scenarioPackages?: readonly string[];
|
|
80
|
+
/** Disable or enable simulation scenario name-pattern discovery. */
|
|
81
|
+
readonly autoDiscoverScenarios?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Additional npm scopes to include in simulation scenario-package
|
|
84
|
+
* auto-discovery, on top of the platform default (`@opensip-cli`).
|
|
85
|
+
*/
|
|
86
|
+
readonly packageScopes?: readonly string[];
|
|
87
|
+
/** Exact graph adapter package names to load from project `node_modules`. */
|
|
88
|
+
readonly graphAdapters?: readonly string[];
|
|
89
|
+
/** Disable or enable graph adapter marker discovery. */
|
|
90
|
+
readonly autoDiscoverGraphAdapters?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** The value shape expected for a capability discovery preference key. */
|
|
93
|
+
export type PluginConfigKeyKind = 'packages' | 'autoDiscover' | 'scopes';
|
|
94
|
+
/**
|
|
95
|
+
* One `plugins.<key>` declared by an admitted tool capability descriptor. The CLI
|
|
96
|
+
* maps manifest `capabilities[].discovery.configKeys` into this config-layer
|
|
97
|
+
* shape, keeping core manifest types out of `@opensip-cli/config`.
|
|
98
|
+
*/
|
|
99
|
+
export interface PluginConfigKeyDeclaration {
|
|
100
|
+
readonly key: string;
|
|
101
|
+
readonly kind: PluginConfigKeyKind;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Result of loading targets config, including both the target registry
|
|
105
|
+
* and per-check target overrides.
|
|
106
|
+
*/
|
|
107
|
+
export interface TargetsConfig {
|
|
108
|
+
/** Global file exclusion patterns (replaces .fitnessignore). */
|
|
109
|
+
readonly globalExcludes: readonly string[];
|
|
110
|
+
/** Per-check target overrides for third-party/marketplace checks. */
|
|
111
|
+
readonly checkOverrides: CheckTargetMap;
|
|
112
|
+
/**
|
|
113
|
+
* Project-local plugin declarations, keyed by domain. When any domain
|
|
114
|
+
* has entries here, plugin discovery for that domain reads from
|
|
115
|
+
* `<project>/.opensip-cli/<domain>/` instead of `~/.opensip-cli/<domain>/`.
|
|
116
|
+
*/
|
|
117
|
+
readonly plugins?: PluginsConfig;
|
|
118
|
+
}
|
|
119
|
+
/** One named target's definition (a `targets.<name>` entry). Non-strict to
|
|
120
|
+
* match the historical fitness loader (unknown keys are stripped, not rejected). */
|
|
121
|
+
export declare const targetDefinitionSchema: z.ZodObject<{
|
|
122
|
+
description: z.ZodString;
|
|
123
|
+
include: z.ZodArray<z.ZodString>;
|
|
124
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
125
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
+
languages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
|
+
concerns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
/** A `checkOverrides` value: a single target name or a non-empty list of them. */
|
|
130
|
+
export declare const checkTargetValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
131
|
+
/** The `targets:` block — a kebab-keyed record of target definitions. */
|
|
132
|
+
export declare const targetsRecordSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
133
|
+
description: z.ZodString;
|
|
134
|
+
include: z.ZodArray<z.ZodString>;
|
|
135
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
136
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
137
|
+
languages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
|
+
concerns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
/** The `globalExcludes:` block — a list of glob patterns. */
|
|
141
|
+
export declare const globalExcludesSchema: z.ZodArray<z.ZodString>;
|
|
142
|
+
/** The `checkOverrides:` block — slug → target name(s). */
|
|
143
|
+
export declare const checkOverridesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
144
|
+
/**
|
|
145
|
+
* Build the `plugins:` schema from the base project-local plugin domains plus
|
|
146
|
+
* the capability preference keys declared by admitted tool manifests.
|
|
147
|
+
*/
|
|
148
|
+
export declare function createPluginsConfigSchema(keys?: readonly PluginConfigKeyDeclaration[]): z.ZodObject<Record<string, z.ZodType>>;
|
|
149
|
+
/** Base schema used by legacy loaders that do not have manifest context. */
|
|
150
|
+
export declare const pluginsConfigSchema: z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strip>;
|
|
151
|
+
//# sourceMappingURL=targeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.d.ts","sourceRoot":"","sources":["../../src/document/targeting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;A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rides:` document-level blocks of
|
|
4
|
+
* `opensip-cli.config.yml`.
|
|
5
|
+
*
|
|
6
|
+
* This is cross-tool config, not a fitness concern — a project shipping only
|
|
7
|
+
* `graph` resolves its scope through the same model. Relocated here from
|
|
8
|
+
* `@opensip-cli/fitness` under ADR-0023. The data/runtime boundary:
|
|
9
|
+
*
|
|
10
|
+
* - config owns the **document shape** — the types below and the Zod field
|
|
11
|
+
* schemas — so the composed whole-document validation can strict-check the
|
|
12
|
+
* three top-level blocks (the host declarations in {@link ./host-declarations}).
|
|
13
|
+
* - fitness keeps the **runtime** — its `TargetRegistry`, the registry build +
|
|
14
|
+
* the cross-validation that `checkOverrides` references known targets, and
|
|
15
|
+
* `resolveTargetFiles` (glob expansion). It builds those from the schemas
|
|
16
|
+
* here. Moving the registry down would invert the layer (config must not
|
|
17
|
+
* import a fitness runtime type).
|
|
18
|
+
*
|
|
19
|
+
* The `plugins:` block type lives here too (it rides on the loaded
|
|
20
|
+
* `TargetsConfig`). Config owns the document shape + Zod validation; the
|
|
21
|
+
* plugin-discovery runtime still lives with the generic capability loader and
|
|
22
|
+
* each owning tool.
|
|
23
|
+
*/
|
|
24
|
+
import { z } from 'zod';
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// Field schemas (the document shape, in Zod) — single source for the loader,
|
|
27
|
+
// the signalers whole-doc schema, and the host declarations.
|
|
28
|
+
// =============================================================================
|
|
29
|
+
/** One named target's definition (a `targets.<name>` entry). Non-strict to
|
|
30
|
+
* match the historical fitness loader (unknown keys are stripped, not rejected). */
|
|
31
|
+
export const targetDefinitionSchema = z.object({
|
|
32
|
+
description: z.string().min(1, 'description is required'),
|
|
33
|
+
include: z.array(z.string()).min(1, 'at least one include pattern is required'),
|
|
34
|
+
exclude: z.array(z.string()).optional(),
|
|
35
|
+
tags: z.array(z.string()).optional(),
|
|
36
|
+
languages: z.array(z.string()).optional(),
|
|
37
|
+
concerns: z.array(z.string()).optional(),
|
|
38
|
+
});
|
|
39
|
+
/** A `checkOverrides` value: a single target name or a non-empty list of them. */
|
|
40
|
+
export const checkTargetValueSchema = z.union([z.string(), z.array(z.string()).min(1)]);
|
|
41
|
+
/** The `targets:` block — a kebab-keyed record of target definitions. */
|
|
42
|
+
export const targetsRecordSchema = z.record(z.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, 'target name must be kebab-case'), targetDefinitionSchema);
|
|
43
|
+
/** The `globalExcludes:` block — a list of glob patterns. */
|
|
44
|
+
export const globalExcludesSchema = z.array(z.string());
|
|
45
|
+
/** The `checkOverrides:` block — slug → target name(s). */
|
|
46
|
+
export const checkOverridesSchema = z.record(z.string(), checkTargetValueSchema);
|
|
47
|
+
const pluginStringArraySchema = z.array(z.string());
|
|
48
|
+
/**
|
|
49
|
+
* Build the `plugins:` schema from the base project-local plugin domains plus
|
|
50
|
+
* the capability preference keys declared by admitted tool manifests.
|
|
51
|
+
*/
|
|
52
|
+
export function createPluginsConfigSchema(keys = []) {
|
|
53
|
+
const shape = {
|
|
54
|
+
fit: pluginStringArraySchema.optional(),
|
|
55
|
+
sim: pluginStringArraySchema.optional(),
|
|
56
|
+
};
|
|
57
|
+
for (const { key, kind } of keys) {
|
|
58
|
+
shape[key] = (kind === 'autoDiscover' ? z.boolean() : pluginStringArraySchema).optional();
|
|
59
|
+
}
|
|
60
|
+
return z.object(shape).strict();
|
|
61
|
+
}
|
|
62
|
+
/** Base schema used by legacy loaders that do not have manifest context. */
|
|
63
|
+
export const pluginsConfigSchema = createPluginsConfigSchema([
|
|
64
|
+
{ key: 'checkPackages', kind: 'packages' },
|
|
65
|
+
{ key: 'scenarioPackages', kind: 'packages' },
|
|
66
|
+
{ key: 'autoDiscoverScenarios', kind: 'autoDiscover' },
|
|
67
|
+
{ key: 'packageScopes', kind: 'scopes' },
|
|
68
|
+
{ key: 'graphAdapters', kind: 'packages' },
|
|
69
|
+
{ key: 'autoDiscoverGraphAdapters', kind: 'autoDiscover' },
|
|
70
|
+
]);
|
|
71
|
+
//# sourceMappingURL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AI,EAAE,QAAQ,EAAE;IACxC,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE;IAC1C,EAAE,GAAG,EAAE,2BAA2B,EAAE,IAAI,EAAE,cAAc,EAAE;CAC3D,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* template — render the document-level skeleton of `opensip-cli.config.yml`
|
|
3
|
+
* that `opensip init` scaffolds.
|
|
4
|
+
*
|
|
5
|
+
* The config package owns the *document shape*, so it owns the rendering of the
|
|
6
|
+
* host-owned blocks — `schemaVersion`, `globalExcludes`, and `targets` — that it
|
|
7
|
+
* also validates (the host declarations in {@link ./host-declarations}). This
|
|
8
|
+
* removes the second, hand-written definition of the document shape that used to
|
|
9
|
+
* live in the CLI's init templates and could drift from what the composed schema
|
|
10
|
+
* accepts (ADR-0023).
|
|
11
|
+
*
|
|
12
|
+
* The CLI supplies the per-language target *content* (include/exclude globs) and
|
|
13
|
+
* appends the per-tool blocks (e.g. `fitness:`) — those are tool-owned and the
|
|
14
|
+
* CLI is the composition root that knows them. A round-trip test
|
|
15
|
+
* (`renderDocumentHeader` output parses clean through the composed schema)
|
|
16
|
+
* guarantees the skeleton never drifts from validation.
|
|
17
|
+
*/
|
|
18
|
+
/** One named target as the template should scaffold it. */
|
|
19
|
+
export interface TargetTemplateInput {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly description: string;
|
|
22
|
+
readonly languages: readonly string[];
|
|
23
|
+
readonly concerns?: readonly string[];
|
|
24
|
+
readonly include: readonly string[];
|
|
25
|
+
readonly exclude: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/** Inputs for the document-level skeleton. */
|
|
28
|
+
export interface DocumentHeaderInput {
|
|
29
|
+
/** The schema version to stamp (the CLI's supported version). */
|
|
30
|
+
readonly schemaVersion: number;
|
|
31
|
+
/** The named targets to scaffold (the CLI provides per-language content). */
|
|
32
|
+
readonly targets: readonly TargetTemplateInput[];
|
|
33
|
+
/** Global exclude globs; a sensible default set is used when omitted. */
|
|
34
|
+
readonly globalExcludes?: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Render the host-owned document skeleton: the header comment, `schemaVersion`,
|
|
38
|
+
* `globalExcludes`, and the `targets` block. The result is valid YAML that
|
|
39
|
+
* parses clean through the composed whole-document schema (the host
|
|
40
|
+
* declarations). The CLI appends tool blocks (e.g. `fitness:`) after this.
|
|
41
|
+
*/
|
|
42
|
+
export declare function renderDocumentHeader(input: DocumentHeaderInput): string;
|
|
43
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/document/template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACjD,yEAAyE;IACzE,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAoBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAqBvE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* template — render the document-level skeleton of `opensip-cli.config.yml`
|
|
3
|
+
* that `opensip init` scaffolds.
|
|
4
|
+
*
|
|
5
|
+
* The config package owns the *document shape*, so it owns the rendering of the
|
|
6
|
+
* host-owned blocks — `schemaVersion`, `globalExcludes`, and `targets` — that it
|
|
7
|
+
* also validates (the host declarations in {@link ./host-declarations}). This
|
|
8
|
+
* removes the second, hand-written definition of the document shape that used to
|
|
9
|
+
* live in the CLI's init templates and could drift from what the composed schema
|
|
10
|
+
* accepts (ADR-0023).
|
|
11
|
+
*
|
|
12
|
+
* The CLI supplies the per-language target *content* (include/exclude globs) and
|
|
13
|
+
* appends the per-tool blocks (e.g. `fitness:`) — those are tool-owned and the
|
|
14
|
+
* CLI is the composition root that knows them. A round-trip test
|
|
15
|
+
* (`renderDocumentHeader` output parses clean through the composed schema)
|
|
16
|
+
* guarantees the skeleton never drifts from validation.
|
|
17
|
+
*/
|
|
18
|
+
const DEFAULT_GLOBAL_EXCLUDES = ['**/node_modules/**', '**/dist/**'];
|
|
19
|
+
/** Render one target into the `targets:` block, matching `targetsRecordSchema`. */
|
|
20
|
+
function renderTarget(t) {
|
|
21
|
+
const concerns = t.concerns ?? ['backend'];
|
|
22
|
+
return [
|
|
23
|
+
` ${t.name}:`,
|
|
24
|
+
` description: ${t.description}`,
|
|
25
|
+
` languages: [${t.languages.join(', ')}]`,
|
|
26
|
+
` concerns: [${concerns.join(', ')}]`,
|
|
27
|
+
' include:',
|
|
28
|
+
...t.include.map((p) => ` - "${p}"`),
|
|
29
|
+
' exclude:',
|
|
30
|
+
...t.exclude.map((p) => ` - "${p}"`),
|
|
31
|
+
'',
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Render the host-owned document skeleton: the header comment, `schemaVersion`,
|
|
36
|
+
* `globalExcludes`, and the `targets` block. The result is valid YAML that
|
|
37
|
+
* parses clean through the composed whole-document schema (the host
|
|
38
|
+
* declarations). The CLI appends tool blocks (e.g. `fitness:`) after this.
|
|
39
|
+
*/
|
|
40
|
+
export function renderDocumentHeader(input) {
|
|
41
|
+
const globalExcludes = input.globalExcludes ?? DEFAULT_GLOBAL_EXCLUDES;
|
|
42
|
+
const lines = [
|
|
43
|
+
'# OpenSIP CLI — project configuration',
|
|
44
|
+
'#',
|
|
45
|
+
'# Defines named target file sets for fitness checks. Each fitness',
|
|
46
|
+
'# check declares a `scope` (languages + concerns); discovery',
|
|
47
|
+
'# matches it against these targets to determine which files the',
|
|
48
|
+
'# check runs against.',
|
|
49
|
+
'#',
|
|
50
|
+
'# Docs: https://github.com/opensip-ai/opensip-cli#configuration',
|
|
51
|
+
'',
|
|
52
|
+
`schemaVersion: ${input.schemaVersion}`,
|
|
53
|
+
'',
|
|
54
|
+
'globalExcludes:',
|
|
55
|
+
...globalExcludes.map((p) => ` - "${p}"`),
|
|
56
|
+
'',
|
|
57
|
+
'targets:',
|
|
58
|
+
];
|
|
59
|
+
for (const t of input.targets)
|
|
60
|
+
lines.push(...renderTarget(t));
|
|
61
|
+
return lines.join('\n');
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/document/template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAsBH,MAAM,uBAAuB,GAAsB,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;AAExF,mFAAmF;AACnF,SAAS,YAAY,CAAC,CAAsB;IAC1C,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3C,OAAO;QACL,KAAK,CAAC,CAAC,IAAI,GAAG;QACd,oBAAoB,CAAC,CAAC,WAAW,EAAE;QACnC,mBAAmB,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC5C,kBAAkB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACxC,cAAc;QACd,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC;QACzC,cAAc;QACd,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC;QACzC,EAAE;KACH,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA0B;IAC7D,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,IAAI,uBAAuB,CAAC;IACvE,MAAM,KAAK,GAAa;QACtB,uCAAuC;QACvC,GAAG;QACH,mEAAmE;QACnE,8DAA8D;QAC9D,iEAAiE;QACjE,uBAAuB;QACvB,GAAG;QACH,iEAAiE;QACjE,EAAE;QACF,kBAAkB,KAAK,CAAC,aAAa,EAAE;QACvC,EAAE;QACF,iBAAiB;QACjB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC1C,EAAE;QACF,UAAU;KACX,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @opensip-cli/config — the capability-configuration layer.
|
|
3
|
+
*
|
|
4
|
+
* Each tool contributes a {@link ToolConfigDeclaration}; the host composes the
|
|
5
|
+
* registered namespaced Zod schemas into one strict whole-document schema
|
|
6
|
+
* ({@link composeConfigSchema}), validates a raw document against it
|
|
7
|
+
* ({@link validateConfigDocument}), resolves precedence across flags / env /
|
|
8
|
+
* file / defaults ({@link resolveConfig}), and emits a JSON Schema for editors
|
|
9
|
+
* and docs ({@link toJsonSchema}).
|
|
10
|
+
*
|
|
11
|
+
* The barrel also re-exports the kernel's {@link ConfigurationError} — the
|
|
12
|
+
* error every config-resolution path in this layer throws on a malformed or
|
|
13
|
+
* contradictory configuration. Surfacing it from the config package's own
|
|
14
|
+
* barrel means consumers `catch` against the configuration layer they call,
|
|
15
|
+
* not the kernel underneath it. (This re-export also keeps a runtime import of
|
|
16
|
+
* @opensip-cli/core live in the barrel.)
|
|
17
|
+
*/
|
|
18
|
+
export { ConfigurationError } from '@opensip-cli/core';
|
|
19
|
+
export { composeConfigSchema, validateConfigDocument } from './composer.js';
|
|
20
|
+
export { analyzeNamespaceClaims } from './namespace-claims.js';
|
|
21
|
+
export type { NamespaceClaimReport, UnclaimedNamespace } from './namespace-claims.js';
|
|
22
|
+
export type { EnvBindingDeclaration, EnvBindingType, ToolConfigDeclaration, } from './declaration.js';
|
|
23
|
+
export { resolveConfig } from './precedence.js';
|
|
24
|
+
export type { ResolveConfigInput, ResolvedConfig } from './precedence.js';
|
|
25
|
+
export { resolveCapabilityPreferences } from './capability-preferences.js';
|
|
26
|
+
export type { CapabilityPreferences } from './capability-preferences.js';
|
|
27
|
+
export { toJsonSchema } from './json-schema.js';
|
|
28
|
+
export type { JsonSchema } from './json-schema.js';
|
|
29
|
+
export { loadCliDefaults, cliConfigSchema } from './document/cli-config.js';
|
|
30
|
+
export type { CliDefaults } from './document/cli-config.js';
|
|
31
|
+
export { dashboardConfigSchema } from './document/dashboard.js';
|
|
32
|
+
export { targetDefinitionSchema, checkTargetValueSchema, targetsRecordSchema, globalExcludesSchema, checkOverridesSchema, pluginsConfigSchema, createPluginsConfigSchema, } from './document/targeting.js';
|
|
33
|
+
export type { TargetConfig, Target, CheckTargetMap, PluginsConfig, PluginConfigKeyKind, PluginConfigKeyDeclaration, TargetsConfig, } from './document/targeting.js';
|
|
34
|
+
export { GLOBAL_CONFIG_PATH, readGlobalConfig, writeGlobalConfig, resolveApiKey, resolveEffectiveCloudConfig, CONFIG_ENV_SPECS, } from './document/global-config.js';
|
|
35
|
+
export type { GlobalConfig } from './document/global-config.js';
|
|
36
|
+
export { renderDocumentHeader } from './document/template.js';
|
|
37
|
+
export type { DocumentHeaderInput, TargetTemplateInput } from './document/template.js';
|
|
38
|
+
export { hostConfigDeclarations } from './document/host-declarations.js';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtF,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAK1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5E,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,YAAY,EACZ,MAAM,EACN,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @opensip-cli/config — the capability-configuration layer.
|
|
3
|
+
*
|
|
4
|
+
* Each tool contributes a {@link ToolConfigDeclaration}; the host composes the
|
|
5
|
+
* registered namespaced Zod schemas into one strict whole-document schema
|
|
6
|
+
* ({@link composeConfigSchema}), validates a raw document against it
|
|
7
|
+
* ({@link validateConfigDocument}), resolves precedence across flags / env /
|
|
8
|
+
* file / defaults ({@link resolveConfig}), and emits a JSON Schema for editors
|
|
9
|
+
* and docs ({@link toJsonSchema}).
|
|
10
|
+
*
|
|
11
|
+
* The barrel also re-exports the kernel's {@link ConfigurationError} — the
|
|
12
|
+
* error every config-resolution path in this layer throws on a malformed or
|
|
13
|
+
* contradictory configuration. Surfacing it from the config package's own
|
|
14
|
+
* barrel means consumers `catch` against the configuration layer they call,
|
|
15
|
+
* not the kernel underneath it. (This re-export also keeps a runtime import of
|
|
16
|
+
* @opensip-cli/core live in the barrel.)
|
|
17
|
+
*/
|
|
18
|
+
export { ConfigurationError } from '@opensip-cli/core';
|
|
19
|
+
export { composeConfigSchema, validateConfigDocument } from './composer.js';
|
|
20
|
+
// ADR-0043: the unclaimed-namespace claim report (pure; the CLI emits the
|
|
21
|
+
// warning / applies the loaded-tool rejection).
|
|
22
|
+
export { analyzeNamespaceClaims } from './namespace-claims.js';
|
|
23
|
+
export { resolveConfig } from './precedence.js';
|
|
24
|
+
// One descriptor-driven capability-preference resolver (§5.3, Phase 3): reads a
|
|
25
|
+
// domain's explicit-list / auto-discover / scopes from the project config through
|
|
26
|
+
// the keys its discovery descriptor declares — replacing the three bespoke
|
|
27
|
+
// per-tool readers with the documented keys unchanged.
|
|
28
|
+
export { resolveCapabilityPreferences } from './capability-preferences.js';
|
|
29
|
+
export { toJsonSchema } from './json-schema.js';
|
|
30
|
+
// Document-level config blocks (the tool-agnostic surface — ADR-0023).
|
|
31
|
+
export { loadCliDefaults, cliConfigSchema } from './document/cli-config.js';
|
|
32
|
+
export { dashboardConfigSchema } from './document/dashboard.js';
|
|
33
|
+
export { targetDefinitionSchema, checkTargetValueSchema, targetsRecordSchema, globalExcludesSchema, checkOverridesSchema, pluginsConfigSchema, createPluginsConfigSchema, } from './document/targeting.js';
|
|
34
|
+
export { GLOBAL_CONFIG_PATH, readGlobalConfig, writeGlobalConfig, resolveApiKey, resolveEffectiveCloudConfig, CONFIG_ENV_SPECS, } from './document/global-config.js';
|
|
35
|
+
export { renderDocumentHeader } from './document/template.js';
|
|
36
|
+
export { hostConfigDeclarations } from './document/host-declarations.js';
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5E,0EAA0E;AAC1E,gDAAgD;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAO/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,gFAAgF;AAChF,kFAAkF;AAClF,2EAA2E;AAC3E,uDAAuD;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,uEAAuE;AACvE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* json-schema — emit a JSON Schema for `opensip-cli.config.yml`.
|
|
3
|
+
*
|
|
4
|
+
* Editors and docs consume a JSON Schema for the whole document so an author
|
|
5
|
+
* gets completion + validation in their editor. The schema is generated from
|
|
6
|
+
* the composed Zod schema (see {@link ./composer}) — single source of truth, no
|
|
7
|
+
* hand-maintained mirror.
|
|
8
|
+
*
|
|
9
|
+
* zod 4 ships a built-in `z.toJSONSchema`, so no extra dependency is needed.
|
|
10
|
+
*/
|
|
11
|
+
import { type ZodType } from 'zod';
|
|
12
|
+
/** A JSON Schema document (object form). */
|
|
13
|
+
export type JsonSchema = Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Emit a JSON Schema for the composed config document.
|
|
16
|
+
*
|
|
17
|
+
* @param composed The whole-document schema returned by `composeConfigSchema`.
|
|
18
|
+
* @returns A JSON Schema object whose `properties` include each registered
|
|
19
|
+
* namespace. The document-level catchall renders
|
|
20
|
+
* as `additionalProperties`, so unclaimed top-level keys remain permitted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toJsonSchema(composed: ZodType): JsonSchema;
|
|
23
|
+
//# sourceMappingURL=json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,UAAU,CAI1D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* json-schema — emit a JSON Schema for `opensip-cli.config.yml`.
|
|
3
|
+
*
|
|
4
|
+
* Editors and docs consume a JSON Schema for the whole document so an author
|
|
5
|
+
* gets completion + validation in their editor. The schema is generated from
|
|
6
|
+
* the composed Zod schema (see {@link ./composer}) — single source of truth, no
|
|
7
|
+
* hand-maintained mirror.
|
|
8
|
+
*
|
|
9
|
+
* zod 4 ships a built-in `z.toJSONSchema`, so no extra dependency is needed.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
/**
|
|
13
|
+
* Emit a JSON Schema for the composed config document.
|
|
14
|
+
*
|
|
15
|
+
* @param composed The whole-document schema returned by `composeConfigSchema`.
|
|
16
|
+
* @returns A JSON Schema object whose `properties` include each registered
|
|
17
|
+
* namespace. The document-level catchall renders
|
|
18
|
+
* as `additionalProperties`, so unclaimed top-level keys remain permitted.
|
|
19
|
+
*/
|
|
20
|
+
export function toJsonSchema(composed) {
|
|
21
|
+
// `io: 'input'` so the schema describes the *authored* document (pre-default
|
|
22
|
+
// application), which is what an editor validates as the user types.
|
|
23
|
+
return z.toJSONSchema(composed, { io: 'input' });
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAgB,MAAM,KAAK,CAAC;AAKtC;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,QAAiB;IAC5C,6EAA6E;IAC7E,qEAAqE;IACrE,OAAO,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* namespace-claims — the ADR-0043 unclaimed-namespace report.
|
|
3
|
+
*
|
|
4
|
+
* The composer deliberately tolerates unclaimed top-level keys (the
|
|
5
|
+
* uninstalled-tool forward-compat contract, `composer.ts` rule 2) — but it
|
|
6
|
+
* tolerates them SILENTLY, which is the live typo hole: `fitnes:` validates
|
|
7
|
+
* cleanly and the user's config just never applies. This pure analyzer makes
|
|
8
|
+
* the tolerance observable: it names each unclaimed namespace and suggests
|
|
9
|
+
* the nearest claimed one when a typo is plausible. The CLI emits the warning
|
|
10
|
+
* (config stays log-free); rejection policy (a LOADED tool with an undeclared
|
|
11
|
+
* namespace) also lives at the caller, which knows the loaded-tool set.
|
|
12
|
+
*/
|
|
13
|
+
import type { ToolConfigDeclaration } from './declaration.js';
|
|
14
|
+
/** One unclaimed top-level namespace, with a did-you-mean when one is close. */
|
|
15
|
+
export interface UnclaimedNamespace {
|
|
16
|
+
readonly namespace: string;
|
|
17
|
+
/** The nearest claimed namespace within edit distance ≤ 2, when any. */
|
|
18
|
+
readonly suggestion?: string;
|
|
19
|
+
}
|
|
20
|
+
/** The ADR-0043 claim report for one validated document. */
|
|
21
|
+
export interface NamespaceClaimReport {
|
|
22
|
+
readonly unclaimed: readonly UnclaimedNamespace[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Report the document's top-level keys that no declaration claims. Pure: no
|
|
26
|
+
* IO, no logging — the caller decides warn-vs-reject per key (ADR-0043).
|
|
27
|
+
*/
|
|
28
|
+
export declare function analyzeNamespaceClaims(declarations: readonly ToolConfigDeclaration[], document: unknown): NamespaceClaimReport;
|
|
29
|
+
//# sourceMappingURL=namespace-claims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace-claims.d.ts","sourceRoot":"","sources":["../src/namespace-claims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACnD;AAyBD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,SAAS,qBAAqB,EAAE,EAC9C,QAAQ,EAAE,OAAO,GAChB,oBAAoB,CAoBtB"}
|