@el-j/magic-agent-helix 4.0.0-beta.2 โ 4.0.0-beta.3
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/dist/cli.mjs +264 -264
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as p from "node:fs";
|
|
3
|
-
import { realpathSync as
|
|
4
|
-
import * as
|
|
5
|
-
import { resolve as
|
|
6
|
-
import { fileURLToPath as
|
|
7
|
-
import { Command as
|
|
3
|
+
import { realpathSync as te, readFileSync as oe } from "node:fs";
|
|
4
|
+
import * as d from "node:path";
|
|
5
|
+
import { resolve as ne, dirname as se, join as ie } from "node:path";
|
|
6
|
+
import { fileURLToPath as U } from "node:url";
|
|
7
|
+
import { Command as re } from "commander";
|
|
8
8
|
import t from "picocolors";
|
|
9
|
-
import { loadUserConfig as
|
|
9
|
+
import { loadUserConfig as N, mergeConfigs as L, PluginRegistry as C, getFormatter as Y, validateInstructions as ae } from "@el-j/magic-helix-core";
|
|
10
10
|
import W from "inquirer";
|
|
11
|
-
import
|
|
11
|
+
import j from "ora";
|
|
12
12
|
import q from "gradient-string";
|
|
13
|
-
import { glob as
|
|
14
|
-
async function
|
|
13
|
+
import { glob as ce } from "glob";
|
|
14
|
+
async function le() {
|
|
15
15
|
console.log(t.cyan(`๐งน Cleaning generated instruction files...
|
|
16
16
|
`));
|
|
17
|
-
const e =
|
|
17
|
+
const e = j("Loading configuration...").start(), n = N(), s = L(n);
|
|
18
18
|
e.succeed("Configuration loaded.");
|
|
19
|
-
const r =
|
|
19
|
+
const r = d.resolve(
|
|
20
20
|
process.cwd(),
|
|
21
21
|
s.outputDirectory
|
|
22
22
|
);
|
|
@@ -54,27 +54,27 @@ async function de() {
|
|
|
54
54
|
console.log(t.yellow("Clean cancelled."));
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
let i = 0,
|
|
57
|
+
const c = j("Deleting files...").start();
|
|
58
|
+
let i = 0, l = 0;
|
|
59
59
|
for (const g of a)
|
|
60
60
|
try {
|
|
61
|
-
p.unlinkSync(
|
|
61
|
+
p.unlinkSync(d.join(r, g)), i++;
|
|
62
62
|
} catch (u) {
|
|
63
63
|
console.error(
|
|
64
64
|
t.red(` โ Error deleting ${g}: ${u.message}`)
|
|
65
|
-
),
|
|
65
|
+
), l++;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
l === 0 ? c.succeed(
|
|
68
68
|
t.green(`โ
Successfully deleted ${i} file(s).`)
|
|
69
|
-
) :
|
|
69
|
+
) : c.warn(
|
|
70
70
|
t.yellow(
|
|
71
|
-
`โ ๏ธ Deleted ${i} file(s), ${
|
|
71
|
+
`โ ๏ธ Deleted ${i} file(s), ${l} error(s) occurred.`
|
|
72
72
|
)
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
const
|
|
75
|
+
const _ = "magic-helix.config.json", O = "ai_templates", ge = {
|
|
76
76
|
target: "github-copilot",
|
|
77
|
-
templateDirectory:
|
|
77
|
+
templateDirectory: O,
|
|
78
78
|
outputDirectory: ".github/instructions",
|
|
79
79
|
dependencyTagMap: {
|
|
80
80
|
// "my-internal-package": "domain-my-rules"
|
|
@@ -91,17 +91,17 @@ const G = "magic-helix.config.json", N = "ai_templates", fe = {
|
|
|
91
91
|
// ]
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
async function
|
|
95
|
-
const e =
|
|
94
|
+
async function ue() {
|
|
95
|
+
const e = j(
|
|
96
96
|
t.bold("Initializing Magic Helix for custom rules...")
|
|
97
|
-
).start(), n =
|
|
97
|
+
).start(), n = d.resolve(process.cwd(), _), s = d.resolve(process.cwd(), O);
|
|
98
98
|
if (p.existsSync(n)) {
|
|
99
99
|
e.stop();
|
|
100
100
|
const { overwrite: a } = await W.prompt([
|
|
101
101
|
{
|
|
102
102
|
type: "confirm",
|
|
103
103
|
name: "overwrite",
|
|
104
|
-
message: `A ${
|
|
104
|
+
message: `A ${_} file already exists. Do you want to overwrite it with a minimal example?`,
|
|
105
105
|
default: !1
|
|
106
106
|
}
|
|
107
107
|
]);
|
|
@@ -114,20 +114,20 @@ async function pe() {
|
|
|
114
114
|
try {
|
|
115
115
|
p.writeFileSync(
|
|
116
116
|
n,
|
|
117
|
-
JSON.stringify(
|
|
117
|
+
JSON.stringify(ge, null, 2),
|
|
118
118
|
"utf-8"
|
|
119
119
|
), e.succeed(
|
|
120
|
-
t.green(`Created minimal config file: ${t.bold(
|
|
120
|
+
t.green(`Created minimal config file: ${t.bold(_)}`)
|
|
121
121
|
);
|
|
122
122
|
} catch (a) {
|
|
123
123
|
e.fail(t.red(`Error writing config file: ${a.message}`));
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
e.start("Creating templates directory..."), p.existsSync(s) || p.mkdirSync(s, { recursive: !0 });
|
|
127
|
-
const r =
|
|
127
|
+
const r = d.resolve(s, "my-custom-rule.md");
|
|
128
128
|
p.existsSync(r) ? e.succeed(
|
|
129
129
|
t.green(
|
|
130
|
-
`Templates directory ${t.bold(
|
|
130
|
+
`Templates directory ${t.bold(O)} already exists.`
|
|
131
131
|
)
|
|
132
132
|
) : (p.writeFileSync(
|
|
133
133
|
r,
|
|
@@ -138,7 +138,7 @@ async function pe() {
|
|
|
138
138
|
"utf-8"
|
|
139
139
|
), e.succeed(
|
|
140
140
|
t.green(
|
|
141
|
-
`Created templates directory and example file: ${t.bold(
|
|
141
|
+
`Created templates directory and example file: ${t.bold(O)}`
|
|
142
142
|
)
|
|
143
143
|
)), console.log(
|
|
144
144
|
q.pastel.multiline(
|
|
@@ -147,27 +147,27 @@ async function pe() {
|
|
|
147
147
|
)
|
|
148
148
|
), console.log(t.cyan(`
|
|
149
149
|
Next steps:`)), console.log(
|
|
150
|
-
` 1. Edit ${t.bold(
|
|
150
|
+
` 1. Edit ${t.bold(_)} to define your team's "tags".`
|
|
151
151
|
), console.log(
|
|
152
|
-
` 2. Add your custom .md instruction files to ${t.bold(
|
|
152
|
+
` 2. Add your custom .md instruction files to ${t.bold(O)}.`
|
|
153
153
|
), console.log(
|
|
154
154
|
` 3. Run ${t.bold("npx @el-j/magic-agent-helix run")} to generate your files.`
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
|
-
async function
|
|
157
|
+
async function de() {
|
|
158
158
|
console.log(t.cyan(`๐ Listing project information...
|
|
159
159
|
`));
|
|
160
|
-
const e =
|
|
160
|
+
const e = j("Loading configuration...").start(), n = N(), s = L(n);
|
|
161
161
|
e.succeed("Configuration loaded.");
|
|
162
|
-
const { dependencyTagMap: r, configFileTagMap: a, fileGlobTagMap: o, tagTemplateMap:
|
|
163
|
-
if (
|
|
162
|
+
const { dependencyTagMap: r, configFileTagMap: a, fileGlobTagMap: o, tagTemplateMap: c } = s, i = j("Scanning for projects...").start(), l = await fe();
|
|
163
|
+
if (l.length === 0) {
|
|
164
164
|
i.warn(t.yellow("No projects found."));
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
i.succeed(`Found ${
|
|
168
|
-
const g =
|
|
169
|
-
for (const u of
|
|
170
|
-
await
|
|
167
|
+
i.succeed(`Found ${l.length} projects.`);
|
|
168
|
+
const g = j("Analyzing projects...").start();
|
|
169
|
+
for (const u of l)
|
|
170
|
+
await pe(
|
|
171
171
|
u,
|
|
172
172
|
r,
|
|
173
173
|
a,
|
|
@@ -176,14 +176,14 @@ async function me() {
|
|
|
176
176
|
g.succeed(`Analysis complete.
|
|
177
177
|
`), console.log(t.cyan(t.bold(`Projects & Tags:
|
|
178
178
|
`)));
|
|
179
|
-
for (const u of
|
|
179
|
+
for (const u of l) {
|
|
180
180
|
if (console.log(t.bold(`๐ฆ ${u.name}`)), console.log(t.gray(` Path: ${u.path}`)), u.tags.size === 0)
|
|
181
181
|
console.log(t.yellow(" No tags detected"));
|
|
182
182
|
else {
|
|
183
183
|
console.log(t.green(` Tags: ${[...u.tags].join(", ")}`));
|
|
184
184
|
const h = [];
|
|
185
185
|
for (const w of u.tags) {
|
|
186
|
-
const m =
|
|
186
|
+
const m = c[w];
|
|
187
187
|
if (m)
|
|
188
188
|
for (const v of m)
|
|
189
189
|
h.push(`${u.name}.${v.suffix}`);
|
|
@@ -195,32 +195,32 @@ async function me() {
|
|
|
195
195
|
console.log(t.cyan(t.bold(`Configuration:
|
|
196
196
|
`))), console.log(t.gray(` Output directory: ${s.outputDirectory}`)), console.log(t.gray(` Template directory: ${s.templateDirectory}`)), console.log(t.gray(` Target: ${s.target}`));
|
|
197
197
|
}
|
|
198
|
-
async function
|
|
198
|
+
async function fe() {
|
|
199
199
|
const e = [], n = process.cwd(), s = C.getInstance();
|
|
200
200
|
await s.initialize();
|
|
201
201
|
const a = (await s.detectAllProjects(n)).map((o) => o.metadata);
|
|
202
202
|
if (a.length === 0)
|
|
203
203
|
return [];
|
|
204
204
|
for (const o of a) {
|
|
205
|
-
const
|
|
205
|
+
const c = d.relative(n, o.projectPath);
|
|
206
206
|
e.push({
|
|
207
|
-
name: o.name ||
|
|
208
|
-
path:
|
|
207
|
+
name: o.name || d.basename(o.projectPath),
|
|
208
|
+
path: c || ".",
|
|
209
209
|
tags: /* @__PURE__ */ new Set()
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
return e;
|
|
213
213
|
}
|
|
214
|
-
async function
|
|
215
|
-
const a =
|
|
214
|
+
async function pe(e, n, s, r) {
|
|
215
|
+
const a = d.resolve(process.cwd(), e.path);
|
|
216
216
|
try {
|
|
217
|
-
const i = (await C.getInstance().detectAllProjects(a)).map((
|
|
217
|
+
const i = (await C.getInstance().detectAllProjects(a)).map((l) => l.metadata);
|
|
218
218
|
if (i.length > 0) {
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
221
|
-
for (const g of
|
|
219
|
+
const l = i[0];
|
|
220
|
+
if (l.tags?.length)
|
|
221
|
+
for (const g of l.tags)
|
|
222
222
|
e.tags.add(g);
|
|
223
|
-
for (const g in
|
|
223
|
+
for (const g in l.dependencies) {
|
|
224
224
|
n[g] && e.tags.add(n[g]);
|
|
225
225
|
const u = g.split(/[@/:]/g).pop();
|
|
226
226
|
u && n[u] && e.tags.add(n[u]);
|
|
@@ -230,16 +230,16 @@ async function he(e, n, s, r) {
|
|
|
230
230
|
}
|
|
231
231
|
try {
|
|
232
232
|
for (const o in s) {
|
|
233
|
-
const
|
|
234
|
-
p.existsSync(i) && e.tags.add(
|
|
233
|
+
const c = s[o], i = d.join(a, o);
|
|
234
|
+
p.existsSync(i) && e.tags.add(c);
|
|
235
235
|
}
|
|
236
236
|
} catch {
|
|
237
237
|
}
|
|
238
238
|
try {
|
|
239
239
|
const { glob: o } = await import("glob");
|
|
240
|
-
for (const
|
|
241
|
-
const i = r[
|
|
242
|
-
(await o(
|
|
240
|
+
for (const c in r) {
|
|
241
|
+
const i = r[c];
|
|
242
|
+
(await o(c, {
|
|
243
243
|
cwd: a,
|
|
244
244
|
nodir: !0,
|
|
245
245
|
dot: !0
|
|
@@ -248,7 +248,7 @@ async function he(e, n, s, r) {
|
|
|
248
248
|
} catch {
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
async function
|
|
251
|
+
async function me(e = {}) {
|
|
252
252
|
console.log(t.blue("๐ MagicAgentHelix Plugin System")), console.log();
|
|
253
253
|
try {
|
|
254
254
|
const n = C.getInstance();
|
|
@@ -259,28 +259,28 @@ async function we(e = {}) {
|
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
261
|
console.log(t.green(`โ
${s.length} plugin(s) loaded successfully`)), console.log();
|
|
262
|
-
const a = s.sort((o,
|
|
262
|
+
const a = s.sort((o, c) => c.priority - o.priority);
|
|
263
263
|
console.log(t.bold("Available Language Plugins:")), console.log("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ");
|
|
264
264
|
for (const o of a) {
|
|
265
|
-
const
|
|
265
|
+
const c = o.priority >= 90 ? "green" : o.priority >= 70 ? "yellow" : "cyan";
|
|
266
266
|
if (console.log(
|
|
267
|
-
`${t.bold(o.displayName)} (${t[
|
|
267
|
+
`${t.bold(o.displayName)} (${t[c](`priority: ${o.priority}`)}) v${o.version}`
|
|
268
268
|
), e.verbose) {
|
|
269
269
|
const i = o.getTemplates();
|
|
270
270
|
i.length > 0 && console.log(
|
|
271
271
|
` ๐ Templates: ${i.map((g) => g.name).join(", ")}`
|
|
272
272
|
);
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
` ๐ท๏ธ Detects: ${Object.keys(
|
|
273
|
+
const l = o.getDependencyTagMap?.();
|
|
274
|
+
l && Object.keys(l).length > 0 && console.log(
|
|
275
|
+
` ๐ท๏ธ Detects: ${Object.keys(l).slice(0, 3).join(", ")}${Object.keys(l).length > 3 ? "..." : ""}`
|
|
276
276
|
), console.log();
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
if (e.verbose || (console.log(), console.log(t.dim("๐ก Use --verbose for detailed plugin information"))), console.log(), console.log(t.bold("System Statistics:")), console.log("โโโโโโโโโโโโโโโโโโ"), console.log(`๐ Total plugins: ${r.totalLoaded}`), console.log(`โก Average load time: ${r.averageLoadTime.toFixed(1)}ms`), console.log(`โ Load errors: ${r.totalErrors}`), r.totalErrors > 0 && e.verbose) {
|
|
280
280
|
const o = n.getLoadErrors();
|
|
281
281
|
console.log(), console.log(t.red("Load Errors:")), console.log("โโโโโโโโโโโโ");
|
|
282
|
-
for (const
|
|
283
|
-
console.log(`โ ${
|
|
282
|
+
for (const c of o)
|
|
283
|
+
console.log(`โ ${c.source.identifier}: ${c.error.message}`);
|
|
284
284
|
}
|
|
285
285
|
} catch (n) {
|
|
286
286
|
console.error(
|
|
@@ -289,7 +289,7 @@ async function we(e = {}) {
|
|
|
289
289
|
), process.exit(1);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
const
|
|
292
|
+
const ye = {
|
|
293
293
|
// Frameworks
|
|
294
294
|
"framework-vue": {
|
|
295
295
|
extensions: ["vue"],
|
|
@@ -429,44 +429,44 @@ const $e = {
|
|
|
429
429
|
description: "Files using Zustand"
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
|
-
function
|
|
433
|
-
return
|
|
432
|
+
function he(e) {
|
|
433
|
+
return ye[e]?.extensions || [];
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function K(e, n, s) {
|
|
436
436
|
const r = /* @__PURE__ */ new Set();
|
|
437
|
-
for (const
|
|
438
|
-
const i =
|
|
439
|
-
for (const
|
|
440
|
-
r.add(
|
|
437
|
+
for (const c of n) {
|
|
438
|
+
const i = he(c);
|
|
439
|
+
for (const l of i)
|
|
440
|
+
r.add(l);
|
|
441
441
|
}
|
|
442
442
|
if (r.size === 0)
|
|
443
443
|
return `${e}/src/**/*.{ts,js,vue,tsx,jsx}`;
|
|
444
444
|
const a = Array.from(r).join(",");
|
|
445
445
|
let o = `${e}/src/**/*.{${a}}`;
|
|
446
446
|
if (s) {
|
|
447
|
-
const
|
|
448
|
-
for (const i of
|
|
447
|
+
const c = s.split(",").map((i) => i.trim());
|
|
448
|
+
for (const i of c)
|
|
449
449
|
i.endsWith("/**") ? o += ` !(${e}/src/${i})` : i.includes("*") ? o += ` !(${e}/src/${i})` : o += ` !(${e}/src/${i})`;
|
|
450
450
|
}
|
|
451
451
|
return o;
|
|
452
452
|
}
|
|
453
|
-
function
|
|
453
|
+
function Q(e) {
|
|
454
454
|
return e.quiet ? "quiet" : e.verbose ? "verbose" : "normal";
|
|
455
455
|
}
|
|
456
|
-
function
|
|
456
|
+
function $(e, n) {
|
|
457
457
|
return !(n === "quiet" && e !== "error" || n === "normal" && e === "verbose");
|
|
458
458
|
}
|
|
459
|
-
async function
|
|
460
|
-
|
|
461
|
-
const n =
|
|
459
|
+
async function we(e = {}) {
|
|
460
|
+
Q(e);
|
|
461
|
+
const n = j("Loading configurations...").start(), s = N(e.config), r = L(s);
|
|
462
462
|
e.target && (r.target = e.target), n.succeed("Configuration loaded.");
|
|
463
|
-
const { dependencyTagMap: a, configFileTagMap: o, fileGlobTagMap:
|
|
463
|
+
const { dependencyTagMap: a, configFileTagMap: o, fileGlobTagMap: c, tagTemplateMap: i } = r, l = d.resolve(
|
|
464
464
|
process.cwd(),
|
|
465
465
|
r.templateDirectory
|
|
466
|
-
), g =
|
|
466
|
+
), g = d.resolve(
|
|
467
467
|
process.cwd(),
|
|
468
468
|
r.outputDirectory
|
|
469
|
-
), u =
|
|
469
|
+
), u = Y(r.target);
|
|
470
470
|
if (!p.existsSync(g)) {
|
|
471
471
|
console.log(
|
|
472
472
|
t.yellow(
|
|
@@ -477,7 +477,7 @@ async function xe(e = {}) {
|
|
|
477
477
|
);
|
|
478
478
|
return;
|
|
479
479
|
}
|
|
480
|
-
const h =
|
|
480
|
+
const h = j("Scanning for projects...").start(), w = await $e();
|
|
481
481
|
if (w.length === 0) {
|
|
482
482
|
h.warn(
|
|
483
483
|
t.yellow(
|
|
@@ -487,14 +487,14 @@ async function xe(e = {}) {
|
|
|
487
487
|
return;
|
|
488
488
|
}
|
|
489
489
|
h.succeed(`Found ${w.length} projects.`);
|
|
490
|
-
const m =
|
|
490
|
+
const m = j("Analyzing project tags...").start();
|
|
491
491
|
let v = 0;
|
|
492
492
|
for (const y of w)
|
|
493
|
-
await
|
|
493
|
+
await je(
|
|
494
494
|
y,
|
|
495
495
|
a,
|
|
496
496
|
o,
|
|
497
|
-
|
|
497
|
+
c
|
|
498
498
|
), v += y.tags.size;
|
|
499
499
|
m.succeed(`Project analysis complete. Found ${v} tags.`), console.log(
|
|
500
500
|
t.cyan(`
|
|
@@ -507,32 +507,32 @@ Refreshing instruction files in ${r.outputDirectory}...`)
|
|
|
507
507
|
continue;
|
|
508
508
|
}
|
|
509
509
|
console.log(t.bold(` Processing: ${y.name}`)), console.log(t.gray(` Tags: ${[...y.tags].join(", ")}`));
|
|
510
|
-
const
|
|
511
|
-
for (const
|
|
512
|
-
const M = i[
|
|
510
|
+
const z = K(y.path, y.tags);
|
|
511
|
+
for (const S of y.tags) {
|
|
512
|
+
const M = i[S];
|
|
513
513
|
if (M)
|
|
514
|
-
for (const
|
|
515
|
-
const
|
|
516
|
-
if (!p.existsSync(
|
|
514
|
+
for (const P of M) {
|
|
515
|
+
const T = `${y.name}.${P.suffix}`, F = d.join(g, T);
|
|
516
|
+
if (!p.existsSync(F)) {
|
|
517
517
|
console.log(
|
|
518
|
-
t.yellow(` โ ๏ธ File not found, skipping: ${
|
|
518
|
+
t.yellow(` โ ๏ธ File not found, skipping: ${T}`)
|
|
519
519
|
);
|
|
520
520
|
continue;
|
|
521
521
|
}
|
|
522
|
-
|
|
523
|
-
if (
|
|
524
|
-
console.warn(t.yellow(` โ ๏ธ Template not found: ${
|
|
522
|
+
const f = xe(l, P.template), x = "Custom";
|
|
523
|
+
if (!f) {
|
|
524
|
+
console.warn(t.yellow(` โ ๏ธ Template not found: ${P.template}`));
|
|
525
525
|
continue;
|
|
526
526
|
}
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
527
|
+
const R = u.getFrontmatter(z, y.name), k = u.format(
|
|
528
|
+
f,
|
|
529
|
+
z,
|
|
530
530
|
y.name
|
|
531
|
-
), b = `${
|
|
532
|
-
${
|
|
533
|
-
p.writeFileSync(
|
|
531
|
+
), b = `${R}
|
|
532
|
+
${k}`;
|
|
533
|
+
p.writeFileSync(F, b), D++, console.log(
|
|
534
534
|
t.green(
|
|
535
|
-
` โ
Refreshed: ${t.bold(
|
|
535
|
+
` โ
Refreshed: ${t.bold(T)} (from ${x})`
|
|
536
536
|
)
|
|
537
537
|
);
|
|
538
538
|
}
|
|
@@ -541,32 +541,32 @@ ${A}`;
|
|
|
541
541
|
console.log(`
|
|
542
542
|
โจ Refresh complete!`), console.log(t.green(` Updated: ${D} files`)), console.log(t.gray(` Skipped: ${E} projects`));
|
|
543
543
|
}
|
|
544
|
-
async function
|
|
544
|
+
async function $e() {
|
|
545
545
|
const e = [], n = process.cwd(), s = C.getInstance();
|
|
546
546
|
await s.initialize();
|
|
547
547
|
const a = (await s.detectAllProjects(n)).map((o) => o.metadata);
|
|
548
548
|
if (a.length === 0)
|
|
549
549
|
return [];
|
|
550
550
|
for (const o of a) {
|
|
551
|
-
const
|
|
551
|
+
const c = d.relative(n, o.projectPath);
|
|
552
552
|
e.push({
|
|
553
|
-
name: o.name ||
|
|
554
|
-
path:
|
|
553
|
+
name: o.name || d.basename(o.projectPath),
|
|
554
|
+
path: c || ".",
|
|
555
555
|
tags: /* @__PURE__ */ new Set()
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
558
|
return e;
|
|
559
559
|
}
|
|
560
|
-
async function
|
|
561
|
-
const a =
|
|
560
|
+
async function je(e, n, s, r) {
|
|
561
|
+
const a = d.resolve(process.cwd(), e.path);
|
|
562
562
|
try {
|
|
563
|
-
const i = (await C.getInstance().detectAllProjects(a)).map((
|
|
563
|
+
const i = (await C.getInstance().detectAllProjects(a)).map((l) => l.metadata);
|
|
564
564
|
if (i.length > 0) {
|
|
565
|
-
const
|
|
566
|
-
if (
|
|
567
|
-
for (const g of
|
|
565
|
+
const l = i[0];
|
|
566
|
+
if (l.tags?.length)
|
|
567
|
+
for (const g of l.tags)
|
|
568
568
|
e.tags.add(g);
|
|
569
|
-
for (const g in
|
|
569
|
+
for (const g in l.dependencies) {
|
|
570
570
|
n[g] && e.tags.add(n[g]);
|
|
571
571
|
const u = g.split(/[@/:]/g).pop();
|
|
572
572
|
u && n[u] && e.tags.add(n[u]);
|
|
@@ -581,8 +581,8 @@ async function be(e, n, s, r) {
|
|
|
581
581
|
}
|
|
582
582
|
try {
|
|
583
583
|
for (const o in s) {
|
|
584
|
-
const
|
|
585
|
-
p.existsSync(i) && e.tags.add(
|
|
584
|
+
const c = s[o], i = d.join(a, o);
|
|
585
|
+
p.existsSync(i) && e.tags.add(c);
|
|
586
586
|
}
|
|
587
587
|
} catch (o) {
|
|
588
588
|
console.warn(
|
|
@@ -593,9 +593,9 @@ async function be(e, n, s, r) {
|
|
|
593
593
|
}
|
|
594
594
|
try {
|
|
595
595
|
const { glob: o } = await import("glob");
|
|
596
|
-
for (const
|
|
597
|
-
const i = r[
|
|
598
|
-
(await o(
|
|
596
|
+
for (const c in r) {
|
|
597
|
+
const i = r[c];
|
|
598
|
+
(await o(c, {
|
|
599
599
|
cwd: a,
|
|
600
600
|
nodir: !0,
|
|
601
601
|
dot: !0
|
|
@@ -609,15 +609,15 @@ async function be(e, n, s, r) {
|
|
|
609
609
|
);
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
const s =
|
|
612
|
+
function xe(e, n) {
|
|
613
|
+
const s = d.join(e, n);
|
|
614
614
|
try {
|
|
615
615
|
return p.readFileSync(s, "utf-8");
|
|
616
616
|
} catch {
|
|
617
617
|
return null;
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
|
-
async function
|
|
620
|
+
async function ve() {
|
|
621
621
|
console.log(
|
|
622
622
|
q.pastel.multiline("๐ค MagicAgentHelix Interactive Setup Wizard")
|
|
623
623
|
), console.log(`Let's configure your AI instruction generation...
|
|
@@ -674,23 +674,23 @@ async function Se() {
|
|
|
674
674
|
โ
Configuration complete! Starting analysis...
|
|
675
675
|
`)), n;
|
|
676
676
|
}
|
|
677
|
-
async function
|
|
677
|
+
async function J(e = {}) {
|
|
678
678
|
let n = e;
|
|
679
|
-
e.wizard && (n = { ...await
|
|
680
|
-
const s =
|
|
681
|
-
|
|
679
|
+
e.wizard && (n = { ...await ve(), ...e });
|
|
680
|
+
const s = Q(n);
|
|
681
|
+
$("normal", s) && console.log(
|
|
682
682
|
q.pastel.multiline("๐ค Running AI Convention Aligner...")
|
|
683
|
-
), n.dryRun &&
|
|
683
|
+
), n.dryRun && $("normal", s) && console.log(t.yellow(`๐ DRY RUN MODE - No files will be written
|
|
684
684
|
`));
|
|
685
|
-
const r =
|
|
685
|
+
const r = j("Loading configurations...").start(), a = N(n.config), o = L(a);
|
|
686
686
|
n.outputDir && (o.outputDirectory = n.outputDir), n.target && (o.target = n.target), r.succeed("Configuration loaded.");
|
|
687
|
-
const { dependencyTagMap:
|
|
687
|
+
const { dependencyTagMap: c, configFileTagMap: i, fileGlobTagMap: l, tagTemplateMap: g } = o, u = d.resolve(
|
|
688
688
|
process.cwd(),
|
|
689
689
|
o.templateDirectory
|
|
690
|
-
), h =
|
|
690
|
+
), h = d.resolve(
|
|
691
691
|
process.cwd(),
|
|
692
692
|
o.outputDirectory
|
|
693
|
-
), w =
|
|
693
|
+
), w = Y(o.target), m = j("Scanning for projects...").start(), v = await Pe();
|
|
694
694
|
if (v.length === 0) {
|
|
695
695
|
m.warn(
|
|
696
696
|
t.yellow(
|
|
@@ -713,54 +713,54 @@ Supported project types: Node.js, Python, Go, Rust, Java, Ruby, PHP, C#, Swift,
|
|
|
713
713
|
return;
|
|
714
714
|
}
|
|
715
715
|
m.succeed(`Found ${v.length} projects.`);
|
|
716
|
-
const D =
|
|
716
|
+
const D = j("Analyzing project tags...").start();
|
|
717
717
|
let E = 0;
|
|
718
|
-
for (const
|
|
719
|
-
if (n.project &&
|
|
720
|
-
|
|
718
|
+
for (const f of v) {
|
|
719
|
+
if (n.project && f.name !== n.project) {
|
|
720
|
+
$("verbose", s) && console.log(t.gray(`Skipping ${f.name} (not target project)`));
|
|
721
721
|
continue;
|
|
722
722
|
}
|
|
723
|
-
await
|
|
724
|
-
|
|
725
|
-
|
|
723
|
+
await Te(
|
|
724
|
+
f,
|
|
725
|
+
c,
|
|
726
726
|
i,
|
|
727
|
-
|
|
728
|
-
), E +=
|
|
727
|
+
l
|
|
728
|
+
), E += f.tags.size;
|
|
729
729
|
}
|
|
730
|
-
D.succeed(`Project analysis complete. Found ${E} tags.`), n.dryRun ?
|
|
730
|
+
D.succeed(`Project analysis complete. Found ${E} tags.`), n.dryRun ? $("verbose", s) && console.log(t.gray(`Would ensure directory: ${h}`)) : be(h);
|
|
731
731
|
let y = g;
|
|
732
732
|
if (n.template) {
|
|
733
|
-
const
|
|
733
|
+
const f = n.template.split(",").map((x) => x.trim());
|
|
734
734
|
y = {};
|
|
735
|
-
for (const [
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
738
|
-
const
|
|
739
|
-
return
|
|
735
|
+
for (const [x, R] of Object.entries(g)) {
|
|
736
|
+
const k = R.filter((b) => f.some((A) => {
|
|
737
|
+
if (A.includes("*")) {
|
|
738
|
+
const I = new RegExp(A.replace(/\*/g, ".*"));
|
|
739
|
+
return I.test(b.template) || I.test(x);
|
|
740
740
|
}
|
|
741
|
-
return b.template.includes(
|
|
741
|
+
return b.template.includes(A) || x.includes(A);
|
|
742
742
|
}));
|
|
743
|
-
|
|
743
|
+
k.length > 0 && (y[x] = k);
|
|
744
744
|
}
|
|
745
|
-
|
|
745
|
+
$("verbose", s) && console.log(
|
|
746
746
|
t.gray(`Template filter applied: ${n.template}`)
|
|
747
747
|
);
|
|
748
748
|
}
|
|
749
|
-
const
|
|
750
|
-
for (const [
|
|
751
|
-
|
|
752
|
-
template:
|
|
753
|
-
suffix:
|
|
749
|
+
const z = await Se(), S = {};
|
|
750
|
+
for (const [f, x] of Object.entries(y))
|
|
751
|
+
S[f] = x.map((R) => ({
|
|
752
|
+
template: R.template,
|
|
753
|
+
suffix: R.suffix
|
|
754
754
|
}));
|
|
755
|
-
for (const [
|
|
756
|
-
|
|
757
|
-
|
|
755
|
+
for (const [f, x] of Object.entries(z))
|
|
756
|
+
S[f] || (S[f] = []), S[f].push(...x);
|
|
757
|
+
$("verbose", s) && (console.log(t.gray(`
|
|
758
758
|
--- Template Map Debug ---`)), console.log(
|
|
759
759
|
t.gray(
|
|
760
|
-
`Plugin templates: ${Object.keys(
|
|
760
|
+
`Plugin templates: ${Object.keys(z).length} tags`
|
|
761
761
|
)
|
|
762
762
|
), console.log(
|
|
763
|
-
t.gray(` Tags: ${Object.keys(
|
|
763
|
+
t.gray(` Tags: ${Object.keys(z).join(", ")}`)
|
|
764
764
|
), console.log(
|
|
765
765
|
t.gray(
|
|
766
766
|
`Config templates: ${Object.keys(y).length} tags`
|
|
@@ -769,78 +769,78 @@ Supported project types: Node.js, Python, Go, Rust, Java, Ruby, PHP, C#, Swift,
|
|
|
769
769
|
t.gray(` Tags: ${Object.keys(y).join(", ")}`)
|
|
770
770
|
), console.log(
|
|
771
771
|
t.gray(
|
|
772
|
-
`Combined templates: ${Object.keys(
|
|
772
|
+
`Combined templates: ${Object.keys(S).length} tags`
|
|
773
773
|
)
|
|
774
774
|
), console.log(
|
|
775
|
-
t.gray(` Tags: ${Object.keys(
|
|
776
|
-
)),
|
|
775
|
+
t.gray(` Tags: ${Object.keys(S).join(", ")}`)
|
|
776
|
+
)), $("normal", s) && console.log(
|
|
777
777
|
t.cyan(`
|
|
778
778
|
Generating instruction files in ${o.outputDirectory}...`)
|
|
779
779
|
);
|
|
780
|
-
const M =
|
|
781
|
-
let
|
|
782
|
-
for (const
|
|
783
|
-
if (n.project &&
|
|
780
|
+
const M = j("Generating instruction files...").start(), P = [];
|
|
781
|
+
let T = 0, F = 0;
|
|
782
|
+
for (const f of v) {
|
|
783
|
+
if (n.project && f.name !== n.project)
|
|
784
784
|
continue;
|
|
785
|
-
if (
|
|
786
|
-
|
|
785
|
+
if (f.tags.size === 0) {
|
|
786
|
+
$("normal", s) && console.log(t.gray(` Skipping: ${f.name} (No matching tags)`));
|
|
787
787
|
continue;
|
|
788
788
|
}
|
|
789
|
-
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
789
|
+
T++, $("normal", s) && console.log(t.bold(` Processing: ${f.name}`)), $("verbose", s) && console.log(t.gray(` Tags: ${[...f.tags].join(", ")}`));
|
|
790
|
+
const x = K(
|
|
791
|
+
f.path,
|
|
792
|
+
f.tags,
|
|
793
793
|
n.exclude
|
|
794
794
|
);
|
|
795
|
-
for (const
|
|
796
|
-
const
|
|
797
|
-
if (
|
|
798
|
-
for (const b of
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
if (
|
|
795
|
+
for (const R of f.tags) {
|
|
796
|
+
const k = S[R];
|
|
797
|
+
if (k)
|
|
798
|
+
for (const b of k) {
|
|
799
|
+
F++;
|
|
800
|
+
const A = b.inlineContent ?? Re(u, b.template), I = b.inlineContent ? "Plugin" : "Custom";
|
|
801
|
+
if (!A) {
|
|
802
802
|
console.warn(t.yellow(` โ ๏ธ Template not found: ${b.template}`));
|
|
803
803
|
continue;
|
|
804
804
|
}
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
),
|
|
810
|
-
${
|
|
811
|
-
|
|
805
|
+
const B = w.getFrontmatter(x, f.name), X = w.format(
|
|
806
|
+
A,
|
|
807
|
+
x,
|
|
808
|
+
f.name
|
|
809
|
+
), Z = `${B}
|
|
810
|
+
${X}`, G = b.suffix, ee = d.join(h, G);
|
|
811
|
+
P.push(G), n.dryRun ? $("normal", s) && console.log(
|
|
812
812
|
t.cyan(
|
|
813
|
-
` ๐ Would generate: ${t.bold(
|
|
813
|
+
` ๐ Would generate: ${t.bold(G)} (from ${I})`
|
|
814
814
|
)
|
|
815
|
-
) : (p.writeFileSync(
|
|
815
|
+
) : (p.writeFileSync(ee, Z), $("normal", s) && console.log(
|
|
816
816
|
t.green(
|
|
817
|
-
` โ
Generated: ${t.bold(
|
|
817
|
+
` โ
Generated: ${t.bold(G)} (from ${I})`
|
|
818
818
|
)
|
|
819
819
|
));
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
823
|
M.succeed(
|
|
824
|
-
`Generated ${
|
|
825
|
-
), !n.dryRun && !n.skipPruning ? await
|
|
826
|
-
Would check for old files to prune...`)),
|
|
824
|
+
`Generated ${P.length} files from ${F} templates across ${T} projects`
|
|
825
|
+
), !n.dryRun && !n.skipPruning ? await Fe(h, P, n.force) : n.dryRun && $("verbose", s) && console.log(t.gray(`
|
|
826
|
+
Would check for old files to prune...`)), $("normal", s) && (console.log(`
|
|
827
827
|
${"โ".repeat(60)}`), n.dryRun ? (console.log(t.cyan("โจ Dry run complete! No files were modified.")), console.log(
|
|
828
828
|
t.gray(
|
|
829
|
-
`๐ Would have generated ${
|
|
829
|
+
`๐ Would have generated ${P.length} instruction file(s)`
|
|
830
830
|
)
|
|
831
831
|
), console.log(
|
|
832
832
|
t.gray(
|
|
833
|
-
`๐ From ${
|
|
833
|
+
`๐ From ${F} template(s) across ${T} project(s)`
|
|
834
834
|
)
|
|
835
835
|
)) : (console.log(t.green("โจ AI instruction alignment complete!")), console.log(
|
|
836
|
-
t.bold(`๐ Generated ${
|
|
836
|
+
t.bold(`๐ Generated ${P.length} instruction file(s)`)
|
|
837
837
|
), console.log(
|
|
838
838
|
t.gray(
|
|
839
|
-
`๐ From ${
|
|
839
|
+
`๐ From ${F} template(s) across ${T} project(s)`
|
|
840
840
|
)
|
|
841
841
|
), console.log(
|
|
842
842
|
t.gray(`๐ Files are located in: ${t.bold(o.outputDirectory)}`)
|
|
843
|
-
)), console.log("โ".repeat(60))), o.target === "github-copilot" &&
|
|
843
|
+
)), console.log("โ".repeat(60))), o.target === "github-copilot" && $("normal", s) && (console.log(`
|
|
844
844
|
--- VS Code + GitHub Copilot Tip ---`), console.log(
|
|
845
845
|
"To maximize Copilot's awareness, add this to your workspace .vscode/settings.json:"
|
|
846
846
|
), console.log(`
|
|
@@ -851,8 +851,8 @@ ${"โ".repeat(60)}`), n.dryRun ? (console.log(t.cyan("โจ Dry run complete! No
|
|
|
851
851
|
"This tells Copilot to *always* read these files. Restart VS Code after adding."
|
|
852
852
|
));
|
|
853
853
|
}
|
|
854
|
-
function
|
|
855
|
-
const n =
|
|
854
|
+
function be(e) {
|
|
855
|
+
const n = j(`Checking target directory: ${e}`).start();
|
|
856
856
|
if (p.existsSync(e))
|
|
857
857
|
n.succeed("Target directory OK.");
|
|
858
858
|
else {
|
|
@@ -871,7 +871,7 @@ function Pe(e) {
|
|
|
871
871
|
async function H() {
|
|
872
872
|
await C.getInstance().initialize();
|
|
873
873
|
}
|
|
874
|
-
async function
|
|
874
|
+
async function Se() {
|
|
875
875
|
await H();
|
|
876
876
|
const e = C.getInstance();
|
|
877
877
|
let n = [];
|
|
@@ -902,37 +902,37 @@ async function Te() {
|
|
|
902
902
|
continue;
|
|
903
903
|
}
|
|
904
904
|
for (const o of a) {
|
|
905
|
-
const
|
|
905
|
+
const c = `${o.name}.md`;
|
|
906
906
|
let i = null;
|
|
907
907
|
try {
|
|
908
908
|
i = typeof o.content == "function" ? await o.content() : o.content;
|
|
909
|
-
} catch (
|
|
909
|
+
} catch (l) {
|
|
910
910
|
console.warn(
|
|
911
911
|
t.yellow(
|
|
912
|
-
`โ ๏ธ Plugin ${r.name} template ${o.name} failed to load: ${
|
|
912
|
+
`โ ๏ธ Plugin ${r.name} template ${o.name} failed to load: ${l.message}`
|
|
913
913
|
)
|
|
914
914
|
);
|
|
915
915
|
}
|
|
916
|
-
for (const
|
|
917
|
-
s[
|
|
916
|
+
for (const l of o.tags)
|
|
917
|
+
s[l] || (s[l] = []), s[l].push({
|
|
918
918
|
template: `plugin:${r.name}/${o.name}`,
|
|
919
|
-
suffix:
|
|
919
|
+
suffix: c,
|
|
920
920
|
inlineContent: i ?? void 0
|
|
921
921
|
});
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
924
|
return s;
|
|
925
925
|
}
|
|
926
|
-
async function
|
|
926
|
+
async function Pe() {
|
|
927
927
|
await H();
|
|
928
928
|
const e = [], n = process.cwd(), r = await C.getInstance().detectAllProjects(n);
|
|
929
929
|
if (r.length === 0)
|
|
930
930
|
return [];
|
|
931
931
|
for (const a of r) {
|
|
932
|
-
const o =
|
|
932
|
+
const o = d.relative(n, a.metadata.projectPath);
|
|
933
933
|
e.push({
|
|
934
|
-
name:
|
|
935
|
-
a.metadata.name ||
|
|
934
|
+
name: Ce(
|
|
935
|
+
a.metadata.name || d.basename(a.metadata.projectPath)
|
|
936
936
|
),
|
|
937
937
|
path: o || ".",
|
|
938
938
|
tags: /* @__PURE__ */ new Set()
|
|
@@ -940,23 +940,23 @@ async function Ce() {
|
|
|
940
940
|
}
|
|
941
941
|
return e;
|
|
942
942
|
}
|
|
943
|
-
function
|
|
943
|
+
function Ce(e) {
|
|
944
944
|
let s = e.trim().replace(/^@/, "").replace(/[\\/\s]+/g, "-");
|
|
945
945
|
return s = s.replace(/-+/g, "-"), s;
|
|
946
946
|
}
|
|
947
|
-
async function
|
|
947
|
+
async function Te(e, n, s, r) {
|
|
948
948
|
await H();
|
|
949
|
-
const a =
|
|
949
|
+
const a = d.resolve(process.cwd(), e.path);
|
|
950
950
|
try {
|
|
951
|
-
const
|
|
952
|
-
if (
|
|
953
|
-
const i =
|
|
951
|
+
const c = await C.getInstance().detectAllProjects(a);
|
|
952
|
+
if (c.length > 0) {
|
|
953
|
+
const i = c[0].metadata;
|
|
954
954
|
if (i.tags?.length)
|
|
955
|
-
for (const
|
|
956
|
-
e.tags.add(
|
|
957
|
-
for (const
|
|
958
|
-
n[
|
|
959
|
-
const g =
|
|
955
|
+
for (const l of i.tags)
|
|
956
|
+
e.tags.add(l);
|
|
957
|
+
for (const l in i.dependencies) {
|
|
958
|
+
n[l] && e.tags.add(n[l]);
|
|
959
|
+
const g = l.split(/[@/:]/g).pop();
|
|
960
960
|
g && n[g] && e.tags.add(n[g]);
|
|
961
961
|
}
|
|
962
962
|
}
|
|
@@ -969,8 +969,8 @@ async function Fe(e, n, s, r) {
|
|
|
969
969
|
}
|
|
970
970
|
try {
|
|
971
971
|
for (const o in s) {
|
|
972
|
-
const
|
|
973
|
-
p.existsSync(i) && e.tags.add(
|
|
972
|
+
const c = s[o], i = d.join(a, o);
|
|
973
|
+
p.existsSync(i) && e.tags.add(c);
|
|
974
974
|
}
|
|
975
975
|
} catch (o) {
|
|
976
976
|
console.warn(
|
|
@@ -981,13 +981,13 @@ async function Fe(e, n, s, r) {
|
|
|
981
981
|
}
|
|
982
982
|
try {
|
|
983
983
|
for (const o in r) {
|
|
984
|
-
const
|
|
985
|
-
(await
|
|
984
|
+
const c = r[o];
|
|
985
|
+
(await ce(o, {
|
|
986
986
|
cwd: a,
|
|
987
987
|
nodir: !0,
|
|
988
988
|
dot: !0
|
|
989
989
|
// Include dotfiles if needed, though 'src' patterns usually don't
|
|
990
|
-
})).length > 0 && e.tags.add(
|
|
990
|
+
})).length > 0 && e.tags.add(c);
|
|
991
991
|
}
|
|
992
992
|
} catch (o) {
|
|
993
993
|
console.warn(
|
|
@@ -997,15 +997,15 @@ async function Fe(e, n, s, r) {
|
|
|
997
997
|
);
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
|
-
function
|
|
1001
|
-
const s =
|
|
1000
|
+
function Re(e, n) {
|
|
1001
|
+
const s = d.join(e, n);
|
|
1002
1002
|
try {
|
|
1003
1003
|
return p.readFileSync(s, "utf-8");
|
|
1004
1004
|
} catch {
|
|
1005
1005
|
return null;
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
|
-
async function
|
|
1008
|
+
async function Fe(e, n, s = !1) {
|
|
1009
1009
|
const a = p.readdirSync(e).filter((o) => o.endsWith(".md")).filter((o) => !n.includes(o));
|
|
1010
1010
|
if (a.length > 0) {
|
|
1011
1011
|
console.warn(
|
|
@@ -1014,8 +1014,8 @@ async function ke(e, n, s = !1) {
|
|
|
1014
1014
|
โ ๏ธ Found ${a.length} instruction files that are no longer generated:`
|
|
1015
1015
|
)
|
|
1016
1016
|
);
|
|
1017
|
-
for (const
|
|
1018
|
-
console.warn(t.yellow(` - ${
|
|
1017
|
+
for (const c of a)
|
|
1018
|
+
console.warn(t.yellow(` - ${c}`));
|
|
1019
1019
|
let o = s;
|
|
1020
1020
|
if (s || (o = (await W.prompt([
|
|
1021
1021
|
{
|
|
@@ -1025,27 +1025,27 @@ async function ke(e, n, s = !1) {
|
|
|
1025
1025
|
default: !1
|
|
1026
1026
|
}
|
|
1027
1027
|
])).prune), o) {
|
|
1028
|
-
let
|
|
1028
|
+
let c = 0;
|
|
1029
1029
|
for (const i of a)
|
|
1030
1030
|
try {
|
|
1031
|
-
p.unlinkSync(
|
|
1032
|
-
} catch (
|
|
1031
|
+
p.unlinkSync(d.join(e, i)), c++;
|
|
1032
|
+
} catch (l) {
|
|
1033
1033
|
console.error(
|
|
1034
|
-
t.red(` โ Error deleting ${i}: ${
|
|
1034
|
+
t.red(` โ Error deleting ${i}: ${l.message}`)
|
|
1035
1035
|
);
|
|
1036
1036
|
}
|
|
1037
|
-
console.log(`โ
Pruned ${
|
|
1037
|
+
console.log(`โ
Pruned ${c} old files.`);
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
|
-
async function
|
|
1041
|
+
async function ke() {
|
|
1042
1042
|
console.log(
|
|
1043
1043
|
t.cyan(`๐ Validating instruction files with quality scoring...
|
|
1044
1044
|
`)
|
|
1045
1045
|
);
|
|
1046
|
-
const e =
|
|
1046
|
+
const e = j("Loading configuration...").start(), n = N(), s = L(n);
|
|
1047
1047
|
e.succeed("Configuration loaded.");
|
|
1048
|
-
const r =
|
|
1048
|
+
const r = d.resolve(
|
|
1049
1049
|
process.cwd(),
|
|
1050
1050
|
s.outputDirectory
|
|
1051
1051
|
);
|
|
@@ -1076,13 +1076,13 @@ async function Ae() {
|
|
|
1076
1076
|
}
|
|
1077
1077
|
} catch {
|
|
1078
1078
|
}
|
|
1079
|
-
let
|
|
1080
|
-
const
|
|
1079
|
+
let c = 0, i = 0;
|
|
1080
|
+
const l = [];
|
|
1081
1081
|
for (const u of a) {
|
|
1082
|
-
const h =
|
|
1082
|
+
const h = d.join(r, u);
|
|
1083
1083
|
try {
|
|
1084
|
-
const w = p.readFileSync(h, "utf-8"), m =
|
|
1085
|
-
|
|
1084
|
+
const w = p.readFileSync(h, "utf-8"), m = ae(w), v = Ae(m.overallScore);
|
|
1085
|
+
l.push({ file: u, score: m.overallScore, grade: v }), m.overallScore >= 70 ? c++ : i++;
|
|
1086
1086
|
const D = m.overallScore >= 90 ? t.green : m.overallScore >= 70 ? t.blue : t.yellow;
|
|
1087
1087
|
console.log(
|
|
1088
1088
|
D(`${v} ${m.overallScore}/100`) + t.gray(` - ${u}`)
|
|
@@ -1103,12 +1103,12 @@ async function Ae() {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
console.log(t.bold(`
|
|
1105
1105
|
=== Validation Summary ===
|
|
1106
|
-
`)), console.log(t.green(`โ
Passed (โฅ70): ${
|
|
1107
|
-
const g =
|
|
1106
|
+
`)), console.log(t.green(`โ
Passed (โฅ70): ${c}`)), console.log(t.red(`โ Failed (<70): ${i}`));
|
|
1107
|
+
const g = l.reduce((u, h) => u + h.score, 0) / l.length;
|
|
1108
1108
|
console.log(t.cyan(`๐ Average Score: ${Math.round(g)}/100`)), o.track({
|
|
1109
1109
|
type: "summary",
|
|
1110
|
-
files:
|
|
1111
|
-
pass:
|
|
1110
|
+
files: l.length,
|
|
1111
|
+
pass: c,
|
|
1112
1112
|
fail: i,
|
|
1113
1113
|
averageScore: Math.round(g)
|
|
1114
1114
|
}), i === 0 && g >= 80 ? console.log(t.green(`
|
|
@@ -1119,25 +1119,25 @@ async function Ae() {
|
|
|
1119
1119
|
)
|
|
1120
1120
|
);
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function Ae(e) {
|
|
1123
1123
|
return e >= 90 ? "A" : e >= 80 ? "B" : e >= 70 ? "C" : e >= 60 ? "D" : "F";
|
|
1124
1124
|
}
|
|
1125
|
-
function
|
|
1125
|
+
function De() {
|
|
1126
1126
|
try {
|
|
1127
|
-
const e =
|
|
1128
|
-
return JSON.parse(
|
|
1127
|
+
const e = U(import.meta.url), n = se(e), s = ie(n, "..", "package.json");
|
|
1128
|
+
return JSON.parse(oe(s, "utf-8")).version;
|
|
1129
1129
|
} catch {
|
|
1130
1130
|
return "2.0.0-beta.1";
|
|
1131
1131
|
}
|
|
1132
1132
|
}
|
|
1133
1133
|
async function ze() {
|
|
1134
1134
|
try {
|
|
1135
|
-
const e = new
|
|
1135
|
+
const e = new re();
|
|
1136
1136
|
e.name("magic-helix").description(
|
|
1137
1137
|
"Magic Helix CLI for aligning AI instructions in your monorepo."
|
|
1138
|
-
).version(
|
|
1138
|
+
).version(De()), e.command("init").description(
|
|
1139
1139
|
"Initialize a custom magic-helix.config.json to extend the built-in rules."
|
|
1140
|
-
).action(
|
|
1140
|
+
).action(ue), e.command("run").description(
|
|
1141
1141
|
"Scan the monorepo and generate AI instruction files based on built-in and custom rules."
|
|
1142
1142
|
).option(
|
|
1143
1143
|
"--dry-run",
|
|
@@ -1151,24 +1151,24 @@ async function ze() {
|
|
|
1151
1151
|
).option(
|
|
1152
1152
|
"--exclude <pattern>",
|
|
1153
1153
|
"Exclude files matching pattern (e.g., 'test/**,*.spec.ts')"
|
|
1154
|
-
).action(
|
|
1154
|
+
).action(J), e.command("refresh").description(
|
|
1155
1155
|
"Rescan the project and update existing instruction files with changed project information."
|
|
1156
1156
|
).alias("resync").option("--config <path>", "Path to custom config file").option(
|
|
1157
1157
|
"--target <assistant>",
|
|
1158
1158
|
"AI assistant target (github-copilot, claude, copilot-chat, generic)"
|
|
1159
|
-
).option("--verbose", "Show detailed output").option("--quiet", "Show minimal output").option("--project <name>", "Target a specific project only").action(
|
|
1159
|
+
).option("--verbose", "Show detailed output").option("--quiet", "Show minimal output").option("--project <name>", "Target a specific project only").action(we), e.command("list").description(
|
|
1160
1160
|
"Show detected projects, tags, and templates without generating files."
|
|
1161
|
-
).action(
|
|
1161
|
+
).action(de), e.command("validate").description("Check instruction files for common issues and integrity.").action(ke), e.command("clean").description("Remove all generated instruction files.").action(le), e.command("plugins").description(
|
|
1162
1162
|
"List available language detection plugins and their status."
|
|
1163
|
-
).option("--verbose", "Show detailed plugin information").action((n) =>
|
|
1163
|
+
).option("--verbose", "Show detailed plugin information").action((n) => me(n)), process.argv.length < 3 && e.action(J), await e.parseAsync(process.argv);
|
|
1164
1164
|
} catch (e) {
|
|
1165
1165
|
console.error(
|
|
1166
1166
|
t.red(`โ An unexpected error occurred: ${e.message}`)
|
|
1167
1167
|
), process.exit(1);
|
|
1168
1168
|
}
|
|
1169
1169
|
}
|
|
1170
|
-
const Ee =
|
|
1171
|
-
|
|
1170
|
+
const Ee = U(import.meta.url), V = process.argv[1] ? te(ne(process.argv[1])) : null;
|
|
1171
|
+
V && Ee === V && ze();
|
|
1172
1172
|
export {
|
|
1173
1173
|
ze as main
|
|
1174
1174
|
};
|