loadouts 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +108 -0
- package/bundled/loadouts/loadouts.yaml +5 -0
- package/bundled/skills/loadout-usage/SKILL.md +110 -0
- package/dist/builtins/index.d.ts +14 -0
- package/dist/builtins/index.d.ts.map +1 -0
- package/dist/builtins/index.js +58 -0
- package/dist/builtins/index.js.map +1 -0
- package/dist/builtins/kinds/extension.d.ts +3 -0
- package/dist/builtins/kinds/extension.d.ts.map +1 -0
- package/dist/builtins/kinds/extension.js +9 -0
- package/dist/builtins/kinds/extension.js.map +1 -0
- package/dist/builtins/kinds/instruction.d.ts +3 -0
- package/dist/builtins/kinds/instruction.d.ts.map +1 -0
- package/dist/builtins/kinds/instruction.js +8 -0
- package/dist/builtins/kinds/instruction.js.map +1 -0
- package/dist/builtins/kinds/prompt.d.ts +3 -0
- package/dist/builtins/kinds/prompt.d.ts.map +1 -0
- package/dist/builtins/kinds/prompt.js +8 -0
- package/dist/builtins/kinds/prompt.js.map +1 -0
- package/dist/builtins/kinds/rule.d.ts +3 -0
- package/dist/builtins/kinds/rule.d.ts.map +1 -0
- package/dist/builtins/kinds/rule.js +10 -0
- package/dist/builtins/kinds/rule.js.map +1 -0
- package/dist/builtins/kinds/skill.d.ts +3 -0
- package/dist/builtins/kinds/skill.d.ts.map +1 -0
- package/dist/builtins/kinds/skill.js +8 -0
- package/dist/builtins/kinds/skill.js.map +1 -0
- package/dist/builtins/kinds/theme.d.ts +3 -0
- package/dist/builtins/kinds/theme.d.ts.map +1 -0
- package/dist/builtins/kinds/theme.js +8 -0
- package/dist/builtins/kinds/theme.js.map +1 -0
- package/dist/builtins/tools/claude-code.d.ts +3 -0
- package/dist/builtins/tools/claude-code.d.ts.map +1 -0
- package/dist/builtins/tools/claude-code.js +30 -0
- package/dist/builtins/tools/claude-code.js.map +1 -0
- package/dist/builtins/tools/codex.d.ts +3 -0
- package/dist/builtins/tools/codex.d.ts.map +1 -0
- package/dist/builtins/tools/codex.js +17 -0
- package/dist/builtins/tools/codex.js.map +1 -0
- package/dist/builtins/tools/cursor.d.ts +3 -0
- package/dist/builtins/tools/cursor.d.ts.map +1 -0
- package/dist/builtins/tools/cursor.js +22 -0
- package/dist/builtins/tools/cursor.js.map +1 -0
- package/dist/builtins/tools/opencode.d.ts +3 -0
- package/dist/builtins/tools/opencode.d.ts.map +1 -0
- package/dist/builtins/tools/opencode.js +45 -0
- package/dist/builtins/tools/opencode.js.map +1 -0
- package/dist/builtins/tools/pi.d.ts +3 -0
- package/dist/builtins/tools/pi.d.ts.map +1 -0
- package/dist/builtins/tools/pi.js +22 -0
- package/dist/builtins/tools/pi.js.map +1 -0
- package/dist/cli/commands/activate.d.ts +12 -0
- package/dist/cli/commands/activate.d.ts.map +1 -0
- package/dist/cli/commands/activate.js +70 -0
- package/dist/cli/commands/activate.js.map +1 -0
- package/dist/cli/commands/check.d.ts +12 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +152 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/clear.d.ts +12 -0
- package/dist/cli/commands/clear.d.ts.map +1 -0
- package/dist/cli/commands/clear.js +25 -0
- package/dist/cli/commands/clear.js.map +1 -0
- package/dist/cli/commands/create.d.ts +11 -0
- package/dist/cli/commands/create.d.ts.map +1 -0
- package/dist/cli/commands/create.js +113 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/deactivate.d.ts +12 -0
- package/dist/cli/commands/deactivate.d.ts.map +1 -0
- package/dist/cli/commands/deactivate.js +67 -0
- package/dist/cli/commands/deactivate.js.map +1 -0
- package/dist/cli/commands/diff.d.ts +16 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +144 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/docs.d.ts +12 -0
- package/dist/cli/commands/docs.d.ts.map +1 -0
- package/dist/cli/commands/docs.js +115 -0
- package/dist/cli/commands/docs.js.map +1 -0
- package/dist/cli/commands/edit.d.ts +11 -0
- package/dist/cli/commands/edit.d.ts.map +1 -0
- package/dist/cli/commands/edit.js +71 -0
- package/dist/cli/commands/edit.js.map +1 -0
- package/dist/cli/commands/fallback.d.ts +9 -0
- package/dist/cli/commands/fallback.d.ts.map +1 -0
- package/dist/cli/commands/fallback.js +35 -0
- package/dist/cli/commands/fallback.js.map +1 -0
- package/dist/cli/commands/info.d.ts +23 -0
- package/dist/cli/commands/info.d.ts.map +1 -0
- package/dist/cli/commands/info.js +314 -0
- package/dist/cli/commands/info.js.map +1 -0
- package/dist/cli/commands/init.d.ts +18 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +255 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install.d.ts +27 -0
- package/dist/cli/commands/install.d.ts.map +1 -0
- package/dist/cli/commands/install.js +586 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/instructions.d.ts +8 -0
- package/dist/cli/commands/instructions.d.ts.map +1 -0
- package/dist/cli/commands/instructions.js +218 -0
- package/dist/cli/commands/instructions.js.map +1 -0
- package/dist/cli/commands/kinds.d.ts +6 -0
- package/dist/cli/commands/kinds.d.ts.map +1 -0
- package/dist/cli/commands/kinds.js +59 -0
- package/dist/cli/commands/kinds.js.map +1 -0
- package/dist/cli/commands/list.d.ts +12 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +182 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/policy.d.ts +28 -0
- package/dist/cli/commands/policy.d.ts.map +1 -0
- package/dist/cli/commands/policy.js +50 -0
- package/dist/cli/commands/policy.js.map +1 -0
- package/dist/cli/commands/remove.d.ts +24 -0
- package/dist/cli/commands/remove.d.ts.map +1 -0
- package/dist/cli/commands/remove.js +64 -0
- package/dist/cli/commands/remove.js.map +1 -0
- package/dist/cli/commands/render-engine.d.ts +36 -0
- package/dist/cli/commands/render-engine.d.ts.map +1 -0
- package/dist/cli/commands/render-engine.js +177 -0
- package/dist/cli/commands/render-engine.js.map +1 -0
- package/dist/cli/commands/rule.d.ts +11 -0
- package/dist/cli/commands/rule.d.ts.map +1 -0
- package/dist/cli/commands/rule.js +302 -0
- package/dist/cli/commands/rule.js.map +1 -0
- package/dist/cli/commands/sanitize.d.ts +14 -0
- package/dist/cli/commands/sanitize.d.ts.map +1 -0
- package/dist/cli/commands/sanitize.js +62 -0
- package/dist/cli/commands/sanitize.js.map +1 -0
- package/dist/cli/commands/skill.d.ts +11 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +380 -0
- package/dist/cli/commands/skill.js.map +1 -0
- package/dist/cli/commands/status.d.ts +26 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +454 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/sync.d.ts +14 -0
- package/dist/cli/commands/sync.d.ts.map +1 -0
- package/dist/cli/commands/sync.js +53 -0
- package/dist/cli/commands/sync.js.map +1 -0
- package/dist/cli/commands/update.d.ts +3 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +48 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/index.d.ts +11 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +134 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +64 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +166 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/discovery.d.ts +50 -0
- package/dist/core/discovery.d.ts.map +1 -0
- package/dist/core/discovery.js +249 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/fallback.d.ts +23 -0
- package/dist/core/fallback.d.ts.map +1 -0
- package/dist/core/fallback.js +119 -0
- package/dist/core/fallback.js.map +1 -0
- package/dist/core/import-discovery.d.ts +56 -0
- package/dist/core/import-discovery.d.ts.map +1 -0
- package/dist/core/import-discovery.js +304 -0
- package/dist/core/import-discovery.js.map +1 -0
- package/dist/core/kindLoader.d.ts +119 -0
- package/dist/core/kindLoader.d.ts.map +1 -0
- package/dist/core/kindLoader.js +141 -0
- package/dist/core/kindLoader.js.map +1 -0
- package/dist/core/manifest.d.ts +39 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +167 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/core/plugin.d.ts +22 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/plugin.js +20 -0
- package/dist/core/plugin.js.map +1 -0
- package/dist/core/registry.d.ts +115 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +105 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/render.d.ts +64 -0
- package/dist/core/render.d.ts.map +1 -0
- package/dist/core/render.js +457 -0
- package/dist/core/render.js.map +1 -0
- package/dist/core/resolve.d.ts +39 -0
- package/dist/core/resolve.d.ts.map +1 -0
- package/dist/core/resolve.js +128 -0
- package/dist/core/resolve.js.map +1 -0
- package/dist/core/schema.d.ts +308 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +81 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/scope.d.ts +74 -0
- package/dist/core/scope.d.ts.map +1 -0
- package/dist/core/scope.js +176 -0
- package/dist/core/scope.js.map +1 -0
- package/dist/core/template.d.ts +32 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/template.js +32 -0
- package/dist/core/template.js.map +1 -0
- package/dist/core/tokens.d.ts +33 -0
- package/dist/core/tokens.d.ts.map +1 -0
- package/dist/core/tokens.js +97 -0
- package/dist/core/tokens.js.map +1 -0
- package/dist/core/types.d.ts +103 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/artifact-paths.d.ts +39 -0
- package/dist/lib/artifact-paths.d.ts.map +1 -0
- package/dist/lib/artifact-paths.js +83 -0
- package/dist/lib/artifact-paths.js.map +1 -0
- package/dist/lib/artifact-table.d.ts +126 -0
- package/dist/lib/artifact-table.d.ts.map +1 -0
- package/dist/lib/artifact-table.js +263 -0
- package/dist/lib/artifact-table.js.map +1 -0
- package/dist/lib/editor.d.ts +17 -0
- package/dist/lib/editor.d.ts.map +1 -0
- package/dist/lib/editor.js +33 -0
- package/dist/lib/editor.js.map +1 -0
- package/dist/lib/fs.d.ts +87 -0
- package/dist/lib/fs.d.ts.map +1 -0
- package/dist/lib/fs.js +229 -0
- package/dist/lib/fs.js.map +1 -0
- package/dist/lib/git.d.ts +13 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +28 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/gitignore.d.ts +26 -0
- package/dist/lib/gitignore.d.ts.map +1 -0
- package/dist/lib/gitignore.js +97 -0
- package/dist/lib/gitignore.js.map +1 -0
- package/dist/lib/loadout-column.d.ts +66 -0
- package/dist/lib/loadout-column.d.ts.map +1 -0
- package/dist/lib/loadout-column.js +66 -0
- package/dist/lib/loadout-column.js.map +1 -0
- package/dist/lib/output.d.ts +15 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +32 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/scope-indicators.d.ts +60 -0
- package/dist/lib/scope-indicators.d.ts.map +1 -0
- package/dist/lib/scope-indicators.js +110 -0
- package/dist/lib/scope-indicators.js.map +1 -0
- package/docs/authoring.md +182 -0
- package/docs/commands.md +192 -0
- package/docs/concepts.md +114 -0
- package/docs/index.md +60 -0
- package/docs/quickstart.md +100 -0
- package/docs/troubleshooting.md +147 -0
- package/docs/visual-language.md +251 -0
- package/docs/workflows.md +184 -0
- package/package.json +54 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for config file validation.
|
|
3
|
+
*
|
|
4
|
+
* Tool and ArtifactKind are open strings (any registered value is valid).
|
|
5
|
+
* Runtime registry validation happens separately in the render pipeline;
|
|
6
|
+
* these schemas focus on structural correctness of config files.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
export declare const ToolSchema: z.ZodString;
|
|
10
|
+
export declare const ArtifactKindSchema: z.ZodString;
|
|
11
|
+
export declare const OutputModeSchema: z.ZodEnum<["symlink", "copy", "generate"]>;
|
|
12
|
+
export declare const SourceRefSchema: z.ZodString;
|
|
13
|
+
export declare const RootConfigSchema: z.ZodObject<{
|
|
14
|
+
version: z.ZodLiteral<"1">;
|
|
15
|
+
default: z.ZodOptional<z.ZodString>;
|
|
16
|
+
mode: z.ZodOptional<z.ZodEnum<["symlink", "copy", "generate"]>>;
|
|
17
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
18
|
+
sources: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
version: "1";
|
|
21
|
+
default?: string | undefined;
|
|
22
|
+
mode?: "symlink" | "copy" | "generate" | undefined;
|
|
23
|
+
tools?: string[] | undefined;
|
|
24
|
+
sources?: string[] | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
version: "1";
|
|
27
|
+
default?: string | undefined;
|
|
28
|
+
mode?: "symlink" | "copy" | "generate" | undefined;
|
|
29
|
+
tools?: string[] | undefined;
|
|
30
|
+
sources?: string[] | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const LoadoutIncludeSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
33
|
+
path: z.ZodString;
|
|
34
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
path: string;
|
|
37
|
+
tools?: string[] | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
path: string;
|
|
40
|
+
tools?: string[] | undefined;
|
|
41
|
+
}>]>;
|
|
42
|
+
export declare const LoadoutDefinitionSchema: z.ZodObject<{
|
|
43
|
+
name: z.ZodString;
|
|
44
|
+
description: z.ZodOptional<z.ZodString>;
|
|
45
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
46
|
+
include: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
47
|
+
path: z.ZodString;
|
|
48
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
path: string;
|
|
51
|
+
tools?: string[] | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
path: string;
|
|
54
|
+
tools?: string[] | undefined;
|
|
55
|
+
}>]>, "many">;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
name: string;
|
|
58
|
+
include: (string | {
|
|
59
|
+
path: string;
|
|
60
|
+
tools?: string[] | undefined;
|
|
61
|
+
})[];
|
|
62
|
+
tools?: string[] | undefined;
|
|
63
|
+
description?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
name: string;
|
|
66
|
+
include: (string | {
|
|
67
|
+
path: string;
|
|
68
|
+
tools?: string[] | undefined;
|
|
69
|
+
})[];
|
|
70
|
+
tools?: string[] | undefined;
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
export declare const ManifestEntrySchema: z.ZodObject<{
|
|
74
|
+
tools: z.ZodArray<z.ZodString, "many">;
|
|
75
|
+
kind: z.ZodString;
|
|
76
|
+
sourcePath: z.ZodString;
|
|
77
|
+
targetPath: z.ZodString;
|
|
78
|
+
mode: z.ZodEnum<["symlink", "copy", "generate"]>;
|
|
79
|
+
renderedHash: z.ZodString;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
mode: "symlink" | "copy" | "generate";
|
|
82
|
+
tools: string[];
|
|
83
|
+
kind: string;
|
|
84
|
+
sourcePath: string;
|
|
85
|
+
targetPath: string;
|
|
86
|
+
renderedHash: string;
|
|
87
|
+
}, {
|
|
88
|
+
mode: "symlink" | "copy" | "generate";
|
|
89
|
+
tools: string[];
|
|
90
|
+
kind: string;
|
|
91
|
+
sourcePath: string;
|
|
92
|
+
targetPath: string;
|
|
93
|
+
renderedHash: string;
|
|
94
|
+
}>;
|
|
95
|
+
export declare const LegacyManifestEntrySchema: z.ZodObject<{
|
|
96
|
+
tool: z.ZodString;
|
|
97
|
+
kind: z.ZodString;
|
|
98
|
+
sourcePath: z.ZodString;
|
|
99
|
+
targetPath: z.ZodString;
|
|
100
|
+
mode: z.ZodEnum<["symlink", "copy", "generate"]>;
|
|
101
|
+
renderedHash: z.ZodString;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
mode: "symlink" | "copy" | "generate";
|
|
104
|
+
kind: string;
|
|
105
|
+
sourcePath: string;
|
|
106
|
+
targetPath: string;
|
|
107
|
+
renderedHash: string;
|
|
108
|
+
tool: string;
|
|
109
|
+
}, {
|
|
110
|
+
mode: "symlink" | "copy" | "generate";
|
|
111
|
+
kind: string;
|
|
112
|
+
sourcePath: string;
|
|
113
|
+
targetPath: string;
|
|
114
|
+
renderedHash: string;
|
|
115
|
+
tool: string;
|
|
116
|
+
}>;
|
|
117
|
+
export declare const ShadowedEntrySchema: z.ZodObject<{
|
|
118
|
+
tool: z.ZodString;
|
|
119
|
+
kind: z.ZodString;
|
|
120
|
+
sourcePath: z.ZodString;
|
|
121
|
+
targetPath: z.ZodString;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
kind: string;
|
|
124
|
+
sourcePath: string;
|
|
125
|
+
targetPath: string;
|
|
126
|
+
tool: string;
|
|
127
|
+
}, {
|
|
128
|
+
kind: string;
|
|
129
|
+
sourcePath: string;
|
|
130
|
+
targetPath: string;
|
|
131
|
+
tool: string;
|
|
132
|
+
}>;
|
|
133
|
+
export declare const AppliedStateSchema: z.ZodObject<{
|
|
134
|
+
active: z.ZodArray<z.ZodString, "many">;
|
|
135
|
+
mode: z.ZodEnum<["symlink", "copy", "generate"]>;
|
|
136
|
+
appliedAt: z.ZodString;
|
|
137
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
138
|
+
tools: z.ZodArray<z.ZodString, "many">;
|
|
139
|
+
kind: z.ZodString;
|
|
140
|
+
sourcePath: z.ZodString;
|
|
141
|
+
targetPath: z.ZodString;
|
|
142
|
+
mode: z.ZodEnum<["symlink", "copy", "generate"]>;
|
|
143
|
+
renderedHash: z.ZodString;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
mode: "symlink" | "copy" | "generate";
|
|
146
|
+
tools: string[];
|
|
147
|
+
kind: string;
|
|
148
|
+
sourcePath: string;
|
|
149
|
+
targetPath: string;
|
|
150
|
+
renderedHash: string;
|
|
151
|
+
}, {
|
|
152
|
+
mode: "symlink" | "copy" | "generate";
|
|
153
|
+
tools: string[];
|
|
154
|
+
kind: string;
|
|
155
|
+
sourcePath: string;
|
|
156
|
+
targetPath: string;
|
|
157
|
+
renderedHash: string;
|
|
158
|
+
}>, "many">;
|
|
159
|
+
shadowed: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
160
|
+
tool: z.ZodString;
|
|
161
|
+
kind: z.ZodString;
|
|
162
|
+
sourcePath: z.ZodString;
|
|
163
|
+
targetPath: z.ZodString;
|
|
164
|
+
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
kind: string;
|
|
166
|
+
sourcePath: string;
|
|
167
|
+
targetPath: string;
|
|
168
|
+
tool: string;
|
|
169
|
+
}, {
|
|
170
|
+
kind: string;
|
|
171
|
+
sourcePath: string;
|
|
172
|
+
targetPath: string;
|
|
173
|
+
tool: string;
|
|
174
|
+
}>, "many">>;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
entries: {
|
|
177
|
+
mode: "symlink" | "copy" | "generate";
|
|
178
|
+
tools: string[];
|
|
179
|
+
kind: string;
|
|
180
|
+
sourcePath: string;
|
|
181
|
+
targetPath: string;
|
|
182
|
+
renderedHash: string;
|
|
183
|
+
}[];
|
|
184
|
+
mode: "symlink" | "copy" | "generate";
|
|
185
|
+
active: string[];
|
|
186
|
+
appliedAt: string;
|
|
187
|
+
shadowed: {
|
|
188
|
+
kind: string;
|
|
189
|
+
sourcePath: string;
|
|
190
|
+
targetPath: string;
|
|
191
|
+
tool: string;
|
|
192
|
+
}[];
|
|
193
|
+
}, {
|
|
194
|
+
entries: {
|
|
195
|
+
mode: "symlink" | "copy" | "generate";
|
|
196
|
+
tools: string[];
|
|
197
|
+
kind: string;
|
|
198
|
+
sourcePath: string;
|
|
199
|
+
targetPath: string;
|
|
200
|
+
renderedHash: string;
|
|
201
|
+
}[];
|
|
202
|
+
mode: "symlink" | "copy" | "generate";
|
|
203
|
+
active: string[];
|
|
204
|
+
appliedAt: string;
|
|
205
|
+
shadowed?: {
|
|
206
|
+
kind: string;
|
|
207
|
+
sourcePath: string;
|
|
208
|
+
targetPath: string;
|
|
209
|
+
tool: string;
|
|
210
|
+
}[] | undefined;
|
|
211
|
+
}>;
|
|
212
|
+
export declare const LegacyAppliedStateSchema: z.ZodObject<{
|
|
213
|
+
loadout: z.ZodString;
|
|
214
|
+
mode: z.ZodEnum<["symlink", "copy", "generate"]>;
|
|
215
|
+
appliedAt: z.ZodString;
|
|
216
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
217
|
+
tool: z.ZodString;
|
|
218
|
+
kind: z.ZodString;
|
|
219
|
+
sourcePath: z.ZodString;
|
|
220
|
+
targetPath: z.ZodString;
|
|
221
|
+
mode: z.ZodEnum<["symlink", "copy", "generate"]>;
|
|
222
|
+
renderedHash: z.ZodString;
|
|
223
|
+
}, "strip", z.ZodTypeAny, {
|
|
224
|
+
mode: "symlink" | "copy" | "generate";
|
|
225
|
+
kind: string;
|
|
226
|
+
sourcePath: string;
|
|
227
|
+
targetPath: string;
|
|
228
|
+
renderedHash: string;
|
|
229
|
+
tool: string;
|
|
230
|
+
}, {
|
|
231
|
+
mode: "symlink" | "copy" | "generate";
|
|
232
|
+
kind: string;
|
|
233
|
+
sourcePath: string;
|
|
234
|
+
targetPath: string;
|
|
235
|
+
renderedHash: string;
|
|
236
|
+
tool: string;
|
|
237
|
+
}>, "many">;
|
|
238
|
+
shadowed: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
239
|
+
tool: z.ZodString;
|
|
240
|
+
kind: z.ZodString;
|
|
241
|
+
sourcePath: z.ZodString;
|
|
242
|
+
targetPath: z.ZodString;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
kind: string;
|
|
245
|
+
sourcePath: string;
|
|
246
|
+
targetPath: string;
|
|
247
|
+
tool: string;
|
|
248
|
+
}, {
|
|
249
|
+
kind: string;
|
|
250
|
+
sourcePath: string;
|
|
251
|
+
targetPath: string;
|
|
252
|
+
tool: string;
|
|
253
|
+
}>, "many">>;
|
|
254
|
+
}, "strip", z.ZodTypeAny, {
|
|
255
|
+
entries: {
|
|
256
|
+
mode: "symlink" | "copy" | "generate";
|
|
257
|
+
kind: string;
|
|
258
|
+
sourcePath: string;
|
|
259
|
+
targetPath: string;
|
|
260
|
+
renderedHash: string;
|
|
261
|
+
tool: string;
|
|
262
|
+
}[];
|
|
263
|
+
mode: "symlink" | "copy" | "generate";
|
|
264
|
+
appliedAt: string;
|
|
265
|
+
shadowed: {
|
|
266
|
+
kind: string;
|
|
267
|
+
sourcePath: string;
|
|
268
|
+
targetPath: string;
|
|
269
|
+
tool: string;
|
|
270
|
+
}[];
|
|
271
|
+
loadout: string;
|
|
272
|
+
}, {
|
|
273
|
+
entries: {
|
|
274
|
+
mode: "symlink" | "copy" | "generate";
|
|
275
|
+
kind: string;
|
|
276
|
+
sourcePath: string;
|
|
277
|
+
targetPath: string;
|
|
278
|
+
renderedHash: string;
|
|
279
|
+
tool: string;
|
|
280
|
+
}[];
|
|
281
|
+
mode: "symlink" | "copy" | "generate";
|
|
282
|
+
appliedAt: string;
|
|
283
|
+
loadout: string;
|
|
284
|
+
shadowed?: {
|
|
285
|
+
kind: string;
|
|
286
|
+
sourcePath: string;
|
|
287
|
+
targetPath: string;
|
|
288
|
+
tool: string;
|
|
289
|
+
}[] | undefined;
|
|
290
|
+
}>;
|
|
291
|
+
export declare const RuleFrontmatterSchema: z.ZodObject<{
|
|
292
|
+
description: z.ZodOptional<z.ZodString>;
|
|
293
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
294
|
+
globs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
295
|
+
alwaysApply: z.ZodOptional<z.ZodBoolean>;
|
|
296
|
+
}, "strip", z.ZodTypeAny, {
|
|
297
|
+
description?: string | undefined;
|
|
298
|
+
paths?: string[] | undefined;
|
|
299
|
+
globs?: string[] | undefined;
|
|
300
|
+
alwaysApply?: boolean | undefined;
|
|
301
|
+
}, {
|
|
302
|
+
description?: string | undefined;
|
|
303
|
+
paths?: string[] | undefined;
|
|
304
|
+
globs?: string[] | undefined;
|
|
305
|
+
alwaysApply?: boolean | undefined;
|
|
306
|
+
}>;
|
|
307
|
+
export type RuleFrontmatter = z.infer<typeof RuleFrontmatterSchema>;
|
|
308
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU,aAAoB,CAAC;AAC5C,eAAO,MAAM,kBAAkB,aAAoB,CAAC;AAEpD,eAAO,MAAM,gBAAgB,4CAA0C,CAAC;AAGxE,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;EAM3B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;IAM/B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKlC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;EAO9B,CAAC;AAGH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;EAOpC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;EAK9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM7B,CAAC;AAGH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AAGH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;EAKhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for config file validation.
|
|
3
|
+
*
|
|
4
|
+
* Tool and ArtifactKind are open strings (any registered value is valid).
|
|
5
|
+
* Runtime registry validation happens separately in the render pipeline;
|
|
6
|
+
* these schemas focus on structural correctness of config files.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
// Tool and kind are open strings — new tools/kinds registered via plugins
|
|
10
|
+
// are automatically accepted without schema changes.
|
|
11
|
+
export const ToolSchema = z.string().min(1);
|
|
12
|
+
export const ArtifactKindSchema = z.string().min(1);
|
|
13
|
+
export const OutputModeSchema = z.enum(["symlink", "copy", "generate"]);
|
|
14
|
+
// Source reference — path to another .loadouts/ directory
|
|
15
|
+
export const SourceRefSchema = z.string();
|
|
16
|
+
export const RootConfigSchema = z.object({
|
|
17
|
+
version: z.literal("1"),
|
|
18
|
+
default: z.string().optional(),
|
|
19
|
+
mode: OutputModeSchema.optional(),
|
|
20
|
+
tools: z.array(ToolSchema).optional(),
|
|
21
|
+
sources: z.array(SourceRefSchema).optional(),
|
|
22
|
+
});
|
|
23
|
+
export const LoadoutIncludeSchema = z.union([
|
|
24
|
+
z.string(),
|
|
25
|
+
z.object({
|
|
26
|
+
path: z.string(),
|
|
27
|
+
tools: z.array(ToolSchema).optional(),
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
30
|
+
export const LoadoutDefinitionSchema = z.object({
|
|
31
|
+
name: z.string(),
|
|
32
|
+
description: z.string().optional(),
|
|
33
|
+
tools: z.array(ToolSchema).optional(),
|
|
34
|
+
include: z.array(LoadoutIncludeSchema),
|
|
35
|
+
});
|
|
36
|
+
export const ManifestEntrySchema = z.object({
|
|
37
|
+
tools: z.array(ToolSchema),
|
|
38
|
+
kind: ArtifactKindSchema,
|
|
39
|
+
sourcePath: z.string(),
|
|
40
|
+
targetPath: z.string(),
|
|
41
|
+
mode: OutputModeSchema,
|
|
42
|
+
renderedHash: z.string(),
|
|
43
|
+
});
|
|
44
|
+
// Legacy schema for single-tool entries (pre-multi-tool format)
|
|
45
|
+
export const LegacyManifestEntrySchema = z.object({
|
|
46
|
+
tool: ToolSchema,
|
|
47
|
+
kind: ArtifactKindSchema,
|
|
48
|
+
sourcePath: z.string(),
|
|
49
|
+
targetPath: z.string(),
|
|
50
|
+
mode: OutputModeSchema,
|
|
51
|
+
renderedHash: z.string(),
|
|
52
|
+
});
|
|
53
|
+
export const ShadowedEntrySchema = z.object({
|
|
54
|
+
tool: ToolSchema,
|
|
55
|
+
kind: ArtifactKindSchema,
|
|
56
|
+
sourcePath: z.string(),
|
|
57
|
+
targetPath: z.string(),
|
|
58
|
+
});
|
|
59
|
+
export const AppliedStateSchema = z.object({
|
|
60
|
+
active: z.array(z.string()), // Set of active loadout names
|
|
61
|
+
mode: OutputModeSchema,
|
|
62
|
+
appliedAt: z.string(),
|
|
63
|
+
entries: z.array(ManifestEntrySchema),
|
|
64
|
+
shadowed: z.array(ShadowedEntrySchema).default([]),
|
|
65
|
+
});
|
|
66
|
+
// Legacy schema for migration from single-loadout format
|
|
67
|
+
export const LegacyAppliedStateSchema = z.object({
|
|
68
|
+
loadout: z.string(),
|
|
69
|
+
mode: OutputModeSchema,
|
|
70
|
+
appliedAt: z.string(),
|
|
71
|
+
entries: z.array(LegacyManifestEntrySchema),
|
|
72
|
+
shadowed: z.array(ShadowedEntrySchema).default([]),
|
|
73
|
+
});
|
|
74
|
+
// Rule frontmatter
|
|
75
|
+
export const RuleFrontmatterSchema = z.object({
|
|
76
|
+
description: z.string().optional(),
|
|
77
|
+
paths: z.array(z.string()).optional(),
|
|
78
|
+
globs: z.array(z.string()).optional(),
|
|
79
|
+
alwaysApply: z.boolean().optional(),
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0EAA0E;AAC1E,qDAAqD;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAExE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CA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AC,KAAK,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACnD,CAAC,CAAC;AAEH,mBAAmB;AACnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACrC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACrC,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified scope resolution for all commands.
|
|
3
|
+
*
|
|
4
|
+
* Scope flags:
|
|
5
|
+
* -l / --local → project scope only (error if not in a project)
|
|
6
|
+
* -g / --global → global scope only
|
|
7
|
+
* -a / --all → both scopes
|
|
8
|
+
* (none) → both scopes (show everything by default)
|
|
9
|
+
*
|
|
10
|
+
* For commands that target a specific loadout by name, collision detection
|
|
11
|
+
* requires explicit scope when the same name exists in both scopes.
|
|
12
|
+
*/
|
|
13
|
+
import type { Scope, CommandContext } from "./types.js";
|
|
14
|
+
export interface ScopeFlags {
|
|
15
|
+
local?: boolean;
|
|
16
|
+
global?: boolean;
|
|
17
|
+
all?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ScopeResolution {
|
|
20
|
+
scopes: Scope[];
|
|
21
|
+
contexts: CommandContext[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Check if we're currently in a loadout project.
|
|
25
|
+
* Returns true only if there's a project-level .loadouts/ directory
|
|
26
|
+
* (not just global or bundled).
|
|
27
|
+
*/
|
|
28
|
+
export declare function inProject(cwd?: string): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a global loadout root exists.
|
|
31
|
+
*/
|
|
32
|
+
export declare function hasGlobal(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve scope flags to a list of scopes.
|
|
35
|
+
* Default (no flags) = all available scopes.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveScopes(flags: ScopeFlags, cwd?: string): Promise<Scope[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve scope flags to CommandContexts.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveContexts(flags: ScopeFlags, cwd?: string): Promise<ScopeResolution>;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a loadout name exists in a given scope.
|
|
44
|
+
*/
|
|
45
|
+
export declare function loadoutExistsInScope(name: string, scope: Scope): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Detect if a loadout name exists in multiple scopes (collision).
|
|
48
|
+
* Returns the scopes where it exists.
|
|
49
|
+
*
|
|
50
|
+
* Note: Bundled loadouts are available in both scopes, but we treat them
|
|
51
|
+
* as "project" scope for resolution purposes when in a project, else "global".
|
|
52
|
+
*/
|
|
53
|
+
export declare function detectCollision(name: string, cwd?: string): Promise<Scope[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Require explicit scope when a loadout name exists in both scopes.
|
|
56
|
+
* Throws if ambiguous; returns the single scope to use if unambiguous.
|
|
57
|
+
*/
|
|
58
|
+
export declare function requireScopeForName(name: string, flags: ScopeFlags, cwd?: string): Promise<Scope>;
|
|
59
|
+
/**
|
|
60
|
+
* For commands that operate on multiple loadouts (activate, deactivate),
|
|
61
|
+
* validate that all names resolve unambiguously given the scope flags.
|
|
62
|
+
*
|
|
63
|
+
* Returns a map of name -> scope for each loadout.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveLoadoutScopes(names: string[], flags: ScopeFlags, cwd?: string): Promise<Map<string, Scope>>;
|
|
66
|
+
/**
|
|
67
|
+
* Standard scope flag definitions for Commander.
|
|
68
|
+
*/
|
|
69
|
+
export declare const SCOPE_FLAGS: {
|
|
70
|
+
local: readonly ["-l, --local", "Project scope only"];
|
|
71
|
+
global: readonly ["-g, --global", "Global scope only"];
|
|
72
|
+
all: readonly ["-a, --all", "All scopes"];
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/core/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAK7E;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,UAAU,EACjB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,KAAK,EAAE,CAAC,CAgClB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,UAAU,EACjB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,eAAe,CAAC,CAS1B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAUxE;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,KAAK,EAAE,CAAC,CAqClB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,UAAU,EACjB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,KAAK,CAAC,CAoBhB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,UAAU,EACjB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAS7B;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;;;;CAIvB,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified scope resolution for all commands.
|
|
3
|
+
*
|
|
4
|
+
* Scope flags:
|
|
5
|
+
* -l / --local → project scope only (error if not in a project)
|
|
6
|
+
* -g / --global → global scope only
|
|
7
|
+
* -a / --all → both scopes
|
|
8
|
+
* (none) → both scopes (show everything by default)
|
|
9
|
+
*
|
|
10
|
+
* For commands that target a specific loadout by name, collision detection
|
|
11
|
+
* requires explicit scope when the same name exists in both scopes.
|
|
12
|
+
*/
|
|
13
|
+
import { getContext, findNearestLoadoutRoot, getGlobalRoot, getBundledRoot } from "./discovery.js";
|
|
14
|
+
import { isProjectScope } from "../lib/artifact-paths.js";
|
|
15
|
+
import { listLoadouts } from "./config.js";
|
|
16
|
+
/**
|
|
17
|
+
* Check if we're currently in a loadout project.
|
|
18
|
+
* Returns true only if there's a project-level .loadouts/ directory
|
|
19
|
+
* (not just global or bundled).
|
|
20
|
+
*/
|
|
21
|
+
export async function inProject(cwd = process.cwd()) {
|
|
22
|
+
const root = await findNearestLoadoutRoot(cwd);
|
|
23
|
+
// Only count as "in project" if we found a project-level root
|
|
24
|
+
// (global and bundled roots don't count)
|
|
25
|
+
return root !== null && isProjectScope(root.level);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if a global loadout root exists.
|
|
29
|
+
*/
|
|
30
|
+
export function hasGlobal() {
|
|
31
|
+
return getGlobalRoot() !== null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve scope flags to a list of scopes.
|
|
35
|
+
* Default (no flags) = all available scopes.
|
|
36
|
+
*/
|
|
37
|
+
export async function resolveScopes(flags, cwd = process.cwd()) {
|
|
38
|
+
const hasProject = await inProject(cwd);
|
|
39
|
+
const hasGlobalRoot = hasGlobal();
|
|
40
|
+
// Explicit --local
|
|
41
|
+
if (flags.local) {
|
|
42
|
+
if (!hasProject) {
|
|
43
|
+
throw new Error("Not in a loadout project. Run 'loadouts init' first.");
|
|
44
|
+
}
|
|
45
|
+
return ["project"];
|
|
46
|
+
}
|
|
47
|
+
// Explicit --global
|
|
48
|
+
if (flags.global) {
|
|
49
|
+
if (!hasGlobalRoot) {
|
|
50
|
+
throw new Error("No global loadout found at ~/.config/loadouts");
|
|
51
|
+
}
|
|
52
|
+
return ["global"];
|
|
53
|
+
}
|
|
54
|
+
// Explicit --all, or default (no flags) = everything available
|
|
55
|
+
const scopes = [];
|
|
56
|
+
if (hasProject)
|
|
57
|
+
scopes.push("project");
|
|
58
|
+
if (hasGlobalRoot)
|
|
59
|
+
scopes.push("global");
|
|
60
|
+
if (scopes.length === 0) {
|
|
61
|
+
throw new Error("No loadout found. Run 'loadouts init' or 'loadouts init --global'.");
|
|
62
|
+
}
|
|
63
|
+
return scopes;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolve scope flags to CommandContexts.
|
|
67
|
+
*/
|
|
68
|
+
export async function resolveContexts(flags, cwd = process.cwd()) {
|
|
69
|
+
const scopes = await resolveScopes(flags, cwd);
|
|
70
|
+
const contexts = [];
|
|
71
|
+
for (const scope of scopes) {
|
|
72
|
+
contexts.push(await getContext(scope, cwd));
|
|
73
|
+
}
|
|
74
|
+
return { scopes, contexts };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if a loadout name exists in a given scope.
|
|
78
|
+
*/
|
|
79
|
+
export function loadoutExistsInScope(name, scope) {
|
|
80
|
+
if (scope === "global") {
|
|
81
|
+
const globalRoot = getGlobalRoot();
|
|
82
|
+
if (!globalRoot)
|
|
83
|
+
return false;
|
|
84
|
+
return listLoadouts(globalRoot.path).includes(name);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// For project scope, we need to check synchronously
|
|
88
|
+
// This is a simplified check - full resolution happens in commands
|
|
89
|
+
return true; // Let the command handle the actual check
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Detect if a loadout name exists in multiple scopes (collision).
|
|
94
|
+
* Returns the scopes where it exists.
|
|
95
|
+
*
|
|
96
|
+
* Note: Bundled loadouts are available in both scopes, but we treat them
|
|
97
|
+
* as "project" scope for resolution purposes when in a project, else "global".
|
|
98
|
+
*/
|
|
99
|
+
export async function detectCollision(name, cwd = process.cwd()) {
|
|
100
|
+
const found = [];
|
|
101
|
+
const hasProjectRoot = await inProject(cwd);
|
|
102
|
+
// Check project scope
|
|
103
|
+
if (hasProjectRoot) {
|
|
104
|
+
const projectRoot = await findNearestLoadoutRoot(cwd);
|
|
105
|
+
if (projectRoot) {
|
|
106
|
+
const projectLoadouts = listLoadouts(projectRoot.path);
|
|
107
|
+
if (projectLoadouts.includes(name)) {
|
|
108
|
+
found.push("project");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Check global scope
|
|
113
|
+
const globalRoot = getGlobalRoot();
|
|
114
|
+
if (globalRoot) {
|
|
115
|
+
const globalLoadouts = listLoadouts(globalRoot.path);
|
|
116
|
+
if (globalLoadouts.includes(name)) {
|
|
117
|
+
found.push("global");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Check bundled root - bundled loadouts are always global scope
|
|
121
|
+
// (they're tools that ship with loadout, not project-specific)
|
|
122
|
+
if (found.length === 0) {
|
|
123
|
+
const bundledRoot = getBundledRoot();
|
|
124
|
+
if (bundledRoot) {
|
|
125
|
+
const bundledLoadouts = listLoadouts(bundledRoot.path);
|
|
126
|
+
if (bundledLoadouts.includes(name)) {
|
|
127
|
+
found.push("global");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return found;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Require explicit scope when a loadout name exists in both scopes.
|
|
135
|
+
* Throws if ambiguous; returns the single scope to use if unambiguous.
|
|
136
|
+
*/
|
|
137
|
+
export async function requireScopeForName(name, flags, cwd = process.cwd()) {
|
|
138
|
+
// If explicit scope given, use it
|
|
139
|
+
if (flags.local)
|
|
140
|
+
return "project";
|
|
141
|
+
if (flags.global)
|
|
142
|
+
return "global";
|
|
143
|
+
// Check for collision
|
|
144
|
+
const collision = await detectCollision(name, cwd);
|
|
145
|
+
if (collision.length > 1) {
|
|
146
|
+
throw new Error(`Loadout '${name}' exists in both project and global scope. ` +
|
|
147
|
+
`Use -l/--local or -g/--global to specify which one.`);
|
|
148
|
+
}
|
|
149
|
+
if (collision.length === 0) {
|
|
150
|
+
throw new Error(`Loadout '${name}' not found in any scope.`);
|
|
151
|
+
}
|
|
152
|
+
return collision[0];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* For commands that operate on multiple loadouts (activate, deactivate),
|
|
156
|
+
* validate that all names resolve unambiguously given the scope flags.
|
|
157
|
+
*
|
|
158
|
+
* Returns a map of name -> scope for each loadout.
|
|
159
|
+
*/
|
|
160
|
+
export async function resolveLoadoutScopes(names, flags, cwd = process.cwd()) {
|
|
161
|
+
const result = new Map();
|
|
162
|
+
for (const name of names) {
|
|
163
|
+
const scope = await requireScopeForName(name, flags, cwd);
|
|
164
|
+
result.set(name, scope);
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Standard scope flag definitions for Commander.
|
|
170
|
+
*/
|
|
171
|
+
export const SCOPE_FLAGS = {
|
|
172
|
+
local: ["-l, --local", "Project scope only"],
|
|
173
|
+
global: ["-g, --global", "Global scope only"],
|
|
174
|
+
all: ["-a, --all", "All scopes"],
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/core/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAc3C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IACzD,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC/C,8DAA8D;IAC9D,yCAAyC;IACzC,OAAO,IAAI,KAAK,IAAI,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,aAAa,EAAE,KAAK,IAAI,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAiB,EACjB,MAAc,OAAO,CAAC,GAAG,EAAE;IAE3B,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,aAAa,GAAG,SAAS,EAAE,CAAC;IAElC,mBAAmB;IACnB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAED,o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