-
Notifications
You must be signed in to change notification settings - Fork 237
Agent context single source #6747
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
6 commits
Select commit
Hold shift + click to select a range
60ad996
WIP
ethanpalm 797f835
remove plugin-specific MCP info
ethanpalm 9290060
remove artifact digest
ethanpalm e0566c1
fix stray writeFile import line left over from digest removal
ethanpalm 96fe68f
💅
ethanpalm 0a93813
bug bot
ethanpalm 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Validate agent context | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - agent-context/** | ||
| - .github/workflows/agent-context-ci.yml | ||
| - .github/workflows/sync-agent-context.yml | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - agent-context/** | ||
| - .github/workflows/agent-context-ci.yml | ||
| - .github/workflows/sync-agent-context.yml | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| package-manager-cache: false | ||
| - run: npm test | ||
| working-directory: agent-context | ||
| - run: npm run check | ||
| working-directory: agent-context | ||
| - run: npm run build | ||
| working-directory: agent-context |
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,132 @@ | ||
| name: Sync plugin context | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - agent-context/context/** | ||
| - agent-context/targets/** | ||
| - agent-context/scripts/** | ||
| - agent-context/test/** | ||
| - agent-context/package.json | ||
| - .github/workflows/sync-agent-context.yml | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: sync-plugin-context | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| package-manager-cache: false | ||
| - run: npm test | ||
| working-directory: agent-context | ||
| - run: npm run check | ||
| working-directory: agent-context | ||
|
|
||
| sync: | ||
| needs: validate | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - target: codex | ||
| repository: mintlify/codex-plugin | ||
| repository_name: codex-plugin | ||
| mcp_file: .mcp.json | ||
| - target: cursor | ||
| repository: mintlify/cursor-plugin | ||
| repository_name: cursor-plugin | ||
| mcp_file: mcp.json | ||
| - target: claude | ||
| repository: mintlify/mintlify-claude-plugin | ||
| repository_name: mintlify-claude-plugin | ||
| mcp_file: .mcp.json | ||
|
|
||
| steps: | ||
| - name: Check out context source | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| path: source | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| package-manager-cache: false | ||
|
|
||
| - name: Create target repository token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@v3 | ||
| with: | ||
| client-id: ${{ vars.CONTEXT_SYNC_APP_CLIENT_ID }} | ||
| private-key: ${{ secrets.CONTEXT_SYNC_APP_PRIVATE_KEY }} | ||
| owner: mintlify | ||
| repositories: ${{ matrix.repository_name }} | ||
| permission-contents: write | ||
| permission-pull-requests: write | ||
|
|
||
| - name: Check out target repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| repository: ${{ matrix.repository }} | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| path: target | ||
|
|
||
| - name: Generate target context | ||
| run: node source/agent-context/scripts/sync-target.mjs "${{ matrix.target }}" target | ||
|
|
||
| - name: Detect changes | ||
| id: changes | ||
| working-directory: target | ||
| run: | | ||
| if [[ -n "$(git status --porcelain)" ]]; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Commit and push sync branch | ||
| if: steps.changes.outputs.changed == 'true' | ||
| working-directory: target | ||
| env: | ||
| APP_SLUG: ${{ steps.app-token.outputs.app-slug }} | ||
| BRANCH: automation/sync-agent-context | ||
| run: | | ||
| git config user.name "${APP_SLUG}[bot]" | ||
| git config user.email "${APP_SLUG}[bot]@users.noreply.github.com" | ||
| git checkout -B "$BRANCH" | ||
| git add skills/mintlify .mintlify-agent-context.json "${{ matrix.mcp_file }}" | ||
| git commit -m "Sync Mintlify agent context" | ||
| git fetch origin "$BRANCH:refs/remotes/origin/$BRANCH" || true | ||
| git push --force-with-lease origin "HEAD:$BRANCH" | ||
|
|
||
| - name: Open sync pull request | ||
| if: steps.changes.outputs.changed == 'true' | ||
| working-directory: target | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| GH_REPO: ${{ matrix.repository }} | ||
| BRANCH: automation/sync-agent-context | ||
| SOURCE_SHA: ${{ github.sha }} | ||
| run: | | ||
| BODY="Generated from mintlify/docs at ${SOURCE_SHA} using agent-context. Do not edit generated skill files in this repository." | ||
| EXISTING_PR="$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')" | ||
| if [[ -z "$EXISTING_PR" ]]; then | ||
| gh pr create \ | ||
| --head "$BRANCH" \ | ||
| --base main \ | ||
| --title "Sync Mintlify agent context" \ | ||
| --body "$BODY" | ||
| else | ||
| gh pr edit "$EXISTING_PR" --body "$BODY" | ||
| fi | ||
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,2 @@ | ||
| # Internal tooling that compiles context for external agent plugins. | ||
| agent-context/ |
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,3 @@ | ||
| dist/ | ||
| node_modules/ | ||
| .DS_Store |
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,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 Mintlify | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
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,60 @@ | ||
| # Mintlify agent context | ||
|
|
||
| Single source of truth, maintained in the Mintlify documentation repository, for the Mintlify skill distributed through the Codex, Cursor, and Claude plugins. | ||
|
|
||
| ## Repository structure | ||
|
|
||
| - `context/skills/mintlify/` contains canonical, client-neutral context. | ||
| - `context/mcp-servers.json` contains canonical MCP names, URLs, and transport settings. | ||
| - `targets/*.json` contains only client packaging differences such as MCP config file and schema names. | ||
| - `scripts/build.mjs` renders self-contained plugin artifacts into `dist/`. | ||
| - `scripts/sync-target.mjs` replaces only `skills/mintlify/` in a target repository. | ||
| - `../.github/workflows/sync-agent-context.yml` opens generated sync pull requests in all three plugin repositories. | ||
|
|
||
| Plugin manifests, assets, READMEs, and Cursor rules remain owned by their target repositories. This project generates the shared skill and each client's MCP configuration file. | ||
|
|
||
| ## Local development | ||
|
|
||
| Requires Node.js 22 or newer and has no package dependencies. | ||
|
|
||
| ```bash | ||
| npm test | ||
| npm run check | ||
| npm run build | ||
| npm run status | ||
| ``` | ||
|
|
||
| Build one target by passing its ID: | ||
|
|
||
| ```bash | ||
| node scripts/build.mjs codex | ||
| ``` | ||
|
|
||
| Preview a sync into a local checkout: | ||
|
|
||
| ```bash | ||
| node scripts/sync-target.mjs codex ../../codex-plugin | ||
| git -C ../../codex-plugin diff | ||
| ``` | ||
|
|
||
| The sync command replaces `skills/mintlify/`, writes the client-specific MCP configuration file, and writes `.mintlify-agent-context.json` with the source commit. It does not change any other plugin files. | ||
|
|
||
| `npm run status` compares locally checked-out sibling plugin repositories with fresh builds and reports whether each one is current. Pass a workspace root as the final argument if the repositories do not share this repository's parent directory. | ||
|
|
||
| ## Publishing setup | ||
|
|
||
| Create a GitHub App installed on these repositories: | ||
|
|
||
| - `mintlify/codex-plugin` | ||
| - `mintlify/cursor-plugin` | ||
| - `mintlify/mintlify-claude-plugin` | ||
|
|
||
| Grant the app repository **Contents: read and write** and **Pull requests: read and write** permissions. Add its client ID as the `CONTEXT_SYNC_APP_CLIENT_ID` Actions variable and its private key as the `CONTEXT_SYNC_APP_PRIVATE_KEY` Actions secret in the `mintlify/docs` repository. | ||
|
|
||
| Every qualifying push to `main` validates the source and opens or updates the `automation/sync-agent-context` pull request in each repository. The workflow never pushes directly to a target's default branch. | ||
|
|
||
| ## Editing rules | ||
|
|
||
| Edit shared knowledge and MCP definitions in `context/`, not in generated plugin copies. Put a value in `targets/` only when a client requires a different packaging format. | ||
|
|
||
| The build rejects retired CLI commands. Tests verify that the skill, detailed references, and MCP definitions remain semantically identical across targets. |
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,10 @@ | ||
| { | ||
| "Mintlify Search": { | ||
| "type": "http", | ||
| "url": "https://mintlify.com/docs/mcp" | ||
| }, | ||
| "Mintlify Admin": { | ||
| "type": "http", | ||
| "url": "https://mcp.mintlify.com" | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.