@el-j/magic-helix-core 4.0.0-beta.3 → 4.0.0-beta.5

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import * as f from "node:path";
1
+ import * as g from "node:path";
2
2
  import C, { dirname as L } from "node:path";
3
3
  import { fileURLToPath as M } from "node:url";
4
4
  import * as p from "node:fs";
@@ -66,19 +66,14 @@ const A = {
66
66
  zustand: "state-zustand"
67
67
  },
68
68
  configFileTagMap: {
69
- // Detect key configs
69
+ // Detect key configs - removed language-specific entries, now handled by plugins
70
70
  "tailwind.config.js": "style-tailwind",
71
71
  "tailwind.config.ts": "style-tailwind",
72
72
  "vite.config.ts": "build-vite",
73
- "vite.config.js": "build-vite",
74
- "tsconfig.json": "lang-typescript"
73
+ "vite.config.js": "build-vite"
75
74
  },
76
75
  fileGlobTagMap: {
77
- // Detect file types
78
- "src/**/*.vue": "framework-vue",
79
- "src/**/*.tsx": "framework-react",
80
- "src/**/*.go": "lang-go",
81
- "src/**/*.py": "lang-python"
76
+ // Detect file types - removed language-specific entries, now handled by plugins
82
77
  },
83
78
  tagTemplateMap: {
84
79
  // Vue Projects
@@ -145,23 +140,8 @@ const A = {
145
140
  template: "generic/test-playwright.md",
146
141
  suffix: "playwright.instructions.md"
147
142
  }
148
- ],
149
- "lang-typescript": [
150
- {
151
- template: "generic/lang-typescript.md",
152
- suffix: "typescript.instructions.md"
153
- }
154
- ],
155
- "lang-python": [
156
- { template: "python/lang-python.md", suffix: "python.instructions.md" }
157
- ],
158
- "lang-go": [{ template: "go/lang-go.md", suffix: "go.instructions.md" }],
159
- "state-rxjs": [
160
- { template: "generic/state-rxjs.md", suffix: "rxjs.instructions.md" }
161
- ],
162
- "state-redux": [
163
- { template: "generic/state-redux.md", suffix: "redux.instructions.md" }
164
143
  ]
144
+ // Language-specific templates removed - now provided by language plugins
165
145
  }
