@procedures/cue 0.0.0-stage → 0.2.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/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +71 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +22 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +127 -0
- package/dist/module.js.map +1 -0
- package/dist/procedures/cue/add.d.ts +13 -0
- package/dist/procedures/cue/add.d.ts.map +1 -0
- package/dist/procedures/cue/add.js +63 -0
- package/dist/procedures/cue/add.js.map +1 -0
- package/dist/procedures/cue/generate.d.ts +14 -0
- package/dist/procedures/cue/generate.d.ts.map +1 -0
- package/dist/procedures/cue/generate.js +189 -0
- package/dist/procedures/cue/generate.js.map +1 -0
- package/dist/procedures/cue/index.d.ts +6 -0
- package/dist/procedures/cue/index.d.ts.map +1 -0
- package/dist/procedures/cue/index.js +6 -0
- package/dist/procedures/cue/index.js.map +1 -0
- package/dist/procedures/cue/init.d.ts +13 -0
- package/dist/procedures/cue/init.d.ts.map +1 -0
- package/dist/procedures/cue/init.js +79 -0
- package/dist/procedures/cue/init.js.map +1 -0
- package/dist/procedures/cue/remove.d.ts +13 -0
- package/dist/procedures/cue/remove.d.ts.map +1 -0
- package/dist/procedures/cue/remove.js +52 -0
- package/dist/procedures/cue/remove.js.map +1 -0
- package/dist/procedures/cue/validate.d.ts +13 -0
- package/dist/procedures/cue/validate.d.ts.map +1 -0
- package/dist/procedures/cue/validate.js +76 -0
- package/dist/procedures/cue/validate.js.map +1 -0
- package/dist/register.d.ts +7 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +9 -0
- package/dist/register.js.map +1 -0
- package/dist/shared.d.ts +39 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +148 -0
- package/dist/shared.js.map +1 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +81 -0
- package/dist/types.js.map +1 -0
- package/package.json +81 -3
- package/src/index.ts +18 -0
- package/src/module.ts +158 -0
- package/src/procedures/cue/add.ts +80 -0
- package/src/procedures/cue/generate.ts +245 -0
- package/src/procedures/cue/index.ts +5 -0
- package/src/procedures/cue/init.ts +98 -0
- package/src/procedures/cue/remove.ts +64 -0
- package/src/procedures/cue/validate.ts +96 -0
- package/src/register.ts +11 -0
- package/src/shared.ts +216 -0
- package/src/types.ts +181 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cue.validate procedure
|
|
3
|
+
*
|
|
4
|
+
* Validate dependencies.json against schema.
|
|
5
|
+
* Uses ctx.client.call() for file system operations (dogfooding).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { resolve } from "node:path";
|
|
9
|
+
import type { ProcedureContext } from "@procedures/client";
|
|
10
|
+
import type { CueValidateInput, CueValidateOutput } from "../../types.js";
|
|
11
|
+
import {
|
|
12
|
+
loadFeatures,
|
|
13
|
+
loadDependencies,
|
|
14
|
+
checkCue,
|
|
15
|
+
runCue,
|
|
16
|
+
packageRoot,
|
|
17
|
+
fileExists,
|
|
18
|
+
} from "../../shared.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Validate dependencies.json
|
|
22
|
+
*/
|
|
23
|
+
export async function cueValidate(
|
|
24
|
+
input: CueValidateInput,
|
|
25
|
+
ctx: ProcedureContext
|
|
26
|
+
): Promise<CueValidateOutput> {
|
|
27
|
+
const projectPath = input.cwd ?? process.cwd();
|
|
28
|
+
const errors: string[] = [];
|
|
29
|
+
|
|
30
|
+
// Load dependencies
|
|
31
|
+
const deps = await loadDependencies(projectPath, ctx);
|
|
32
|
+
if (!deps) {
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
valid: false,
|
|
36
|
+
features: [],
|
|
37
|
+
errors: ["No dependencies.json found. Run cue.init first."],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Load features manifest
|
|
42
|
+
const manifest = await loadFeatures(ctx);
|
|
43
|
+
if (!manifest) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
valid: false,
|
|
47
|
+
features: deps,
|
|
48
|
+
errors: ["Could not load features.json from @mark1russell7/cue package"],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Validate each feature exists
|
|
53
|
+
for (const feature of deps) {
|
|
54
|
+
if (!manifest.features[feature]) {
|
|
55
|
+
errors.push(`Unknown feature: '${feature}'`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (errors.length > 0) {
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
valid: false,
|
|
63
|
+
features: deps,
|
|
64
|
+
errors,
|
|
65
|
+
message: `Validation failed with ${errors.length} error(s)`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// If CUE is available, validate against schema
|
|
70
|
+
if (await checkCue(ctx.signal)) {
|
|
71
|
+
const schemaPath = resolve(packageRoot, "dependencies/schema.cue");
|
|
72
|
+
if (await fileExists(schemaPath, ctx)) {
|
|
73
|
+
const depsPath = resolve(projectPath, "dependencies.json");
|
|
74
|
+
const result = await runCue(["vet", "-d", "#Dependencies", schemaPath, depsPath], { signal: ctx.signal });
|
|
75
|
+
|
|
76
|
+
if (!result.success) {
|
|
77
|
+
errors.push(`CUE schema validation failed: ${result.stderr || result.stdout}`);
|
|
78
|
+
return {
|
|
79
|
+
success: true,
|
|
80
|
+
valid: false,
|
|
81
|
+
features: deps,
|
|
82
|
+
errors,
|
|
83
|
+
message: "CUE schema validation failed",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
valid: true,
|
|
92
|
+
features: deps,
|
|
93
|
+
errors: [],
|
|
94
|
+
message: "Validation passed",
|
|
95
|
+
};
|
|
96
|
+
}
|
package/src/register.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Importing this file registers the procedures of @procedures/cue, and of the modules that it
|
|
3
|
+
* requires, in the global registry: `import "@procedures/cue/register"`. The package root and the
|
|
4
|
+
* `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { registerCueProcedures } from "./module.js";
|
|
8
|
+
|
|
9
|
+
export * from "./module.js";
|
|
10
|
+
|
|
11
|
+
registerCueProcedures();
|
package/src/shared.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for cue procedures
|
|
3
|
+
*
|
|
4
|
+
* Uses ctx.client.call() for file system operations (dogfooding).
|
|
5
|
+
*
|
|
6
|
+
* A file operation that fails is an error of the call. Only a missing file is a normal result.
|
|
7
|
+
* (Before, each helper turned every error into "missing": with no fs.* procedures in the host,
|
|
8
|
+
* cue.validate answered "No dependencies.json found", deep dive WRP-3.)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
import { dirname, resolve } from "node:path";
|
|
13
|
+
import type { ProcedureContext } from "@procedures/client";
|
|
14
|
+
import { runCommand, type CommandResult } from "@procedures/shell/command";
|
|
15
|
+
import type { FeaturesManifest, DependenciesJson } from "./types.js";
|
|
16
|
+
|
|
17
|
+
// Constants
|
|
18
|
+
// The root of the installed @mark1russell7/cue package (its CUE files and features.json).
|
|
19
|
+
// Resolve it like an import, so it works wherever the package manager put it
|
|
20
|
+
// (BUGS-2026-07 H32: a hard-coded node_modules path only worked for a dev install).
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
export const packageRoot: string = dirname(require.resolve("@mark1russell7/cue/features.json"));
|
|
23
|
+
|
|
24
|
+
// Tsconfig priority: later features override earlier (most specific wins)
|
|
25
|
+
export const TSCONFIG_PRIORITY: readonly string[] = ["ts", "node", "node-cjs", "vite", "react"] as const;
|
|
26
|
+
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// FS Procedure Output Types
|
|
29
|
+
// =============================================================================
|
|
30
|
+
|
|
31
|
+
interface FsExistsOutput {
|
|
32
|
+
exists: boolean;
|
|
33
|
+
path: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface FsReadOutput {
|
|
37
|
+
path: string;
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface FsWriteOutput {
|
|
42
|
+
path: string;
|
|
43
|
+
written: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface FsMkdirOutput {
|
|
47
|
+
path: string;
|
|
48
|
+
created: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// =============================================================================
|
|
52
|
+
// File System Helpers (using ctx.client.call)
|
|
53
|
+
// =============================================================================
|
|
54
|
+
|
|
55
|
+
export async function fileExists(path: string, ctx: ProcedureContext): Promise<boolean> {
|
|
56
|
+
const result = await ctx.client.call<{ path: string }, FsExistsOutput>(
|
|
57
|
+
["fs", "exists"],
|
|
58
|
+
{ path }
|
|
59
|
+
);
|
|
60
|
+
return result.exists;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The content of a file, or null when the file does not exist. Other failures throw. */
|
|
64
|
+
export async function readFile(path: string, ctx: ProcedureContext): Promise<string | null> {
|
|
65
|
+
if (!(await fileExists(path, ctx))) return null;
|
|
66
|
+
const result = await ctx.client.call<{ path: string; encoding?: string }, FsReadOutput>(
|
|
67
|
+
["fs", "read"],
|
|
68
|
+
{ path, encoding: "utf-8" }
|
|
69
|
+
);
|
|
70
|
+
return result.content;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function writeFile(path: string, content: string, ctx: ProcedureContext): Promise<boolean> {
|
|
74
|
+
try {
|
|
75
|
+
await ctx.client.call<{ path: string; content: string }, FsWriteOutput>(
|
|
76
|
+
["fs", "write"],
|
|
77
|
+
{ path, content }
|
|
78
|
+
);
|
|
79
|
+
return true;
|
|
80
|
+
} catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function mkdir(path: string, ctx: ProcedureContext): Promise<boolean> {
|
|
86
|
+
try {
|
|
87
|
+
await ctx.client.call<{ path: string; recursive?: boolean }, FsMkdirOutput>(
|
|
88
|
+
["fs", "mkdir"],
|
|
89
|
+
{ path, recursive: true }
|
|
90
|
+
);
|
|
91
|
+
return true;
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// =============================================================================
|
|
98
|
+
// JSON Helpers
|
|
99
|
+
// =============================================================================
|
|
100
|
+
|
|
101
|
+
/** The JSON content of a file, or null when the file does not exist. Text that is not JSON throws. */
|
|
102
|
+
export async function readJson<T>(path: string, ctx: ProcedureContext): Promise<T | null> {
|
|
103
|
+
const content = await readFile(path, ctx);
|
|
104
|
+
if (content === null) return null;
|
|
105
|
+
try {
|
|
106
|
+
return JSON.parse(content) as T;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
throw new Error(`${path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function writeJson<T>(path: string, data: T, ctx: ProcedureContext): Promise<boolean> {
|
|
113
|
+
const content = JSON.stringify(data, null, 2) + "\n";
|
|
114
|
+
return writeFile(path, content, ctx);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// =============================================================================
|
|
118
|
+
// Core Functions
|
|
119
|
+
// =============================================================================
|
|
120
|
+
|
|
121
|
+
export async function loadFeatures(ctx: ProcedureContext): Promise<FeaturesManifest | null> {
|
|
122
|
+
const featuresPath = resolve(packageRoot, "features.json");
|
|
123
|
+
return readJson<FeaturesManifest>(featuresPath, ctx);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export async function loadDependencies(
|
|
127
|
+
projectPath: string,
|
|
128
|
+
ctx: ProcedureContext
|
|
129
|
+
): Promise<string[] | null> {
|
|
130
|
+
const depsPath = resolve(projectPath, "dependencies.json");
|
|
131
|
+
const content = await readJson<DependenciesJson | string[]>(depsPath, ctx);
|
|
132
|
+
|
|
133
|
+
if (!content) return null;
|
|
134
|
+
|
|
135
|
+
if (Array.isArray(content)) {
|
|
136
|
+
return content;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (content.dependencies && Array.isArray(content.dependencies)) {
|
|
140
|
+
return content.dependencies;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export async function saveDependencies(
|
|
147
|
+
deps: string[],
|
|
148
|
+
projectPath: string,
|
|
149
|
+
ctx: ProcedureContext
|
|
150
|
+
): Promise<boolean> {
|
|
151
|
+
const depsJson: DependenciesJson = {
|
|
152
|
+
$schema: "./node_modules/@mark1russell7/cue/dependencies/schema.json",
|
|
153
|
+
dependencies: deps,
|
|
154
|
+
};
|
|
155
|
+
return writeJson(resolve(projectPath, "dependencies.json"), depsJson, ctx);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Flood-fill resolve all transitive dependencies
|
|
159
|
+
export function resolveFeatures(requested: string[], manifest: FeaturesManifest): string[] {
|
|
160
|
+
const resolved = new Set<string>();
|
|
161
|
+
const queue = [...requested];
|
|
162
|
+
|
|
163
|
+
while (queue.length > 0) {
|
|
164
|
+
const feature = queue.shift()!;
|
|
165
|
+
if (resolved.has(feature)) continue;
|
|
166
|
+
|
|
167
|
+
const featureDef = manifest.features[feature];
|
|
168
|
+
if (!featureDef) continue;
|
|
169
|
+
|
|
170
|
+
resolved.add(feature);
|
|
171
|
+
|
|
172
|
+
for (const dep of featureDef.dependencies) {
|
|
173
|
+
if (!resolved.has(dep)) {
|
|
174
|
+
queue.push(dep);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return Array.from(resolved);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Map feature name to CUE file field name (handle vite-react -> viteReact)
|
|
183
|
+
export function featureToFieldName(feature: string): string {
|
|
184
|
+
if (feature === "vite-react") return "viteReact";
|
|
185
|
+
return feature;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// =============================================================================
|
|
189
|
+
// CUE Evaluation
|
|
190
|
+
// =============================================================================
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* This function runs the cue program with an argument list and no shell, through `runCommand`
|
|
194
|
+
* of client-shell: async, and the signal of the call kills it (roadmap 2.2).
|
|
195
|
+
*/
|
|
196
|
+
export function runCue(
|
|
197
|
+
args: string[],
|
|
198
|
+
options: { cwd?: string | undefined; signal?: AbortSignal | undefined } = {}
|
|
199
|
+
): Promise<CommandResult> {
|
|
200
|
+
return runCommand("cue", { args, cwd: options.cwd, signal: options.signal, timeout: 120_000 });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** True when the cue program is installed. */
|
|
204
|
+
export async function checkCue(signal?: AbortSignal): Promise<boolean> {
|
|
205
|
+
return (await runCue(["version"], { signal })).success;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function determineTsconfig(resolvedFeatures: string[]): string {
|
|
209
|
+
let selected = "ts";
|
|
210
|
+
for (const feature of TSCONFIG_PRIORITY) {
|
|
211
|
+
if (resolvedFeatures.includes(feature)) {
|
|
212
|
+
selected = feature;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return selected;
|
|
216
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and schemas for cue procedures
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Shared Types
|
|
9
|
+
// =============================================================================
|
|
10
|
+
|
|
11
|
+
export interface Feature {
|
|
12
|
+
dependencies: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FeaturesManifest {
|
|
16
|
+
features: Record<string, Feature>;
|
|
17
|
+
presets: Record<string, string[]>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DependenciesJson {
|
|
21
|
+
$schema?: string;
|
|
22
|
+
dependencies: string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// cue.init
|
|
27
|
+
// =============================================================================
|
|
28
|
+
|
|
29
|
+
export const CueInitInputSchema: z.ZodObject<{
|
|
30
|
+
preset: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
31
|
+
force: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
32
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}> = z.object({
|
|
34
|
+
preset: z.string().optional().default("lib").describe("The preset: lib, react-lib or app"),
|
|
35
|
+
force: z.boolean().optional().default(false).describe("Write dependencies.json again when it exists"),
|
|
36
|
+
cwd: z.string().optional().describe("The folder of the package (default: the current folder)"),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type CueInitInput = z.infer<typeof CueInitInputSchema>;
|
|
40
|
+
|
|
41
|
+
export interface CueInitOutput {
|
|
42
|
+
success: boolean;
|
|
43
|
+
preset: string;
|
|
44
|
+
created: string[];
|
|
45
|
+
message?: string | undefined;
|
|
46
|
+
error?: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// cue.add
|
|
51
|
+
// =============================================================================
|
|
52
|
+
|
|
53
|
+
export const CueAddInputSchema: z.ZodObject<{
|
|
54
|
+
feature: z.ZodString;
|
|
55
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}> = z.object({
|
|
57
|
+
feature: z.string().describe("The feature: git, npm, ts, node, node-cjs, react, vite, vite-react, cue or vitest"),
|
|
58
|
+
cwd: z.string().optional().describe("The folder of the package (default: the current folder)"),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export type CueAddInput = z.infer<typeof CueAddInputSchema>;
|
|
62
|
+
|
|
63
|
+
export interface CueAddOutput {
|
|
64
|
+
success: boolean;
|
|
65
|
+
feature: string;
|
|
66
|
+
added: boolean;
|
|
67
|
+
message?: string | undefined;
|
|
68
|
+
error?: string | undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// cue.remove
|
|
73
|
+
// =============================================================================
|
|
74
|
+
|
|
75
|
+
export const CueRemoveInputSchema: z.ZodObject<{
|
|
76
|
+
feature: z.ZodString;
|
|
77
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}> = z.object({
|
|
79
|
+
feature: z.string().describe("The feature: git, npm, ts, node, node-cjs, react, vite, vite-react, cue or vitest"),
|
|
80
|
+
cwd: z.string().optional().describe("The folder of the package (default: the current folder)"),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export type CueRemoveInput = z.infer<typeof CueRemoveInputSchema>;
|
|
84
|
+
|
|
85
|
+
export interface CueRemoveOutput {
|
|
86
|
+
success: boolean;
|
|
87
|
+
feature: string;
|
|
88
|
+
removed: boolean;
|
|
89
|
+
message?: string | undefined;
|
|
90
|
+
error?: string | undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// =============================================================================
|
|
94
|
+
// cue.generate
|
|
95
|
+
// =============================================================================
|
|
96
|
+
|
|
97
|
+
export const CueGenerateInputSchema: z.ZodObject<{
|
|
98
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}> = z.object({
|
|
100
|
+
cwd: z.string().optional().describe("The folder of the package (default: the current folder)"),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export type CueGenerateInput = z.infer<typeof CueGenerateInputSchema>;
|
|
104
|
+
|
|
105
|
+
export interface CueGenerateOutput {
|
|
106
|
+
success: boolean;
|
|
107
|
+
resolvedFeatures: string[];
|
|
108
|
+
generated: string[];
|
|
109
|
+
message?: string | undefined;
|
|
110
|
+
error?: string | undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// =============================================================================
|
|
114
|
+
// cue.validate
|
|
115
|
+
// =============================================================================
|
|
116
|
+
|
|
117
|
+
export const CueValidateInputSchema: z.ZodObject<{
|
|
118
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}> = z.object({
|
|
120
|
+
cwd: z.string().optional().describe("The folder of the package (default: the current folder)"),
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export type CueValidateInput = z.infer<typeof CueValidateInputSchema>;
|
|
124
|
+
|
|
125
|
+
export interface CueValidateOutput {
|
|
126
|
+
success: boolean;
|
|
127
|
+
valid: boolean;
|
|
128
|
+
features: string[];
|
|
129
|
+
errors: string[];
|
|
130
|
+
message?: string | undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// =============================================================================
|
|
134
|
+
// Output schemas (roadmap 2.1)
|
|
135
|
+
// =============================================================================
|
|
136
|
+
|
|
137
|
+
// Loose objects: a field that a schema does not name stays in the result (a strict schema
|
|
138
|
+
// would remove it when the output is validated).
|
|
139
|
+
|
|
140
|
+
const messageField = z.string().optional().describe("A message about the result");
|
|
141
|
+
const errorField = z.string().optional().describe("The reason of a failure (when success is false)");
|
|
142
|
+
|
|
143
|
+
export const CueInitOutputSchema: z.ZodType<CueInitOutput> = z.looseObject({
|
|
144
|
+
success: z.boolean().describe("True when dependencies.json exists after the call"),
|
|
145
|
+
preset: z.string().describe("The preset of the new dependencies.json"),
|
|
146
|
+
created: z.array(z.string()).describe("The files that the call made"),
|
|
147
|
+
message: messageField,
|
|
148
|
+
error: errorField,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export const CueAddOutputSchema: z.ZodType<CueAddOutput> = z.looseObject({
|
|
152
|
+
success: z.boolean().describe("True when the feature is in dependencies.json after the call"),
|
|
153
|
+
feature: z.string().describe("The feature"),
|
|
154
|
+
added: z.boolean().describe("True when the call added the feature (false when it was there already)"),
|
|
155
|
+
message: messageField,
|
|
156
|
+
error: errorField,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export const CueRemoveOutputSchema: z.ZodType<CueRemoveOutput> = z.looseObject({
|
|
160
|
+
success: z.boolean().describe("True when the feature is not in dependencies.json after the call"),
|
|
161
|
+
feature: z.string().describe("The feature"),
|
|
162
|
+
removed: z.boolean().describe("True when the call removed the feature"),
|
|
163
|
+
message: messageField,
|
|
164
|
+
error: errorField,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const CueGenerateOutputSchema: z.ZodType<CueGenerateOutput> = z.looseObject({
|
|
168
|
+
success: z.boolean().describe("True when every file was generated"),
|
|
169
|
+
resolvedFeatures: z.array(z.string()).describe("The features with their dependencies"),
|
|
170
|
+
generated: z.array(z.string()).describe("The files that the call wrote"),
|
|
171
|
+
message: messageField,
|
|
172
|
+
error: errorField,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export const CueValidateOutputSchema: z.ZodType<CueValidateOutput> = z.looseObject({
|
|
176
|
+
success: z.boolean().describe("True when the validation ran"),
|
|
177
|
+
valid: z.boolean().describe("True when dependencies.json is valid"),
|
|
178
|
+
features: z.array(z.string()).describe("The features of dependencies.json"),
|
|
179
|
+
errors: z.array(z.string()).describe("The problems that the validation found"),
|
|
180
|
+
message: messageField,
|
|
181
|
+
});
|