agents-inc 0.164.0 → 0.166.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/CHANGELOG.md +63 -0
- package/README.md +8 -9
- package/dist/{chunk-X4SSJZLY.js → chunk-25MPBIK3.js} +12 -261
- package/dist/chunk-25MPBIK3.js.map +1 -0
- package/dist/{chunk-LT5GXEB2.js → chunk-2VUYFTUB.js} +8 -7
- package/dist/chunk-2VUYFTUB.js.map +1 -0
- package/dist/chunk-4AAOOAIN.js +49 -0
- package/dist/chunk-4AAOOAIN.js.map +1 -0
- package/dist/{chunk-ARYNOWKF.js → chunk-4NDBUJHK.js} +8 -8
- package/dist/{chunk-S63LXWMC.js → chunk-6L75SQZU.js} +2 -2
- package/dist/{chunk-7REKOTKG.js → chunk-6LF4CQBY.js} +3 -3
- package/dist/{chunk-K5ITEA3I.js → chunk-7JNJ52CD.js} +34 -17
- package/dist/chunk-7JNJ52CD.js.map +1 -0
- package/dist/{chunk-XPDVAJDH.js → chunk-A4KDXNOT.js} +3519 -1568
- package/dist/chunk-A4KDXNOT.js.map +1 -0
- package/dist/{chunk-XHPWTL4I.js → chunk-DAIEQJIF.js} +3 -3
- package/dist/{chunk-UITEKY2R.js → chunk-ENGYJCTF.js} +28 -4
- package/dist/chunk-ENGYJCTF.js.map +1 -0
- package/dist/{chunk-G2JJ5BO5.js → chunk-G4JK7WVO.js} +336 -140
- package/dist/chunk-G4JK7WVO.js.map +1 -0
- package/dist/{chunk-X37UYIE3.js → chunk-G6UREQ4V.js} +436 -739
- package/dist/chunk-G6UREQ4V.js.map +1 -0
- package/dist/chunk-GE3WKJ6Q.js +375 -0
- package/dist/chunk-GE3WKJ6Q.js.map +1 -0
- package/dist/{chunk-RGYDFBCT.js → chunk-HHIYT3PI.js} +5 -5
- package/dist/{chunk-2CQNPLVF.js → chunk-HWEKHVLE.js} +63 -42
- package/dist/chunk-HWEKHVLE.js.map +1 -0
- package/dist/{chunk-XVAQG2CV.js → chunk-JOEA52NR.js} +10 -8
- package/dist/chunk-JOEA52NR.js.map +1 -0
- package/dist/{chunk-3WVH2CTK.js → chunk-JQRJQ4SS.js} +15 -8
- package/dist/chunk-JQRJQ4SS.js.map +1 -0
- package/dist/{chunk-DSL66I4N.js → chunk-LFWLEDUG.js} +6 -6
- package/dist/{chunk-B3Y3QMWI.js → chunk-MAWNVT2C.js} +4 -4
- package/dist/{chunk-Q4IRRVXK.js → chunk-MPTNC32T.js} +3 -3
- package/dist/chunk-NBXXFIIW.js +73 -0
- package/dist/chunk-NBXXFIIW.js.map +1 -0
- package/dist/{chunk-B6FSLXYN.js → chunk-PMJWD27C.js} +3 -3
- package/dist/{chunk-XATLUKXK.js → chunk-PNB3524H.js} +6 -6
- package/dist/chunk-PXWG7KFO.js +39 -0
- package/dist/chunk-PXWG7KFO.js.map +1 -0
- package/dist/{chunk-4VL3CEOS.js → chunk-QHDPLLK6.js} +3 -3
- package/dist/{chunk-AOTCIUGX.js → chunk-RAHSOJQ2.js} +2 -2
- package/dist/{chunk-PHCPUQVR.js → chunk-RZDXDMT6.js} +2 -2
- package/dist/{chunk-6MV4JOCL.js → chunk-SAYZWCH6.js} +2 -2
- package/dist/{chunk-URXIQE7I.js → chunk-SCOQ34YM.js} +2 -2
- package/dist/{chunk-NQXO4LR3.js → chunk-SXVHSOTH.js} +16 -11
- package/dist/chunk-SXVHSOTH.js.map +1 -0
- package/dist/{chunk-QZX7SYKU.js → chunk-T6UWJAB3.js} +2 -2
- package/dist/{chunk-ZVXGW2IC.js → chunk-TODCQFRB.js} +4 -6
- package/dist/chunk-TODCQFRB.js.map +1 -0
- package/dist/{chunk-YRS3QZP2.js → chunk-TTY6DPJN.js} +3 -3
- package/dist/{chunk-QGUP3QJF.js → chunk-TZ2YJJKK.js} +22 -18
- package/dist/{chunk-QGUP3QJF.js.map → chunk-TZ2YJJKK.js.map} +1 -1
- package/dist/chunk-V3I7VQ7N.js +356 -0
- package/dist/chunk-V3I7VQ7N.js.map +1 -0
- package/dist/{chunk-AVK2HEKB.js → chunk-V5WXIM2F.js} +2 -6
- package/dist/{chunk-AVK2HEKB.js.map → chunk-V5WXIM2F.js.map} +1 -1
- package/dist/{chunk-NKGYKOB7.js → chunk-VAPTVR3J.js} +7 -8
- package/dist/chunk-VAPTVR3J.js.map +1 -0
- package/dist/chunk-VRXX4D6K.js +31 -0
- package/dist/chunk-VRXX4D6K.js.map +1 -0
- package/dist/{chunk-ABAZMMG4.js → chunk-WVUDLKIO.js} +2 -2
- package/dist/{chunk-ECURHW3T.js → chunk-WWIFNPJG.js} +13 -12
- package/dist/chunk-WWIFNPJG.js.map +1 -0
- package/dist/{chunk-J27W6TXS.js → chunk-XQHZPINL.js} +8 -4
- package/dist/chunk-XQHZPINL.js.map +1 -0
- package/dist/{chunk-V5GLL2JB.js → chunk-XZEVWPX6.js} +7 -7
- package/dist/chunk-Y3VIRVVE.js +932 -0
- package/dist/chunk-Y3VIRVVE.js.map +1 -0
- package/dist/{chunk-NTF4UXGK.js → chunk-Y47EV74W.js} +73 -30
- package/dist/chunk-Y47EV74W.js.map +1 -0
- package/dist/chunk-ZR4YPKXQ.js +159 -0
- package/dist/chunk-ZR4YPKXQ.js.map +1 -0
- package/dist/chunk-ZXKBERQU.js +250 -0
- package/dist/chunk-ZXKBERQU.js.map +1 -0
- package/dist/commands/build/marketplace.js +17 -17
- package/dist/commands/build/marketplace.js.map +1 -1
- package/dist/commands/build/plugins.js +11 -9
- package/dist/commands/build/plugins.js.map +1 -1
- package/dist/commands/compile.js +105 -27
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/doctor.js +309 -171
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/edit.js +503 -314
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/eject.js +40 -23
- package/dist/commands/eject.js.map +1 -1
- package/dist/commands/init.js +44 -40
- package/dist/commands/list.js +44 -10
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/new/marketplace.js +13 -10
- package/dist/commands/new/marketplace.js.map +1 -1
- package/dist/commands/search.js +12 -10
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/share.js +102 -15
- package/dist/commands/share.js.map +1 -1
- package/dist/commands/uninstall.js +231 -103
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/commands/update.js +49 -20
- package/dist/commands/update.js.map +1 -1
- package/dist/components/common/prompt-confirm.js +1 -1
- package/dist/components/common/removal-plan-confirm.js +2 -2
- package/dist/components/common/select-list.js +3 -3
- package/dist/components/common/spinner.js +6 -3
- package/dist/components/wizard/category-grid.js +5 -5
- package/dist/components/wizard/checkbox-grid.js +4 -4
- package/dist/components/wizard/domain-selection.js +9 -9
- package/dist/components/wizard/run-wizard-session.js +29 -29
- package/dist/components/wizard/scroll-affordance.js +2 -2
- package/dist/components/wizard/skill-agent-summary.js +5 -5
- package/dist/components/wizard/source-grid.js +6 -6
- package/dist/components/wizard/stack-selection.js +8 -8
- package/dist/components/wizard/step-agents.js +8 -8
- package/dist/components/wizard/step-build.js +8 -8
- package/dist/components/wizard/step-confirm.js +9 -9
- package/dist/components/wizard/step-sources.js +9 -9
- package/dist/components/wizard/step-stack.js +9 -9
- package/dist/components/wizard/summary-panel.js +8 -8
- package/dist/components/wizard/toast.js +2 -2
- package/dist/components/wizard/wizard-layout.js +12 -12
- package/dist/components/wizard/wizard-tabs.js +2 -2
- package/dist/components/wizard/wizard.js +27 -27
- package/dist/hooks/init.js +69 -43
- package/dist/hooks/init.js.map +1 -1
- package/dist/load-agent-defs-3C27ENC7.js +14 -0
- package/dist/recompile-project-agents-DGNBCU3N.js +18 -0
- package/dist/{source-loader-GRBVNRAW.js → source-loader-7KZ3MD5O.js} +6 -4
- package/dist/src/agents/_templates/agent-body.liquid +55 -0
- package/dist/src/agents/_templates/agent.liquid +1 -55
- package/dist/src/agents/meta/agent-summoner/output.md +1 -1
- package/dist/src/agents/meta/agent-summoner/playbook.md +15 -7
- package/dist/stores/wizard-store.js +4 -4
- package/package.json +10 -9
- package/src/agents/_templates/agent-body.liquid +55 -0
- package/src/agents/_templates/agent.liquid +1 -55
- package/src/agents/meta/agent-summoner/output.md +1 -1
- package/src/agents/meta/agent-summoner/playbook.md +15 -7
- package/src/schemas/project-config.schema.json +1 -1
- package/src/schemas/project-source-config.schema.json +1 -1
- package/dist/chunk-2CQNPLVF.js.map +0 -1
- package/dist/chunk-3WVH2CTK.js.map +0 -1
- package/dist/chunk-7ANJQLPJ.js +0 -35
- package/dist/chunk-7ANJQLPJ.js.map +0 -1
- package/dist/chunk-ECURHW3T.js.map +0 -1
- package/dist/chunk-FLW25ORT.js +0 -130
- package/dist/chunk-FLW25ORT.js.map +0 -1
- package/dist/chunk-G2JJ5BO5.js.map +0 -1
- package/dist/chunk-J27W6TXS.js.map +0 -1
- package/dist/chunk-JCPANDNR.js +0 -35
- package/dist/chunk-JCPANDNR.js.map +0 -1
- package/dist/chunk-JIERYE6B.js +0 -480
- package/dist/chunk-JIERYE6B.js.map +0 -1
- package/dist/chunk-JU4ZGJ7A.js +0 -668
- package/dist/chunk-JU4ZGJ7A.js.map +0 -1
- package/dist/chunk-K5ITEA3I.js.map +0 -1
- package/dist/chunk-LT5GXEB2.js.map +0 -1
- package/dist/chunk-NKGYKOB7.js.map +0 -1
- package/dist/chunk-NQXO4LR3.js.map +0 -1
- package/dist/chunk-NTF4UXGK.js.map +0 -1
- package/dist/chunk-UITEKY2R.js.map +0 -1
- package/dist/chunk-X37UYIE3.js.map +0 -1
- package/dist/chunk-X4SSJZLY.js.map +0 -1
- package/dist/chunk-XPDVAJDH.js.map +0 -1
- package/dist/chunk-XVAQG2CV.js.map +0 -1
- package/dist/chunk-ZBPEFQ4G.js +0 -12
- package/dist/chunk-ZBPEFQ4G.js.map +0 -1
- package/dist/chunk-ZVXGW2IC.js.map +0 -1
- package/dist/load-agent-defs-7IM3GBEQ.js +0 -13
- package/dist/recompile-project-agents-VR4NLGOU.js +0 -17
- /package/dist/{chunk-ARYNOWKF.js.map → chunk-4NDBUJHK.js.map} +0 -0
- /package/dist/{chunk-S63LXWMC.js.map → chunk-6L75SQZU.js.map} +0 -0
- /package/dist/{chunk-7REKOTKG.js.map → chunk-6LF4CQBY.js.map} +0 -0
- /package/dist/{chunk-XHPWTL4I.js.map → chunk-DAIEQJIF.js.map} +0 -0
- /package/dist/{chunk-RGYDFBCT.js.map → chunk-HHIYT3PI.js.map} +0 -0
- /package/dist/{chunk-DSL66I4N.js.map → chunk-LFWLEDUG.js.map} +0 -0
- /package/dist/{chunk-B3Y3QMWI.js.map → chunk-MAWNVT2C.js.map} +0 -0
- /package/dist/{chunk-Q4IRRVXK.js.map → chunk-MPTNC32T.js.map} +0 -0
- /package/dist/{chunk-B6FSLXYN.js.map → chunk-PMJWD27C.js.map} +0 -0
- /package/dist/{chunk-XATLUKXK.js.map → chunk-PNB3524H.js.map} +0 -0
- /package/dist/{chunk-4VL3CEOS.js.map → chunk-QHDPLLK6.js.map} +0 -0
- /package/dist/{chunk-AOTCIUGX.js.map → chunk-RAHSOJQ2.js.map} +0 -0
- /package/dist/{chunk-PHCPUQVR.js.map → chunk-RZDXDMT6.js.map} +0 -0
- /package/dist/{chunk-6MV4JOCL.js.map → chunk-SAYZWCH6.js.map} +0 -0
- /package/dist/{chunk-URXIQE7I.js.map → chunk-SCOQ34YM.js.map} +0 -0
- /package/dist/{chunk-QZX7SYKU.js.map → chunk-T6UWJAB3.js.map} +0 -0
- /package/dist/{chunk-YRS3QZP2.js.map → chunk-TTY6DPJN.js.map} +0 -0
- /package/dist/{chunk-ABAZMMG4.js.map → chunk-WVUDLKIO.js.map} +0 -0
- /package/dist/{chunk-V5GLL2JB.js.map → chunk-XZEVWPX6.js.map} +0 -0
- /package/dist/{load-agent-defs-7IM3GBEQ.js.map → load-agent-defs-3C27ENC7.js.map} +0 -0
- /package/dist/{recompile-project-agents-VR4NLGOU.js.map → recompile-project-agents-DGNBCU3N.js.map} +0 -0
- /package/dist/{source-loader-GRBVNRAW.js.map → source-loader-7KZ3MD5O.js.map} +0 -0
package/dist/chunk-JU4ZGJ7A.js
DELETED
|
@@ -1,668 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
agentFrontmatterValidationSchema,
|
|
4
|
-
buildCompileAgents,
|
|
5
|
-
computeStringHash,
|
|
6
|
-
copy,
|
|
7
|
-
determinePluginVersion,
|
|
8
|
-
directoryExists,
|
|
9
|
-
discoverAllPluginSkills,
|
|
10
|
-
ensureDir,
|
|
11
|
-
extractFrontmatter,
|
|
12
|
-
fetchFromSource,
|
|
13
|
-
fileExists,
|
|
14
|
-
formatZodIssues,
|
|
15
|
-
generateAgentPluginManifest,
|
|
16
|
-
getErrorMessage,
|
|
17
|
-
getPluginAgentsDir,
|
|
18
|
-
getPluginManifestPath,
|
|
19
|
-
glob,
|
|
20
|
-
isAgentName,
|
|
21
|
-
loadAllAgents,
|
|
22
|
-
loadProjectAgents,
|
|
23
|
-
loadProjectConfig,
|
|
24
|
-
loadProjectSourceConfig,
|
|
25
|
-
log,
|
|
26
|
-
readFile,
|
|
27
|
-
readFileOptional,
|
|
28
|
-
remove,
|
|
29
|
-
resolveAgents,
|
|
30
|
-
resolveInstallPaths,
|
|
31
|
-
verbose,
|
|
32
|
-
warn,
|
|
33
|
-
writeContentHash,
|
|
34
|
-
writeFile,
|
|
35
|
-
writePluginManifest
|
|
36
|
-
} from "./chunk-XPDVAJDH.js";
|
|
37
|
-
import {
|
|
38
|
-
typedEntries,
|
|
39
|
-
typedFromEntries,
|
|
40
|
-
typedKeys
|
|
41
|
-
} from "./chunk-AVK2HEKB.js";
|
|
42
|
-
import {
|
|
43
|
-
CLAUDE_DIR,
|
|
44
|
-
CLAUDE_SRC_DIR,
|
|
45
|
-
DEFAULT_PLUGIN_NAME,
|
|
46
|
-
DIRS,
|
|
47
|
-
EJECT_SOURCE,
|
|
48
|
-
PROJECT_ROOT,
|
|
49
|
-
STANDARD_DIRS,
|
|
50
|
-
STANDARD_FILES,
|
|
51
|
-
diagnostics,
|
|
52
|
-
effectivelyExcludedSkillIds
|
|
53
|
-
} from "./chunk-UITEKY2R.js";
|
|
54
|
-
|
|
55
|
-
// src/cli/lib/agents/list-compiled-agents.ts
|
|
56
|
-
import path2 from "path";
|
|
57
|
-
import { partition } from "remeda";
|
|
58
|
-
|
|
59
|
-
// src/cli/lib/agents/agent-provenance.ts
|
|
60
|
-
import path from "path";
|
|
61
|
-
import { z } from "zod";
|
|
62
|
-
|
|
63
|
-
// ../compile/src/agent-source.ts
|
|
64
|
-
var LIQUID_SYNTAX_PATTERN = /\{\{|\}\}|\{%|%\}/g;
|
|
65
|
-
function sanitizeLiquidSyntax(value, fieldName) {
|
|
66
|
-
if (!LIQUID_SYNTAX_PATTERN.test(value)) return value;
|
|
67
|
-
LIQUID_SYNTAX_PATTERN.lastIndex = 0;
|
|
68
|
-
const sanitized = value.replace(LIQUID_SYNTAX_PATTERN, "");
|
|
69
|
-
diagnostics().warn(
|
|
70
|
-
`Stripped Liquid template syntax from '${fieldName}' \u2014 possible template injection attempt`
|
|
71
|
-
);
|
|
72
|
-
return sanitized;
|
|
73
|
-
}
|
|
74
|
-
function sanitizeStringArray(values, fieldName) {
|
|
75
|
-
return values.map((v) => sanitizeLiquidSyntax(v, fieldName));
|
|
76
|
-
}
|
|
77
|
-
function sanitizeHooks(hooks) {
|
|
78
|
-
return Object.fromEntries(
|
|
79
|
-
Object.entries(hooks).map(([event, definitions]) => [
|
|
80
|
-
sanitizeLiquidSyntax(event, "hook.event"),
|
|
81
|
-
definitions.map((definition) => ({
|
|
82
|
-
...definition,
|
|
83
|
-
...definition.matcher !== void 0 && {
|
|
84
|
-
matcher: sanitizeLiquidSyntax(definition.matcher, "hook.matcher")
|
|
85
|
-
},
|
|
86
|
-
hooks: definition.hooks.map((action) => ({
|
|
87
|
-
...action,
|
|
88
|
-
type: sanitizeLiquidSyntax(action.type, "hook.type"),
|
|
89
|
-
...action.command !== void 0 && {
|
|
90
|
-
command: sanitizeLiquidSyntax(action.command, "hook.command")
|
|
91
|
-
},
|
|
92
|
-
...action.script !== void 0 && {
|
|
93
|
-
script: sanitizeLiquidSyntax(action.script, "hook.script")
|
|
94
|
-
},
|
|
95
|
-
...action.prompt !== void 0 && {
|
|
96
|
-
prompt: sanitizeLiquidSyntax(action.prompt, "hook.prompt")
|
|
97
|
-
}
|
|
98
|
-
}))
|
|
99
|
-
}))
|
|
100
|
-
])
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
function sanitizeExperimental(experimental) {
|
|
104
|
-
return {
|
|
105
|
-
...experimental,
|
|
106
|
-
...experimental.cacheTtl !== void 0 && {
|
|
107
|
-
cacheTtl: sanitizeLiquidSyntax(
|
|
108
|
-
experimental.cacheTtl,
|
|
109
|
-
"agent.experimental.cacheTtl"
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function sanitizeSkills(skills) {
|
|
115
|
-
return skills.map((s) => ({
|
|
116
|
-
...s,
|
|
117
|
-
id: sanitizeLiquidSyntax(s.id, "skill.id"),
|
|
118
|
-
description: sanitizeLiquidSyntax(s.description, "skill.description"),
|
|
119
|
-
usage: sanitizeLiquidSyntax(s.usage, "skill.usage"),
|
|
120
|
-
...s.pluginRef !== void 0 && {
|
|
121
|
-
pluginRef: sanitizeLiquidSyntax(s.pluginRef, "skill.pluginRef")
|
|
122
|
-
}
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
function sanitizeCompiledAgentData(data) {
|
|
126
|
-
const sanitizedAgent = {
|
|
127
|
-
...data.agent,
|
|
128
|
-
name: sanitizeLiquidSyntax(data.agent.name, "agent.name"),
|
|
129
|
-
title: sanitizeLiquidSyntax(data.agent.title, "agent.title"),
|
|
130
|
-
description: sanitizeLiquidSyntax(
|
|
131
|
-
data.agent.description,
|
|
132
|
-
"agent.description"
|
|
133
|
-
),
|
|
134
|
-
tools: sanitizeStringArray(data.agent.tools, "agent.tools"),
|
|
135
|
-
...data.agent.disallowedTools !== void 0 && {
|
|
136
|
-
disallowedTools: sanitizeStringArray(
|
|
137
|
-
data.agent.disallowedTools,
|
|
138
|
-
"agent.disallowedTools"
|
|
139
|
-
)
|
|
140
|
-
},
|
|
141
|
-
...data.agent.model !== void 0 && {
|
|
142
|
-
model: sanitizeLiquidSyntax(data.agent.model, "agent.model")
|
|
143
|
-
},
|
|
144
|
-
...data.agent.effort !== void 0 && {
|
|
145
|
-
effort: sanitizeLiquidSyntax(data.agent.effort, "agent.effort")
|
|
146
|
-
},
|
|
147
|
-
...data.agent.permissionMode !== void 0 && {
|
|
148
|
-
permissionMode: sanitizeLiquidSyntax(
|
|
149
|
-
data.agent.permissionMode,
|
|
150
|
-
"agent.permissionMode"
|
|
151
|
-
)
|
|
152
|
-
},
|
|
153
|
-
...data.agent.isolation !== void 0 && {
|
|
154
|
-
isolation: sanitizeLiquidSyntax(data.agent.isolation, "agent.isolation")
|
|
155
|
-
},
|
|
156
|
-
...data.agent.experimental !== void 0 && {
|
|
157
|
-
experimental: sanitizeExperimental(data.agent.experimental)
|
|
158
|
-
},
|
|
159
|
-
...data.agent.hooks !== void 0 && {
|
|
160
|
-
hooks: sanitizeHooks(data.agent.hooks)
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
const sanitizedSkills = sanitizeSkills(data.skills);
|
|
164
|
-
const sanitizedPreloaded = sanitizeSkills(data.preloadedSkills);
|
|
165
|
-
const sanitizedDynamic = sanitizeSkills(data.dynamicSkills);
|
|
166
|
-
const sanitizedPreloadedIds = data.preloadedSkillIds.map(
|
|
167
|
-
(id) => sanitizeLiquidSyntax(id, "preloadedSkillId")
|
|
168
|
-
);
|
|
169
|
-
return {
|
|
170
|
-
agent: sanitizedAgent,
|
|
171
|
-
identity: data.identity,
|
|
172
|
-
playbook: data.playbook,
|
|
173
|
-
output: data.output,
|
|
174
|
-
criticalRequirementsTop: data.criticalRequirementsTop,
|
|
175
|
-
criticalReminders: data.criticalReminders,
|
|
176
|
-
skills: sanitizedSkills,
|
|
177
|
-
preloadedSkills: sanitizedPreloaded,
|
|
178
|
-
dynamicSkills: sanitizedDynamic,
|
|
179
|
-
preloadedSkillIds: sanitizedPreloadedIds
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
var SKILL_TOOL = "Skill";
|
|
183
|
-
function withSkillTool(agent) {
|
|
184
|
-
if (agent.tools.includes(SKILL_TOOL)) return agent;
|
|
185
|
-
return { ...agent, tools: [...agent.tools, SKILL_TOOL] };
|
|
186
|
-
}
|
|
187
|
-
function buildAgentTemplateContext(name, agent, files, mapSkill = (skill) => skill) {
|
|
188
|
-
const skills = agent.skills.map(mapSkill);
|
|
189
|
-
const preloadedSkills = skills.filter((s) => s.preloaded);
|
|
190
|
-
const dynamicSkills = skills.filter((s) => !s.preloaded);
|
|
191
|
-
const preloadedSkillIds = preloadedSkills.map((s) => s.pluginRef ?? s.id);
|
|
192
|
-
diagnostics().verbose(
|
|
193
|
-
`Skills for ${name}: ${preloadedSkills.length} preloaded, ${dynamicSkills.length} dynamic`
|
|
194
|
-
);
|
|
195
|
-
return {
|
|
196
|
-
agent: withSkillTool(agent),
|
|
197
|
-
...files,
|
|
198
|
-
skills,
|
|
199
|
-
preloadedSkills,
|
|
200
|
-
dynamicSkills,
|
|
201
|
-
preloadedSkillIds
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function pluginRefFor(skill) {
|
|
205
|
-
if (skill.source === void 0 || skill.source === EJECT_SOURCE) return {};
|
|
206
|
-
return { pluginRef: `${skill.id}:${skill.id}` };
|
|
207
|
-
}
|
|
208
|
-
var MARKER_OPEN = `<!-- Generated by ${DEFAULT_PLUGIN_NAME}`;
|
|
209
|
-
var MARKER_NOTICE = " \u2014 do not edit; compile rewrites this file";
|
|
210
|
-
var MARKER_CLOSE = " -->";
|
|
211
|
-
var FRONTMATTER_FENCE = "---";
|
|
212
|
-
function provenanceMarker() {
|
|
213
|
-
return `${MARKER_OPEN}${MARKER_NOTICE}${MARKER_CLOSE}`;
|
|
214
|
-
}
|
|
215
|
-
function isProvenanceMarker(line) {
|
|
216
|
-
return line.startsWith(MARKER_OPEN) && line.endsWith(MARKER_CLOSE);
|
|
217
|
-
}
|
|
218
|
-
function bodyStartIndex(lines) {
|
|
219
|
-
if (lines[0] !== FRONTMATTER_FENCE) return 0;
|
|
220
|
-
const closingFence = lines.indexOf(FRONTMATTER_FENCE, 1);
|
|
221
|
-
if (closingFence === -1) return 0;
|
|
222
|
-
return closingFence + 1;
|
|
223
|
-
}
|
|
224
|
-
function hasProvenanceMarker(content) {
|
|
225
|
-
const lines = content.split("\n");
|
|
226
|
-
const firstBodyLine = lines[bodyStartIndex(lines)];
|
|
227
|
-
return firstBodyLine !== void 0 && isProvenanceMarker(firstBodyLine);
|
|
228
|
-
}
|
|
229
|
-
function stampProvenanceMarker(content) {
|
|
230
|
-
const lines = content.split("\n");
|
|
231
|
-
const bodyStart = bodyStartIndex(lines);
|
|
232
|
-
const replacedLines = hasProvenanceMarker(content) ? 1 : 0;
|
|
233
|
-
return [
|
|
234
|
-
...lines.slice(0, bodyStart),
|
|
235
|
-
provenanceMarker(),
|
|
236
|
-
...lines.slice(bodyStart + replacedLines)
|
|
237
|
-
].join("\n");
|
|
238
|
-
}
|
|
239
|
-
var AGENT_TEMPLATE = "agent";
|
|
240
|
-
var COMPLETION_GATE_COMMAND = `command -v npm >/dev/null 2>&1 && [ -f package.json ] || exit 0; out=$(npm run --if-present --silent typecheck 2>&1) || { printf '%s\\n' "$out" >&2; exit 2; }`;
|
|
241
|
-
var WRITING_TOOLS = ["Write", "Edit"];
|
|
242
|
-
var GATE_EVENT = "Stop";
|
|
243
|
-
var CONVERTED_GATE_EVENT = "SubagentStop";
|
|
244
|
-
function completionGateHooks() {
|
|
245
|
-
return {
|
|
246
|
-
[GATE_EVENT]: [
|
|
247
|
-
{ hooks: [{ type: "command", command: COMPLETION_GATE_COMMAND }] }
|
|
248
|
-
]
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
function declaresOwnGate(hooks) {
|
|
252
|
-
if (hooks === void 0) return false;
|
|
253
|
-
const stated = [GATE_EVENT, CONVERTED_GATE_EVENT];
|
|
254
|
-
return stated.some((event) => (hooks[event]?.length ?? 0) > 0);
|
|
255
|
-
}
|
|
256
|
-
function withCompletionGate(agent) {
|
|
257
|
-
const writes = WRITING_TOOLS.some((tool) => agent.tools.includes(tool));
|
|
258
|
-
if (!writes || declaresOwnGate(agent.hooks)) return agent;
|
|
259
|
-
return { ...agent, hooks: { ...agent.hooks, ...completionGateHooks() } };
|
|
260
|
-
}
|
|
261
|
-
function prepareForRender(data) {
|
|
262
|
-
return sanitizeCompiledAgentData({
|
|
263
|
-
...data,
|
|
264
|
-
agent: withCompletionGate(data.agent)
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
async function renderAgent(engine, data, version) {
|
|
268
|
-
const rendered = await engine.renderFile(AGENT_TEMPLATE, {
|
|
269
|
-
...prepareForRender(data),
|
|
270
|
-
generatorVersion: sanitizeLiquidSyntax(version, "generatorVersion")
|
|
271
|
-
});
|
|
272
|
-
return stampProvenanceMarker(rendered);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// src/cli/lib/agents/agent-provenance.ts
|
|
276
|
-
var ownPackageJsonSchema = z.object({ version: z.string().min(1) });
|
|
277
|
-
var ownVersion;
|
|
278
|
-
function cliVersion() {
|
|
279
|
-
ownVersion ??= readOwnVersion();
|
|
280
|
-
return ownVersion;
|
|
281
|
-
}
|
|
282
|
-
async function readOwnVersion() {
|
|
283
|
-
const manifestPath = path.join(PROJECT_ROOT, STANDARD_FILES.PACKAGE_JSON);
|
|
284
|
-
const raw = JSON.parse(await readFile(manifestPath));
|
|
285
|
-
const parsed = ownPackageJsonSchema.safeParse(raw);
|
|
286
|
-
if (!parsed.success) {
|
|
287
|
-
throw new Error(`Could not read this CLI's own version from ${manifestPath}`);
|
|
288
|
-
}
|
|
289
|
-
return parsed.data.version;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// src/cli/lib/agents/list-compiled-agents.ts
|
|
293
|
-
async function listAgentMdFiles(agentsDir) {
|
|
294
|
-
return glob("*.md", agentsDir);
|
|
295
|
-
}
|
|
296
|
-
async function splitAgentsByProvenance(agentsDir) {
|
|
297
|
-
const files = await listAgentMdFiles(agentsDir);
|
|
298
|
-
const classified = await Promise.all(files.map((file) => readAgentProvenance(agentsDir, file)));
|
|
299
|
-
const [marked, unmarked] = partition(classified, (agent) => agent.compiledHere);
|
|
300
|
-
return { marked: marked.map(agentName), unmarked: unmarked.map(agentName) };
|
|
301
|
-
}
|
|
302
|
-
async function readAgentProvenance(agentsDir, file) {
|
|
303
|
-
const content = await readFileOptional(path2.join(agentsDir, file));
|
|
304
|
-
return { name: path2.basename(file, ".md"), compiledHere: hasProvenanceMarker(content) };
|
|
305
|
-
}
|
|
306
|
-
function agentName(agent) {
|
|
307
|
-
return agent.name;
|
|
308
|
-
}
|
|
309
|
-
async function listCompiledAgentNames(agentsDir) {
|
|
310
|
-
const files = await listAgentMdFiles(agentsDir);
|
|
311
|
-
return files.map((f) => path2.basename(f, ".md"));
|
|
312
|
-
}
|
|
313
|
-
async function pruneStaleCompiledAgents(agentsDir, keep) {
|
|
314
|
-
const isStaleCompiledAgent = (file) => {
|
|
315
|
-
const name = path2.basename(file, ".md");
|
|
316
|
-
return isAgentName(name) && !keep.has(name);
|
|
317
|
-
};
|
|
318
|
-
const files = await listAgentMdFiles(agentsDir);
|
|
319
|
-
await Promise.all(
|
|
320
|
-
files.filter(isStaleCompiledAgent).map((file) => remove(path2.join(agentsDir, file)))
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// src/cli/lib/agents/agent-fetcher.ts
|
|
325
|
-
import path3 from "path";
|
|
326
|
-
async function getAgentDefinitions(remoteSource) {
|
|
327
|
-
if (remoteSource) {
|
|
328
|
-
return fetchAgentDefinitionsFromRemote(remoteSource);
|
|
329
|
-
}
|
|
330
|
-
return getLocalAgentDefinitions();
|
|
331
|
-
}
|
|
332
|
-
async function getLocalAgentDefinitions() {
|
|
333
|
-
const agentsDir = path3.join(PROJECT_ROOT, DIRS.agents);
|
|
334
|
-
if (!await directoryExists(agentsDir)) {
|
|
335
|
-
throw new Error(
|
|
336
|
-
`Agent partials not found at '${agentsDir}'. Ensure the CLI is properly installed.`
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
verbose(`Agent partials loaded from CLI: ${agentsDir}`);
|
|
340
|
-
return {
|
|
341
|
-
agentsDir,
|
|
342
|
-
sourcePath: PROJECT_ROOT
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
async function fetchAgentDefinitionsFromRemote(source, options = {}) {
|
|
346
|
-
verbose(`Fetching agent partials from remote: ${source}`);
|
|
347
|
-
const result = await fetchFromSource(source, { subdir: "" });
|
|
348
|
-
const sourceProjectConfig = options.agentsDir ? void 0 : await loadProjectSourceConfig(result.path);
|
|
349
|
-
if (sourceProjectConfig?.agentsDir) {
|
|
350
|
-
verbose(`Using agentsDir from source config: ${sourceProjectConfig.agentsDir}`);
|
|
351
|
-
}
|
|
352
|
-
const agentsDirRelPath = options.agentsDir ?? sourceProjectConfig?.agentsDir ?? DIRS.agents;
|
|
353
|
-
const agentsDir = path3.join(result.path, agentsDirRelPath);
|
|
354
|
-
if (!await directoryExists(agentsDir)) {
|
|
355
|
-
throw new Error(`Agent partials not found at '${agentsDir}'`);
|
|
356
|
-
}
|
|
357
|
-
verbose(`Agent partials fetched from: ${result.path}`);
|
|
358
|
-
return {
|
|
359
|
-
agentsDir,
|
|
360
|
-
sourcePath: result.path
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// src/cli/lib/agents/agent-recompiler.ts
|
|
365
|
-
import { partition as partition2 } from "remeda";
|
|
366
|
-
|
|
367
|
-
// src/cli/lib/agents/write-compiled-agents.ts
|
|
368
|
-
import os from "os";
|
|
369
|
-
import path5 from "path";
|
|
370
|
-
|
|
371
|
-
// src/cli/lib/compiler.ts
|
|
372
|
-
import { Liquid } from "liquidjs";
|
|
373
|
-
import path4 from "path";
|
|
374
|
-
async function readAgentFiles(name, agent, projectRoot) {
|
|
375
|
-
const agentSourceRoot = agent.sourceRoot || projectRoot;
|
|
376
|
-
const agentBaseDir = agent.agentBaseDir || DIRS.agents;
|
|
377
|
-
const agentDir = path4.join(agentSourceRoot, agentBaseDir, agent.path || name);
|
|
378
|
-
const identity = await readFile(path4.join(agentDir, STANDARD_FILES.IDENTITY_MD));
|
|
379
|
-
const playbook = await readFile(path4.join(agentDir, STANDARD_FILES.PLAYBOOK_MD));
|
|
380
|
-
const criticalRequirementsTop = await readFileOptional(
|
|
381
|
-
path4.join(agentDir, STANDARD_FILES.CRITICAL_REQUIREMENTS_MD),
|
|
382
|
-
""
|
|
383
|
-
);
|
|
384
|
-
const criticalReminders = await readFileOptional(
|
|
385
|
-
path4.join(agentDir, STANDARD_FILES.CRITICAL_REMINDERS_MD),
|
|
386
|
-
""
|
|
387
|
-
);
|
|
388
|
-
const agentPath = agent.path || name;
|
|
389
|
-
const parts = agentPath.split("/");
|
|
390
|
-
const category = parts[0] || name;
|
|
391
|
-
const categoryDir = path4.join(agentSourceRoot, agentBaseDir, category);
|
|
392
|
-
let output = await readFileOptional(path4.join(agentDir, STANDARD_FILES.OUTPUT_MD), "");
|
|
393
|
-
if (!output) {
|
|
394
|
-
output = await readFileOptional(path4.join(categoryDir, STANDARD_FILES.OUTPUT_MD), "");
|
|
395
|
-
}
|
|
396
|
-
return { identity, playbook, output, criticalRequirementsTop, criticalReminders };
|
|
397
|
-
}
|
|
398
|
-
async function createLiquidEngine(projectDir) {
|
|
399
|
-
const roots = [];
|
|
400
|
-
if (projectDir) {
|
|
401
|
-
const srcTemplatesDir = path4.join(
|
|
402
|
-
projectDir,
|
|
403
|
-
CLAUDE_SRC_DIR,
|
|
404
|
-
STANDARD_DIRS.AGENTS,
|
|
405
|
-
path4.basename(DIRS.templates)
|
|
406
|
-
);
|
|
407
|
-
if (await directoryExists(srcTemplatesDir)) {
|
|
408
|
-
roots.push(srcTemplatesDir);
|
|
409
|
-
verbose(`Using local templates from: ${srcTemplatesDir}`);
|
|
410
|
-
}
|
|
411
|
-
const legacyTemplatesDir = path4.join(projectDir, CLAUDE_DIR, STANDARD_DIRS.TEMPLATES);
|
|
412
|
-
if (await directoryExists(legacyTemplatesDir)) {
|
|
413
|
-
roots.push(legacyTemplatesDir);
|
|
414
|
-
verbose(`Using legacy templates from: ${legacyTemplatesDir}`);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
roots.push(path4.join(PROJECT_ROOT, DIRS.templates));
|
|
418
|
-
return new Liquid({
|
|
419
|
-
root: roots,
|
|
420
|
-
extname: ".liquid",
|
|
421
|
-
strictVariables: false,
|
|
422
|
-
strictFilters: true
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
async function compileAgentForPlugin(name, agent, fallbackRoot, engine) {
|
|
426
|
-
verbose(`Compiling agent: ${name}`);
|
|
427
|
-
const files = await readAgentFiles(name, agent, fallbackRoot);
|
|
428
|
-
const data = buildAgentTemplateContext(name, agent, files, (skill) => ({
|
|
429
|
-
...skill,
|
|
430
|
-
...pluginRefFor(skill)
|
|
431
|
-
}));
|
|
432
|
-
return renderAgent(engine, data, await cliVersion());
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// src/cli/lib/agents/write-compiled-agents.ts
|
|
436
|
-
async function holdsExactly(filePath, content) {
|
|
437
|
-
return await fileExists(filePath) && await readFile(filePath) === content;
|
|
438
|
-
}
|
|
439
|
-
var UNROUTED_AGENT_SCOPE = "project";
|
|
440
|
-
async function writeCompiledAgentsByScope(params) {
|
|
441
|
-
const globalAgentsDir = resolveInstallPaths(os.homedir(), "global").agentsDir;
|
|
442
|
-
const outcomes = [];
|
|
443
|
-
for (const [name, agent] of typedEntries(params.resolvedAgents)) {
|
|
444
|
-
try {
|
|
445
|
-
const output = await compileAgentForPlugin(name, agent, params.sourcePath, params.engine);
|
|
446
|
-
const scope = params.agentScopeMap?.get(name) ?? UNROUTED_AGENT_SCOPE;
|
|
447
|
-
const targetDir = scope === "global" ? globalAgentsDir : params.projectAgentsDir;
|
|
448
|
-
const targetPath = path5.join(targetDir, `${name}.md`);
|
|
449
|
-
const rewritten = !await holdsExactly(targetPath, output);
|
|
450
|
-
if (rewritten) await writeFile(targetPath, output);
|
|
451
|
-
outcomes.push({ name, ok: true, scope, targetDir, rewritten });
|
|
452
|
-
} catch (error) {
|
|
453
|
-
outcomes.push({ name, ok: false, error });
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
return outcomes;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// src/cli/lib/agents/agent-recompiler.ts
|
|
460
|
-
import path6 from "path";
|
|
461
|
-
async function getExistingAgentNames(pluginDir) {
|
|
462
|
-
return listCompiledAgentNames(getPluginAgentsDir(pluginDir));
|
|
463
|
-
}
|
|
464
|
-
async function resolveAgentNames(params) {
|
|
465
|
-
const { specifiedAgents, projectConfig, allAgents, outputDir, pluginDir } = params;
|
|
466
|
-
if (specifiedAgents) {
|
|
467
|
-
return specifiedAgents;
|
|
468
|
-
}
|
|
469
|
-
if (projectConfig) {
|
|
470
|
-
const agentNames = projectConfig.agents.map((a) => a.name);
|
|
471
|
-
verbose(`Using agents from config: ${agentNames.join(", ")}`);
|
|
472
|
-
return agentNames;
|
|
473
|
-
}
|
|
474
|
-
if (outputDir) {
|
|
475
|
-
const names = typedKeys(allAgents);
|
|
476
|
-
verbose(`Using all available agents from source: ${names.join(", ")}`);
|
|
477
|
-
return names;
|
|
478
|
-
}
|
|
479
|
-
return getExistingAgentNames(pluginDir);
|
|
480
|
-
}
|
|
481
|
-
function buildRecompileResult(outcomes, priorWarnings) {
|
|
482
|
-
const [succeeded, failedOutcomes] = partition2(
|
|
483
|
-
outcomes,
|
|
484
|
-
(outcome) => outcome.ok
|
|
485
|
-
);
|
|
486
|
-
succeeded.forEach(
|
|
487
|
-
(outcome) => verbose(
|
|
488
|
-
` ${outcome.rewritten ? "Rewrote" : "Unchanged"}: ${outcome.name} (${outcome.scope} -> ${outcome.targetDir})`
|
|
489
|
-
)
|
|
490
|
-
);
|
|
491
|
-
return {
|
|
492
|
-
compiled: succeeded.map((outcome) => outcome.name),
|
|
493
|
-
rewritten: succeeded.filter((outcome) => outcome.rewritten).map((outcome) => outcome.name),
|
|
494
|
-
failed: failedOutcomes.map((outcome) => outcome.name),
|
|
495
|
-
warnings: [
|
|
496
|
-
...priorWarnings,
|
|
497
|
-
...failedOutcomes.map(
|
|
498
|
-
(outcome) => `Failed to compile ${outcome.name}: ${getErrorMessage(outcome.error)}`
|
|
499
|
-
)
|
|
500
|
-
]
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
function filterExcludedEntries(config) {
|
|
504
|
-
const excludedIds = effectivelyExcludedSkillIds(config.skills);
|
|
505
|
-
const activeSkills = config.skills.filter((s) => !s.excluded);
|
|
506
|
-
const activeAgents = config.agents.filter((a) => !a.excluded);
|
|
507
|
-
const filteredStack = config.stack === void 0 ? {} : {
|
|
508
|
-
stack: Object.fromEntries(
|
|
509
|
-
typedEntries(config.stack).map(([agentName2, agentStack]) => [
|
|
510
|
-
agentName2,
|
|
511
|
-
Object.fromEntries(
|
|
512
|
-
typedEntries(agentStack).map(([category, assignments]) => [
|
|
513
|
-
category,
|
|
514
|
-
assignments.filter((a) => !excludedIds.has(a.id))
|
|
515
|
-
])
|
|
516
|
-
)
|
|
517
|
-
])
|
|
518
|
-
)
|
|
519
|
-
};
|
|
520
|
-
return { ...config, skills: activeSkills, agents: activeAgents, ...filteredStack };
|
|
521
|
-
}
|
|
522
|
-
async function recompileAgents(options) {
|
|
523
|
-
const { pluginDir, sourcePath, skills: providedSkills, projectDir, outputDir } = options;
|
|
524
|
-
const configDir = projectDir ?? pluginDir;
|
|
525
|
-
const loadedConfig = await loadProjectConfig(configDir);
|
|
526
|
-
const projectConfig = loadedConfig?.config ?? null;
|
|
527
|
-
const filteredConfig = projectConfig ? filterExcludedEntries(projectConfig) : null;
|
|
528
|
-
const builtinAgents = await loadAllAgents(sourcePath);
|
|
529
|
-
const projectAgents = projectDir ? await loadProjectAgents(projectDir) : {};
|
|
530
|
-
const allAgents = {
|
|
531
|
-
...builtinAgents,
|
|
532
|
-
...projectAgents
|
|
533
|
-
};
|
|
534
|
-
const agentNames = await resolveAgentNames({
|
|
535
|
-
...options.agents !== void 0 && { specifiedAgents: options.agents },
|
|
536
|
-
projectConfig: filteredConfig,
|
|
537
|
-
allAgents,
|
|
538
|
-
...outputDir !== void 0 && { outputDir },
|
|
539
|
-
pluginDir
|
|
540
|
-
});
|
|
541
|
-
if (agentNames.length === 0) {
|
|
542
|
-
return { compiled: [], rewritten: [], failed: [], warnings: ["No agents found to recompile"] };
|
|
543
|
-
}
|
|
544
|
-
verbose(`Recompiling ${agentNames.length} agents in ${outputDir ?? pluginDir}`);
|
|
545
|
-
const pluginSkills = providedSkills ?? await discoverAllPluginSkills(projectDir ?? pluginDir);
|
|
546
|
-
const allConfigAgents = filteredConfig ? buildCompileAgents(filteredConfig, allAgents) : {};
|
|
547
|
-
const [knownAgents, missingAgents] = partition2(
|
|
548
|
-
agentNames,
|
|
549
|
-
(name) => Boolean(allConfigAgents[name] || allAgents[name])
|
|
550
|
-
);
|
|
551
|
-
const missingWarnings = missingAgents.map(
|
|
552
|
-
(name) => `Agent "${name}" not found in source definitions`
|
|
553
|
-
);
|
|
554
|
-
const configAgents = typedFromEntries(
|
|
555
|
-
knownAgents.map((name) => [name, allConfigAgents[name] ?? {}])
|
|
556
|
-
);
|
|
557
|
-
const compileConfig = {
|
|
558
|
-
name: filteredConfig?.name || path6.basename(pluginDir),
|
|
559
|
-
description: filteredConfig?.description || "Recompiled plugin",
|
|
560
|
-
agents: configAgents
|
|
561
|
-
};
|
|
562
|
-
const engine = await createLiquidEngine(projectDir);
|
|
563
|
-
const resolvedAgents = await resolveAgents(allAgents, pluginSkills, compileConfig, sourcePath);
|
|
564
|
-
const agentsDir = outputDir ?? getPluginAgentsDir(pluginDir);
|
|
565
|
-
await ensureDir(agentsDir);
|
|
566
|
-
const outcomes = await writeCompiledAgentsByScope({
|
|
567
|
-
resolvedAgents,
|
|
568
|
-
sourcePath,
|
|
569
|
-
engine,
|
|
570
|
-
projectAgentsDir: agentsDir,
|
|
571
|
-
...options.agentScopeMap !== void 0 && { agentScopeMap: options.agentScopeMap }
|
|
572
|
-
});
|
|
573
|
-
return buildRecompileResult(outcomes, missingWarnings);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// src/cli/lib/agents/agent-plugin-compiler.ts
|
|
577
|
-
import path7 from "path";
|
|
578
|
-
var NO_FRONTMATTER_REASON = "no YAML frontmatter block";
|
|
579
|
-
function parseAgentFrontmatter(content) {
|
|
580
|
-
const raw = extractFrontmatter(content);
|
|
581
|
-
if (!raw) {
|
|
582
|
-
return { ok: false, reason: NO_FRONTMATTER_REASON };
|
|
583
|
-
}
|
|
584
|
-
const result = agentFrontmatterValidationSchema.safeParse(raw);
|
|
585
|
-
if (!result.success) {
|
|
586
|
-
return { ok: false, reason: formatZodIssues(result.error.issues) };
|
|
587
|
-
}
|
|
588
|
-
return {
|
|
589
|
-
ok: true,
|
|
590
|
-
frontmatter: { name: result.data.name, description: result.data.description }
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
async function compileAgentPlugin(options) {
|
|
594
|
-
const { agentPath, outputDir } = options;
|
|
595
|
-
const fileName = path7.basename(agentPath);
|
|
596
|
-
const content = await readFile(agentPath);
|
|
597
|
-
const parsed = parseAgentFrontmatter(content);
|
|
598
|
-
if (!parsed.ok) {
|
|
599
|
-
throw new Error(
|
|
600
|
-
`Agent '${fileName}' has invalid or missing YAML frontmatter: ${parsed.reason}. File: ${agentPath}`
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
const agentName2 = parsed.frontmatter.name;
|
|
604
|
-
verbose(`Compiling agent plugin: ${agentName2} from ${agentPath}`);
|
|
605
|
-
const pluginDir = path7.join(outputDir, `agent-${agentName2}`);
|
|
606
|
-
const agentsDir = path7.join(pluginDir, "agents");
|
|
607
|
-
await ensureDir(pluginDir);
|
|
608
|
-
await ensureDir(agentsDir);
|
|
609
|
-
const newHash = computeStringHash(content);
|
|
610
|
-
const { version, contentHash } = await determinePluginVersion(
|
|
611
|
-
newHash,
|
|
612
|
-
pluginDir,
|
|
613
|
-
getPluginManifestPath
|
|
614
|
-
);
|
|
615
|
-
const manifest = generateAgentPluginManifest({
|
|
616
|
-
agentName: agentName2,
|
|
617
|
-
description: parsed.frontmatter.description,
|
|
618
|
-
version
|
|
619
|
-
});
|
|
620
|
-
await writePluginManifest(pluginDir, manifest);
|
|
621
|
-
await writeContentHash(pluginDir, contentHash, getPluginManifestPath);
|
|
622
|
-
verbose(` Wrote plugin.json for ${agentName2} (v${version})`);
|
|
623
|
-
await copy(agentPath, path7.join(agentsDir, `${agentName2}.md`));
|
|
624
|
-
verbose(` Copied agent ${fileName} -> agents/${agentName2}.md`);
|
|
625
|
-
return {
|
|
626
|
-
pluginPath: pluginDir,
|
|
627
|
-
manifest,
|
|
628
|
-
agentName: agentName2
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
async function compileAllAgentPlugins(agentsDir, outputDir) {
|
|
632
|
-
const results = [];
|
|
633
|
-
const agentMdFiles = await listAgentMdFiles(agentsDir);
|
|
634
|
-
for (const agentFile of agentMdFiles) {
|
|
635
|
-
const agentPath = path7.join(agentsDir, agentFile);
|
|
636
|
-
try {
|
|
637
|
-
const result = await compileAgentPlugin({
|
|
638
|
-
agentPath,
|
|
639
|
-
outputDir
|
|
640
|
-
});
|
|
641
|
-
results.push(result);
|
|
642
|
-
log(` [OK] agent-${result.agentName}`);
|
|
643
|
-
} catch (error) {
|
|
644
|
-
const errorMessage = getErrorMessage(error);
|
|
645
|
-
warn(`Failed to compile agent from '${agentFile}': ${errorMessage}`);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
return results;
|
|
649
|
-
}
|
|
650
|
-
function printAgentCompilationSummary(results) {
|
|
651
|
-
log(`
|
|
652
|
-
Compiled ${results.length} agent plugins:`);
|
|
653
|
-
for (const result of results) {
|
|
654
|
-
log(` - agent-${result.agentName} (v${result.manifest.version})`);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
export {
|
|
659
|
-
listAgentMdFiles,
|
|
660
|
-
splitAgentsByProvenance,
|
|
661
|
-
pruneStaleCompiledAgents,
|
|
662
|
-
getAgentDefinitions,
|
|
663
|
-
filterExcludedEntries,
|
|
664
|
-
recompileAgents,
|
|
665
|
-
compileAllAgentPlugins,
|
|
666
|
-
printAgentCompilationSummary
|
|
667
|
-
};
|
|
668
|
-
//# sourceMappingURL=chunk-JU4ZGJ7A.js.map
|