agentpacks 1.7.13 → 1.8.0
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/api.js +48 -3658
- package/dist/cli/export-cmd.js +7 -1027
- package/dist/cli/generate.js +39 -2731
- package/dist/cli/import-cmd.js +19 -770
- package/dist/cli/info.js +4 -231
- package/dist/cli/init.js +9 -185
- package/dist/cli/install.js +4 -902
- package/dist/cli/login.js +6 -201
- package/dist/cli/models-explain.js +14 -1266
- package/dist/cli/pack/create.js +4 -146
- package/dist/cli/pack/enable.js +2 -65
- package/dist/cli/pack/list.js +5 -893
- package/dist/cli/pack/validate.js +4 -642
- package/dist/cli/publish.js +8 -679
- package/dist/cli/search.js +4 -209
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +1 -145
- package/dist/core/dependency-resolver.js +1 -126
- package/dist/core/feature-merger.js +3 -398
- package/dist/core/index.js +5 -1129
- package/dist/core/lockfile.js +2 -43
- package/dist/core/metarepo.js +1 -183
- package/dist/core/pack-loader.js +4 -841
- package/dist/core/profile-resolver.js +1 -110
- package/dist/exporters/cursor-plugin.js +6 -404
- package/dist/exporters/index.js +6 -404
- package/dist/features/agents.js +3 -161
- package/dist/features/commands.js +3 -161
- package/dist/features/hooks.js +3 -153
- package/dist/features/ignore.js +2 -43
- package/dist/features/index.js +4 -629
- package/dist/features/mcp.js +3 -143
- package/dist/features/models.js +3 -292
- package/dist/features/plugins.js +3 -139
- package/dist/features/rules.d.ts +0 -1
- package/dist/features/rules.js +3 -169
- package/dist/features/skills.js +3 -228
- package/dist/importers/claude-code.js +6 -195
- package/dist/importers/cursor.js +5 -355
- package/dist/importers/opencode.js +6 -346
- package/dist/importers/rulesync.js +5 -365
- package/dist/index.js +89 -4934
- package/dist/node/api.js +48 -3659
- package/dist/node/cli/export-cmd.js +7 -1028
- package/dist/node/cli/generate.js +39 -2732
- package/dist/node/cli/import-cmd.js +19 -771
- package/dist/node/cli/info.js +4 -232
- package/dist/node/cli/init.js +9 -186
- package/dist/node/cli/install.js +4 -903
- package/dist/node/cli/login.js +6 -202
- package/dist/node/cli/models-explain.js +14 -1267
- package/dist/node/cli/pack/create.js +4 -147
- package/dist/node/cli/pack/enable.js +2 -66
- package/dist/node/cli/pack/list.js +5 -894
- package/dist/node/cli/pack/validate.js +4 -643
- package/dist/node/cli/publish.js +8 -680
- package/dist/node/cli/search.js +4 -210
- package/dist/node/core/config.js +1 -146
- package/dist/node/core/dependency-resolver.js +1 -127
- package/dist/node/core/feature-merger.js +3 -399
- package/dist/node/core/index.js +5 -1130
- package/dist/node/core/lockfile.js +2 -44
- package/dist/node/core/metarepo.js +1 -184
- package/dist/node/core/pack-loader.js +4 -842
- package/dist/node/core/profile-resolver.js +1 -111
- package/dist/node/exporters/cursor-plugin.js +6 -405
- package/dist/node/exporters/index.js +6 -405
- package/dist/node/features/agents.js +3 -162
- package/dist/node/features/commands.js +3 -162
- package/dist/node/features/hooks.js +3 -154
- package/dist/node/features/ignore.js +2 -44
- package/dist/node/features/index.js +4 -630
- package/dist/node/features/mcp.js +3 -144
- package/dist/node/features/models.js +3 -293
- package/dist/node/features/plugins.js +3 -140
- package/dist/node/features/rules.js +3 -170
- package/dist/node/features/skills.js +3 -229
- package/dist/node/importers/claude-code.js +6 -196
- package/dist/node/importers/cursor.js +5 -356
- package/dist/node/importers/opencode.js +6 -347
- package/dist/node/importers/rulesync.js +5 -366
- package/dist/node/index.js +89 -4935
- package/dist/node/sources/git-ref.js +1 -56
- package/dist/node/sources/git.js +2 -222
- package/dist/node/sources/index.js +4 -714
- package/dist/node/sources/local.js +1 -24
- package/dist/node/sources/npm-ref.js +1 -56
- package/dist/node/sources/npm.js +2 -184
- package/dist/node/sources/registry-ref.js +1 -37
- package/dist/node/sources/registry.js +4 -355
- package/dist/node/targets/additional-targets.js +6 -587
- package/dist/node/targets/base-target.js +1 -23
- package/dist/node/targets/claude-code.js +6 -714
- package/dist/node/targets/codex-cli.js +3 -324
- package/dist/node/targets/copilot.js +5 -603
- package/dist/node/targets/cursor.js +6 -700
- package/dist/node/targets/gemini-cli.js +10 -319
- package/dist/node/targets/generic-md-target.js +6 -478
- package/dist/node/targets/index.js +32 -1873
- package/dist/node/targets/mistral-vibe.js +7 -661
- package/dist/node/targets/opencode.js +13 -723
- package/dist/node/targets/registry.js +32 -1864
- package/dist/node/utils/credentials.js +3 -38
- package/dist/node/utils/diff.js +5 -132
- package/dist/node/utils/filesystem.js +3 -124
- package/dist/node/utils/frontmatter.js +1 -24
- package/dist/node/utils/global.js +1 -53
- package/dist/node/utils/markdown.js +3 -30
- package/dist/node/utils/model-allowlist.js +1 -126
- package/dist/node/utils/model-guidance.js +2 -78
- package/dist/node/utils/registry-client.js +1 -142
- package/dist/node/utils/tarball.js +1 -49
- package/dist/sources/git-ref.js +1 -55
- package/dist/sources/git.js +2 -221
- package/dist/sources/index.js +4 -713
- package/dist/sources/local.js +1 -23
- package/dist/sources/npm-ref.js +1 -55
- package/dist/sources/npm.js +2 -183
- package/dist/sources/registry-ref.js +1 -36
- package/dist/sources/registry.js +4 -354
- package/dist/targets/additional-targets.js +6 -586
- package/dist/targets/base-target.js +1 -22
- package/dist/targets/claude-code.js +6 -713
- package/dist/targets/codex-cli.js +3 -323
- package/dist/targets/copilot.js +5 -602
- package/dist/targets/cursor.js +6 -699
- package/dist/targets/gemini-cli.js +10 -318
- package/dist/targets/generic-md-target.js +6 -477
- package/dist/targets/index.d.ts +0 -1
- package/dist/targets/index.js +32 -1872
- package/dist/targets/mistral-vibe.js +7 -660
- package/dist/targets/opencode.js +13 -722
- package/dist/targets/registry.js +32 -1863
- package/dist/utils/credentials.js +3 -37
- package/dist/utils/diff.js +5 -131
- package/dist/utils/filesystem.js +3 -123
- package/dist/utils/frontmatter.js +1 -23
- package/dist/utils/global.js +1 -52
- package/dist/utils/markdown.js +3 -29
- package/dist/utils/model-allowlist.js +1 -125
- package/dist/utils/model-guidance.js +2 -77
- package/dist/utils/registry-client.js +1 -141
- package/dist/utils/tarball.js +1 -48
- package/package.json +4 -16
- package/dist/node/targets/agents-md.js +0 -211
- package/dist/targets/agents-md.d.ts +0 -13
- package/dist/targets/agents-md.js +0 -211
package/dist/targets/index.js
CHANGED
|
@@ -1,1890 +1,50 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var u0=import.meta.require;import{existsSync as Qq,mkdirSync as tq,readdirSync as Sq,readFileSync as eq,rmSync as q0,statSync as Aq,writeFileSync as $0}from"fs";import{dirname as Q0,join as bq,relative as U0}from"path";var wq="<!-- Generated by agentpacks. DO NOT EDIT. -->",Iq="// Generated by agentpacks. DO NOT EDIT.",Fq="// Generated by agentpacks. DO NOT EDIT.";function x(q,$,Y={}){let{header:Q=!0,type:L}=Y,B=L??Y0(q);N(Q0(q));let H=$;if(Q){let J=Z0(B);if(J)H=`${J}
|
|
3
|
+
${$}`}$0(q,H,"utf-8")}function w(q,$,Y={}){let Q=JSON.stringify($,null,2);x(q,Q+`
|
|
4
|
+
`,{...Y,type:"json"})}function yq(q){if(!Qq(q))return null;return eq(q,"utf-8")}function Zq(q){let $=yq(q);if($===null)return null;return JSON.parse($)}function N(q){if(!Qq(q))tq(q,{recursive:!0})}function _(q){if(Qq(q))q0(q,{recursive:!0,force:!0})}function o(q,$={}){let{extension:Y,recursive:Q=!1}=$;if(!Qq(q))return[];let L=[],B=Sq(q);for(let H of B){let J=bq(q,H),z=Aq(J);if(z.isDirectory()&&Q)L.push(...o(J,$));else if(z.isFile()){if(!Y||H.endsWith(Y))L.push(J)}}return L}function Rq(q){if(!Qq(q))return[];return Sq(q).map(($)=>bq(q,$)).filter(($)=>Aq($).isDirectory())}function c0(q,$){return U0(q,$)}function f0(q){let $=yq(q);if(!$)return!1;return $.startsWith(wq)||$.startsWith(Iq)||$.startsWith(Fq)}function Y0(q){if(q.endsWith(".json")||q.endsWith(".jsonc"))return"json";if(q.endsWith(".ts")||q.endsWith(".mts"))return"ts";if(q.endsWith(".js")||q.endsWith(".mjs"))return"js";return"md"}function Z0(q){switch(q){case"md":return wq;case"json":return Iq;case"js":case"ts":return Fq;default:return null}}import Mq from"gray-matter";function h(q){let{data:$,content:Y}=Mq(q);return{data:$,content:Y.trim(),raw:q}}function D(q,$){let Y=Object.fromEntries(Object.entries(q).filter(([,Q])=>Q!==void 0));if(Object.keys(Y).length===0)return $;return Mq.stringify($,Y)}import{readFileSync as X0}from"fs";import{basename as V0}from"path";function r0(q,$){return o(q,{extension:".md"}).map((Q)=>K0(Q,$))}function K0(q,$){let Y=X0(q,"utf-8"),{data:Q,content:L}=h(Y);return{name:Q.name??V0(q,".md"),sourcePath:q,packName:$,meta:Q,content:L}}function E(q,$){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes($)}import{readFileSync as B0}from"fs";import{basename as L0}from"path";function U1(q,$){return o(q,{extension:".md"}).map((Q)=>J0(Q,$))}function J0(q,$){let Y=B0(q,"utf-8"),{data:Q,content:L}=h(Y);return{name:L0(q,".md"),sourcePath:q,packName:$,meta:Q,content:L}}function y(q,$){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes($)}import{join as z0}from"path";var O0=["cursor","claudecode","codexcli","opencode"];function V1(q,$){let Y=z0(q,"hooks","hooks.json"),Q=Zq(Y);if(!Q)return null;let L=Q.hooks??{},B={};for(let H of O0){let J=Q[H];if(J&&typeof J==="object"&&"hooks"in J&&J.hooks)B[H]=J.hooks}return{packName:$,sourcePath:Y,version:Q.version,shared:L,targetOverrides:B}}function g(q,$){let Y={};for(let[L,B]of Object.entries(q.shared))Y[L]=[...B];let Q=q.targetOverrides[$];if(Q)for(let[L,B]of Object.entries(Q))Y[L]=[...Y[L]??[],...B];return Y}import{readFileSync as H0}from"fs";import{basename as C0}from"path";function O1(q,$){return o(q,{extension:".md"}).map((Q)=>P0(Q,$))}function P0(q,$){let Y=H0(q,"utf-8"),{data:Q,content:L}=h(Y);return{name:C0(q,".md"),sourcePath:q,packName:$,meta:Q,content:L}}function I(q,$){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes($)}function Xq(q){return q.filter(($)=>$.meta.root===!0)}function l(q){return q.filter(($)=>$.meta.root!==!0)}import{existsSync as x0,readFileSync as N0}from"fs";import{basename as jq,join as W0}from"path";var _0=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Gq=64;function W1(q,$){let Y=Rq(q),Q=[];for(let L of Y){let B=W0(L,"SKILL.md");if(x0(B))Q.push(S0(B,L,$))}return Q}function S0(q,$,Y){let Q=N0(q,"utf-8"),{data:L,content:B}=h(Q);return{name:L.name??jq($),sourcePath:q,sourceDir:$,packName:Y,meta:L,content:B}}function A0(q){return{...q.meta,name:q.name}}function G(q){return D(A0(q),q.content)}function _1(q,$){let{data:Y,content:Q}=h(q),L={...Y,name:$},B=!1,H=L.description;if(typeof H!=="string"||H.trim().length===0)L.description=`Imported skill: ${$}`,B=!0;return{content:D(L,Q),addedDescription:B}}function S1(q){let $=[],Y=jq(q.sourceDir),Q=q.meta.name;if(typeof Q!=="string"||Q.trim().length===0)$.push('Missing required frontmatter field "name".');else{if(Q.length>Gq)$.push(`Invalid "name": must be at most ${Gq} characters.`);if(!_0.test(Q))$.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');if(Q!==Y)$.push(`Invalid "name": must match containing directory "${Y}".`)}let L=q.meta.description;if(typeof L!=="string"||L.trim().length===0)$.push('Missing required frontmatter field "description".');let B=q.meta["allowed-tools"];if(B!==void 0&&(!Array.isArray(B)||B.some((H)=>typeof H!=="string"||H.length===0)))$.push('Invalid "allowed-tools": expected an array of non-empty strings.');return $}function j(q,$){let{targets:Y}=q.meta;if(!Y||Y==="*")return!0;if(Array.isArray(Y)&&Y.includes("*"))return!0;return Array.isArray(Y)&&Y.includes($)}function F(q,$,Y){let{default:Q,small:L}=q,B={...q.agents};if($&&q.profiles?.[$]){let O=b0($,q.profiles);if(O.default)Q=O.default;if(O.small)L=O.small;if(O.agents)B={...B,...O.agents}}if(Y){let O=q.overrides?.[Y];if(O){if(O.default)Q=O.default;if(O.small)L=O.small;if(O.agents)B={...B,...O.agents}}}let H={};if(q.providers)for(let[O,S]of Object.entries(q.providers))H[O]={...S.options?{options:S.options}:{},...S.models?{models:S.models}:{}};let J=Object.keys(q.profiles??{}),z={};if(q.profiles)for(let[O,S]of Object.entries(q.profiles))z[O]={description:S.description,default:S.default,small:S.small};return{default:Q,small:L,agents:B,providers:H,routing:q.routing??[],profileNames:J,activeProfile:$,profiles:z}}function b1(q,$,Y){let Q=q.agents[$];if(Q)return{model:Q.model,temperature:Q.temperature,top_p:Q.top_p};if(Y)return{model:Y};return{}}function b0(q,$){return Tq(q,$,new Set,0)}var Eq=10;function Tq(q,$,Y,Q){if(Q>Eq)throw Error(`Profile inheritance too deep (max ${Eq}): ${q}`);if(Y.has(q))throw Error(`Circular profile inheritance detected: ${[...Y,q].join(" \u2192 ")}`);let L=$[q];if(!L)throw Error(`Profile "${q}" not found`);if(Y.add(q),!L.extends)return{...L};let B=Tq(L.extends,$,Y,Q+1);return{description:L.description??B.description,default:L.default??B.default,small:L.small??B.small,agents:{...B.agents,...L.agents}}}function p(q){if(!q.default&&!q.small&&Object.keys(q.agents).length===0&&Object.keys(q.profiles).length===0)return null;let $=[];if($.push("# Model Configuration"),$.push(""),$.push("Use the following model preferences when working in this project."),$.push(""),q.default||q.small){if($.push("## Default Models"),$.push(""),q.default)$.push(`- **Primary model**: ${q.default}`);if(q.small)$.push(`- **Lightweight tasks** (titles, summaries): ${q.small}`);$.push("")}let Y=Object.entries(q.agents);if(Y.length>0){$.push("## Agent Model Assignments"),$.push(""),$.push("| Agent | Model | Temperature |"),$.push("| --- | --- | --- |");for(let[Q,L]of Y){let B=L.temperature!==void 0?String(L.temperature):"\u2014";$.push(`| ${Q} | ${L.model} | ${B} |`)}$.push("")}if(Object.keys(q.profiles).length>0){$.push("## Available Profiles"),$.push(""),$.push("| Profile | Description | Default Model |"),$.push("| --- | --- | --- |");for(let[Q,L]of Object.entries(q.profiles))$.push(`| ${Q} | ${L.description??"\u2014"} | ${L.default??"\u2014"} |`);$.push("")}if(q.activeProfile)$.push(`**Active profile**: \`${q.activeProfile}\``),$.push("");if(q.routing.length>0){$.push("## Task-Aware Routing"),$.push(""),$.push("Select the appropriate profile based on the task context:"),$.push(""),$.push("| Condition | Profile | Description |"),$.push("| --- | --- | --- |");for(let Q of q.routing){let L=Object.entries(Q.when).map(([H,J])=>`${H}=${J}`).join(", "),B=Q.description??"\u2014";$.push(`| ${L} | ${Q.use} | ${B} |`)}$.push(""),$.push("### Condition Reference"),$.push(""),$.push("- **complexity**: low | medium | high | critical"),$.push("- **urgency**: low | normal | high"),$.push("- **budget**: minimal | standard | premium"),$.push("- **contextWindowNeed**: small | medium | large | max"),$.push("- **toolUseIntensity**: none | light | heavy"),$.push("")}return $.join(`
|
|
5
|
+
`)}class b{supportsFeature(q){return this.supportedFeatures.includes(q)}getEffectiveFeatures(q){return q.filter(($)=>this.supportsFeature($))}createResult(q=[],$=[],Y=[]){return{targetId:this.id,filesWritten:q,filesDeleted:$,warnings:Y}}}import{join as Cq,resolve as s}from"path";function R(q){return new kq(q)}class kq extends b{id;name;supportedFeatures;config;constructor(q){super();this.id=q.id,this.name=q.name,this.supportedFeatures=q.supportedFeatures,this.config=q}generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=s($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=s(H,this.config.configDir),X=this.config.rulesDir??"rules",V=this.config.ruleExtension??".md";if(J.includes("rules")){let U=s(P,X);if(B)_(U),O.push(U);N(U);let Z=Q.rules.filter((K)=>I(K,this.id));for(let K of Z){let C=Cq(U,`${K.name}${V}`);x(C,K.content),z.push(C)}}if(J.includes("commands")){let U=s(P,"commands");if(B)_(U),O.push(U);N(U);let Z=Q.commands.filter((K)=>y(K,this.id));for(let K of Z){let C=Cq(U,`${K.name}.md`);x(C,K.content),z.push(C)}}if(J.includes("mcp")){if(Object.entries(Q.mcpServers).length>0){let Z=this.config.mcpInConfigDir?P:H,K=s(Z,"mcp.json");w(K,{mcpServers:Q.mcpServers},{header:!1}),z.push(K)}}if(J.includes("ignore")&&this.config.ignoreFile){if(Q.ignorePatterns.length>0){let U=s(H,this.config.ignoreFile);x(U,Q.ignorePatterns.join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`),z.push(U)}}if(J.includes("models")&&Q.models){let U=F(Q.models,q.modelProfile,this.id),Z=p(U);if(Z){N(P);let K=Cq(P,"model-config.md");x(K,Z),z.push(K)}}return this.createResult(z,O,S)}}var hq=R({id:"cline",name:"Cline",configDir:".cline",supportedFeatures:["rules","commands","mcp","ignore"],ignoreFile:".clineignore",mcpInConfigDir:!0}),Dq=R({id:"kilo",name:"Kilo Code",configDir:".kilo",supportedFeatures:["rules","commands","mcp","ignore"],ignoreFile:".kiloignore",mcpInConfigDir:!0}),vq=R({id:"roo",name:"Roo Code",configDir:".roo",supportedFeatures:["rules","commands","mcp","ignore"],ignoreFile:".rooignore",mcpInConfigDir:!0}),uq=R({id:"qwencode",name:"Qwen Code",configDir:".qwencode",supportedFeatures:["rules","mcp","ignore"],ignoreFile:".qwencodeignore",mcpInConfigDir:!0}),gq=R({id:"kiro",name:"Kiro",configDir:".kiro",supportedFeatures:["rules","mcp"],mcpInConfigDir:!0}),pq=R({id:"factorydroid",name:"Factory Droid",configDir:".factorydroid",supportedFeatures:["rules","mcp"],mcpInConfigDir:!0}),mq=R({id:"antigravity",name:"AntiGravity",configDir:".antigravity",supportedFeatures:["rules","mcp"],mcpInConfigDir:!0}),cq=R({id:"junie",name:"Junie",configDir:".junie",supportedFeatures:["rules","mcp"],mcpInConfigDir:!0}),fq=R({id:"augmentcode",name:"Augment Code",configDir:".augmentcode",supportedFeatures:["rules","mcp"],mcpInConfigDir:!0}),dq=R({id:"windsurf",name:"Windsurf",configDir:".windsurf",supportedFeatures:["rules","mcp","ignore"],ignoreFile:".windsurfignore",mcpInConfigDir:!0}),oq=R({id:"warp",name:"Warp",configDir:".warp",supportedFeatures:["rules"]}),nq=R({id:"replit",name:"Replit Agent",configDir:".replit",supportedFeatures:["rules","mcp"],mcpInConfigDir:!0}),aq=R({id:"zed",name:"Zed",configDir:".zed",supportedFeatures:["rules","mcp"],mcpInConfigDir:!0});import{join as i,resolve as v}from"path";var m="claudecode";class Vq extends b{id=m;name="Claude Code";supportedFeatures=["rules","commands","agents","skills","hooks","mcp","ignore","models"];generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=v($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=v(H,".claude");if(J.includes("rules")){let X=v(P,"rules");if(B)_(X),O.push(X);N(X);let V=Q.rules.filter((K)=>I(K,m)),U=Xq(V),Z=l(V);if(U.length>0){let K=U.map((W)=>W.content).join(`
|
|
3
8
|
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/utils/frontmatter.ts
|
|
115
|
-
import matter from "gray-matter";
|
|
116
|
-
function parseFrontmatter(source) {
|
|
117
|
-
const { data, content } = matter(source);
|
|
118
|
-
return {
|
|
119
|
-
data,
|
|
120
|
-
content: content.trim(),
|
|
121
|
-
raw: source
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function serializeFrontmatter(data, content) {
|
|
125
|
-
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
126
|
-
if (Object.keys(filtered).length === 0) {
|
|
127
|
-
return content;
|
|
128
|
-
}
|
|
129
|
-
return matter.stringify(content, filtered);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/features/agents.ts
|
|
133
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
134
|
-
import { basename } from "path";
|
|
135
|
-
function parseAgents(agentsDir, packName) {
|
|
136
|
-
const files = listFiles(agentsDir, { extension: ".md" });
|
|
137
|
-
return files.map((filepath) => parseAgentFile(filepath, packName));
|
|
138
|
-
}
|
|
139
|
-
function parseAgentFile(filepath, packName) {
|
|
140
|
-
const raw = readFileSync2(filepath, "utf-8");
|
|
141
|
-
const { data, content } = parseFrontmatter(raw);
|
|
142
|
-
return {
|
|
143
|
-
name: data.name ?? basename(filepath, ".md"),
|
|
144
|
-
sourcePath: filepath,
|
|
145
|
-
packName,
|
|
146
|
-
meta: data,
|
|
147
|
-
content
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function agentMatchesTarget(agent, targetId) {
|
|
151
|
-
const { targets } = agent.meta;
|
|
152
|
-
if (!targets || targets === "*")
|
|
153
|
-
return true;
|
|
154
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
|
-
return true;
|
|
156
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/features/commands.ts
|
|
160
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
161
|
-
import { basename as basename2 } from "path";
|
|
162
|
-
function parseCommands(commandsDir, packName) {
|
|
163
|
-
const files = listFiles(commandsDir, { extension: ".md" });
|
|
164
|
-
return files.map((filepath) => parseCommandFile(filepath, packName));
|
|
165
|
-
}
|
|
166
|
-
function parseCommandFile(filepath, packName) {
|
|
167
|
-
const raw = readFileSync3(filepath, "utf-8");
|
|
168
|
-
const { data, content } = parseFrontmatter(raw);
|
|
169
|
-
return {
|
|
170
|
-
name: basename2(filepath, ".md"),
|
|
171
|
-
sourcePath: filepath,
|
|
172
|
-
packName,
|
|
173
|
-
meta: data,
|
|
174
|
-
content
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function commandMatchesTarget(cmd, targetId) {
|
|
178
|
-
const { targets } = cmd.meta;
|
|
179
|
-
if (!targets || targets === "*")
|
|
180
|
-
return true;
|
|
181
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
182
|
-
return true;
|
|
183
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/features/hooks.ts
|
|
187
|
-
import { join as join2 } from "path";
|
|
188
|
-
var TARGET_OVERRIDE_KEYS = ["cursor", "claudecode", "opencode"];
|
|
189
|
-
function parseHooks(packDir, packName) {
|
|
190
|
-
const hooksPath = join2(packDir, "hooks", "hooks.json");
|
|
191
|
-
const raw = readJsonOrNull(hooksPath);
|
|
192
|
-
if (!raw)
|
|
193
|
-
return null;
|
|
194
|
-
const shared = raw.hooks ?? {};
|
|
195
|
-
const targetOverrides = {};
|
|
196
|
-
for (const key of TARGET_OVERRIDE_KEYS) {
|
|
197
|
-
const override = raw[key];
|
|
198
|
-
if (override && typeof override === "object" && "hooks" in override && override.hooks) {
|
|
199
|
-
targetOverrides[key] = override.hooks;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return {
|
|
203
|
-
packName,
|
|
204
|
-
sourcePath: hooksPath,
|
|
205
|
-
version: raw.version,
|
|
206
|
-
shared,
|
|
207
|
-
targetOverrides
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function resolveHooksForTarget(hooks, targetId) {
|
|
211
|
-
const merged = {};
|
|
212
|
-
for (const [event, entries] of Object.entries(hooks.shared)) {
|
|
213
|
-
merged[event] = [...entries];
|
|
214
|
-
}
|
|
215
|
-
const overrides = hooks.targetOverrides[targetId];
|
|
216
|
-
if (overrides) {
|
|
217
|
-
for (const [event, entries] of Object.entries(overrides)) {
|
|
218
|
-
merged[event] = [...merged[event] ?? [], ...entries];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return merged;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// src/features/rules.ts
|
|
225
|
-
import { readFileSync as readFileSync4 } from "fs";
|
|
226
|
-
import { basename as basename3 } from "path";
|
|
227
|
-
function parseRules(rulesDir, packName) {
|
|
228
|
-
const files = listFiles(rulesDir, { extension: ".md" });
|
|
229
|
-
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
230
|
-
}
|
|
231
|
-
function parseRuleFile(filepath, packName) {
|
|
232
|
-
const raw = readFileSync4(filepath, "utf-8");
|
|
233
|
-
const { data, content } = parseFrontmatter(raw);
|
|
234
|
-
return {
|
|
235
|
-
name: basename3(filepath, ".md"),
|
|
236
|
-
sourcePath: filepath,
|
|
237
|
-
packName,
|
|
238
|
-
meta: data,
|
|
239
|
-
content
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function ruleMatchesTarget(rule, targetId) {
|
|
243
|
-
const { targets } = rule.meta;
|
|
244
|
-
if (!targets || targets === "*")
|
|
245
|
-
return true;
|
|
246
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
247
|
-
return true;
|
|
248
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
249
|
-
}
|
|
250
|
-
function getRootRules(rules) {
|
|
251
|
-
return rules.filter((r) => r.meta.root === true);
|
|
252
|
-
}
|
|
253
|
-
function getDetailRules(rules) {
|
|
254
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// src/features/skills.ts
|
|
258
|
-
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
259
|
-
import { basename as basename4, join as join3 } from "path";
|
|
260
|
-
var SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
261
|
-
var SKILL_NAME_MAX_LENGTH = 64;
|
|
262
|
-
function parseSkills(skillsDir, packName) {
|
|
263
|
-
const dirs = listDirs(skillsDir);
|
|
264
|
-
const skills = [];
|
|
265
|
-
for (const dir of dirs) {
|
|
266
|
-
const skillMd = join3(dir, "SKILL.md");
|
|
267
|
-
if (existsSync2(skillMd)) {
|
|
268
|
-
skills.push(parseSkillFile(skillMd, dir, packName));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return skills;
|
|
272
|
-
}
|
|
273
|
-
function parseSkillFile(filepath, skillDir, packName) {
|
|
274
|
-
const raw = readFileSync5(filepath, "utf-8");
|
|
275
|
-
const { data, content } = parseFrontmatter(raw);
|
|
276
|
-
return {
|
|
277
|
-
name: data.name ?? basename4(skillDir),
|
|
278
|
-
sourcePath: filepath,
|
|
279
|
-
sourceDir: skillDir,
|
|
280
|
-
packName,
|
|
281
|
-
meta: data,
|
|
282
|
-
content
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
function buildSkillFrontmatter(skill) {
|
|
286
|
-
return {
|
|
287
|
-
...skill.meta,
|
|
288
|
-
name: skill.name
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function serializeSkill(skill) {
|
|
292
|
-
return serializeFrontmatter(buildSkillFrontmatter(skill), skill.content);
|
|
293
|
-
}
|
|
294
|
-
function normalizeImportedSkillMarkdown(source, skillName) {
|
|
295
|
-
const { data, content } = parseFrontmatter(source);
|
|
296
|
-
const normalized = {
|
|
297
|
-
...data,
|
|
298
|
-
name: skillName
|
|
299
|
-
};
|
|
300
|
-
let addedDescription = false;
|
|
301
|
-
const description = normalized.description;
|
|
302
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
303
|
-
normalized.description = `Imported skill: ${skillName}`;
|
|
304
|
-
addedDescription = true;
|
|
305
|
-
}
|
|
306
|
-
return {
|
|
307
|
-
content: serializeFrontmatter(normalized, content),
|
|
308
|
-
addedDescription
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
function validateAgentSkillsFrontmatter(skill) {
|
|
312
|
-
const errors = [];
|
|
313
|
-
const dirName = basename4(skill.sourceDir);
|
|
314
|
-
const declaredName = skill.meta.name;
|
|
315
|
-
if (typeof declaredName !== "string" || declaredName.trim().length === 0) {
|
|
316
|
-
errors.push('Missing required frontmatter field "name".');
|
|
317
|
-
} else {
|
|
318
|
-
if (declaredName.length > SKILL_NAME_MAX_LENGTH) {
|
|
319
|
-
errors.push(`Invalid "name": must be at most ${SKILL_NAME_MAX_LENGTH} characters.`);
|
|
320
|
-
}
|
|
321
|
-
if (!SKILL_NAME_PATTERN.test(declaredName)) {
|
|
322
|
-
errors.push('Invalid "name": use lowercase letters, numbers, and single hyphens only.');
|
|
323
|
-
}
|
|
324
|
-
if (declaredName !== dirName) {
|
|
325
|
-
errors.push(`Invalid "name": must match containing directory "${dirName}".`);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const description = skill.meta.description;
|
|
329
|
-
if (typeof description !== "string" || description.trim().length === 0) {
|
|
330
|
-
errors.push('Missing required frontmatter field "description".');
|
|
331
|
-
}
|
|
332
|
-
const allowedTools = skill.meta["allowed-tools"];
|
|
333
|
-
if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.some((tool) => typeof tool !== "string" || tool.length === 0))) {
|
|
334
|
-
errors.push('Invalid "allowed-tools": expected an array of non-empty strings.');
|
|
335
|
-
}
|
|
336
|
-
return errors;
|
|
337
|
-
}
|
|
338
|
-
function skillMatchesTarget(skill, targetId) {
|
|
339
|
-
const { targets } = skill.meta;
|
|
340
|
-
if (!targets || targets === "*")
|
|
341
|
-
return true;
|
|
342
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
343
|
-
return true;
|
|
344
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// src/core/profile-resolver.ts
|
|
348
|
-
function resolveModels(merged, modelProfile, targetId) {
|
|
349
|
-
let defaultModel = merged.default;
|
|
350
|
-
let smallModel = merged.small;
|
|
351
|
-
let agents = { ...merged.agents };
|
|
352
|
-
if (modelProfile && merged.profiles?.[modelProfile]) {
|
|
353
|
-
const resolvedProfile = resolveProfileInheritance(modelProfile, merged.profiles);
|
|
354
|
-
if (resolvedProfile.default)
|
|
355
|
-
defaultModel = resolvedProfile.default;
|
|
356
|
-
if (resolvedProfile.small)
|
|
357
|
-
smallModel = resolvedProfile.small;
|
|
358
|
-
if (resolvedProfile.agents) {
|
|
359
|
-
agents = { ...agents, ...resolvedProfile.agents };
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if (targetId) {
|
|
363
|
-
const targetOverride = merged.overrides?.[targetId];
|
|
364
|
-
if (targetOverride) {
|
|
365
|
-
if (targetOverride.default)
|
|
366
|
-
defaultModel = targetOverride.default;
|
|
367
|
-
if (targetOverride.small)
|
|
368
|
-
smallModel = targetOverride.small;
|
|
369
|
-
if (targetOverride.agents) {
|
|
370
|
-
agents = { ...agents, ...targetOverride.agents };
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
const providers = {};
|
|
375
|
-
if (merged.providers) {
|
|
376
|
-
for (const [name, config] of Object.entries(merged.providers)) {
|
|
377
|
-
providers[name] = {
|
|
378
|
-
...config.options ? { options: config.options } : {},
|
|
379
|
-
...config.models ? { models: config.models } : {}
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
const profileNames = Object.keys(merged.profiles ?? {});
|
|
384
|
-
const profiles = {};
|
|
385
|
-
if (merged.profiles) {
|
|
386
|
-
for (const [name, profile] of Object.entries(merged.profiles)) {
|
|
387
|
-
profiles[name] = {
|
|
388
|
-
description: profile.description,
|
|
389
|
-
default: profile.default,
|
|
390
|
-
small: profile.small
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return {
|
|
395
|
-
default: defaultModel,
|
|
396
|
-
small: smallModel,
|
|
397
|
-
agents,
|
|
398
|
-
providers,
|
|
399
|
-
routing: merged.routing ?? [],
|
|
400
|
-
profileNames,
|
|
401
|
-
activeProfile: modelProfile,
|
|
402
|
-
profiles
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
function resolveAgentModel(resolved, agentName, frontmatterModel) {
|
|
406
|
-
const fromModels = resolved.agents[agentName];
|
|
407
|
-
if (fromModels) {
|
|
408
|
-
return {
|
|
409
|
-
model: fromModels.model,
|
|
410
|
-
temperature: fromModels.temperature,
|
|
411
|
-
top_p: fromModels.top_p
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
if (frontmatterModel) {
|
|
415
|
-
return { model: frontmatterModel };
|
|
416
|
-
}
|
|
417
|
-
return {};
|
|
418
|
-
}
|
|
419
|
-
function resolveProfileInheritance(profileName, profiles) {
|
|
420
|
-
const visited = new Set;
|
|
421
|
-
return resolveProfileChain(profileName, profiles, visited, 0);
|
|
422
|
-
}
|
|
423
|
-
var MAX_INHERITANCE_DEPTH = 10;
|
|
424
|
-
function resolveProfileChain(name, profiles, visited, depth) {
|
|
425
|
-
if (depth > MAX_INHERITANCE_DEPTH) {
|
|
426
|
-
throw new Error(`Profile inheritance too deep (max ${MAX_INHERITANCE_DEPTH}): ${name}`);
|
|
427
|
-
}
|
|
428
|
-
if (visited.has(name)) {
|
|
429
|
-
throw new Error(`Circular profile inheritance detected: ${[...visited, name].join(" \u2192 ")}`);
|
|
430
|
-
}
|
|
431
|
-
const profile = profiles[name];
|
|
432
|
-
if (!profile) {
|
|
433
|
-
throw new Error(`Profile "${name}" not found`);
|
|
434
|
-
}
|
|
435
|
-
visited.add(name);
|
|
436
|
-
if (!profile.extends) {
|
|
437
|
-
return { ...profile };
|
|
438
|
-
}
|
|
439
|
-
const parent = resolveProfileChain(profile.extends, profiles, visited, depth + 1);
|
|
440
|
-
return {
|
|
441
|
-
description: profile.description ?? parent.description,
|
|
442
|
-
default: profile.default ?? parent.default,
|
|
443
|
-
small: profile.small ?? parent.small,
|
|
444
|
-
agents: {
|
|
445
|
-
...parent.agents,
|
|
446
|
-
...profile.agents
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// src/utils/model-guidance.ts
|
|
452
|
-
function generateModelGuidanceMarkdown(resolved) {
|
|
453
|
-
if (!resolved.default && !resolved.small && Object.keys(resolved.agents).length === 0 && Object.keys(resolved.profiles).length === 0) {
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
const lines = [];
|
|
457
|
-
lines.push("# Model Configuration");
|
|
458
|
-
lines.push("");
|
|
459
|
-
lines.push("Use the following model preferences when working in this project.");
|
|
460
|
-
lines.push("");
|
|
461
|
-
if (resolved.default || resolved.small) {
|
|
462
|
-
lines.push("## Default Models");
|
|
463
|
-
lines.push("");
|
|
464
|
-
if (resolved.default) {
|
|
465
|
-
lines.push(`- **Primary model**: ${resolved.default}`);
|
|
466
|
-
}
|
|
467
|
-
if (resolved.small) {
|
|
468
|
-
lines.push(`- **Lightweight tasks** (titles, summaries): ${resolved.small}`);
|
|
469
|
-
}
|
|
470
|
-
lines.push("");
|
|
471
|
-
}
|
|
472
|
-
const agentEntries = Object.entries(resolved.agents);
|
|
473
|
-
if (agentEntries.length > 0) {
|
|
474
|
-
lines.push("## Agent Model Assignments");
|
|
475
|
-
lines.push("");
|
|
476
|
-
lines.push("| Agent | Model | Temperature |");
|
|
477
|
-
lines.push("| --- | --- | --- |");
|
|
478
|
-
for (const [name, assignment] of agentEntries) {
|
|
479
|
-
const temp = assignment.temperature !== undefined ? String(assignment.temperature) : "\u2014";
|
|
480
|
-
lines.push(`| ${name} | ${assignment.model} | ${temp} |`);
|
|
481
|
-
}
|
|
482
|
-
lines.push("");
|
|
483
|
-
}
|
|
484
|
-
if (Object.keys(resolved.profiles).length > 0) {
|
|
485
|
-
lines.push("## Available Profiles");
|
|
486
|
-
lines.push("");
|
|
487
|
-
lines.push("| Profile | Description | Default Model |");
|
|
488
|
-
lines.push("| --- | --- | --- |");
|
|
489
|
-
for (const [name, profile] of Object.entries(resolved.profiles)) {
|
|
490
|
-
lines.push(`| ${name} | ${profile.description ?? "\u2014"} | ${profile.default ?? "\u2014"} |`);
|
|
491
|
-
}
|
|
492
|
-
lines.push("");
|
|
493
|
-
}
|
|
494
|
-
if (resolved.activeProfile) {
|
|
495
|
-
lines.push(`**Active profile**: \`${resolved.activeProfile}\``);
|
|
496
|
-
lines.push("");
|
|
497
|
-
}
|
|
498
|
-
if (resolved.routing.length > 0) {
|
|
499
|
-
lines.push("## Task-Aware Routing");
|
|
500
|
-
lines.push("");
|
|
501
|
-
lines.push("Select the appropriate profile based on the task context:");
|
|
502
|
-
lines.push("");
|
|
503
|
-
lines.push("| Condition | Profile | Description |");
|
|
504
|
-
lines.push("| --- | --- | --- |");
|
|
505
|
-
for (const rule of resolved.routing) {
|
|
506
|
-
const conditions = Object.entries(rule.when).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
507
|
-
const desc = rule.description ?? "\u2014";
|
|
508
|
-
lines.push(`| ${conditions} | ${rule.use} | ${desc} |`);
|
|
509
|
-
}
|
|
510
|
-
lines.push("");
|
|
511
|
-
lines.push("### Condition Reference");
|
|
512
|
-
lines.push("");
|
|
513
|
-
lines.push("- **complexity**: low | medium | high | critical");
|
|
514
|
-
lines.push("- **urgency**: low | normal | high");
|
|
515
|
-
lines.push("- **budget**: minimal | standard | premium");
|
|
516
|
-
lines.push("- **contextWindowNeed**: small | medium | large | max");
|
|
517
|
-
lines.push("- **toolUseIntensity**: none | light | heavy");
|
|
518
|
-
lines.push("");
|
|
519
|
-
}
|
|
520
|
-
return lines.join(`
|
|
521
|
-
`);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// src/targets/base-target.ts
|
|
525
|
-
class BaseTarget {
|
|
526
|
-
supportsFeature(feature) {
|
|
527
|
-
return this.supportedFeatures.includes(feature);
|
|
528
|
-
}
|
|
529
|
-
getEffectiveFeatures(enabledFeatures) {
|
|
530
|
-
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
531
|
-
}
|
|
532
|
-
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
533
|
-
return {
|
|
534
|
-
targetId: this.id,
|
|
535
|
-
filesWritten,
|
|
536
|
-
filesDeleted,
|
|
537
|
-
warnings
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// src/targets/generic-md-target.ts
|
|
543
|
-
import { join as join4, resolve } from "path";
|
|
544
|
-
function createGenericMdTarget(config) {
|
|
545
|
-
return new GenericMdTarget(config);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
class GenericMdTarget extends BaseTarget {
|
|
549
|
-
id;
|
|
550
|
-
name;
|
|
551
|
-
supportedFeatures;
|
|
552
|
-
config;
|
|
553
|
-
constructor(config) {
|
|
554
|
-
super();
|
|
555
|
-
this.id = config.id;
|
|
556
|
-
this.name = config.name;
|
|
557
|
-
this.supportedFeatures = config.supportedFeatures;
|
|
558
|
-
this.config = config;
|
|
559
|
-
}
|
|
560
|
-
generate(options) {
|
|
561
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
562
|
-
const root = resolve(projectRoot, baseDir);
|
|
563
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
564
|
-
const filesWritten = [];
|
|
565
|
-
const filesDeleted = [];
|
|
566
|
-
const warnings = [];
|
|
567
|
-
const configDir = resolve(root, this.config.configDir);
|
|
568
|
-
const rulesSubDir = this.config.rulesDir ?? "rules";
|
|
569
|
-
const ext = this.config.ruleExtension ?? ".md";
|
|
570
|
-
if (effective.includes("rules")) {
|
|
571
|
-
const rulesDir = resolve(configDir, rulesSubDir);
|
|
572
|
-
if (deleteExisting) {
|
|
573
|
-
removeIfExists(rulesDir);
|
|
574
|
-
filesDeleted.push(rulesDir);
|
|
575
|
-
}
|
|
576
|
-
ensureDir(rulesDir);
|
|
577
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, this.id));
|
|
578
|
-
for (const rule of rules) {
|
|
579
|
-
const filepath = join4(rulesDir, `${rule.name}${ext}`);
|
|
580
|
-
writeGeneratedFile(filepath, rule.content);
|
|
581
|
-
filesWritten.push(filepath);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
if (effective.includes("commands")) {
|
|
585
|
-
const commandsDir = resolve(configDir, "commands");
|
|
586
|
-
if (deleteExisting) {
|
|
587
|
-
removeIfExists(commandsDir);
|
|
588
|
-
filesDeleted.push(commandsDir);
|
|
589
|
-
}
|
|
590
|
-
ensureDir(commandsDir);
|
|
591
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, this.id));
|
|
592
|
-
for (const cmd of commands) {
|
|
593
|
-
const filepath = join4(commandsDir, `${cmd.name}.md`);
|
|
594
|
-
writeGeneratedFile(filepath, cmd.content);
|
|
595
|
-
filesWritten.push(filepath);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
if (effective.includes("mcp")) {
|
|
599
|
-
const mcpEntries = Object.entries(features.mcpServers);
|
|
600
|
-
if (mcpEntries.length > 0) {
|
|
601
|
-
const mcpDir = this.config.mcpInConfigDir ? configDir : root;
|
|
602
|
-
const filepath = resolve(mcpDir, "mcp.json");
|
|
603
|
-
writeGeneratedJson(filepath, { mcpServers: features.mcpServers }, {
|
|
604
|
-
header: false
|
|
605
|
-
});
|
|
606
|
-
filesWritten.push(filepath);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
if (effective.includes("ignore") && this.config.ignoreFile) {
|
|
610
|
-
if (features.ignorePatterns.length > 0) {
|
|
611
|
-
const filepath = resolve(root, this.config.ignoreFile);
|
|
612
|
-
writeGeneratedFile(filepath, features.ignorePatterns.join(`
|
|
613
|
-
`) + `
|
|
614
|
-
`);
|
|
615
|
-
filesWritten.push(filepath);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
if (effective.includes("models") && features.models) {
|
|
619
|
-
const resolved = resolveModels(features.models, options.modelProfile, this.id);
|
|
620
|
-
const guidance = generateModelGuidanceMarkdown(resolved);
|
|
621
|
-
if (guidance) {
|
|
622
|
-
ensureDir(configDir);
|
|
623
|
-
const filepath = join4(configDir, "model-config.md");
|
|
624
|
-
writeGeneratedFile(filepath, guidance);
|
|
625
|
-
filesWritten.push(filepath);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
// src/targets/additional-targets.ts
|
|
633
|
-
var ClineTarget = createGenericMdTarget({
|
|
634
|
-
id: "cline",
|
|
635
|
-
name: "Cline",
|
|
636
|
-
configDir: ".cline",
|
|
637
|
-
supportedFeatures: ["rules", "commands", "mcp", "ignore"],
|
|
638
|
-
ignoreFile: ".clineignore",
|
|
639
|
-
mcpInConfigDir: true
|
|
640
|
-
});
|
|
641
|
-
var KiloTarget = createGenericMdTarget({
|
|
642
|
-
id: "kilo",
|
|
643
|
-
name: "Kilo Code",
|
|
644
|
-
configDir: ".kilo",
|
|
645
|
-
supportedFeatures: ["rules", "commands", "mcp", "ignore"],
|
|
646
|
-
ignoreFile: ".kiloignore",
|
|
647
|
-
mcpInConfigDir: true
|
|
648
|
-
});
|
|
649
|
-
var RooTarget = createGenericMdTarget({
|
|
650
|
-
id: "roo",
|
|
651
|
-
name: "Roo Code",
|
|
652
|
-
configDir: ".roo",
|
|
653
|
-
supportedFeatures: ["rules", "commands", "mcp", "ignore"],
|
|
654
|
-
ignoreFile: ".rooignore",
|
|
655
|
-
mcpInConfigDir: true
|
|
656
|
-
});
|
|
657
|
-
var QwenCodeTarget = createGenericMdTarget({
|
|
658
|
-
id: "qwencode",
|
|
659
|
-
name: "Qwen Code",
|
|
660
|
-
configDir: ".qwencode",
|
|
661
|
-
supportedFeatures: ["rules", "mcp", "ignore"],
|
|
662
|
-
ignoreFile: ".qwencodeignore",
|
|
663
|
-
mcpInConfigDir: true
|
|
664
|
-
});
|
|
665
|
-
var KiroTarget = createGenericMdTarget({
|
|
666
|
-
id: "kiro",
|
|
667
|
-
name: "Kiro",
|
|
668
|
-
configDir: ".kiro",
|
|
669
|
-
supportedFeatures: ["rules", "mcp"],
|
|
670
|
-
mcpInConfigDir: true
|
|
671
|
-
});
|
|
672
|
-
var FactoryDroidTarget = createGenericMdTarget({
|
|
673
|
-
id: "factorydroid",
|
|
674
|
-
name: "Factory Droid",
|
|
675
|
-
configDir: ".factorydroid",
|
|
676
|
-
supportedFeatures: ["rules", "mcp"],
|
|
677
|
-
mcpInConfigDir: true
|
|
678
|
-
});
|
|
679
|
-
var AntiGravityTarget = createGenericMdTarget({
|
|
680
|
-
id: "antigravity",
|
|
681
|
-
name: "AntiGravity",
|
|
682
|
-
configDir: ".antigravity",
|
|
683
|
-
supportedFeatures: ["rules", "mcp"],
|
|
684
|
-
mcpInConfigDir: true
|
|
685
|
-
});
|
|
686
|
-
var JunieTarget = createGenericMdTarget({
|
|
687
|
-
id: "junie",
|
|
688
|
-
name: "Junie",
|
|
689
|
-
configDir: ".junie",
|
|
690
|
-
supportedFeatures: ["rules", "mcp"],
|
|
691
|
-
mcpInConfigDir: true
|
|
692
|
-
});
|
|
693
|
-
var AugmentCodeTarget = createGenericMdTarget({
|
|
694
|
-
id: "augmentcode",
|
|
695
|
-
name: "Augment Code",
|
|
696
|
-
configDir: ".augmentcode",
|
|
697
|
-
supportedFeatures: ["rules", "mcp"],
|
|
698
|
-
mcpInConfigDir: true
|
|
699
|
-
});
|
|
700
|
-
var WindsurfTarget = createGenericMdTarget({
|
|
701
|
-
id: "windsurf",
|
|
702
|
-
name: "Windsurf",
|
|
703
|
-
configDir: ".windsurf",
|
|
704
|
-
supportedFeatures: ["rules", "mcp", "ignore"],
|
|
705
|
-
ignoreFile: ".windsurfignore",
|
|
706
|
-
mcpInConfigDir: true
|
|
707
|
-
});
|
|
708
|
-
var WarpTarget = createGenericMdTarget({
|
|
709
|
-
id: "warp",
|
|
710
|
-
name: "Warp",
|
|
711
|
-
configDir: ".warp",
|
|
712
|
-
supportedFeatures: ["rules"]
|
|
713
|
-
});
|
|
714
|
-
var ReplitTarget = createGenericMdTarget({
|
|
715
|
-
id: "replit",
|
|
716
|
-
name: "Replit Agent",
|
|
717
|
-
configDir: ".replit",
|
|
718
|
-
supportedFeatures: ["rules", "mcp"],
|
|
719
|
-
mcpInConfigDir: true
|
|
720
|
-
});
|
|
721
|
-
var ZedTarget = createGenericMdTarget({
|
|
722
|
-
id: "zed",
|
|
723
|
-
name: "Zed",
|
|
724
|
-
configDir: ".zed",
|
|
725
|
-
supportedFeatures: ["rules", "mcp"],
|
|
726
|
-
mcpInConfigDir: true
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
// src/targets/agents-md.ts
|
|
730
|
-
import { resolve as resolve2 } from "path";
|
|
731
|
-
class AgentsMdTarget extends BaseTarget {
|
|
732
|
-
id = "agentsmd";
|
|
733
|
-
name = "AGENTS.md";
|
|
734
|
-
supportedFeatures = ["rules"];
|
|
735
|
-
generate(options) {
|
|
736
|
-
const { projectRoot, baseDir, features } = options;
|
|
737
|
-
const root = resolve2(projectRoot, baseDir);
|
|
738
|
-
const filesWritten = [];
|
|
739
|
-
const warnings = [];
|
|
740
|
-
const rootRules = getRootRules(features.rules);
|
|
741
|
-
if (rootRules.length === 0) {
|
|
742
|
-
warnings.push("No root rules found. AGENTS.md will not be generated.");
|
|
743
|
-
return this.createResult(filesWritten, [], warnings);
|
|
744
|
-
}
|
|
745
|
-
const sections = rootRules.map((r) => r.content);
|
|
746
|
-
const content = sections.join(`
|
|
747
|
-
|
|
748
|
-
`);
|
|
749
|
-
const filepath = resolve2(root, "AGENTS.md");
|
|
750
|
-
writeGeneratedFile(filepath, content);
|
|
751
|
-
filesWritten.push(filepath);
|
|
752
|
-
return this.createResult(filesWritten, [], warnings);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
// src/targets/claude-code.ts
|
|
757
|
-
import { join as join5, resolve as resolve3 } from "path";
|
|
758
|
-
var TARGET_ID = "claudecode";
|
|
759
|
-
|
|
760
|
-
class ClaudeCodeTarget extends BaseTarget {
|
|
761
|
-
id = TARGET_ID;
|
|
762
|
-
name = "Claude Code";
|
|
763
|
-
supportedFeatures = [
|
|
764
|
-
"rules",
|
|
765
|
-
"commands",
|
|
766
|
-
"agents",
|
|
767
|
-
"skills",
|
|
768
|
-
"hooks",
|
|
769
|
-
"mcp",
|
|
770
|
-
"ignore",
|
|
771
|
-
"models"
|
|
772
|
-
];
|
|
773
|
-
generate(options) {
|
|
774
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
775
|
-
const root = resolve3(projectRoot, baseDir);
|
|
776
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
777
|
-
const filesWritten = [];
|
|
778
|
-
const filesDeleted = [];
|
|
779
|
-
const warnings = [];
|
|
780
|
-
const claudeDir = resolve3(root, ".claude");
|
|
781
|
-
if (effective.includes("rules")) {
|
|
782
|
-
const rulesDir = resolve3(claudeDir, "rules");
|
|
783
|
-
if (deleteExisting) {
|
|
784
|
-
removeIfExists(rulesDir);
|
|
785
|
-
filesDeleted.push(rulesDir);
|
|
786
|
-
}
|
|
787
|
-
ensureDir(rulesDir);
|
|
788
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID));
|
|
789
|
-
const rootRules = getRootRules(rules);
|
|
790
|
-
const detailRules = getDetailRules(rules);
|
|
791
|
-
if (rootRules.length > 0) {
|
|
792
|
-
const claudeMd = rootRules.map((r) => r.content).join(`
|
|
793
|
-
|
|
794
|
-
`);
|
|
795
|
-
const filepath = resolve3(claudeDir, "CLAUDE.md");
|
|
796
|
-
writeGeneratedFile(filepath, claudeMd);
|
|
797
|
-
filesWritten.push(filepath);
|
|
798
|
-
}
|
|
799
|
-
for (const rule of detailRules) {
|
|
800
|
-
const filepath = join5(rulesDir, `${rule.name}.md`);
|
|
801
|
-
writeGeneratedFile(filepath, rule.content);
|
|
802
|
-
filesWritten.push(filepath);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
if (effective.includes("agents")) {
|
|
806
|
-
const agentsDir = resolve3(claudeDir, "agents");
|
|
807
|
-
if (deleteExisting) {
|
|
808
|
-
removeIfExists(agentsDir);
|
|
809
|
-
filesDeleted.push(agentsDir);
|
|
810
|
-
}
|
|
811
|
-
ensureDir(agentsDir);
|
|
812
|
-
const resolvedModels = features.models ? resolveModels(features.models, options.modelProfile, TARGET_ID) : null;
|
|
813
|
-
const agents = features.agents.filter((a) => agentMatchesTarget(a, TARGET_ID));
|
|
814
|
-
for (const agent of agents) {
|
|
815
|
-
const filepath = join5(agentsDir, `${agent.name}.md`);
|
|
816
|
-
const cc = agent.meta.claudecode ?? {};
|
|
817
|
-
const modelsAgent = resolvedModels?.agents[agent.name];
|
|
818
|
-
const agentModel = modelsAgent?.model ?? cc.model;
|
|
819
|
-
let content = agent.content;
|
|
820
|
-
if (agentModel) {
|
|
821
|
-
content = `<!-- model: ${agentModel} -->
|
|
822
|
-
${content}`;
|
|
823
|
-
}
|
|
824
|
-
writeGeneratedFile(filepath, content);
|
|
825
|
-
filesWritten.push(filepath);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
if (effective.includes("skills")) {
|
|
829
|
-
const skillsDir = resolve3(claudeDir, "skills");
|
|
830
|
-
if (deleteExisting) {
|
|
831
|
-
removeIfExists(skillsDir);
|
|
832
|
-
filesDeleted.push(skillsDir);
|
|
833
|
-
}
|
|
834
|
-
ensureDir(skillsDir);
|
|
835
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID));
|
|
836
|
-
for (const skill of skills) {
|
|
837
|
-
const skillSubDir = join5(skillsDir, skill.name);
|
|
838
|
-
ensureDir(skillSubDir);
|
|
839
|
-
const filepath = join5(skillSubDir, "SKILL.md");
|
|
840
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
841
|
-
filesWritten.push(filepath);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
if (effective.includes("commands")) {
|
|
845
|
-
const commandsDir = resolve3(claudeDir, "commands");
|
|
846
|
-
if (deleteExisting) {
|
|
847
|
-
removeIfExists(commandsDir);
|
|
848
|
-
filesDeleted.push(commandsDir);
|
|
849
|
-
}
|
|
850
|
-
ensureDir(commandsDir);
|
|
851
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID));
|
|
852
|
-
for (const cmd of commands) {
|
|
853
|
-
const filepath = join5(commandsDir, `${cmd.name}.md`);
|
|
854
|
-
writeGeneratedFile(filepath, cmd.content);
|
|
855
|
-
filesWritten.push(filepath);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
if (effective.includes("models") && features.models) {
|
|
859
|
-
const resolved = resolveModels(features.models, options.modelProfile, TARGET_ID);
|
|
860
|
-
const guidance = generateModelGuidanceMarkdown(resolved);
|
|
861
|
-
if (guidance) {
|
|
862
|
-
const rulesDir = resolve3(claudeDir, "rules");
|
|
863
|
-
ensureDir(rulesDir);
|
|
864
|
-
const filepath = join5(rulesDir, "model-config.md");
|
|
865
|
-
writeGeneratedFile(filepath, guidance);
|
|
866
|
-
filesWritten.push(filepath);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
if (effective.includes("hooks") || effective.includes("mcp") || effective.includes("ignore")) {
|
|
870
|
-
const settings = buildClaudeSettings(options, effective);
|
|
871
|
-
if (Object.keys(settings).length > 0) {
|
|
872
|
-
const filepath = resolve3(claudeDir, "settings.json");
|
|
873
|
-
const existing = readJsonOrNull(filepath) ?? {};
|
|
874
|
-
const merged = { ...existing, ...settings };
|
|
875
|
-
writeGeneratedJson(filepath, merged, { header: false });
|
|
876
|
-
filesWritten.push(filepath);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
function buildClaudeSettings(options, effective) {
|
|
883
|
-
const settings = {};
|
|
884
|
-
if (effective.includes("hooks")) {
|
|
885
|
-
const allHookEntries = {};
|
|
886
|
-
for (const hookSet of options.features.hooks) {
|
|
887
|
-
const events = resolveHooksForTarget(hookSet, TARGET_ID);
|
|
888
|
-
for (const [event, entries] of Object.entries(events)) {
|
|
889
|
-
const pascalEvent = toPascalCase(event);
|
|
890
|
-
if (!allHookEntries[pascalEvent]) {
|
|
891
|
-
allHookEntries[pascalEvent] = [];
|
|
892
|
-
}
|
|
893
|
-
allHookEntries[pascalEvent].push(...entries.map((e) => ({
|
|
894
|
-
type: e.type ?? "command",
|
|
895
|
-
...e.matcher ? { matcher: e.matcher } : {},
|
|
896
|
-
command: e.command
|
|
897
|
-
})));
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
if (Object.keys(allHookEntries).length > 0) {
|
|
901
|
-
settings.hooks = allHookEntries;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
if (effective.includes("mcp")) {
|
|
905
|
-
const mcpEntries = Object.entries(options.features.mcpServers);
|
|
906
|
-
if (mcpEntries.length > 0) {
|
|
907
|
-
const mcpServers = {};
|
|
908
|
-
for (const [name, entry] of mcpEntries) {
|
|
909
|
-
if (entry.url) {
|
|
910
|
-
mcpServers[name] = { url: entry.url };
|
|
911
|
-
} else if (entry.command) {
|
|
912
|
-
mcpServers[name] = {
|
|
913
|
-
command: entry.command,
|
|
914
|
-
...entry.args ? { args: entry.args } : {},
|
|
915
|
-
...entry.env ? { env: entry.env } : {}
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
settings.mcpServers = mcpServers;
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
return settings;
|
|
923
|
-
}
|
|
924
|
-
function toPascalCase(str) {
|
|
925
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// src/targets/codex-cli.ts
|
|
929
|
-
import { join as join6, resolve as resolve4 } from "path";
|
|
930
|
-
var TARGET_ID2 = "codexcli";
|
|
931
|
-
|
|
932
|
-
class CodexCliTarget extends BaseTarget {
|
|
933
|
-
id = TARGET_ID2;
|
|
934
|
-
name = "Codex CLI";
|
|
935
|
-
supportedFeatures = ["rules", "skills", "mcp", "hooks"];
|
|
936
|
-
generate(options) {
|
|
937
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
938
|
-
const root = resolve4(projectRoot, baseDir);
|
|
939
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
940
|
-
const filesWritten = [];
|
|
941
|
-
const filesDeleted = [];
|
|
942
|
-
const warnings = [];
|
|
943
|
-
const codexDir = resolve4(root, ".codex");
|
|
944
|
-
if (effective.includes("rules")) {
|
|
945
|
-
const memoriesDir = resolve4(codexDir, "memories");
|
|
946
|
-
if (deleteExisting) {
|
|
947
|
-
removeIfExists(memoriesDir);
|
|
948
|
-
filesDeleted.push(memoriesDir);
|
|
949
|
-
}
|
|
950
|
-
ensureDir(memoriesDir);
|
|
951
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID2));
|
|
952
|
-
for (const rule of rules) {
|
|
953
|
-
const filepath = join6(memoriesDir, `${rule.name}.md`);
|
|
954
|
-
writeGeneratedFile(filepath, rule.content);
|
|
955
|
-
filesWritten.push(filepath);
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
if (effective.includes("skills")) {
|
|
959
|
-
const skillsDir = resolve4(codexDir, "skills");
|
|
960
|
-
if (deleteExisting) {
|
|
961
|
-
removeIfExists(skillsDir);
|
|
962
|
-
filesDeleted.push(skillsDir);
|
|
963
|
-
}
|
|
964
|
-
ensureDir(skillsDir);
|
|
965
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID2));
|
|
966
|
-
for (const skill of skills) {
|
|
967
|
-
const skillSubDir = join6(skillsDir, skill.name);
|
|
968
|
-
ensureDir(skillSubDir);
|
|
969
|
-
const filepath = join6(skillSubDir, "SKILL.md");
|
|
970
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
971
|
-
filesWritten.push(filepath);
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
// src/targets/copilot.ts
|
|
979
|
-
import { join as join7, resolve as resolve5 } from "path";
|
|
980
|
-
var TARGET_ID3 = "copilot";
|
|
981
|
-
|
|
982
|
-
class CopilotTarget extends BaseTarget {
|
|
983
|
-
id = TARGET_ID3;
|
|
984
|
-
name = "GitHub Copilot";
|
|
985
|
-
supportedFeatures = [
|
|
986
|
-
"rules",
|
|
987
|
-
"commands",
|
|
988
|
-
"agents",
|
|
989
|
-
"skills",
|
|
990
|
-
"mcp",
|
|
991
|
-
"ignore",
|
|
992
|
-
"models"
|
|
993
|
-
];
|
|
994
|
-
generate(options) {
|
|
995
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
996
|
-
const root = resolve5(projectRoot, baseDir);
|
|
997
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
998
|
-
const filesWritten = [];
|
|
999
|
-
const filesDeleted = [];
|
|
1000
|
-
const warnings = [];
|
|
1001
|
-
const githubDir = resolve5(root, ".github");
|
|
1002
|
-
if (effective.includes("rules")) {
|
|
1003
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID3));
|
|
1004
|
-
if (rules.length > 0) {
|
|
1005
|
-
const combinedContent = rules.map((r) => r.content).join(`
|
|
9
|
+
`),C=v(P,"CLAUDE.md");x(C,K),z.push(C)}for(let K of Z){let C=i(X,`${K.name}.md`);x(C,K.content),z.push(C)}}if(J.includes("agents")){let X=v(P,"agents");if(B)_(X),O.push(X);N(X);let V=Q.models?F(Q.models,q.modelProfile,m):null,U=Q.agents.filter((Z)=>E(Z,m));for(let Z of U){let K=i(X,`${Z.name}.md`),C=Z.meta.claudecode??{},A=V?.agents[Z.name]?.model??C.model,M=Z.content;if(A)M=`<!-- model: ${A} -->
|
|
10
|
+
${M}`;x(K,M),z.push(K)}}if(J.includes("skills")){let X=v(P,"skills");if(B)_(X),O.push(X);N(X);let V=Q.skills.filter((U)=>j(U,m));for(let U of V){let Z=i(X,U.name);N(Z);let K=i(Z,"SKILL.md");x(K,G(U)),z.push(K)}}if(J.includes("commands")){let X=v(P,"commands");if(B)_(X),O.push(X);N(X);let V=Q.commands.filter((U)=>y(U,m));for(let U of V){let Z=i(X,`${U.name}.md`);x(Z,U.content),z.push(Z)}}if(J.includes("models")&&Q.models){let X=F(Q.models,q.modelProfile,m),V=p(X);if(V){let U=v(P,"rules");N(U);let Z=i(U,"model-config.md");x(Z,V),z.push(Z)}}if(J.includes("hooks")||J.includes("mcp")||J.includes("ignore")){let X=w0(q,J);if(Object.keys(X).length>0){let V=v(P,"settings.json"),Z={...Zq(V)??{},...X};w(V,Z,{header:!1}),z.push(V)}}return this.createResult(z,O,S)}}function w0(q,$){let Y={};if($.includes("hooks")){let Q={};for(let L of q.features.hooks){let B=g(L,m);for(let[H,J]of Object.entries(B)){let z=I0(H);if(!Q[z])Q[z]=[];Q[z].push(...J.map((O)=>({type:O.type??"command",...O.matcher?{matcher:O.matcher}:{},command:O.command})))}}if(Object.keys(Q).length>0)Y.hooks=Q}if($.includes("mcp")){let Q=Object.entries(q.features.mcpServers);if(Q.length>0){let L={};for(let[B,H]of Q)if(H.url)L[B]={url:H.url};else if(H.command)L[B]={command:H.command,...H.args?{args:H.args}:{},...H.env?{env:H.env}:{}};Y.mcpServers=L}}return Y}function I0(q){return q.charAt(0).toUpperCase()+q.slice(1)}import{join as Pq,resolve as r}from"path";var Kq="codexcli";class Bq extends b{id=Kq;name="Codex CLI";supportedFeatures=["rules","skills","mcp","hooks"];generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=r($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=r(H,".codex");if(J.includes("rules")){let X=r(P,"memories");if(B)xq(X,O,S);N(X);let V=Q.rules.filter((U)=>I(U,Kq));for(let U of V){let Z=Pq(X,`${U.name}.md`);x(Z,U.content),z.push(Z)}}if(J.includes("skills")){let X=r(P,"skills");if(B)xq(X,O,S);N(X);let V=Q.skills.filter((U)=>j(U,Kq));for(let U of V){let Z=Pq(X,U.name);N(Z);let K=Pq(Z,"SKILL.md");x(K,G(U)),z.push(K)}}if(J.includes("hooks")){let X=r(P,"hooks.json");if(B)xq(X,O,S);let V={};for(let U of Q.hooks){let Z=g(U,Kq);for(let[K,C]of Object.entries(Z)){if(!V[K])V[K]=[];V[K].push(...C)}}if(Object.keys(V).length>0){let U=Q.hooks.find((Z)=>Z.version!==void 0)?.version??1;w(X,{version:U,hooks:V},{header:!1}),z.push(X)}}if(J.includes("mcp")){let X=Object.entries(Q.mcpServers);if(X.length>0){let V={};for(let[U,Z]of X)if(Z.url)V[U]={url:Z.url};else if(Z.command)V[U]={command:Z.command,...Z.args?{args:Z.args}:{},...Z.env?{env:Z.env}:{}};if(Object.keys(V).length>0){let U=r(P,"mcp.json");w(U,{mcpServers:V},{header:!1}),z.push(U)}}}return this.createResult(z,O,S)}}function xq(q,$,Y){try{_(q),$.push(q)}catch(Q){Y.push(`Could not remove ${q}: ${Q instanceof Error?Q.message:String(Q)}`)}}import{join as Uq,resolve as T}from"path";var t="copilot";class Lq extends b{id=t;name="GitHub Copilot";supportedFeatures=["rules","commands","agents","skills","mcp","ignore","models"];generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=T($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=T(H,".github");if(J.includes("rules")){let X=Q.rules.filter((V)=>I(V,t));if(X.length>0){let V=X.map((Z)=>Z.content).join(`
|
|
1006
11
|
|
|
1007
12
|
---
|
|
1008
13
|
|
|
1009
|
-
`);
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
filesWritten.push(filepath);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
if (effective.includes("agents")) {
|
|
1017
|
-
const copilotDir = resolve5(githubDir, "copilot");
|
|
1018
|
-
const agentsDir = resolve5(copilotDir, "agents");
|
|
1019
|
-
if (deleteExisting) {
|
|
1020
|
-
removeIfExists(agentsDir);
|
|
1021
|
-
filesDeleted.push(agentsDir);
|
|
1022
|
-
}
|
|
1023
|
-
ensureDir(agentsDir);
|
|
1024
|
-
const agents = features.agents.filter((a) => agentMatchesTarget(a, TARGET_ID3));
|
|
1025
|
-
for (const agent of agents) {
|
|
1026
|
-
const filepath = join7(agentsDir, `${agent.name}.md`);
|
|
1027
|
-
writeGeneratedFile(filepath, agent.content);
|
|
1028
|
-
filesWritten.push(filepath);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
if (effective.includes("skills")) {
|
|
1032
|
-
const copilotDir = resolve5(githubDir, "copilot");
|
|
1033
|
-
const skillsDir = resolve5(copilotDir, "skills");
|
|
1034
|
-
if (deleteExisting) {
|
|
1035
|
-
removeIfExists(skillsDir);
|
|
1036
|
-
filesDeleted.push(skillsDir);
|
|
1037
|
-
}
|
|
1038
|
-
ensureDir(skillsDir);
|
|
1039
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID3));
|
|
1040
|
-
for (const skill of skills) {
|
|
1041
|
-
const skillSubDir = join7(skillsDir, skill.name);
|
|
1042
|
-
ensureDir(skillSubDir);
|
|
1043
|
-
const filepath = join7(skillSubDir, "SKILL.md");
|
|
1044
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
1045
|
-
filesWritten.push(filepath);
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
if (effective.includes("commands")) {
|
|
1049
|
-
const copilotDir = resolve5(githubDir, "copilot");
|
|
1050
|
-
const commandsDir = resolve5(copilotDir, "commands");
|
|
1051
|
-
if (deleteExisting) {
|
|
1052
|
-
removeIfExists(commandsDir);
|
|
1053
|
-
filesDeleted.push(commandsDir);
|
|
1054
|
-
}
|
|
1055
|
-
ensureDir(commandsDir);
|
|
1056
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID3));
|
|
1057
|
-
for (const cmd of commands) {
|
|
1058
|
-
const filepath = join7(commandsDir, `${cmd.name}.md`);
|
|
1059
|
-
writeGeneratedFile(filepath, cmd.content);
|
|
1060
|
-
filesWritten.push(filepath);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
if (effective.includes("ignore")) {}
|
|
1064
|
-
if (effective.includes("models") && features.models) {
|
|
1065
|
-
const resolved = resolveModels(features.models, options.modelProfile, TARGET_ID3);
|
|
1066
|
-
const guidance = generateModelGuidanceMarkdown(resolved);
|
|
1067
|
-
if (guidance) {
|
|
1068
|
-
const copilotDir = resolve5(githubDir, "copilot");
|
|
1069
|
-
ensureDir(copilotDir);
|
|
1070
|
-
const filepath = join7(copilotDir, "model-config.md");
|
|
1071
|
-
writeGeneratedFile(filepath, guidance);
|
|
1072
|
-
filesWritten.push(filepath);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
14
|
+
`),U=T(P,"copilot-instructions.md");N(P),x(U,V),z.push(U)}}if(J.includes("agents")){let X=T(P,"copilot"),V=T(X,"agents");if(B)_(V),O.push(V);N(V);let U=Q.agents.filter((Z)=>E(Z,t));for(let Z of U){let K=Uq(V,`${Z.name}.md`);x(K,Z.content),z.push(K)}}if(J.includes("skills")){let X=T(P,"copilot"),V=T(X,"skills");if(B)_(V),O.push(V);N(V);let U=Q.skills.filter((Z)=>j(Z,t));for(let Z of U){let K=Uq(V,Z.name);N(K);let C=Uq(K,"SKILL.md");x(C,G(Z)),z.push(C)}}if(J.includes("commands")){let X=T(P,"copilot"),V=T(X,"commands");if(B)_(V),O.push(V);N(V);let U=Q.commands.filter((Z)=>y(Z,t));for(let Z of U){let K=Uq(V,`${Z.name}.md`);x(K,Z.content),z.push(K)}}if(J.includes("ignore"));if(J.includes("models")&&Q.models){let X=F(Q.models,q.modelProfile,t),V=p(X);if(V){let U=T(P,"copilot");N(U);let Z=Uq(U,"model-config.md");x(Z,V),z.push(Z)}}return this.createResult(z,O,S)}}import{join as e,resolve as k}from"path";var c="cursor";class Jq extends b{id=c;name="Cursor";supportedFeatures=["rules","commands","agents","skills","hooks","mcp","ignore","models"];generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=k($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=k(H,".cursor");if(J.includes("rules")){let X=k(P,"rules");if(B)_(X),O.push(X);N(X);let V=Q.rules.filter((U)=>I(U,c));for(let U of V){let Z=U.meta.cursor??{},K={description:Z.description??U.meta.description??"",alwaysApply:Z.alwaysApply??U.meta.root??!1},C=Z.globs??U.meta.globs;if(C)K.globs=C;let W=e(X,`${U.name}.mdc`),A=D(K,U.content);x(W,A),z.push(W)}}if(J.includes("agents")){let X=k(P,"agents");if(B)_(X),O.push(X);N(X);let V=Q.models?F(Q.models,q.modelProfile,c):null,U=Q.agents.filter((Z)=>E(Z,c));for(let Z of U){let K={name:Z.name,description:Z.meta.description??""},C=Z.meta.cursor??{},A=V?.agents[Z.name]?.model??C.model;if(A)K.model=A;let M=e(X,`${Z.name}.md`),Yq=D(K,Z.content);x(M,Yq),z.push(M)}}if(J.includes("skills")){let X=k(P,"skills");if(B)_(X),O.push(X);N(X);let V=Q.skills.filter((U)=>j(U,c));for(let U of V){let Z=e(X,U.name);N(Z);let K=e(Z,"SKILL.md"),C=G(U);x(K,C),z.push(K)}}if(J.includes("commands")){let X=k(P,"commands");if(B)_(X),O.push(X);N(X);let V=Q.commands.filter((U)=>y(U,c));for(let U of V){let Z=e(X,`${U.name}.md`);x(Z,U.content),z.push(Z)}}if(J.includes("hooks")){let X=k(P,"hooks.json");if(B)_(X),O.push(X);let V={};for(let U of Q.hooks){let Z=g(U,c);for(let[K,C]of Object.entries(Z)){if(!V[K])V[K]=[];V[K].push(...C)}}if(Object.keys(V).length>0){let U=Q.hooks.find((Z)=>Z.version!==void 0)?.version??1;w(X,{version:U,hooks:V},{header:!1}),z.push(X)}}if(J.includes("mcp")){if(Object.entries(Q.mcpServers).length>0){let V=F0(Q.mcpServers),U=k(P,"mcp.json");w(U,V,{header:!1}),z.push(U)}}if(J.includes("ignore")){if(Q.ignorePatterns.length>0){let X=k(H,".cursorignore"),V=Q.ignorePatterns.join(`
|
|
15
|
+
`)+`
|
|
16
|
+
`;x(X,V),z.push(X)}}if(J.includes("models")&&Q.models){let X=F(Q.models,q.modelProfile,c),V=y0(X);if(V){let U=k(P,"rules");N(U);let Z=e(U,"model-config.mdc");x(Z,V,{header:!1}),z.push(Z)}}return this.createResult(z,O,S)}}function F0(q){let $={};for(let[Y,Q]of Object.entries(q))if(Q.url)$[Y]={url:Q.url};else if(Q.command)$[Y]={command:Q.command,...Q.args?{args:Q.args}:{},...Q.env?{env:Q.env}:{}};return{mcpServers:$}}function y0(q){if(!q.default&&!q.small&&Object.keys(q.agents).length===0)return null;let $={description:"Model configuration and selection guidelines for this workspace",alwaysApply:!0},Y=[];if(Y.push("# Model Configuration"),Y.push(""),Y.push("Use the following model preferences when working in this project."),Y.push(""),q.default||q.small){if(Y.push("## Default Models"),Y.push(""),q.default)Y.push(`- **Primary model**: ${q.default}`);if(q.small)Y.push(`- **Lightweight tasks** (titles, summaries): ${q.small}`);Y.push("")}let Q=Object.entries(q.agents);if(Q.length>0){Y.push("## Agent Model Assignments"),Y.push(""),Y.push("| Agent | Model | Temperature |"),Y.push("| --- | --- | --- |");for(let[L,B]of Q){let H=B.temperature!==void 0?String(B.temperature):"\u2014";Y.push(`| ${L} | ${B.model} | ${H} |`)}Y.push("")}if(Object.keys(q.profiles).length>0){Y.push("## Available Profiles"),Y.push(""),Y.push("| Profile | Description | Default Model |"),Y.push("| --- | --- | --- |");for(let[L,B]of Object.entries(q.profiles))Y.push(`| ${L} | ${B.description??"\u2014"} | ${B.default??"\u2014"} |`);Y.push("")}if(q.activeProfile)Y.push(`**Active profile**: \`${q.activeProfile}\``),Y.push("");return D($,Y.join(`
|
|
17
|
+
`))}import{join as lq,resolve as n}from"path";var Nq="geminicli";class zq extends b{id=Nq;name="Gemini CLI";supportedFeatures=["rules","commands","mcp","ignore","skills","hooks"];generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=n($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=n(H,".gemini");if(J.includes("rules")){let X=Q.rules.filter((Z)=>I(Z,Nq)),V=Xq(X),U=l(X);if(V.length>0){let Z=V.map((C)=>C.content).join(`
|
|
1078
18
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
id = TARGET_ID4;
|
|
1085
|
-
name = "Cursor";
|
|
1086
|
-
supportedFeatures = [
|
|
1087
|
-
"rules",
|
|
1088
|
-
"commands",
|
|
1089
|
-
"agents",
|
|
1090
|
-
"skills",
|
|
1091
|
-
"hooks",
|
|
1092
|
-
"mcp",
|
|
1093
|
-
"ignore",
|
|
1094
|
-
"models"
|
|
1095
|
-
];
|
|
1096
|
-
generate(options) {
|
|
1097
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
1098
|
-
const root = resolve6(projectRoot, baseDir);
|
|
1099
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
1100
|
-
const filesWritten = [];
|
|
1101
|
-
const filesDeleted = [];
|
|
1102
|
-
const warnings = [];
|
|
1103
|
-
const cursorDir = resolve6(root, ".cursor");
|
|
1104
|
-
if (effective.includes("rules")) {
|
|
1105
|
-
const rulesDir = resolve6(cursorDir, "rules");
|
|
1106
|
-
if (deleteExisting) {
|
|
1107
|
-
removeIfExists(rulesDir);
|
|
1108
|
-
filesDeleted.push(rulesDir);
|
|
1109
|
-
}
|
|
1110
|
-
ensureDir(rulesDir);
|
|
1111
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID4));
|
|
1112
|
-
for (const rule of rules) {
|
|
1113
|
-
const cursorMeta = rule.meta.cursor ?? {};
|
|
1114
|
-
const frontmatter = {
|
|
1115
|
-
description: cursorMeta.description ?? rule.meta.description ?? "",
|
|
1116
|
-
alwaysApply: cursorMeta.alwaysApply ?? rule.meta.root ?? false
|
|
1117
|
-
};
|
|
1118
|
-
const globs = cursorMeta.globs ?? rule.meta.globs;
|
|
1119
|
-
if (globs) {
|
|
1120
|
-
frontmatter.globs = globs;
|
|
1121
|
-
}
|
|
1122
|
-
const filepath = join8(rulesDir, `${rule.name}.mdc`);
|
|
1123
|
-
const content = serializeFrontmatter(frontmatter, rule.content);
|
|
1124
|
-
writeGeneratedFile(filepath, content);
|
|
1125
|
-
filesWritten.push(filepath);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
if (effective.includes("agents")) {
|
|
1129
|
-
const agentsDir = resolve6(cursorDir, "agents");
|
|
1130
|
-
if (deleteExisting) {
|
|
1131
|
-
removeIfExists(agentsDir);
|
|
1132
|
-
filesDeleted.push(agentsDir);
|
|
1133
|
-
}
|
|
1134
|
-
ensureDir(agentsDir);
|
|
1135
|
-
const resolvedModels = features.models ? resolveModels(features.models, options.modelProfile, TARGET_ID4) : null;
|
|
1136
|
-
const agents = features.agents.filter((a) => agentMatchesTarget(a, TARGET_ID4));
|
|
1137
|
-
for (const agent of agents) {
|
|
1138
|
-
const frontmatter = {
|
|
1139
|
-
name: agent.name,
|
|
1140
|
-
description: agent.meta.description ?? ""
|
|
1141
|
-
};
|
|
1142
|
-
const cursorMeta = agent.meta.cursor ?? {};
|
|
1143
|
-
const modelsAgent = resolvedModels?.agents[agent.name];
|
|
1144
|
-
const model = modelsAgent?.model ?? cursorMeta.model;
|
|
1145
|
-
if (model) {
|
|
1146
|
-
frontmatter.model = model;
|
|
1147
|
-
}
|
|
1148
|
-
const filepath = join8(agentsDir, `${agent.name}.md`);
|
|
1149
|
-
const content = serializeFrontmatter(frontmatter, agent.content);
|
|
1150
|
-
writeGeneratedFile(filepath, content);
|
|
1151
|
-
filesWritten.push(filepath);
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
if (effective.includes("skills")) {
|
|
1155
|
-
const skillsDir = resolve6(cursorDir, "skills");
|
|
1156
|
-
if (deleteExisting) {
|
|
1157
|
-
removeIfExists(skillsDir);
|
|
1158
|
-
filesDeleted.push(skillsDir);
|
|
1159
|
-
}
|
|
1160
|
-
ensureDir(skillsDir);
|
|
1161
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID4));
|
|
1162
|
-
for (const skill of skills) {
|
|
1163
|
-
const skillSubDir = join8(skillsDir, skill.name);
|
|
1164
|
-
ensureDir(skillSubDir);
|
|
1165
|
-
const filepath = join8(skillSubDir, "SKILL.md");
|
|
1166
|
-
const content = serializeSkill(skill);
|
|
1167
|
-
writeGeneratedFile(filepath, content);
|
|
1168
|
-
filesWritten.push(filepath);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
if (effective.includes("commands")) {
|
|
1172
|
-
const commandsDir = resolve6(cursorDir, "commands");
|
|
1173
|
-
if (deleteExisting) {
|
|
1174
|
-
removeIfExists(commandsDir);
|
|
1175
|
-
filesDeleted.push(commandsDir);
|
|
1176
|
-
}
|
|
1177
|
-
ensureDir(commandsDir);
|
|
1178
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID4));
|
|
1179
|
-
for (const cmd of commands) {
|
|
1180
|
-
const filepath = join8(commandsDir, `${cmd.name}.md`);
|
|
1181
|
-
writeGeneratedFile(filepath, cmd.content);
|
|
1182
|
-
filesWritten.push(filepath);
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
if (effective.includes("hooks")) {
|
|
1186
|
-
const hooksFilepath = resolve6(cursorDir, "hooks.json");
|
|
1187
|
-
if (deleteExisting) {
|
|
1188
|
-
removeIfExists(hooksFilepath);
|
|
1189
|
-
filesDeleted.push(hooksFilepath);
|
|
1190
|
-
}
|
|
1191
|
-
const mergedHooks = {};
|
|
1192
|
-
for (const hookSet of features.hooks) {
|
|
1193
|
-
const events = resolveHooksForTarget(hookSet, TARGET_ID4);
|
|
1194
|
-
for (const [event, entries] of Object.entries(events)) {
|
|
1195
|
-
if (!mergedHooks[event]) {
|
|
1196
|
-
mergedHooks[event] = [];
|
|
1197
|
-
}
|
|
1198
|
-
mergedHooks[event].push(...entries);
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
if (Object.keys(mergedHooks).length > 0) {
|
|
1202
|
-
const hooksVersion = features.hooks.find((h) => h.version !== undefined)?.version ?? 1;
|
|
1203
|
-
writeGeneratedJson(hooksFilepath, { version: hooksVersion, hooks: mergedHooks }, { header: false });
|
|
1204
|
-
filesWritten.push(hooksFilepath);
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
if (effective.includes("mcp")) {
|
|
1208
|
-
const mcpEntries = Object.entries(features.mcpServers);
|
|
1209
|
-
if (mcpEntries.length > 0) {
|
|
1210
|
-
const mcpConfig = buildCursorMcp(features.mcpServers);
|
|
1211
|
-
const filepath = resolve6(cursorDir, "mcp.json");
|
|
1212
|
-
writeGeneratedJson(filepath, mcpConfig, { header: false });
|
|
1213
|
-
filesWritten.push(filepath);
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
if (effective.includes("ignore")) {
|
|
1217
|
-
if (features.ignorePatterns.length > 0) {
|
|
1218
|
-
const filepath = resolve6(root, ".cursorignore");
|
|
1219
|
-
const content = features.ignorePatterns.join(`
|
|
1220
|
-
`) + `
|
|
1221
|
-
`;
|
|
1222
|
-
writeGeneratedFile(filepath, content);
|
|
1223
|
-
filesWritten.push(filepath);
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
if (effective.includes("models") && features.models) {
|
|
1227
|
-
const resolved = resolveModels(features.models, options.modelProfile, TARGET_ID4);
|
|
1228
|
-
const guidanceContent = buildCursorModelGuidance(resolved);
|
|
1229
|
-
if (guidanceContent) {
|
|
1230
|
-
const rulesDir = resolve6(cursorDir, "rules");
|
|
1231
|
-
ensureDir(rulesDir);
|
|
1232
|
-
const filepath = join8(rulesDir, "model-config.mdc");
|
|
1233
|
-
writeGeneratedFile(filepath, guidanceContent, { header: false });
|
|
1234
|
-
filesWritten.push(filepath);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
function buildCursorMcp(servers) {
|
|
1241
|
-
const mcpServers = {};
|
|
1242
|
-
for (const [name, entry] of Object.entries(servers)) {
|
|
1243
|
-
if (entry.url) {
|
|
1244
|
-
mcpServers[name] = { url: entry.url };
|
|
1245
|
-
} else if (entry.command) {
|
|
1246
|
-
mcpServers[name] = {
|
|
1247
|
-
command: entry.command,
|
|
1248
|
-
...entry.args ? { args: entry.args } : {},
|
|
1249
|
-
...entry.env ? { env: entry.env } : {}
|
|
1250
|
-
};
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
return { mcpServers };
|
|
1254
|
-
}
|
|
1255
|
-
function buildCursorModelGuidance(resolved) {
|
|
1256
|
-
if (!resolved.default && !resolved.small && Object.keys(resolved.agents).length === 0) {
|
|
1257
|
-
return null;
|
|
1258
|
-
}
|
|
1259
|
-
const frontmatter = {
|
|
1260
|
-
description: "Model configuration and selection guidelines for this workspace",
|
|
1261
|
-
alwaysApply: true
|
|
1262
|
-
};
|
|
1263
|
-
const lines = [];
|
|
1264
|
-
lines.push("# Model Configuration");
|
|
1265
|
-
lines.push("");
|
|
1266
|
-
lines.push("Use the following model preferences when working in this project.");
|
|
1267
|
-
lines.push("");
|
|
1268
|
-
if (resolved.default || resolved.small) {
|
|
1269
|
-
lines.push("## Default Models");
|
|
1270
|
-
lines.push("");
|
|
1271
|
-
if (resolved.default) {
|
|
1272
|
-
lines.push(`- **Primary model**: ${resolved.default}`);
|
|
1273
|
-
}
|
|
1274
|
-
if (resolved.small) {
|
|
1275
|
-
lines.push(`- **Lightweight tasks** (titles, summaries): ${resolved.small}`);
|
|
1276
|
-
}
|
|
1277
|
-
lines.push("");
|
|
1278
|
-
}
|
|
1279
|
-
const agentEntries = Object.entries(resolved.agents);
|
|
1280
|
-
if (agentEntries.length > 0) {
|
|
1281
|
-
lines.push("## Agent Model Assignments");
|
|
1282
|
-
lines.push("");
|
|
1283
|
-
lines.push("| Agent | Model | Temperature |");
|
|
1284
|
-
lines.push("| --- | --- | --- |");
|
|
1285
|
-
for (const [name, assignment] of agentEntries) {
|
|
1286
|
-
const temp = assignment.temperature !== undefined ? String(assignment.temperature) : "\u2014";
|
|
1287
|
-
lines.push(`| ${name} | ${assignment.model} | ${temp} |`);
|
|
1288
|
-
}
|
|
1289
|
-
lines.push("");
|
|
1290
|
-
}
|
|
1291
|
-
if (Object.keys(resolved.profiles).length > 0) {
|
|
1292
|
-
lines.push("## Available Profiles");
|
|
1293
|
-
lines.push("");
|
|
1294
|
-
lines.push("| Profile | Description | Default Model |");
|
|
1295
|
-
lines.push("| --- | --- | --- |");
|
|
1296
|
-
for (const [name, profile] of Object.entries(resolved.profiles)) {
|
|
1297
|
-
lines.push(`| ${name} | ${profile.description ?? "\u2014"} | ${profile.default ?? "\u2014"} |`);
|
|
1298
|
-
}
|
|
1299
|
-
lines.push("");
|
|
1300
|
-
}
|
|
1301
|
-
if (resolved.activeProfile) {
|
|
1302
|
-
lines.push(`**Active profile**: \`${resolved.activeProfile}\``);
|
|
1303
|
-
lines.push("");
|
|
1304
|
-
}
|
|
1305
|
-
return serializeFrontmatter(frontmatter, lines.join(`
|
|
1306
|
-
`));
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
// src/targets/gemini-cli.ts
|
|
1310
|
-
import { join as join9, resolve as resolve7 } from "path";
|
|
1311
|
-
var TARGET_ID5 = "geminicli";
|
|
1312
|
-
|
|
1313
|
-
class GeminiCliTarget extends BaseTarget {
|
|
1314
|
-
id = TARGET_ID5;
|
|
1315
|
-
name = "Gemini CLI";
|
|
1316
|
-
supportedFeatures = [
|
|
1317
|
-
"rules",
|
|
1318
|
-
"commands",
|
|
1319
|
-
"mcp",
|
|
1320
|
-
"ignore",
|
|
1321
|
-
"skills",
|
|
1322
|
-
"hooks"
|
|
1323
|
-
];
|
|
1324
|
-
generate(options) {
|
|
1325
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
1326
|
-
const root = resolve7(projectRoot, baseDir);
|
|
1327
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
1328
|
-
const filesWritten = [];
|
|
1329
|
-
const filesDeleted = [];
|
|
1330
|
-
const warnings = [];
|
|
1331
|
-
const geminiDir = resolve7(root, ".gemini");
|
|
1332
|
-
if (effective.includes("rules")) {
|
|
1333
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID5));
|
|
1334
|
-
const rootRules = getRootRules(rules);
|
|
1335
|
-
const detailRules = getDetailRules(rules);
|
|
1336
|
-
if (rootRules.length > 0) {
|
|
1337
|
-
const geminiMd = rootRules.map((r) => r.content).join(`
|
|
1338
|
-
|
|
1339
|
-
`);
|
|
1340
|
-
const filepath = resolve7(root, "GEMINI.md");
|
|
1341
|
-
writeGeneratedFile(filepath, geminiMd);
|
|
1342
|
-
filesWritten.push(filepath);
|
|
1343
|
-
}
|
|
1344
|
-
if (detailRules.length > 0) {
|
|
1345
|
-
const memoriesDir = resolve7(geminiDir, "memories");
|
|
1346
|
-
if (deleteExisting) {
|
|
1347
|
-
removeIfExists(memoriesDir);
|
|
1348
|
-
filesDeleted.push(memoriesDir);
|
|
1349
|
-
}
|
|
1350
|
-
ensureDir(memoriesDir);
|
|
1351
|
-
for (const rule of detailRules) {
|
|
1352
|
-
const filepath = join9(memoriesDir, `${rule.name}.md`);
|
|
1353
|
-
writeGeneratedFile(filepath, rule.content);
|
|
1354
|
-
filesWritten.push(filepath);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
if (effective.includes("commands")) {
|
|
1359
|
-
const commandsDir = resolve7(geminiDir, "commands");
|
|
1360
|
-
if (deleteExisting) {
|
|
1361
|
-
removeIfExists(commandsDir);
|
|
1362
|
-
filesDeleted.push(commandsDir);
|
|
1363
|
-
}
|
|
1364
|
-
ensureDir(commandsDir);
|
|
1365
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID5));
|
|
1366
|
-
for (const cmd of commands) {
|
|
1367
|
-
const toml = buildGeminiCommand(cmd.name, cmd.meta.description ?? "", cmd.content);
|
|
1368
|
-
const filepath = join9(commandsDir, `${cmd.name}.toml`);
|
|
1369
|
-
writeGeneratedFile(filepath, toml, { type: "md" });
|
|
1370
|
-
filesWritten.push(filepath);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
if (effective.includes("mcp")) {
|
|
1374
|
-
const mcpEntries = Object.entries(features.mcpServers);
|
|
1375
|
-
if (mcpEntries.length > 0) {
|
|
1376
|
-
const settings = buildGeminiSettings(features.mcpServers);
|
|
1377
|
-
const filepath = resolve7(geminiDir, "settings.json");
|
|
1378
|
-
writeGeneratedJson(filepath, settings, { header: false });
|
|
1379
|
-
filesWritten.push(filepath);
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
if (effective.includes("ignore")) {
|
|
1383
|
-
if (features.ignorePatterns.length > 0) {
|
|
1384
|
-
const filepath = resolve7(root, ".geminiignore");
|
|
1385
|
-
const content = features.ignorePatterns.join(`
|
|
1386
|
-
`) + `
|
|
1387
|
-
`;
|
|
1388
|
-
writeGeneratedFile(filepath, content);
|
|
1389
|
-
filesWritten.push(filepath);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
function buildGeminiCommand(name, description, content) {
|
|
1396
|
-
return `[command]
|
|
1397
|
-
name = "${name}"
|
|
1398
|
-
description = "${description}"
|
|
19
|
+
`),K=n(H,"GEMINI.md");x(K,Z),z.push(K)}if(U.length>0){let Z=n(P,"memories");if(B)_(Z),O.push(Z);N(Z);for(let K of U){let C=lq(Z,`${K.name}.md`);x(C,K.content),z.push(C)}}}if(J.includes("commands")){let X=n(P,"commands");if(B)_(X),O.push(X);N(X);let V=Q.commands.filter((U)=>y(U,Nq));for(let U of V){let Z=R0(U.name,U.meta.description??"",U.content),K=lq(X,`${U.name}.toml`);x(K,Z,{type:"md"}),z.push(K)}}if(J.includes("mcp")){if(Object.entries(Q.mcpServers).length>0){let V=M0(Q.mcpServers),U=n(P,"settings.json");w(U,V,{header:!1}),z.push(U)}}if(J.includes("ignore")){if(Q.ignorePatterns.length>0){let X=n(H,".geminiignore"),V=Q.ignorePatterns.join(`
|
|
20
|
+
`)+`
|
|
21
|
+
`;x(X,V),z.push(X)}}return this.createResult(z,O,S)}}function R0(q,$,Y){return`[command]
|
|
22
|
+
name = "${q}"
|
|
23
|
+
description = "${$}"
|
|
1399
24
|
|
|
1400
25
|
[prompt]
|
|
1401
26
|
content = """
|
|
1402
|
-
${
|
|
27
|
+
${Y}
|
|
1403
28
|
"""
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
function
|
|
1407
|
-
|
|
1408
|
-
for (const [name, entry] of Object.entries(servers)) {
|
|
1409
|
-
if (entry.command) {
|
|
1410
|
-
mcpServers[name] = {
|
|
1411
|
-
command: entry.command,
|
|
1412
|
-
...entry.args ? { args: entry.args } : {},
|
|
1413
|
-
...entry.env ? { env: entry.env } : {}
|
|
1414
|
-
};
|
|
1415
|
-
} else if (entry.url) {
|
|
1416
|
-
mcpServers[name] = { url: entry.url };
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
return { mcpServers };
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
// src/targets/mistral-vibe.ts
|
|
1423
|
-
import { join as join10, resolve as resolve8 } from "path";
|
|
1424
|
-
var TARGET_ID6 = "mistralvibe";
|
|
1425
|
-
|
|
1426
|
-
class MistralVibeTarget extends BaseTarget {
|
|
1427
|
-
id = TARGET_ID6;
|
|
1428
|
-
name = "Mistral Vibe";
|
|
1429
|
-
supportedFeatures = [
|
|
1430
|
-
"rules",
|
|
1431
|
-
"commands",
|
|
1432
|
-
"agents",
|
|
1433
|
-
"skills",
|
|
1434
|
-
"mcp",
|
|
1435
|
-
"ignore",
|
|
1436
|
-
"models"
|
|
1437
|
-
];
|
|
1438
|
-
generate(options) {
|
|
1439
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
1440
|
-
const root = resolve8(projectRoot, baseDir);
|
|
1441
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
1442
|
-
const filesWritten = [];
|
|
1443
|
-
const filesDeleted = [];
|
|
1444
|
-
const warnings = [];
|
|
1445
|
-
const vibeDir = resolve8(root, ".vibe");
|
|
1446
|
-
ensureDir(vibeDir);
|
|
1447
|
-
if (effective.includes("rules")) {
|
|
1448
|
-
const rulesDir = resolve8(vibeDir, "rules");
|
|
1449
|
-
if (deleteExisting) {
|
|
1450
|
-
removeIfExists(rulesDir);
|
|
1451
|
-
filesDeleted.push(rulesDir);
|
|
1452
|
-
}
|
|
1453
|
-
ensureDir(rulesDir);
|
|
1454
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID6));
|
|
1455
|
-
for (const rule of rules) {
|
|
1456
|
-
const filepath = join10(rulesDir, `${rule.name}.md`);
|
|
1457
|
-
writeGeneratedFile(filepath, rule.content);
|
|
1458
|
-
filesWritten.push(filepath);
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
if (effective.includes("agents")) {
|
|
1462
|
-
const agentsDir = resolve8(vibeDir, "agents");
|
|
1463
|
-
if (deleteExisting) {
|
|
1464
|
-
removeIfExists(agentsDir);
|
|
1465
|
-
filesDeleted.push(agentsDir);
|
|
1466
|
-
}
|
|
1467
|
-
ensureDir(agentsDir);
|
|
1468
|
-
const agents = features.agents.filter((a) => agentMatchesTarget(a, TARGET_ID6));
|
|
1469
|
-
for (const agent of agents) {
|
|
1470
|
-
const filepath = join10(agentsDir, `${agent.name}.md`);
|
|
1471
|
-
writeGeneratedFile(filepath, agent.content);
|
|
1472
|
-
filesWritten.push(filepath);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
if (effective.includes("skills")) {
|
|
1476
|
-
const skillsDir = resolve8(vibeDir, "skills");
|
|
1477
|
-
if (deleteExisting) {
|
|
1478
|
-
removeIfExists(skillsDir);
|
|
1479
|
-
filesDeleted.push(skillsDir);
|
|
1480
|
-
}
|
|
1481
|
-
ensureDir(skillsDir);
|
|
1482
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID6));
|
|
1483
|
-
for (const skill of skills) {
|
|
1484
|
-
const skillSubDir = join10(skillsDir, skill.name);
|
|
1485
|
-
ensureDir(skillSubDir);
|
|
1486
|
-
const filepath = join10(skillSubDir, "SKILL.md");
|
|
1487
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
1488
|
-
filesWritten.push(filepath);
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
if (effective.includes("commands")) {
|
|
1492
|
-
const commandsDir = resolve8(vibeDir, "commands");
|
|
1493
|
-
if (deleteExisting) {
|
|
1494
|
-
removeIfExists(commandsDir);
|
|
1495
|
-
filesDeleted.push(commandsDir);
|
|
1496
|
-
}
|
|
1497
|
-
ensureDir(commandsDir);
|
|
1498
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID6));
|
|
1499
|
-
for (const command of commands) {
|
|
1500
|
-
const filepath = join10(commandsDir, `${command.name}.md`);
|
|
1501
|
-
writeGeneratedFile(filepath, command.content);
|
|
1502
|
-
filesWritten.push(filepath);
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
let hasMcpConfig = false;
|
|
1506
|
-
if (effective.includes("mcp")) {
|
|
1507
|
-
const mcpEntries = Object.entries(features.mcpServers);
|
|
1508
|
-
if (mcpEntries.length > 0) {
|
|
1509
|
-
const filepath = resolve8(vibeDir, "mcp.json");
|
|
1510
|
-
writeGeneratedJson(filepath, { mcpServers: features.mcpServers }, {
|
|
1511
|
-
header: false
|
|
1512
|
-
});
|
|
1513
|
-
filesWritten.push(filepath);
|
|
1514
|
-
hasMcpConfig = true;
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
if (effective.includes("ignore") && features.ignorePatterns.length > 0) {
|
|
1518
|
-
const filepath = resolve8(root, ".vibeignore");
|
|
1519
|
-
writeGeneratedFile(filepath, features.ignorePatterns.join(`
|
|
1520
|
-
`) + `
|
|
1521
|
-
`);
|
|
1522
|
-
filesWritten.push(filepath);
|
|
1523
|
-
}
|
|
1524
|
-
let defaultModel;
|
|
1525
|
-
let smallModel;
|
|
1526
|
-
if (effective.includes("models") && features.models) {
|
|
1527
|
-
const resolved = resolveModels(features.models, options.modelProfile, TARGET_ID6);
|
|
1528
|
-
defaultModel = resolved.default;
|
|
1529
|
-
smallModel = resolved.small;
|
|
1530
|
-
const guidance = generateModelGuidanceMarkdown(resolved);
|
|
1531
|
-
if (guidance) {
|
|
1532
|
-
const filepath = join10(vibeDir, "model-config.md");
|
|
1533
|
-
writeGeneratedFile(filepath, guidance);
|
|
1534
|
-
filesWritten.push(filepath);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
const vibeConfig = buildVibeConfigToml({
|
|
1538
|
-
hasMcpConfig,
|
|
1539
|
-
defaultModel,
|
|
1540
|
-
smallModel,
|
|
1541
|
-
profile: options.modelProfile
|
|
1542
|
-
});
|
|
1543
|
-
if (vibeConfig.length > 0) {
|
|
1544
|
-
const filepath = resolve8(vibeDir, "config.toml");
|
|
1545
|
-
writeGeneratedFile(filepath, vibeConfig);
|
|
1546
|
-
filesWritten.push(filepath);
|
|
1547
|
-
}
|
|
1548
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
function buildVibeConfigToml(options) {
|
|
1552
|
-
const lines = [];
|
|
1553
|
-
if (options.defaultModel || options.smallModel || options.profile) {
|
|
1554
|
-
lines.push("[models]");
|
|
1555
|
-
if (options.defaultModel) {
|
|
1556
|
-
lines.push(`default = "${escapeTomlString(options.defaultModel)}"`);
|
|
1557
|
-
}
|
|
1558
|
-
if (options.smallModel) {
|
|
1559
|
-
lines.push(`small = "${escapeTomlString(options.smallModel)}"`);
|
|
1560
|
-
}
|
|
1561
|
-
if (options.profile) {
|
|
1562
|
-
lines.push(`profile = "${escapeTomlString(options.profile)}"`);
|
|
1563
|
-
}
|
|
1564
|
-
lines.push("");
|
|
1565
|
-
}
|
|
1566
|
-
if (options.hasMcpConfig) {
|
|
1567
|
-
lines.push("[mcp]");
|
|
1568
|
-
lines.push('config_path = ".vibe/mcp.json"');
|
|
1569
|
-
lines.push("");
|
|
1570
|
-
}
|
|
1571
|
-
return lines.join(`
|
|
1572
|
-
`).trim();
|
|
1573
|
-
}
|
|
1574
|
-
function escapeTomlString(value) {
|
|
1575
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
// src/utils/markdown.ts
|
|
1579
|
-
function stripGeneratedHeader(content) {
|
|
1580
|
-
return content.replace(/^<!-- Generated by agentpacks.*-->\n/, "").replace(/^\/\/ Generated by agentpacks.*\n/, "");
|
|
1581
|
-
}
|
|
1582
|
-
function packNameToIdentifier(packName) {
|
|
1583
|
-
return packName.split(/[-_.]/).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
1584
|
-
}
|
|
1585
|
-
function extractFirstHeading(content) {
|
|
1586
|
-
const match = content.match(/^#{1,6}\s+(.+)$/m);
|
|
1587
|
-
return match?.[1]?.trim() ?? null;
|
|
1588
|
-
}
|
|
1589
|
-
function combineMarkdown(sections, separator = `
|
|
29
|
+
`}function M0(q){let $={};for(let[Y,Q]of Object.entries(q))if(Q.command)$[Y]={command:Q.command,...Q.args?{args:Q.args}:{},...Q.env?{env:Q.env}:{}};else if(Q.url)$[Y]={url:Q.url};return{mcpServers:$}}import{join as qq,resolve as u}from"path";var $q="mistralvibe";class Oq extends b{id=$q;name="Mistral Vibe";supportedFeatures=["rules","commands","agents","skills","mcp","ignore","models"];generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=u($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=u(H,".vibe");if(N(P),J.includes("rules")){let K=u(P,"rules");if(B)_(K),O.push(K);N(K);let C=Q.rules.filter((W)=>I(W,$q));for(let W of C){let A=qq(K,`${W.name}.md`);x(A,W.content),z.push(A)}}if(J.includes("agents")){let K=u(P,"agents");if(B)_(K),O.push(K);N(K);let C=Q.agents.filter((W)=>E(W,$q));for(let W of C){let A=qq(K,`${W.name}.md`);x(A,W.content),z.push(A)}}if(J.includes("skills")){let K=u(P,"skills");if(B)_(K),O.push(K);N(K);let C=Q.skills.filter((W)=>j(W,$q));for(let W of C){let A=qq(K,W.name);N(A);let M=qq(A,"SKILL.md");x(M,G(W)),z.push(M)}}if(J.includes("commands")){let K=u(P,"commands");if(B)_(K),O.push(K);N(K);let C=Q.commands.filter((W)=>y(W,$q));for(let W of C){let A=qq(K,`${W.name}.md`);x(A,W.content),z.push(A)}}let X=!1;if(J.includes("mcp")){if(Object.entries(Q.mcpServers).length>0){let C=u(P,"mcp.json");w(C,{mcpServers:Q.mcpServers},{header:!1}),z.push(C),X=!0}}if(J.includes("ignore")&&Q.ignorePatterns.length>0){let K=u(H,".vibeignore");x(K,Q.ignorePatterns.join(`
|
|
30
|
+
`)+`
|
|
31
|
+
`),z.push(K)}let V,U;if(J.includes("models")&&Q.models){let K=F(Q.models,q.modelProfile,$q);V=K.default,U=K.small;let C=p(K);if(C){let W=qq(P,"model-config.md");x(W,C),z.push(W)}}let Z=G0({hasMcpConfig:X,defaultModel:V,smallModel:U,profile:q.modelProfile});if(Z.length>0){let K=u(P,"config.toml");x(K,Z),z.push(K)}return this.createResult(z,O,S)}}function G0(q){let $=[];if(q.defaultModel||q.smallModel||q.profile){if($.push("[models]"),q.defaultModel)$.push(`default = "${Wq(q.defaultModel)}"`);if(q.smallModel)$.push(`small = "${Wq(q.smallModel)}"`);if(q.profile)$.push(`profile = "${Wq(q.profile)}"`);$.push("")}if(q.hasMcpConfig)$.push("[mcp]"),$.push('config_path = ".vibe/mcp.json"'),$.push("");return $.join(`
|
|
32
|
+
`).trim()}function Wq(q){return q.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}function u2(q){return q.replace(/^<!-- Generated by agentpacks.*-->\n/,"").replace(/^\/\/ Generated by agentpacks.*\n/,"")}function sq(q){return q.split(/[-_.]/).filter(($)=>$.length>0).map(($)=>$.charAt(0).toUpperCase()+$.slice(1)).join("")}function g2(q){return q.match(/^#{1,6}\s+(.+)$/m)?.[1]?.trim()??null}function p2(q,$=`
|
|
1590
33
|
|
|
1591
34
|
---
|
|
1592
35
|
|
|
1593
|
-
`) {
|
|
1594
|
-
return sections.filter(Boolean).join(separator);
|
|
1595
|
-
}
|
|
1596
|
-
function wrapSection(heading, content, level = 2) {
|
|
1597
|
-
const prefix = "#".repeat(level);
|
|
1598
|
-
return `${prefix} ${heading}
|
|
1599
|
-
|
|
1600
|
-
${content}`;
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
// src/targets/opencode.ts
|
|
1604
|
-
import { join as join11, resolve as resolve9 } from "path";
|
|
1605
|
-
var TARGET_ID7 = "opencode";
|
|
36
|
+
`){return q.filter(Boolean).join($)}function m2(q,$,Y=2){return`${"#".repeat(Y)} ${q}
|
|
1606
37
|
|
|
1607
|
-
class
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
"agents",
|
|
1614
|
-
"skills",
|
|
1615
|
-
"hooks",
|
|
1616
|
-
"plugins",
|
|
1617
|
-
"mcp",
|
|
1618
|
-
"ignore",
|
|
1619
|
-
"models"
|
|
1620
|
-
];
|
|
1621
|
-
generate(options) {
|
|
1622
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
1623
|
-
const root = resolve9(projectRoot, baseDir);
|
|
1624
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
1625
|
-
const filesWritten = [];
|
|
1626
|
-
const filesDeleted = [];
|
|
1627
|
-
const warnings = [];
|
|
1628
|
-
const opencodeDir = resolve9(root, ".opencode");
|
|
1629
|
-
if (effective.includes("agents")) {
|
|
1630
|
-
const agentDir = resolve9(opencodeDir, "agent");
|
|
1631
|
-
if (deleteExisting) {
|
|
1632
|
-
removeIfExists(agentDir);
|
|
1633
|
-
filesDeleted.push(agentDir);
|
|
1634
|
-
}
|
|
1635
|
-
ensureDir(agentDir);
|
|
1636
|
-
const resolvedModels = features.models ? resolveModels(features.models, options.modelProfile, TARGET_ID7) : null;
|
|
1637
|
-
const agents = features.agents.filter((a) => agentMatchesTarget(a, TARGET_ID7));
|
|
1638
|
-
for (const agent of agents) {
|
|
1639
|
-
const filepath = join11(agentDir, `${agent.name}.md`);
|
|
1640
|
-
const fm = {};
|
|
1641
|
-
const oc = agent.meta.opencode ?? {};
|
|
1642
|
-
const modelsAgent = resolvedModels?.agents[agent.name];
|
|
1643
|
-
const agentModel = modelsAgent?.model ?? oc.model;
|
|
1644
|
-
const agentTemp = modelsAgent?.temperature ?? oc.temperature;
|
|
1645
|
-
if (agentModel)
|
|
1646
|
-
fm.model = agentModel;
|
|
1647
|
-
if (agentTemp !== undefined)
|
|
1648
|
-
fm.temperature = agentTemp;
|
|
1649
|
-
if (oc.mode)
|
|
1650
|
-
fm.mode = oc.mode;
|
|
1651
|
-
if (oc.top_p !== undefined)
|
|
1652
|
-
fm.top_p = oc.top_p;
|
|
1653
|
-
const content = Object.keys(fm).length > 0 ? serializeFrontmatter(fm, agent.content) : agent.content;
|
|
1654
|
-
writeGeneratedFile(filepath, content);
|
|
1655
|
-
filesWritten.push(filepath);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
if (effective.includes("skills")) {
|
|
1659
|
-
const skillDir = resolve9(opencodeDir, "skill");
|
|
1660
|
-
if (deleteExisting) {
|
|
1661
|
-
removeIfExists(skillDir);
|
|
1662
|
-
filesDeleted.push(skillDir);
|
|
1663
|
-
}
|
|
1664
|
-
ensureDir(skillDir);
|
|
1665
|
-
const skills = features.skills.filter((s) => skillMatchesTarget(s, TARGET_ID7));
|
|
1666
|
-
for (const skill of skills) {
|
|
1667
|
-
const skillSubDir = join11(skillDir, skill.name);
|
|
1668
|
-
ensureDir(skillSubDir);
|
|
1669
|
-
const filepath = join11(skillSubDir, "SKILL.md");
|
|
1670
|
-
writeGeneratedFile(filepath, serializeSkill(skill));
|
|
1671
|
-
filesWritten.push(filepath);
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
if (effective.includes("commands")) {
|
|
1675
|
-
const cmdDir = resolve9(opencodeDir, "command");
|
|
1676
|
-
if (deleteExisting) {
|
|
1677
|
-
removeIfExists(cmdDir);
|
|
1678
|
-
filesDeleted.push(cmdDir);
|
|
1679
|
-
}
|
|
1680
|
-
ensureDir(cmdDir);
|
|
1681
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID7));
|
|
1682
|
-
for (const cmd of commands) {
|
|
1683
|
-
const filepath = join11(cmdDir, `${cmd.name}.md`);
|
|
1684
|
-
writeGeneratedFile(filepath, cmd.content);
|
|
1685
|
-
filesWritten.push(filepath);
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
if (effective.includes("hooks") || effective.includes("plugins")) {
|
|
1689
|
-
const pluginsDir = resolve9(opencodeDir, "plugins");
|
|
1690
|
-
ensureDir(pluginsDir);
|
|
1691
|
-
if (effective.includes("hooks")) {
|
|
1692
|
-
for (const hookSet of features.hooks) {
|
|
1693
|
-
const events = resolveHooksForTarget(hookSet, TARGET_ID7);
|
|
1694
|
-
if (Object.keys(events).length > 0) {
|
|
1695
|
-
const filepath = join11(pluginsDir, `agentpacks-${hookSet.packName}.ts`);
|
|
1696
|
-
const content = generateOpenCodeHookPlugin(hookSet.packName, events);
|
|
1697
|
-
writeGeneratedFile(filepath, content, { type: "ts" });
|
|
1698
|
-
filesWritten.push(filepath);
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
if (effective.includes("plugins")) {
|
|
1703
|
-
for (const plugin of features.plugins) {
|
|
1704
|
-
const filepath = join11(pluginsDir, `agentpacks-${plugin.packName}-${plugin.name}.${plugin.extension}`);
|
|
1705
|
-
writeGeneratedFile(filepath, plugin.content, {
|
|
1706
|
-
type: plugin.extension
|
|
1707
|
-
});
|
|
1708
|
-
filesWritten.push(filepath);
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
if (effective.includes("mcp") || effective.includes("models")) {
|
|
1713
|
-
const filepath = resolve9(root, "opencode.json");
|
|
1714
|
-
const opencodeConfig = {
|
|
1715
|
-
$schema: "https://opencode.ai/config.json"
|
|
1716
|
-
};
|
|
1717
|
-
if (effective.includes("mcp")) {
|
|
1718
|
-
const mcpEntries = Object.entries(features.mcpServers);
|
|
1719
|
-
if (mcpEntries.length > 0) {
|
|
1720
|
-
opencodeConfig.mcp = buildOpenCodeMcpServers(features.mcpServers);
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
if (effective.includes("models") && features.models) {
|
|
1724
|
-
const resolved = resolveModels(features.models, options.modelProfile, TARGET_ID7);
|
|
1725
|
-
if (resolved.default)
|
|
1726
|
-
opencodeConfig.model = resolved.default;
|
|
1727
|
-
if (resolved.small)
|
|
1728
|
-
opencodeConfig.small_model = resolved.small;
|
|
1729
|
-
if (Object.keys(resolved.providers).length > 0) {
|
|
1730
|
-
opencodeConfig.provider = resolved.providers;
|
|
1731
|
-
}
|
|
1732
|
-
const agentEntries = Object.entries(resolved.agents);
|
|
1733
|
-
if (agentEntries.length > 0) {
|
|
1734
|
-
const agentConfig = {};
|
|
1735
|
-
for (const [name, assignment] of agentEntries) {
|
|
1736
|
-
const config = { model: assignment.model };
|
|
1737
|
-
if (assignment.temperature !== undefined) {
|
|
1738
|
-
config.temperature = assignment.temperature;
|
|
1739
|
-
}
|
|
1740
|
-
if (assignment.top_p !== undefined) {
|
|
1741
|
-
config.top_p = assignment.top_p;
|
|
1742
|
-
}
|
|
1743
|
-
agentConfig[name] = config;
|
|
1744
|
-
}
|
|
1745
|
-
opencodeConfig.agent = agentConfig;
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
if (Object.keys(opencodeConfig).length > 1) {
|
|
1749
|
-
writeGeneratedJson(filepath, opencodeConfig, { header: false });
|
|
1750
|
-
filesWritten.push(filepath);
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
if (effective.includes("rules")) {
|
|
1754
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID7));
|
|
1755
|
-
const detailRules = getDetailRules(rules);
|
|
1756
|
-
if (detailRules.length > 0) {
|
|
1757
|
-
const memoriesDir = resolve9(opencodeDir, "memories");
|
|
1758
|
-
if (deleteExisting) {
|
|
1759
|
-
removeIfExists(memoriesDir);
|
|
1760
|
-
filesDeleted.push(memoriesDir);
|
|
1761
|
-
}
|
|
1762
|
-
ensureDir(memoriesDir);
|
|
1763
|
-
for (const rule of detailRules) {
|
|
1764
|
-
const filepath = join11(memoriesDir, `${rule.name}.md`);
|
|
1765
|
-
writeGeneratedFile(filepath, rule.content);
|
|
1766
|
-
filesWritten.push(filepath);
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
function buildOpenCodeMcpServers(servers) {
|
|
1774
|
-
const mcp = {};
|
|
1775
|
-
for (const [name, entry] of Object.entries(servers)) {
|
|
1776
|
-
if (entry.url) {
|
|
1777
|
-
mcp[name] = {
|
|
1778
|
-
type: "remote",
|
|
1779
|
-
url: entry.url,
|
|
1780
|
-
enabled: true,
|
|
1781
|
-
...entry.headers && Object.keys(entry.headers).length > 0 ? { headers: entry.headers } : {}
|
|
1782
|
-
};
|
|
1783
|
-
} else if (entry.command) {
|
|
1784
|
-
const cmd = entry.args ? [entry.command, ...entry.args] : [entry.command];
|
|
1785
|
-
mcp[name] = {
|
|
1786
|
-
type: "local",
|
|
1787
|
-
command: cmd,
|
|
1788
|
-
enabled: true,
|
|
1789
|
-
...entry.env && Object.keys(entry.env).length > 0 ? { environment: entry.env } : {}
|
|
1790
|
-
};
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
return mcp;
|
|
1794
|
-
}
|
|
1795
|
-
function generateOpenCodeHookPlugin(packName, events) {
|
|
1796
|
-
const identifier = packNameToIdentifier(packName);
|
|
1797
|
-
const hookMap = mapHookEvents(events);
|
|
1798
|
-
const hookEntries = Object.entries(hookMap).map(([event, handlers]) => {
|
|
1799
|
-
const body = handlers.map((h) => {
|
|
1800
|
-
const matcherGuard = h.matcher ? `if (!/(?:${h.matcher})/.test(String(input?.tool ?? ""))) return;
|
|
1801
|
-
` : "";
|
|
1802
|
-
return ` ${matcherGuard}await $\`${h.command}\`;`;
|
|
1803
|
-
}).join(`
|
|
1804
|
-
`);
|
|
1805
|
-
return ` "${event}": async (input, output) => {
|
|
1806
|
-
${body}
|
|
1807
|
-
},`;
|
|
1808
|
-
}).join(`
|
|
1809
|
-
`);
|
|
1810
|
-
return `import type { Plugin } from "@opencode-ai/plugin";
|
|
38
|
+
${$}`}import{join as a,resolve as f}from"path";var d="opencode";class Hq extends b{id=d;name="OpenCode";supportedFeatures=["rules","commands","agents","skills","hooks","plugins","mcp","ignore","models"];generate(q){let{projectRoot:$,baseDir:Y,features:Q,enabledFeatures:L,deleteExisting:B}=q,H=f($,Y),J=this.getEffectiveFeatures(L),z=[],O=[],S=[],P=f(H,".opencode");if(J.includes("agents")){let X=f(P,"agent");if(B)_(X),O.push(X);N(X);let V=Q.models?F(Q.models,q.modelProfile,d):null,U=Q.agents.filter((Z)=>E(Z,d));for(let Z of U){let K=a(X,`${Z.name}.md`),C={},W=Z.meta.opencode??{},A=V?.agents[Z.name],M=A?.model??W.model,Yq=A?.temperature??W.temperature;if(M)C.model=M;if(Yq!==void 0)C.temperature=Yq;if(W.mode)C.mode=W.mode;if(W.top_p!==void 0)C.top_p=W.top_p;let rq=Object.keys(C).length>0?D(C,Z.content):Z.content;x(K,rq),z.push(K)}}if(J.includes("skills")){let X=f(P,"skill");if(B)_(X),O.push(X);N(X);let V=Q.skills.filter((U)=>j(U,d));for(let U of V){let Z=a(X,U.name);N(Z);let K=a(Z,"SKILL.md");x(K,G(U)),z.push(K)}}if(J.includes("commands")){let X=f(P,"command");if(B)_(X),O.push(X);N(X);let V=Q.commands.filter((U)=>y(U,d));for(let U of V){let Z=a(X,`${U.name}.md`);x(Z,U.content),z.push(Z)}}if(J.includes("hooks")||J.includes("plugins")){let X=f(P,"plugins");if(N(X),J.includes("hooks"))for(let V of Q.hooks){let U=g(V,d);if(Object.keys(U).length>0){let Z=a(X,`agentpacks-${V.packName}.ts`),K=E0(V.packName,U);x(Z,K,{type:"ts"}),z.push(Z)}}if(J.includes("plugins"))for(let V of Q.plugins){let U=a(X,`agentpacks-${V.packName}-${V.name}.${V.extension}`);x(U,V.content,{type:V.extension}),z.push(U)}}if(J.includes("mcp")||J.includes("models")){let X=f(H,"opencode.json"),V={$schema:"https://opencode.ai/config.json"};if(J.includes("mcp")){if(Object.entries(Q.mcpServers).length>0)V.mcp=j0(Q.mcpServers)}if(J.includes("models")&&Q.models){let U=F(Q.models,q.modelProfile,d);if(U.default)V.model=U.default;if(U.small)V.small_model=U.small;if(Object.keys(U.providers).length>0)V.provider=U.providers;let Z=Object.entries(U.agents);if(Z.length>0){let K={};for(let[C,W]of Z){let A={model:W.model};if(W.temperature!==void 0)A.temperature=W.temperature;if(W.top_p!==void 0)A.top_p=W.top_p;K[C]=A}V.agent=K}}if(Object.keys(V).length>1)w(X,V,{header:!1}),z.push(X)}if(J.includes("rules")){let X=Q.rules.filter((U)=>I(U,d)),V=l(X);if(V.length>0){let U=f(P,"memories");if(B)_(U),O.push(U);N(U);for(let Z of V){let K=a(U,`${Z.name}.md`);x(K,Z.content),z.push(K)}}}return this.createResult(z,O,S)}}function j0(q){let $={};for(let[Y,Q]of Object.entries(q))if(Q.url)$[Y]={type:"remote",url:Q.url,enabled:!0,...Q.headers&&Object.keys(Q.headers).length>0?{headers:Q.headers}:{}};else if(Q.command){let L=Q.args?[Q.command,...Q.args]:[Q.command];$[Y]={type:"local",command:L,enabled:!0,...Q.env&&Object.keys(Q.env).length>0?{environment:Q.env}:{}}}return $}function E0(q,$){let Y=sq(q),Q=T0($),L=Object.entries(Q).map(([B,H])=>{let J=H.map((z)=>{return` ${z.matcher?`if (!/(?:${z.matcher})/.test(String(input?.tool ?? ""))) return;
|
|
39
|
+
`:""}await $\`${z.command}\`;`}).join(`
|
|
40
|
+
`);return` "${B}": async (input, output) => {
|
|
41
|
+
${J}
|
|
42
|
+
},`}).join(`
|
|
43
|
+
`);return`import type { Plugin } from "@opencode-ai/plugin";
|
|
1811
44
|
|
|
1812
|
-
export const ${
|
|
45
|
+
export const ${Y}Plugin: Plugin = async ({ project, client, $, directory, worktree }) => {
|
|
1813
46
|
return {
|
|
1814
|
-
${
|
|
47
|
+
${L}
|
|
1815
48
|
};
|
|
1816
49
|
};
|
|
1817
|
-
|
|
1818
|
-
}
|
|
1819
|
-
function mapHookEvents(events) {
|
|
1820
|
-
const mapped = {};
|
|
1821
|
-
const eventMapping = {
|
|
1822
|
-
sessionStart: "session.created",
|
|
1823
|
-
postToolUse: "tool.execute.after",
|
|
1824
|
-
preToolUse: "tool.execute.before",
|
|
1825
|
-
stop: "session.idle",
|
|
1826
|
-
afterFileEdit: "file.edited",
|
|
1827
|
-
afterShellExecution: "command.executed"
|
|
1828
|
-
};
|
|
1829
|
-
for (const [event, handlers] of Object.entries(events)) {
|
|
1830
|
-
const opencodeEvent = eventMapping[event] ?? event;
|
|
1831
|
-
if (!mapped[opencodeEvent]) {
|
|
1832
|
-
mapped[opencodeEvent] = [];
|
|
1833
|
-
}
|
|
1834
|
-
mapped[opencodeEvent].push(...handlers.filter((h) => h.command));
|
|
1835
|
-
}
|
|
1836
|
-
return mapped;
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
// src/targets/registry.ts
|
|
1840
|
-
var TARGETS = [
|
|
1841
|
-
new OpenCodeTarget,
|
|
1842
|
-
new CursorTarget,
|
|
1843
|
-
new ClaudeCodeTarget,
|
|
1844
|
-
new CodexCliTarget,
|
|
1845
|
-
new MistralVibeTarget,
|
|
1846
|
-
new GeminiCliTarget,
|
|
1847
|
-
new CopilotTarget,
|
|
1848
|
-
new AgentsMdTarget,
|
|
1849
|
-
ClineTarget,
|
|
1850
|
-
KiloTarget,
|
|
1851
|
-
RooTarget,
|
|
1852
|
-
QwenCodeTarget,
|
|
1853
|
-
KiroTarget,
|
|
1854
|
-
FactoryDroidTarget,
|
|
1855
|
-
AntiGravityTarget,
|
|
1856
|
-
JunieTarget,
|
|
1857
|
-
AugmentCodeTarget,
|
|
1858
|
-
WindsurfTarget,
|
|
1859
|
-
WarpTarget,
|
|
1860
|
-
ReplitTarget,
|
|
1861
|
-
ZedTarget
|
|
1862
|
-
];
|
|
1863
|
-
var targetMap = new Map(TARGETS.map((t) => [t.id, t]));
|
|
1864
|
-
function getTarget(id) {
|
|
1865
|
-
return targetMap.get(id);
|
|
1866
|
-
}
|
|
1867
|
-
function getAllTargets() {
|
|
1868
|
-
return [...TARGETS];
|
|
1869
|
-
}
|
|
1870
|
-
function getTargets(ids) {
|
|
1871
|
-
return ids.map((id) => targetMap.get(id)).filter((t) => t !== undefined);
|
|
1872
|
-
}
|
|
1873
|
-
function listTargetIds() {
|
|
1874
|
-
return TARGETS.map((t) => t.id);
|
|
1875
|
-
}
|
|
1876
|
-
export {
|
|
1877
|
-
listTargetIds,
|
|
1878
|
-
getTargets,
|
|
1879
|
-
getTarget,
|
|
1880
|
-
getAllTargets,
|
|
1881
|
-
OpenCodeTarget,
|
|
1882
|
-
MistralVibeTarget,
|
|
1883
|
-
GeminiCliTarget,
|
|
1884
|
-
CursorTarget,
|
|
1885
|
-
CopilotTarget,
|
|
1886
|
-
CodexCliTarget,
|
|
1887
|
-
ClaudeCodeTarget,
|
|
1888
|
-
BaseTarget,
|
|
1889
|
-
AgentsMdTarget
|
|
1890
|
-
};
|
|
50
|
+
`}function T0(q){let $={},Y={sessionStart:"session.created",postToolUse:"tool.execute.after",preToolUse:"tool.execute.before",stop:"session.idle",afterFileEdit:"file.edited",afterShellExecution:"command.executed"};for(let[Q,L]of Object.entries(q)){let B=Y[Q]??Q;if(!$[B])$[B]=[];$[B].push(...L.filter((H)=>H.command))}return $}var _q=[new Hq,new Jq,new Vq,new Bq,new Oq,new zq,new Lq,hq,Dq,vq,uq,gq,pq,mq,cq,fq,dq,oq,nq,aq],iq=new Map(_q.map((q)=>[q.id,q]));function k0(q){return iq.get(q)}function h0(){return[..._q]}function D0(q){return q.map(($)=>iq.get($)).filter(($)=>$!==void 0)}function v0(){return _q.map((q)=>q.id)}export{v0 as listTargetIds,D0 as getTargets,k0 as getTarget,h0 as getAllTargets,Hq as OpenCodeTarget,Oq as MistralVibeTarget,zq as GeminiCliTarget,Jq as CursorTarget,Lq as CopilotTarget,Bq as CodexCliTarget,Vq as ClaudeCodeTarget,b as BaseTarget};
|