-
Notifications
You must be signed in to change notification settings - Fork 43
feat(metrics): add wizard metrics program (runs the context-mill metrics skill)
#1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
98419b9
feat(metrics): add `wizard metrics` program for application metrics
DanielVisca ee6ab19
fix(metrics): make the metrics intro e2e-drivable
DanielVisca 705728a
Merge main into posthog/metrics-program (replay-vision landed; unions…
gewenyu99 eae2c3d
feat(metrics): move the metrics program to the orchestrator sequence …
gewenyu99 cc731be
refactor(metrics): one collapsed skill — drop the detect step and var…
gewenyu99 46d6332
revert(metrics): back to the five platform variants — tasks and the l…
gewenyu99 6f2d352
fix(pi): grant the skill-menu tool pair to tasks whose frontmatter al…
gewenyu99 c5d6f23
chore: metrics program owned by @PostHog/apm
gewenyu99 86aee59
Merge branch 'main' into posthog/metrics-program
gewenyu99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { metricsConfig } from '@lib/programs/metrics/index'; | ||
|
|
||
| import type { Command } from './command'; | ||
| import { nativeCommandFactory } from './factories/native-command-factory'; | ||
|
|
||
| /** | ||
| * `wizard metrics` — flat skill command, wire PostHog application metrics | ||
| * (counters, gauges, histograms via \`posthog.metrics\`) into a project. | ||
| * | ||
| * The `metrics` context-mill skill has one variant per platform (python, | ||
| * nodejs, javascript, kubernetes, other/OTLP); the agent picks the right one | ||
| * at run time by scanning the project's manifest and (when ambiguous) asking | ||
| * the user via `wizard_ask`. Stays flat while a single "add metrics to a | ||
| * project" flow is the only action. | ||
| */ | ||
| export const metricsCommand: Command = nativeCommandFactory(metricsConfig); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/index'; | ||
| import { getProgramConfig, Program } from '@lib/programs/program-registry'; | ||
| import { metricsConfig } from '@lib/programs/metrics/index'; | ||
| import type { ProgramRun } from '@lib/agent/agent-runner'; | ||
| import type { WizardSession } from '@lib/wizard-session'; | ||
|
|
||
| import { metricsCommand } from '../../../commands/metrics'; | ||
|
|
||
| function staticRun(config: typeof metricsConfig): ProgramRun { | ||
| if (typeof config.run === 'function') { | ||
| throw new Error('expected a static ProgramRun, got a function'); | ||
| } | ||
| if (!config.run) throw new Error('expected a ProgramRun'); | ||
| return config.run; | ||
| } | ||
|
|
||
| describe('metrics program', () => { | ||
| it('is registered as a flat top-level `metrics` command', () => { | ||
| const config = getProgramConfig('metrics'); | ||
| expect(config).toBe(metricsConfig); | ||
| expect(config.command).toBe('metrics'); | ||
| expect(config.parentCommand).toBeUndefined(); | ||
| expect(Program.Metrics).toBe('metrics'); | ||
| }); | ||
|
|
||
| it('uses the agent-skill steps with a metrics-specific intro', () => { | ||
| const [intro, ...rest] = metricsConfig.steps; | ||
| expect(intro.id).toBe('intro'); | ||
| expect(intro.screenId).toBe('metrics-intro'); | ||
| expect(rest).toEqual(AGENT_SKILL_STEPS.slice(1)); | ||
| }); | ||
|
|
||
| it('runs the metrics agent flow on the orchestrator', () => { | ||
| expect(metricsConfig.agentFlow).toBe('metrics'); | ||
| }); | ||
|
|
||
| it('has no fixed skillId — the agent picks the variant from the menu', () => { | ||
| const run = staticRun(metricsConfig); | ||
| expect(run.skillId).toBeUndefined(); | ||
|
|
||
| const prompt = run.customPrompt?.({} as WizardSession); | ||
| expect(prompt).toContain('load_skill_menu'); | ||
| expect(prompt).toContain('"metrics"'); | ||
| // Every published variant the prompt teaches the agent to choose from. | ||
| for (const variant of [ | ||
| 'metrics-python', | ||
| 'metrics-nodejs', | ||
| 'metrics-javascript', | ||
| 'metrics-kubernetes', | ||
| 'metrics-other', | ||
| ]) { | ||
| expect(prompt).toContain(variant); | ||
| } | ||
| }); | ||
|
|
||
| it('points the outro at the metrics docs and report file', () => { | ||
| const run = staticRun(metricsConfig); | ||
| expect(run.docsUrl).toBe('https://posthog.com/docs/metrics'); | ||
| expect(run.reportFile).toBe('posthog-metrics-report.md'); | ||
| expect(metricsConfig.reportFile).toBe(run.reportFile); | ||
| }); | ||
|
|
||
| it('is exposed as a yargs command via nativeCommandFactory', () => { | ||
| expect(metricsCommand.name).toBe('metrics'); | ||
| expect(metricsCommand.description).toBe(metricsConfig.description); | ||
| expect(typeof metricsCommand.handler).toBe('function'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Medium: Skill installation can escape the workspace
Registering
install_skillhere makes the existing unsafe destination calculation reachable from remote task prompts. The installer passes the registry-controlledskillEntry.idtopath.join(installDir, '.claude', 'skills', skillEntry.id)without verifying that the result remains under.claude/skills; an attacker controlling the skill registry can use an ID such as../../../../targetto write the downloaded bundle outside the project, and a rejected scan subsequently callsrmSyncon that escaped directory. Validate skill IDs against a strict format and resolve the destination before any directory creation, download extraction, scanning, or cleanup, rejecting paths that are not descendants of the intended skills root.