agents-inc 0.171.0 → 0.173.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/{chunk-W4KAY26P.js → chunk-2RTBSLSR.js} +12 -3
  3. package/dist/{chunk-W4KAY26P.js.map → chunk-2RTBSLSR.js.map} +1 -1
  4. package/dist/{chunk-WM2N2D6Q.js → chunk-3N4FSTVX.js} +12 -6
  5. package/dist/{chunk-WM2N2D6Q.js.map → chunk-3N4FSTVX.js.map} +1 -1
  6. package/dist/{chunk-ZC6GC66J.js → chunk-3R3LHA4Q.js} +2 -2
  7. package/dist/{chunk-24OD7IP4.js → chunk-7OG635DK.js} +26 -4
  8. package/dist/chunk-7OG635DK.js.map +1 -0
  9. package/dist/{chunk-WDH6HHA3.js → chunk-A3ZAXL5T.js} +4 -5
  10. package/dist/{chunk-WDH6HHA3.js.map → chunk-A3ZAXL5T.js.map} +1 -1
  11. package/dist/{chunk-KMOCMVK5.js → chunk-AARQBW5L.js} +106 -60
  12. package/dist/chunk-AARQBW5L.js.map +1 -0
  13. package/dist/{chunk-WII6GOPM.js → chunk-BRZA7ZCX.js} +52 -31
  14. package/dist/chunk-BRZA7ZCX.js.map +1 -0
  15. package/dist/{chunk-AWWCRL5A.js → chunk-EHJIQDXR.js} +8 -6
  16. package/dist/{chunk-AWWCRL5A.js.map → chunk-EHJIQDXR.js.map} +1 -1
  17. package/dist/{chunk-RDXY4GRO.js → chunk-F437ICEG.js} +2 -2
  18. package/dist/chunk-G7NUK3BF.js +253 -0
  19. package/dist/chunk-G7NUK3BF.js.map +1 -0
  20. package/dist/{chunk-7IVLVEHX.js → chunk-ITQF35UQ.js} +3 -3
  21. package/dist/{chunk-QIR56IDM.js → chunk-LJQXQTFC.js} +29 -102
  22. package/dist/chunk-LJQXQTFC.js.map +1 -0
  23. package/dist/{chunk-A6OWEJGC.js → chunk-MHAQWMNJ.js} +35 -5
  24. package/dist/{chunk-A6OWEJGC.js.map → chunk-MHAQWMNJ.js.map} +1 -1
  25. package/dist/{chunk-YLUOGAW7.js → chunk-N33AKFLR.js} +2 -2
  26. package/dist/{chunk-TNFYBKVD.js → chunk-Q4UNHVPX.js} +25 -14
  27. package/dist/chunk-Q4UNHVPX.js.map +1 -0
  28. package/dist/chunk-Q6WRR4BN.js +195 -0
  29. package/dist/chunk-Q6WRR4BN.js.map +1 -0
  30. package/dist/{chunk-JGPE4RRE.js → chunk-SPQSNZMM.js} +2 -2
  31. package/dist/{chunk-EOKNEGRD.js → chunk-VR6QTK5Z.js} +8 -8
  32. package/dist/{chunk-S2SKVJT2.js → chunk-VSPC74SS.js} +48 -26
  33. package/dist/chunk-VSPC74SS.js.map +1 -0
  34. package/dist/{chunk-3YYHL76L.js → chunk-WVFBBZEP.js} +648 -394
  35. package/dist/chunk-WVFBBZEP.js.map +1 -0
  36. package/dist/commands/build/marketplace.js +16 -14
  37. package/dist/commands/build/marketplace.js.map +1 -1
  38. package/dist/commands/build/plugins.js +6 -6
  39. package/dist/commands/compile.js +12 -12
  40. package/dist/commands/doctor.js +87 -86
  41. package/dist/commands/doctor.js.map +1 -1
  42. package/dist/commands/edit.js +150 -152
  43. package/dist/commands/edit.js.map +1 -1
  44. package/dist/commands/eject.js +25 -30
  45. package/dist/commands/eject.js.map +1 -1
  46. package/dist/commands/init.js +19 -16
  47. package/dist/commands/list.js +14 -17
  48. package/dist/commands/list.js.map +1 -1
  49. package/dist/commands/new/marketplace.js +4 -4
  50. package/dist/commands/search.js +15 -13
  51. package/dist/commands/search.js.map +1 -1
  52. package/dist/commands/share.js +11 -11
  53. package/dist/commands/uninstall.js +145 -130
  54. package/dist/commands/uninstall.js.map +1 -1
  55. package/dist/commands/update.js +6 -6
  56. package/dist/components/common/scroll-affordance.js +2 -2
  57. package/dist/components/common/select-list.js +2 -2
  58. package/dist/components/common/skill-agent-summary.js +3 -4
  59. package/dist/components/common/summary-panel.js +11 -146
  60. package/dist/components/common/summary-panel.js.map +1 -1
  61. package/dist/hooks/init.js +39 -27
  62. package/dist/hooks/init.js.map +1 -1
  63. package/dist/load-agent-defs-E67DSYTN.js +14 -0
  64. package/dist/{recompile-project-agents-IQANWGOP.js → recompile-project-agents-6G6M2RS6.js} +8 -8
  65. package/dist/{source-loader-YGG7DY2W.js → source-loader-W7XCNKNA.js} +4 -4
  66. package/dist/src/agents/tester/web-tester/playbook.md +1 -1
  67. package/package.json +1 -1
  68. package/src/agents/tester/web-tester/playbook.md +1 -1
  69. package/dist/chunk-24OD7IP4.js.map +0 -1
  70. package/dist/chunk-3YYHL76L.js.map +0 -1
  71. package/dist/chunk-4RQKCV6I.js +0 -103
  72. package/dist/chunk-4RQKCV6I.js.map +0 -1
  73. package/dist/chunk-5FM77WKW.js +0 -69
  74. package/dist/chunk-5FM77WKW.js.map +0 -1
  75. package/dist/chunk-KMOCMVK5.js.map +0 -1
  76. package/dist/chunk-QIR56IDM.js.map +0 -1
  77. package/dist/chunk-R572RLTI.js +0 -108
  78. package/dist/chunk-R572RLTI.js.map +0 -1
  79. package/dist/chunk-S2SKVJT2.js.map +0 -1
  80. package/dist/chunk-TNFYBKVD.js.map +0 -1
  81. package/dist/chunk-WII6GOPM.js.map +0 -1
  82. package/dist/components/common/removal-plan-confirm.js +0 -10
  83. package/dist/load-agent-defs-UBWITIEI.js +0 -14
  84. package/dist/source-loader-YGG7DY2W.js.map +0 -1
  85. /package/dist/{chunk-ZC6GC66J.js.map → chunk-3R3LHA4Q.js.map} +0 -0
  86. /package/dist/{chunk-RDXY4GRO.js.map → chunk-F437ICEG.js.map} +0 -0
  87. /package/dist/{chunk-7IVLVEHX.js.map → chunk-ITQF35UQ.js.map} +0 -0
  88. /package/dist/{chunk-YLUOGAW7.js.map → chunk-N33AKFLR.js.map} +0 -0
  89. /package/dist/{chunk-JGPE4RRE.js.map → chunk-SPQSNZMM.js.map} +0 -0
  90. /package/dist/{chunk-EOKNEGRD.js.map → chunk-VR6QTK5Z.js.map} +0 -0
  91. /package/dist/{components/common/removal-plan-confirm.js.map → load-agent-defs-E67DSYTN.js.map} +0 -0
  92. /package/dist/{recompile-project-agents-IQANWGOP.js.map → recompile-project-agents-6G6M2RS6.js.map} +0 -0
  93. /package/dist/{load-agent-defs-UBWITIEI.js.map → source-loader-W7XCNKNA.js.map} +0 -0
@@ -1,36 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  listAgentMdFiles
4
- } from "./chunk-AWWCRL5A.js";
4
+ } from "./chunk-EHJIQDXR.js";
5
5
  import {
6
6
  agentCodec,
7
7
  agentFrontmatterValidationSchema,
8
8
  agentPluginName,
9
+ clearEarlierBuild,
10
+ computeShippedHash,
9
11
  computeStringHash,
10
12
  copy,
11
- determinePluginVersion,
12
13
  directoryExists,
13
- ensureDir,
14
14
  extractFrontmatter,
15
15
  formatZodIssues,
16
16
  generateAgentPluginManifest,
17
17
  getErrorMessage,
18
18
  getPluginAgentsDir,
19
19
  getPluginManifestPath,
20
+ holdsContentNoBuildMade,
21
+ isPathWithin,
20
22
  log,
23
+ readEarlierBuild,
21
24
  readFile,
22
25
  verbose,
26
+ versionAfterRebuild,
23
27
  warn,
24
28
  writeContentHash,
25
29
  writePluginManifest
26
- } from "./chunk-3YYHL76L.js";
30
+ } from "./chunk-WVFBBZEP.js";
27
31
  import {
28
32
  plural
29
- } from "./chunk-24OD7IP4.js";
33
+ } from "./chunk-7OG635DK.js";
30
34
  import {
35
+ DEFAULT_VERSION,
31
36
  DIRS,
37
+ PLUGIN_MANIFEST_DIR,
38
+ PLUGIN_MANIFEST_FILE,
32
39
  PROJECT_ROOT
33
- } from "./chunk-A6OWEJGC.js";
40
+ } from "./chunk-MHAQWMNJ.js";
34
41
 
35
42
  // src/cli/lib/agents/agent-fetcher.ts
36
43
  import path from "path";
@@ -65,39 +72,53 @@ function parseAgentFrontmatter(content) {
65
72
  frontmatter: { name: result.data.name, description: result.data.description }
66
73
  };
67
74
  }
