Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/frameworks/ruby/ruby-wizard-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const RUBY_AGENT_CONFIG: FrameworkConfig<RubyContext> = {
``,
`client = PostHog::Client.new(`,
` api_key: ENV['POSTHOG_PROJECT_TOKEN'],`,
` host: ENV['POSTHOG_HOST'] || 'https://us.i.posthog.com'`,
` host: ENV['POSTHOG_HOST'] || '<PostHog Host from the project context above>'`,
`)`,
``,
`### 3. MUST Call shutdown Before Exit`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index';
import { DJANGO_AGENT_CONFIG } from '@frameworks/django/django-wizard-agent';
import type { WizardSession } from '@lib/wizard-session';
import type { PromptContext } from '@lib/agent/agent-prompt';
import * as os from 'node:os';

function makeSession(): WizardSession {
return {
installDir: os.tmpdir(),
frameworkConfig: DJANGO_AGENT_CONFIG,
frameworkContext: {},
additionalFeatureQueue: [],
} as unknown as WizardSession;
}

/**
* Regression: the auto-generated config must default POSTHOG_HOST to the
* detected region's host, not the US fallback. An EU user selecting EU in the
* CLI was getting `POSTHOG_HOST = os.environ.get('POSTHOG_HOST',
* 'https://us.i.posthog.com')` because the agent copied the US literal from
* example code. The prompt now tells the agent to use the detected host as the
* fallback default.
*/
describe('integration prompt threads the region host into generated fallbacks', () => {
const euCtx: PromptContext = {
projectId: 42,
projectApiKey: 'phc_test',
host: 'https://eu.i.posthog.com',
};

it('instructs the agent to use the EU host as the fallback default', async () => {
const run = await posthogIntegrationConfig.run(makeSession());
const prompt = run.customPrompt!(euCtx);

// The detected host is present and called out as the fallback default.
expect(prompt).toContain('https://eu.i.posthog.com');
// It explicitly warns against emitting a mismatched-region fallback.
expect(prompt).toContain('region-correct host');
expect(prompt).toContain(
'Never emit a fallback host for a different region than the detected one.',
);
// The US literal only ever appears as the example of what NOT to hardcode,
// never as the value the agent should use.
expect(prompt).not.toMatch(
/use https:\/\/us\.i\.posthog\.com as that default/,
);
});
});
5 changes: 5 additions & 0 deletions src/lib/programs/posthog-integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ STEP 5: Set up environment variables for PostHog using the wizard-tools MCP serv
config.metadata.name
}, which you'll find in example code. The tool will also ensure .gitignore coverage. Don't assume the presence of keys means the value is up to date. Write the correct value each time.
- Reference these environment variables in the code files you create instead of hardcoding the public token and host.
- IMPORTANT — region-correct host: this project's PostHog Host is ${
ctx.host
}. Example code (from skills or docs) often hardcodes a fallback like \`https://us.i.posthog.com\`. When you write a fallback/default host in generated code (e.g. \`os.environ.get('POSTHOG_HOST', '...')\` or \`ENV['POSTHOG_HOST'] || '...'\`), use ${
ctx.host
} as that default so it matches the user's region. Never emit a fallback host for a different region than the detected one.

Important: Use the detect_package_manager tool (from the wizard-tools MCP server) to determine which package manager the project uses. Do not manually search for lockfiles or config files. Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation. You must read a file immediately before attempting to write it, even if you have previously read it; failure to do so will cause a tool failure.

Expand Down
Loading