Skip to content

Commit 02f9a34

Browse files
authored
Merge pull request #246 from PostHog/fix/publish-agents
fix(release): publish agent prompts as flat release assets
2 parents ad69d56 + 5685c28 commit 02f9a34

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ jobs:
175175
# Upload skill-menu.json (used by the wizard to discover available skills)
176176
echo "Uploading skill-menu.json..."
177177
gh release upload "$RELEASE_TAG" dist/skills/skill-menu.json --clobber
178+
# Upload the orchestrator agent prompts + menu (flat asset names)
179+
gh release upload "$RELEASE_TAG" dist/agents/agent-menu.json dist/agents/agents-*.md --clobber
178180
# Upload each bundled group (one JSON of every variant, in place of per-variant ZIPs)
179181
for file in dist/skills/*.json; do
180182
filename=$(basename "$file")

scripts/dev-server.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const agentsDir = path.join(distDir, 'agents');
5656
const exampleAppsDir = path.join(repoRoot, 'example-apps');
5757

5858
const localSkillsUrl = `http://localhost:${PORT}/skills`;
59-
const localAgentsUrl = `http://localhost:${PORT}/agents`;
59+
const localAgentsUrl = `http://localhost:${PORT}`;
6060

6161
// `generateManifest` reads SKILLS_BASE_URL from process.env, and the agent build
6262
// reads AGENTS_BASE_URL. Partial rebuilds run in this process, so set both here —
@@ -301,9 +301,9 @@ function createServer() {
301301
return;
302302
}
303303

304-
const agentMatch = req.url?.match(/^\/agents\/([\w-]+)\/([\w-]+\.md)$/);
304+
const agentMatch = req.url?.match(/^\/(agents-[\w-]+\.md)$/);
305305
if (agentMatch) {
306-
serveFile(res, path.join(agentsDir, agentMatch[1], agentMatch[2]), 'text/markdown; charset=utf-8');
306+
serveFile(res, path.join(agentsDir, agentMatch[1]), 'text/markdown; charset=utf-8');
307307
return;
308308
}
309309

@@ -323,7 +323,7 @@ function createServer() {
323323
}
324324

325325
res.writeHead(404, { 'Content-Type': 'text/plain', ...NO_CACHE_HEADERS });
326-
res.end('Not found. Available endpoints:\n /skill-menu.json\n /skills-mcp-resources.zip\n /skills/{id}.zip\n /skills/{group}.json\n /agent-menu.json\n /agents/{flow}/{type}.md');
326+
res.end('Not found. Available endpoints:\n /skill-menu.json\n /skills-mcp-resources.zip\n /skills/{id}.zip\n /skills/{group}.json\n /agent-menu.json\n /agents-{flow}-{type}.md');
327327
});
328328

329329
server.listen(PORT, () => {
@@ -332,7 +332,7 @@ function createServer() {
332332
console.log(`📍 Individual skill: http://localhost:${PORT}/skills/{id}.zip`);
333333
console.log(`📦 Bundled group: http://localhost:${PORT}/skills/{group}.json`);
334334
console.log(`📋 Skills menu: http://localhost:${PORT}/skill-menu.json`);
335-
console.log(`🤖 Agent prompt: http://localhost:${PORT}/agents/{flow}/{type}.md`);
335+
console.log(`🤖 Agent prompt: http://localhost:${PORT}/agents-{flow}-{type}.md`);
336336
console.log(`📋 Agents menu: http://localhost:${PORT}/agent-menu.json`);
337337
});
338338

scripts/lib/agent-generator.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414

1515
import fs from 'fs';
1616
import path from 'path';
17+
import { REPO_URL } from './constants.js';
1718

18-
const DEFAULT_AGENTS_BASE_URL =
19-
'https://github.com/PostHog/context-mill/releases/latest/download/agents';
19+
/** Release assets are a flat namespace: agent prompts live at the release root, like skills. */
20+
function defaultAgentsBaseUrl(version) {
21+
return version && version !== 'dev'
22+
? `${REPO_URL}/releases/download/v${version}`
23+
: `${REPO_URL}/releases/latest/download`;
24+
}
2025

2126
/**
2227
* The agent prompts available in source: one { flow, id } per
@@ -74,7 +79,7 @@ function assertFlowMatches(sourcePath, flow) {
7479
export function buildAgents({ configDir, distDir, baseUrl, version = 'dev' }) {
7580
const agentsSourceDir = path.join(configDir, 'agents');
7681
const agentsDistDir = path.join(distDir, 'agents');
77-
const resolvedBase = (baseUrl || DEFAULT_AGENTS_BASE_URL).replace(/\/+$/, '');
82+
const resolvedBase = (baseUrl || defaultAgentsBaseUrl(version)).replace(/\/+$/, '');
7883

7984
fs.mkdirSync(agentsDistDir, { recursive: true });
8085

@@ -83,9 +88,9 @@ export function buildAgents({ configDir, distDir, baseUrl, version = 'dev' }) {
8388
for (const { flow, id } of entries) {
8489
const sourcePath = path.join(agentsSourceDir, flow, `${id}.md`);
8590
assertFlowMatches(sourcePath, flow);
86-
fs.mkdirSync(path.join(agentsDistDir, flow), { recursive: true });
87-
fs.copyFileSync(sourcePath, path.join(agentsDistDir, flow, `${id}.md`));
88-
agents.push({ id, flow, downloadUrl: `${resolvedBase}/${flow}/${id}.md` });
91+
const assetName = `agents-${flow}-${id}.md`;
92+
fs.copyFileSync(sourcePath, path.join(agentsDistDir, assetName));
93+
agents.push({ id, flow, downloadUrl: `${resolvedBase}/${assetName}` });
8994
}
9095

9196
const menu = { version: '1.0', buildVersion: version, agents };
@@ -95,7 +100,7 @@ export function buildAgents({ configDir, distDir, baseUrl, version = 'dev' }) {
95100
);
96101

97102
// Reconcile: drop dist files and folders whose source markdown was removed.
98-
const keep = new Set(entries.map(e => path.join(e.flow, `${e.id}.md`)));
103+
const keep = new Set(entries.map(e => `agents-${e.flow}-${e.id}.md`));
99104
keep.add('agent-menu.json');
100105
const walk = dir => {
101106
for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) {

scripts/lib/tests/agent-generator-flow.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('buildAgents flow frontmatter', () => {
3030
expect(count).toBe(1);
3131
const menu = JSON.parse(readFileSync(join(distDir, 'agents', 'agent-menu.json'), 'utf8'));
3232
expect(menu.agents).toEqual([
33-
{ id: 'task', flow: 'my-flow', downloadUrl: 'http://x/my-flow/task.md' },
33+
{ id: 'task', flow: 'my-flow', downloadUrl: 'http://x/agents-my-flow-task.md' },
3434
]);
3535
});
3636

0 commit comments

Comments
 (0)