68
- async function compileAgentPlugin(options) {
69
- const { agentPath, outputDir } = options;
70
- const fileName = path2.basename(agentPath);
75
+ async function assertClearable(pluginDir, agentPath) {
76
+ const agent = `Agent '${path2.basename(agentPath)}'`;
77
+ const file = `File: ${agentPath}`;
78
+ if (isPathWithin(agentPath, pluginDir)) {
79
+ throw new Error(
80
+ `${agent} would be built into ${pluginDir}, which holds its own source, so building it would overwrite that source. Build into an output directory outside the agents directory. ${file}`
81
+ );
82
+ }
83
+ if (await holdsContentNoBuildMade(pluginDir)) {
84
+ throw new Error(
85
+ `${agent} would be built into ${pluginDir}, which holds no ${path2.join(PLUGIN_MANIFEST_DIR, PLUGIN_MANIFEST_FILE)} and is not empty, so no earlier build made it and a rebuild would delete what it holds. Move its contents out, or build into another output directory. ${file}`
86
+ );
87
+ }
88
+ }
89
+ async function readAgentToBuild(agentPath) {
71
90
  const content = await readFile(agentPath);
72
91
  const parsed = parseAgentFrontmatter(content);
73
92
  if (!parsed.ok) {
74
93
  throw new Error(
75
- `Agent '${fileName}' has invalid or missing YAML frontmatter: ${parsed.reason}. File: ${agentPath}`
94
+ `Agent '${path2.basename(agentPath)}' has invalid or missing YAML frontmatter: ${parsed.reason}. File: ${agentPath}`
76
95
  );
77
96
  }
78
- const agentName = parsed.frontmatter.name;
79
- verbose(`Compiling agent plugin: ${agentName} from ${agentPath}`);
97
+ return { content, frontmatter: parsed.frontmatter };
98
+ }
99
+ async function copyAgentInto(pluginDir, agentPath, agentName) {
100
+ const pluginAgentFile = `${agentName}${agentCodec("claude").extension}`;
101
+ await copy(agentPath, path2.join(getPluginAgentsDir(pluginDir), pluginAgentFile));
102
+ verbose(` Copied agent ${path2.basename(agentPath)} -> agents/${pluginAgentFile}`);
103
+ }
104
+ async function compileAgentPlugin(options) {
105
+ const { agentPath, outputDir } = options;
106
+ const { content, frontmatter } = await readAgentToBuild(agentPath);
107
+ const agentName = frontmatter.name;
80
108
  const pluginDir = path2.join(outputDir, agentPluginName(agentName));
81
- const agentsDir = getPluginAgentsDir(pluginDir);
82
- await ensureDir(pluginDir);
83
- await ensureDir(agentsDir);
84
- const newHash = computeStringHash(content);
85
- const { version, contentHash } = await determinePluginVersion(
86
- newHash,
87
- pluginDir,
88
- getPluginManifestPath
109
+ await assertClearable(pluginDir, agentPath);
110
+ verbose(`Compiling agent plugin: ${agentName} from ${agentPath}`);
111
+ const manifestAt = (version) => generateAgentPluginManifest({ agentName, description: frontmatter.description, version });
112
+ const earlierBuild = await readEarlierBuild(pluginDir, getPluginManifestPath);
113
+ await clearEarlierBuild(pluginDir);
114
+ await writePluginManifest(pluginDir, manifestAt(earlierBuild?.version ?? DEFAULT_VERSION));
115
+ await writeContentHash(pluginDir, computeStringHash(content), getPluginManifestPath);
116
+ await copyAgentInto(pluginDir, agentPath, agentName);
117
+ const manifest = manifestAt(
118
+ versionAfterRebuild(earlierBuild, await computeShippedHash(pluginDir))
89
119
  );
90
- const manifest = generateAgentPluginManifest({
91
- agentName,
92
- description: parsed.frontmatter.description,
93
- version
94
- });
95
120
  await writePluginManifest(pluginDir, manifest);
96
- await writeContentHash(pluginDir, contentHash, getPluginManifestPath);
97
- verbose(` Wrote plugin.json for ${agentName} (v${version})`);
98
- const pluginAgentFile = `${agentName}${agentCodec("claude").extension}`;
99
- await copy(agentPath, path2.join(agentsDir, pluginAgentFile));
100
- verbose(` Copied agent ${fileName} -> agents/${pluginAgentFile}`);
121
+ verbose(` Wrote plugin.json for ${agentName} (v${manifest.version})`);
101
122
  return {
102
123
  pluginPath: pluginDir,
103
124
  manifest,
@@ -136,4 +157,4 @@ export {
136
157
  compileAllAgentPlugins,
137
158
  printAgentCompilationSummary
138
159
  };
139
- //# sourceMappingURL=chunk-WII6GOPM.js.map
160
+ //# sourceMappingURL=chunk-BRZA7ZCX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/lib/agents/agent-fetcher.ts","../src/cli/lib/agents/agent-plugin-compiler.ts"],"sourcesContent":["import path from \"path\";\nimport { directoryExists } from \"../../utils/fs\";\nimport { verbose } from \"../../utils/logger\";\nimport { PROJECT_ROOT, DIRS } from \"../../consts\";\nimport type { AgentSourcePaths } from \"../../types\";\n\nexport async function getLocalAgentDefinitions(): Promise<AgentSourcePaths> {\n const agentsDir = path.join(PROJECT_ROOT, DIRS.agents);\n\n if (!(await directoryExists(agentsDir))) {\n throw new Error(\n `Agent partials not found at '${agentsDir}'. Ensure the CLI is properly installed.`,\n );\n }\n\n verbose(`Agent partials loaded from CLI: ${agentsDir}`);\n\n return {\n agentsDir,\n sourcePath: PROJECT_ROOT,\n };\n}\n","import path from \"path\";\nimport { getErrorMessage } from \"../../utils/errors\";\nimport { readFile, copy, isPathWithin } from \"../../utils/fs\";\nimport { log, verbose, warn } from \"../../utils/logger\";\nimport {\n agentPluginName,\n clearEarlierBuild,\n generateAgentPluginManifest,\n getPluginAgentsDir,\n holdsContentNoBuildMade,\n writePluginManifest,\n getPluginManifestPath,\n} from \"../plugins\";\nimport { listAgentMdFiles } from \"./list-compiled-agents\";\nimport { agentCodec } from \"../installation/install-layout\";\nimport {\n computeShippedHash,\n computeStringHash,\n readEarlierBuild,\n versionAfterRebuild,\n writeContentHash,\n} from \"../versioning\";\nimport { extractFrontmatter } from \"../../utils/frontmatter\";\nimport { plural } from \"../../utils/string\";\nimport { DEFAULT_VERSION, PLUGIN_MANIFEST_DIR, PLUGIN_MANIFEST_FILE } from \"../../consts\";\nimport type { AgentFrontmatter, PluginManifest } from \"../../types\";\nimport { agentFrontmatterValidationSchema, formatZodIssues } from \"../schemas\";\n\ntype AgentPluginOptions = {\n agentPath: string;\n outputDir: string;\n};\n\ntype CompiledAgentPlugin = {\n pluginPath: string;\n manifest: PluginManifest;\n agentName: string;\n};\n\n/** Carries the reason out, so the throw in `compileAgentPlugin` names what actually went wrong. */\ntype AgentFrontmatterParse =\n | { ok: true; frontmatter: Pick<AgentFrontmatter, \"name\" | \"description\"> }\n | { ok: false; reason: string };\n\nconst NO_FRONTMATTER_REASON = \"no YAML frontmatter block\";\n\nfunction parseAgentFrontmatter(content: string): AgentFrontmatterParse {\n const raw = extractFrontmatter(content);\n if (!raw) {\n return { ok: false, reason: NO_FRONTMATTER_REASON };\n }\n\n const result = agentFrontmatterValidationSchema.safeParse(raw);\n if (!result.success) {\n return { ok: false, reason: formatZodIssues(result.error.issues) };\n }\n\n return {\n ok: true,\n frontmatter: { name: result.data.name, description: result.data.description },\n };\n}\n\n/**\n * A plugin's folder is cleared before each build, so it must not hold the agent's own source, nor\n * files no build made. The name needs no check: the frontmatter schema holds it to kebab-case.\n */\nasync function assertClearable(pluginDir: string, agentPath: string): Promise<void> {\n const agent = `Agent '${path.basename(agentPath)}'`;\n const file = `File: ${agentPath}`;\n\n if (isPathWithin(agentPath, pluginDir)) {\n throw new Error(\n `${agent} would be built into ${pluginDir}, which holds its own source, so building it would overwrite that source. Build into an output directory outside the agents directory. ${file}`,\n );\n }\n if (await holdsContentNoBuildMade(pluginDir)) {\n throw new Error(\n `${agent} would be built into ${pluginDir}, which holds no ${path.join(PLUGIN_MANIFEST_DIR, PLUGIN_MANIFEST_FILE)} and is not empty, so no earlier build made it and a rebuild would delete what it holds. Move its contents out, or build into another output directory. ${file}`,\n );\n }\n}\n\n/** A plugin is built from the agent's frontmatter, so one that is absent or invalid refuses. */\nasync function readAgentToBuild(\n agentPath: string,\n): Promise<{ content: string; frontmatter: Pick<AgentFrontmatter, \"name\" | \"description\"> }> {\n const content = await readFile(agentPath);\n const parsed = parseAgentFrontmatter(content);\n\n if (!parsed.ok) {\n throw new Error(\n `Agent '${path.basename(agentPath)}' has invalid or missing YAML frontmatter: ${parsed.reason}. ` +\n `File: ${agentPath}`,\n );\n }\n\n return { content, frontmatter: parsed.frontmatter };\n}\n\nasync function copyAgentInto(\n pluginDir: string,\n agentPath: string,\n agentName: string,\n): Promise<void> {\n const pluginAgentFile = `${agentName}${agentCodec(\"claude\").extension}`;\n await copy(agentPath, path.join(getPluginAgentsDir(pluginDir), pluginAgentFile));\n verbose(` Copied agent ${path.basename(agentPath)} -> agents/${pluginAgentFile}`);\n}\n\nasync function compileAgentPlugin(options: AgentPluginOptions): Promise<CompiledAgentPlugin> {\n const { agentPath, outputDir } = options;\n const { content, frontmatter } = await readAgentToBuild(agentPath);\n\n const agentName = frontmatter.name;\n const pluginDir = path.join(outputDir, agentPluginName(agentName));\n await assertClearable(pluginDir, agentPath);\n\n verbose(`Compiling agent plugin: ${agentName} from ${agentPath}`);\n\n const manifestAt = (version: string): PluginManifest =>\n generateAgentPluginManifest({ agentName, description: frontmatter.description, version });\n\n // Read before the clear: what the earlier build shipped decides whether the version moves.\n const earlierBuild = await readEarlierBuild(pluginDir, getPluginManifestPath);\n await clearEarlierBuild(pluginDir);\n\n // At the earlier build's version, so the version alone cannot set the two builds apart; and\n // first, so a build that stops halfway leaves a folder the next build may clear.\n await writePluginManifest(pluginDir, manifestAt(earlierBuild?.version ?? DEFAULT_VERSION));\n\n // Nothing reads it back. Every plugin built so far ships it, so dropping it would bump them all.\n await writeContentHash(pluginDir, computeStringHash(content), getPluginManifestPath);\n\n await copyAgentInto(pluginDir, agentPath, agentName);\n\n const manifest = manifestAt(\n versionAfterRebuild(earlierBuild, await computeShippedHash(pluginDir)),\n );\n await writePluginManifest(pluginDir, manifest);\n verbose(` Wrote plugin.json for ${agentName} (v${manifest.version})`);\n\n return {\n pluginPath: pluginDir,\n manifest,\n agentName,\n };\n}\n\nexport async function compileAllAgentPlugins(\n agentsDir: string,\n outputDir: string,\n): Promise<CompiledAgentPlugin[]> {\n const results: CompiledAgentPlugin[] = [];\n\n const agentMdFiles = await listAgentMdFiles(agentsDir);\n\n for (const agentFile of agentMdFiles) {\n const agentPath = path.join(agentsDir, agentFile);\n\n try {\n const result = await compileAgentPlugin({\n agentPath,\n outputDir,\n });\n results.push(result);\n log(` [OK] ${agentPluginName(result.agentName)}`);\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n warn(`Failed to compile agent from '${agentFile}': ${errorMessage}`);\n }\n }\n\n return results;\n}\n\nexport function printAgentCompilationSummary(results: CompiledAgentPlugin[]): void {\n log(`\\nCompiled ${plural(results.length, \"agent plugin\")}:`);\n for (const result of results) {\n log(` - ${agentPluginName(result.agentName)} (v${result.manifest.version})`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAMjB,eAAsB,2BAAsD;AAC1E,QAAM,YAAY,KAAK,KAAK,cAAc,KAAK,MAAM;AAErD,MAAI,CAAE,MAAM,gBAAgB,SAAS,GAAI;AACvC,UAAM,IAAI;AAAA,MACR,gCAAgC,SAAS;AAAA,IAC3C;AAAA,EACF;AAEA,UAAQ,mCAAmC,SAAS,EAAE;AAEtD,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,EACd;AACF;;;ACrBA,OAAOA,WAAU;AA4CjB,IAAM,wBAAwB;AAE9B,SAAS,sBAAsB,SAAwC;AACrE,QAAM,MAAM,mBAAmB,OAAO;AACtC,MAAI,CAAC,KAAK;AACR,WAAO,EAAE,IAAI,OAAO,QAAQ,sBAAsB;AAAA,EACpD;AAEA,QAAM,SAAS,iCAAiC,UAAU,GAAG;AAC7D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,IAAI,OAAO,QAAQ,gBAAgB,OAAO,MAAM,MAAM,EAAE;AAAA,EACnE;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,aAAa,EAAE,MAAM,OAAO,KAAK,MAAM,aAAa,OAAO,KAAK,YAAY;AAAA,EAC9E;AACF;AAMA,eAAe,gBAAgB,WAAmB,WAAkC;AAClF,QAAM,QAAQ,UAAUC,MAAK,SAAS,SAAS,CAAC;AAChD,QAAM,OAAO,SAAS,SAAS;AAE/B,MAAI,aAAa,WAAW,SAAS,GAAG;AACtC,UAAM,IAAI;AAAA,MACR,GAAG,KAAK,wBAAwB,SAAS,0IAA0I,IAAI;AAAA,IACzL;AAAA,EACF;AACA,MAAI,MAAM,wBAAwB,SA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qB;AAEnF,QAAM,cAAc,WAAW,WAAW,SAAS;AAEnD,QAAM,WAAW;AAAA,IACf,oBAAoB,cAAc,MAAM,mBAAmB,SAAS,CAAC;AAAA,EACvE;AACA,QAAM,oBAAoB,WAAW,QAAQ;AAC7C,UAAQ,2BAA2B,SAAS,MAAM,SAAS,OAAO,GAAG;AAErE,SAAO;AAAA,IACL,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,uBACpB,WACA,WACgC;AAChC,QAAM,UAAiC,CAAC;AAExC,QAAM,eAAe,MAAM,iBAAiB,SAAS;AAErD,aAAW,aAAa,cAAc;AACpC,UAAM,YAAYA,MAAK,KAAK,WAAW,SAAS;AAEhD,QAAI;AACF,YAAM,SAAS,MAAM,mBAAmB;AAAA,QACtC;AAAA,QACA;AAAA,MACF,CAAC;AACD,cAAQ,KAAK,MAAM;AACnB,UAAI,UAAU,gBAAgB,OAAO,SAAS,CAAC,EAAE;AAAA,IACnD,SAAS,OAAO;AACd,YAAM,eAAe,gBAAgB,KAAK;AAC1C,WAAK,iCAAiC,SAAS,MAAM,YAAY,EAAE;AAAA,IACrE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,6BAA6B,SAAsC;AACjF,MAAI;AAAA,WAAc,OAAO,QAAQ,QAAQ,cAAc,CAAC,GAAG;AAC3D,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,gBAAgB,OAAO,SAAS,CAAC,MAAM,OAAO,SAAS,OAAO,GAAG;AAAA,EAC9E;AACF;","names":["path","path"]}
@@ -27,12 +27,14 @@ import {
27
27
  resolveInstallPaths,
28
28
  sourceFolderInUse,
29
29
  sourceFolderName,
30
- typedEntries,
31
- typedFromEntries,
32
- typedKeys,
33
30
  verbose,
34
31
  writeFile
35
- } from "./chunk-3YYHL76L.js";
32
+ } from "./chunk-WVFBBZEP.js";
33
+ import {
34
+ typedEntries,
35
+ typedFromEntries,
36
+ typedKeys
37
+ } from "./chunk-7OG635DK.js";
36
38
  import {
37
39
  CLAUDE_DIR,
38
40
  DIRS,
@@ -40,7 +42,7 @@ import {
40
42
  STANDARD_DIRS,
41
43
  STANDARD_FILES,
42
44
  effectivelyExcludedSkillIds
43
- } from "./chunk-A6OWEJGC.js";
45
+ } from "./chunk-MHAQWMNJ.js";
44
46
 
45
47
  // src/cli/lib/agents/list-compiled-agents.ts
46
48
  import path from "path";
@@ -372,4 +374,4 @@ export {
372
374
  withoutExcludedAssignments,
373
375
  recompileAgents
374
376
  };
375
- //# sourceMappingURL=chunk-AWWCRL5A.js.map
377
+ //# sourceMappingURL=chunk-EHJIQDXR.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/lib/agents/list-compiled-agents.ts","../src/cli/lib/agents/agent-recompiler.ts","../src/cli/lib/agents/write-compiled-agents.ts","../src/cli/lib/compiler.ts","../src/cli/lib/agents/agent-provenance.ts"],"sourcesContent":["import path from \"path\";\nimport { partition } from \"remeda\";\nimport { glob, readFileOptional, remove } from \"../../utils/fs\";\nimport { isAgentName } from \"../../utils/type-guards\";\nimport { type AgentCodec, agentCodec } from \"../installation/install-layout\";\nimport type { AgentName } from \"../../types\";\n\n/**\n * The default codec; a caller on another host passes that host's\n * (`agentCodec(providerInUse(dir))`).\n */\nconst CLAUDE_AGENTS = agentCodec(\"claude\");\n\ntype AgentProvenanceSplit = {\n marked: string[];\n unmarked: string[];\n};\n\nexport async function listAgentMdFiles(agentsDir: string): Promise<string[]> {\n return listAgentFilesOf(agentsDir, CLAUDE_AGENTS);\n}\n\nexport async function listAgentFilesOf(agentsDir: string, codec: AgentCodec): Promise<string[]> {\n return glob(codec.listGlob, agentsDir);\n}\n\n/** An unreadable file lands in `unmarked`: \"cannot prove it is ours\" means leave it alone. */\nexport async function splitAgentsByProvenance(\n agentsDir: string,\n codec: AgentCodec = CLAUDE_AGENTS,\n): Promise<AgentProvenanceSplit> {\n const files = await listAgentFilesOf(agentsDir, codec);\n const classified = await Promise.all(\n files.map((file) => readAgentProvenance(agentsDir, file, codec)),\n );\n const [marked, unmarked] = partition(classified, (agent) => agent.compiledHere);\n\n return {\n marked: marked.map((agent) => agent.name),\n unmarked: unmarked.map((agent) => agent.name),\n };\n}\n\ntype ClassifiedAgent = { name: string; compiledHere: boolean };\n\nasync function readAgentProvenance(\n agentsDir: string,\n file: string,\n codec: AgentCodec,\n): Promise<ClassifiedAgent> {\n const content = await readFileOptional(path.join(agentsDir, file));\n return { name: path.basename(file, codec.extension), compiledHere: codec.hasMarker(content) };\n}\n\nexport async function listCompiledAgentNames(agentsDir: string): Promise<AgentName[]> {\n const files = await listAgentMdFiles(agentsDir);\n // Boundary cast: custom marketplace agents may fall outside the AgentName union.\n return files.map((f) => path.basename(f, CLAUDE_AGENTS.extension) as AgentName);\n}\n\n/**\n * Deletes built-in-named agent files not in `keep`, which must be the complete set for `agentsDir`.\n */\nexport async function pruneStaleCompiledAgents(\n agentsDir: string,\n keep: ReadonlySet<AgentName>,\n codec: AgentCodec = CLAUDE_AGENTS,\n): Promise<void> {\n const isStaleCompiledAgent = (file: string): boolean => {\n const name = path.basename(file, codec.extension);\n return isAgentName(name) && !keep.has(name);\n };\n\n const files = await listAgentFilesOf(agentsDir, codec);\n await Promise.all(\n files.filter(isStaleCompiledAgent).map((file) => remove(path.join(agentsDir, file))),\n );\n}\n","import { partition } from \"remeda\";\nimport { writeCompiledAgentsByScope, type AgentWriteOutcome } from \"./write-compiled-agents\";\nimport { listCompiledAgentNames } from \"./list-compiled-agents\";\nimport path from \"path\";\n\nimport { getErrorMessage } from \"../../utils/errors\";\nimport type {\n AgentDefinition,\n AgentName,\n CompileAgentConfig,\n CompileConfig,\n ProjectConfig,\n SkillDefinitionMap,\n SkillId,\n SkillScope,\n} from \"../../types\";\n\nimport { buildCompileAgents } from \"../installation/local-installer\";\nimport { ensureDir } from \"../../utils/fs\";\nimport { verbose } from \"../../utils/logger\";\nimport { typedEntries, typedFromEntries, typedKeys } from \"../../utils/typed-object\";\nimport { createLiquidEngine } from \"../compiler\";\nimport { loadProjectConfig, effectivelyExcludedSkillIds } from \"../configuration\";\nimport { loadAllAgents, loadProjectAgents } from \"../loading\";\nimport { getPluginAgentsDir } from \"../plugins\";\nimport { discoverAllPluginSkills } from \"../plugins/plugin-discovery\";\nimport { resolveAgents } from \"../resolver\";\n\nexport type RecompileAgentsOptions = {\n pluginDir: string;\n sourcePath: string;\n agents?: AgentName[];\n skills?: SkillDefinitionMap;\n projectDir?: string;\n outputDir?: string;\n /** When provided, routes agents by scope: global agents to ~/.claude/agents/, project agents to outputDir */\n agentScopeMap?: Map<AgentName, SkillScope>;\n};\n\nexport type RecompileAgentsResult = {\n compiled: AgentName[];\n /** The subset of `compiled` whose file content moved; the rest count as unchanged. */\n rewritten: AgentName[];\n failed: AgentName[];\n warnings: string[];\n};\n\nasync function getExistingAgentNames(pluginDir: string): Promise<AgentName[]> {\n return listCompiledAgentNames(getPluginAgentsDir(pluginDir));\n}\n\ntype ResolveAgentNamesParams = {\n specifiedAgents?: AgentName[];\n projectConfig: ProjectConfig | null;\n allAgents: Partial<Record<AgentName, AgentDefinition>>;\n outputDir?: string;\n pluginDir: string;\n};\n\nasync function resolveAgentNames(params: ResolveAgentNamesParams): Promise<AgentName[]> {\n const { specifiedAgents, projectConfig, allAgents, outputDir, pluginDir } = params;\n\n if (specifiedAgents) {\n return specifiedAgents;\n }\n\n // A present config is authoritative even when its roster is empty.\n if (projectConfig) {\n const agentNames = projectConfig.agents.map((a) => a.name);\n verbose(`Using agents from config: ${agentNames.join(\", \")}`);\n return agentNames;\n }\n\n if (outputDir) {\n const names = typedKeys<AgentName>(allAgents);\n verbose(`Using all available agents from source: ${names.join(\", \")}`);\n return names;\n }\n\n return getExistingAgentNames(pluginDir);\n}\n\nfunction buildRecompileResult(\n outcomes: AgentWriteOutcome[],\n priorWarnings: string[],\n): RecompileAgentsResult {\n const [succeeded, failedOutcomes] = partition(\n outcomes,\n (outcome): outcome is Extract<AgentWriteOutcome, { ok: true }> => outcome.ok,\n );\n succeeded.forEach((outcome) =>\n verbose(\n ` ${outcome.rewritten ? \"Rewrote\" : \"Unchanged\"}: ${outcome.name} (${outcome.scope} -> ${outcome.targetDir})`,\n ),\n );\n return {\n compiled: succeeded.map((outcome) => outcome.name),\n rewritten: succeeded.filter((outcome) => outcome.rewritten).map((outcome) => outcome.name),\n failed: failedOutcomes.map((outcome) => outcome.name),\n warnings: [\n ...priorWarnings,\n ...failedOutcomes.map(\n (outcome) => `Failed to compile ${outcome.name}: ${getErrorMessage(outcome.error)}`,\n ),\n ],\n };\n}\n\nexport function filterExcludedEntries(config: ProjectConfig): ProjectConfig {\n const excludedIds = effectivelyExcludedSkillIds(config.skills);\n const activeSkills = config.skills.filter((s) => !s.excluded);\n const activeAgents = config.agents.filter((a) => !a.excluded);\n\n // No stack stays absent rather than an explicit `undefined`.\n const filteredStack =\n config.stack === undefined\n ? {}\n : { stack: withoutExcludedAssignments(config.stack, excludedIds) };\n\n return { ...config, skills: activeSkills, agents: activeAgents, ...filteredStack };\n}\n\n/** Each agent and category keeps its key, even when left with no assignments. */\nexport function withoutExcludedAssignments(\n stack: NonNullable<ProjectConfig[\"stack\"]>,\n excludedIds: ReadonlySet<SkillId>,\n): NonNullable<ProjectConfig[\"stack\"]> {\n return Object.fromEntries(\n typedEntries(stack).map(([agentName, agentStack]) => [\n agentName,\n Object.fromEntries(\n typedEntries(agentStack).map(([category, assignments]) => [\n category,\n assignments.filter((assignment) => !excludedIds.has(assignment.id)),\n ]),\n ),\n ]),\n );\n}\n\nexport async function recompileAgents(\n options: RecompileAgentsOptions,\n): Promise<RecompileAgentsResult> {\n const { pluginDir, sourcePath, skills: providedSkills, projectDir, outputDir } = options;\n\n const configDir = projectDir ?? pluginDir;\n const filteredConfig = await loadConfigWithoutExclusions(configDir);\n const allAgents = await loadAgentDefinitions(sourcePath, projectDir);\n\n const agentNames = await resolveAgentNames({\n ...(options.agents !== undefined && { specifiedAgents: options.agents }),\n projectConfig: filteredConfig,\n allAgents,\n ...(outputDir !== undefined && { outputDir }),\n pluginDir,\n });\n\n // An empty pass is not a warning: callers report it off `compiled`.\n if (agentNames.length === 0) {\n return { compiled: [], rewritten: [], failed: [], warnings: [] };\n }\n\n verbose(`Recompiling ${agentNames.length} agents in ${outputDir ?? pluginDir}`);\n\n const pluginSkills: SkillDefinitionMap =\n providedSkills ?? (await discoverAllPluginSkills(projectDir ?? pluginDir));\n\n const { configAgents, missingWarnings } = compileEntriesFor(\n agentNames,\n filteredConfig,\n allAgents,\n );\n const compileConfig = compileConfigFor(filteredConfig, configAgents, pluginDir);\n\n const engine = await createLiquidEngine(projectDir);\n const resolvedAgents = await resolveAgents(allAgents, pluginSkills, compileConfig);\n\n const agentsDir = outputDir ?? getPluginAgentsDir(pluginDir);\n await ensureDir(agentsDir);\n\n const outcomes = await writeCompiledAgentsByScope({\n resolvedAgents,\n sourcePath,\n engine,\n projectAgentsDir: agentsDir,\n // Same root as the config, so format and configuration come from one installation.\n projectDir: configDir,\n ...(options.agentScopeMap !== undefined && { agentScopeMap: options.agentScopeMap }),\n });\n return buildRecompileResult(outcomes, missingWarnings);\n}\n\nasync function loadConfigWithoutExclusions(configDir: string): Promise<ProjectConfig | null> {\n const loaded = await loadProjectConfig(configDir);\n return loaded ? filterExcludedEntries(loaded.config) : null;\n}\n\n/** A project agent wins over a built-in one of the same name. */\nasync function loadAgentDefinitions(\n sourcePath: string,\n projectDir: string | undefined,\n): Promise<Partial<Record<AgentName, AgentDefinition>>> {\n const builtinAgents = await loadAllAgents(sourcePath);\n const projectAgents = projectDir ? await loadProjectAgents(projectDir) : {};\n\n return { ...builtinAgents, ...projectAgents };\n}\n\nfunction compileConfigFor(\n config: ProjectConfig | null,\n agents: Partial<Record<AgentName, CompileAgentConfig>>,\n pluginDir: string,\n): CompileConfig {\n return {\n name: config?.name || path.basename(pluginDir),\n description: config?.description || \"Recompiled plugin\",\n agents,\n };\n}\n\n/** Only agents the scope filter matches: a project pass must not overwrite stackless globals. */\nfunction compileEntriesFor(\n agentNames: AgentName[],\n config: ProjectConfig | null,\n allAgents: Partial<Record<AgentName, AgentDefinition>>,\n): { configAgents: Partial<Record<AgentName, CompileAgentConfig>>; missingWarnings: string[] } {\n const allConfigAgents = config ? buildCompileAgents(config, allAgents) : {};\n\n const [knownAgents, missingAgents] = partition(agentNames, (name) =>\n Boolean(allConfigAgents[name] || allAgents[name]),\n );\n\n return {\n configAgents: typedFromEntries<AgentName, CompileAgentConfig>(\n knownAgents.map((name) => [name, allConfigAgents[name] ?? {}]),\n ),\n missingWarnings: missingAgents.map((name) => `Agent \"${name}\" not found in source definitions`),\n };\n}\n","import os from \"os\";\nimport path from \"path\";\nimport type { Liquid } from \"liquidjs\";\nimport { compileAgentForHost } from \"../compiler.js\";\nimport { resolveInstallPaths } from \"../installation/install-base-dir.js\";\nimport { agentCodec, hostCompilesAgent, providerInUse } from \"../installation/install-layout.js\";\nimport { writeFile, fileExists, readFile } from \"../../utils/fs.js\";\nimport { typedEntries } from \"../../utils/typed-object.js\";\nimport type { Provider } from \"../../consts.js\";\nimport type { AgentConfig, AgentName, SkillScope } from \"../../types/index.js\";\n\nexport type AgentWriteOutcome =\n | {\n name: AgentName;\n ok: true;\n scope: SkillScope;\n targetDir: string;\n /** False when the output matched the file on disk, so nothing was written. */\n rewritten: boolean;\n }\n | { name: AgentName; ok: false; error: unknown };\n\n/** Skipping an identical write keeps the mtime, the only trace telling unchanged from rewritten. */\nasync function holdsExactly(filePath: string, content: string): Promise<boolean> {\n return (await fileExists(filePath)) && (await readFile(filePath)) === content;\n}\n\n/**\n * Routing for an agent the scope map does not name: the caller's `projectAgentsDir`. Deliberately\n * not the selection default, which would move unrouted agents into `~/.claude/agents`.\n */\nconst UNROUTED_AGENT_SCOPE: SkillScope = \"project\";\n\n/**\n * Per-agent failures come back as outcomes; a directory appears only when an agent routes into it.\n */\nexport async function writeCompiledAgentsByScope(params: {\n resolvedAgents: Partial<Record<AgentName, AgentConfig>>;\n sourcePath: string;\n engine: Liquid;\n projectAgentsDir: string;\n /** The root whose folder says which host the PROJECT scope's sub-agents are written for. */\n projectDir: string;\n agentScopeMap?: Map<AgentName, SkillScope>;\n}): Promise<AgentWriteOutcome[]> {\n const hosts: Record<SkillScope, AgentHost> = {\n // Each scope reads its own root: a Codex project under a Claude global is allowed.\n global: {\n provider: providerInUse(os.homedir()),\n agentsDir: resolveInstallPaths(os.homedir(), \"global\").agentsDir,\n },\n project: { provider: providerInUse(params.projectDir), agentsDir: params.projectAgentsDir },\n };\n\n const outcomes: AgentWriteOutcome[] = [];\n for (const [name, agent] of typedEntries<AgentName, AgentConfig>(params.resolvedAgents)) {\n const scope = params.agentScopeMap?.get(name) ?? UNROUTED_AGENT_SCOPE;\n const host = hosts[scope];\n\n // No outcome for a sub-agent this host does not carry: it was neither compiled nor failed.\n if (!hostCompilesAgent(host.provider, name)) continue;\n\n outcomes.push(await writeOneAgent({ ...params, name, agent, scope, host }));\n }\n return outcomes;\n}\n\n/** Returns the failure rather than throwing: the policy is the caller's. */\nasync function writeOneAgent(params: {\n name: AgentName;\n agent: AgentConfig;\n scope: SkillScope;\n host: AgentHost;\n sourcePath: string;\n engine: Liquid;\n}): Promise<AgentWriteOutcome> {\n const { name, scope, host } = params;\n\n try {\n const output = await compileAgentForHost(\n host.provider,\n name,\n params.agent,\n params.sourcePath,\n params.engine,\n );\n const targetPath = path.join(host.agentsDir, fileNameFor(name, host.provider));\n const rewritten = !(await holdsExactly(targetPath, output));\n if (rewritten) await writeFile(targetPath, output);\n\n return { name, ok: true, scope, targetDir: host.agentsDir, rewritten };\n } catch (error) {\n return { name, ok: false, error };\n }\n}\n\ntype AgentHost = { provider: Provider; agentsDir: string };\n\n/** The extension comes from `agentCodec`, so a `.md` never lands where Codex reads `.toml`. */\nfunction fileNameFor(name: AgentName, provider: Provider): string {\n return `${name}${agentCodec(provider).extension}`;\n}\n","import { Liquid } from \"liquidjs\";\nimport path from \"path\";\nimport {\n buildAgentTemplateContext,\n pluginRefFor,\n renderAgent,\n renderAgentBody,\n renderAgentRoleToml,\n type AgentFiles,\n} from \"@workspace/compile/agent-source\";\nimport { readFile, readFileOptional, directoryExists } from \"../utils/fs\";\nimport { verbose } from \"../utils/logger\";\nimport {\n CLAUDE_DIR,\n DIRS,\n PROJECT_ROOT,\n STANDARD_FILES,\n STANDARD_DIRS,\n type Provider,\n} from \"../consts\";\nimport { providerInUse, sourceFolderInUse, sourceFolderName } from \"./installation/install-layout\";\nimport { cliVersion } from \"./agents/agent-provenance\";\nimport \"./compile-seat.js\";\nimport type { AgentConfig, AgentName } from \"../types\";\n\nexport {\n buildAgentTemplateContext,\n sanitizeCompiledAgentData,\n sanitizeLiquidSyntax,\n} from \"@workspace/compile/agent-source\";\n\nasync function readAgentFiles(\n name: AgentName,\n agent: AgentConfig,\n projectRoot: string,\n): Promise<AgentFiles> {\n const agentSourceRoot = agent.sourceRoot || projectRoot;\n const agentBaseDir = agent.agentBaseDir || DIRS.agents;\n const agentPath = agent.path || name;\n const agentDir = path.join(agentSourceRoot, agentBaseDir, agentPath);\n\n const identity = await readFile(path.join(agentDir, STANDARD_FILES.IDENTITY_MD));\n const playbook = await readFile(path.join(agentDir, STANDARD_FILES.PLAYBOOK_MD));\n const criticalRequirementsTop = await readFileOptional(\n path.join(agentDir, STANDARD_FILES.CRITICAL_REQUIREMENTS_MD),\n \"\",\n );\n const criticalReminders = await readFileOptional(\n path.join(agentDir, STANDARD_FILES.CRITICAL_REMINDERS_MD),\n \"\",\n );\n\n const category = agentPath.split(\"/\")[0] || name;\n const categoryDir = path.join(agentSourceRoot, agentBaseDir, category);\n const output = await readOutputPartial(agentDir, categoryDir);\n\n return { identity, playbook, output, criticalRequirementsTop, criticalReminders };\n}\n\n/** The agent's own `output.md`, or its category's where the agent's is absent or empty. */\nasync function readOutputPartial(agentDir: string, categoryDir: string): Promise<string> {\n const own = await readFileOptional(path.join(agentDir, STANDARD_FILES.OUTPUT_MD), \"\");\n if (own) return own;\n return readFileOptional(path.join(categoryDir, STANDARD_FILES.OUTPUT_MD), \"\");\n}\n\n/**\n * Template roots, first match wins: the project source folder's `agents/_templates/`, legacy\n * `.claude/templates/`, then the built-ins. The options mirror `createEngineFromTemplates` in\n * `@workspace/compile/engine`; keep the two in sync.\n */\nexport async function createLiquidEngine(projectDir?: string): Promise<Liquid> {\n const roots: string[] = [];\n // One read for both: template overrides and source folder must name one installation.\n const provider = providerInUse(projectDir);\n\n if (projectDir) {\n const srcTemplatesDir = path.join(\n sourceFolderInUse(projectDir, provider).dir,\n STANDARD_DIRS.AGENTS,\n path.basename(DIRS.templates),\n );\n if (await directoryExists(srcTemplatesDir)) {\n roots.push(srcTemplatesDir);\n verbose(`Using local templates from: ${srcTemplatesDir}`);\n }\n\n const legacyTemplatesDir = path.join(projectDir, CLAUDE_DIR, STANDARD_DIRS.TEMPLATES);\n if (await directoryExists(legacyTemplatesDir)) {\n roots.push(legacyTemplatesDir);\n verbose(`Using legacy templates from: ${legacyTemplatesDir}`);\n }\n }\n\n roots.push(path.join(PROJECT_ROOT, DIRS.templates));\n\n return new Liquid({\n root: roots,\n extname: \".liquid\",\n strictVariables: false,\n strictFilters: true,\n globals: { sourceFolder: sourceFolderName(projectDir, provider) },\n });\n}\n\n/** Both hosts render from one template context; only the wrapper differs (markdown or TOML). */\nexport async function compileAgentForHost(\n provider: Provider,\n name: AgentName,\n agent: AgentConfig,\n fallbackRoot: string,\n engine: Liquid,\n): Promise<string> {\n verbose(`Compiling agent: ${name} (${provider})`);\n\n const files = await readAgentFiles(name, agent, fallbackRoot);\n\n // Each skill's own `source` decides `${id}:${id}` versus a bare id; no `source` means bare.\n const data = buildAgentTemplateContext(name, agent, files, (skill) => ({\n ...skill,\n ...pluginRefFor(skill),\n }));\n const version = await cliVersion();\n\n switch (provider) {\n case \"claude\":\n return renderAgent(engine, data, version);\n case \"codex\":\n return renderAgentRoleToml(agent, await renderAgentBody(engine, data, version));\n default: {\n const _exhaustive: never = provider;\n return _exhaustive;\n }\n }\n}\n","import path from \"path\";\nimport { z } from \"zod\";\n\nimport { PROJECT_ROOT, STANDARD_FILES } from \"../../consts\";\nimport { readFile } from \"../../utils/fs\";\n\nconst ownPackageJsonSchema = z.object({ version: z.string().min(1) });\n\nexport {\n hasProvenanceMarker,\n provenanceMarker,\n stampProvenanceMarker,\n} from \"@workspace/compile/agent-source\";\n\nlet ownVersion: Promise<string> | undefined;\n\n/**\n * Rendered in the trailing `<system-reminder>`, not the provenance marker, so a version bump leaves\n * the first cacheable bytes of every compiled agent unchanged.\n */\nexport function cliVersion(): Promise<string> {\n ownVersion ??= readOwnVersion();\n return ownVersion;\n}\n\nasync function readOwnVersion(): Promise<string> {\n const manifestPath = path.join(PROJECT_ROOT, STANDARD_FILES.PACKAGE_JSON);\n const raw: unknown = JSON.parse(await readFile(manifestPath));\n\n const parsed = ownPackageJsonSchema.safeParse(raw);\n if (!parsed.success) {\n throw new Error(`Could not read this CLI's own version from ${manifestPath}`);\n }\n return parsed.data.version;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAU1B,IAAM,gBAAgB,WAAW,QAAQ;AAOzC,eAAsB,iBAAiB,WAAsC;AAC3E,SAAO,iBAAiB,WAAW,aAAa;AAClD;AAEA,eAAsB,iBAAiB,WAAmB,OAAsC;AAC9F,SAAO,KAAK,MAAM,UAAU,SAAS;AACvC;AAGA,eAAsB,wBACpB,WACA,QAAoB,eACW;AAC/B,QAAM,QAAQ,MAAM,iBAAiB,WAAW,KAAK;AACrD,QAAM,aAAa,MAAM,QAAQ;AAAA,IAC/B,MAAM,IAAI,CAAC,SAAS,oBAAoB,WAAW,MAAM,KAAK,CAAC;AAAA,EACjE;AACA,QAAM,CAAC,QAAQ,QAAQ,IAAI,UAAU,YAAY,CAAC,UAAU,MAAM,YAAY;AAE9E,SAAO;AAAA,IACL,QAAQ,OAAO,IAAI,CAAC,UAAU,MAAM,IAAI;AAA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aAAa,IAAID;AAAA,IAAU;AAAA,IAAY,CAAC,SAC1D,QAAQ,gBAAgB,IAAI,KAAK,UAAU,IAAI,CAAC;AAAA,EAClD;AAEA,SAAO;AAAA,IACL,cAAc;AAAA,MACZ,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM,gBAAgB,IAAI,KAAK,CAAC,CAAC,CAAC;AAAA,IAC/D;AAAA,IACA,iBAAiB,cAAc,IAAI,CAAC,SAAS,UAAU,IAAI,mCAAmC;AAAA,EAChG;AACF;","names":["partition","path","path","path","path","path","path","path","partition","path"]}
1
+ {"version":3,"sources":["../src/cli/lib/agents/list-compiled-agents.ts","../src/cli/lib/agents/agent-recompiler.ts","../src/cli/lib/agents/write-compiled-agents.ts","../src/cli/lib/compiler.ts","../src/cli/lib/agents/agent-provenance.ts"],"sourcesContent":["import path from \"path\";\nimport { partition } from \"remeda\";\nimport { glob, readFileOptional, remove } from \"../../utils/fs\";\nimport { isAgentName } from \"../../utils/type-guards\";\nimport { type AgentCodec, agentCodec } from \"../installation/install-layout\";\nimport type { AgentName } from \"../../types\";\n\n/**\n * The default codec; a caller on another host passes that host's\n * (`agentCodec(providerInUse(dir))`).\n */\nconst CLAUDE_AGENTS = agentCodec(\"claude\");\n\ntype AgentProvenanceSplit = {\n marked: string[];\n unmarked: string[];\n};\n\nexport async function listAgentMdFiles(agentsDir: string): Promise<string[]> {\n return listAgentFilesOf(agentsDir, CLAUDE_AGENTS);\n}\n\nexport async function listAgentFilesOf(agentsDir: string, codec: AgentCodec): Promise<string[]> {\n return glob(codec.listGlob, agentsDir);\n}\n\n/** An unreadable file lands in `unmarked`: \"cannot prove it is ours\" means leave it alone. */\nexport async function splitAgentsByProvenance(\n agentsDir: string,\n codec: AgentCodec = CLAUDE_AGENTS,\n): Promise<AgentProvenanceSplit> {\n const files = await listAgentFilesOf(agentsDir, codec);\n const classified = await Promise.all(\n files.map((file) => readAgentProvenance(agentsDir, file, codec)),\n );\n const [marked, unmarked] = partition(classified, (agent) => agent.compiledHere);\n\n return {\n marked: marked.map((agent) => agent.name),\n unmarked: unmarked.map((agent) => agent.name),\n };\n}\n\ntype ClassifiedAgent = { name: string; compiledHere: boolean };\n\nasync function readAgentProvenance(\n agentsDir: string,\n file: string,\n codec: AgentCodec,\n): Promise<ClassifiedAgent> {\n const content = await readFileOptional(path.join(agentsDir, file));\n return { name: path.basename(file, codec.extension), compiledHere: codec.hasMarker(content) };\n}\n\nexport async function listCompiledAgentNames(agentsDir: string): Promise<AgentName[]> {\n const files = await listAgentMdFiles(agentsDir);\n // Boundary cast: custom marketplace agents may fall outside the AgentName union.\n return files.map((f) => path.basename(f, CLAUDE_AGENTS.extension) as AgentName);\n}\n\n/**\n * Deletes built-in-named agent files not in `keep`, which must be the complete set for `agentsDir`.\n */\nexport async function pruneStaleCompiledAgents(\n agentsDir: string,\n keep: ReadonlySet<AgentName>,\n codec: AgentCodec = CLAUDE_AGENTS,\n): Promise<void> {\n const isStaleCompiledAgent = (file: string): boolean => {\n const name = path.basename(file, codec.extension);\n return isAgentName(name) && !keep.has(name);\n };\n\n const files = await listAgentFilesOf(agentsDir, codec);\n await Promise.all(\n files.filter(isStaleCompiledAgent).map((file) => remove(path.join(agentsDir, file))),\n );\n}\n","import { partition } from \"remeda\";\nimport { writeCompiledAgentsByScope, type AgentWriteOutcome } from \"./write-compiled-agents\";\nimport { listCompiledAgentNames } from \"./list-compiled-agents\";\nimport path from \"path\";\n\nimport { getErrorMessage } from \"../../utils/errors\";\nimport type {\n AgentDefinition,\n AgentName,\n CompileAgentConfig,\n CompileConfig,\n ProjectConfig,\n SkillDefinitionMap,\n SkillId,\n SkillScope,\n} from \"../../types\";\n\nimport { buildCompileAgents } from \"../installation/local-installer\";\nimport { ensureDir } from \"../../utils/fs\";\nimport { verbose } from \"../../utils/logger\";\nimport { typedEntries, typedFromEntries, typedKeys } from \"../../utils/typed-object\";\nimport { createLiquidEngine } from \"../compiler\";\nimport { loadProjectConfig, effectivelyExcludedSkillIds } from \"../configuration\";\nimport { loadAllAgents, loadProjectAgents } from \"../loading\";\nimport { getPluginAgentsDir } from \"../plugins\";\nimport { discoverAllPluginSkills } from \"../plugins/plugin-discovery\";\nimport { resolveAgents } from \"../resolver\";\n\nexport type RecompileAgentsOptions = {\n pluginDir: string;\n sourcePath: string;\n agents?: AgentName[];\n skills?: SkillDefinitionMap;\n projectDir?: string;\n outputDir?: string;\n /** When provided, routes agents by scope: global agents to ~/.claude/agents/, project agents to outputDir */\n agentScopeMap?: Map<AgentName, SkillScope>;\n};\n\nexport type RecompileAgentsResult = {\n compiled: AgentName[];\n /** The subset of `compiled` whose file content moved; the rest count as unchanged. */\n rewritten: AgentName[];\n failed: AgentName[];\n warnings: string[];\n};\n\nasync function getExistingAgentNames(pluginDir: string): Promise<AgentName[]> {\n return listCompiledAgentNames(getPluginAgentsDir(pluginDir));\n}\n\ntype ResolveAgentNamesParams = {\n specifiedAgents?: AgentName[];\n projectConfig: ProjectConfig | null;\n allAgents: Partial<Record<AgentName, AgentDefinition>>;\n outputDir?: string;\n pluginDir: string;\n};\n\nasync function resolveAgentNames(params: ResolveAgentNamesParams): Promise<AgentName[]> {\n const { specifiedAgents, projectConfig, allAgents, outputDir, pluginDir } = params;\n\n if (specifiedAgents) {\n return specifiedAgents;\n }\n\n // A present config is authoritative even when its roster is empty.\n if (projectConfig) {\n const agentNames = projectConfig.agents.map((a) => a.name);\n verbose(`Using agents from config: ${agentNames.join(\", \")}`);\n return agentNames;\n }\n\n if (outputDir) {\n const names = typedKeys<AgentName>(allAgents);\n verbose(`Using all available agents from source: ${names.join(\", \")}`);\n return names;\n }\n\n return getExistingAgentNames(pluginDir);\n}\n\nfunction buildRecompileResult(\n outcomes: AgentWriteOutcome[],\n priorWarnings: string[],\n): RecompileAgentsResult {\n const [succeeded, failedOutcomes] = partition(\n outcomes,\n (outcome): outcome is Extract<AgentWriteOutcome, { ok: true }> => outcome.ok,\n );\n succeeded.forEach((outcome) =>\n verbose(\n ` ${outcome.rewritten ? \"Rewrote\" : \"Unchanged\"}: ${outcome.name} (${outcome.scope} -> ${outcome.targetDir})`,\n ),\n );\n return {\n compiled: succeeded.map((outcome) => outcome.name),\n rewritten: succeeded.filter((outcome) => outcome.rewritten).map((outcome) => outcome.name),\n failed: failedOutcomes.map((outcome) => outcome.name),\n warnings: [\n ...priorWarnings,\n ...failedOutcomes.map(\n (outcome) => `Failed to compile ${outcome.name}: ${getErrorMessage(outcome.error)}`,\n ),\n ],\n };\n}\n\nexport function filterExcludedEntries(config: ProjectConfig): ProjectConfig {\n const excludedIds = effectivelyExcludedSkillIds(config.skills);\n const activeSkills = config.skills.filter((s) => !s.excluded);\n const activeAgents = config.agents.filter((a) => !a.excluded);\n\n // No stack stays absent rather than an explicit `undefined`.\n const filteredStack =\n config.stack === undefined\n ? {}\n : { stack: withoutExcludedAssignments(config.stack, excludedIds) };\n\n return { ...config, skills: activeSkills, agents: activeAgents, ...filteredStack };\n}\n\n/** Each agent and category keeps its key, even when left with no assignments. */\nexport function withoutExcludedAssignments(\n stack: NonNullable<ProjectConfig[\"stack\"]>,\n excludedIds: ReadonlySet<SkillId>,\n): NonNullable<ProjectConfig[\"stack\"]> {\n return Object.fromEntries(\n typedEntries(stack).map(([agentName, agentStack]) => [\n agentName,\n Object.fromEntries(\n typedEntries(agentStack).map(([category, assignments]) => [\n category,\n assignments.filter((assignment) => !excludedIds.has(assignment.id)),\n ]),\n ),\n ]),\n );\n}\n\nexport async function recompileAgents(\n options: RecompileAgentsOptions,\n): Promise<RecompileAgentsResult> {\n const { pluginDir, sourcePath, skills: providedSkills, projectDir, outputDir } = options;\n\n const configDir = projectDir ?? pluginDir;\n const filteredConfig = await loadConfigWithoutExclusions(configDir);\n const allAgents = await loadAgentDefinitions(sourcePath, projectDir);\n\n const agentNames = await resolveAgentNames({\n ...(options.agents !== undefined && { specifiedAgents: options.agents }),\n projectConfig: filteredConfig,\n allAgents,\n ...(outputDir !== undefined && { outputDir }),\n pluginDir,\n });\n\n // An empty pass is not a warning: callers report it off `compiled`.\n if (agentNames.length === 0) {\n return { compiled: [], rewritten: [], failed: [], warnings: [] };\n }\n\n verbose(`Recompiling ${agentNames.length} agents in ${outputDir ?? pluginDir}`);\n\n const pluginSkills: SkillDefinitionMap =\n providedSkills ?? (await discoverAllPluginSkills(projectDir ?? pluginDir));\n\n const { configAgents, missingWarnings } = compileEntriesFor(\n agentNames,\n filteredConfig,\n allAgents,\n );\n const compileConfig = compileConfigFor(filteredConfig, configAgents, pluginDir);\n\n const engine = await createLiquidEngine(projectDir);\n const resolvedAgents = await resolveAgents(allAgents, pluginSkills, compileConfig);\n\n const agentsDir = outputDir ?? getPluginAgentsDir(pluginDir);\n await ensureDir(agentsDir);\n\n const outcomes = await writeCompiledAgentsByScope({\n resolvedAgents,\n sourcePath,\n engine,\n projectAgentsDir: agentsDir,\n // Same root as the config, so format and configuration come from one installation.\n projectDir: configDir,\n ...(options.agentScopeMap !== undefined && { agentScopeMap: options.agentScopeMap }),\n });\n return buildRecompileResult(outcomes, missingWarnings);\n}\n\nasync function loadConfigWithoutExclusions(configDir: string): Promise<ProjectConfig | null> {\n const loaded = await loadProjectConfig(configDir);\n return loaded ? filterExcludedEntries(loaded.config) : null;\n}\n\n/** A project agent wins over a built-in one of the same name. */\nasync function loadAgentDefinitions(\n sourcePath: string,\n projectDir: string | undefined,\n): Promise<Partial<Record<AgentName, AgentDefinition>>> {\n const builtinAgents = await loadAllAgents(sourcePath);\n const projectAgents = projectDir ? await loadProjectAgents(projectDir) : {};\n\n return { ...builtinAgents, ...projectAgents };\n}\n\nfunction compileConfigFor(\n config: ProjectConfig | null,\n agents: Partial<Record<AgentName, CompileAgentConfig>>,\n pluginDir: string,\n): CompileConfig {\n return {\n name: config?.name || path.basename(pluginDir),\n description: config?.description || \"Recompiled plugin\",\n agents,\n };\n}\n\n/** Only agents the scope filter matches: a project pass must not overwrite stackless globals. */\nfunction compileEntriesFor(\n agentNames: AgentName[],\n config: ProjectConfig | null,\n allAgents: Partial<Record<AgentName, AgentDefinition>>,\n): { configAgents: Partial<Record<AgentName, CompileAgentConfig>>; missingWarnings: string[] } {\n const allConfigAgents = config ? buildCompileAgents(config, allAgents) : {};\n\n const [knownAgents, missingAgents] = partition(agentNames, (name) =>\n Boolean(allConfigAgents[name] || allAgents[name]),\n );\n\n return {\n configAgents: typedFromEntries<AgentName, CompileAgentConfig>(\n knownAgents.map((name) => [name, allConfigAgents[name] ?? {}]),\n ),\n missingWarnings: missingAgents.map((name) => `Agent \"${name}\" not found in source definitions`),\n };\n}\n","import os from \"os\";\nimport path from \"path\";\nimport type { Liquid } from \"liquidjs\";\nimport { compileAgentForHost } from \"../compiler.js\";\nimport { resolveInstallPaths } from \"../installation/install-base-dir.js\";\nimport { agentCodec, hostCompilesAgent, providerInUse } from \"../installation/install-layout.js\";\nimport { writeFile, fileExists, readFile } from \"../../utils/fs.js\";\nimport { typedEntries } from \"../../utils/typed-object.js\";\nimport type { Provider } from \"../../consts.js\";\nimport type { AgentConfig, AgentName, SkillScope } from \"../../types/index.js\";\n\nexport type AgentWriteOutcome =\n | {\n name: AgentName;\n ok: true;\n scope: SkillScope;\n targetDir: string;\n /** False when the output matched the file on disk, so nothing was written. */\n rewritten: boolean;\n }\n | { name: AgentName; ok: false; error: unknown };\n\n/** Skipping an identical write keeps the mtime, the only trace telling unchanged from rewritten. */\nasync function holdsExactly(filePath: string, content: string): Promise<boolean> {\n return (await fileExists(filePath)) && (await readFile(filePath)) === content;\n}\n\n/**\n * Routing for an agent the scope map does not name: the caller's `projectAgentsDir`. Deliberately\n * not the selection default, which would move unrouted agents into `~/.claude/agents`.\n */\nconst UNROUTED_AGENT_SCOPE: SkillScope = \"project\";\n\n/**\n * Per-agent failures come back as outcomes; a directory appears only when an agent routes into it.\n */\nexport async function writeCompiledAgentsByScope(params: {\n resolvedAgents: Partial<Record<AgentName, AgentConfig>>;\n sourcePath: string;\n engine: Liquid;\n projectAgentsDir: string;\n /** The root whose folder says which host the PROJECT scope's sub-agents are written for. */\n projectDir: string;\n agentScopeMap?: Map<AgentName, SkillScope>;\n}): Promise<AgentWriteOutcome[]> {\n const hosts: Record<SkillScope, AgentHost> = {\n // Each scope reads its own root: a Codex project under a Claude global is allowed.\n global: {\n provider: providerInUse(os.homedir()),\n agentsDir: resolveInstallPaths(os.homedir(), \"global\").agentsDir,\n },\n project: { provider: providerInUse(params.projectDir), agentsDir: params.projectAgentsDir },\n };\n\n const outcomes: AgentWriteOutcome[] = [];\n for (const [name, agent] of typedEntries<AgentName, AgentConfig>(params.resolvedAgents)) {\n const scope = params.agentScopeMap?.get(name) ?? UNROUTED_AGENT_SCOPE;\n const host = hosts[scope];\n\n // No outcome for a sub-agent this host does not carry: it was neither compiled nor failed.\n if (!hostCompilesAgent(host.provider, name)) continue;\n\n outcomes.push(await writeOneAgent({ ...params, name, agent, scope, host }));\n }\n return outcomes;\n}\n\n/** Returns the failure rather than throwing: the policy is the caller's. */\nasync function writeOneAgent(params: {\n name: AgentName;\n agent: AgentConfig;\n scope: SkillScope;\n host: AgentHost;\n sourcePath: string;\n engine: Liquid;\n}): Promise<AgentWriteOutcome> {\n const { name, scope, host } = params;\n\n try {\n const output = await compileAgentForHost(\n host.provider,\n name,\n params.agent,\n params.sourcePath,\n params.engine,\n );\n const targetPath = path.join(host.agentsDir, fileNameFor(name, host.provider));\n const rewritten = !(await holdsExactly(targetPath, output));\n if (rewritten) await writeFile(targetPath, output);\n\n return { name, ok: true, scope, targetDir: host.agentsDir, rewritten };\n } catch (error) {\n return { name, ok: false, error };\n }\n}\n\ntype AgentHost = { provider: Provider; agentsDir: string };\n\n/** The extension comes from `agentCodec`, so a `.md` never lands where Codex reads `.toml`. */\nfunction fileNameFor(name: AgentName, provider: Provider): string {\n return `${name}${agentCodec(provider).extension}`;\n}\n","import { Liquid } from \"liquidjs\";\nimport path from \"path\";\nimport {\n buildAgentTemplateContext,\n pluginRefFor,\n renderAgent,\n renderAgentBody,\n renderAgentRoleToml,\n type AgentFiles,\n} from \"@workspace/compile/agent-source\";\nimport { readFile, readFileOptional, directoryExists } from \"../utils/fs\";\nimport { verbose } from \"../utils/logger\";\nimport {\n CLAUDE_DIR,\n DIRS,\n PROJECT_ROOT,\n STANDARD_FILES,\n STANDARD_DIRS,\n type Provider,\n} from \"../consts\";\nimport { providerInUse, sourceFolderInUse, sourceFolderName } from \"./installation/install-layout\";\nimport { cliVersion } from \"./agents/agent-provenance\";\nimport \"./compile-seat.js\";\nimport type { AgentConfig, AgentName } from \"../types\";\n\nexport {\n buildAgentTemplateContext,\n sanitizeCompiledAgentData,\n sanitizeLiquidSyntax,\n} from \"@workspace/compile/agent-source\";\n\nasync function readAgentFiles(\n name: AgentName,\n agent: AgentConfig,\n projectRoot: string,\n): Promise<AgentFiles> {\n const agentSourceRoot = agent.sourceRoot || projectRoot;\n const agentBaseDir = agent.agentBaseDir || DIRS.agents;\n const agentPath = agent.path || name;\n const agentDir = path.join(agentSourceRoot, agentBaseDir, agentPath);\n\n const identity = await readFile(path.join(agentDir, STANDARD_FILES.IDENTITY_MD));\n const playbook = await readFile(path.join(agentDir, STANDARD_FILES.PLAYBOOK_MD));\n const criticalRequirementsTop = await readFileOptional(\n path.join(agentDir, STANDARD_FILES.CRITICAL_REQUIREMENTS_MD),\n \"\",\n );\n const criticalReminders = await readFileOptional(\n path.join(agentDir, STANDARD_FILES.CRITICAL_REMINDERS_MD),\n \"\",\n );\n\n const category = agentPath.split(\"/\")[0] || name;\n const categoryDir = path.join(agentSourceRoot, agentBaseDir, category);\n const output = await readOutputPartial(agentDir, categoryDir);\n\n return { identity, playbook, output, criticalRequirementsTop, criticalReminders };\n}\n\n/** The agent's own `output.md`, or its category's where the agent's is absent or empty. */\nasync function readOutputPartial(agentDir: string, categoryDir: string): Promise<string> {\n const own = await readFileOptional(path.join(agentDir, STANDARD_FILES.OUTPUT_MD), \"\");\n if (own) return own;\n return readFileOptional(path.join(categoryDir, STANDARD_FILES.OUTPUT_MD), \"\");\n}\n\n/**\n * Template roots, first match wins: the project source folder's `agents/_templates/`, legacy\n * `.claude/templates/`, then the built-ins. The options mirror `createEngineFromTemplates` in\n * `@workspace/compile/engine`; keep the two in sync.\n */\nexport async function createLiquidEngine(projectDir?: string): Promise<Liquid> {\n const roots: string[] = [];\n // One read for both: template overrides and source folder must name one installation.\n const provider = providerInUse(projectDir);\n\n if (projectDir) {\n const srcTemplatesDir = path.join(\n sourceFolderInUse(projectDir, provider).dir,\n STANDARD_DIRS.AGENTS,\n path.basename(DIRS.templates),\n );\n if (await directoryExists(srcTemplatesDir)) {\n roots.push(srcTemplatesDir);\n verbose(`Using local templates from: ${srcTemplatesDir}`);\n }\n\n const legacyTemplatesDir = path.join(projectDir, CLAUDE_DIR, STANDARD_DIRS.TEMPLATES);\n if (await directoryExists(legacyTemplatesDir)) {\n roots.push(legacyTemplatesDir);\n verbose(`Using legacy templates from: ${legacyTemplatesDir}`);\n }\n }\n\n roots.push(path.join(PROJECT_ROOT, DIRS.templates));\n\n return new Liquid({\n root: roots,\n extname: \".liquid\",\n strictVariables: false,\n strictFilters: true,\n globals: { sourceFolder: sourceFolderName(projectDir, provider) },\n });\n}\n\n/** Both hosts render from one template context; only the wrapper differs (markdown or TOML). */\nexport async function compileAgentForHost(\n provider: Provider,\n name: AgentName,\n agent: AgentConfig,\n fallbackRoot: string,\n engine: Liquid,\n): Promise<string> {\n verbose(`Compiling agent: ${name} (${provider})`);\n\n const files = await readAgentFiles(name, agent, fallbackRoot);\n\n // Each skill's own `source` decides `${id}:${id}` versus a bare id; no `source` means bare.\n const data = buildAgentTemplateContext(name, agent, files, (skill) => ({\n ...skill,\n ...pluginRefFor(skill),\n }));\n const version = await cliVersion();\n\n switch (provider) {\n case \"claude\":\n return renderAgent(engine, data, version);\n case \"codex\":\n return renderAgentRoleToml(agent, await renderAgentBody(engine, data, version));\n default: {\n const _exhaustive: never = provider;\n return _exhaustive;\n }\n }\n}\n","import path from \"path\";\nimport { z } from \"zod\";\n\nimport { PROJECT_ROOT, STANDARD_FILES } from \"../../consts\";\nimport { readFile } from \"../../utils/fs\";\n\nconst ownPackageJsonSchema = z.object({ version: z.string().min(1) });\n\nexport {\n hasProvenanceMarker,\n provenanceMarker,\n stampProvenanceMarker,\n} from \"@workspace/compile/agent-source\";\n\nlet ownVersion: Promise<string> | undefined;\n\n/**\n * Rendered in the trailing `<system-reminder>`, not the provenance marker, so a version bump leaves\n * the first cacheable bytes of every compiled agent unchanged.\n */\nexport function cliVersion(): Promise<string> {\n ownVersion ??= readOwnVersion();\n return ownVersion;\n}\n\nasync function readOwnVersion(): Promise<string> {\n const manifestPath = path.join(PROJECT_ROOT, STANDARD_FILES.PACKAGE_JSON);\n const raw: unknown = JSON.parse(await readFile(manifestPath));\n\n const parsed = ownPackageJsonSchema.safeParse(raw);\n if (!parsed.success) {\n throw new Error(`Could not read this CLI's own version from ${manifestPath}`);\n }\n return parsed.data.version;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAU1B,IAAM,gBAAgB,WAAW,QAAQ;AAOzC,eAAsB,iBAAiB,WAAsC;AAC3E,SAAO,iBAAiB,WAAW,aAAa;AAClD;AAEA,eAAsB,iBAAiB,WAAmB,OAAsC;AAC9F,SAAO,KAAK,MAAM,UAAU,SAAS;AACvC;AAGA,eAAsB,wBACpB,WACA,QAAoB,eACW;AAC/B,QAAM,QAAQ,MAAM,iBAAiB,WAAW,KAAK;AACrD,QAAM,aAAa,MAAM,QAAQ;AAAA,IAC/B,MAAM,IAAI,CAAC,SAAS,oBAAoB,WAAW,MAAM,KAAK,CAAC;AAAA,EACjE;AACA,QAAM,CAAC,QAAQ,QAAQ,IAAI,UAAU,YAAY,CAAC,UAAU,MAAM,YAAY;AAE9E,SAAO;AAAA,IACL,QAAQ,OAAO,IAAI,CAAC,UAAU,MAAM,IAAI;AAAA,IACxC,UAAU,SAAS,IAAI,CAAC,UAAU,MAAM,IAA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,QAAQ,gBAAgB,IAAI,KAAK,UAAU,IAAI,CAAC;AAAA,EAClD;AAEA,SAAO;AAAA,IACL,cAAc;AAAA,MACZ,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM,gBAAgB,IAAI,KAAK,CAAC,CAAC,CAAC;AAAA,IAC/D;AAAA,IACA,iBAAiB,cAAc,IAAI,CAAC,SAAS,UAAU,IAAI,mCAAmC;AAAA,EAChG;AACF;","names":["partition","path","path","path","path","path","path","path","partition","path"]}
@@ -6,7 +6,7 @@ import {
6
6
  hostAt,
7
7
  loadInstalledConfig,
8
8
  refuseUnofferedPlacements
9
- } from "./chunk-3YYHL76L.js";
9
+ } from "./chunk-WVFBBZEP.js";
10
10
 
11
11
  // src/cli/lib/hosts/configured-placements.ts
12
12
  async function unofferablePlacementsFound(cwd) {
@@ -36,4 +36,4 @@ async function configuredSkillsAt(root) {
36
36
  export {
37
37
  unofferablePlacementsFound
38
38
  };
39
- //# sourceMappingURL=chunk-RDXY4GRO.js.map
39
+ //# sourceMappingURL=chunk-F437ICEG.js.map
@@ -0,0 +1,253 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getSkillDisplayName,
4
+ inertLine,
5
+ typedValues
6
+ } from "./chunk-7OG635DK.js";
7
+ import {
8
+ CLI_COLORS,
9
+ EJECT_SOURCE,
10
+ UI_SYMBOLS,
11
+ isActiveAt,
12
+ isGlobalTombstone
13
+ } from "./chunk-MHAQWMNJ.js";
14
+
15
+ // src/cli/components/common/skill-agent-summary.tsx
16
+ import { Box, Text } from "ink";
17
+ import "react";
18
+
19
+ // src/cli/lib/configuration/scope-diff.ts
20
+ import { difference, partition, unique } from "remeda";
21
+ var NOTHING = /* @__PURE__ */ new Set();
22
+ function computeScopeDiff(input) {
23
+ const { currentSkills, currentAgents, installedSkillConfigs, installedAgentConfigs, isInitMode } = input;
24
+ const overwritten = input.overwrittenSkillIds ?? NOTHING;
25
+ const changed = input.changedAgentNames ?? NOTHING;
26
+ const skills = diffRoster(currentSkills, installedSkillConfigs, (skill) => skill.id, isInitMode);
27
+ const agents = diffRoster(
28
+ currentAgents,
29
+ installedAgentConfigs,
30
+ (agent) => agent.name,
31
+ isInitMode
32
+ );
33
+ const skillRow = skillRowClassifier(installedSkillConfigs, overwritten);
34
+ const agentRow = agentRowClassifier(installedAgentConfigs, changed);
35
+ const projectSkillRows = rowsOf(skills.project, skillRow, toRemovedSkillRow);
36
+ const globalSkillRows = rowsOf(skills.global, skillRow, toRemovedSkillRow);
37
+ const projectAgentRows = rowsOf(agents.project, agentRow, toRemovedAgentRow);
38
+ const globalAgentRows = rowsOf(agents.global, agentRow, toRemovedAgentRow);
39
+ const hasContent = [projectSkillRows, globalSkillRows, projectAgentRows, globalAgentRows].some(
40
+ (rows) => rows.length > 0
41
+ );
42
+ return { projectSkillRows, globalSkillRows, projectAgentRows, globalAgentRows, hasContent };
43
+ }
44
+ function diffRoster(current, installed, identityOf, isInitMode) {
45
+ const activeBaseline = (installed ?? []).filter((entry) => !entry.excluded);
46
+ const vacated = vacatedInstalls(activeBaseline, current, identityOf);
47
+ const projectEntries = current.filter((entry) => isActiveAt(entry, "project"));
48
+ const claimedByProject = new Set(projectEntries.map(identityOf));
49
+ const [inheritedGlobals, removedGlobals] = partition(
50
+ vacated.filter((entry) => entry.scope === "global"),
51
+ (entry) => claimedByProject.has(identityOf(entry))
52
+ );
53
+ return {
54
+ project: {
55
+ listed: projectEntries,
56
+ removed: vacated.filter((entry) => entry.scope === "project")
57
+ },
58
+ global: {
59
+ listed: [
60
+ ...current.filter((entry) => isActiveAt(entry, "global")),
61
+ ...inheritedGlobals,
62
+ ...current.filter(isGlobalTombstone)
63
+ ],
64
+ removed: isInitMode ? [] : removedGlobals
65
+ }
66
+ };
67
+ }
68
+ function vacatedInstalls(activeBaseline, current, identityOf) {
69
+ const slotOf = (entry) => slotKey(identityOf(entry), entry.scope);
70
+ const occupiedSlots = new Set(current.map(slotOf));
71
+ return activeBaseline.filter((install) => !occupiedSlots.has(slotOf(install)));
72
+ }
73
+ function rowsOf(entries, toRow, toRemovedRow) {
74
+ return [...entries.listed.map(toRow), ...entries.removed.map(toRemovedRow)];
75
+ }
76
+ function slotKey(identity, scope) {
77
+ return `${identity}:${scope}`;
78
+ }
79
+ function formatScopeTag(scope) {
80
+ return scope === "global" ? "[G]" : "[P]";
81
+ }
82
+ function skillRowClassifier(installed, overwritten) {
83
+ const installedSlots = installed ? new Set(installed.map((skill) => slotKey(skill.id, skill.scope))) : null;
84
+ const installedOriginBySlot = installed ? new Map(
85
+ installed.filter((skill) => !skill.excluded).map((skill) => [slotKey(skill.id, skill.scope), skill.origin])
86
+ ) : null;
87
+ return (skill) => ({
88
+ id: skill.id,
89
+ source: skill.origin,
90
+ status: skillStatus(skill, installedSlots, installedOriginBySlot, overwritten)
91
+ });
92
+ }
93
+ function agentRowClassifier(installed, changed) {
94
+ const installedSlots = installed ? new Set(installed.map((agent) => slotKey(agent.name, agent.scope))) : null;
95
+ return (agent) => ({ name: agent.name, status: agentStatus(agent, installedSlots, changed) });
96
+ }
97
+ function skillStatus(skill, installedSlots, installedOriginBySlot, overwritten) {
98
+ const slot = slotKey(skill.id, skill.scope);
99
+ if (installedSlots === null || !installedSlots.has(slot)) return "added";
100
+ if (!skill.excluded && overwritten.has(skill.id)) return "overwritten";
101
+ const installedOrigin = installedOriginBySlot?.get(slot);
102
+ const modeChanged = installedOrigin != null && installedOrigin !== skill.origin;
103
+ return modeChanged ? "mode-changed" : "unchanged";
104
+ }
105
+ function agentStatus(agent, installedSlots, changed) {
106
+ const isNew = installedSlots === null || !installedSlots.has(slotKey(agent.name, agent.scope));
107
+ if (isNew) return "added";
108
+ return !agent.excluded && changed.has(agent.name) ? "changed" : "unchanged";
109
+ }
110
+ function toRemovedSkillRow(skill) {
111
+ return { id: skill.id, source: skill.origin, status: "removed" };
112
+ }
113
+ function toRemovedAgentRow(agent) {
114
+ return { name: agent.name, status: "removed" };
115
+ }
116
+ var AGENT_SETTINGS = [
117
+ ["model", (agent) => agent.model],
118
+ ["codex model", (agent) => agent.codexModel],
119
+ ["effort", (agent) => agent.effort]
120
+ ];
121
+ function agentChangesAmong(names, before, after) {
122
+ return names.flatMap((name) => {
123
+ const was = agentStateIn(before, name);
124
+ const is = agentStateIn(after, name);
125
+ return was === void 0 || is === void 0 ? [] : [agentChange(was, is)];
126
+ });
127
+ }
128
+ function agentStateIn(config, name) {
129
+ const agent = config.agents.find((entry) => entry.name === name && !entry.excluded);
130
+ return agent === void 0 ? void 0 : { agent, rows: config.stack?.[name] };
131
+ }
132
+ function agentChange(before, after) {
133
+ const beforeIds = assignedSkillIds(before.rows);
134
+ const afterIds = assignedSkillIds(after.rows);
135
+ return {
136
+ name: after.agent.name,
137
+ scope: after.agent.scope,
138
+ gains: difference(afterIds, beforeIds),
139
+ loses: difference(beforeIds, afterIds),
140
+ settings: settingChanges(before.agent, after.agent)
141
+ };
142
+ }
143
+ function settingChanges(before, after) {
144
+ return AGENT_SETTINGS.filter(([, read]) => read(before) !== read(after)).map(
145
+ ([setting, read]) => ({ setting, from: read(before), to: read(after) })
146
+ );
147
+ }
148
+ function assignedSkillIds(rows) {
149
+ return unique(typedValues(rows ?? {}).flatMap((assignments) => assignments.map(({ id }) => id)));
150
+ }
151
+
152
+ // src/cli/components/common/skill-agent-summary.tsx
153
+ import { jsx, jsxs } from "react/jsx-runtime";
154
+ var NO_NAMES = /* @__PURE__ */ new Map();
155
+ function skillNameOf(id, names) {
156
+ const recorded = names.get(id);
157
+ return recorded === void 0 ? getSkillDisplayName(id) : inertLine(recorded);
158
+ }
159
+ var TableHeader = ({ children }) => /* @__PURE__ */ jsx(Text, { bold: true, color: CLI_COLORS.WARNING, children });
160
+ var ScopeLabel = ({ children }) => /* @__PURE__ */ jsx(Text, { color: CLI_COLORS.WHITE, backgroundColor: CLI_COLORS.LABEL_BG, children: ` ${children} ` });
161
+ var EjectIcon = () => /* @__PURE__ */ jsxs(Text, { color: CLI_COLORS.WARNING, children: [
162
+ " ",
163
+ UI_SYMBOLS.EJECT
164
+ ] });
165
+ var DIFF_PREFIX = {
166
+ added: `${UI_SYMBOLS.ADDED} `,
167
+ "mode-changed": `${UI_SYMBOLS.CHANGED} `,
168
+ overwritten: `${UI_SYMBOLS.OVERWRITTEN} `,
169
+ changed: `${UI_SYMBOLS.CHANGED} `,
170
+ removed: `${UI_SYMBOLS.REMOVED} `,
171
+ unchanged: `${UI_SYMBOLS.BULLET} `
172
+ };
173
+ var DIFF_COLOR = {
174
+ added: CLI_COLORS.SUCCESS,
175
+ "mode-changed": CLI_COLORS.WARNING,
176
+ overwritten: CLI_COLORS.WARNING,
177
+ changed: CLI_COLORS.WARNING,
178
+ removed: CLI_COLORS.ERROR,
179
+ unchanged: CLI_COLORS.NEUTRAL
180
+ };
181
+ var NAME_GUTTER_COLUMNS = 3;
182
+ var SkillRow = ({ row, name }) => /* @__PURE__ */ jsxs(Box, { width: "50%", paddingRight: NAME_GUTTER_COLUMNS, children: [
183
+ /* @__PURE__ */ jsx(Box, { flexShrink: 0, children: /* @__PURE__ */ jsx(Text, { color: DIFF_COLOR[row.status], children: DIFF_PREFIX[row.status] }) }),
184
+ /* @__PURE__ */ jsxs(Text, { color: DIFF_COLOR[row.status], children: [
185
+ name,
186
+ row.source === EJECT_SOURCE && /* @__PURE__ */ jsx(EjectIcon, {})
187
+ ] })
188
+ ] });
189
+ var AgentRow = ({ row }) => /* @__PURE__ */ jsxs(Text, { color: DIFF_COLOR[row.status], children: [
190
+ DIFF_PREFIX[row.status],
191
+ row.name
192
+ ] });
193
+ var skillRowKey = (row) => row.status === "removed" ? `removed-${row.id}` : row.id;
194
+ var agentRowKey = (row) => row.status === "removed" ? `removed-${row.name}` : row.name;
195
+ var SkillAgentSummary = ({
196
+ skillConfigs,
197
+ agentConfigs,
198
+ skillNames = NO_NAMES,
199
+ ...baseline
200
+ }) => {
201
+ const diff = computeScopeDiff({
202
+ currentSkills: skillConfigs,
203
+ currentAgents: agentConfigs,
204
+ ...baseline
205
+ });
206
+ if (!diff.hasContent) return null;
207
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", width: "100%", children: [
208
+ /* @__PURE__ */ jsxs(
209
+ Box,
210
+ {
211
+ flexDirection: "column",
212
+ borderStyle: "single",
213
+ flexGrow: 2,
214
+ flexBasis: 0,
215
+ borderRight: true,
216
+ borderTop: false,
217
+ borderBottom: false,
218
+ borderLeft: false,
219
+ borderColor: CLI_COLORS.NEUTRAL,
220
+ borderRightDimColor: true,
221
+ children: [
222
+ /* @__PURE__ */ jsx(TableHeader, { children: "Skills" }),
223
+ diff.projectSkillRows.length > 0 && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
224
+ /* @__PURE__ */ jsx(ScopeLabel, { children: "Project" }),
225
+ /* @__PURE__ */ jsx(Box, { flexWrap: "wrap", children: diff.projectSkillRows.map((row) => /* @__PURE__ */ jsx(SkillRow, { row, name: skillNameOf(row.id, skillNames) }, skillRowKey(row))) })
226
+ ] }),
227
+ diff.globalSkillRows.length > 0 && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
228
+ /* @__PURE__ */ jsx(ScopeLabel, { children: "Global" }),
229
+ /* @__PURE__ */ jsx(Box, { flexWrap: "wrap", children: diff.globalSkillRows.map((row) => /* @__PURE__ */ jsx(SkillRow, { row, name: skillNameOf(row.id, skillNames) }, skillRowKey(row))) })
230
+ ] })
231
+ ]
232
+ }
233
+ ),
234
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "column", flexGrow: 1, flexBasis: 0, marginLeft: 1, paddingLeft: 1, children: [
235
+ /* @__PURE__ */ jsx(TableHeader, { children: "Agents" }),
236
+ diff.projectAgentRows.length > 0 && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
237
+ /* @__PURE__ */ jsx(ScopeLabel, { children: "Project" }),
238
+ /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: diff.projectAgentRows.map((row) => /* @__PURE__ */ jsx(AgentRow, { row }, agentRowKey(row))) })
239
+ ] }),
240
+ diff.globalAgentRows.length > 0 && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
241
+ /* @__PURE__ */ jsx(ScopeLabel, { children: "Global" }),
242
+ /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: diff.globalAgentRows.map((row) => /* @__PURE__ */ jsx(AgentRow, { row }, agentRowKey(row))) })
243
+ ] })
244
+ ] })
245
+ ] });
246
+ };
247
+
248
+ export {
249
+ formatScopeTag,
250
+ agentChangesAmong,
251
+ SkillAgentSummary
252
+ };
253
+ //# sourceMappingURL=chunk-G7NUK3BF.js.map