@sous-io/sous 0.2.37 → 1.0.2
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 +14 -256
- package/dist/bin.js +11 -0
- package/dist/sous.js +1094 -0
- package/docs/markdown/README.md +5 -4
- package/docs/markdown/_sidebar.md +21 -1
- package/docs/markdown/commands.md +294 -431
- package/docs/markdown/config-discovery.md +25 -14
- package/docs/markdown/config-inspection.md +53 -31
- package/docs/markdown/config-layers.md +168 -66
- package/docs/markdown/config-variables.md +44 -11
- package/docs/markdown/configuration.md +104 -17
- package/docs/markdown/design-principles.md +4 -1
- package/docs/markdown/repositories-authoring.md +30 -0
- package/docs/markdown/repositories-consuming.md +72 -14
- package/docs/markdown/repositories-file-formats.md +31 -13
- package/docs/markdown/repositories-providers.md +48 -57
- package/docs/markdown/repositories-quickstart.md +3 -2
- package/docs/markdown/repositories-troubleshooting.md +27 -1
- package/docs/markdown/repositories-variables.md +6 -1
- package/docs/markdown/repositories.md +18 -8
- package/package.json +48 -107
- package/recipes/core/sous-skills/skills/about-liquid-templates/SKILL.tpl.md +4 -6
- package/recipes/core/sous-skills/skills/about-liquid-templates/references/liquid-filters.tpl.md +2 -0
- package/recipes/core/sous-skills/skills/about-sous/SKILL.tpl.md +10 -9
- package/recipes/core/sous-skills/skills/about-sous-configuration/SKILL.tpl.md +35 -14
- package/recipes/core/sous-skills/skills/about-sous-recipes/SKILL.tpl.md +51 -20
- package/recipes/core/sous-skills/sous.recipe.yaml +1 -1
- package/sous.config.schema.json +351 -132
- package/bin/run.js +0 -51
- package/src/base-command.ts +0 -457
- package/src/commands/build.ts +0 -181
- package/src/commands/clear.ts +0 -79
- package/src/commands/compile.ts +0 -155
- package/src/commands/config/get.ts +0 -110
- package/src/commands/config/show.ts +0 -32
- package/src/commands/config/validate.ts +0 -53
- package/src/commands/help.ts +0 -46
- package/src/commands/init.ts +0 -289
- package/src/commands/launch.ts +0 -139
- package/src/commands/lock/rebuild.ts +0 -239
- package/src/commands/lock/show.ts +0 -115
- package/src/commands/namespace/list.ts +0 -138
- package/src/commands/namespace/show.ts +0 -130
- package/src/commands/prune.ts +0 -43
- package/src/commands/recipe/list.ts +0 -112
- package/src/commands/recipe/show.ts +0 -439
- package/src/commands/repo/add.ts +0 -145
- package/src/commands/repo/contribute.ts +0 -604
- package/src/commands/repo/gc.ts +0 -173
- package/src/commands/repo/init.ts +0 -136
- package/src/commands/repo/link.ts +0 -899
- package/src/commands/repo/list.ts +0 -236
- package/src/commands/repo/release.ts +0 -685
- package/src/commands/repo/remove.ts +0 -194
- package/src/commands/repo/search.ts +0 -243
- package/src/commands/repo/submit.ts +0 -341
- package/src/commands/repo/unlink.ts +0 -461
- package/src/commands/subscription/add.ts +0 -286
- package/src/commands/subscription/list.ts +0 -208
- package/src/commands/subscription/remove.ts +0 -182
- package/src/commands/subscription/update.ts +0 -216
- package/src/commands/update.ts +0 -178
- package/src/commands/vars/ask.ts +0 -417
- package/src/commands/vars/index.ts +0 -79
- package/src/commands/vars/list.ts +0 -67
- package/src/commands/vars/show.ts +0 -77
- package/src/config-command.ts +0 -30
- package/src/lib/build-preparation.ts +0 -128
- package/src/lib/build-service.ts +0 -580
- package/src/lib/config-discovery.ts +0 -378
- package/src/lib/config-inspect.ts +0 -145
- package/src/lib/config-kernel.mjs +0 -379
- package/src/lib/config-schema.ts +0 -401
- package/src/lib/env-file.ts +0 -328
- package/src/lib/env-local.ts +0 -212
- package/src/lib/errors.ts +0 -32
- package/src/lib/glob-pattern.ts +0 -24
- package/src/lib/include-resolver.ts +0 -523
- package/src/lib/interactive.ts +0 -165
- package/src/lib/markdown-compiler.ts +0 -947
- package/src/lib/package-info.ts +0 -25
- package/src/lib/pid-service.ts +0 -99
- package/src/lib/project-install.d.mts +0 -44
- package/src/lib/project-install.mjs +0 -234
- package/src/lib/project-scaffold/index.ts +0 -332
- package/src/lib/project-scaffold/templates.ts +0 -240
- package/src/lib/repos/catalog-display.ts +0 -215
- package/src/lib/repos/catalog-inputs.ts +0 -288
- package/src/lib/repos/catalog.ts +0 -842
- package/src/lib/repos/contribute.ts +0 -452
- package/src/lib/repos/core-recipe.ts +0 -105
- package/src/lib/repos/declarations.ts +0 -187
- package/src/lib/repos/defaults.ts +0 -175
- package/src/lib/repos/formats/common.ts +0 -440
- package/src/lib/repos/formats/index-file.ts +0 -253
- package/src/lib/repos/formats/links-map.ts +0 -98
- package/src/lib/repos/formats/lockfile.ts +0 -169
- package/src/lib/repos/formats/patterns.ts +0 -57
- package/src/lib/repos/formats/recipe-manifest.ts +0 -205
- package/src/lib/repos/formats/repo-manifest.ts +0 -97
- package/src/lib/repos/formats/store-entry.ts +0 -84
- package/src/lib/repos/formats/variable-definition.ts +0 -268
- package/src/lib/repos/freshness.ts +0 -264
- package/src/lib/repos/git-clone.ts +0 -850
- package/src/lib/repos/identity.ts +0 -89
- package/src/lib/repos/index.ts +0 -57
- package/src/lib/repos/links.ts +0 -356
- package/src/lib/repos/load-manifest.ts +0 -237
- package/src/lib/repos/lock-service.ts +0 -454
- package/src/lib/repos/locked-namespace-resolver.ts +0 -232
- package/src/lib/repos/locked-recipe-lookup.ts +0 -123
- package/src/lib/repos/locked-recipes.ts +0 -254
- package/src/lib/repos/managed-layer.ts +0 -422
- package/src/lib/repos/memories-hash-name.ts +0 -33
- package/src/lib/repos/namespace-resolver.ts +0 -527
- package/src/lib/repos/providers/base.ts +0 -268
- package/src/lib/repos/providers/git.ts +0 -245
- package/src/lib/repos/providers/github.ts +0 -589
- package/src/lib/repos/providers/gitlab.ts +0 -332
- package/src/lib/repos/providers/http.ts +0 -128
- package/src/lib/repos/providers/index-cache.ts +0 -421
- package/src/lib/repos/providers/index.ts +0 -106
- package/src/lib/repos/providers/local.ts +0 -410
- package/src/lib/repos/providers/provider.ts +0 -615
- package/src/lib/repos/recipe-config-layers.ts +0 -316
- package/src/lib/repos/recipe-key-matcher.ts +0 -62
- package/src/lib/repos/recipe-memories.ts +0 -178
- package/src/lib/repos/recipe-targets.ts +0 -236
- package/src/lib/repos/ref-search.ts +0 -46
- package/src/lib/repos/release/bump.ts +0 -161
- package/src/lib/repos/release/changelog.ts +0 -461
- package/src/lib/repos/release/git-state.ts +0 -460
- package/src/lib/repos/release/index-builder.ts +0 -1108
- package/src/lib/repos/release/index.ts +0 -19
- package/src/lib/repos/release/plan.ts +0 -521
- package/src/lib/repos/release/settle.ts +0 -154
- package/src/lib/repos/release/submissions.ts +0 -214
- package/src/lib/repos/release/submit-checkout.ts +0 -290
- package/src/lib/repos/release/submit-questions.ts +0 -153
- package/src/lib/repos/release/submit-service.ts +0 -898
- package/src/lib/repos/release/tags.ts +0 -239
- package/src/lib/repos/release/validate.ts +0 -463
- package/src/lib/repos/resolver.ts +0 -1028
- package/src/lib/repos/scaffold/index.ts +0 -245
- package/src/lib/repos/scaffold/templates.ts +0 -517
- package/src/lib/repos/seed.ts +0 -473
- package/src/lib/repos/store/contract.ts +0 -64
- package/src/lib/repos/store/hash.ts +0 -191
- package/src/lib/repos/store/recipe-store.ts +0 -599
- package/src/lib/repos/store/settings.ts +0 -58
- package/src/lib/repos/subscription-service.ts +0 -3859
- package/src/lib/repos/trust.ts +0 -447
- package/src/lib/repos/update-plan.ts +0 -235
- package/src/lib/self-update/index.ts +0 -14
- package/src/lib/self-update/installs.ts +0 -413
- package/src/lib/self-update/managers.ts +0 -126
- package/src/lib/self-update/plan.ts +0 -315
- package/src/lib/self-update/registry.ts +0 -99
- package/src/lib/self-update/run.ts +0 -506
- package/src/lib/self-update/versions.ts +0 -243
- package/src/lib/settings.ts +0 -1107
- package/src/lib/sous-home.ts +0 -104
- package/src/lib/state.ts +0 -167
- package/src/lib/vars/answers.ts +0 -192
- package/src/lib/vars/ask.ts +0 -1152
- package/src/lib/vars/definition-source.ts +0 -261
- package/src/lib/vars/display.ts +0 -231
- package/src/lib/vars/index.ts +0 -20
- package/src/lib/vars/ladder.ts +0 -282
- package/src/lib/vars/mappings.ts +0 -260
- package/src/lib/vars/names.ts +0 -94
- package/src/lib/vars/preanswers.ts +0 -395
- package/src/lib/vars/question-plan.ts +0 -241
- package/src/lib/vars/report.ts +0 -228
- package/src/lib/vars/safe-regex.ts +0 -235
- package/src/lib/vars/secrets.ts +0 -131
- package/src/lib/vars/validate.ts +0 -312
- package/src/lib/version-report.ts +0 -90
- package/src/lib/watch-loop.ts +0 -148
- package/src/lib/watch-service.ts +0 -116
- package/src/services/ref-resolver/container.ts +0 -107
- package/src/services/ref-resolver/dependency.ts +0 -60
- package/src/services/ref-resolver/format.ts +0 -197
- package/src/services/ref-resolver/glob.ts +0 -115
- package/src/services/ref-resolver/hash-names.ts +0 -155
- package/src/services/ref-resolver/index.ts +0 -55
- package/src/services/ref-resolver/injectable.ts +0 -36
- package/src/services/ref-resolver/location.ts +0 -62
- package/src/services/ref-resolver/lookups/cached-index-lookup.ts +0 -53
- package/src/services/ref-resolver/lookups/catalog-lookup.ts +0 -23
- package/src/services/ref-resolver/lookups/catalog-matcher.ts +0 -261
- package/src/services/ref-resolver/lookups/chained-lookup.ts +0 -27
- package/src/services/ref-resolver/lookups/env-var-lookup.ts +0 -65
- package/src/services/ref-resolver/lookups/fetched-index-lookup.ts +0 -150
- package/src/services/ref-resolver/lookups/recorded-dependency-lookup.ts +0 -62
- package/src/services/ref-resolver/lookups/ref-lookup.ts +0 -54
- package/src/services/ref-resolver/lookups/variable-lookup.ts +0 -123
- package/src/services/ref-resolver/named-refs.ts +0 -144
- package/src/services/ref-resolver/parser/env-var-splitter.ts +0 -27
- package/src/services/ref-resolver/parser/location-splitter.ts +0 -239
- package/src/services/ref-resolver/parser/name-path-splitter.ts +0 -200
- package/src/services/ref-resolver/parser/partial-ref.ts +0 -84
- package/src/services/ref-resolver/parser/query-splitter.ts +0 -61
- package/src/services/ref-resolver/parser/range-splitter.ts +0 -52
- package/src/services/ref-resolver/parser/ref-parser.ts +0 -115
- package/src/services/ref-resolver/parser/repo-qualifier-splitter.ts +0 -51
- package/src/services/ref-resolver/parts.ts +0 -115
- package/src/services/ref-resolver/pruners/command-line-pruner.ts +0 -47
- package/src/services/ref-resolver/pruners/include-pruner.ts +0 -66
- package/src/services/ref-resolver/pruners/manifest-pruner.ts +0 -130
- package/src/services/ref-resolver/pruners/ref-pruner.ts +0 -135
- package/src/services/ref-resolver/pruners/rule-helpers.ts +0 -44
- package/src/services/ref-resolver/pruners/stored-key-pruner.ts +0 -136
- package/src/services/ref-resolver/ref-helpers.ts +0 -62
- package/src/services/ref-resolver/ref-picker-service.ts +0 -204
- package/src/services/ref-resolver/ref-report.ts +0 -84
- package/src/services/ref-resolver/ref-resolve-arguments.ts +0 -47
- package/src/services/ref-resolver/ref-resolve-result.ts +0 -36
- package/src/services/ref-resolver/ref-resolver-service.ts +0 -323
- package/src/services/ref-resolver/source.ts +0 -48
- package/src/services/ref-resolver/tokens.ts +0 -25
- package/src/services/ref-resolver/types.ts +0 -155
- package/src/templating/filters/bullet-list.ts +0 -9
- package/src/templating/filters/index.ts +0 -8
- package/src/templating/init-liquid-engine.ts +0 -139
- package/src/templating/lib/glob-files.ts +0 -74
- package/src/templating/lib/import-export.ts +0 -32
- package/src/templating/lib/secret-scope.ts +0 -41
- package/src/templating/lib/tag-args.ts +0 -19
- package/src/templating/tags/exportScalarVarsJs.ts +0 -46
- package/src/templating/tags/getFiles.ts +0 -89
- package/src/templating/tags/index.ts +0 -14
- package/src/templating/tags/listFiles.ts +0 -54
- package/src/templating/tags/showVars.ts +0 -28
- package/src/utils/choice-prompt.ts +0 -143
- package/src/utils/command-errors.ts +0 -186
- package/src/utils/command-help.ts +0 -45
- package/src/utils/confirm-prompt.ts +0 -110
- package/src/utils/flags.ts +0 -177
- package/src/utils/formatting.ts +0 -849
- package/src/utils/prompts.ts +0 -53
- package/src/utils/sous-directory.ts +0 -245
- package/src/utils/table.ts +0 -603
- package/src/utils/value-prompt.ts +0 -119
package/src/lib/config-schema.ts
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod schema for a merged sous config.
|
|
3
|
-
*
|
|
4
|
-
* This mirrors the hand-written `Settings` / `RawProjectCompilation` /
|
|
5
|
-
* `RawTarget` / `RawOutput` / `RawRuntimeContext` / `ToolConfig` types in
|
|
6
|
-
* settings.ts — those remain the exported TypeScript types; this schema is the
|
|
7
|
-
* RUNTIME validator. Keep the two in sync: when a config field changes in
|
|
8
|
-
* settings.ts, change it here too.
|
|
9
|
-
*
|
|
10
|
-
* Every object level is STRICT (unknown keys are rejected), so a typo like
|
|
11
|
-
* `compilaton` is caught the moment the merged config is loaded rather than
|
|
12
|
-
* silently ignored. Validation runs on the MERGED config only (in
|
|
13
|
-
* loadSettingsWithLayers, after the kernel merges every conf.d layer and after
|
|
14
|
-
* assertFlatConfig); a single conf.d fragment need not be a complete config.
|
|
15
|
-
*
|
|
16
|
-
* The schema also drives `npm run schema:build`, which emits the committed
|
|
17
|
-
* `sous.config.schema.json` artifact via `z.toJSONSchema`.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { z } from "zod";
|
|
21
|
-
import { ConfigError } from "./errors.js";
|
|
22
|
-
import { compileRecipeKeyMatcher } from "./repos/recipe-key-matcher.js";
|
|
23
|
-
import { repoUrlSchema, semverRangeSchema } from "./repos/formats/common.js";
|
|
24
|
-
import { REF_KEY_PATTERN, REPO_NAME_PATTERN } from "./repos/formats/patterns.js";
|
|
25
|
-
import type { Settings } from "./settings.js";
|
|
26
|
-
|
|
27
|
-
/** The only config version this sous understands. */
|
|
28
|
-
export const SUPPORTED_CONFIG_VERSION = 1;
|
|
29
|
-
|
|
30
|
-
/** A record of string → string (used for _env and every _vars block). */
|
|
31
|
-
const stringRecord = z.record(z.string(), z.string());
|
|
32
|
-
|
|
33
|
-
const outputSchema = z
|
|
34
|
-
.object({
|
|
35
|
-
_if: z.record(z.string(), z.object({ eq: z.string() }).strict()).optional(),
|
|
36
|
-
_vars: stringRecord.optional(),
|
|
37
|
-
destinationFile: z.string().optional(),
|
|
38
|
-
destinationDir: z.string().optional(),
|
|
39
|
-
})
|
|
40
|
-
.strict();
|
|
41
|
-
|
|
42
|
-
const runtimeContextSchema = z
|
|
43
|
-
.object({
|
|
44
|
-
gitRoot: z.string(),
|
|
45
|
-
outputPath: z.string(),
|
|
46
|
-
taskFileRoot: z.string(),
|
|
47
|
-
branchPattern: z.string().optional(),
|
|
48
|
-
})
|
|
49
|
-
.strict();
|
|
50
|
-
|
|
51
|
-
const targetSchema = z
|
|
52
|
-
.object({
|
|
53
|
-
_vars: stringRecord.optional(),
|
|
54
|
-
entryPoint: z.string().optional(),
|
|
55
|
-
entryGlob: z.string().optional(),
|
|
56
|
-
globBase: z.string().optional(),
|
|
57
|
-
generateRuntimeContext: z.boolean().optional(),
|
|
58
|
-
outputs: z.array(outputSchema),
|
|
59
|
-
})
|
|
60
|
-
.strict()
|
|
61
|
-
.refine((t) => (t.entryPoint !== undefined) !== (t.entryGlob !== undefined), {
|
|
62
|
-
message: "a target must have exactly one of 'entryPoint' or 'entryGlob'",
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const compilationSchema = z
|
|
66
|
-
.object({
|
|
67
|
-
_vars: stringRecord.optional(),
|
|
68
|
-
includeSourceComments: z.boolean().optional(),
|
|
69
|
-
targets: z.array(targetSchema),
|
|
70
|
-
})
|
|
71
|
-
.strict();
|
|
72
|
-
|
|
73
|
-
const toolSchema = z
|
|
74
|
-
.object({
|
|
75
|
-
command: z.string(),
|
|
76
|
-
args: z.array(z.string()).optional(),
|
|
77
|
-
promptFile: z.string().optional(),
|
|
78
|
-
})
|
|
79
|
-
.strict();
|
|
80
|
-
|
|
81
|
-
// --- Repositories -------------------------------------------------------------------------------
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* One trusted repository, keyed by the short name refs use in the `repo:`
|
|
85
|
-
* qualifier. Adding a repo IS trusting it: `sous repo add` writes the entry
|
|
86
|
-
* into the machine-written `conf.d/500-repos.jsonc` layer, and removing the
|
|
87
|
-
* entry withdraws the trust. A user may also hand-write `repos:` in the primary
|
|
88
|
-
* config; the two layers merge like anything else.
|
|
89
|
-
*/
|
|
90
|
-
const repoEntrySchema = z
|
|
91
|
-
.object({
|
|
92
|
-
/**
|
|
93
|
-
* Where the repository lives. A hosted repository is named by its URL; a
|
|
94
|
-
* repository on this machine, which the `local` provider reads, is named by
|
|
95
|
-
* an absolute path or the same path in `file:///...` form.
|
|
96
|
-
*/
|
|
97
|
-
url: repoUrlSchema,
|
|
98
|
-
/**
|
|
99
|
-
* Whether the repository takes part in anything at all. Defaults to true.
|
|
100
|
-
* Setting it to false is how a project opts out of a repository sous
|
|
101
|
-
* provides itself (the official `sous-recipes`), without having to delete an
|
|
102
|
-
* entry it never wrote.
|
|
103
|
-
*/
|
|
104
|
-
enabled: z.boolean().optional(),
|
|
105
|
-
/**
|
|
106
|
-
* Which provider handles it. Inferred from the URL when omitted; set it
|
|
107
|
-
* explicitly for a self-hosted instance the URL does not give away.
|
|
108
|
-
* `local` is a repository on this machine, for local development and tests;
|
|
109
|
-
* its trust semantics are identical to a hosted one.
|
|
110
|
-
*/
|
|
111
|
-
provider: z.enum(["github", "gitlab", "local"]).optional(),
|
|
112
|
-
/**
|
|
113
|
-
* When true, sous installs a newer in-range version whenever one exists
|
|
114
|
-
* rather than holding the locked one. The flag never widens the range a
|
|
115
|
-
* subscription or a dependency declared.
|
|
116
|
-
*/
|
|
117
|
-
alwaysPull: z.boolean().optional(),
|
|
118
|
-
/** When the repo was added, for provenance. */
|
|
119
|
-
addedAt: z.string().optional(),
|
|
120
|
-
/**
|
|
121
|
-
* Who required the repo: the literal "user" for a deliberate add, or the ref
|
|
122
|
-
* of the recipe whose dependency pulled it in. Removal hygiene reads this.
|
|
123
|
-
*/
|
|
124
|
-
addedBy: z.string().optional(),
|
|
125
|
-
})
|
|
126
|
-
.strict();
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* One subscription, keyed by a ref key: a bare namespace (every recipe in it,
|
|
130
|
-
* including ones published later) or `namespace/recipe`. Written by
|
|
131
|
-
* `sous subscribe` into the machine-written `conf.d/510-subscriptions.jsonc`
|
|
132
|
-
* layer, and hand-writable in the primary config.
|
|
133
|
-
*/
|
|
134
|
-
const subscriptionEntrySchema = z
|
|
135
|
-
.object({
|
|
136
|
-
/**
|
|
137
|
-
* Whether the subscription takes part in anything at all. Defaults to true.
|
|
138
|
-
* Setting it to false is how a project opts out of the `core` namespace sous
|
|
139
|
-
* subscribes every project to.
|
|
140
|
-
*/
|
|
141
|
-
enabled: z.boolean().optional(),
|
|
142
|
-
/** The semantic version range to resolve within. Defaults to "*". */
|
|
143
|
-
range: semverRangeSchema.optional(),
|
|
144
|
-
/** When true, prerelease versions take part in range matching. */
|
|
145
|
-
prerelease: z.boolean().optional(),
|
|
146
|
-
/** Per-subscription form of the repo-level always-pull flag. */
|
|
147
|
-
alwaysPull: z.boolean().optional(),
|
|
148
|
-
/** When the subscription was added, for provenance. */
|
|
149
|
-
addedAt: z.string().optional(),
|
|
150
|
-
/** Who required it: "user", or the ref of the recipe that co-subscribed it. */
|
|
151
|
-
addedBy: z.string().optional(),
|
|
152
|
-
})
|
|
153
|
-
.strict();
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Knobs for the machine-wide recipe store under the user-level sous directory.
|
|
157
|
-
* Every value here is a number the user can change; the numbers sous ships are
|
|
158
|
-
* defaults, not assumptions. Phase 2 applies them, so all three are optional
|
|
159
|
-
* here and the defaults live with the store itself: one gigabyte for maxBytes,
|
|
160
|
-
* 300 seconds for freshnessSeconds, and 300 seconds for watchPollSeconds.
|
|
161
|
-
*/
|
|
162
|
-
const storeSchema = z
|
|
163
|
-
.object({
|
|
164
|
-
/** Size cap for the store, past which least-recently-used entries are collected. */
|
|
165
|
-
maxBytes: z.number().int().positive().optional(),
|
|
166
|
-
/**
|
|
167
|
-
* How long a fetched index stays fresh. A non-watch build checks upstream
|
|
168
|
-
* only once this window has lapsed, and a failed check never breaks a
|
|
169
|
-
* build; the last good answer stands.
|
|
170
|
-
*/
|
|
171
|
-
freshnessSeconds: z.number().int().nonnegative().optional(),
|
|
172
|
-
/** How often watch mode polls upstream for a newer in-range version. */
|
|
173
|
-
watchPollSeconds: z.number().int().nonnegative().optional(),
|
|
174
|
-
})
|
|
175
|
-
.strict();
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* One list of recipe keys: each entry is a glob over `namespace/recipe` keys, or
|
|
179
|
-
* a regular expression written between two slashes (`/^tool-usage\//`). A
|
|
180
|
-
* regular expression that does not compile is an error naming the key and the
|
|
181
|
-
* value.
|
|
182
|
-
*/
|
|
183
|
-
function recipeKeyListSchema(where: string) {
|
|
184
|
-
return z.array(z.string()).superRefine((entries, context) => {
|
|
185
|
-
entries.forEach((entry, index) => {
|
|
186
|
-
try {
|
|
187
|
-
compileRecipeKeyMatcher([entry], `${where}[${index}]`);
|
|
188
|
-
} catch (error) {
|
|
189
|
-
context.addIssue({
|
|
190
|
-
code: "custom",
|
|
191
|
-
path: [index],
|
|
192
|
-
message: error instanceof Error ? error.message : String(error),
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* What a project does with the content kinds the subscribed recipes publish, one
|
|
201
|
-
* block per kind.
|
|
202
|
-
*
|
|
203
|
-
* `skills.outputs` lists the destination directories recipe skill bundles are
|
|
204
|
-
* written into. Each is `${var}` substituted like any other config path, and
|
|
205
|
-
* several may be named so the same recipe feeds more than one agent directory
|
|
206
|
-
* (`.claude/skills` and `.codex/skills`, say). The default is
|
|
207
|
-
* `<project root>/.claude/skills`, the project root being the parent of the
|
|
208
|
-
* discovered `.sous/` directory.
|
|
209
|
-
*
|
|
210
|
-
* `memories.first` and `memories.exclude` shape which recipe memories an
|
|
211
|
-
* `@#memories` include pulls in and in what order: recipes matching `first` lead,
|
|
212
|
-
* and recipes matching `exclude` are left out. Each entry is a glob over
|
|
213
|
-
* `namespace/recipe` keys, or a regular expression written between two slashes.
|
|
214
|
-
*
|
|
215
|
-
* A recipe's `config` contents are not listed here; they are loaded as config
|
|
216
|
-
* layers rather than written anywhere.
|
|
217
|
-
*/
|
|
218
|
-
const recipesSchema = z
|
|
219
|
-
.object({
|
|
220
|
-
/** Where recipe skill bundles are written. */
|
|
221
|
-
skills: z
|
|
222
|
-
.object({
|
|
223
|
-
/** Destination directories, `${var}` substituted. */
|
|
224
|
-
outputs: z.array(z.string()).optional(),
|
|
225
|
-
})
|
|
226
|
-
.strict()
|
|
227
|
-
.optional(),
|
|
228
|
-
/** Which recipe memories an `@#memories` include pulls in, and in what order. */
|
|
229
|
-
memories: z
|
|
230
|
-
.object({
|
|
231
|
-
/** Recipes whose memories come first. */
|
|
232
|
-
first: recipeKeyListSchema("recipes.memories.first").optional(),
|
|
233
|
-
/** Recipes whose memories are left out. */
|
|
234
|
-
exclude: recipeKeyListSchema("recipes.memories.exclude").optional(),
|
|
235
|
-
})
|
|
236
|
-
.strict()
|
|
237
|
-
.optional(),
|
|
238
|
-
})
|
|
239
|
-
.strict();
|
|
240
|
-
|
|
241
|
-
// --- Variable mappings --------------------------------------------------------------------------
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* A mapping record's target: one variable, named in full, as
|
|
245
|
-
* `namespace/recipe/variableName` with an optional `repo:` qualifier. Mapping
|
|
246
|
-
* records are the top rung of the answer resolution ladder and the universal
|
|
247
|
-
* resolver when two recipes want the same environment variable name.
|
|
248
|
-
*/
|
|
249
|
-
const mappingTargetSchema = z
|
|
250
|
-
.string()
|
|
251
|
-
.regex(
|
|
252
|
-
/^([a-z][a-z0-9-]*:)?[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*\/[a-z][a-zA-Z0-9]*$/,
|
|
253
|
-
"a variable mapping target must be written as 'namespace/recipe/variableName', " +
|
|
254
|
-
"optionally qualified with a repository as 'repo:namespace/recipe/variableName'"
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* The full merged-config schema. `version`, when present, must be exactly
|
|
259
|
-
* `SUPPORTED_CONFIG_VERSION` — but validateSettings pre-checks it with a clearer
|
|
260
|
-
* message before this schema runs, so a bad version never reaches the generic
|
|
261
|
-
* literal error here.
|
|
262
|
-
*/
|
|
263
|
-
export const settingsSchema = z
|
|
264
|
-
.object({
|
|
265
|
-
// Allowed so a JSON config can bind itself to the shipped
|
|
266
|
-
// `sous.config.schema.json` via the standard `"$schema": "..."` property
|
|
267
|
-
// for editor autocompletion / external validation. Editors treat `$schema`
|
|
268
|
-
// as reserved and never flag it, so rejecting it here would break the
|
|
269
|
-
// documented workflow. sous itself ignores the value.
|
|
270
|
-
$schema: z.string().optional(),
|
|
271
|
-
version: z.literal(SUPPORTED_CONFIG_VERSION).optional(),
|
|
272
|
-
_env: stringRecord.optional(),
|
|
273
|
-
_vars: stringRecord.optional(),
|
|
274
|
-
_aliases: z
|
|
275
|
-
.record(z.string(), z.union([z.string(), z.array(z.string())]))
|
|
276
|
-
.optional(),
|
|
277
|
-
name: z.string().optional(),
|
|
278
|
-
compilation: compilationSchema.optional(),
|
|
279
|
-
runtimeContext: runtimeContextSchema.optional(),
|
|
280
|
-
tools: z.record(z.string(), toolSchema).optional(),
|
|
281
|
-
/** Trusted repositories, keyed by the short name refs use. */
|
|
282
|
-
repos: z
|
|
283
|
-
.record(
|
|
284
|
-
z
|
|
285
|
-
.string()
|
|
286
|
-
.regex(
|
|
287
|
-
REPO_NAME_PATTERN,
|
|
288
|
-
"a repo name must be lowercase kebab-case: a letter, then letters, " +
|
|
289
|
-
"digits or hyphens"
|
|
290
|
-
),
|
|
291
|
-
repoEntrySchema
|
|
292
|
-
)
|
|
293
|
-
.optional(),
|
|
294
|
-
/** Subscriptions, keyed by ref key (`namespace` or `namespace/recipe`). */
|
|
295
|
-
subscriptions: z
|
|
296
|
-
.record(
|
|
297
|
-
z
|
|
298
|
-
.string()
|
|
299
|
-
.regex(
|
|
300
|
-
REF_KEY_PATTERN,
|
|
301
|
-
"a subscription key must be a namespace such as 'workflow', or a " +
|
|
302
|
-
"namespace and recipe such as 'workflow/task-files', with no repo " +
|
|
303
|
-
"qualifier and no version range"
|
|
304
|
-
),
|
|
305
|
-
subscriptionEntrySchema
|
|
306
|
-
)
|
|
307
|
-
.optional(),
|
|
308
|
-
/** Knobs for the machine-wide recipe store. */
|
|
309
|
-
store: storeSchema.optional(),
|
|
310
|
-
/** What the project does with each content kind its subscribed recipes publish. */
|
|
311
|
-
recipes: recipesSchema.optional(),
|
|
312
|
-
/**
|
|
313
|
-
* Variable mapping records, keyed by environment variable name. Each entry
|
|
314
|
-
* binds that name to one recipe variable, which is how an answer is stored
|
|
315
|
-
* under a name of your choosing when the generated names are taken. Written
|
|
316
|
-
* by `sous vars ask` into `conf.d/520-var-mappings.jsonc`, and hand-writable
|
|
317
|
-
* in the primary config.
|
|
318
|
-
*/
|
|
319
|
-
varMappings: z
|
|
320
|
-
.record(
|
|
321
|
-
z
|
|
322
|
-
.string()
|
|
323
|
-
.regex(
|
|
324
|
-
/^[A-Z][A-Z0-9_]*$/,
|
|
325
|
-
"an environment variable name must be upper snake case: a capital " +
|
|
326
|
-
"letter, then capitals, digits or underscores"
|
|
327
|
-
),
|
|
328
|
-
mappingTargetSchema
|
|
329
|
-
)
|
|
330
|
-
.optional(),
|
|
331
|
-
})
|
|
332
|
-
.strict();
|
|
333
|
-
|
|
334
|
-
/** Renders a zod issue path (e.g. `["compilation","targets",0,"entryPoint"]`) as `compilation.targets[0].entryPoint`. */
|
|
335
|
-
function formatIssuePath(parts: ReadonlyArray<PropertyKey>): string {
|
|
336
|
-
let out = "";
|
|
337
|
-
for (const part of parts) {
|
|
338
|
-
if (typeof part === "number") out += `[${part}]`;
|
|
339
|
-
else out += out.length > 0 ? `.${String(part)}` : String(part);
|
|
340
|
-
}
|
|
341
|
-
return out;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Turns a ZodError into a readable, per-issue ConfigError message. Never leaks
|
|
346
|
-
* the raw zod JSON dump. Unknown-key issues are surfaced as likely typos and
|
|
347
|
-
* name the config file.
|
|
348
|
-
*/
|
|
349
|
-
function formatZodError(error: z.ZodError, configPath: string): ConfigError {
|
|
350
|
-
const lines: string[] = [`Invalid sous config at ${configPath}:`];
|
|
351
|
-
|
|
352
|
-
for (const issue of error.issues) {
|
|
353
|
-
const where = formatIssuePath(issue.path);
|
|
354
|
-
if (issue.code === "unrecognized_keys") {
|
|
355
|
-
const keys = issue.keys.map((k) => `'${k}'`).join(", ");
|
|
356
|
-
const loc = where.length > 0 ? `under '${where}'` : "at the top level";
|
|
357
|
-
lines.push(
|
|
358
|
-
` - unknown key(s) ${keys} ${loc} — likely a typo. Check ${configPath}.`
|
|
359
|
-
);
|
|
360
|
-
} else if (issue.code === "invalid_key") {
|
|
361
|
-
// zod reports a bad record KEY as a bare "Invalid key in record" and hides
|
|
362
|
-
// the reason in a nested issue list. Surface the reason, since that is the
|
|
363
|
-
// part telling the user how to fix the key.
|
|
364
|
-
const reasons = issue.issues.map((inner) => inner.message).join("; ");
|
|
365
|
-
lines.push(` - ${where}: invalid key; ${reasons}`);
|
|
366
|
-
} else {
|
|
367
|
-
lines.push(` - ${where.length > 0 ? where : "(root)"}: ${issue.message}`);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
return new ConfigError(lines.join("\n"));
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Validates a merged config object against the schema, returning it typed as
|
|
376
|
-
* `Settings`. Throws a ConfigError (never a raw ZodError) on any problem.
|
|
377
|
-
*
|
|
378
|
-
* @param raw - The merged config produced by the kernel (post assertFlatConfig).
|
|
379
|
-
* @param configPath - The primary config file path, named in error messages.
|
|
380
|
-
*/
|
|
381
|
-
export function validateSettings(raw: unknown, configPath: string): Settings {
|
|
382
|
-
// Version gets a dedicated, friendlier message than the generic literal error.
|
|
383
|
-
if (raw !== null && typeof raw === "object" && "version" in raw) {
|
|
384
|
-
const version = (raw as { version: unknown }).version;
|
|
385
|
-
if (version !== SUPPORTED_CONFIG_VERSION) {
|
|
386
|
-
throw new ConfigError(
|
|
387
|
-
`Config at ${configPath} declares version ${JSON.stringify(version)}, which is not ` +
|
|
388
|
-
`supported by this version of sous.\n` +
|
|
389
|
-
` This sous understands config version ${SUPPORTED_CONFIG_VERSION}. Omit the ` +
|
|
390
|
-
`'version' field or set it to ${SUPPORTED_CONFIG_VERSION}.`
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const result = settingsSchema.safeParse(raw);
|
|
396
|
-
if (!result.success) {
|
|
397
|
-
throw formatZodError(result.error, configPath);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return result.data as Settings;
|
|
401
|
-
}
|