Skip to content

Commit e5a7de5

Browse files
authored
Merge pull request #1789 from PostHog/fury-road-name-changes
updated context mill directories
2 parents ac5f48f + f159244 commit e5a7de5

4 files changed

Lines changed: 44 additions & 26 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Repository paths (use ~ for home directory, or absolute paths)
22
CONTEXT_MILL_PATH=~/development/context-mill
33
# Points evaluator at context-mill's commandments directly (zero drift). Falls back to vendored copy if unset.
4-
COMMANDMENTS_PATH=~/development/context-mill/transformation-config/commandments.yaml
4+
COMMANDMENTS_PATH=~/development/context-mill/context/commandments.yaml
55
MCP_PATH=~/development/posthog/services/mcp
66
WIZARD_PATH=~/development/wizard
77

fresh-setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ else
128128
# macOS sed needs the -i '' form.
129129
sed -i '' \
130130
-e "s|^CONTEXT_MILL_PATH=.*|CONTEXT_MILL_PATH=$PARENT/context-mill|" \
131-
-e "s|^COMMANDMENTS_PATH=.*|COMMANDMENTS_PATH=$PARENT/context-mill/transformation-config/commandments.yaml|" \
131+
-e "s|^COMMANDMENTS_PATH=.*|COMMANDMENTS_PATH=$PARENT/context-mill/context/commandments.yaml|" \
132132
-e "s|^MCP_PATH=.*|MCP_PATH=$PARENT/posthog/services/mcp|" \
133133
-e "s|^WIZARD_PATH=.*|WIZARD_PATH=$PARENT/wizard|" \
134134
"$ENV_FILE"

services/pr-evaluator/prompt-builder.ts

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,50 @@ const PROMPTS_BY_COMMAND: Record<string, { rubric: string; outputFormat: string
2828

2929
// Commandments loading: fetch from GitHub > COMMANDMENTS_PATH env var > vendored fallback
3030
const VENDORED_COMMANDMENTS = join(__dirname, "prompts/commandments.yaml");
31-
const GITHUB_COMMANDMENTS_URL =
32-
"https://raw.githubusercontent.com/PostHog/context-mill/main/transformation-config/commandments.yaml";
31+
// Try the post-rename `context/` path first, fall back to `transformation-config/`
32+
// so this works whether or not the context-mill rename has landed on main.
33+
const GITHUB_COMMANDMENTS_URLS = [
34+
"https://raw.githubusercontent.com/PostHog/context-mill/main/context/commandments.yaml",
35+
"https://raw.githubusercontent.com/PostHog/context-mill/main/transformation-config/commandments.yaml",
36+
];
3337

3438
// Docs loading: fetch integration config from context-mill to get tag -> doc URL mapping
35-
const GITHUB_INTEGRATION_CONFIG_URL =
36-
"https://raw.githubusercontent.com/PostHog/context-mill/main/transformation-config/skills/integration/config.yaml";
39+
const GITHUB_INTEGRATION_CONFIG_URLS = [
40+
"https://raw.githubusercontent.com/PostHog/context-mill/main/context/skills/integration/config.yaml",
41+
"https://raw.githubusercontent.com/PostHog/context-mill/main/transformation-config/skills/integration/config.yaml",
42+
];
43+
44+
/**
45+
* Fetch the first URL that returns OK. Treats network errors and non-2xx as
46+
* "try next URL". Returns null only when every URL failed.
47+
*/
48+
async function fetchFirstOk(urls: string[]): Promise<{ url: string; body: string } | null> {
49+
for (const url of urls) {
50+
try {
51+
const response = await fetch(url, { signal: AbortSignal.timeout(5000) });
52+
if (response.ok) {
53+
return { url, body: await response.text() };
54+
}
55+
} catch {
56+
// fall through to next URL
57+
}
58+
}
59+
return null;
60+
}
3761

3862
let _commandmentsCache: string | null = null;
3963

4064
async function fetchCommandments(): Promise<string> {
4165
if (_commandmentsCache) return _commandmentsCache;
4266

43-
// 1. Try fetching latest from GitHub
44-
try {
45-
const response = await fetch(GITHUB_COMMANDMENTS_URL, { signal: AbortSignal.timeout(5000) });
46-
if (response.ok) {
47-
_commandmentsCache = await response.text();
48-
console.log("Loaded commandments from GitHub (latest)");
49-
return _commandmentsCache;
50-
}
51-
} catch {
52-
console.warn("Warning: Could not fetch commandments from GitHub, trying local fallbacks");
67+
// 1. Try fetching latest from GitHub (tries both context/ and transformation-config/)
68+
const fetched = await fetchFirstOk(GITHUB_COMMANDMENTS_URLS);
69+
if (fetched) {
70+
_commandmentsCache = fetched.body;
71+
console.log(`Loaded commandments from GitHub (latest): ${fetched.url}`);
72+
return _commandmentsCache;
5373
}
74+
console.warn("Warning: Could not fetch commandments from GitHub, trying local fallbacks");
5475

5576
// 2. Try COMMANDMENTS_PATH env var (local context-mill checkout)
5677
if (process.env.COMMANDMENTS_PATH) {
@@ -107,16 +128,13 @@ let _docsConfigCache: string | null = null;
107128
async function fetchIntegrationConfig(): Promise<string> {
108129
if (_docsConfigCache) return _docsConfigCache;
109130

110-
try {
111-
const response = await fetch(GITHUB_INTEGRATION_CONFIG_URL, { signal: AbortSignal.timeout(5000) });
112-
if (response.ok) {
113-
_docsConfigCache = await response.text();
114-
console.log("Loaded integration config from GitHub (latest)");
115-
return _docsConfigCache;
116-
}
117-
} catch {
118-
console.warn("Warning: Could not fetch integration config from GitHub");
131+
const fetched = await fetchFirstOk(GITHUB_INTEGRATION_CONFIG_URLS);
132+
if (fetched) {
133+
_docsConfigCache = fetched.body;
134+
console.log(`Loaded integration config from GitHub (latest): ${fetched.url}`);
135+
return _docsConfigCache;
119136
}
137+
console.warn("Warning: Could not fetch integration config from GitHub");
120138

121139
return "";
122140
}

services/pr-evaluator/prompts/commandments.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Fallback copy of context-mill/transformation-config/commandments.yaml — fetched from GitHub at runtime, this is only used if the fetch fails
1+
# Fallback copy of context-mill/context/commandments.yaml — fetched from GitHub at runtime, this is only used if the fetch fails
22
# Tag-based rules that get folded into skill descriptions
33
# Skills collect all commandments matching their tags
44

0 commit comments

Comments
 (0)