@el-j/magic-helix-core 4.0.0-beta.2 → 4.0.0-beta.4
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-B88j4AyE.js +13 -0
- package/dist/index-B88j4AyE.js.map +1 -0
- package/dist/index-CY-pQbuu.cjs +2 -0
- package/dist/index-CY-pQbuu.cjs.map +1 -0
- package/dist/index.cjs +75 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +2214 -51
- package/dist/index.mjs.map +1 -1
- package/dist/pattern-combiner.d.ts +1 -1
- package/dist/plugin-loader.d.ts +2 -1
- package/package.json +4 -4
- package/dist/BasePlugin-6wv0hYJ9.js +0 -98
- package/dist/BasePlugin-6wv0hYJ9.js.map +0 -1
- package/dist/BasePlugin-odQJAKA-.cjs +0 -2
- package/dist/BasePlugin-odQJAKA-.cjs.map +0 -1
- package/dist/builtin-plugins/base/BasePlugin.d.ts +0 -69
- package/dist/builtin-plugins/cpp/index.d.ts +0 -46
- package/dist/builtin-plugins/csharp/index.d.ts +0 -20
- package/dist/builtin-plugins/go/index.d.ts +0 -23
- package/dist/builtin-plugins/index.d.ts +0 -16
- package/dist/builtin-plugins/java/index.d.ts +0 -22
- package/dist/builtin-plugins/nodejs/index.d.ts +0 -44
- package/dist/builtin-plugins/php/index.d.ts +0 -20
- package/dist/builtin-plugins/python/index.d.ts +0 -27
- package/dist/builtin-plugins/ruby/index.d.ts +0 -20
- package/dist/builtin-plugins/rust/index.d.ts +0 -53
- package/dist/builtin-plugins/swift/index.d.ts +0 -22
- package/dist/default_templates/angular/angular-core.md +0 -19
- package/dist/default_templates/architecture/codeowners.md +0 -123
- package/dist/default_templates/architecture/monorepo.md +0 -146
- package/dist/default_templates/architecture/nx.md +0 -122
- package/dist/default_templates/architecture/turborepo.md +0 -114
- package/dist/default_templates/ci/github-actions.md +0 -268
- package/dist/default_templates/ci/gitlab-ci.md +0 -330
- package/dist/default_templates/containers/docker-multistage.md +0 -120
- package/dist/default_templates/containers/kubernetes-deploy.md +0 -210
- package/dist/default_templates/devops/docker-compose.md +0 -111
- package/dist/default_templates/devops/docker-dockerfile.md +0 -94
- package/dist/default_templates/devops/github-actions.md +0 -160
- package/dist/default_templates/devops/gitlab-ci.md +0 -210
- package/dist/default_templates/dotnet/framework-aspnetcore.md +0 -205
- package/dist/default_templates/dotnet/framework-blazor.md +0 -271
- package/dist/default_templates/dotnet/lang-csharp.md +0 -162
- package/dist/default_templates/generic/lang-typescript.md +0 -57
- package/dist/default_templates/generic/state-redux.md +0 -21
- package/dist/default_templates/generic/state-rxjs.md +0 -6
- package/dist/default_templates/generic/style-mui.md +0 -23
- package/dist/default_templates/generic/style-tailwind.md +0 -76
- package/dist/default_templates/generic/test-cypress.md +0 -21
- package/dist/default_templates/generic/test-jest.md +0 -20
- package/dist/default_templates/generic/test-playwright.md +0 -21
- package/dist/default_templates/generic/test-vitest.md +0 -131
- package/dist/default_templates/go/lang-go.md +0 -571
- package/dist/default_templates/java/build-gradle.md +0 -102
- package/dist/default_templates/java/build-maven.md +0 -86
- package/dist/default_templates/java/framework-spring-boot.md +0 -179
- package/dist/default_templates/java/lang-java.md +0 -78
- package/dist/default_templates/java/lang-kotlin.md +0 -88
- package/dist/default_templates/meta/magic-helix-meta.md +0 -213
- package/dist/default_templates/meta/meta-debug.md +0 -459
- package/dist/default_templates/meta/meta-implement.md +0 -450
- package/dist/default_templates/meta/meta-roadmap.md +0 -265
- package/dist/default_templates/nestjs/nestjs-core.md +0 -7
- package/dist/default_templates/patterns/architecture/clean-architecture.md +0 -469
- package/dist/default_templates/patterns/architecture/dependency-injection.md +0 -517
- package/dist/default_templates/patterns/architecture/domain-driven-design.md +0 -621
- package/dist/default_templates/patterns/architecture/layered-architecture.md +0 -382
- package/dist/default_templates/patterns/architecture/repository-pattern.md +0 -408
- package/dist/default_templates/patterns/domain-expertise/nextjs-rules.md +0 -115
- package/dist/default_templates/patterns/domain-expertise/react-patterns.md +0 -181
- package/dist/default_templates/patterns/domain-expertise/server-components.md +0 -212
- package/dist/default_templates/patterns/domain-expertise/shadcn-ui.md +0 -52
- package/dist/default_templates/patterns/domain-expertise/tailwind-patterns.md +0 -52
- package/dist/default_templates/patterns/environment/container-awareness.md +0 -17
- package/dist/default_templates/patterns/environment/ide-features.md +0 -17
- package/dist/default_templates/patterns/environment/os-commands.md +0 -17
- package/dist/default_templates/patterns/organization/heading-hierarchy.md +0 -103
- package/dist/default_templates/patterns/organization/sequential-workflows.md +0 -102
- package/dist/default_templates/patterns/organization/xml-rule-groups.md +0 -64
- package/dist/default_templates/patterns/reasoning/agent-loop.md +0 -151
- package/dist/default_templates/patterns/reasoning/confirmation-gates.md +0 -141
- package/dist/default_templates/patterns/reasoning/dependency-analysis.md +0 -132
- package/dist/default_templates/patterns/reasoning/one-tool-per-iteration.md +0 -152
- package/dist/default_templates/patterns/reasoning/preview-before-action.md +0 -194
- package/dist/default_templates/patterns/reasoning/reflection-checkpoints.md +0 -166
- package/dist/default_templates/patterns/reasoning/result-verification.md +0 -157
- package/dist/default_templates/patterns/reasoning/subtask-breakdown.md +0 -131
- package/dist/default_templates/patterns/reasoning/thinking-tags.md +0 -100
- package/dist/default_templates/patterns/role-definition/capability-declarations.md +0 -72
- package/dist/default_templates/patterns/role-definition/expert-identity.md +0 -45
- package/dist/default_templates/patterns/role-definition/scope-boundaries.md +0 -61
- package/dist/default_templates/patterns/safety/code-safety-rules.md +0 -17
- package/dist/default_templates/patterns/safety/credential-handling.md +0 -17
- package/dist/default_templates/patterns/safety/destructive-warnings.md +0 -17
- package/dist/default_templates/patterns/safety/refusal-messages.md +0 -17
- package/dist/default_templates/patterns/tone/adaptive-tone.md +0 -17
- package/dist/default_templates/patterns/tone/concise-communication.md +0 -17
- package/dist/default_templates/patterns/tone/forbidden-phrases.md +0 -17
- package/dist/default_templates/patterns/tool-guidelines/function-schemas.md +0 -143
- package/dist/default_templates/patterns/tool-guidelines/parameter-examples.md +0 -137
- package/dist/default_templates/patterns/tool-guidelines/usage-policies.md +0 -105
- package/dist/default_templates/php/framework-laravel.md +0 -112
- package/dist/default_templates/php/lang-php.md +0 -94
- package/dist/default_templates/python/lang-python.md +0 -508
- package/dist/default_templates/react/react-core.md +0 -677
- package/dist/default_templates/react/react-zustand.md +0 -7
- package/dist/default_templates/ruby/framework-rails.md +0 -309
- package/dist/default_templates/ruby/framework-sinatra.md +0 -227
- package/dist/default_templates/ruby/lang-ruby.md +0 -216
- package/dist/default_templates/rust/lang-rust.md +0 -89
- package/dist/default_templates/swift/framework-vapor.md +0 -352
- package/dist/default_templates/swift/lang-swift.md +0 -291
- package/dist/default_templates/vue/style-primevue.md +0 -6
- package/dist/default_templates/vue/style-quasar.md +0 -22
- package/dist/default_templates/vue/vue-core.md +0 -108
- package/dist/default_templates/vue/vue-pinia.md +0 -5
- package/dist/index-0GK4RlUx.js +0 -1748
- package/dist/index-0GK4RlUx.js.map +0 -1
- package/dist/index-AkVwRl-r.js +0 -92
- package/dist/index-AkVwRl-r.js.map +0 -1
- package/dist/index-B6BeG1yT.cjs +0 -68
- package/dist/index-B6BeG1yT.cjs.map +0 -1
- package/dist/index-B8pyjKdF.js +0 -94
- package/dist/index-B8pyjKdF.js.map +0 -1
- package/dist/index-BQ6v041y.js +0 -13
- package/dist/index-BQ6v041y.js.map +0 -1
- package/dist/index-Baxb1vI_.js +0 -210
- package/dist/index-Baxb1vI_.js.map +0 -1
- package/dist/index-Bg8DD8ku.js +0 -216
- package/dist/index-Bg8DD8ku.js.map +0 -1
- package/dist/index-BqTqxCpG.cjs +0 -89
- package/dist/index-BqTqxCpG.cjs.map +0 -1
- package/dist/index-Bv4Q1Pr7.cjs +0 -33
- package/dist/index-Bv4Q1Pr7.cjs.map +0 -1
- package/dist/index-CN8J45Nc.cjs +0 -24
- package/dist/index-CN8J45Nc.cjs.map +0 -1
- package/dist/index-CPbv2Od1.js +0 -62
- package/dist/index-CPbv2Od1.js.map +0 -1
- package/dist/index-Cf-MC6Al.js +0 -63
- package/dist/index-Cf-MC6Al.js.map +0 -1
- package/dist/index-DDPXXXDy.cjs +0 -19
- package/dist/index-DDPXXXDy.cjs.map +0 -1
- package/dist/index-DO30AzDe.cjs +0 -19
- package/dist/index-DO30AzDe.cjs.map +0 -1
- package/dist/index-DkvW5yBY.js +0 -2249
- package/dist/index-DkvW5yBY.js.map +0 -1
- package/dist/index-Dn1ehjIj.cjs +0 -80
- package/dist/index-Dn1ehjIj.cjs.map +0 -1
- package/dist/index-DqHvgoXJ.cjs +0 -19
- package/dist/index-DqHvgoXJ.cjs.map +0 -1
- package/dist/index-K39pdw94.cjs +0 -31
- package/dist/index-K39pdw94.cjs.map +0 -1
- package/dist/index-OT2XAJkc.js +0 -117
- package/dist/index-OT2XAJkc.js.map +0 -1
- package/dist/index-TPAX4XKg.cjs +0 -30
- package/dist/index-TPAX4XKg.cjs.map +0 -1
- package/dist/index-WmVSB57y.js +0 -107
- package/dist/index-WmVSB57y.js.map +0 -1
- package/dist/index-mYXvc3Fs.js +0 -68
- package/dist/index-mYXvc3Fs.js.map +0 -1
- package/dist/index-nioXOg4m.cjs +0 -76
- package/dist/index-nioXOg4m.cjs.map +0 -1
- package/dist/index-okhY3fWD.cjs +0 -2
- package/dist/index-okhY3fWD.cjs.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CodeOwnersPlugin as P, DockerPlugin as u, GitHubActionsPlugin as g, GitLabCIPlugin as l, GolangPlugin as o, MonorepoPlugin as t, PHPPlugin as e, PythonPlugin as r, RustPlugin as s } from "./index.mjs";
|
|
2
|
+
export {
|
|
3
|
+
P as CodeOwnersPlugin,
|
|
4
|
+
u as DockerPlugin,
|
|
5
|
+
g as GitHubActionsPlugin,
|
|
6
|
+
l as GitLabCIPlugin,
|
|
7
|
+
o as GolangPlugin,
|
|
8
|
+
t as MonorepoPlugin,
|
|
9
|
+
e as PHPPlugin,
|
|
10
|
+
r as PythonPlugin,
|
|
11
|
+
s as RustPlugin
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index-B88j4AyE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B88j4AyE.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index.cjs");exports.CodeOwnersPlugin=n.CodeOwnersPlugin;exports.DockerPlugin=n.DockerPlugin;exports.GitHubActionsPlugin=n.GitHubActionsPlugin;exports.GitLabCIPlugin=n.GitLabCIPlugin;exports.GolangPlugin=n.GolangPlugin;exports.MonorepoPlugin=n.MonorepoPlugin;exports.PHPPlugin=n.PHPPlugin;exports.PythonPlugin=n.PythonPlugin;exports.RustPlugin=n.RustPlugin;
|
|
2
|
+
//# sourceMappingURL=index-CY-pQbuu.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CY-pQbuu.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,76 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("node:path")
|
|
1
|
+
"use strict";var Q=Object.create;var I=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var te=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of K(e))!ee.call(n,i)&&i!==t&&I(n,i,{get:()=>e[i],enumerable:!(s=X(e,i))||s.enumerable});return n};var $=(n,e,t)=>(t=n!=null?Q(Z(n)):{},te(e||!n||!n.__esModule?I(t,"default",{value:n,enumerable:!0}):t,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("node:path"),se=require("node:url"),j=require("node:fs"),P=require("picocolors"),ne=require("glob");var F=typeof document<"u"?document.currentScript:null;function M(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const f=M(b),p=M(j);function ie(n){if(n==="src/**/*.ts")return/^src\/.*\.ts$/;if(n==="src/**/*.vue")return/^src\/.*\.vue$/;const e=n.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(`^${e.replace(/[.+^${}()|[\]\\]/g,"\\$&")}$`)}function re(n,e){const t=ie(e);return n.some(s=>t.test(s))}function oe(n,e,t,s){const i=new Set;for(const[r,o]of Object.entries(n.dependencies))e[r]&&i.add(e[r]);for(const r of n.configFiles)t[r]&&i.add(t[r]);for(const r in s){const o=s[r];re(n.projectFiles,r)&&i.add(o)}return i}const O={target:"github-copilot",templateDirectory:"ai_templates",outputDirectory:".github/instructions",aiRefinement:{quality:"standard",contextLevel:"balanced",outputFormat:"markdown",tokenBudget:4e3,includeExamples:!0,includeBestPractices:!0},dependencyTagMap:{vue:"framework-vue",react:"framework-react","@angular/core":"framework-angular","@nestjs/core":"framework-nestjs",tailwindcss:"style-tailwind",primevue:"style-primevue","@mui/material":"style-mui",quasar:"style-quasar",vitest:"test-vitest",jest:"test-jest",cypress:"test-cypress",playwright:"test-playwright",rxjs:"state-rxjs",pinia:"state-pinia",redux:"state-redux",zustand:"state-zustand"},configFileTagMap:{"tailwind.config.js":"style-tailwind","tailwind.config.ts":"style-tailwind","vite.config.ts":"build-vite","vite.config.js":"build-vite"},fileGlobTagMap:{},tagTemplateMap:{"framework-vue":[{template:"vue/vue-core.md",suffix:"vue.instructions.md"}],"state-pinia":[{template:"vue/vue-pinia.md",suffix:"vue-pinia.instructions.md"}],"style-primevue":[{template:"vue/style-primevue.md",suffix:"vue-primevue.instructions.md"}],"style-quasar":[{template:"vue/style-quasar.md",suffix:"vue-quasar.instructions.md"}],"framework-react":[{template:"react/react-core.md",suffix:"react.instructions.md"}],"state-zustand":[{template:"react/react-zustand.md",suffix:"react-zustand.instructions.md"}],"framework-nestjs":[{template:"nestjs/nestjs-core.md",suffix:"nestjs.instructions.md"}],"framework-angular":[{template:"angular/angular-core.md",suffix:"angular.instructions.md"}],"style-tailwind":[{template:"generic/style-tailwind.md",suffix:"tailwind.instructions.md"}],"style-mui":[{template:"generic/style-mui.md",suffix:"mui.instructions.md"}],"test-vitest":[{template:"generic/test-vitest.md",suffix:"vitest.instructions.md"}],"test-jest":[{template:"generic/test-jest.md",suffix:"jest.instructions.md"}],"test-cypress":[{template:"generic/test-cypress.md",suffix:"cypress.instructions.md"}],"test-playwright":[{template:"generic/test-playwright.md",suffix:"playwright.instructions.md"}]}},E={quality:"standard",contextLevel:"balanced",outputFormat:"markdown",tokenBudget:4e3,includeExamples:!0,includeBestPractices:!0};function ae(n,e){const t={...E,...e};let s=n;return s=ue(s,t.outputFormat),s=ce(s,t.quality),s=le(s,t.contextLevel),t.includeExamples||(s=de(s)),t.includeBestPractices||(s=ge(s)),s=fe(s,t.tokenBudget),s}function ce(n,e){switch(e){case"basic":return n.split(/\n(?=##? )/).filter(s=>{s.toLowerCase();const i=s.split(`
|
|
2
|
+
`)[0].toLowerCase();return i.includes("# ")||i.includes("overview")||i.includes("basic")||i.includes("essential")}).join(`
|
|
3
|
+
`);case"comprehensive":return n;default:return n.split(/\n(?=##? )/).filter(s=>{const i=s.split(`
|
|
4
|
+
`)[0].toLowerCase();return!i.includes("advanced")&&!i.includes("deep dive")}).join(`
|
|
5
|
+
`)}}function le(n,e){switch(e){case"minimal":return n.split(/\n(?=##? )/).filter(s=>{const i=s.split(`
|
|
6
|
+
`)[0].toLowerCase();return!i.includes("background")&&!i.includes("why ")&&!i.includes("explanation")&&!i.includes("deep dive")}).join(`
|
|
7
|
+
`);case"extensive":return n;default:return n.split(`
|
|
8
|
+
`).filter(t=>t.startsWith("#")||t.startsWith("-")||t.startsWith("*")||t.match(/^\d+\./)||t.startsWith("```")||t.startsWith(" ")||t.trim().length===0||t.trim().length<200).join(`
|
|
9
|
+
`)}}function ue(n,e){switch(e){case"structured":return n.replace(/^### /gm,"#### ").replace(/^## /gm,"### ").replace(/^# /gm,"## ");case"conversational":return n.replace(/^- (.+)$/gm,(t,s)=>`${s}.`).replace(/\n{3,}/g,`
|
|
10
|
+
|
|
11
|
+
`);case"code-focused":{const t=n.split(`
|
|
12
|
+
`);let s=!1;return t.filter(i=>i.startsWith("```")?(s=!s,!0):s||i.startsWith("#")||i.trim().length===0?!0:i.match(/^[^.]+\./)).join(`
|
|
13
|
+
`)}default:return n}}function de(n){let e="",t=!1,s=!1;for(const i of n.split(`
|
|
14
|
+
`)){if(i.startsWith("```")){t=!t;continue}if(!t){if(i.match(/^##+ .*example/i)){s=!0;continue}i.startsWith("##")&&(s=!1)}!t&&!s&&(e+=`${i}
|
|
15
|
+
`)}return e}function ge(n){return n.split(`
|
|
16
|
+
`).filter(e=>{const t=e.toLowerCase();return!(t.match(/^##+ .*best practice/i)||t.match(/^##+ .*recommendation/i)||t.match(/^##+ .*tip/i))}).join(`
|
|
17
|
+
`)}function fe(n,e){const t=e*4;if(n.length<=t)return n;const s=n.substring(0,t),i=s.lastIndexOf(`
|
|
18
|
+
## `);return i>t*.7?`${s.substring(0,i)}
|
|
19
|
+
|
|
20
|
+
<!-- Content truncated to fit token budget -->`:`${s}
|
|
21
|
+
|
|
22
|
+
<!-- Content truncated to fit token budget -->`}function pe(n){return Math.ceil(n.length/4)}const D="magic-helix.config.json",me=["ai-aligner.config.json"];function he(n){const t=(n?[f.resolve(process.cwd(),n)]:[f.resolve(process.cwd(),D),...me.map(s=>f.resolve(process.cwd(),s))]).find((s,i)=>{const r=p.existsSync(s);return!n&&r&&i>0&&console.warn(P.yellow(` Detected legacy config file ${f.basename(s)}. Please rename it to ${D}.`)),r});if(!t)return console.log(P.gray(" No user config file found. Using built-in conventions only.")),{};try{return console.log(P.blue(" User config file found. Merging with built-in conventions.")),JSON.parse(p.readFileSync(t,"utf-8"))}catch(s){return console.error(P.red(`❌ Error parsing config file: ${s.message}`)),console.warn(P.yellow(" Please fix the JSON or remove the file. Using built-in conventions only.")),{}}}function ye(n){const e=O,t=we(n.outputDirectory??e.outputDirectory);return{target:n.target||e.target,templateDirectory:n.templateDirectory??e.templateDirectory,outputDirectory:t,dependencyTagMap:{...e.dependencyTagMap,...n.dependencyTagMap||{}},configFileTagMap:{...e.configFileTagMap,...n.configFileTagMap||{}},fileGlobTagMap:{...e.fileGlobTagMap,...n.fileGlobTagMap||{}},tagTemplateMap:{...e.tagTemplateMap,...n.tagTemplateMap||{}},aiRefinement:{...E,...n.aiRefinement||{}}}}function we(n){const e=n.trim();if(e.endsWith(".github/instruction")||/\binstruction\/?$/.test(e)){const t=e.replace(/instruction\/?$/,"instructions");return console.warn(P.yellow(` Normalized outputDirectory from "${e}" to "${t}". Using ".github/instructions" as the default convention.`)),t}return e}class L{format(e,t,s){return e}getFileExtension(){return".md"}getFrontmatter(e,t){return`---
|
|
23
|
+
applyTo: "${e}"
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
`}}class ve{format(e,t,s){return e.replace(/- \*\*([^*]+)\*\*/g,"- **$1** (important)")}getFileExtension(){return".md"}getFrontmatter(e,t){return`---
|
|
27
|
+
applyTo: "${e}"
|
|
28
|
+
assistant: claude
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
`}}class Pe{format(e,t,s){return e.replace(/- \*\*ALWAYS\*\*/g,"- 🔴").replace(/- \*\*NEVER\*\*/g,"- ❌")}getFileExtension(){return".md"}getFrontmatter(e,t){return`---
|
|
32
|
+
applyTo: "${e}"
|
|
33
|
+
context: chat
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
`}}class be{format(e,t,s){return e}getFileExtension(){return".md"}getFrontmatter(e,t){return`---
|
|
37
|
+
applyTo: "${e}"
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
`}}function Ce(n){switch(n){case"github-copilot":return new L;case"claude":return new ve;case"copilot-chat":return new Pe;case"generic":return new be;default:return new L}}const v={};function R(){const n=require.resolve("@el-j/magic-helix-plugins"),e=v.dirname(n),t=v.join(e,"patterns"),s=new Map,i=["role-definition","organization","tool-guidelines","reasoning","domain-expertise","safety","tone","environment"];for(const r of i){const o=v.join(t,r);if(!v.existsSync(o))continue;const a=v.readdirSync(o).filter(c=>c.endsWith(".md"));for(const c of a){const l=c.replace(".md",""),u=v.readFileSync(v.join(o,c),"utf-8");s.set(l,{name:l,category:r,content:u,priority:ke(r)})}}return s}function ke(n){return{"role-definition":1,organization:2,"tool-guidelines":3,reasoning:4,"domain-expertise":5,environment:6,tone:7,safety:8}[n]}function _(n,e){const t=[],s=n.get("expert-identity"),i=n.get("scope-boundaries");s&&t.push(s),i&&t.push(i);const r=n.get("heading-hierarchy");r&&t.push(r);const o=n.get("function-schemas"),a=n.get("usage-policies");if(o&&t.push(o),a&&t.push(a),e.framework==="react"||e.framework==="vue"){const u=n.get("react-patterns");u&&t.push(u)}if(e.libraries){if(e.libraries.includes("tailwind")){const u=n.get("tailwind-patterns");u&&t.push(u)}if(e.libraries.includes("shadcn-ui")){const u=n.get("shadcn-ui");u&&t.push(u)}}if(e.aiModel==="claude"){const u=n.get("thinking-tags"),d=n.get("concise-communication");u&&t.push(u),d&&t.push(d)}if(e.tone==="concise"){const u=n.get("concise-communication"),d=n.get("forbidden-phrases");u&&t.push(u),d&&t.push(d)}if(e.environment==="vscode"){const u=n.get("ide-features");u&&t.push(u)}const c=n.get("refusal-messages"),l=n.get("destructive-warnings");if(c&&t.push(c),l&&t.push(l),e.includePatterns)for(const u of e.includePatterns){const d=n.get(u);d&&!t.includes(d)&&t.push(d)}return e.excludePatterns?t.filter(u=>!e.excludePatterns?.includes(u.name)):t}function A(n){const e=n.sort((g,m)=>g.priority-m.priority),t=[],s=new Map;for(const g of e){s.has(g.category)||s.set(g.category,[]);const m=s.get(g.category);m&&m.push(g)}t.push(`# AI Agent Instructions
|
|
41
|
+
`);const i=s.get("role-definition");if(i){t.push(`## Role & Identity
|
|
42
|
+
`);for(const g of i)t.push(w(g.content))}const r=s.get("organization");if(r){t.push(`## Instruction Structure
|
|
43
|
+
`);for(const g of r)t.push(w(g.content))}const o=s.get("tool-guidelines");if(o){t.push(`## Tool Usage Guidelines
|
|
44
|
+
`);for(const g of o)t.push(w(g.content))}const a=s.get("reasoning");if(a){t.push(`## Reasoning & Execution Patterns
|
|
45
|
+
`);for(const g of a)t.push(w(g.content))}const c=s.get("domain-expertise");if(c){t.push(`## Domain-Specific Guidelines
|
|
46
|
+
`);for(const g of c)t.push(w(g.content))}const l=s.get("environment");if(l){t.push(`## Environment Context
|
|
47
|
+
`);for(const g of l)t.push(w(g.content))}const u=s.get("tone");if(u){t.push(`## Communication Style
|
|
48
|
+
`);for(const g of u)t.push(w(g.content))}const d=s.get("safety");if(d){t.push(`## Safety & Refusal Protocols
|
|
49
|
+
`);for(const g of d)t.push(w(g.content))}return t.join(`
|
|
50
|
+
|
|
51
|
+
`)}function w(n){let e=n.replace(/^# .+ Pattern\n+/,"");const t=e.match(/## Examples\n([\s\S]+?)(?=\n## |\n---|Z)/);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())}function N(n){const e=R(),t=_(e,n);return A(t)}const W=[{name:"Expert Identity",weight:1,required:!0,check:n=>/you are (an?|the) .+? (expert|specialist|assistant)/i.test(n)},{name:"Capability Declarations",weight:.8,required:!0,check:n=>/you (can|excel at|have expertise in)/i.test(n)},{name:"Scope Boundaries",weight:.7,required:!1,check:n=>/you (will not|won't|cannot|must not)/i.test(n)},{name:"Clear Headings",weight:.9,required:!0,check:n=>(n.match(/^##? /gm)||[]).length>=3},{name:"Structured Sections",weight:.8,required:!1,check:n=>/<rules>|<thinking>|```xml/i.test(n)||(n.match(/^###? /gm)||[]).length>=5},{name:"Tool Documentation",weight:1,required:!0,check:n=>/tool|function|command|api/i.test(n)&&/parameter|argument|input/i.test(n)},{name:"Tool Usage Policies",weight:.9,required:!0,check:n=>/when to use|when not to use|prefer|avoid/i.test(n)},{name:"Concrete Examples",weight:.8,required:!0,check:n=>(n.match(/```[\s\S]+?```/g)||[]).length>=2},{name:"Step-by-Step Process",weight:.7,required:!1,check:n=>/^\d+\. /gm.test(n)||/first|then|next|finally/i.test(n)},{name:"Thinking/Planning Phase",weight:.6,required:!1,check:n=>/<thinking>|before .+?, (think|plan|analyze)/i.test(n)},{name:"Confirmation Gates",weight:.8,required:!1,check:n=>/confirmation|preview|show .+? before|ask .+? before/i.test(n)},{name:"Refusal Guidelines",weight:1,required:!0,check:n=>/refuse|decline|cannot (assist|help) with|inappropriate/i.test(n)},{name:"Destructive Action Warnings",weight:.9,required:!1,check:n=>/warning|caution|delete|remove|overwrite/i.test(n)},{name:"Communication Style",weight:.5,required:!1,check:n=>/concise|brief|direct|friendly|professional|tone/i.test(n)},{name:"Forbidden Phrases",weight:.4,required:!1,check:n=>/do not (say|use|start with)|avoid (saying|phrases like)/i.test(n)}];function x(n){const e=W.map(d=>({element:d,passed:d.check(n)})),t=e.filter(d=>["Clear Headings","Structured Sections"].includes(d.element.name)),s=S(t),i=e.filter(d=>["Concrete Examples","Communication Style","Forbidden Phrases"].includes(d.element.name)),r=S(i),o=e.filter(d=>d.element.required),a=S(o),c=Math.round(s*.3+r*.2+a*.5),l=e.filter(d=>d.element.required&&!d.passed).map(d=>d.element.name),u=Fe(e,n);return{overallScore:c,structureScore:s,clarityScore:r,completenessScore:a,recommendations:u,missingElements:l}}function S(n){if(n.length===0)return 100;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);return Math.round(t/e*100)}function Fe(n,e){const t=[],s=n.filter(a=>a.element.required&&!a.passed);s.length>0&&t.push(`Add ${s.length} critical element(s): ${s.map(a=>a.element.name).join(", ")}`),n.find(a=>a.element.name==="Expert Identity")?.passed||t.push('Add expert identity: Start with "You are an expert [domain] specialist..."'),n.find(a=>a.element.name==="Tool Documentation")?.passed||t.push("Add tool documentation: Include function schemas with parameters and examples"),n.find(a=>a.element.name==="Refusal Guidelines")?.passed||t.push("Add refusal guidelines: Specify what requests should be declined and how");const i=(e.match(/```[\s\S]+?```/g)||[]).length;i<3&&t.push(`Add more code examples: Currently ${i}, aim for at least 5 concrete examples`),/✅|❌|good:|bad:/i.test(e)||t.push("Add ✅/❌ comparisons: Show good vs bad examples for clarity");const o=e.split(/\s+/).length;return o<500?t.push(`Instructions may be too brief (${o} words). Aim for 1000-3000 words for comprehensive guidance.`):o>5e3&&t.push(`Instructions may be too long (${o} words). Consider breaking into sections or modules.`),n.find(a=>a.element.name==="Confirmation Gates")?.passed||t.push("Consider adding confirmation gates for destructive operations (delete, overwrite)"),t.length===0&&t.push("Instructions meet quality standards. Consider A/B testing variants for optimization."),t}function Se(n,e=70){return x(n).overallScore>=e}function z(n){return n>=90?"A":n>=80?"B":n>=70?"C":n>=60?"D":"F"}function je(n){const e=[];if(e.push(`=== Instruction Quality Report ===
|
|
52
|
+
`),e.push(`Overall Score: ${n.overallScore}/100 (${z(n.overallScore)})
|
|
53
|
+
`),e.push(` Structure: ${n.structureScore}/100`),e.push(` Clarity: ${n.clarityScore}/100`),e.push(` Completeness: ${n.completenessScore}/100
|
|
54
|
+
`),n.missingElements.length>0){e.push("❌ Missing Critical Elements:");for(const t of n.missingElements)e.push(` - ${t}`);e.push("")}if(n.recommendations.length>0){e.push("💡 Recommendations:");for(const t of n.recommendations)e.push(` - ${t}`);e.push("")}return e.join(`
|
|
55
|
+
`)}let G=class{constructor(){this.plugins=new Map}register(e){this.plugins.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),this.plugins.set(e.name,e)}unregister(e){return this.plugins.delete(e)}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}clear(){this.plugins.clear()}get size(){return this.plugins.size}};const h=new G;class Te{constructor(e,t=new Map){this.analysisData=e,this.fileContentCache=t}get files(){return this.analysisData.projectFiles}get dependencies(){return this.analysisData.dependencies}get configFiles(){return this.analysisData.configFiles}getTextFile(e){return this.fileContentCache.has(e)&&this.fileContentCache.get(e)||null}hasFile(e){return this.analysisData.projectFiles.includes(e)||this.analysisData.configFiles.includes(e)}matchesPattern(e){const t=this.globToRegex(e);return this.analysisData.projectFiles.some(s=>t.test(s))}globToRegex(e){const t=e.replace(/\\/g,"\\\\").replace(/\*\*/g,"§DOUBLESTAR§").replace(/\*/g,"[^/]*").replace(/§DOUBLESTAR§/g,".*").replace(/\./g,"\\.");return new RegExp(`^${t}$`)}}async function Ee(n,e){const t=new Set,s=[],i=new Map,r=new Map;if(e)for(const c of n.configFiles){const l=e(c);l&&r.set(c,l)}const o=new Te(n,r);if(e){const c=o.getTextFile.bind(o);o.getTextFile=l=>{const u=c(l);return u!==null?u:e(l)}}const a=h.getAll();for(const c of a)try{const l=await Promise.resolve(c.detect(o));if(l.detected){if(l.tags)for(const d of l.tags)t.add(d);l.metadata&&i.set(c.name,l.metadata);const u=await Promise.resolve(c.generateInstructions(o,l.metadata));s.push(...u)}}catch(l){console.error(`Error running plugin ${c.name}:`,l)}return{tags:t,instructions:s,metadata:i}}function xe(){Promise.resolve().then(()=>require("./index-CY-pQbuu.cjs")).then(n=>{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)})}class Ie{constructor(){this.name="codeowners",this.description="Detects CODEOWNERS file and provides code ownership instructions",this.version="1.0.0"}detect(e){if(!(e.hasFile(".github/CODEOWNERS")||e.hasFile("CODEOWNERS")||e.hasFile("docs/CODEOWNERS")))return{detected:!1};const s={hasCodeOwners:!0};let i="";e.hasFile(".github/CODEOWNERS")?i=".github/CODEOWNERS":e.hasFile("CODEOWNERS")?i="CODEOWNERS":i="docs/CODEOWNERS",s.location=i;const r=e.getTextFile(i);if(r){const a=r.split(`
|
|
56
|
+
`).filter(l=>l.trim()&&!l.trim().startsWith("#"));s.ruleCount=a.length;const c=new Set;for(const l of a){const u=l.trim().split(/\s+/);if(u.length>1)for(const d of u.slice(1))d.startsWith("@")&&c.add(d)}s.ownerCount=c.size,s.owners=Array.from(c).slice(0,10)}return{detected:!0,tags:["architecture-codeowners"],metadata:s}}generateInstructions(e,t){return[{template:"architecture/codeowners.md",suffix:"codeowners.md",targetFiles:[".github/CODEOWNERS","CODEOWNERS","docs/CODEOWNERS"]}]}}class $e{constructor(){this.name="docker",this.description="Detects Docker usage and provides Docker-specific instructions",this.version="1.0.0"}detect(e){const t=e.hasFile("Dockerfile")||e.matchesPattern("**/Dockerfile"),s=e.hasFile("docker-compose.yml")||e.hasFile("docker-compose.yaml")||e.hasFile("compose.yml")||e.hasFile("compose.yaml"),i=e.hasFile(".dockerignore");if(!(t||s))return{detected:!1};const o={hasDockerfile:t,hasDockerCompose:s,hasDockerignore:i};if(t){const a=e.getTextFile("Dockerfile");if(a){const c=(a.match(/FROM\s+\S+\s+AS\s+\S+/gi)||[]).length;c>0&&(o.multiStage=!0,o.stageCount=c)}}return{detected:!0,tags:["devops-docker"],metadata:o}}generateInstructions(e,t){const s=[];return t?.hasDockerfile&&s.push({template:"devops/docker-dockerfile.md",suffix:"docker-dockerfile.md",targetFiles:["**/Dockerfile"]}),t?.hasDockerCompose&&s.push({template:"devops/docker-compose.md",suffix:"docker-compose.md",targetFiles:["**/docker-compose.yml","**/docker-compose.yaml","**/compose.yml","**/compose.yaml"]}),s}}class De{constructor(){this.name="github-actions",this.description="Detects GitHub Actions workflows and provides CI/CD-specific instructions",this.version="1.0.0"}detect(e){if(!(e.matchesPattern(".github/workflows/*.yml")||e.matchesPattern(".github/workflows/*.yaml")))return{detected:!1};const s={hasWorkflows:!0},i=e.files.filter(r=>r.startsWith(".github/workflows/")&&(r.endsWith(".yml")||r.endsWith(".yaml")));if(i.length>0){s.workflowCount=i.length,s.workflowFiles=i;const r=e.getTextFile(i[0]);r&&(s.hasMatrixStrategy=r.includes("strategy:")&&r.includes("matrix:"),s.hasCaching=r.includes("actions/cache")||r.includes("cache:"),s.hasArtifacts=r.includes("actions/upload-artifact")||r.includes("actions/download-artifact"))}return{detected:!0,tags:["devops-github-actions","ci-cd"],metadata:s}}generateInstructions(e,t){return[{template:"devops/github-actions.md",suffix:"github-actions.md",targetFiles:[".github/workflows/*.yml",".github/workflows/*.yaml"]}]}}class Le{constructor(){this.name="gitlab-ci",this.description="Detects GitLab CI/CD configuration and provides CI/CD-specific instructions",this.version="1.0.0"}detect(e){if(!e.hasFile(".gitlab-ci.yml"))return{detected:!1};const s={hasGitLabCI:!0},i=e.getTextFile(".gitlab-ci.yml");if(i){i.match(/^stages:\s*$/m)&&(s.hasStages=!0),s.hasCache=i.includes("cache:"),s.hasArtifacts=i.includes("artifacts:"),s.hasServices=i.includes("services:"),s.hasIncludes=i.includes("include:");const o=i.match(/^stages:\s*\n((?: {2}- .+\n?)+)/m);if(o){const a=o[1].match(/- (.+)/g)?.map(c=>c.replace(/- /,"").trim());a&&(s.stages=a)}}return{detected:!0,tags:["devops-gitlab-ci","ci-cd"],metadata:s}}generateInstructions(e,t){return[{template:"devops/gitlab-ci.md",suffix:"gitlab-ci.md",targetFiles:[".gitlab-ci.yml"]}]}}class Me{constructor(){this.name="golang",this.description="Detects Go (Golang) projects and provides Go-specific instructions",this.version="1.0.0"}detect(e){const t=e.hasFile("go.mod"),s=e.matchesPattern("**/*.go");if(!(t||s))return{detected:!1};const r=e.getTextFile("go.mod"),o={hasGoMod:t,hasGoFiles:s};if(r){const a=r.match(/^module\s+(.+)$/m);a&&(o.moduleName=a[1].trim());const c=r.match(/^go\s+([\d.]+)$/m);c&&(o.goVersion=c[1])}return{detected:!0,tags:["lang-go"],metadata:o}}generateInstructions(e,t){return[{template:"go/lang-go.md",suffix:"lang-go.md",targetFiles:["**/*.go"]}]}}class Oe{constructor(){this.name="monorepo",this.description="Detects monorepo structures and provides monorepo-specific instructions",this.version="1.0.0"}detect(e){const t=e.hasFile("turbo.json"),s=e.hasFile("nx.json"),i=e.hasFile("pnpm-workspace.yaml"),r=e.hasFile("lerna.json"),o=e.hasFile("package.json")&&e.getTextFile("package.json")?.includes('"workspaces"');if(e.hasFile("package.json")&&e.getTextFile("package.json")?.includes('"workspaces"'),!(t||s||i||r||o))return{detected:!1};const c={hasTurbo:t,hasNx:s,hasPnpmWorkspace:i,hasLerna:r,hasYarnWorkspaces:o};if(t){c.tool="turborepo";const d=e.getTextFile("turbo.json");d&&(c.hasPipeline=d.includes('"pipeline"'))}else s?c.tool="nx":i?c.tool="pnpm":r?c.tool="lerna":c.tool="npm/yarn workspaces";const l=["packages/*/package.json","apps/*/package.json"],u=e.files.filter(d=>l.some(g=>new RegExp(g.replace(/\*/g,"[^/]+")).test(d)));return u.length>0&&(c.packageCount=u.length),{detected:!0,tags:["architecture-monorepo"],metadata:c}}generateInstructions(e,t){const s=[{template:"architecture/monorepo.md",suffix:"monorepo.md",targetFiles:["package.json","turbo.json","nx.json","pnpm-workspace.yaml","lerna.json"]}];return t?.tool==="turborepo"?s.push({template:"architecture/turborepo.md",suffix:"turborepo.md",targetFiles:["turbo.json"]}):t?.tool==="nx"&&s.push({template:"architecture/nx.md",suffix:"nx.md",targetFiles:["nx.json","workspace.json"]}),s}}class Re{constructor(){this.name="php",this.description="Detects PHP projects and provides PHP-specific instructions",this.version="1.0.0"}detect(e){const t=e.hasFile("composer.json"),s=e.hasFile("composer.lock"),i=e.matchesPattern("**/*.php");if(!(t||i))return{detected:!1};const o={hasComposerJson:t,hasComposerLock:s,hasPhpFiles:i},a=e.getTextFile("composer.json");if(a){a.includes('"laravel/framework"')?(o.framework="laravel",o.hasArtisan=e.hasFile("artisan")):a.includes('"symfony/')&&(o.framework="symfony");const c=a.match(/"name"\s*:\s*"([^"]+)"/);c&&(o.projectName=c[1])}return{detected:!0,tags:["lang-php"],metadata:o}}generateInstructions(e,t){const s=[{template:"php/lang-php.md",suffix:"lang-php.md",targetFiles:["**/*.php"]}];return t?.framework==="laravel"&&s.push({template:"php/framework-laravel.md",suffix:"framework-laravel.md",targetFiles:["**/*.php"]}),s}}class _e{constructor(){this.name="python",this.description="Detects Python projects and provides Python-specific instructions",this.version="1.0.0"}detect(e){const t=e.hasFile("pyproject.toml"),s=e.hasFile("requirements.txt"),i=e.hasFile("setup.py"),r=e.hasFile("Pipfile"),o=e.matchesPattern("**/*.py");if(!(t||s||i||r||o))return{detected:!1};const c={hasPyprojectToml:t,hasRequirementsTxt:s,hasSetupPy:i,hasPipfile:r,hasPyFiles:o};if(t){const d=e.getTextFile("pyproject.toml");d&&(d.includes("[tool.poetry]")?c.packageManager="poetry":d.includes("[build-system]")&&(c.packageManager="pip"))}else r?c.packageManager="pipenv":s&&(c.packageManager="pip");const l=[],u=e.getTextFile("requirements.txt");return u&&(u.includes("django")&&l.push("django"),u.includes("flask")&&l.push("flask"),u.includes("fastapi")&&l.push("fastapi")),l.length>0&&(c.frameworks=l),{detected:!0,tags:["lang-python"],metadata:c}}generateInstructions(e,t){return[{template:"python/lang-python.md",suffix:"lang-python.md",targetFiles:["**/*.py"]}]}}class Ae{constructor(){this.name="rust",this.description="Detects Rust projects and provides Rust-specific instructions",this.version="1.0.0"}detect(e){const t=e.hasFile("Cargo.toml"),s=e.hasFile("Cargo.lock"),i=e.matchesPattern("**/*.rs");if(!(t||i))return{detected:!1};const o=e.getTextFile("Cargo.toml"),a={hasCargoToml:t,hasCargoLock:s,hasRustFiles:i};if(o){const c=o.match(/^\[package\][\s\S]*?^name\s*=\s*"(.+?)"/m);c&&(a.packageName=c[1]);const l=o.match(/^edition\s*=\s*"(\d+)"/m);l&&(a.edition=l[1]),o.includes("[workspace]")&&(a.isWorkspace=!0)}return{detected:!0,tags:["lang-rust"],metadata:a}}generateInstructions(e,t){return[{template:"rust/lang-rust.md",suffix:"lang-rust.md",targetFiles:["**/*.rs"]}]}}class T{constructor(e={}){this.loadedPlugins=new Map,this.loadErrors=[],this.verbose=e.verbose??!1}async loadBuiltinPlugins(e){const t=[];try{const s=await this.tryImport("@el-j/magic-helix-plugins");if(!s)return t;const i=Object.entries(s).filter(([r,o])=>r!=="BasePlugin"&&typeof o=="function"&&r.endsWith("Plugin")).map(([r,o])=>o);for(const r of i){const o=new r;if(e&&!e.includes(o.name))continue;const a={plugin:o,source:{type:"npm",identifier:o.name,packageName:"@el-j/magic-helix-plugins"},loadTime:0};this.loadedPlugins.set(o.name,a),t.push(a),this.log(`Loaded built-in plugin: ${o.displayName} (${o.name})`)}}catch(s){this.handleLoadError({type:"npm",identifier:"@el-j/magic-helix-plugins",packageName:"@el-j/magic-helix-plugins"},s)}return t}async loadNpmPlugin(e){try{const t=Date.now(),s=await this.tryImport(e);if(!s)throw new Error(`Package "${e}" not found`);const i=s.default||s.Plugin||s;if(typeof i!="function")throw new Error(`Package "${e}" does not export a valid plugin class`);const r=new i,o=Date.now()-t;this.validatePlugin(r);const a={plugin:r,source:{type:"npm",identifier:e,packageName:e},loadTime:o};return this.loadedPlugins.set(r.name,a),this.log(`✓ Loaded npm plugin: ${r.displayName} from ${e} (${o}ms)`),a}catch(t){return this.handleLoadError({type:"npm",identifier:e,packageName:e},t),null}}async loadLocalPlugin(e){try{const t=f.resolve(e);if(!p.existsSync(t))throw new Error(`Plugin file not found: ${t}`);const s=Date.now(),i=await import(t),r=Date.now()-s,o=i.default||i.Plugin||i;if(typeof o!="function")throw new Error(`File "${e}" does not export a valid plugin class`);const a=new o;this.validatePlugin(a);const c={plugin:a,source:{type:"local",identifier:e,path:t},loadTime:r};return this.loadedPlugins.set(a.name,c),this.log(`✓ Loaded local plugin: ${a.displayName} from ${e} (${r}ms)`),c}catch(t){return this.handleLoadError({type:"local",identifier:e,path:e},t),null}}async loadWorkspacePlugins(e,t){const s=[],i=t||[".magic-helix/plugins/**/*.js",".magic-helix/plugins/**/*.mjs"];try{const{glob:r}=await import("glob");for(const o of i){const a=await r(o,{cwd:e,absolute:!0});for(const c of a){const l=await this.loadLocalPlugin(c);l&&(l.source.type="workspace",s.push(l))}}}catch(r){this.logWarning(`Error loading workspace plugins: ${r.message}`)}return s}getPlugin(e){return this.loadedPlugins.get(e)?.plugin}getAllPlugins(){return Array.from(this.loadedPlugins.values()).map(e=>e.plugin).sort((e,t)=>t.priority-e.priority)}getPluginsByNames(e){return e.map(t=>this.getPlugin(t)).filter(t=>t!==void 0)}async detectProject(e){const t=this.getAllPlugins();for(const s of t)try{this.log(`Trying plugin: ${s.displayName}`);const i=await s.detect(e);if(i)return this.log(`✓ Detected ${i.language} project with ${s.displayName}`),{metadata:i,plugin:s}}catch(i){this.logWarning(`Plugin ${s.name} detection failed: ${i.message}`)}return null}async scanForProjects(e,t=5){const s=new Set,i=new Set,r=["package.json","Cargo.toml","go.mod","go.sum","setup.py","pyproject.toml","requirements.txt","pom.xml","build.gradle","build.gradle.kts","Package.swift","Gemfile","composer.json","CMakeLists.txt","Makefile","platformio.ini"],o=new Set(["node_modules","target","dist","build",".git",".svn",".hg","vendor","__pycache__",".venv","venv","env",".cargo",".gradle"]),a=async(c,l)=>{if(l>t)return;const u=f.normalize(c);if(!i.has(u)){i.add(u);try{const d=await p.promises.readdir(c,{withFileTypes:!0});let g=!1;for(const m of d)if(!m.isDirectory()&&r.includes(m.name)){s.add(c),g=!0;break}for(const m of d)if(m.isDirectory()&&!o.has(m.name)){const Y=f.join(c,m.name);await a(Y,l+1)}}catch{return}}};return await a(e,0),Array.from(s).sort()}async detectAllProjects(e){const t=[],s=new Set,i=this.getAllPlugins();for(const r of i)try{const o=await r.detect(e);if(o&&(s.add(o.projectPath),t.push({metadata:o,plugin:r}),o.workspaceMembers&&o.workspaceMembers.length>0))for(const a of o.workspaceMembers){const c=f.resolve(e,a);if(!s.has(c)){const l=await this.detectProject(c);l&&(s.add(l.metadata.projectPath),t.push(l))}}}catch(o){this.logWarning(`Plugin ${r.name} failed: ${o.message}`)}try{const r=await this.scanForProjects(e);for(const o of r)if(!s.has(o)){const a=await this.detectProject(o);a&&(s.add(a.metadata.projectPath),t.push(a))}}catch(r){this.logWarning(`Recursive scan failed: ${r.message}`)}return t}getLoadErrors(){return[...this.loadErrors]}clear(){this.loadedPlugins.clear(),this.loadErrors=[]}getStats(){const e=Array.from(this.loadedPlugins.values()),t={};for(const s of e)t[s.source.type]=(t[s.source.type]||0)+1;return{totalLoaded:e.length,totalErrors:this.loadErrors.length,averageLoadTime:e.length>0?e.reduce((s,i)=>s+i.loadTime,0)/e.length:0,byType:t}}validatePlugin(e){if(!e||typeof e!="object")throw new Error("Plugin must be an object");const t=e;if(!t.name||typeof t.name!="string")throw new Error('Plugin must have a "name" property');if(!t.displayName||typeof t.displayName!="string")throw new Error('Plugin must have a "displayName" property');if(!t.version||typeof t.version!="string")throw new Error('Plugin must have a "version" property');if(typeof t.priority!="number")throw new Error('Plugin must have a "priority" property');if(typeof t.detect!="function")throw new Error('Plugin must implement "detect" method');if(typeof t.getTemplates!="function")throw new Error('Plugin must implement "getTemplates" method')}async tryImport(e){try{return await import(e)}catch{return null}}handleLoadError(e,t){this.loadErrors.push({source:e,error:t,timestamp:new Date}),this.logWarning(`Failed to load plugin "${e.identifier}": ${t.message}`)}log(e){this.verbose&&console.log(`[PluginLoader] ${e}`)}logWarning(e){this.verbose&&console.warn(`[PluginLoader] ⚠️ ${e}`)}}const y=class y{constructor(){this.initialized=!1,this.loader=new T({verbose:!1}),this.config={}}static getInstance(){return y.instance||(y.instance=new y),y.instance}async initialize(e={}){if(!this.initialized&&(this.config=e,this.loader=new T({verbose:e.verbose}),await this.loadConfiguredPlugins(e.plugins),this.initialized=!0,e.verbose)){const t=this.loader.getStats();console.log(`[PluginRegistry] Initialized with ${t.totalLoaded} plugins`),console.log(`[PluginRegistry] Load time: ${t.averageLoadTime.toFixed(2)}ms avg`)}}reset(){this.loader.clear(),this.initialized=!1,this.config={}}async ensureInitialized(){this.initialized||await this.initialize()}async getPlugin(e){return await this.ensureInitialized(),this.loader.getPlugin(e)}async getAllPlugins(){return await this.ensureInitialized(),this.loader.getAllPlugins()}async detectProject(e){return await this.ensureInitialized(),this.loader.detectProject(e)}async detectAllProjects(e){return await this.ensureInitialized(),this.loader.detectAllProjects(e)}async getPluginForLanguage(e){await this.ensureInitialized();const t=this.loader.getAllPlugins();let s=t.find(i=>i.name===e.toLowerCase());return s||(s=t.find(i=>i.displayName.toLowerCase()===e.toLowerCase()),s)||(s=t.find(i=>i.displayName.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(i.name))),s}async loadPlugin(e){return await this.ensureInitialized(),(e.type==="npm"?await this.loader.loadNpmPlugin(e.path):await this.loader.loadLocalPlugin(e.path))?.plugin??null}async getStats(){await this.ensureInitialized();const e=this.loader.getStats();return{totalPlugins:e.totalLoaded,loadErrors:e.totalErrors,averageLoadTime:e.averageLoadTime,pluginsByType:e.byType}}async getLoadErrors(){return await this.ensureInitialized(),this.loader.getLoadErrors().map(e=>({source:e.source.identifier,error:e.error.message,timestamp:e.timestamp}))}getStatistics(){return this.loader.getStats()}async loadConfiguredPlugins(e={}){const{builtin:t=[],npm:s=[],local:i=[],workspace:r=[],disabled:o=[]}=e;if(t.length>0){const a=t.filter(c=>!o.includes(c));await this.loader.loadBuiltinPlugins(a)}else await this.loader.loadBuiltinPlugins();for(const a of s)o.includes(a)||await this.loader.loadNpmPlugin(a);for(const a of i)if(!o.includes(a)){const c=this.resolvePath(a);await this.loader.loadLocalPlugin(c)}this.config.workspacePath&&r.length>0&&await this.loader.loadWorkspacePlugins(this.config.workspacePath,r),e.priority&&this.applyPriorityOverrides(e.priority)}resolvePath(e){if(e.startsWith("~/")){const s=process.env.HOME||process.env.USERPROFILE||"";return f.join(s,e.slice(2))}if(f.isAbsolute(e))return e;const t=this.config.workspacePath||process.cwd();return f.resolve(t,e)}applyPriorityOverrides(e){for(const[t,s]of Object.entries(e)){const i=this.loader.getPlugin(t);i&&(i.priority=s)}}static async loadConfigFromFile(e){try{if(!p.existsSync(e))return null;const t=p.readFileSync(e,"utf-8");return JSON.parse(t)}catch(t){return console.warn(`Failed to load config from ${e}: ${t.message}`),null}}static async loadConfig(e){const t=[],s=process.env.HOME||process.env.USERPROFILE;if(s){const i=f.join(s,".magic-helix","config.json"),r=await y.loadConfigFromFile(i);r&&t.push(r)}if(e){const i=f.join(e,".magic-helix.json"),r=await y.loadConfigFromFile(i);r&&(r.workspacePath=e,t.push(r))}return t.length===0?{workspacePath:e}:t.reduce((i,r)=>{const o={...i.plugins||{},...r.plugins||{}},a={...i.templates||{},...r.templates||{}};return i.plugins=o,i.templates=a,Object.assign(i,r,{plugins:o,templates:a}),i},{workspacePath:e})}};y.instance=null;let C=y;function Ne(){return C.getInstance()}async function We(n){const e=C.getInstance();return await e.initialize(n),e}class ze{constructor(e={}){this.templateCache=new Map,this.config=e.config||{},this.verbose=e.verbose??!1,this.cacheEnabled=e.cacheEnabled??!0}async loadTemplate(e,t=[]){const s=`${e}:${t.map(i=>i.name).join(",")}`;if(this.cacheEnabled&&this.templateCache.has(s)){const i=this.templateCache.get(s);if(i)return{content:i,source:"plugin",path:"(cached)"}}if(this.config.overrides?.[e]){const i=this.config.overrides[e],r=await this.loadFromPath(i,"override");if(r)return this.cacheTemplate(s,r.content),r}if(this.config.searchPaths)for(const i of this.config.searchPaths){const r=await this.searchInDirectory(i,e,i.includes(".magic-helix")?"workspace":"global");if(r)return this.cacheTemplate(s,r.content),r}for(const i of t){const r=await this.loadFromPlugin(i,e);if(r)return this.cacheTemplate(s,r.content),r}return this.log(`Template "${e}" not found`),null}async loadPluginTemplates(e){try{const t=await Promise.resolve(e.getTemplates());return this.log(`Loaded ${t.length} templates from ${e.displayName}`),t}catch(t){return this.logWarning(`Failed to load templates from ${e.name}: ${t.message}`),[]}}async loadTemplates(e,t=[]){const s=new Map;for(const i of e){const r=await this.loadTemplate(i,t);r&&s.set(i,r)}return s}async findTemplatesByTags(e,t=[]){const s=[];for(const i of t){const r=await this.loadPluginTemplates(i);s.push(...r)}return s.filter(i=>i.tags.some(r=>e.includes(r)))}async resolveTemplateContent(e){return typeof e.content=="string"?e.content:await Promise.resolve(e.content())}clearCache(){this.templateCache.clear(),this.log("Template cache cleared")}getCacheStats(){return{size:this.templateCache.size,keys:Array.from(this.templateCache.keys())}}async loadFromPath(e,t){try{const s=this.resolvePath(e);if(!p.existsSync(s))return this.log(`Template not found at: ${s}`),null;const i=p.readFileSync(s,"utf-8");return this.log(`✓ Loaded template from ${t}: ${s}`),{content:i,source:t,path:s}}catch(s){return this.logWarning(`Failed to load template from ${e}: ${s.message}`),null}}async searchInDirectory(e,t,s){const i=this.resolvePath(e);if(!p.existsSync(i))return null;const r=this.config.extensions||[".md",".txt",""];for(const o of r){const a=t.endsWith(o)?t:`${t}${o}`,c=f.join(i,a);if(p.existsSync(c))return this.loadFromPath(c,s)}return null}async loadFromPlugin(e,t){try{const i=(await this.loadPluginTemplates(e)).find(o=>o.name===t);if(!i)return null;const r=await this.resolveTemplateContent(i);return this.log(`✓ Loaded template "${t}" from plugin: ${e.displayName}`),{content:r,source:"plugin",path:`plugin:${e.name}/${t}`,plugin:e.name}}catch(s){return this.logWarning(`Failed to load template "${t}" from plugin ${e.name}: ${s.message}`),null}}resolvePath(e){if(e.startsWith("~/")){const t=process.env.HOME||process.env.USERPROFILE||"";return f.join(t,e.slice(2))}return f.isAbsolute(e)?e:f.resolve(process.cwd(),e)}cacheTemplate(e,t){this.cacheEnabled&&this.templateCache.set(e,t)}log(e){this.verbose&&console.log(`[TemplateLoader] ${e}`)}logWarning(e){this.verbose&&console.warn(`[TemplateLoader] ⚠️ ${e}`)}}const k=".magic-helix",B="meta-instructions.json";function q(n){const e=f.join(n,k,B);if(!p.existsSync(e))return null;try{const t=p.readFileSync(e,"utf-8");return JSON.parse(t)}catch(t){return console.warn(`Failed to load meta-instruction config: ${t.message}`),null}}function U(n){const e=f.join(n,k,"overrides"),t=new Map;if(!p.existsSync(e))return t;const s=ne.glob.sync("**/*.md",{cwd:e,absolute:!0});for(const i of s){const r=f.basename(i,".md"),o=p.readFileSync(i,"utf-8");t.set(r,o)}return t}function H(n,e,t){const s=new Map(n);if(e.ignoreTags)for(const r of e.ignoreTags)s.delete(r);const i=U(t);for(const[r,o]of i)s.set(r,o);if(e.overrides)for(const r of e.overrides){const o=s.get(r.tag);switch(r.mode){case"replace":s.set(r.tag,r.content);break;case"prepend":o?s.set(r.tag,`${r.content}
|
|
57
|
+
|
|
58
|
+
${o}`):s.set(r.tag,r.content);break;case"append":o?s.set(r.tag,`${o}
|
|
59
|
+
|
|
60
|
+
${r.content}`):s.set(r.tag,r.content);break}}return s}function V(n,e){const t=new Map(n);let s=e.template;for(const i of e.tags){const r=n.get(i);r&&(s=s.replace(`{{${i}}}`,r))}return t.set(e.outputTag,s),t}function Ge(n,e){const t=q(e);if(!t)return n;let s=H(n,t,e);if(t.combiners)for(const i of t.combiners)s=V(s,i);return s}function Be(n){const e=f.join(n,k);return p.existsSync(e)}function qe(n){const e=f.join(n,k),t=f.join(e,"overrides");p.mkdirSync(e,{recursive:!0}),p.mkdirSync(t,{recursive:!0});const s={overrides:[{tag:"example-tag",content:`# Custom Instruction
|
|
61
|
+
|
|
62
|
+
Your content here...`,mode:"replace"}],combiners:[{tags:["tag1","tag2"],outputTag:"combined-tag",template:`# Combined Instructions
|
|
63
|
+
|
|
64
|
+
{{tag1}}
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
{{tag2}}`}],ignoreTags:["unwanted-tag"]},i=f.join(e,B);p.writeFileSync(i,JSON.stringify(s,null,2)),p.writeFileSync(f.join(t,"example.md"),`# Example Override
|
|
69
|
+
|
|
70
|
+
This file overrides the default instructions for this tag.
|
|
71
|
+
Create files like:
|
|
72
|
+
- react-core.md → overrides "react-core" tag
|
|
73
|
+
- style-tailwind.md → overrides "style-tailwind" tag
|
|
74
|
+
`),console.log(`✅ Initialized .magic-helix/ directory structure at: ${e}`)}class J{constructor(e={}){this.enabled=!!e.enabled;const t=e.dir||b.resolve(process.cwd(),".magic-helix/telemetry");this.filePath=b.join(t,"events.jsonl"),this.sessionId=e.sessionId,this.variant=e.variant,this.projectRoot=e.projectRoot,this.enabled&&j.mkdirSync(b.dirname(this.filePath),{recursive:!0})}isEnabled(){return this.enabled}track(e){if(!this.enabled)return;const t={...e,timestamp:new Date().toISOString(),sessionId:this.sessionId,projectRoot:this.projectRoot};"variant"in e&&e.variant?t.variant=e.variant:t.variant=this.variant;const s=`${JSON.stringify(t)}
|
|
75
|
+
`;j.appendFileSync(this.filePath,s,"utf-8")}}function Ue(n={}){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();return new J({enabled:e,dir:t,sessionId:s,variant:i,projectRoot:r})}function He(n){return n.map(e=>{const t=N(e.context),s=x(t);return{variant:e.name,instructions:t,score:s.overallScore,structureScore:s.structureScore,clarityScore:s.clarityScore,completenessScore:s.completenessScore,missingCount:s.missingElements.length}})}function Ve(n){return n.length===0?{variant:"",instructions:"",score:0,structureScore:0,clarityScore:0,completenessScore:0,missingCount:0}:n.reduce((e,t)=>t.score>e.score?t:e,n[0])}function Je(n,e){if(e?.isEnabled())for(const t of n){const s={type:"instruction_validation",file:`ab-test-variant-${t.variant}`,score:t.score,structureScore:t.structureScore,clarityScore:t.clarityScore,completenessScore:t.completenessScore,missingCount:t.missingCount,variant:t.variant};e.track(s)}}const Ye=se.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:F&&F.tagName.toUpperCase()==="SCRIPT"&&F.src||new URL("index.cjs",document.baseURI).href);b.dirname(Ye);exports.BUILT_IN_CONFIG=O;exports.CodeOwnersPlugin=Ie;exports.DEFAULT_AI_REFINEMENT=E;exports.DockerPlugin=$e;exports.GitHubActionsPlugin=De;exports.GitLabCIPlugin=Le;exports.GolangPlugin=Me;exports.INSTRUCTION_ELEMENTS=W;exports.MonorepoPlugin=Oe;exports.PHPPlugin=Re;exports.PluginLoader=T;exports.PluginRegistry=C;exports.PluginRegistryOld=G;exports.PythonPlugin=_e;exports.RustPlugin=Ae;exports.TelemetryClient=J;exports.TemplateLoader=ze;exports.analyzeBestVariant=Ve;exports.analyzeProjectTags=oe;exports.analyzeWithPlugins=Ee;exports.applyCombiner=V;exports.applyMetaInstructions=Ge;exports.applyOverrides=H;exports.combinePatterns=A;exports.createTelemetry=Ue;exports.estimateTokens=pe;exports.formatValidationReport=je;exports.generateABVariants=He;exports.generateInstructions=N;exports.getFormatter=Ce;exports.getQualityGrade=z;exports.getRegistry=Ne;exports.hasMetaInstructions=Be;exports.initMetaInstructions=qe;exports.initializeRegistry=We;exports.loadMetaConfig=q;exports.loadOverrideInstructions=U;exports.loadPatternTemplates=R;exports.loadUserConfig=he;exports.mergeConfigs=ye;exports.passesQualityThreshold=Se;exports.pluginRegistry=h;exports.refineInstructions=ae;exports.registerBuiltInPlugins=xe;exports.selectPatterns=_;exports.trackABTest=Je;exports.validateInstructions=x;
|
|
2
76
|
//# sourceMappingURL=index.cjs.map
|