166
146
  }, T = {
167
147
  quality: "standard",
@@ -278,18 +258,18 @@ function q(n, e) {
278
258
  function ve(n) {
279
259
  return Math.ceil(n.length / 4);
280
260
  }
281
- const x = "magic-helix.config.json", H = ["ai-aligner.config.json"];
261
+ const j = "magic-helix.config.json", H = ["ai-aligner.config.json"];
282
262
  function Pe(n) {
283
- const t = (n ? [f.resolve(process.cwd(), n)] : [
284
- f.resolve(process.cwd(), x),
263
+ const t = (n ? [g.resolve(process.cwd(), n)] : [
264
+ g.resolve(process.cwd(), j),
285
265
  ...H.map(
286
- (s) => f.resolve(process.cwd(), s)
266
+ (s) => g.resolve(process.cwd(), s)
287
267
  )
288
268
  ]).find((s, i) => {
289
269
  const r = p.existsSync(s);
290
270
  return !n && r && i > 0 && console.warn(
291
271
  P.yellow(
292
- ` Detected legacy config file ${f.basename(s)}. Please rename it to ${x}.`
272
+ ` Detected legacy config file ${g.basename(s)}. Please rename it to ${j}.`
293
273
  )
294
274
  ), r;
295
275
  });
@@ -353,7 +333,7 @@ function U(n) {
353
333
  }
354
334
  return e;
355
335
  }
356
- class j {
336
+ class E {
357
337
  format(e, t, s) {
358
338
  return e;
359
339
  }
@@ -418,7 +398,7 @@ applyTo: "${e}"
418
398
  function ke(n) {
419
399
  switch (n) {
420
400
  case "github-copilot":
421
- return new j();
401
+ return new E();
422
402
  case "claude":
423
403
  return new J();
424
404
  case "copilot-chat":
@@ -426,7 +406,7 @@ function ke(n) {
426
406
  case "generic":
427
407
  return new Y();
428
408
  default:
429
- return new j();
409
+ return new E();
430
410
  }
431
411
  }
432
412
  const v = {};
@@ -511,11 +491,11 @@ function K(n, e) {
511
491
  return e.excludePatterns ? t.filter((u) => !e.excludePatterns?.includes(u.name)) : t;
512
492
  }
513
493
  function Z(n) {
514
- const e = n.sort((g, m) => g.priority - m.priority), t = [], s = /* @__PURE__ */ new Map();
515
- for (const g of e) {
516
- s.has(g.category) || s.set(g.category, []);
517
- const m = s.get(g.category);
518
- m && m.push(g);
494
+ const e = n.sort((f, m) => f.priority - m.priority), t = [], s = /* @__PURE__ */ new Map();
495
+ for (const f of e) {
496
+ s.has(f.category) || s.set(f.category, []);
497
+ const m = s.get(f.category);
498
+ m && m.push(f);
519
499
  }
520
500
  t.push(`# AI Agent Instructions
521
501
  `);
@@ -523,57 +503,57 @@ function Z(n) {
523
503
  if (i) {
524
504
  t.push(`## Role & Identity
525
505
  `);
526
- for (const g of i)
527
- t.push(w(g.content));
506
+ for (const f of i)
507
+ t.push(w(f.content));
528
508
  }
529
509
  const r = s.get("organization");
530
510
  if (r) {
531
511
  t.push(`## Instruction Structure
532
512
  `);
533
- for (const g of r)
534
- t.push(w(g.content));
513
+ for (const f of r)
514
+ t.push(w(f.content));
535
515
  }
536
516
  const o = s.get("tool-guidelines");
537
517
  if (o) {
538
518
  t.push(`## Tool Usage Guidelines
539
519
  `);
540
- for (const g of o)
541
- t.push(w(g.content));
520
+ for (const f of o)
521
+ t.push(w(f.content));
542
522
  }
543
523
  const a = s.get("reasoning");
544
524
  if (a) {
545
525
  t.push(`## Reasoning & Execution Patterns
546
526
  `);
547
- for (const g of a)
548
- t.push(w(g.content));
527
+ for (const f of a)
528
+ t.push(w(f.content));
549
529
  }
550
530
  const c = s.get("domain-expertise");
551
531
  if (c) {
552
532
  t.push(`## Domain-Specific Guidelines
553
533
  `);
554
- for (const g of c)
555
- t.push(w(g.content));
534
+ for (const f of c)
535
+ t.push(w(f.content));
556
536
  }
557
537
  const l = s.get("environment");
558
538
  if (l) {
559
539
  t.push(`## Environment Context
560
540
  `);
561
- for (const g of l)
562
- t.push(w(g.content));
541
+ for (const f of l)
542
+ t.push(w(f.content));
563
543
  }
564
544
  const u = s.get("tone");
565
545
  if (u) {
566
546
  t.push(`## Communication Style
567
547
  `);
568
- for (const g of u)
569
- t.push(w(g.content));
548
+ for (const f of u)
549
+ t.push(w(f.content));
570
550
  }
571
551
  const d = s.get("safety");
572
552
  if (d) {
573
553
  t.push(`## Safety & Refusal Protocols
574
554
  `);
575
- for (const g of d)
576
- t.push(w(g.content));
555
+ for (const f of d)
556
+ t.push(w(f.content));
577
557
  }
578
558
  return t.join(`
579
559
 
@@ -848,7 +828,7 @@ class re {
848
828
  return new RegExp(`^${t}$`);
849
829
  }
850
830
  }
851
- async function xe(n, e) {
831
+ async function je(n, e) {
852
832
  const t = /* @__PURE__ */ new Set(), s = [], i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
853
833
  if (e)
854
834
  for (const c of n.configFiles) {
@@ -886,12 +866,12 @@ async function xe(n, e) {
886
866
  metadata: i
887
867
  };
888
868
  }
889
- function je() {
869
+ function Ee() {
890
870
  import("./index-B88j4AyE.js").then((n) => {
891
871
  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());
892
872
  });
893
873
  }
894
- class Ee {
874
+ class xe {
895
875
  constructor() {
896
876
  this.name = "codeowners", this.description = "Detects CODEOWNERS file and provides code ownership instructions", this.version = "1.0.0";
897
877
  }
@@ -1103,7 +1083,7 @@ class Le {
1103
1083
  d && (c.hasPipeline = d.includes('"pipeline"'));
1104
1084
  } else s ? c.tool = "nx" : i ? c.tool = "pnpm" : r ? c.tool = "lerna" : c.tool = "npm/yarn workspaces";
1105
1085
  const l = ["packages/*/package.json", "apps/*/package.json"], u = e.files.filter(
1106
- (d) => l.some((g) => new RegExp(g.replace(/\*/g, "[^/]+")).test(d))
1086
+ (d) => l.some((f) => new RegExp(f.replace(/\*/g, "[^/]+")).test(d))
1107
1087
  );
1108
1088
  return u.length > 0 && (c.packageCount = u.length), {
1109
1089
  detected: !0,
@@ -1248,7 +1228,7 @@ class Re {
1248
1228
  ];
1249
1229
  }
1250
1230
  }
1251
- class E {
1231
+ class x {
1252
1232
  constructor(e = {}) {
1253
1233
  this.loadedPlugins = /* @__PURE__ */ new Map(), this.loadErrors = [], this.verbose = e.verbose ?? !1;
1254
1234
  }
@@ -1335,7 +1315,7 @@ class E {
1335
1315
  */
1336
1316
  async loadLocalPlugin(e) {
1337
1317
  try {
1338
- const t = f.resolve(e);
1318
+ const t = g.resolve(e);
1339
1319
  if (!p.existsSync(t))
1340
1320
  throw new Error(`Plugin file not found: ${t}`);
1341
1321
  const s = Date.now(), i = await import(t), r = Date.now() - s, o = i.default || i.Plugin || i;
@@ -1472,22 +1452,22 @@ class E {
1472
1452
  ".gradle"
1473
1453
  ]), a = async (c, l) => {
1474
1454
  if (l > t) return;
1475
- const u = f.normalize(c);
1455
+ const u = g.normalize(c);
1476
1456
  if (!i.has(u)) {
1477
1457
  i.add(u);
1478
1458
  try {
1479
1459
  const d = await p.promises.readdir(c, {
1480
1460
  withFileTypes: !0
1481
1461
  });
1482
- let g = !1;
1462
+ let f = !1;
1483
1463
  for (const m of d)
1484
1464
  if (!m.isDirectory() && r.includes(m.name)) {
1485
- s.add(c), g = !0;
1465
+ s.add(c), f = !0;
1486
1466
  break;
1487
1467
  }
1488
1468
  for (const m of d)
1489
1469
  if (m.isDirectory() && !o.has(m.name)) {
1490
- const D = f.join(c, m.name);
1470
+ const D = g.join(c, m.name);
1491
1471
  await a(D, l + 1);
1492
1472
  }
1493
1473
  } catch {
@@ -1508,7 +1488,7 @@ class E {
1508
1488
  const o = await r.detect(e);
1509
1489
  if (o && (s.add(o.projectPath), t.push({ metadata: o, plugin: r }), o.workspaceMembers && o.workspaceMembers.length > 0))
1510
1490
  for (const a of o.workspaceMembers) {
1511
- const c = f.resolve(e, a);
1491
+ const c = g.resolve(e, a);
1512
1492
  if (!s.has(c)) {
1513
1493
  const l = await this.detectProject(c);
1514
1494
  l && (s.add(l.metadata.projectPath), t.push(l));
@@ -1600,7 +1580,7 @@ class E {
1600
1580
  }
1601
1581
  const y = class y {
1602
1582
  constructor() {
1603
- this.initialized = !1, this.loader = new E({ verbose: !1 }), this.config = {};
1583
+ this.initialized = !1, this.loader = new x({ verbose: !1 }), this.config = {};
1604
1584
  }
1605
1585
  /**
1606
1586
  * Get the singleton instance
@@ -1612,7 +1592,7 @@ const y = class y {
1612
1592
  * Initialize the registry with configuration
1613
1593
  */
1614
1594
  async initialize(e = {}) {
1615
- if (!this.initialized && (this.config = e, this.loader = new E({ verbose: e.verbose }), await this.loadConfiguredPlugins(e.plugins), this.initialized = !0, e.verbose)) {
1595
+ if (!this.initialized && (this.config = e, this.loader = new x({ verbose: e.verbose }), await this.loadConfiguredPlugins(e.plugins), this.initialized = !0, e.verbose)) {
1616
1596
  const t = this.loader.getStats();
1617
1597
  console.log(
1618
1598
  `[PluginRegistry] Initialized with ${t.totalLoaded} plugins`
@@ -1742,12 +1722,12 @@ const y = class y {
1742
1722
  resolvePath(e) {
1743
1723
  if (e.startsWith("~/")) {
1744
1724
  const s = process.env.HOME || process.env.USERPROFILE || "";
1745
- return f.join(s, e.slice(2));
1725
+ return g.join(s, e.slice(2));
1746
1726
  }
1747
- if (f.isAbsolute(e))
1727
+ if (g.isAbsolute(e))
1748
1728
  return e;
1749
1729
  const t = this.config.workspacePath || process.cwd();
1750
- return f.resolve(t, e);
1730
+ return g.resolve(t, e);
1751
1731
  }
1752
1732
  /**
1753
1733
  * Apply priority overrides from configuration
@@ -1779,7 +1759,7 @@ const y = class y {
1779
1759
  static async loadConfig(e) {
1780
1760
  const t = [], s = process.env.HOME || process.env.USERPROFILE;
1781
1761
  if (s) {
1782
- const i = f.join(
1762
+ const i = g.join(
1783
1763
  s,
1784
1764
  ".magic-helix",
1785
1765
  "config.json"
@@ -1787,7 +1767,7 @@ const y = class y {
1787
1767
  r && t.push(r);
1788
1768
  }
1789
1769
  if (e) {
1790
- const i = f.join(e, ".magic-helix.json"), r = await y.loadConfigFromFile(i);
1770
+ const i = g.join(e, ".magic-helix.json"), r = await y.loadConfigFromFile(i);
1791
1771
  r && (r.workspacePath = e, t.push(r));
1792
1772
  }
1793
1773
  return t.length === 0 ? { workspacePath: e } : t.reduce(
@@ -1945,7 +1925,7 @@ class We {
1945
1925
  return null;
1946
1926
  const r = this.config.extensions || [".md", ".txt", ""];
1947
1927
  for (const o of r) {
1948
- const a = t.endsWith(o) ? t : `${t}${o}`, c = f.join(i, a);
1928
+ const a = t.endsWith(o) ? t : `${t}${o}`, c = g.join(i, a);
1949
1929
  if (p.existsSync(c))
1950
1930
  return this.loadFromPath(c, s);
1951
1931
  }
@@ -1980,9 +1960,9 @@ class We {
1980
1960
  resolvePath(e) {
1981
1961
  if (e.startsWith("~/")) {
1982
1962
  const t = process.env.HOME || process.env.USERPROFILE || "";
1983
- return f.join(t, e.slice(2));
1963
+ return g.join(t, e.slice(2));
1984
1964
  }
1985
- return f.isAbsolute(e) ? e : f.resolve(process.cwd(), e);
1965
+ return g.isAbsolute(e) ? e : g.resolve(process.cwd(), e);
1986
1966
  }
1987
1967
  /**
1988
1968
  * Cache a template
@@ -1999,7 +1979,7 @@ class We {
1999
1979
  }
2000
1980
  const k = ".magic-helix", I = "meta-instructions.json";
2001
1981
  function oe(n) {
2002
- const e = f.join(n, k, I);
1982
+ const e = g.join(n, k, I);
2003
1983
  if (!p.existsSync(e))
2004
1984
  return null;
2005
1985
  try {
@@ -2012,12 +1992,12 @@ function oe(n) {
2012
1992
  }
2013
1993
  }
2014
1994
  function ae(n) {
2015
- const e = f.join(n, k, "overrides"), t = /* @__PURE__ */ new Map();
1995
+ const e = g.join(n, k, "overrides"), t = /* @__PURE__ */ new Map();
2016
1996
  if (!p.existsSync(e))
2017
1997
  return t;
2018
1998
  const s = O.sync("**/*.md", { cwd: e, absolute: !0 });
2019
1999
  for (const i of s) {
2020
- const r = f.basename(i, ".md"), o = p.readFileSync(i, "utf-8");
2000
+ const r = g.basename(i, ".md"), o = p.readFileSync(i, "utf-8");
2021
2001
  t.set(r, o);
2022
2002
  }
2023
2003
  return t;
@@ -2071,11 +2051,11 @@ function Ne(n, e) {
2071
2051
  return s;
2072
2052
  }
2073
2053
  function ze(n) {
2074
- const e = f.join(n, k);
2054
+ const e = g.join(n, k);
2075
2055
  return p.existsSync(e);
2076
2056
  }
2077
2057
  function Ge(n) {
2078
- const e = f.join(n, k), t = f.join(e, "overrides");
2058
+ const e = g.join(n, k), t = g.join(e, "overrides");
2079
2059
  p.mkdirSync(e, { recursive: !0 }), p.mkdirSync(t, { recursive: !0 });
2080
2060
  const s = {
2081
2061
  overrides: [
@@ -2101,8 +2081,8 @@ Your content here...`,
2101
2081
  }
2102
2082
  ],
2103
2083
  ignoreTags: ["unwanted-tag"]
2104
- }, i = f.join(e, I);
2105
- p.writeFileSync(i, JSON.stringify(s, null, 2)), p.writeFileSync(f.join(t, "example.md"), `# Example Override
2084
+ }, i = g.join(e, I);
2085
+ p.writeFileSync(i, JSON.stringify(s, null, 2)), p.writeFileSync(g.join(t, "example.md"), `# Example Override
2106
2086
 
2107
2087
  This file overrides the default instructions for this tag.
2108
2088
  Create files like:
@@ -2187,7 +2167,7 @@ const de = M(import.meta.url);
2187
2167
  L(de);
2188
2168
  export {
2189
2169
  A as BUILT_IN_CONFIG,
2190
- Ee as CodeOwnersPlugin,
2170
+ xe as CodeOwnersPlugin,
2191
2171
  T as DEFAULT_AI_REFINEMENT,
2192
2172
  Te as DockerPlugin,
2193
2173
  $e as GitHubActionsPlugin,
@@ -2196,7 +2176,7 @@ export {
2196
2176
  te as INSTRUCTION_ELEMENTS,
2197
2177
  Le as MonorepoPlugin,
2198
2178
  Me as PHPPlugin,
2199
- E as PluginLoader,
2179
+ x as PluginLoader,
2200
2180
  b as PluginRegistry,
2201
2181
  ie as PluginRegistryOld,
2202
2182
  Oe as PythonPlugin,
@@ -2205,7 +2185,7 @@ export {
2205
2185
  We as TemplateLoader,
2206
2186
  He as analyzeBestVariant,
2207
2187
  ye as analyzeProjectTags,
2208
- xe as analyzeWithPlugins,
2188
+ je as analyzeWithPlugins,
2209
2189
  le as applyCombiner,
2210
2190
  Ne as applyMetaInstructions,
2211
2191
  ce as applyOverrides,
@@ -2229,7 +2209,7 @@ export {
2229
2209
  Ce as passesQualityThreshold,
2230
2210
  h as pluginRegistry,
2231
2211
  we as refineInstructions,
2232
- je as registerBuiltInPlugins,
2212
+ Ee as registerBuiltInPlugins,
2233
2213
  K as selectPatterns,
2234
2214
  Ue as trackABTest,
2235
2215
  $ as validateInstructions