@procedures/cue 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +71 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/index.d.ts +13 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +16 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/module.d.ts +16 -0
  10. package/dist/module.d.ts.map +1 -0
  11. package/dist/module.js +110 -0
  12. package/dist/module.js.map +1 -0
  13. package/dist/procedures/cue/add.d.ts +13 -0
  14. package/dist/procedures/cue/add.d.ts.map +1 -0
  15. package/dist/procedures/cue/add.js +63 -0
  16. package/dist/procedures/cue/add.js.map +1 -0
  17. package/dist/procedures/cue/generate.d.ts +14 -0
  18. package/dist/procedures/cue/generate.d.ts.map +1 -0
  19. package/dist/procedures/cue/generate.js +189 -0
  20. package/dist/procedures/cue/generate.js.map +1 -0
  21. package/dist/procedures/cue/index.d.ts +6 -0
  22. package/dist/procedures/cue/index.d.ts.map +1 -0
  23. package/dist/procedures/cue/index.js +6 -0
  24. package/dist/procedures/cue/index.js.map +1 -0
  25. package/dist/procedures/cue/init.d.ts +13 -0
  26. package/dist/procedures/cue/init.d.ts.map +1 -0
  27. package/dist/procedures/cue/init.js +79 -0
  28. package/dist/procedures/cue/init.js.map +1 -0
  29. package/dist/procedures/cue/remove.d.ts +13 -0
  30. package/dist/procedures/cue/remove.d.ts.map +1 -0
  31. package/dist/procedures/cue/remove.js +52 -0
  32. package/dist/procedures/cue/remove.js.map +1 -0
  33. package/dist/procedures/cue/validate.d.ts +13 -0
  34. package/dist/procedures/cue/validate.d.ts.map +1 -0
  35. package/dist/procedures/cue/validate.js +76 -0
  36. package/dist/procedures/cue/validate.js.map +1 -0
  37. package/dist/register.d.ts +9 -0
  38. package/dist/register.d.ts.map +1 -0
  39. package/dist/register.js +17 -0
  40. package/dist/register.js.map +1 -0
  41. package/dist/shared.d.ts +39 -0
  42. package/dist/shared.d.ts.map +1 -0
  43. package/dist/shared.js +148 -0
  44. package/dist/shared.js.map +1 -0
  45. package/dist/types.d.ts +80 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/types.js +81 -0
  48. package/dist/types.js.map +1 -0
  49. package/package.json +78 -3
  50. package/src/index.ts +18 -0
  51. package/src/module.ts +140 -0
  52. package/src/procedures/cue/add.ts +80 -0
  53. package/src/procedures/cue/generate.ts +245 -0
  54. package/src/procedures/cue/index.ts +5 -0
  55. package/src/procedures/cue/init.ts +98 -0
  56. package/src/procedures/cue/remove.ts +64 -0
  57. package/src/procedures/cue/validate.ts +96 -0
  58. package/src/register.ts +21 -0
  59. package/src/shared.ts +216 -0
  60. package/src/types.ts +181 -0
