@el-j/magic-helix-core 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/builtin-plugins/cpp/index.d.ts +46 -0
- package/dist/builtin-plugins/index.d.ts +1 -0
- package/dist/default_templates/generic/lang-typescript.md +49 -3
- package/dist/default_templates/generic/style-tailwind.md +72 -2
- package/dist/default_templates/generic/test-vitest.md +126 -1
- package/dist/default_templates/vue/vue-core.md +90 -10
- package/dist/{index-BkJhe5Af.js → index-0GK4RlUx.js} +2 -2
- package/dist/{index-BkJhe5Af.js.map → index-0GK4RlUx.js.map} +1 -1
- package/dist/{index-Jz0HYZ7B.js → index-BQ6v041y.js} +2 -2
- package/dist/index-BQ6v041y.js.map +1 -0
- package/dist/index-Baxb1vI_.js +210 -0
- package/dist/index-Baxb1vI_.js.map +1 -0
- package/dist/{index-L3IVvhd1.cjs → index-BqTqxCpG.cjs} +2 -2
- package/dist/{index-L3IVvhd1.cjs.map → index-BqTqxCpG.cjs.map} +1 -1
- package/dist/{index-Dm37u5ut.js → index-DkvW5yBY.js} +362 -241
- package/dist/index-DkvW5yBY.js.map +1 -0
- package/dist/index-Dn1ehjIj.cjs +80 -0
- package/dist/index-Dn1ehjIj.cjs.map +1 -0
- package/dist/index-nioXOg4m.cjs +76 -0
- package/dist/index-nioXOg4m.cjs.map +1 -0
- package/dist/{index-J1qAfsnO.cjs → index-okhY3fWD.cjs} +2 -2
- package/dist/index-okhY3fWD.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plugin-loader.d.ts +5 -0
- package/package.json +1 -1
- package/dist/index-B_6W_RnJ.cjs +0 -76
- package/dist/index-B_6W_RnJ.cjs.map +0 -1
- package/dist/index-Dm37u5ut.js.map +0 -1
- package/dist/index-J1qAfsnO.cjs.map +0 -1
- package/dist/index-Jz0HYZ7B.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import { fileURLToPath as
|
|
4
|
-
import * as
|
|
1
|
+
import * as f from "node:path";
|
|
2
|
+
import S, { dirname as O, resolve as R } from "node:path";
|
|
3
|
+
import { fileURLToPath as A } from "node:url";
|
|
4
|
+
import * as p from "node:fs";
|
|
5
5
|
import E from "node:fs";
|
|
6
6
|
import b from "picocolors";
|
|
7
|
-
import { glob as
|
|
8
|
-
function
|
|
7
|
+
import { glob as W } from "glob";
|
|
8
|
+
function N(n) {
|
|
9
9
|
if (n === "src/**/*.ts")
|
|
10
10
|
return /^src\/.*\.ts$/;
|
|
11
11
|
if (n === "src/**/*.vue")
|
|
@@ -13,11 +13,11 @@ function W(n) {
|
|
|
13
13
|
const e = n.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*");
|
|
14
14
|
return new RegExp(`^${e.replace(/[.+^${}()|[\]\\]/g, "\\$&")}$`);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const t =
|
|
16
|
+
function z(n, e) {
|
|
17
|
+
const t = N(e);
|
|
18
18
|
return n.some((s) => t.test(s));
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function ke(n, e, t, s) {
|
|
21
21
|
const i = /* @__PURE__ */ new Set();
|
|
22
22
|
for (const [r, o] of Object.entries(n.dependencies))
|
|
23
23
|
e[r] && i.add(e[r]);
|
|
@@ -25,7 +25,7 @@ function Pe(n, e, t, s) {
|
|
|
25
25
|
t[r] && i.add(t[r]);
|
|
26
26
|
for (const r in s) {
|
|
27
27
|
const o = s[r];
|
|
28
|
-
|
|
28
|
+
z(n.projectFiles, r) && i.add(o);
|
|
29
29
|
}
|
|
30
30
|
return i;
|
|
31
31
|
}
|
|
@@ -82,59 +82,88 @@ const G = {
|
|
|
82
82
|
},
|
|
83
83
|
tagTemplateMap: {
|
|
84
84
|
// Vue Projects
|
|
85
|
-
"framework-vue": [
|
|
86
|
-
|
|
85
|
+
"framework-vue": [
|
|
86
|
+
{ template: "vue/vue-core.md", suffix: "vue.instructions.md" }
|
|
87
|
+
],
|
|
88
|
+
"state-pinia": [
|
|
89
|
+
{ template: "vue/vue-pinia.md", suffix: "vue-pinia.instructions.md" }
|
|
90
|
+
],
|
|
87
91
|
"style-primevue": [
|
|
88
|
-
{
|
|
92
|
+
{
|
|
93
|
+
template: "vue/style-primevue.md",
|
|
94
|
+
suffix: "vue-primevue.instructions.md"
|
|
95
|
+
}
|
|
89
96
|
],
|
|
90
97
|
"style-quasar": [
|
|
91
|
-
{ template: "vue/style-quasar.md", suffix: "vue-
|
|
98
|
+
{ template: "vue/style-quasar.md", suffix: "vue-quasar.instructions.md" }
|
|
92
99
|
],
|
|
93
100
|
// React Projects
|
|
94
101
|
"framework-react": [
|
|
95
|
-
{ template: "react/react-core.md", suffix: "react
|
|
102
|
+
{ template: "react/react-core.md", suffix: "react.instructions.md" }
|
|
96
103
|
],
|
|
97
104
|
"state-zustand": [
|
|
98
|
-
{
|
|
105
|
+
{
|
|
106
|
+
template: "react/react-zustand.md",
|
|
107
|
+
suffix: "react-zustand.instructions.md"
|
|
108
|
+
}
|
|
99
109
|
],
|
|
100
110
|
// NestJS Projects
|
|
101
111
|
"framework-nestjs": [
|
|
102
|
-
{ template: "nestjs/nestjs-core.md", suffix: "nestjs
|
|
112
|
+
{ template: "nestjs/nestjs-core.md", suffix: "nestjs.instructions.md" }
|
|
103
113
|
],
|
|
104
114
|
// Angular Projects
|
|
105
115
|
"framework-angular": [
|
|
106
|
-
{
|
|
116
|
+
{
|
|
117
|
+
template: "angular/angular-core.md",
|
|
118
|
+
suffix: "angular.instructions.md"
|
|
119
|
+
}
|
|
107
120
|
],
|
|
108
121
|
// Generic
|
|
109
122
|
"style-tailwind": [
|
|
110
|
-
{
|
|
123
|
+
{
|
|
124
|
+
template: "generic/style-tailwind.md",
|
|
125
|
+
suffix: "tailwind.instructions.md"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"style-mui": [
|
|
129
|
+
{ template: "generic/style-mui.md", suffix: "mui.instructions.md" }
|
|
111
130
|
],
|
|
112
|
-
"style-mui": [{ template: "generic/style-mui.md", suffix: "style-mui.md" }],
|
|
113
131
|
"test-vitest": [
|
|
114
|
-
{ template: "generic/test-vitest.md", suffix: "
|
|
132
|
+
{ template: "generic/test-vitest.md", suffix: "vitest.instructions.md" }
|
|
133
|
+
],
|
|
134
|
+
"test-jest": [
|
|
135
|
+
{ template: "generic/test-jest.md", suffix: "jest.instructions.md" }
|
|
115
136
|
],
|
|
116
|
-
"test-jest": [{ template: "generic/test-jest.md", suffix: "test-jest.md" }],
|
|
117
137
|
"test-cypress": [
|
|
118
|
-
{
|
|
138
|
+
{
|
|
139
|
+
template: "generic/test-cypress.md",
|
|
140
|
+
suffix: "cypress.instructions.md"
|
|
141
|
+
}
|
|
119
142
|
],
|
|
120
143
|
"test-playwright": [
|
|
121
|
-
{
|
|
144
|
+
{
|
|
145
|
+
template: "generic/test-playwright.md",
|
|
146
|
+
suffix: "playwright.instructions.md"
|
|
147
|
+
}
|
|
122
148
|
],
|
|
123
149
|
"lang-typescript": [
|
|
124
|
-
{
|
|
150
|
+
{
|
|
151
|
+
template: "generic/lang-typescript.md",
|
|
152
|
+
suffix: "typescript.instructions.md"
|
|
153
|
+
}
|
|
125
154
|
],
|
|
126
155
|
"lang-python": [
|
|
127
|
-
{ template: "python/lang-python.md", suffix: "
|
|
156
|
+
{ template: "python/lang-python.md", suffix: "python.instructions.md" }
|
|
128
157
|
],
|
|
129
|
-
"lang-go": [{ template: "go/lang-go.md", suffix: "
|
|
158
|
+
"lang-go": [{ template: "go/lang-go.md", suffix: "go.instructions.md" }],
|
|
130
159
|
"state-rxjs": [
|
|
131
|
-
{ template: "generic/state-rxjs.md", suffix: "
|
|
160
|
+
{ template: "generic/state-rxjs.md", suffix: "rxjs.instructions.md" }
|
|
132
161
|
],
|
|
133
162
|
"state-redux": [
|
|
134
|
-
{ template: "generic/state-redux.md", suffix: "
|
|
163
|
+
{ template: "generic/state-redux.md", suffix: "redux.instructions.md" }
|
|
135
164
|
]
|
|
136
165
|
}
|
|
137
|
-
},
|
|
166
|
+
}, D = {
|
|
138
167
|
quality: "standard",
|
|
139
168
|
contextLevel: "balanced",
|
|
140
169
|
outputFormat: "markdown",
|
|
@@ -142,12 +171,12 @@ const G = {
|
|
|
142
171
|
includeExamples: !0,
|
|
143
172
|
includeBestPractices: !0
|
|
144
173
|
};
|
|
145
|
-
function
|
|
146
|
-
const t = { ...
|
|
174
|
+
function Ce(n, e) {
|
|
175
|
+
const t = { ...D, ...e };
|
|
147
176
|
let s = n;
|
|
148
|
-
return s =
|
|
177
|
+
return s = H(s, t.outputFormat), s = B(s, t.quality), s = q(s, t.contextLevel), t.includeExamples || (s = U(s)), t.includeBestPractices || (s = J(s)), s = V(s, t.tokenBudget), s;
|
|
149
178
|
}
|
|
150
|
-
function
|
|
179
|
+
function B(n, e) {
|
|
151
180
|
switch (e) {
|
|
152
181
|
case "basic":
|
|
153
182
|
return n.split(/\n(?=##? )/).filter((s) => {
|
|
@@ -169,7 +198,7 @@ function z(n, e) {
|
|
|
169
198
|
`);
|
|
170
199
|
}
|
|
171
200
|
}
|
|
172
|
-
function
|
|
201
|
+
function q(n, e) {
|
|
173
202
|
switch (e) {
|
|
174
203
|
case "minimal":
|
|
175
204
|
return n.split(/\n(?=##? )/).filter((s) => {
|
|
@@ -187,7 +216,7 @@ function B(n, e) {
|
|
|
187
216
|
`);
|
|
188
217
|
}
|
|
189
218
|
}
|
|
190
|
-
function
|
|
219
|
+
function H(n, e) {
|
|
191
220
|
switch (e) {
|
|
192
221
|
case "structured":
|
|
193
222
|
return n.replace(/^### /gm, "#### ").replace(/^## /gm, "### ").replace(/^# /gm, "## ");
|
|
@@ -207,7 +236,7 @@ function q(n, e) {
|
|
|
207
236
|
return n;
|
|
208
237
|
}
|
|
209
238
|
}
|
|
210
|
-
function
|
|
239
|
+
function U(n) {
|
|
211
240
|
let e = "", t = !1, s = !1;
|
|
212
241
|
for (const i of n.split(`
|
|
213
242
|
`)) {
|
|
@@ -227,7 +256,7 @@ function H(n) {
|
|
|
227
256
|
}
|
|
228
257
|
return e;
|
|
229
258
|
}
|
|
230
|
-
function
|
|
259
|
+
function J(n) {
|
|
231
260
|
return n.split(`
|
|
232
261
|
`).filter((e) => {
|
|
233
262
|
const t = e.toLowerCase();
|
|
@@ -235,7 +264,7 @@ function U(n) {
|
|
|
235
264
|
}).join(`
|
|
236
265
|
`);
|
|
237
266
|
}
|
|
238
|
-
function
|
|
267
|
+
function V(n, e) {
|
|
239
268
|
const t = e * 4;
|
|
240
269
|
if (n.length <= t) return n;
|
|
241
270
|
const s = n.substring(0, t), i = s.lastIndexOf(`
|
|
@@ -246,21 +275,21 @@ function J(n, e) {
|
|
|
246
275
|
|
|
247
276
|
<!-- Content truncated to fit token budget -->`;
|
|
248
277
|
}
|
|
249
|
-
function
|
|
278
|
+
function Fe(n) {
|
|
250
279
|
return Math.ceil(n.length / 4);
|
|
251
280
|
}
|
|
252
|
-
const T = "magic-helix.config.json",
|
|
253
|
-
function
|
|
254
|
-
const t = (n ? [
|
|
255
|
-
|
|
256
|
-
...
|
|
257
|
-
(s) =>
|
|
281
|
+
const T = "magic-helix.config.json", Y = ["ai-aligner.config.json"];
|
|
282
|
+
function Se(n) {
|
|
283
|
+
const t = (n ? [f.resolve(process.cwd(), n)] : [
|
|
284
|
+
f.resolve(process.cwd(), T),
|
|
285
|
+
...Y.map(
|
|
286
|
+
(s) => f.resolve(process.cwd(), s)
|
|
258
287
|
)
|
|
259
288
|
]).find((s, i) => {
|
|
260
|
-
const r =
|
|
289
|
+
const r = p.existsSync(s);
|
|
261
290
|
return !n && r && i > 0 && console.warn(
|
|
262
291
|
b.yellow(
|
|
263
|
-
` Detected legacy config file ${
|
|
292
|
+
` Detected legacy config file ${f.basename(s)}. Please rename it to ${T}.`
|
|
264
293
|
)
|
|
265
294
|
), r;
|
|
266
295
|
});
|
|
@@ -271,7 +300,7 @@ function Ce(n) {
|
|
|
271
300
|
try {
|
|
272
301
|
return console.log(
|
|
273
302
|
b.blue(" User config file found. Merging with built-in conventions.")
|
|
274
|
-
), JSON.parse(
|
|
303
|
+
), JSON.parse(p.readFileSync(t, "utf-8"));
|
|
275
304
|
} catch (s) {
|
|
276
305
|
return console.error(
|
|
277
306
|
b.red(`❌ Error parsing config file: ${s.message}`)
|
|
@@ -282,12 +311,14 @@ function Ce(n) {
|
|
|
282
311
|
), {};
|
|
283
312
|
}
|
|
284
313
|
}
|
|
285
|
-
function
|
|
286
|
-
const e = G
|
|
314
|
+
function xe(n) {
|
|
315
|
+
const e = G, t = Q(
|
|
316
|
+
n.outputDirectory ?? e.outputDirectory
|
|
317
|
+
);
|
|
287
318
|
return {
|
|
288
319
|
target: n.target || e.target,
|
|
289
320
|
templateDirectory: n.templateDirectory ?? e.templateDirectory,
|
|
290
|
-
outputDirectory:
|
|
321
|
+
outputDirectory: t,
|
|
291
322
|
dependencyTagMap: {
|
|
292
323
|
...e.dependencyTagMap,
|
|
293
324
|
...n.dependencyTagMap || {}
|
|
@@ -305,12 +336,24 @@ function Fe(n) {
|
|
|
305
336
|
...n.tagTemplateMap || {}
|
|
306
337
|
},
|
|
307
338
|
aiRefinement: {
|
|
308
|
-
...
|
|
339
|
+
...D,
|
|
309
340
|
...n.aiRefinement || {}
|
|
310
341
|
}
|
|
311
342
|
};
|
|
312
343
|
}
|
|
313
|
-
|
|
344
|
+
function Q(n) {
|
|
345
|
+
const e = n.trim();
|
|
346
|
+
if (e.endsWith(".github/instruction") || /\binstruction\/?$/.test(e)) {
|
|
347
|
+
const t = e.replace(/instruction\/?$/, "instructions");
|
|
348
|
+
return console.warn(
|
|
349
|
+
b.yellow(
|
|
350
|
+
` Normalized outputDirectory from "${e}" to "${t}". Using ".github/instructions" as the default convention.`
|
|
351
|
+
)
|
|
352
|
+
), t;
|
|
353
|
+
}
|
|
354
|
+
return e;
|
|
355
|
+
}
|
|
356
|
+
class $ {
|
|
314
357
|
format(e, t, s) {
|
|
315
358
|
return e;
|
|
316
359
|
}
|
|
@@ -325,7 +368,7 @@ applyTo: "${e}"
|
|
|
325
368
|
`;
|
|
326
369
|
}
|
|
327
370
|
}
|
|
328
|
-
class
|
|
371
|
+
class X {
|
|
329
372
|
format(e, t, s) {
|
|
330
373
|
return e.replace(/- \*\*([^*]+)\*\*/g, "- **$1** (important)");
|
|
331
374
|
}
|
|
@@ -341,7 +384,7 @@ assistant: claude
|
|
|
341
384
|
`;
|
|
342
385
|
}
|
|
343
386
|
}
|
|
344
|
-
class
|
|
387
|
+
class K {
|
|
345
388
|
format(e, t, s) {
|
|
346
389
|
return e.replace(/- \*\*ALWAYS\*\*/g, "- 🔴").replace(/- \*\*NEVER\*\*/g, "- ❌");
|
|
347
390
|
}
|
|
@@ -357,7 +400,7 @@ context: chat
|
|
|
357
400
|
`;
|
|
358
401
|
}
|
|
359
402
|
}
|
|
360
|
-
class
|
|
403
|
+
class Z {
|
|
361
404
|
format(e, t, s) {
|
|
362
405
|
return e;
|
|
363
406
|
}
|
|
@@ -372,25 +415,25 @@ applyTo: "${e}"
|
|
|
372
415
|
`;
|
|
373
416
|
}
|
|
374
417
|
}
|
|
375
|
-
function
|
|
418
|
+
function je(n) {
|
|
376
419
|
switch (n) {
|
|
377
420
|
case "github-copilot":
|
|
378
|
-
return new
|
|
421
|
+
return new $();
|
|
379
422
|
case "claude":
|
|
380
|
-
return new
|
|
423
|
+
return new X();
|
|
381
424
|
case "copilot-chat":
|
|
382
|
-
return new
|
|
425
|
+
return new K();
|
|
383
426
|
case "generic":
|
|
384
|
-
return new
|
|
427
|
+
return new Z();
|
|
385
428
|
default:
|
|
386
|
-
return new
|
|
429
|
+
return new $();
|
|
387
430
|
}
|
|
388
431
|
}
|
|
389
|
-
const v = {},
|
|
432
|
+
const v = {}, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
390
433
|
__proto__: null,
|
|
391
434
|
default: v
|
|
392
435
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
393
|
-
function
|
|
436
|
+
function ee() {
|
|
394
437
|
const n = v.join(__dirname, "default_templates", "patterns"), e = /* @__PURE__ */ new Map(), t = [
|
|
395
438
|
"role-definition",
|
|
396
439
|
"organization",
|
|
@@ -411,13 +454,13 @@ function K() {
|
|
|
411
454
|
name: a,
|
|
412
455
|
category: s,
|
|
413
456
|
content: c,
|
|
414
|
-
priority:
|
|
457
|
+
priority: te(s)
|
|
415
458
|
});
|
|
416
459
|
}
|
|
417
460
|
}
|
|
418
461
|
return e;
|
|
419
462
|
}
|
|
420
|
-
function
|
|
463
|
+
function te(n) {
|
|
421
464
|
return {
|
|
422
465
|
"role-definition": 1,
|
|
423
466
|
organization: 2,
|
|
@@ -430,7 +473,7 @@ function Z(n) {
|
|
|
430
473
|
// Safety always highest priority (never overridden)
|
|
431
474
|
}[n];
|
|
432
475
|
}
|
|
433
|
-
function
|
|
476
|
+
function se(n, e) {
|
|
434
477
|
const t = [], s = n.get("expert-identity"), i = n.get("scope-boundaries");
|
|
435
478
|
s && t.push(s), i && t.push(i);
|
|
436
479
|
const r = n.get("heading-hierarchy");
|
|
@@ -470,12 +513,12 @@ function ee(n, e) {
|
|
|
470
513
|
}
|
|
471
514
|
return e.excludePatterns ? t.filter((u) => !e.excludePatterns?.includes(u.name)) : t;
|
|
472
515
|
}
|
|
473
|
-
function
|
|
474
|
-
const e = n.sort((g,
|
|
516
|
+
function ne(n) {
|
|
517
|
+
const e = n.sort((g, m) => g.priority - m.priority), t = [], s = /* @__PURE__ */ new Map();
|
|
475
518
|
for (const g of e) {
|
|
476
519
|
s.has(g.category) || s.set(g.category, []);
|
|
477
|
-
const
|
|
478
|
-
|
|
520
|
+
const m = s.get(g.category);
|
|
521
|
+
m && m.push(g);
|
|
479
522
|
}
|
|
480
523
|
t.push(`# AI Agent Instructions
|
|
481
524
|
`);
|
|
@@ -484,73 +527,73 @@ function te(n) {
|
|
|
484
527
|
t.push(`## Role & Identity
|
|
485
528
|
`);
|
|
486
529
|
for (const g of i)
|
|
487
|
-
t.push(
|
|
530
|
+
t.push(w(g.content));
|
|
488
531
|
}
|
|
489
532
|
const r = s.get("organization");
|
|
490
533
|
if (r) {
|
|
491
534
|
t.push(`## Instruction Structure
|
|
492
535
|
`);
|
|
493
536
|
for (const g of r)
|
|
494
|
-
t.push(
|
|
537
|
+
t.push(w(g.content));
|
|
495
538
|
}
|
|
496
539
|
const o = s.get("tool-guidelines");
|
|
497
540
|
if (o) {
|
|
498
541
|
t.push(`## Tool Usage Guidelines
|
|
499
542
|
`);
|
|
500
543
|
for (const g of o)
|
|
501
|
-
t.push(
|
|
544
|
+
t.push(w(g.content));
|
|
502
545
|
}
|
|
503
546
|
const a = s.get("reasoning");
|
|
504
547
|
if (a) {
|
|
505
548
|
t.push(`## Reasoning & Execution Patterns
|
|
506
549
|
`);
|
|
507
550
|
for (const g of a)
|
|
508
|
-
t.push(
|
|
551
|
+
t.push(w(g.content));
|
|
509
552
|
}
|
|
510
553
|
const c = s.get("domain-expertise");
|
|
511
554
|
if (c) {
|
|
512
555
|
t.push(`## Domain-Specific Guidelines
|
|
513
556
|
`);
|
|
514
557
|
for (const g of c)
|
|
515
|
-
t.push(
|
|
558
|
+
t.push(w(g.content));
|
|
516
559
|
}
|
|
517
560
|
const l = s.get("environment");
|
|
518
561
|
if (l) {
|
|
519
562
|
t.push(`## Environment Context
|
|
520
563
|
`);
|
|
521
564
|
for (const g of l)
|
|
522
|
-
t.push(
|
|
565
|
+
t.push(w(g.content));
|
|
523
566
|
}
|
|
524
567
|
const u = s.get("tone");
|
|
525
568
|
if (u) {
|
|
526
569
|
t.push(`## Communication Style
|
|
527
570
|
`);
|
|
528
571
|
for (const g of u)
|
|
529
|
-
t.push(
|
|
572
|
+
t.push(w(g.content));
|
|
530
573
|
}
|
|
531
574
|
const d = s.get("safety");
|
|
532
575
|
if (d) {
|
|
533
576
|
t.push(`## Safety & Refusal Protocols
|
|
534
577
|
`);
|
|
535
578
|
for (const g of d)
|
|
536
|
-
t.push(
|
|
579
|
+
t.push(w(g.content));
|
|
537
580
|
}
|
|
538
581
|
return t.join(`
|
|
539
582
|
|
|
540
583
|
`);
|
|
541
584
|
}
|
|
542
|
-
function
|
|
585
|
+
function w(n) {
|
|
543
586
|
let e = n.replace(/^# .+ Pattern\n+/, "");
|
|
544
587
|
const t = e.match(
|
|
545
588
|
/## Examples\n([\s\S]+?)(?=\n## |\n---|Z)/
|
|
546
589
|
);
|
|
547
590
|
return t ? t[1].trim() : (e = e.replace(/## Purpose\n.+?\n\n/, ""), e = e.replace(/## Template\n[\s\S]+?(?=\n## |$)/, ""), e = e.replace(/## Best Practices\n[\s\S]+$/, ""), e.trim());
|
|
548
591
|
}
|
|
549
|
-
function
|
|
550
|
-
const e =
|
|
551
|
-
return
|
|
592
|
+
function ie(n) {
|
|
593
|
+
const e = ee(), t = se(e, n);
|
|
594
|
+
return ne(t);
|
|
552
595
|
}
|
|
553
|
-
const
|
|
596
|
+
const re = [
|
|
554
597
|
// Role Definition (Critical)
|
|
555
598
|
{
|
|
556
599
|
name: "Expert Identity",
|
|
@@ -648,19 +691,19 @@ const ne = [
|
|
|
648
691
|
check: (n) => /do not (say|use|start with)|avoid (saying|phrases like)/i.test(n)
|
|
649
692
|
}
|
|
650
693
|
];
|
|
651
|
-
function
|
|
652
|
-
const e =
|
|
694
|
+
function L(n) {
|
|
695
|
+
const e = re.map((d) => ({
|
|
653
696
|
element: d,
|
|
654
697
|
passed: d.check(n)
|
|
655
698
|
})), t = e.filter(
|
|
656
699
|
(d) => ["Clear Headings", "Structured Sections"].includes(d.element.name)
|
|
657
|
-
), s =
|
|
700
|
+
), s = x(t), i = e.filter(
|
|
658
701
|
(d) => ["Concrete Examples", "Communication Style", "Forbidden Phrases"].includes(
|
|
659
702
|
d.element.name
|
|
660
703
|
)
|
|
661
|
-
), r =
|
|
704
|
+
), r = x(i), o = e.filter((d) => d.element.required), a = x(o), c = Math.round(
|
|
662
705
|
s * 0.3 + r * 0.2 + a * 0.5
|
|
663
|
-
), l = e.filter((d) => d.element.required && !d.passed).map((d) => d.element.name), u =
|
|
706
|
+
), l = e.filter((d) => d.element.required && !d.passed).map((d) => d.element.name), u = oe(e, n);
|
|
664
707
|
return {
|
|
665
708
|
overallScore: c,
|
|
666
709
|
structureScore: s,
|
|
@@ -670,12 +713,12 @@ function D(n) {
|
|
|
670
713
|
missingElements: l
|
|
671
714
|
};
|
|
672
715
|
}
|
|
673
|
-
function
|
|
716
|
+
function x(n) {
|
|
674
717
|
if (n.length === 0) return 100;
|
|
675
718
|
const e = n.reduce((s, i) => s + i.element.weight, 0), t = n.filter((s) => s.passed).reduce((s, i) => s + i.element.weight, 0);
|
|
676
719
|
return Math.round(t / e * 100);
|
|
677
720
|
}
|
|
678
|
-
function
|
|
721
|
+
function oe(n, e) {
|
|
679
722
|
const t = [], s = n.filter(
|
|
680
723
|
(a) => a.element.required && !a.passed
|
|
681
724
|
);
|
|
@@ -705,17 +748,17 @@ function ie(n, e) {
|
|
|
705
748
|
"Instructions meet quality standards. Consider A/B testing variants for optimization."
|
|
706
749
|
), t;
|
|
707
750
|
}
|
|
708
|
-
function
|
|
709
|
-
return
|
|
751
|
+
function Te(n, e = 70) {
|
|
752
|
+
return L(n).overallScore >= e;
|
|
710
753
|
}
|
|
711
|
-
function
|
|
754
|
+
function ae(n) {
|
|
712
755
|
return n >= 90 ? "A" : n >= 80 ? "B" : n >= 70 ? "C" : n >= 60 ? "D" : "F";
|
|
713
756
|
}
|
|
714
|
-
function
|
|
757
|
+
function $e(n) {
|
|
715
758
|
const e = [];
|
|
716
759
|
if (e.push(`=== Instruction Quality Report ===
|
|
717
760
|
`), e.push(
|
|
718
|
-
`Overall Score: ${n.overallScore}/100 (${
|
|
761
|
+
`Overall Score: ${n.overallScore}/100 (${ae(n.overallScore)})
|
|
719
762
|
`
|
|
720
763
|
), e.push(` Structure: ${n.structureScore}/100`), e.push(` Clarity: ${n.clarityScore}/100`), e.push(` Completeness: ${n.completenessScore}/100
|
|
721
764
|
`), n.missingElements.length > 0) {
|
|
@@ -733,7 +776,7 @@ function Te(n) {
|
|
|
733
776
|
return e.join(`
|
|
734
777
|
`);
|
|
735
778
|
}
|
|
736
|
-
let
|
|
779
|
+
let ce = class {
|
|
737
780
|
constructor() {
|
|
738
781
|
this.plugins = /* @__PURE__ */ new Map();
|
|
739
782
|
}
|
|
@@ -779,8 +822,8 @@ let oe = class {
|
|
|
779
822
|
return this.plugins.size;
|
|
780
823
|
}
|
|
781
824
|
};
|
|
782
|
-
const
|
|
783
|
-
class
|
|
825
|
+
const h = new ce();
|
|
826
|
+
class le {
|
|
784
827
|
constructor(e, t = /* @__PURE__ */ new Map()) {
|
|
785
828
|
this.analysisData = e, this.fileContentCache = t;
|
|
786
829
|
}
|
|
@@ -808,14 +851,14 @@ class ae {
|
|
|
808
851
|
return new RegExp(`^${t}$`);
|
|
809
852
|
}
|
|
810
853
|
}
|
|
811
|
-
async function
|
|
854
|
+
async function De(n, e) {
|
|
812
855
|
const t = /* @__PURE__ */ new Set(), s = [], i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
813
856
|
if (e)
|
|
814
857
|
for (const c of n.configFiles) {
|
|
815
858
|
const l = e(c);
|
|
816
859
|
l && r.set(c, l);
|
|
817
860
|
}
|
|
818
|
-
const o = new
|
|
861
|
+
const o = new le(n, r);
|
|
819
862
|
if (e) {
|
|
820
863
|
const c = o.getTextFile.bind(o);
|
|
821
864
|
o.getTextFile = (l) => {
|
|
@@ -823,7 +866,7 @@ async function $e(n, e) {
|
|
|
823
866
|
return u !== null ? u : e(l);
|
|
824
867
|
};
|
|
825
868
|
}
|
|
826
|
-
const a =
|
|
869
|
+
const a = h.getAll();
|
|
827
870
|
for (const c of a)
|
|
828
871
|
try {
|
|
829
872
|
const l = await Promise.resolve(c.detect(o));
|
|
@@ -846,12 +889,12 @@ async function $e(n, e) {
|
|
|
846
889
|
metadata: i
|
|
847
890
|
};
|
|
848
891
|
}
|
|
849
|
-
function
|
|
850
|
-
import("./index-
|
|
851
|
-
|
|
892
|
+
function Le() {
|
|
893
|
+
import("./index-BQ6v041y.js").then((n) => {
|
|
894
|
+
h.register(new n.GolangPlugin()), h.register(new n.PythonPlugin()), h.register(new n.RustPlugin()), h.register(new n.PHPPlugin()), h.register(new n.DockerPlugin()), h.register(new n.GitHubActionsPlugin()), h.register(new n.GitLabCIPlugin()), h.register(new n.MonorepoPlugin()), h.register(new n.CodeOwnersPlugin());
|
|
852
895
|
});
|
|
853
896
|
}
|
|
854
|
-
class
|
|
897
|
+
class Me {
|
|
855
898
|
constructor() {
|
|
856
899
|
this.name = "codeowners", this.description = "Detects CODEOWNERS file and provides code ownership instructions", this.version = "1.0.0";
|
|
857
900
|
}
|
|
@@ -895,7 +938,7 @@ class De {
|
|
|
895
938
|
];
|
|
896
939
|
}
|
|
897
940
|
}
|
|
898
|
-
class
|
|
941
|
+
class _e {
|
|
899
942
|
constructor() {
|
|
900
943
|
this.name = "docker", this.description = "Detects Docker usage and provides Docker-specific instructions", this.version = "1.0.0";
|
|
901
944
|
}
|
|
@@ -939,7 +982,7 @@ class Le {
|
|
|
939
982
|
}), s;
|
|
940
983
|
}
|
|
941
984
|
}
|
|
942
|
-
class
|
|
985
|
+
class Oe {
|
|
943
986
|
constructor() {
|
|
944
987
|
this.name = "github-actions", this.description = "Detects GitHub Actions workflows and provides CI/CD-specific instructions", this.version = "1.0.0";
|
|
945
988
|
}
|
|
@@ -972,7 +1015,7 @@ class Me {
|
|
|
972
1015
|
];
|
|
973
1016
|
}
|
|
974
1017
|
}
|
|
975
|
-
class
|
|
1018
|
+
class Re {
|
|
976
1019
|
constructor() {
|
|
977
1020
|
this.name = "gitlab-ci", this.description = "Detects GitLab CI/CD configuration and provides CI/CD-specific instructions", this.version = "1.0.0";
|
|
978
1021
|
}
|
|
@@ -1008,7 +1051,7 @@ class Oe {
|
|
|
1008
1051
|
];
|
|
1009
1052
|
}
|
|
1010
1053
|
}
|
|
1011
|
-
class
|
|
1054
|
+
class Ae {
|
|
1012
1055
|
constructor() {
|
|
1013
1056
|
this.name = "golang", this.description = "Detects Go (Golang) projects and provides Go-specific instructions", this.version = "1.0.0";
|
|
1014
1057
|
}
|
|
@@ -1042,7 +1085,7 @@ class Re {
|
|
|
1042
1085
|
];
|
|
1043
1086
|
}
|
|
1044
1087
|
}
|
|
1045
|
-
class
|
|
1088
|
+
class We {
|
|
1046
1089
|
constructor() {
|
|
1047
1090
|
this.name = "monorepo", this.description = "Detects monorepo structures and provides monorepo-specific instructions", this.version = "1.0.0";
|
|
1048
1091
|
}
|
|
@@ -1096,7 +1139,7 @@ class _e {
|
|
|
1096
1139
|
}), s;
|
|
1097
1140
|
}
|
|
1098
1141
|
}
|
|
1099
|
-
class
|
|
1142
|
+
class Ne {
|
|
1100
1143
|
constructor() {
|
|
1101
1144
|
this.name = "php", this.description = "Detects PHP projects and provides PHP-specific instructions", this.version = "1.0.0";
|
|
1102
1145
|
}
|
|
@@ -1135,7 +1178,7 @@ class Ae {
|
|
|
1135
1178
|
}), s;
|
|
1136
1179
|
}
|
|
1137
1180
|
}
|
|
1138
|
-
class
|
|
1181
|
+
class ze {
|
|
1139
1182
|
constructor() {
|
|
1140
1183
|
this.name = "python", this.description = "Detects Python projects and provides Python-specific instructions", this.version = "1.0.0";
|
|
1141
1184
|
}
|
|
@@ -1171,7 +1214,7 @@ class We {
|
|
|
1171
1214
|
];
|
|
1172
1215
|
}
|
|
1173
1216
|
}
|
|
1174
|
-
class
|
|
1217
|
+
class Ge {
|
|
1175
1218
|
constructor() {
|
|
1176
1219
|
this.name = "rust", this.description = "Detects Rust projects and provides Rust-specific instructions", this.version = "1.0.0";
|
|
1177
1220
|
}
|
|
@@ -1208,7 +1251,7 @@ class Ne {
|
|
|
1208
1251
|
];
|
|
1209
1252
|
}
|
|
1210
1253
|
}
|
|
1211
|
-
class
|
|
1254
|
+
class I {
|
|
1212
1255
|
constructor(e = {}) {
|
|
1213
1256
|
this.loadedPlugins = /* @__PURE__ */ new Map(), this.loadErrors = [], this.verbose = e.verbose ?? !1;
|
|
1214
1257
|
}
|
|
@@ -1218,7 +1261,7 @@ class $ {
|
|
|
1218
1261
|
async loadBuiltinPlugins(e) {
|
|
1219
1262
|
const t = [];
|
|
1220
1263
|
try {
|
|
1221
|
-
const { NodeJSPlugin: s } = await import("./index-Bg8DD8ku.js"), { GoPlugin: i } = await import("./index-B8pyjKdF.js"), { PythonPlugin: r } = await import("./index-OT2XAJkc.js"), { RustPlugin: o } = await import("./index-
|
|
1264
|
+
const { NodeJSPlugin: s } = await import("./index-Bg8DD8ku.js"), { GoPlugin: i } = await import("./index-B8pyjKdF.js"), { PythonPlugin: r } = await import("./index-OT2XAJkc.js"), { RustPlugin: o } = await import("./index-0GK4RlUx.js"), { JavaPlugin: a } = await import("./index-AkVwRl-r.js"), { RubyPlugin: c } = await import("./index-CPbv2Od1.js"), { PHPPlugin: l } = await import("./index-mYXvc3Fs.js"), { CSharpPlugin: u } = await import("./index-Cf-MC6Al.js"), { SwiftPlugin: d } = await import("./index-WmVSB57y.js"), { CppPlugin: g } = await import("./index-Baxb1vI_.js"), m = [
|
|
1222
1265
|
s,
|
|
1223
1266
|
i,
|
|
1224
1267
|
r,
|
|
@@ -1227,22 +1270,23 @@ class $ {
|
|
|
1227
1270
|
c,
|
|
1228
1271
|
l,
|
|
1229
1272
|
u,
|
|
1230
|
-
d
|
|
1273
|
+
d,
|
|
1274
|
+
g
|
|
1231
1275
|
];
|
|
1232
|
-
for (const
|
|
1233
|
-
const P = new
|
|
1276
|
+
for (const F of m) {
|
|
1277
|
+
const P = new F();
|
|
1234
1278
|
if (e && !e.includes(P.name))
|
|
1235
1279
|
continue;
|
|
1236
|
-
const
|
|
1280
|
+
const _ = Date.now(), j = {
|
|
1237
1281
|
plugin: P,
|
|
1238
1282
|
source: {
|
|
1239
1283
|
type: "builtin",
|
|
1240
1284
|
identifier: P.name,
|
|
1241
1285
|
packageName: "magic-helix-plugins"
|
|
1242
1286
|
},
|
|
1243
|
-
loadTime: Date.now() -
|
|
1287
|
+
loadTime: Date.now() - _
|
|
1244
1288
|
};
|
|
1245
|
-
this.loadedPlugins.set(P.name,
|
|
1289
|
+
this.loadedPlugins.set(P.name, j), t.push(j), this.log(
|
|
1246
1290
|
`Loaded built-in plugin: ${P.displayName} (${P.name})`
|
|
1247
1291
|
);
|
|
1248
1292
|
}
|
|
@@ -1300,8 +1344,8 @@ class $ {
|
|
|
1300
1344
|
*/
|
|
1301
1345
|
async loadLocalPlugin(e) {
|
|
1302
1346
|
try {
|
|
1303
|
-
const t =
|
|
1304
|
-
if (!
|
|
1347
|
+
const t = f.resolve(e);
|
|
1348
|
+
if (!p.existsSync(t))
|
|
1305
1349
|
throw new Error(`Plugin file not found: ${t}`);
|
|
1306
1350
|
const s = Date.now(), i = await import(t), r = Date.now() - s, o = i.default || i.Plugin || i;
|
|
1307
1351
|
if (typeof o != "function")
|
|
@@ -1399,24 +1443,101 @@ class $ {
|
|
|
1399
1443
|
}
|
|
1400
1444
|
return null;
|
|
1401
1445
|
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Recursively scan directories for project manifests
|
|
1448
|
+
*/
|
|
1449
|
+
async scanForProjects(e, t = 5) {
|
|
1450
|
+
const s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), r = [
|
|
1451
|
+
"package.json",
|
|
1452
|
+
"Cargo.toml",
|
|
1453
|
+
"go.mod",
|
|
1454
|
+
"go.sum",
|
|
1455
|
+
"setup.py",
|
|
1456
|
+
"pyproject.toml",
|
|
1457
|
+
"requirements.txt",
|
|
1458
|
+
"pom.xml",
|
|
1459
|
+
"build.gradle",
|
|
1460
|
+
"build.gradle.kts",
|
|
1461
|
+
"Package.swift",
|
|
1462
|
+
"Gemfile",
|
|
1463
|
+
"composer.json",
|
|
1464
|
+
"CMakeLists.txt",
|
|
1465
|
+
"Makefile",
|
|
1466
|
+
"platformio.ini"
|
|
1467
|
+
], o = /* @__PURE__ */ new Set([
|
|
1468
|
+
"node_modules",
|
|
1469
|
+
"target",
|
|
1470
|
+
"dist",
|
|
1471
|
+
"build",
|
|
1472
|
+
".git",
|
|
1473
|
+
".svn",
|
|
1474
|
+
".hg",
|
|
1475
|
+
"vendor",
|
|
1476
|
+
"__pycache__",
|
|
1477
|
+
".venv",
|
|
1478
|
+
"venv",
|
|
1479
|
+
"env",
|
|
1480
|
+
".cargo",
|
|
1481
|
+
".gradle"
|
|
1482
|
+
]), a = async (c, l) => {
|
|
1483
|
+
if (l > t) return;
|
|
1484
|
+
const u = f.normalize(c);
|
|
1485
|
+
if (!i.has(u)) {
|
|
1486
|
+
i.add(u);
|
|
1487
|
+
try {
|
|
1488
|
+
const d = await p.promises.readdir(c, {
|
|
1489
|
+
withFileTypes: !0
|
|
1490
|
+
});
|
|
1491
|
+
let g = !1;
|
|
1492
|
+
for (const m of d)
|
|
1493
|
+
if (!m.isDirectory() && r.includes(m.name)) {
|
|
1494
|
+
s.add(c), g = !0;
|
|
1495
|
+
break;
|
|
1496
|
+
}
|
|
1497
|
+
for (const m of d)
|
|
1498
|
+
if (m.isDirectory() && !o.has(m.name)) {
|
|
1499
|
+
const F = f.join(c, m.name);
|
|
1500
|
+
await a(F, l + 1);
|
|
1501
|
+
}
|
|
1502
|
+
} catch {
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
return await a(e, 0), Array.from(s).sort();
|
|
1508
|
+
}
|
|
1402
1509
|
/**
|
|
1403
1510
|
* Detect all projects in a directory (for monorepo support)
|
|
1511
|
+
* Enhanced version that recursively scans for ALL project types
|
|
1404
1512
|
*/
|
|
1405
1513
|
async detectAllProjects(e) {
|
|
1406
|
-
const t = [], s = this.getAllPlugins();
|
|
1407
|
-
for (const
|
|
1514
|
+
const t = [], s = /* @__PURE__ */ new Set(), i = this.getAllPlugins();
|
|
1515
|
+
for (const r of i)
|
|
1408
1516
|
try {
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1411
|
-
for (const
|
|
1412
|
-
const
|
|
1413
|
-
|
|
1517
|
+
const o = await r.detect(e);
|
|
1518
|
+
if (o && (s.add(o.projectPath), t.push({ metadata: o, plugin: r }), o.workspaceMembers && o.workspaceMembers.length > 0))
|
|
1519
|
+
for (const a of o.workspaceMembers) {
|
|
1520
|
+
const c = f.resolve(e, a);
|
|
1521
|
+
if (!s.has(c)) {
|
|
1522
|
+
const l = await this.detectProject(c);
|
|
1523
|
+
l && (s.add(l.metadata.projectPath), t.push(l));
|
|
1524
|
+
}
|
|
1414
1525
|
}
|
|
1415
|
-
} catch (
|
|
1526
|
+
} catch (o) {
|
|
1416
1527
|
this.logWarning(
|
|
1417
|
-
`Plugin ${
|
|
1528
|
+
`Plugin ${r.name} failed: ${o.message}`
|
|
1418
1529
|
);
|
|
1419
1530
|
}
|
|
1531
|
+
try {
|
|
1532
|
+
const r = await this.scanForProjects(e);
|
|
1533
|
+
for (const o of r)
|
|
1534
|
+
if (!s.has(o)) {
|
|
1535
|
+
const a = await this.detectProject(o);
|
|
1536
|
+
a && (s.add(a.metadata.projectPath), t.push(a));
|
|
1537
|
+
}
|
|
1538
|
+
} catch (r) {
|
|
1539
|
+
this.logWarning(`Recursive scan failed: ${r.message}`);
|
|
1540
|
+
}
|
|
1420
1541
|
return t;
|
|
1421
1542
|
}
|
|
1422
1543
|
/**
|
|
@@ -1486,21 +1607,21 @@ class $ {
|
|
|
1486
1607
|
this.verbose && console.warn(`[PluginLoader] ⚠️ ${e}`);
|
|
1487
1608
|
}
|
|
1488
1609
|
}
|
|
1489
|
-
const
|
|
1610
|
+
const y = class y {
|
|
1490
1611
|
constructor() {
|
|
1491
|
-
this.initialized = !1, this.loader = new
|
|
1612
|
+
this.initialized = !1, this.loader = new I({ verbose: !1 }), this.config = {};
|
|
1492
1613
|
}
|
|
1493
1614
|
/**
|
|
1494
1615
|
* Get the singleton instance
|
|
1495
1616
|
*/
|
|
1496
1617
|
static getInstance() {
|
|
1497
|
-
return
|
|
1618
|
+
return y.instance || (y.instance = new y()), y.instance;
|
|
1498
1619
|
}
|
|
1499
1620
|
/**
|
|
1500
1621
|
* Initialize the registry with configuration
|
|
1501
1622
|
*/
|
|
1502
1623
|
async initialize(e = {}) {
|
|
1503
|
-
if (!this.initialized && (this.config = e, this.loader = new
|
|
1624
|
+
if (!this.initialized && (this.config = e, this.loader = new I({ verbose: e.verbose }), await this.loadConfiguredPlugins(e.plugins), this.initialized = !0, e.verbose)) {
|
|
1504
1625
|
const t = this.loader.getStats();
|
|
1505
1626
|
console.log(
|
|
1506
1627
|
`[PluginRegistry] Initialized with ${t.totalLoaded} plugins`
|
|
@@ -1632,12 +1753,12 @@ const h = class h {
|
|
|
1632
1753
|
resolvePath(e) {
|
|
1633
1754
|
if (e.startsWith("~/")) {
|
|
1634
1755
|
const s = process.env.HOME || process.env.USERPROFILE || "";
|
|
1635
|
-
return
|
|
1756
|
+
return f.join(s, e.slice(2));
|
|
1636
1757
|
}
|
|
1637
|
-
if (
|
|
1758
|
+
if (f.isAbsolute(e))
|
|
1638
1759
|
return e;
|
|
1639
1760
|
const t = this.config.workspacePath || process.cwd();
|
|
1640
|
-
return
|
|
1761
|
+
return f.resolve(t, e);
|
|
1641
1762
|
}
|
|
1642
1763
|
/**
|
|
1643
1764
|
* Apply priority overrides from configuration
|
|
@@ -1653,9 +1774,9 @@ const h = class h {
|
|
|
1653
1774
|
*/
|
|
1654
1775
|
static async loadConfigFromFile(e) {
|
|
1655
1776
|
try {
|
|
1656
|
-
if (!
|
|
1777
|
+
if (!p.existsSync(e))
|
|
1657
1778
|
return null;
|
|
1658
|
-
const t =
|
|
1779
|
+
const t = p.readFileSync(e, "utf-8");
|
|
1659
1780
|
return JSON.parse(t);
|
|
1660
1781
|
} catch (t) {
|
|
1661
1782
|
return console.warn(
|
|
@@ -1669,15 +1790,15 @@ const h = class h {
|
|
|
1669
1790
|
static async loadConfig(e) {
|
|
1670
1791
|
const t = [], s = process.env.HOME || process.env.USERPROFILE;
|
|
1671
1792
|
if (s) {
|
|
1672
|
-
const i =
|
|
1793
|
+
const i = f.join(
|
|
1673
1794
|
s,
|
|
1674
1795
|
".magic-helix",
|
|
1675
1796
|
"config.json"
|
|
1676
|
-
), r = await
|
|
1797
|
+
), r = await y.loadConfigFromFile(i);
|
|
1677
1798
|
r && t.push(r);
|
|
1678
1799
|
}
|
|
1679
1800
|
if (e) {
|
|
1680
|
-
const i =
|
|
1801
|
+
const i = f.join(e, ".magic-helix.json"), r = await y.loadConfigFromFile(i);
|
|
1681
1802
|
r && (r.workspacePath = e, t.push(r));
|
|
1682
1803
|
}
|
|
1683
1804
|
return t.length === 0 ? { workspacePath: e } : t.reduce(
|
|
@@ -1698,16 +1819,16 @@ const h = class h {
|
|
|
1698
1819
|
);
|
|
1699
1820
|
}
|
|
1700
1821
|
};
|
|
1701
|
-
|
|
1702
|
-
let k =
|
|
1703
|
-
function
|
|
1822
|
+
y.instance = null;
|
|
1823
|
+
let k = y;
|
|
1824
|
+
function Be() {
|
|
1704
1825
|
return k.getInstance();
|
|
1705
1826
|
}
|
|
1706
|
-
async function
|
|
1827
|
+
async function qe(n) {
|
|
1707
1828
|
const e = k.getInstance();
|
|
1708
1829
|
return await e.initialize(n), e;
|
|
1709
1830
|
}
|
|
1710
|
-
class
|
|
1831
|
+
class He {
|
|
1711
1832
|
constructor(e = {}) {
|
|
1712
1833
|
this.templateCache = /* @__PURE__ */ new Map(), this.config = e.config || {}, this.verbose = e.verbose ?? !1, this.cacheEnabled = e.cacheEnabled ?? !0;
|
|
1713
1834
|
}
|
|
@@ -1812,9 +1933,9 @@ class Be {
|
|
|
1812
1933
|
async loadFromPath(e, t) {
|
|
1813
1934
|
try {
|
|
1814
1935
|
const s = this.resolvePath(e);
|
|
1815
|
-
if (!
|
|
1936
|
+
if (!p.existsSync(s))
|
|
1816
1937
|
return this.log(`Template not found at: ${s}`), null;
|
|
1817
|
-
const i =
|
|
1938
|
+
const i = p.readFileSync(s, "utf-8");
|
|
1818
1939
|
return this.log(`✓ Loaded template from ${t}: ${s}`), {
|
|
1819
1940
|
content: i,
|
|
1820
1941
|
source: t,
|
|
@@ -1831,12 +1952,12 @@ class Be {
|
|
|
1831
1952
|
*/
|
|
1832
1953
|
async searchInDirectory(e, t, s) {
|
|
1833
1954
|
const i = this.resolvePath(e);
|
|
1834
|
-
if (!
|
|
1955
|
+
if (!p.existsSync(i))
|
|
1835
1956
|
return null;
|
|
1836
1957
|
const r = this.config.extensions || [".md", ".txt", ""];
|
|
1837
1958
|
for (const o of r) {
|
|
1838
|
-
const a = t.endsWith(o) ? t : `${t}${o}`, c =
|
|
1839
|
-
if (
|
|
1959
|
+
const a = t.endsWith(o) ? t : `${t}${o}`, c = f.join(i, a);
|
|
1960
|
+
if (p.existsSync(c))
|
|
1840
1961
|
return this.loadFromPath(c, s);
|
|
1841
1962
|
}
|
|
1842
1963
|
return null;
|
|
@@ -1870,9 +1991,9 @@ class Be {
|
|
|
1870
1991
|
resolvePath(e) {
|
|
1871
1992
|
if (e.startsWith("~/")) {
|
|
1872
1993
|
const t = process.env.HOME || process.env.USERPROFILE || "";
|
|
1873
|
-
return
|
|
1994
|
+
return f.join(t, e.slice(2));
|
|
1874
1995
|
}
|
|
1875
|
-
return
|
|
1996
|
+
return f.isAbsolute(e) ? e : f.resolve(process.cwd(), e);
|
|
1876
1997
|
}
|
|
1877
1998
|
/**
|
|
1878
1999
|
* Cache a template
|
|
@@ -1887,13 +2008,13 @@ class Be {
|
|
|
1887
2008
|
this.verbose && console.warn(`[TemplateLoader] ⚠️ ${e}`);
|
|
1888
2009
|
}
|
|
1889
2010
|
}
|
|
1890
|
-
const C = ".magic-helix",
|
|
1891
|
-
function
|
|
1892
|
-
const e =
|
|
1893
|
-
if (!
|
|
2011
|
+
const C = ".magic-helix", M = "meta-instructions.json";
|
|
2012
|
+
function ue(n) {
|
|
2013
|
+
const e = f.join(n, C, M);
|
|
2014
|
+
if (!p.existsSync(e))
|
|
1894
2015
|
return null;
|
|
1895
2016
|
try {
|
|
1896
|
-
const t =
|
|
2017
|
+
const t = p.readFileSync(e, "utf-8");
|
|
1897
2018
|
return JSON.parse(t);
|
|
1898
2019
|
} catch (t) {
|
|
1899
2020
|
return console.warn(
|
|
@@ -1901,23 +2022,23 @@ function ce(n) {
|
|
|
1901
2022
|
), null;
|
|
1902
2023
|
}
|
|
1903
2024
|
}
|
|
1904
|
-
function
|
|
1905
|
-
const e =
|
|
1906
|
-
if (!
|
|
2025
|
+
function de(n) {
|
|
2026
|
+
const e = f.join(n, C, "overrides"), t = /* @__PURE__ */ new Map();
|
|
2027
|
+
if (!p.existsSync(e))
|
|
1907
2028
|
return t;
|
|
1908
|
-
const s =
|
|
2029
|
+
const s = W.sync("**/*.md", { cwd: e, absolute: !0 });
|
|
1909
2030
|
for (const i of s) {
|
|
1910
|
-
const r =
|
|
2031
|
+
const r = f.basename(i, ".md"), o = p.readFileSync(i, "utf-8");
|
|
1911
2032
|
t.set(r, o);
|
|
1912
2033
|
}
|
|
1913
2034
|
return t;
|
|
1914
2035
|
}
|
|
1915
|
-
function
|
|
2036
|
+
function ge(n, e, t) {
|
|
1916
2037
|
const s = new Map(n);
|
|
1917
2038
|
if (e.ignoreTags)
|
|
1918
2039
|
for (const r of e.ignoreTags)
|
|
1919
2040
|
s.delete(r);
|
|
1920
|
-
const i =
|
|
2041
|
+
const i = de(t);
|
|
1921
2042
|
for (const [r, o] of i)
|
|
1922
2043
|
s.set(r, o);
|
|
1923
2044
|
if (e.overrides)
|
|
@@ -1941,7 +2062,7 @@ ${r.content}`) : s.set(r.tag, r.content);
|
|
|
1941
2062
|
}
|
|
1942
2063
|
return s;
|
|
1943
2064
|
}
|
|
1944
|
-
function
|
|
2065
|
+
function fe(n, e) {
|
|
1945
2066
|
const t = new Map(n);
|
|
1946
2067
|
let s = e.template;
|
|
1947
2068
|
for (const i of e.tags) {
|
|
@@ -1950,23 +2071,23 @@ function de(n, e) {
|
|
|
1950
2071
|
}
|
|
1951
2072
|
return t.set(e.outputTag, s), t;
|
|
1952
2073
|
}
|
|
1953
|
-
function
|
|
1954
|
-
const t =
|
|
2074
|
+
function Ue(n, e) {
|
|
2075
|
+
const t = ue(e);
|
|
1955
2076
|
if (!t)
|
|
1956
2077
|
return n;
|
|
1957
|
-
let s =
|
|
2078
|
+
let s = ge(n, t, e);
|
|
1958
2079
|
if (t.combiners)
|
|
1959
2080
|
for (const i of t.combiners)
|
|
1960
|
-
s =
|
|
2081
|
+
s = fe(s, i);
|
|
1961
2082
|
return s;
|
|
1962
2083
|
}
|
|
1963
|
-
function
|
|
1964
|
-
const e =
|
|
1965
|
-
return
|
|
2084
|
+
function Je(n) {
|
|
2085
|
+
const e = f.join(n, C);
|
|
2086
|
+
return p.existsSync(e);
|
|
1966
2087
|
}
|
|
1967
|
-
function
|
|
1968
|
-
const e =
|
|
1969
|
-
|
|
2088
|
+
function Ve(n) {
|
|
2089
|
+
const e = f.join(n, C), t = f.join(e, "overrides");
|
|
2090
|
+
p.mkdirSync(e, { recursive: !0 }), p.mkdirSync(t, { recursive: !0 });
|
|
1970
2091
|
const s = {
|
|
1971
2092
|
overrides: [
|
|
1972
2093
|
{
|
|
@@ -1991,8 +2112,8 @@ Your content here...`,
|
|
|
1991
2112
|
}
|
|
1992
2113
|
],
|
|
1993
2114
|
ignoreTags: ["unwanted-tag"]
|
|
1994
|
-
}, i =
|
|
1995
|
-
|
|
2115
|
+
}, i = f.join(e, M);
|
|
2116
|
+
p.writeFileSync(i, JSON.stringify(s, null, 2)), p.writeFileSync(f.join(t, "example.md"), `# Example Override
|
|
1996
2117
|
|
|
1997
2118
|
This file overrides the default instructions for this tag.
|
|
1998
2119
|
Create files like:
|
|
@@ -2002,11 +2123,11 @@ Create files like:
|
|
|
2002
2123
|
`✅ Initialized .magic-helix/ directory structure at: ${e}`
|
|
2003
2124
|
);
|
|
2004
2125
|
}
|
|
2005
|
-
class
|
|
2126
|
+
class pe {
|
|
2006
2127
|
constructor(e = {}) {
|
|
2007
2128
|
this.enabled = !!e.enabled;
|
|
2008
|
-
const t = e.dir ||
|
|
2009
|
-
this.filePath =
|
|
2129
|
+
const t = e.dir || S.resolve(process.cwd(), ".magic-helix/telemetry");
|
|
2130
|
+
this.filePath = S.join(t, "events.jsonl"), this.sessionId = e.sessionId, this.variant = e.variant, this.projectRoot = e.projectRoot, this.enabled && E.mkdirSync(S.dirname(this.filePath), { recursive: !0 });
|
|
2010
2131
|
}
|
|
2011
2132
|
isEnabled() {
|
|
2012
2133
|
return this.enabled;
|
|
@@ -2025,13 +2146,13 @@ class ge {
|
|
|
2025
2146
|
E.appendFileSync(this.filePath, s, "utf-8");
|
|
2026
2147
|
}
|
|
2027
2148
|
}
|
|
2028
|
-
function
|
|
2149
|
+
function Ye(n = {}) {
|
|
2029
2150
|
const e = n.enabled ?? process.env.MAGIC_HELIX_TELEMETRY === "1", t = n.dir || process.env.MAGIC_HELIX_TELEMETRY_DIR, s = n.sessionId || process.env.MAGIC_HELIX_SESSION_ID || `${Date.now()}`, i = n.variant || process.env.MAGIC_HELIX_VARIANT || "default", r = n.projectRoot || process.cwd();
|
|
2030
|
-
return new
|
|
2151
|
+
return new pe({ enabled: e, dir: t, sessionId: s, variant: i, projectRoot: r });
|
|
2031
2152
|
}
|
|
2032
|
-
function
|
|
2153
|
+
function Qe(n) {
|
|
2033
2154
|
return n.map((e) => {
|
|
2034
|
-
const t =
|
|
2155
|
+
const t = ie(e.context), s = L(t);
|
|
2035
2156
|
return {
|
|
2036
2157
|
variant: e.name,
|
|
2037
2158
|
instructions: t,
|
|
@@ -2043,7 +2164,7 @@ function Ve(n) {
|
|
|
2043
2164
|
};
|
|
2044
2165
|
});
|
|
2045
2166
|
}
|
|
2046
|
-
function
|
|
2167
|
+
function Xe(n) {
|
|
2047
2168
|
return n.length === 0 ? {
|
|
2048
2169
|
variant: "",
|
|
2049
2170
|
instructions: "",
|
|
@@ -2057,7 +2178,7 @@ function Ye(n) {
|
|
|
2057
2178
|
n[0]
|
|
2058
2179
|
);
|
|
2059
2180
|
}
|
|
2060
|
-
function
|
|
2181
|
+
function Ke(n, e) {
|
|
2061
2182
|
if (e?.isEnabled())
|
|
2062
2183
|
for (const t of n) {
|
|
2063
2184
|
const s = {
|
|
@@ -2073,56 +2194,56 @@ function Qe(n, e) {
|
|
|
2073
2194
|
e.track(s);
|
|
2074
2195
|
}
|
|
2075
2196
|
}
|
|
2076
|
-
const
|
|
2197
|
+
const me = A(import.meta.url), he = O(me), Ze = R(he, "default_templates");
|
|
2077
2198
|
export {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2199
|
+
qe as A,
|
|
2200
|
+
Ze as B,
|
|
2201
|
+
Me as C,
|
|
2202
|
+
_e as D,
|
|
2203
|
+
ue as E,
|
|
2204
|
+
de as F,
|
|
2205
|
+
Oe as G,
|
|
2206
|
+
ge as H,
|
|
2207
|
+
re as I,
|
|
2208
|
+
fe as J,
|
|
2209
|
+
Ue as K,
|
|
2210
|
+
Je as L,
|
|
2211
|
+
We as M,
|
|
2212
|
+
Ve as N,
|
|
2213
|
+
Ye as O,
|
|
2214
|
+
Ne as P,
|
|
2215
|
+
pe as Q,
|
|
2216
|
+
Ge as R,
|
|
2217
|
+
Qe as S,
|
|
2218
|
+
He as T,
|
|
2219
|
+
Xe as U,
|
|
2220
|
+
Ke as V,
|
|
2221
|
+
Ee as _,
|
|
2222
|
+
Re as a,
|
|
2223
|
+
Ae as b,
|
|
2224
|
+
ze as c,
|
|
2225
|
+
ke as d,
|
|
2105
2226
|
G as e,
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2227
|
+
Fe as f,
|
|
2228
|
+
D as g,
|
|
2229
|
+
je as h,
|
|
2230
|
+
ie as i,
|
|
2231
|
+
ee as j,
|
|
2232
|
+
ne as k,
|
|
2233
|
+
Se as l,
|
|
2234
|
+
xe as m,
|
|
2235
|
+
$e as n,
|
|
2236
|
+
ae as o,
|
|
2237
|
+
Te as p,
|
|
2238
|
+
De as q,
|
|
2239
|
+
Ce as r,
|
|
2240
|
+
se as s,
|
|
2241
|
+
Le as t,
|
|
2242
|
+
ce as u,
|
|
2243
|
+
L as v,
|
|
2244
|
+
h as w,
|
|
2245
|
+
I as x,
|
|
2125
2246
|
k as y,
|
|
2126
|
-
|
|
2247
|
+
Be as z
|
|
2127
2248
|
};
|
|
2128
|
-
//# sourceMappingURL=index-
|
|
2249
|
+
//# sourceMappingURL=index-DkvW5yBY.js.map
|