@el-j/magic-agent-helix 4.0.0-beta.1 โ 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +327 -235
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import * as p from "node:fs";
|
|
3
3
|
import { realpathSync as se, readFileSync as ie } from "node:fs";
|
|
4
4
|
import * as f from "node:path";
|
|
5
|
-
import { resolve as re, dirname as ae, join as
|
|
5
|
+
import { resolve as re, dirname as ae, join as le } from "node:path";
|
|
6
6
|
import { fileURLToPath as Y } from "node:url";
|
|
7
|
-
import { Command as
|
|
7
|
+
import { Command as ce } from "commander";
|
|
8
8
|
import t from "picocolors";
|
|
9
|
-
import { loadUserConfig as
|
|
9
|
+
import { loadUserConfig as O, mergeConfigs as L, PluginRegistry as C, getFormatter as K, BUILT_IN_TEMPLATE_DIR as Q, validateInstructions as ge } from "@el-j/magic-helix-core";
|
|
10
10
|
import W from "inquirer";
|
|
11
|
-
import
|
|
11
|
+
import x from "ora";
|
|
12
12
|
import q from "gradient-string";
|
|
13
13
|
import { glob as ue } from "glob";
|
|
14
14
|
async function de() {
|
|
15
15
|
console.log(t.cyan(`๐งน Cleaning generated instruction files...
|
|
16
16
|
`));
|
|
17
|
-
const e =
|
|
17
|
+
const e = x("Loading configuration...").start(), n = O(), s = L(n);
|
|
18
18
|
e.succeed("Configuration loaded.");
|
|
19
19
|
const r = f.resolve(
|
|
20
20
|
process.cwd(),
|
|
@@ -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 l = x("Deleting files...").start();
|
|
58
|
+
let i = 0, c = 0;
|
|
59
59
|
for (const g of a)
|
|
60
60
|
try {
|
|
61
61
|
p.unlinkSync(f.join(r, g)), i++;
|
|
62
62
|
} catch (u) {
|
|
63
63
|
console.error(
|
|
64
64
|
t.red(` โ Error deleting ${g}: ${u.message}`)
|
|
65
|
-
),
|
|
65
|
+
), c++;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
c === 0 ? l.succeed(
|
|
68
68
|
t.green(`โ
Successfully deleted ${i} file(s).`)
|
|
69
|
-
) :
|
|
69
|
+
) : l.warn(
|
|
70
70
|
t.yellow(
|
|
71
|
-
`โ ๏ธ Deleted ${i} file(s), ${
|
|
71
|
+
`โ ๏ธ Deleted ${i} file(s), ${c} error(s) occurred.`
|
|
72
72
|
)
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
const G = "magic-helix.config.json",
|
|
75
|
+
const G = "magic-helix.config.json", N = "ai_templates", fe = {
|
|
76
76
|
target: "github-copilot",
|
|
77
|
-
templateDirectory:
|
|
77
|
+
templateDirectory: N,
|
|
78
78
|
outputDirectory: ".github/instructions",
|
|
79
79
|
dependencyTagMap: {
|
|
80
80
|
// "my-internal-package": "domain-my-rules"
|
|
@@ -92,9 +92,9 @@ const G = "magic-helix.config.json", z = "ai_templates", fe = {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
async function pe() {
|
|
95
|
-
const e =
|
|
95
|
+
const e = x(
|
|
96
96
|
t.bold("Initializing Magic Helix for custom rules...")
|
|
97
|
-
).start(), n = f.resolve(process.cwd(), G), s = f.resolve(process.cwd(),
|
|
97
|
+
).start(), n = f.resolve(process.cwd(), G), s = f.resolve(process.cwd(), N);
|
|
98
98
|
if (p.existsSync(n)) {
|
|
99
99
|
e.stop();
|
|
100
100
|
const { overwrite: a } = await W.prompt([
|
|
@@ -127,7 +127,7 @@ async function pe() {
|
|
|
127
127
|
const r = f.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(N)} 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(N)}`
|
|
142
142
|
)
|
|
143
143
|
)), console.log(
|
|
144
144
|
q.pastel.multiline(
|
|
@@ -149,7 +149,7 @@ async function pe() {
|
|
|
149
149
|
Next steps:`)), console.log(
|
|
150
150
|
` 1. Edit ${t.bold(G)} 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(N)}.`
|
|
153
153
|
), console.log(
|
|
154
154
|
` 3. Run ${t.bold("npx @el-j/magic-agent-helix run")} to generate your files.`
|
|
155
155
|
);
|
|
@@ -157,16 +157,16 @@ Next steps:`)), console.log(
|
|
|
157
157
|
async function me() {
|
|
158
158
|
console.log(t.cyan(`๐ Listing project information...
|
|
159
159
|
`));
|
|
160
|
-
const e =
|
|
160
|
+
const e = x("Loading configuration...").start(), n = O(), 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: l } = s, i = x("Scanning for projects...").start(), c = await ye();
|
|
163
|
+
if (c.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
|
|
167
|
+
i.succeed(`Found ${c.length} projects.`);
|
|
168
|
+
const g = x("Analyzing projects...").start();
|
|
169
|
+
for (const u of c)
|
|
170
170
|
await he(
|
|
171
171
|
u,
|
|
172
172
|
r,
|
|
@@ -176,19 +176,19 @@ 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 c) {
|
|
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
|
-
const
|
|
184
|
+
const h = [];
|
|
185
185
|
for (const w of u.tags) {
|
|
186
|
-
const m =
|
|
186
|
+
const m = l[w];
|
|
187
187
|
if (m)
|
|
188
|
-
for (const
|
|
189
|
-
|
|
188
|
+
for (const v of m)
|
|
189
|
+
h.push(`${u.name}.${v.suffix}`);
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
h.length > 0 && console.log(t.gray(` Would generate: ${h.join(", ")}`));
|
|
192
192
|
}
|
|
193
193
|
console.log();
|
|
194
194
|
}
|
|
@@ -196,16 +196,16 @@ async function me() {
|
|
|
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
198
|
async function ye() {
|
|
199
|
-
const e = [], n = process.cwd(), s =
|
|
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 l = f.relative(n, o.projectPath);
|
|
206
206
|
e.push({
|
|
207
207
|
name: o.name || f.basename(o.projectPath),
|
|
208
|
-
path:
|
|
208
|
+
path: l || ".",
|
|
209
209
|
tags: /* @__PURE__ */ new Set()
|
|
210
210
|
});
|
|
211
211
|
}
|
|
@@ -214,13 +214,13 @@ async function ye() {
|
|
|
214
214
|
async function he(e, n, s, r) {
|
|
215
215
|
const a = f.resolve(process.cwd(), e.path);
|
|
216
216
|
try {
|
|
217
|
-
const i = (await
|
|
217
|
+
const i = (await C.getInstance().detectAllProjects(a)).map((c) => c.metadata);
|
|
218
218
|
if (i.length > 0) {
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
221
|
-
for (const g of
|
|
219
|
+
const c = i[0];
|
|
220
|
+
if (c.tags?.length)
|
|
221
|
+
for (const g of c.tags)
|
|
222
222
|
e.tags.add(g);
|
|
223
|
-
for (const g in
|
|
223
|
+
for (const g in c.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 l = s[o], i = f.join(a, o);
|
|
234
|
+
p.existsSync(i) && e.tags.add(l);
|
|
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 l in r) {
|
|
241
|
+
const i = r[l];
|
|
242
|
+
(await o(l, {
|
|
243
243
|
cwd: a,
|
|
244
244
|
nodir: !0,
|
|
245
245
|
dot: !0
|
|
@@ -251,7 +251,7 @@ async function he(e, n, s, r) {
|
|
|
251
251
|
async function we(e = {}) {
|
|
252
252
|
console.log(t.blue("๐ MagicAgentHelix Plugin System")), console.log();
|
|
253
253
|
try {
|
|
254
|
-
const n =
|
|
254
|
+
const n = C.getInstance();
|
|
255
255
|
await n.initialize({ verbose: e.verbose });
|
|
256
256
|
const s = await n.getAllPlugins(), r = n.getStatistics();
|
|
257
257
|
if (s.length === 0) {
|
|
@@ -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, l) => l.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 l = 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[l](`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 c = o.getDependencyTagMap?.();
|
|
274
|
+
c && Object.keys(c).length > 0 && console.log(
|
|
275
|
+
` ๐ท๏ธ Detects: ${Object.keys(c).slice(0, 3).join(", ")}${Object.keys(c).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 l of o)
|
|
283
|
+
console.log(`โ ${l.source.identifier}: ${l.error.message}`);
|
|
284
284
|
}
|
|
285
285
|
} catch (n) {
|
|
286
286
|
console.error(
|
|
@@ -324,6 +324,54 @@ const $e = {
|
|
|
324
324
|
extensions: ["py"],
|
|
325
325
|
description: "Python files"
|
|
326
326
|
},
|
|
327
|
+
"lang-rust": {
|
|
328
|
+
extensions: ["rs"],
|
|
329
|
+
description: "Rust files"
|
|
330
|
+
},
|
|
331
|
+
"rust-embedded": {
|
|
332
|
+
extensions: ["rs"],
|
|
333
|
+
description: "Embedded Rust files"
|
|
334
|
+
},
|
|
335
|
+
hardware2rust: {
|
|
336
|
+
extensions: ["rs"],
|
|
337
|
+
description: "Hardware2Rust project files"
|
|
338
|
+
},
|
|
339
|
+
"lang-java": {
|
|
340
|
+
extensions: ["java"],
|
|
341
|
+
description: "Java files"
|
|
342
|
+
},
|
|
343
|
+
"lang-swift": {
|
|
344
|
+
extensions: ["swift"],
|
|
345
|
+
description: "Swift files"
|
|
346
|
+
},
|
|
347
|
+
"lang-ruby": {
|
|
348
|
+
extensions: ["rb"],
|
|
349
|
+
description: "Ruby files"
|
|
350
|
+
},
|
|
351
|
+
"lang-php": {
|
|
352
|
+
extensions: ["php"],
|
|
353
|
+
description: "PHP files"
|
|
354
|
+
},
|
|
355
|
+
"lang-csharp": {
|
|
356
|
+
extensions: ["cs"],
|
|
357
|
+
description: "C# files"
|
|
358
|
+
},
|
|
359
|
+
"lang-cpp": {
|
|
360
|
+
extensions: ["cpp", "hpp", "cc", "h", "cxx", "hxx"],
|
|
361
|
+
description: "C++ files"
|
|
362
|
+
},
|
|
363
|
+
"lang-c": {
|
|
364
|
+
extensions: ["c", "h"],
|
|
365
|
+
description: "C files"
|
|
366
|
+
},
|
|
367
|
+
"lang-kotlin": {
|
|
368
|
+
extensions: ["kt", "kts"],
|
|
369
|
+
description: "Kotlin files"
|
|
370
|
+
},
|
|
371
|
+
"lang-scala": {
|
|
372
|
+
extensions: ["scala", "sc"],
|
|
373
|
+
description: "Scala files"
|
|
374
|
+
},
|
|
327
375
|
// Styling
|
|
328
376
|
"style-tailwind": {
|
|
329
377
|
extensions: ["ts", "tsx", "js", "jsx", "vue"],
|
|
@@ -386,18 +434,18 @@ function je(e) {
|
|
|
386
434
|
}
|
|
387
435
|
function X(e, n, s) {
|
|
388
436
|
const r = /* @__PURE__ */ new Set();
|
|
389
|
-
for (const
|
|
390
|
-
const i = je(
|
|
391
|
-
for (const
|
|
392
|
-
r.add(
|
|
437
|
+
for (const l of n) {
|
|
438
|
+
const i = je(l);
|
|
439
|
+
for (const c of i)
|
|
440
|
+
r.add(c);
|
|
393
441
|
}
|
|
394
442
|
if (r.size === 0)
|
|
395
443
|
return `${e}/src/**/*.{ts,js,vue,tsx,jsx}`;
|
|
396
444
|
const a = Array.from(r).join(",");
|
|
397
445
|
let o = `${e}/src/**/*.{${a}}`;
|
|
398
446
|
if (s) {
|
|
399
|
-
const
|
|
400
|
-
for (const i of
|
|
447
|
+
const l = s.split(",").map((i) => i.trim());
|
|
448
|
+
for (const i of l)
|
|
401
449
|
i.endsWith("/**") ? o += ` !(${e}/src/${i})` : i.includes("*") ? o += ` !(${e}/src/${i})` : o += ` !(${e}/src/${i})`;
|
|
402
450
|
}
|
|
403
451
|
return o;
|
|
@@ -405,20 +453,20 @@ function X(e, n, s) {
|
|
|
405
453
|
function Z(e) {
|
|
406
454
|
return e.quiet ? "quiet" : e.verbose ? "verbose" : "normal";
|
|
407
455
|
}
|
|
408
|
-
function
|
|
456
|
+
function j(e, n) {
|
|
409
457
|
return !(n === "quiet" && e !== "error" || n === "normal" && e === "verbose");
|
|
410
458
|
}
|
|
411
|
-
async function
|
|
459
|
+
async function xe(e = {}) {
|
|
412
460
|
Z(e);
|
|
413
|
-
const n =
|
|
461
|
+
const n = x("Loading configurations...").start(), s = O(e.config), r = L(s);
|
|
414
462
|
e.target && (r.target = e.target), n.succeed("Configuration loaded.");
|
|
415
|
-
const { dependencyTagMap: a, configFileTagMap: o, fileGlobTagMap:
|
|
463
|
+
const { dependencyTagMap: a, configFileTagMap: o, fileGlobTagMap: l, tagTemplateMap: i } = r, c = f.resolve(
|
|
416
464
|
process.cwd(),
|
|
417
465
|
r.templateDirectory
|
|
418
466
|
), g = f.resolve(
|
|
419
467
|
process.cwd(),
|
|
420
468
|
r.outputDirectory
|
|
421
|
-
), u =
|
|
469
|
+
), u = K(r.target);
|
|
422
470
|
if (!p.existsSync(g)) {
|
|
423
471
|
console.log(
|
|
424
472
|
t.yellow(
|
|
@@ -429,62 +477,62 @@ async function ve(e = {}) {
|
|
|
429
477
|
);
|
|
430
478
|
return;
|
|
431
479
|
}
|
|
432
|
-
const
|
|
480
|
+
const h = x("Scanning for projects...").start(), w = await ve();
|
|
433
481
|
if (w.length === 0) {
|
|
434
|
-
|
|
482
|
+
h.warn(
|
|
435
483
|
t.yellow(
|
|
436
484
|
'No projects found. Make sure your root package.json has a "workspaces" field.'
|
|
437
485
|
)
|
|
438
486
|
);
|
|
439
487
|
return;
|
|
440
488
|
}
|
|
441
|
-
|
|
442
|
-
const m =
|
|
443
|
-
let
|
|
444
|
-
for (const
|
|
489
|
+
h.succeed(`Found ${w.length} projects.`);
|
|
490
|
+
const m = x("Analyzing project tags...").start();
|
|
491
|
+
let v = 0;
|
|
492
|
+
for (const y of w)
|
|
445
493
|
await be(
|
|
446
|
-
|
|
494
|
+
y,
|
|
447
495
|
a,
|
|
448
496
|
o,
|
|
449
|
-
|
|
450
|
-
),
|
|
451
|
-
m.succeed(`Project analysis complete. Found ${
|
|
497
|
+
l
|
|
498
|
+
), v += y.tags.size;
|
|
499
|
+
m.succeed(`Project analysis complete. Found ${v} tags.`), console.log(
|
|
452
500
|
t.cyan(`
|
|
453
501
|
Refreshing instruction files in ${r.outputDirectory}...`)
|
|
454
502
|
);
|
|
455
503
|
let D = 0, E = 0;
|
|
456
|
-
for (const
|
|
457
|
-
if (
|
|
458
|
-
console.log(t.gray(` Skipping: ${
|
|
504
|
+
for (const y of w) {
|
|
505
|
+
if (y.tags.size === 0) {
|
|
506
|
+
console.log(t.gray(` Skipping: ${y.name} (No matching tags)`)), E++;
|
|
459
507
|
continue;
|
|
460
508
|
}
|
|
461
|
-
console.log(t.bold(` Processing: ${
|
|
462
|
-
const
|
|
463
|
-
for (const
|
|
464
|
-
const
|
|
465
|
-
if (
|
|
466
|
-
for (const S of
|
|
467
|
-
const
|
|
468
|
-
if (!p.existsSync(
|
|
509
|
+
console.log(t.bold(` Processing: ${y.name}`)), console.log(t.gray(` Tags: ${[...y.tags].join(", ")}`));
|
|
510
|
+
const I = X(y.path, y.tags);
|
|
511
|
+
for (const P of y.tags) {
|
|
512
|
+
const M = i[P];
|
|
513
|
+
if (M)
|
|
514
|
+
for (const S of M) {
|
|
515
|
+
const R = `${y.name}.${S.suffix}`, k = f.join(g, R);
|
|
516
|
+
if (!p.existsSync(k)) {
|
|
469
517
|
console.log(
|
|
470
|
-
t.yellow(` โ ๏ธ File not found, skipping: ${
|
|
518
|
+
t.yellow(` โ ๏ธ File not found, skipping: ${R}`)
|
|
471
519
|
);
|
|
472
520
|
continue;
|
|
473
521
|
}
|
|
474
|
-
let d = J(
|
|
475
|
-
if (d || (d = J(
|
|
522
|
+
let d = J(c, S.template), $ = "Custom";
|
|
523
|
+
if (d || (d = J(Q, S.template), $ = "Built-in"), !d) {
|
|
476
524
|
console.warn(t.yellow(` โ ๏ธ Template not found: ${S.template}`));
|
|
477
525
|
continue;
|
|
478
526
|
}
|
|
479
|
-
const
|
|
527
|
+
const F = u.getFrontmatter(I, y.name), A = u.format(
|
|
480
528
|
d,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
), b = `${
|
|
484
|
-
${
|
|
485
|
-
p.writeFileSync(
|
|
529
|
+
I,
|
|
530
|
+
y.name
|
|
531
|
+
), b = `${F}
|
|
532
|
+
${A}`;
|
|
533
|
+
p.writeFileSync(k, b), D++, console.log(
|
|
486
534
|
t.green(
|
|
487
|
-
` โ
Refreshed: ${t.bold(
|
|
535
|
+
` โ
Refreshed: ${t.bold(R)} (from ${$})`
|
|
488
536
|
)
|
|
489
537
|
);
|
|
490
538
|
}
|
|
@@ -493,17 +541,17 @@ ${k}`;
|
|
|
493
541
|
console.log(`
|
|
494
542
|
โจ Refresh complete!`), console.log(t.green(` Updated: ${D} files`)), console.log(t.gray(` Skipped: ${E} projects`));
|
|
495
543
|
}
|
|
496
|
-
async function
|
|
497
|
-
const e = [], n = process.cwd(), s =
|
|
544
|
+
async function ve() {
|
|
545
|
+
const e = [], n = process.cwd(), s = C.getInstance();
|
|
498
546
|
await s.initialize();
|
|
499
547
|
const a = (await s.detectAllProjects(n)).map((o) => o.metadata);
|
|
500
548
|
if (a.length === 0)
|
|
501
549
|
return [];
|
|
502
550
|
for (const o of a) {
|
|
503
|
-
const
|
|
551
|
+
const l = f.relative(n, o.projectPath);
|
|
504
552
|
e.push({
|
|
505
553
|
name: o.name || f.basename(o.projectPath),
|
|
506
|
-
path:
|
|
554
|
+
path: l || ".",
|
|
507
555
|
tags: /* @__PURE__ */ new Set()
|
|
508
556
|
});
|
|
509
557
|
}
|
|
@@ -512,13 +560,13 @@ async function xe() {
|
|
|
512
560
|
async function be(e, n, s, r) {
|
|
513
561
|
const a = f.resolve(process.cwd(), e.path);
|
|
514
562
|
try {
|
|
515
|
-
const i = (await
|
|
563
|
+
const i = (await C.getInstance().detectAllProjects(a)).map((c) => c.metadata);
|
|
516
564
|
if (i.length > 0) {
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
519
|
-
for (const g of
|
|
565
|
+
const c = i[0];
|
|
566
|
+
if (c.tags?.length)
|
|
567
|
+
for (const g of c.tags)
|
|
520
568
|
e.tags.add(g);
|
|
521
|
-
for (const g in
|
|
569
|
+
for (const g in c.dependencies) {
|
|
522
570
|
n[g] && e.tags.add(n[g]);
|
|
523
571
|
const u = g.split(/[@/:]/g).pop();
|
|
524
572
|
u && n[u] && e.tags.add(n[u]);
|
|
@@ -533,8 +581,8 @@ async function be(e, n, s, r) {
|
|
|
533
581
|
}
|
|
534
582
|
try {
|
|
535
583
|
for (const o in s) {
|
|
536
|
-
const
|
|
537
|
-
p.existsSync(i) && e.tags.add(
|
|
584
|
+
const l = s[o], i = f.join(a, o);
|
|
585
|
+
p.existsSync(i) && e.tags.add(l);
|
|
538
586
|
}
|
|
539
587
|
} catch (o) {
|
|
540
588
|
console.warn(
|
|
@@ -545,9 +593,9 @@ async function be(e, n, s, r) {
|
|
|
545
593
|
}
|
|
546
594
|
try {
|
|
547
595
|
const { glob: o } = await import("glob");
|
|
548
|
-
for (const
|
|
549
|
-
const i = r[
|
|
550
|
-
(await o(
|
|
596
|
+
for (const l in r) {
|
|
597
|
+
const i = r[l];
|
|
598
|
+
(await o(l, {
|
|
551
599
|
cwd: a,
|
|
552
600
|
nodir: !0,
|
|
553
601
|
dot: !0
|
|
@@ -626,141 +674,173 @@ async function Se() {
|
|
|
626
674
|
โ
Configuration complete! Starting analysis...
|
|
627
675
|
`)), n;
|
|
628
676
|
}
|
|
629
|
-
async function
|
|
677
|
+
async function V(e = {}) {
|
|
630
678
|
let n = e;
|
|
631
679
|
e.wizard && (n = { ...await Se(), ...e });
|
|
632
680
|
const s = Z(n);
|
|
633
|
-
|
|
681
|
+
j("normal", s) && console.log(
|
|
634
682
|
q.pastel.multiline("๐ค Running AI Convention Aligner...")
|
|
635
|
-
), n.dryRun &&
|
|
683
|
+
), n.dryRun && j("normal", s) && console.log(t.yellow(`๐ DRY RUN MODE - No files will be written
|
|
636
684
|
`));
|
|
637
|
-
const r =
|
|
685
|
+
const r = x("Loading configurations...").start(), a = O(n.config), o = L(a);
|
|
638
686
|
n.outputDir && (o.outputDirectory = n.outputDir), n.target && (o.target = n.target), r.succeed("Configuration loaded.");
|
|
639
|
-
const { dependencyTagMap:
|
|
687
|
+
const { dependencyTagMap: l, configFileTagMap: i, fileGlobTagMap: c, tagTemplateMap: g } = o, u = f.resolve(
|
|
640
688
|
process.cwd(),
|
|
641
689
|
o.templateDirectory
|
|
642
|
-
),
|
|
690
|
+
), h = f.resolve(
|
|
643
691
|
process.cwd(),
|
|
644
692
|
o.outputDirectory
|
|
645
|
-
), w =
|
|
646
|
-
if (
|
|
693
|
+
), w = K(o.target), m = x("Scanning for projects...").start(), v = await Ce();
|
|
694
|
+
if (v.length === 0) {
|
|
647
695
|
m.warn(
|
|
648
696
|
t.yellow(
|
|
649
|
-
|
|
697
|
+
"No projects detected. The tool could not find any supported project types in the current directory."
|
|
698
|
+
)
|
|
699
|
+
), console.log(
|
|
700
|
+
t.gray(
|
|
701
|
+
`
|
|
702
|
+
Supported project types: Node.js, Python, Go, Rust, Java, Ruby, PHP, C#, Swift, C/C++, PlatformIO`
|
|
703
|
+
)
|
|
704
|
+
), console.log(
|
|
705
|
+
t.gray(
|
|
706
|
+
'For monorepos, ensure your root package.json has a "workspaces" field.'
|
|
707
|
+
)
|
|
708
|
+
), console.log(
|
|
709
|
+
t.gray(
|
|
710
|
+
"For standalone projects, ensure you have the appropriate manifest file (package.json, go.mod, Cargo.toml, platformio.ini, etc.)"
|
|
650
711
|
)
|
|
651
712
|
);
|
|
652
713
|
return;
|
|
653
714
|
}
|
|
654
|
-
m.succeed(`Found ${
|
|
655
|
-
const D =
|
|
715
|
+
m.succeed(`Found ${v.length} projects.`);
|
|
716
|
+
const D = x("Analyzing project tags...").start();
|
|
656
717
|
let E = 0;
|
|
657
|
-
for (const d of
|
|
718
|
+
for (const d of v) {
|
|
658
719
|
if (n.project && d.name !== n.project) {
|
|
659
|
-
|
|
720
|
+
j("verbose", s) && console.log(t.gray(`Skipping ${d.name} (not target project)`));
|
|
660
721
|
continue;
|
|
661
722
|
}
|
|
662
|
-
await
|
|
723
|
+
await Fe(
|
|
663
724
|
d,
|
|
664
|
-
|
|
725
|
+
l,
|
|
665
726
|
i,
|
|
666
|
-
|
|
727
|
+
c
|
|
667
728
|
), E += d.tags.size;
|
|
668
729
|
}
|
|
669
|
-
D.succeed(`Project analysis complete. Found ${E} tags.`), n.dryRun ?
|
|
670
|
-
let
|
|
730
|
+
D.succeed(`Project analysis complete. Found ${E} tags.`), n.dryRun ? j("verbose", s) && console.log(t.gray(`Would ensure directory: ${h}`)) : Pe(h);
|
|
731
|
+
let y = g;
|
|
671
732
|
if (n.template) {
|
|
672
733
|
const d = n.template.split(",").map(($) => $.trim());
|
|
673
|
-
|
|
674
|
-
for (const [$,
|
|
675
|
-
const
|
|
676
|
-
if (
|
|
677
|
-
const
|
|
678
|
-
return
|
|
734
|
+
y = {};
|
|
735
|
+
for (const [$, F] of Object.entries(g)) {
|
|
736
|
+
const A = F.filter((b) => d.some((T) => {
|
|
737
|
+
if (T.includes("*")) {
|
|
738
|
+
const z = new RegExp(T.replace(/\*/g, ".*"));
|
|
739
|
+
return z.test(b.template) || z.test($);
|
|
679
740
|
}
|
|
680
|
-
return b.template.includes(
|
|
741
|
+
return b.template.includes(T) || $.includes(T);
|
|
681
742
|
}));
|
|
682
|
-
|
|
743
|
+
A.length > 0 && (y[$] = A);
|
|
683
744
|
}
|
|
684
|
-
|
|
745
|
+
j("verbose", s) && console.log(
|
|
685
746
|
t.gray(`Template filter applied: ${n.template}`)
|
|
686
747
|
);
|
|
687
748
|
}
|
|
688
|
-
const
|
|
689
|
-
for (const [d, $] of Object.entries(
|
|
690
|
-
|
|
691
|
-
template:
|
|
692
|
-
suffix:
|
|
749
|
+
const I = await Te(), P = {};
|
|
750
|
+
for (const [d, $] of Object.entries(y))
|
|
751
|
+
P[d] = $.map((F) => ({
|
|
752
|
+
template: F.template,
|
|
753
|
+
suffix: F.suffix
|
|
693
754
|
}));
|
|
694
|
-
for (const [d, $] of Object.entries(
|
|
695
|
-
|
|
696
|
-
|
|
755
|
+
for (const [d, $] of Object.entries(I))
|
|
756
|
+
P[d] || (P[d] = []), P[d].push(...$);
|
|
757
|
+
j("verbose", s) && (console.log(t.gray(`
|
|
758
|
+
--- Template Map Debug ---`)), console.log(
|
|
759
|
+
t.gray(
|
|
760
|
+
`Plugin templates: ${Object.keys(I).length} tags`
|
|
761
|
+
)
|
|
762
|
+
), console.log(
|
|
763
|
+
t.gray(` Tags: ${Object.keys(I).join(", ")}`)
|
|
764
|
+
), console.log(
|
|
765
|
+
t.gray(
|
|
766
|
+
`Config templates: ${Object.keys(y).length} tags`
|
|
767
|
+
)
|
|
768
|
+
), console.log(
|
|
769
|
+
t.gray(` Tags: ${Object.keys(y).join(", ")}`)
|
|
770
|
+
), console.log(
|
|
771
|
+
t.gray(
|
|
772
|
+
`Combined templates: ${Object.keys(P).length} tags`
|
|
773
|
+
)
|
|
774
|
+
), console.log(
|
|
775
|
+
t.gray(` Tags: ${Object.keys(P).join(", ")}`)
|
|
776
|
+
)), j("normal", s) && console.log(
|
|
697
777
|
t.cyan(`
|
|
698
778
|
Generating instruction files in ${o.outputDirectory}...`)
|
|
699
779
|
);
|
|
700
|
-
const
|
|
701
|
-
let
|
|
702
|
-
for (const d of
|
|
780
|
+
const M = x("Generating instruction files...").start(), S = [];
|
|
781
|
+
let R = 0, k = 0;
|
|
782
|
+
for (const d of v) {
|
|
703
783
|
if (n.project && d.name !== n.project)
|
|
704
784
|
continue;
|
|
705
785
|
if (d.tags.size === 0) {
|
|
706
|
-
|
|
786
|
+
j("normal", s) && console.log(t.gray(` Skipping: ${d.name} (No matching tags)`));
|
|
707
787
|
continue;
|
|
708
788
|
}
|
|
709
|
-
|
|
789
|
+
R++, j("normal", s) && console.log(t.bold(` Processing: ${d.name}`)), j("verbose", s) && console.log(t.gray(` Tags: ${[...d.tags].join(", ")}`));
|
|
710
790
|
const $ = X(
|
|
711
791
|
d.path,
|
|
712
792
|
d.tags,
|
|
713
793
|
n.exclude
|
|
714
794
|
);
|
|
715
|
-
for (const
|
|
716
|
-
const
|
|
717
|
-
if (
|
|
718
|
-
for (const b of
|
|
719
|
-
|
|
720
|
-
let
|
|
721
|
-
if (
|
|
795
|
+
for (const F of d.tags) {
|
|
796
|
+
const A = P[F];
|
|
797
|
+
if (A)
|
|
798
|
+
for (const b of A) {
|
|
799
|
+
k++;
|
|
800
|
+
let T = b.inlineContent ?? U(u, b.template), z = b.inlineContent ? "Plugin (inline)" : "Custom";
|
|
801
|
+
if (T || (T = U(Q, b.template), z = "Built-in"), !T) {
|
|
722
802
|
console.warn(t.yellow(` โ ๏ธ Template not found: ${b.template}`));
|
|
723
803
|
continue;
|
|
724
804
|
}
|
|
725
805
|
const ee = w.getFrontmatter($, d.name), te = w.format(
|
|
726
|
-
|
|
806
|
+
T,
|
|
727
807
|
$,
|
|
728
808
|
d.name
|
|
729
809
|
), oe = `${ee}
|
|
730
|
-
${te}`, _ =
|
|
731
|
-
S.push(_), n.dryRun ?
|
|
810
|
+
${te}`, _ = b.suffix, ne = f.join(h, _);
|
|
811
|
+
S.push(_), n.dryRun ? j("normal", s) && console.log(
|
|
732
812
|
t.cyan(
|
|
733
|
-
` ๐ Would generate: ${t.bold(_)} (from ${
|
|
813
|
+
` ๐ Would generate: ${t.bold(_)} (from ${z})`
|
|
734
814
|
)
|
|
735
|
-
) : (p.writeFileSync(ne, oe),
|
|
815
|
+
) : (p.writeFileSync(ne, oe), j("normal", s) && console.log(
|
|
736
816
|
t.green(
|
|
737
|
-
` โ
Generated: ${t.bold(_)} (from ${
|
|
817
|
+
` โ
Generated: ${t.bold(_)} (from ${z})`
|
|
738
818
|
)
|
|
739
819
|
));
|
|
740
820
|
}
|
|
741
821
|
}
|
|
742
822
|
}
|
|
743
|
-
|
|
744
|
-
`Generated ${S.length} files from ${
|
|
745
|
-
), !n.dryRun && !n.skipPruning ? await
|
|
746
|
-
Would check for old files to prune...`)),
|
|
823
|
+
M.succeed(
|
|
824
|
+
`Generated ${S.length} files from ${k} templates across ${R} projects`
|
|
825
|
+
), !n.dryRun && !n.skipPruning ? await ke(h, S, n.force) : n.dryRun && j("verbose", s) && console.log(t.gray(`
|
|
826
|
+
Would check for old files to prune...`)), j("normal", s) && (console.log(`
|
|
747
827
|
${"โ".repeat(60)}`), n.dryRun ? (console.log(t.cyan("โจ Dry run complete! No files were modified.")), console.log(
|
|
748
828
|
t.gray(
|
|
749
829
|
`๐ Would have generated ${S.length} instruction file(s)`
|
|
750
830
|
)
|
|
751
831
|
), console.log(
|
|
752
832
|
t.gray(
|
|
753
|
-
`๐ From ${
|
|
833
|
+
`๐ From ${k} template(s) across ${R} project(s)`
|
|
754
834
|
)
|
|
755
835
|
)) : (console.log(t.green("โจ AI instruction alignment complete!")), console.log(
|
|
756
836
|
t.bold(`๐ Generated ${S.length} instruction file(s)`)
|
|
757
837
|
), console.log(
|
|
758
838
|
t.gray(
|
|
759
|
-
`๐ From ${
|
|
839
|
+
`๐ From ${k} template(s) across ${R} project(s)`
|
|
760
840
|
)
|
|
761
841
|
), console.log(
|
|
762
842
|
t.gray(`๐ Files are located in: ${t.bold(o.outputDirectory)}`)
|
|
763
|
-
)), console.log("โ".repeat(60))), o.target === "github-copilot" &&
|
|
843
|
+
)), console.log("โ".repeat(60))), o.target === "github-copilot" && j("normal", s) && (console.log(`
|
|
764
844
|
--- VS Code + GitHub Copilot Tip ---`), console.log(
|
|
765
845
|
"To maximize Copilot's awareness, add this to your workspace .vscode/settings.json:"
|
|
766
846
|
), console.log(`
|
|
@@ -772,7 +852,7 @@ ${"โ".repeat(60)}`), n.dryRun ? (console.log(t.cyan("โจ Dry run complete! No
|
|
|
772
852
|
));
|
|
773
853
|
}
|
|
774
854
|
function Pe(e) {
|
|
775
|
-
const n =
|
|
855
|
+
const n = x(`Checking target directory: ${e}`).start();
|
|
776
856
|
if (p.existsSync(e))
|
|
777
857
|
n.succeed("Target directory OK.");
|
|
778
858
|
else {
|
|
@@ -788,19 +868,25 @@ function Pe(e) {
|
|
|
788
868
|
}
|
|
789
869
|
}
|
|
790
870
|
}
|
|
791
|
-
async function
|
|
792
|
-
await
|
|
871
|
+
async function H() {
|
|
872
|
+
await C.getInstance().initialize();
|
|
793
873
|
}
|
|
794
874
|
async function Te() {
|
|
795
|
-
await
|
|
796
|
-
const e =
|
|
875
|
+
await H();
|
|
876
|
+
const e = C.getInstance();
|
|
877
|
+
let n = [];
|
|
797
878
|
try {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
879
|
+
n = await e.getAllPlugins();
|
|
880
|
+
} catch (r) {
|
|
881
|
+
console.warn(
|
|
882
|
+
t.yellow(`โ ๏ธ Failed to get plugins: ${r.message}`)
|
|
883
|
+
), console.warn(
|
|
884
|
+
t.yellow(
|
|
885
|
+
`โ ๏ธ Registry type: ${typeof e}, has getAllPlugins: ${typeof e?.getAllPlugins}`
|
|
886
|
+
)
|
|
887
|
+
);
|
|
803
888
|
}
|
|
889
|
+
n.length === 0 && console.warn(t.yellow("โ ๏ธ No plugins loaded from registry!"));
|
|
804
890
|
const s = {};
|
|
805
891
|
for (const r of n) {
|
|
806
892
|
let a = [];
|
|
@@ -816,21 +902,21 @@ async function Te() {
|
|
|
816
902
|
continue;
|
|
817
903
|
}
|
|
818
904
|
for (const o of a) {
|
|
819
|
-
const
|
|
905
|
+
const l = `${o.name}.md`;
|
|
820
906
|
let i = null;
|
|
821
907
|
try {
|
|
822
908
|
i = typeof o.content == "function" ? await o.content() : o.content;
|
|
823
|
-
} catch (
|
|
909
|
+
} catch (c) {
|
|
824
910
|
console.warn(
|
|
825
911
|
t.yellow(
|
|
826
|
-
`โ ๏ธ Plugin ${r.name} template ${o.name} failed to load: ${
|
|
912
|
+
`โ ๏ธ Plugin ${r.name} template ${o.name} failed to load: ${c.message}`
|
|
827
913
|
)
|
|
828
914
|
);
|
|
829
915
|
}
|
|
830
|
-
for (const
|
|
831
|
-
s[
|
|
916
|
+
for (const c of o.tags)
|
|
917
|
+
s[c] || (s[c] = []), s[c].push({
|
|
832
918
|
template: `plugin:${r.name}/${o.name}`,
|
|
833
|
-
suffix:
|
|
919
|
+
suffix: l,
|
|
834
920
|
inlineContent: i ?? void 0
|
|
835
921
|
});
|
|
836
922
|
}
|
|
@@ -838,33 +924,39 @@ async function Te() {
|
|
|
838
924
|
return s;
|
|
839
925
|
}
|
|
840
926
|
async function Ce() {
|
|
841
|
-
await
|
|
842
|
-
const e = [], n = process.cwd(), r = await
|
|
927
|
+
await H();
|
|
928
|
+
const e = [], n = process.cwd(), r = await C.getInstance().detectAllProjects(n);
|
|
843
929
|
if (r.length === 0)
|
|
844
930
|
return [];
|
|
845
931
|
for (const a of r) {
|
|
846
932
|
const o = f.relative(n, a.metadata.projectPath);
|
|
847
933
|
e.push({
|
|
848
|
-
name:
|
|
934
|
+
name: Re(
|
|
935
|
+
a.metadata.name || f.basename(a.metadata.projectPath)
|
|
936
|
+
),
|
|
849
937
|
path: o || ".",
|
|
850
938
|
tags: /* @__PURE__ */ new Set()
|
|
851
939
|
});
|
|
852
940
|
}
|
|
853
941
|
return e;
|
|
854
942
|
}
|
|
855
|
-
|
|
856
|
-
|
|
943
|
+
function Re(e) {
|
|
944
|
+
let s = e.trim().replace(/^@/, "").replace(/[\\/\s]+/g, "-");
|
|
945
|
+
return s = s.replace(/-+/g, "-"), s;
|
|
946
|
+
}
|
|
947
|
+
async function Fe(e, n, s, r) {
|
|
948
|
+
await H();
|
|
857
949
|
const a = f.resolve(process.cwd(), e.path);
|
|
858
950
|
try {
|
|
859
|
-
const
|
|
860
|
-
if (
|
|
861
|
-
const i =
|
|
951
|
+
const l = await C.getInstance().detectAllProjects(a);
|
|
952
|
+
if (l.length > 0) {
|
|
953
|
+
const i = l[0].metadata;
|
|
862
954
|
if (i.tags?.length)
|
|
863
|
-
for (const
|
|
864
|
-
e.tags.add(
|
|
865
|
-
for (const
|
|
866
|
-
n[
|
|
867
|
-
const g =
|
|
955
|
+
for (const c of i.tags)
|
|
956
|
+
e.tags.add(c);
|
|
957
|
+
for (const c in i.dependencies) {
|
|
958
|
+
n[c] && e.tags.add(n[c]);
|
|
959
|
+
const g = c.split(/[@/:]/g).pop();
|
|
868
960
|
g && n[g] && e.tags.add(n[g]);
|
|
869
961
|
}
|
|
870
962
|
}
|
|
@@ -877,8 +969,8 @@ async function Re(e, n, s, r) {
|
|
|
877
969
|
}
|
|
878
970
|
try {
|
|
879
971
|
for (const o in s) {
|
|
880
|
-
const
|
|
881
|
-
p.existsSync(i) && e.tags.add(
|
|
972
|
+
const l = s[o], i = f.join(a, o);
|
|
973
|
+
p.existsSync(i) && e.tags.add(l);
|
|
882
974
|
}
|
|
883
975
|
} catch (o) {
|
|
884
976
|
console.warn(
|
|
@@ -889,13 +981,13 @@ async function Re(e, n, s, r) {
|
|
|
889
981
|
}
|
|
890
982
|
try {
|
|
891
983
|
for (const o in r) {
|
|
892
|
-
const
|
|
984
|
+
const l = r[o];
|
|
893
985
|
(await ue(o, {
|
|
894
986
|
cwd: a,
|
|
895
987
|
nodir: !0,
|
|
896
988
|
dot: !0
|
|
897
989
|
// Include dotfiles if needed, though 'src' patterns usually don't
|
|
898
|
-
})).length > 0 && e.tags.add(
|
|
990
|
+
})).length > 0 && e.tags.add(l);
|
|
899
991
|
}
|
|
900
992
|
} catch (o) {
|
|
901
993
|
console.warn(
|
|
@@ -905,7 +997,7 @@ async function Re(e, n, s, r) {
|
|
|
905
997
|
);
|
|
906
998
|
}
|
|
907
999
|
}
|
|
908
|
-
function
|
|
1000
|
+
function U(e, n) {
|
|
909
1001
|
const s = f.join(e, n);
|
|
910
1002
|
try {
|
|
911
1003
|
return p.readFileSync(s, "utf-8");
|
|
@@ -913,7 +1005,7 @@ function H(e, n) {
|
|
|
913
1005
|
return null;
|
|
914
1006
|
}
|
|
915
1007
|
}
|
|
916
|
-
async function
|
|
1008
|
+
async function ke(e, n, s = !1) {
|
|
917
1009
|
const a = p.readdirSync(e).filter((o) => o.endsWith(".md")).filter((o) => !n.includes(o));
|
|
918
1010
|
if (a.length > 0) {
|
|
919
1011
|
console.warn(
|
|
@@ -922,8 +1014,8 @@ async function Fe(e, n, s = !1) {
|
|
|
922
1014
|
โ ๏ธ Found ${a.length} instruction files that are no longer generated:`
|
|
923
1015
|
)
|
|
924
1016
|
);
|
|
925
|
-
for (const
|
|
926
|
-
console.warn(t.yellow(` - ${
|
|
1017
|
+
for (const l of a)
|
|
1018
|
+
console.warn(t.yellow(` - ${l}`));
|
|
927
1019
|
let o = s;
|
|
928
1020
|
if (s || (o = (await W.prompt([
|
|
929
1021
|
{
|
|
@@ -933,16 +1025,16 @@ async function Fe(e, n, s = !1) {
|
|
|
933
1025
|
default: !1
|
|
934
1026
|
}
|
|
935
1027
|
])).prune), o) {
|
|
936
|
-
let
|
|
1028
|
+
let l = 0;
|
|
937
1029
|
for (const i of a)
|
|
938
1030
|
try {
|
|
939
|
-
p.unlinkSync(f.join(e, i)),
|
|
940
|
-
} catch (
|
|
1031
|
+
p.unlinkSync(f.join(e, i)), l++;
|
|
1032
|
+
} catch (c) {
|
|
941
1033
|
console.error(
|
|
942
|
-
t.red(` โ Error deleting ${i}: ${
|
|
1034
|
+
t.red(` โ Error deleting ${i}: ${c.message}`)
|
|
943
1035
|
);
|
|
944
1036
|
}
|
|
945
|
-
console.log(`โ
Pruned ${
|
|
1037
|
+
console.log(`โ
Pruned ${l} old files.`);
|
|
946
1038
|
}
|
|
947
1039
|
}
|
|
948
1040
|
}
|
|
@@ -951,7 +1043,7 @@ async function Ae() {
|
|
|
951
1043
|
t.cyan(`๐ Validating instruction files with quality scoring...
|
|
952
1044
|
`)
|
|
953
1045
|
);
|
|
954
|
-
const e =
|
|
1046
|
+
const e = x("Loading configuration...").start(), n = O(), s = L(n);
|
|
955
1047
|
e.succeed("Configuration loaded.");
|
|
956
1048
|
const r = f.resolve(
|
|
957
1049
|
process.cwd(),
|
|
@@ -977,23 +1069,23 @@ async function Ae() {
|
|
|
977
1069
|
let o = { track: () => {
|
|
978
1070
|
} };
|
|
979
1071
|
try {
|
|
980
|
-
const
|
|
981
|
-
if (typeof
|
|
982
|
-
const w =
|
|
1072
|
+
const h = await import("@el-j/magic-helix-core");
|
|
1073
|
+
if (typeof h.createTelemetry == "function") {
|
|
1074
|
+
const w = h.createTelemetry;
|
|
983
1075
|
o = w({});
|
|
984
1076
|
}
|
|
985
1077
|
} catch {
|
|
986
1078
|
}
|
|
987
|
-
let
|
|
988
|
-
const
|
|
1079
|
+
let l = 0, i = 0;
|
|
1080
|
+
const c = [];
|
|
989
1081
|
for (const u of a) {
|
|
990
|
-
const
|
|
1082
|
+
const h = f.join(r, u);
|
|
991
1083
|
try {
|
|
992
|
-
const w = p.readFileSync(
|
|
993
|
-
|
|
1084
|
+
const w = p.readFileSync(h, "utf-8"), m = ge(w), v = De(m.overallScore);
|
|
1085
|
+
c.push({ file: u, score: m.overallScore, grade: v }), m.overallScore >= 70 ? l++ : i++;
|
|
994
1086
|
const D = m.overallScore >= 90 ? t.green : m.overallScore >= 70 ? t.blue : t.yellow;
|
|
995
1087
|
console.log(
|
|
996
|
-
D(`${
|
|
1088
|
+
D(`${v} ${m.overallScore}/100`) + t.gray(` - ${u}`)
|
|
997
1089
|
), m.missingElements.length > 0 && console.log(
|
|
998
1090
|
t.red(` Missing: ${m.missingElements.join(", ")}`)
|
|
999
1091
|
), m.recommendations.length > 0 && m.overallScore < 90 && console.log(t.gray(` Tip: ${m.recommendations[0]}`)), o.track({
|
|
@@ -1011,12 +1103,12 @@ async function Ae() {
|
|
|
1011
1103
|
}
|
|
1012
1104
|
console.log(t.bold(`
|
|
1013
1105
|
=== Validation Summary ===
|
|
1014
|
-
`)), console.log(t.green(`โ
Passed (โฅ70): ${
|
|
1015
|
-
const g =
|
|
1106
|
+
`)), console.log(t.green(`โ
Passed (โฅ70): ${l}`)), console.log(t.red(`โ Failed (<70): ${i}`));
|
|
1107
|
+
const g = c.reduce((u, h) => u + h.score, 0) / c.length;
|
|
1016
1108
|
console.log(t.cyan(`๐ Average Score: ${Math.round(g)}/100`)), o.track({
|
|
1017
1109
|
type: "summary",
|
|
1018
|
-
files:
|
|
1019
|
-
pass:
|
|
1110
|
+
files: c.length,
|
|
1111
|
+
pass: l,
|
|
1020
1112
|
fail: i,
|
|
1021
1113
|
averageScore: Math.round(g)
|
|
1022
1114
|
}), i === 0 && g >= 80 ? console.log(t.green(`
|
|
@@ -1027,23 +1119,23 @@ async function Ae() {
|
|
|
1027
1119
|
)
|
|
1028
1120
|
);
|
|
1029
1121
|
}
|
|
1030
|
-
function
|
|
1122
|
+
function De(e) {
|
|
1031
1123
|
return e >= 90 ? "A" : e >= 80 ? "B" : e >= 70 ? "C" : e >= 60 ? "D" : "F";
|
|
1032
1124
|
}
|
|
1033
|
-
function
|
|
1125
|
+
function Ie() {
|
|
1034
1126
|
try {
|
|
1035
|
-
const e = Y(import.meta.url), n = ae(e), s =
|
|
1127
|
+
const e = Y(import.meta.url), n = ae(e), s = le(n, "..", "package.json");
|
|
1036
1128
|
return JSON.parse(ie(s, "utf-8")).version;
|
|
1037
1129
|
} catch {
|
|
1038
1130
|
return "2.0.0-beta.1";
|
|
1039
1131
|
}
|
|
1040
1132
|
}
|
|
1041
|
-
async function
|
|
1133
|
+
async function ze() {
|
|
1042
1134
|
try {
|
|
1043
|
-
const e = new
|
|
1135
|
+
const e = new ce();
|
|
1044
1136
|
e.name("magic-helix").description(
|
|
1045
1137
|
"Magic Helix CLI for aligning AI instructions in your monorepo."
|
|
1046
|
-
).version(
|
|
1138
|
+
).version(Ie()), e.command("init").description(
|
|
1047
1139
|
"Initialize a custom magic-helix.config.json to extend the built-in rules."
|
|
1048
1140
|
).action(pe), e.command("run").description(
|
|
1049
1141
|
"Scan the monorepo and generate AI instruction files based on built-in and custom rules."
|
|
@@ -1059,16 +1151,16 @@ async function Ie() {
|
|
|
1059
1151
|
).option(
|
|
1060
1152
|
"--exclude <pattern>",
|
|
1061
1153
|
"Exclude files matching pattern (e.g., 'test/**,*.spec.ts')"
|
|
1062
|
-
).action(
|
|
1154
|
+
).action(V), e.command("refresh").description(
|
|
1063
1155
|
"Rescan the project and update existing instruction files with changed project information."
|
|
1064
1156
|
).alias("resync").option("--config <path>", "Path to custom config file").option(
|
|
1065
1157
|
"--target <assistant>",
|
|
1066
1158
|
"AI assistant target (github-copilot, claude, copilot-chat, generic)"
|
|
1067
|
-
).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(xe), e.command("list").description(
|
|
1068
1160
|
"Show detected projects, tags, and templates without generating files."
|
|
1069
1161
|
).action(me), e.command("validate").description("Check instruction files for common issues and integrity.").action(Ae), e.command("clean").description("Remove all generated instruction files.").action(de), e.command("plugins").description(
|
|
1070
1162
|
"List available language detection plugins and their status."
|
|
1071
|
-
).option("--verbose", "Show detailed plugin information").action((n) => we(n)), process.argv.length < 3 && e.action(
|
|
1163
|
+
).option("--verbose", "Show detailed plugin information").action((n) => we(n)), process.argv.length < 3 && e.action(V), await e.parseAsync(process.argv);
|
|
1072
1164
|
} catch (e) {
|
|
1073
1165
|
console.error(
|
|
1074
1166
|
t.red(`โ An unexpected error occurred: ${e.message}`)
|
|
@@ -1076,8 +1168,8 @@ async function Ie() {
|
|
|
1076
1168
|
}
|
|
1077
1169
|
}
|
|
1078
1170
|
const Ee = Y(import.meta.url), B = process.argv[1] ? se(re(process.argv[1])) : null;
|
|
1079
|
-
B && Ee === B &&
|
|
1171
|
+
B && Ee === B && ze();
|
|
1080
1172
|
export {
|
|
1081
|
-
|
|
1173
|
+
ze as main
|
|
1082
1174
|
};
|
|
1083
1175
|
//# sourceMappingURL=cli.mjs.map
|