package/dist/module.js ADDED
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Module (no side effects): the procedures of this package as data, for `createRegistry()`.
3
+ *
4
+ * Procedure Registration for cue operations
5
+ *
6
+ * Registers cue.* procedures with the client system.
7
+ * This file is referenced by package.json's client.procedures field.
8
+ */
9
+ import { createProcedure, zodAdapter, defineModule } from "@procedures/client";
10
+ import fsModule from "@procedures/fs/module";
11
+ import { cueInit } from "./procedures/cue/init.js";
12
+ import { cueAdd } from "./procedures/cue/add.js";
13
+ import { cueRemove } from "./procedures/cue/remove.js";
14
+ import { cueGenerate } from "./procedures/cue/generate.js";
15
+ import { cueValidate } from "./procedures/cue/validate.js";
16
+ import { CueInitInputSchema, CueAddInputSchema, CueRemoveInputSchema, CueGenerateInputSchema, CueValidateInputSchema, CueInitOutputSchema, CueAddOutputSchema, CueRemoveOutputSchema, CueGenerateOutputSchema, CueValidateOutputSchema, } from "./types.js";
17
+ // =============================================================================
18
+ // Procedure Definitions
19
+ // =============================================================================
20
+ const cueInitProcedure = createProcedure()
21
+ .path(["cue", "init"])
22
+ .input(zodAdapter(CueInitInputSchema))
23
+ .output(zodAdapter(CueInitOutputSchema))
24
+ .meta({
25
+ description: "Initialize dependencies.json with a preset",
26
+ calls: ["fs.exists", "fs.read", "fs.write", "fs.mkdir"],
27
+ args: [],
28
+ shorts: { preset: "p", force: "f", cwd: "C" },
29
+ output: "json",
30
+ })
31
+ .handler(async (input, ctx) => {
32
+ return cueInit(input, ctx);
33
+ })
34
+ .build();
35
+ const cueAddProcedure = createProcedure()
36
+ .path(["cue", "add"])
37
+ .input(zodAdapter(CueAddInputSchema))
38
+ .output(zodAdapter(CueAddOutputSchema))
39
+ .meta({
40
+ description: "Add a feature to dependencies.json",
41
+ calls: ["fs.exists", "fs.read", "fs.write"],
42
+ args: ["feature"],
43
+ shorts: { cwd: "C" },
44
+ output: "json",
45
+ })
46
+ .handler(async (input, ctx) => {
47
+ return cueAdd(input, ctx);
48
+ })
49
+ .build();
50
+ const cueRemoveProcedure = createProcedure()
51
+ .path(["cue", "remove"])
52
+ .input(zodAdapter(CueRemoveInputSchema))
53
+ .output(zodAdapter(CueRemoveOutputSchema))
54
+ .meta({
55
+ description: "Remove a feature from dependencies.json",
56
+ calls: ["fs.exists", "fs.read", "fs.write"],
57
+ args: ["feature"],
58
+ shorts: { cwd: "C" },
59
+ output: "json",
60
+ })
61
+ .handler(async (input, ctx) => {
62
+ return cueRemove(input, ctx);
63
+ })
64
+ .build();
65
+ const cueGenerateProcedure = createProcedure()
66
+ .path(["cue", "generate"])
67
+ .input(zodAdapter(CueGenerateInputSchema))
68
+ .output(zodAdapter(CueGenerateOutputSchema))
69
+ .meta({
70
+ description: "Generate config files from dependencies.json",
71
+ calls: ["fs.exists", "fs.read", "fs.write", "fs.mkdir"],
72
+ args: [],
73
+ shorts: { cwd: "C" },
74
+ output: "json",
75
+ })
76
+ .handler(async (input, ctx) => {
77
+ return cueGenerate(input, ctx);
78
+ })
79
+ .build();
80
+ const cueValidateProcedure = createProcedure()
81
+ .path(["cue", "validate"])
82
+ .input(zodAdapter(CueValidateInputSchema))
83
+ .output(zodAdapter(CueValidateOutputSchema))
84
+ .meta({
85
+ description: "Validate dependencies.json",
86
+ calls: ["fs.exists", "fs.read"],
87
+ args: [],
88
+ shorts: { cwd: "C" },
89
+ output: "json",
90
+ })
91
+ .handler(async (input, ctx) => {
92
+ return cueValidate(input, ctx);
93
+ })
94
+ .build();
95
+ // =============================================================================
96
+ // Registration
97
+ // =============================================================================
98
+ /**
99
+ * The module of this package, for `createRegistry()`: its procedures as data. Importing this
100
+ * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
101
+ */
102
+ export const cueModule = defineModule("@procedures/cue", [
103
+ cueInitProcedure,
104
+ cueAddProcedure,
105
+ cueRemoveProcedure,
106
+ cueGenerateProcedure,
107
+ cueValidateProcedure,
108
+ ], [fsModule]);
109
+ export default cueModule;
110
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AACrG,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EAWtB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF,MAAM,gBAAgB,GAAG,eA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,CAAC,CAAC;KAC3D,MAAM,CAAC,UAAU,CAAoB,uBAAuB,CAAC,CAAC;KAC9D,IAAI,CAAC;IACJ,WAAW,EAAE,4BAA4B;IACzC,KAAK,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;IAC/B,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;IACpB,MAAM,EAAE,MAAM;CACf,CAAC;KACD,OAAO,CAAC,KAAK,EAAE,KAAuB,EAAE,GAAG,EAA8B,EAAE;IAC1E,OAAO,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoB,YAAY,CAAC,iBAAiB,EAAE;IACtE,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,oBAAoB;IACpB,oBAAoB;CACrB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEjB,eAAe,SAAS,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * cue.add procedure
3
+ *
4
+ * Add a feature to dependencies.json.
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ */
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import type { CueAddInput, CueAddOutput } from "../../types.js";
9
+ /**
10
+ * Add a feature to dependencies.json
11
+ */
12
+ export declare function cueAdd(input: CueAddInput, ctx: ProcedureContext): Promise<CueAddOutput>;
13
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/add.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAOhE;;GAEG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,YAAY,CAAC,CA0DvB"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * cue.add procedure
3
+ *
4
+ * Add a feature to dependencies.json.
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ */
7
+ import { loadFeatures, loadDependencies, saveDependencies, } from "../../shared.js";
8
+ /**
9
+ * Add a feature to dependencies.json
10
+ */
11
+ export async function cueAdd(input, ctx) {
12
+ const projectPath = input.cwd ?? process.cwd();
13
+ const feature = input.feature;
14
+ // Load features manifest
15
+ const manifest = await loadFeatures(ctx);
16
+ if (!manifest) {
17
+ return {
18
+ success: false,
19
+ feature,
20
+ added: false,
21
+ error: "Could not load features.json from @mark1russell7/cue package",
22
+ };
23
+ }
24
+ // Validate feature exists
25
+ if (!manifest.features[feature]) {
26
+ const available = Object.keys(manifest.features).join(", ");
27
+ return {
28
+ success: false,
29
+ feature,
30
+ added: false,
31
+ error: `Unknown feature: ${feature}. Available: ${available}`,
32
+ };
33
+ }
34
+ // Load current dependencies
35
+ const deps = await loadDependencies(projectPath, ctx) ?? [];
36
+ // Check if already present
37
+ if (deps.includes(feature)) {
38
+ return {
39
+ success: true,
40
+ feature,
41
+ added: false,
42
+ message: `Feature '${feature}' is already in dependencies`,
43
+ };
44
+ }
45
+ // Add feature and save
46
+ deps.push(feature);
47
+ const saved = await saveDependencies(deps, projectPath, ctx);
48
+ if (!saved) {
49
+ return {
50
+ success: false,
51
+ feature,
52
+ added: false,
53
+ error: "Failed to write dependencies.json",
54
+ };
55
+ }
56
+ return {
57
+ success: true,
58
+ feature,
59
+ added: true,
60
+ message: `Added '${feature}' to dependencies.json`,
61
+ };
62
+ }
63
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/procedures/cue/add.ts"],"names":[],"mappings":"AAAA;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AC,CAAC;IACnB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;IAE7D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO;YACP,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,mCAAmC;SAC3C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO;QACP,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,UAAU,OAAO,wBAAwB;KACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * cue.generate procedure
3
+ *
4
+ * Generate config files (package.json, tsconfig.json, .gitignore).
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ * Runs the cue program through runCommand of client-shell (async, no shell).
7
+ */
8
+ import type { ProcedureContext } from "@procedures/client";
9
+ import type { CueGenerateInput, CueGenerateOutput } from "../../types.js";
10
+ /**
11
+ * Generate config files from dependencies.json
12
+ */
13
+ export declare function cueGenerate(input: CueGenerateInput, ctx: ProcedureContext): Promise<CueGenerateOutput>;
14
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/generate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA0I1E;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CA0F5B"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * cue.generate procedure
3
+ *
4
+ * Generate config files (package.json, tsconfig.json, .gitignore).
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ * Runs the cue program through runCommand of client-shell (async, no shell).
7
+ */
8
+ import { resolve } from "node:path";
9
+ import { loadFeatures, loadDependencies, resolveFeatures, checkCue, runCue, determineTsconfig, featureToFieldName, packageRoot, fileExists, readJson, writeJson, writeFile, mkdir, } from "../../shared.js";
10
+ /**
11
+ * Keys that describe a package's own entry points. The package owns them: a generated value
12
+ * is only a default for a package that has none. (BUGS-2026-07 H33: generate replaced a
13
+ * multi-entry "exports" with the generated "." entry, and dropped bin and sideEffects.)
14
+ * Policy keys, for example "engines", still come from the generator.
15
+ */
16
+ const PACKAGE_OWNED_KEYS = new Set(["exports", "main", "types", "bin", "sideEffects"]);
17
+ /**
18
+ * Generate package.json via CUE evaluation
19
+ */
20
+ async function generatePackageJson(resolvedFeatures, existingPkg, ctx) {
21
+ const configDir = resolve(packageRoot, "npm/package");
22
+ // Build list of CUE files to evaluate
23
+ const files = ["base.cue"];
24
+ for (const feature of resolvedFeatures) {
25
+ const fieldName = featureToFieldName(feature);
26
+ const cuePath = resolve(configDir, `${fieldName}.cue`);
27
+ if (await fileExists(cuePath, ctx)) {
28
+ files.push(`${fieldName}.cue`);
29
+ }
30
+ }
31
+ // Run cue eval
32
+ const result = await runCue(["eval", ...files, "-e", "output", "--out", "json"], { cwd: configDir, signal: ctx.signal });
33
+ if (!result.success) {
34
+ throw new Error(`cue eval failed for package.json: ${(result.stderr || result.stdout || "").trim()}`);
35
+ }
36
+ const generated = JSON.parse(result.stdout);
37
+ // Merge with existing package.json
38
+ const pkg = { ...existingPkg };
39
+ for (const [key, value] of Object.entries(generated)) {
40
+ if (key === "name" || key === "version" || key === "description") {
41
+ if (!pkg[key])
42
+ pkg[key] = value;
43
+ }
44
+ else if (key === "devDependencies" || key === "peerDependencies" || key === "scripts") {
45
+ pkg[key] = { ...value, ...(pkg[key] ?? {}) };
46
+ }
47
+ else if (key === "files" && Array.isArray(value) && Array.isArray(pkg[key])) {
48
+ const merged = [...value];
49
+ for (const item of pkg[key]) {
50
+ if (!merged.includes(item))
51
+ merged.push(item);
52
+ }
53
+ pkg[key] = merged;
54
+ }
55
+ else if (PACKAGE_OWNED_KEYS.has(key)) {
56
+ if (pkg[key] === undefined)
57
+ pkg[key] = value;
58
+ }
59
+ else {
60
+ pkg[key] = value;
61
+ }
62
+ }
63
+ // Ensure $schema is first
64
+ const ordered = { $schema: "https://json.schemastore.org/package" };
65
+ for (const [key, value] of Object.entries(pkg)) {
66
+ if (key !== "$schema")
67
+ ordered[key] = value;
68
+ }
69
+ return ordered;
70
+ }
71
+ /**
72
+ * Generate .gitignore via CUE evaluation
73
+ */
74
+ async function generateGitignore(resolvedFeatures, ctx) {
75
+ const configDir = resolve(packageRoot, "git/ignore");
76
+ const files = ["base.cue"];
77
+ for (const feature of resolvedFeatures) {
78
+ const cuePath = resolve(configDir, `${feature}.cue`);
79
+ if (await fileExists(cuePath, ctx)) {
80
+ files.push(`${feature}.cue`);
81
+ }
82
+ }
83
+ const result = await runCue(["eval", ...files, "-e", "patterns", "--out", "json"], { cwd: configDir, signal: ctx.signal });
84
+ if (!result.success) {
85
+ throw new Error(`cue eval failed for .gitignore: ${(result.stderr || result.stdout || "").trim()}`);
86
+ }
87
+ const patterns = JSON.parse(result.stdout);
88
+ return patterns.join("\n") + "\n";
89
+ }
90
+ /**
91
+ * Setup cue.mod directory
92
+ */
93
+ async function setupCueMod(projectPath, ctx) {
94
+ const cueModPath = resolve(projectPath, "cue.mod");
95
+ if (!(await fileExists(cueModPath, ctx))) {
96
+ await mkdir(cueModPath, ctx);
97
+ }
98
+ await writeFile(resolve(cueModPath, "module.cue"), `module: "project.local"
99
+ language: {
100
+ \tversion: "v0.15.1"
101
+ }
102
+ `, ctx);
103
+ }
104
+ /**
105
+ * Generate config files from dependencies.json
106
+ */
107
+ export async function cueGenerate(input, ctx) {
108
+ const projectPath = input.cwd ?? process.cwd();
109
+ const generated = [];
110
+ // Check CUE is installed
111
+ if (!(await checkCue(ctx.signal))) {
112
+ return {
113
+ success: false,
114
+ resolvedFeatures: [],
115
+ generated: [],
116
+ error: "CUE is not installed. Install from: https://cuelang.org/docs/install/",
117
+ };
118
+ }
119
+ // Load features manifest
120
+ const manifest = await loadFeatures(ctx);
121
+ if (!manifest) {
122
+ return {
123
+ success: false,
124
+ resolvedFeatures: [],
125
+ generated: [],
126
+ error: "Could not load features.json from @mark1russell7/cue package",
127
+ };
128
+ }
129
+ // Load dependencies
130
+ const deps = await loadDependencies(projectPath, ctx);
131
+ if (!deps) {
132
+ return {
133
+ success: false,
134
+ resolvedFeatures: [],
135
+ generated: [],
136
+ error: "No dependencies.json found. Run cue.init first.",
137
+ };
138
+ }
139
+ // Resolve transitive dependencies
140
+ const resolvedFeatures = resolveFeatures(deps, manifest);
141
+ // Load existing package.json
142
+ const existingPkg = await readJson(resolve(projectPath, "package.json"), ctx);
143
+ // A failed cue eval is an error of the whole call, not a silently skipped file
144
+ // (BUGS-2026-07 M36: the procedure reported success with nothing generated).
145
+ try {
146
+ // Generate package.json
147
+ const packageJson = await generatePackageJson(resolvedFeatures, existingPkg, ctx);
148
+ if (packageJson) {
149
+ await writeJson(resolve(projectPath, "package.json"), packageJson, ctx);
150
+ generated.push("package.json");
151
+ }
152
+ // Generate tsconfig.json if ts feature is present
153
+ if (resolvedFeatures.includes("ts")) {
154
+ const tsconfigName = determineTsconfig(resolvedFeatures);
155
+ const tsconfig = {
156
+ $schema: "https://json.schemastore.org/tsconfig",
157
+ extends: `@mark1russell7/cue/ts/config/${tsconfigName}.json`,
158
+ };
159
+ await writeJson(resolve(projectPath, "tsconfig.json"), tsconfig, ctx);
160
+ generated.push("tsconfig.json");
161
+ }
162
+ // Generate .gitignore
163
+ const gitignoreContent = await generateGitignore(resolvedFeatures, ctx);
164
+ if (gitignoreContent) {
165
+ await writeFile(resolve(projectPath, ".gitignore"), gitignoreContent, ctx);
166
+ generated.push(".gitignore");
167
+ }
168
+ // Setup cue.mod if cue feature is present
169
+ if (resolvedFeatures.includes("cue")) {
170
+ await setupCueMod(projectPath, ctx);
171
+ generated.push("cue.mod/");
172
+ }
173
+ }
174
+ catch (error) {
175
+ return {
176
+ success: false,
177
+ resolvedFeatures,
178
+ generated,
179
+ error: error instanceof Error ? error.message : String(error),
180
+ };
181
+ }
182
+ return {
183
+ success: true,
184
+ resolvedFeatures,
185
+ generated,
186
+ message: `Generated ${generated.length} files`,
187
+ };
188
+ }
189
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/procedures/cue/generate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,KAAK,GACN,MAAM,iBAAiB,CAAC;AASzB;;;;;GAKG;AACH,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;AAE5G;;GAEG;AACH,KAAK,UAAU,mBAAmB,CAChC,gBAA0B,EAC1B,WAA+B,EAC/B,GAAqB;IAErB,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAEtD,sCAAsC;IACtC,MAAM,KAAK,GAAa,CAAC,UAAU,CAAC,CAAC;IACrC,KAAK,MAAM,OAAO,IAAI,gBAAgB,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,SAAS,MAAM,CAAC,CAAC;QACvD,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE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M,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,gBAAgB;QAChB,SAAS;QACT,OAAO,EAAE,aAAa,SAAS,CAAC,MAAM,QAAQ;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { cueInit } from "./init.js";
2
+ export { cueAdd } from "./add.js";
3
+ export { cueRemove } from "./remove.js";
4
+ export { cueGenerate } from "./generate.js";
5
+ export { cueValidate } from "./validate.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { cueInit } from "./init.js";
2
+ export { cueAdd } from "./add.js";
3
+ export { cueRemove } from "./remove.js";
4
+ export { cueGenerate } from "./generate.js";
5
+ export { cueValidate } from "./validate.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/cue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * cue.init procedure
3
+ *
4
+ * Initialize dependencies.json with a preset.
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ */
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import type { CueInitInput, CueInitOutput } from "../../types.js";
9
+ /**
10
+ * Initialize a project with dependencies.json
11
+ */
12
+ export declare function cueInit(input: CueInitInput, ctx: ProcedureContext): Promise<CueInitOutput>;
13
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASlE;;GAEG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,aAAa,CAAC,CAyExB"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * cue.init procedure
3
+ *
4
+ * Initialize dependencies.json with a preset.
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ */
7
+ import { resolve } from "node:path";
8
+ import { loadFeatures, saveDependencies, fileExists, mkdir, writeFile, } from "../../shared.js";
9
+ /**
10
+ * Initialize a project with dependencies.json
11
+ */
12
+ export async function cueInit(input, ctx) {
13
+ const projectPath = input.cwd ?? process.cwd();
14
+ const presetName = input.preset ?? "lib";
15
+ const created = [];
16
+ // Load features manifest
17
+ const manifest = await loadFeatures(ctx);
18
+ if (!manifest) {
19
+ return {
20
+ success: false,
21
+ preset: presetName,
22
+ created: [],
23
+ error: "Could not load features.json from @mark1russell7/cue package",
24
+ };
25
+ }
26
+ // Validate preset
27
+ const preset = manifest.presets[presetName];
28
+ if (!preset) {
29
+ const available = Object.keys(manifest.presets).join(", ");
30
+ return {
31
+ success: false,
32
+ preset: presetName,
33
+ created: [],
34
+ error: `Unknown preset: ${presetName}. Available: ${available}`,
35
+ };
36
+ }
37
+ // Check if dependencies.json exists
38
+ const depsPath = resolve(projectPath, "dependencies.json");
39
+ if (await fileExists(depsPath, ctx)) {
40
+ if (!input.force) {
41
+ return {
42
+ success: true,
43
+ preset: presetName,
44
+ created: [],
45
+ message: "dependencies.json already exists (use force: true to overwrite)",
46
+ };
47
+ }
48
+ }
49
+ // Create dependencies.json
50
+ const saved = await saveDependencies(preset, projectPath, ctx);
51
+ if (!saved) {
52
+ return {
53
+ success: false,
54
+ preset: presetName,
55
+ created: [],
56
+ error: "Failed to write dependencies.json",
57
+ };
58
+ }
59
+ created.push("dependencies.json");
60
+ // Create src directory if needed
61
+ const srcPath = resolve(projectPath, "src");
62
+ if (!(await fileExists(srcPath, ctx))) {
63
+ await mkdir(srcPath, ctx);
64
+ created.push("src/");
65
+ }
66
+ // Create src/index.ts if needed
67
+ const indexPath = resolve(projectPath, "src", "index.ts");
68
+ if (!(await fileExists(indexPath, ctx))) {
69
+ await writeFile(indexPath, "// Entry point\nexport {};\n", ctx);
70
+ created.push("src/index.ts");
71
+ }
72
+ return {
73
+ success: true,
74
+ preset: presetName,
75
+ created,
76
+ message: `Initialized with preset '${presetName}'. Run cue.generate to create config files.`,
77
+ };
78
+ }
79
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/procedures/cue/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,KAAmB,EACnB,GAAqB;IAErB,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IA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,EAAE,KAAK;YACd,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,mCAAmC;SAC3C,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAElC,iCAAiC;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;QACtC,MAAM,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,gCAAgC;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAC1D,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;QACxC,MAAM,SAAS,CAAC,SAAS,EAAE,8BAA8B,EAAE,GAAG,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,UAAU;QAClB,OAAO;QACP,OAAO,EAAE,4BAA4B,UAAU,6CAA6C;KAC7F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * cue.remove procedure
3
+ *
4
+ * Remove a feature from dependencies.json.
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ */
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import type { CueRemoveInput, CueRemoveOutput } from "../../types.js";
9
+ /**
10
+ * Remove a feature from dependencies.json
11
+ */
12
+ export declare function cueRemove(input: CueRemoveInput, ctx: ProcedureContext): Promise<CueRemoveOutput>;
13
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/remove.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtE;;GAEG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,cAAc,EACrB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,eAAe,CAAC,CA8C1B"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * cue.remove procedure
3
+ *
4
+ * Remove a feature from dependencies.json.
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ */
7
+ import { loadDependencies, saveDependencies } from "../../shared.js";
8
+ /**
9
+ * Remove a feature from dependencies.json
10
+ */
11
+ export async function cueRemove(input, ctx) {
12
+ const projectPath = input.cwd ?? process.cwd();
13
+ const feature = input.feature;
14
+ // Load current dependencies
15
+ const deps = await loadDependencies(projectPath, ctx);
16
+ if (!deps) {
17
+ return {
18
+ success: false,
19
+ feature,
20
+ removed: false,
21
+ error: "No dependencies.json found. Run cue.init first.",
22
+ };
23
+ }
24
+ // Check if feature is present
25
+ const idx = deps.indexOf(feature);
26
+ if (idx === -1) {
27
+ return {
28
+ success: true,
29
+ feature,
30
+ removed: false,
31
+ message: `Feature '${feature}' is not in dependencies`,
32
+ };
33
+ }
34
+ // Remove feature and save
35
+ deps.splice(idx, 1);
36
+ const saved = await saveDependencies(deps, projectPath, ctx);
37
+ if (!saved) {
38
+ return {
39
+ success: false,
40
+ feature,
41
+ removed: false,
42
+ error: "Failed to write dependencies.json",
43
+ };
44
+ }
45
+ return {
46
+ success: true,
47
+ feature,
48
+ removed: true,
49
+ message: `Removed '${feature}' from dependencies.json`,
50
+ };
51
+ }
52
+ //# sourceMappingURL=remove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.js","sourceRoot":"","sources":["../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OAAO,0BAA0B;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * cue.validate procedure
3
+ *
4
+ * Validate dependencies.json against schema.
5
+ * Uses ctx.client.call() for file system operations (dogfooding).
6
+ */
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import type { CueValidateInput, CueValidateOutput } from "../../types.js";
9
+ /**
10
+ * Validate dependencies.json
11
+ */
12
+ export declare function cueValidate(input: CueValidateInput, ctx: ProcedureContext): Promise<CueValidateOutput>;
13
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAU1E;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAsE5B"}