chore: regenerate the screenshots from a scripted demo machine
ac310d3 parent: 8f750be modified
README.md +5 -0 | @@ -106,6 +106,10 @@ Browse skill sources and import what you want into your catalog. Three sources a | ||
| 106 | 106 | |
| 107 | 107 | Commit, pull and push from the UI, against any remote: GitHub, GitLab, Codeberg, rickub, a self-hosted server… Conflicts are resolved file by file. An optional automatic mode commits and syncs after each change. On a new machine, clone your catalog during setup, add your projects, and you are back. |
| 108 | 108 | |
| 109 | +<p align="center"> | |
| 110 | + <img src="media/screenshots/sync.png" alt="The catalog synced with a shared git remote" width="900"> | |
| 111 | +</p> | |
| 112 | + | |
| 109 | 113 | ## Supported agents and items |
| 110 | 114 | |
| 111 | 115 | | | Claude Code | Codex | |
| @@ -205,6 +209,7 @@ The repository is a TypeScript monorepo managed with pnpm: | ||
| 205 | 209 | pnpm dev # API on :4300 and the UI with hot reload on :3000 |
| 206 | 210 | pnpm test # Vitest |
| 207 | 211 | pnpm typecheck |
| 212 | +pnpm screenshots # rebuilds media/screenshots from a demo machine in /demo (needs pnpm build first) | |
| 208 | 213 | ``` |
| 209 | 214 | |
| 210 | 215 | Commits follow [Conventional Commits](https://www.conventionalcommits.org/). |
| @@ -106,6 +106,10 @@ Browse skill sources and import what you want into your catalog. Three sources a | |||
| 106 | 106 | ||
| 107 | Commit, pull and push from the UI, against any remote: GitHub, GitLab, Codeberg, rickub, a self-hosted server… Conflicts are resolved file by file. An optional automatic mode commits and syncs after each change. On a new machine, clone your catalog during setup, add your projects, and you are back. | 107 | Commit, pull and push from the UI, against any remote: GitHub, GitLab, Codeberg, rickub, a self-hosted server… Conflicts are resolved file by file. An optional automatic mode commits and syncs after each change. On a new machine, clone your catalog during setup, add your projects, and you are back. |
| 108 | 108 | ||
| 109 | +<p align="center"> | ||
| 110 | + <img src="media/screenshots/sync.png" alt="The catalog synced with a shared git remote" width="900"> | ||
| 111 | +</p> | ||
| 112 | + | ||
| 109 | ## Supported agents and items | 113 | ## Supported agents and items |
| 110 | 114 | ||
| 111 | | | Claude Code | Codex | | 115 | | | Claude Code | Codex | |
| @@ -205,6 +209,7 @@ The repository is a TypeScript monorepo managed with pnpm: | |||
| 205 | pnpm dev # API on :4300 and the UI with hot reload on :3000 | 209 | pnpm dev # API on :4300 and the UI with hot reload on :3000 |
| 206 | pnpm test # Vitest | 210 | pnpm test # Vitest |
| 207 | pnpm typecheck | 211 | pnpm typecheck |
| 212 | +pnpm screenshots # rebuilds media/screenshots from a demo machine in /demo (needs pnpm build first) | ||
| 208 | ``` | 213 | ``` |
| 209 | 214 | ||
| 210 | Commits follow [Conventional Commits](https://www.conventionalcommits.org/). | 215 | Commits follow [Conventional Commits](https://www.conventionalcommits.org/). |
modified
media/screenshots/catalog.png +0 -0 | Binary files a/media/screenshots/catalog.png and b/media/screenshots/catalog.png differ |
| Binary files a/media/screenshots/catalog.png and b/media/screenshots/catalog.png differ | Binary files a/media/screenshots/catalog.png and b/media/screenshots/catalog.png differ |
modified
media/screenshots/global.png +0 -0 | Binary files a/media/screenshots/global.png and b/media/screenshots/global.png differ |
| Binary files a/media/screenshots/global.png and b/media/screenshots/global.png differ | Binary files a/media/screenshots/global.png and b/media/screenshots/global.png differ |
modified
media/screenshots/marketplaces.png +0 -0 | Binary files a/media/screenshots/marketplaces.png and b/media/screenshots/marketplaces.png differ |
| Binary files a/media/screenshots/marketplaces.png and b/media/screenshots/marketplaces.png differ | Binary files a/media/screenshots/marketplaces.png and b/media/screenshots/marketplaces.png differ |
modified
media/screenshots/presets.png +0 -0 | Binary files a/media/screenshots/presets.png and b/media/screenshots/presets.png differ |
| Binary files a/media/screenshots/presets.png and b/media/screenshots/presets.png differ | Binary files a/media/screenshots/presets.png and b/media/screenshots/presets.png differ |
modified
media/screenshots/project.png +0 -0 | Binary files a/media/screenshots/project.png and b/media/screenshots/project.png differ |
| Binary files a/media/screenshots/project.png and b/media/screenshots/project.png differ | Binary files a/media/screenshots/project.png and b/media/screenshots/project.png differ |
modified
media/screenshots/review.png +0 -0 | Binary files a/media/screenshots/review.png and b/media/screenshots/review.png differ |
| Binary files a/media/screenshots/review.png and b/media/screenshots/review.png differ | Binary files a/media/screenshots/review.png and b/media/screenshots/review.png differ |
added
media/screenshots/sync.png +0 -0 | new file mode 100644 | ||
| Binary files /dev/null and b/media/screenshots/sync.png differ | ||
| new file mode 100644 | |||
| Binary files /dev/null and b/media/screenshots/sync.png differ | Binary files /dev/null and b/media/screenshots/sync.png differ | ||
modified
package.json +3 -1 | @@ -10,10 +10,12 @@ | ||
| 10 | 10 | "start": "pnpm --filter panoplie start", |
| 11 | 11 | "test": "vitest run", |
| 12 | 12 | "typecheck": "tsc -p packages/core && tsc -p packages/server && tsc -p packages/cli", |
| 13 | - "site:build": "node site/build.mjs" | |
| 13 | + "site:build": "node site/build.mjs", | |
| 14 | + "screenshots": "tsx scripts/screenshots.ts" | |
| 14 | 15 | }, |
| 15 | 16 | "devDependencies": { |
| 16 | 17 | "@types/node": "^22.10.0", |
| 18 | + "playwright": "^1.65.0", | |
| 17 | 19 | "tsx": "^4.20.0", |
| 18 | 20 | "typescript": "~5.9.0", |
| 19 | 21 | "vitest": "^4.0.0" |
| @@ -10,10 +10,12 @@ | |||
| 10 | "start": "pnpm --filter panoplie start", | 10 | "start": "pnpm --filter panoplie start", |
| 11 | "test": "vitest run", | 11 | "test": "vitest run", |
| 12 | "typecheck": "tsc -p packages/core && tsc -p packages/server && tsc -p packages/cli", | 12 | "typecheck": "tsc -p packages/core && tsc -p packages/server && tsc -p packages/cli", |
| 13 | - "site:build": "node site/build.mjs" | 13 | + "site:build": "node site/build.mjs", |
| 14 | + "screenshots": "tsx scripts/screenshots.ts" | ||
| 14 | }, | 15 | }, |
| 15 | "devDependencies": { | 16 | "devDependencies": { |
| 16 | "@types/node": "^22.10.0", | 17 | "@types/node": "^22.10.0", |
| 18 | + "playwright": "^1.65.0", | ||
| 17 | "tsx": "^4.20.0", | 19 | "tsx": "^4.20.0", |
| 18 | "typescript": "~5.9.0", | 20 | "typescript": "~5.9.0", |
| 19 | "vitest": "^4.0.0" | 21 | "vitest": "^4.0.0" |
modified
pnpm-lock.yaml +19 -0 | @@ -11,6 +11,9 @@ importers: | ||
| 11 | 11 | '@types/node': |
| 12 | 12 | specifier: ^22.10.0 |
| 13 | 13 | version: 22.20.5 |
| 14 | + playwright: | |
| 15 | + specifier: ^1.65.0 | |
| 16 | + version: 1.65.0 | |
| 14 | 17 | tsx: |
| 15 | 18 | specifier: ^4.20.0 |
| 16 | 19 | version: 4.23.15 |
| @@ -3217,6 +3220,16 @@ packages: | ||
| 3217 | 3220 | pkg-types@2.4.0: |
| 3218 | 3221 | resolution: {integrity: sha512-07Fys7iVx0X6TcviMOgogM1Lk33ZyqOezMnU79S+kffWqwolG/5W9V8EgQSeYCIfFTYVgssRbnH630Oa2+soBA==} |
| 3219 | 3222 | |
| 3223 | + playwright-core@1.65.0: | |
| 3224 | + resolution: {integrity: sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==} | |
| 3225 | + engines: {node: '>=20'} | |
| 3226 | + hasBin: true | |
| 3227 | + | |
| 3228 | + playwright@1.65.0: | |
| 3229 | + resolution: {integrity: sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==} | |
| 3230 | + engines: {node: '>=20'} | |
| 3231 | + hasBin: true | |
| 3232 | + | |
| 3220 | 3233 | postcss-calc@11.2.3: |
| 3221 | 3234 | resolution: {integrity: sha512-pFW3MR2a4W7uHcSGUiyQGGXZWHon83ljbNwnUJ1mRKublWQbv+3o9NiqhlV4TJfNby+U+zLY2OgiywzhA5eFqw==} |
| 3222 | 3235 | engines: {node: ^22.22.3 || ^24.15 || >=26.0} |
| @@ -7760,6 +7773,12 @@ snapshots: | ||
| 7760 | 7773 | exsolve: 1.1.3 |
| 7761 | 7774 | pathe: 2.0.3 |
| 7762 | 7775 | |
| 7776 | + playwright-core@1.65.0: {} | |
| 7777 | + | |
| 7778 | + playwright@1.65.0: | |
| 7779 | + dependencies: | |
| 7780 | + playwright-core: 1.65.0 | |
| 7781 | + | |
| 7763 | 7782 | postcss-calc@11.2.3(postcss@8.5.31): |
| 7764 | 7783 | dependencies: |
| 7765 | 7784 | '@csstools/css-tokenizer': 4.0.2 |
| @@ -11,6 +11,9 @@ importers: | |||
| 11 | '@types/node': | 11 | '@types/node': |
| 12 | specifier: ^22.10.0 | 12 | specifier: ^22.10.0 |
| 13 | version: 22.20.5 | 13 | version: 22.20.5 |
| 14 | + playwright: | ||
| 15 | + specifier: ^1.65.0 | ||
| 16 | + version: 1.65.0 | ||
| 14 | tsx: | 17 | tsx: |
| 15 | specifier: ^4.20.0 | 18 | specifier: ^4.20.0 |
| 16 | version: 4.23.15 | 19 | version: 4.23.15 |
| @@ -3217,6 +3220,16 @@ packages: | |||
| 3217 | pkg-types@2.4.0: | 3220 | pkg-types@2.4.0: |
| 3218 | resolution: {integrity: sha512-07Fys7iVx0X6TcviMOgogM1Lk33ZyqOezMnU79S+kffWqwolG/5W9V8EgQSeYCIfFTYVgssRbnH630Oa2+soBA==} | 3221 | resolution: {integrity: sha512-07Fys7iVx0X6TcviMOgogM1Lk33ZyqOezMnU79S+kffWqwolG/5W9V8EgQSeYCIfFTYVgssRbnH630Oa2+soBA==} |
| 3219 | 3222 | ||
| 3223 | + playwright-core@1.65.0: | ||
| 3224 | + resolution: {integrity: sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==} | ||
| 3225 | + engines: {node: '>=20'} | ||
| 3226 | + hasBin: true | ||
| 3227 | + | ||
| 3228 | + playwright@1.65.0: | ||
| 3229 | + resolution: {integrity: sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==} | ||
| 3230 | + engines: {node: '>=20'} | ||
| 3231 | + hasBin: true | ||
| 3232 | + | ||
| 3220 | postcss-calc@11.2.3: | 3233 | postcss-calc@11.2.3: |
| 3221 | resolution: {integrity: sha512-pFW3MR2a4W7uHcSGUiyQGGXZWHon83ljbNwnUJ1mRKublWQbv+3o9NiqhlV4TJfNby+U+zLY2OgiywzhA5eFqw==} | 3234 | resolution: {integrity: sha512-pFW3MR2a4W7uHcSGUiyQGGXZWHon83ljbNwnUJ1mRKublWQbv+3o9NiqhlV4TJfNby+U+zLY2OgiywzhA5eFqw==} |
| 3222 | engines: {node: ^22.22.3 || ^24.15 || >=26.0} | 3235 | engines: {node: ^22.22.3 || ^24.15 || >=26.0} |
| @@ -7760,6 +7773,12 @@ snapshots: | |||
| 7760 | exsolve: 1.1.3 | 7773 | exsolve: 1.1.3 |
| 7761 | pathe: 2.0.3 | 7774 | pathe: 2.0.3 |
| 7762 | 7775 | ||
| 7776 | + playwright-core@1.65.0: {} | ||
| 7777 | + | ||
| 7778 | + playwright@1.65.0: | ||
| 7779 | + dependencies: | ||
| 7780 | + playwright-core: 1.65.0 | ||
| 7781 | + | ||
| 7763 | postcss-calc@11.2.3(postcss@8.5.31): | 7782 | postcss-calc@11.2.3(postcss@8.5.31): |
| 7764 | dependencies: | 7783 | dependencies: |
| 7765 | '@csstools/css-tokenizer': 4.0.2 | 7784 | '@csstools/css-tokenizer': 4.0.2 |
added
scripts/screenshots.ts +332 -0 | new file mode 100644 | ||
| @@ -0,0 +1,332 @@ | ||
| 1 | +// Regenerates media/screenshots: builds a throwaway demo machine (a fake home folder, three projects, a catalog with | |
| 2 | +// a "team" remote and a teammate's commit), runs the real server against it and captures the UI with Playwright. | |
| 3 | +// | |
| 4 | +// pnpm build # the UI must be built first | |
| 5 | +// pnpm screenshots [demoDir] # demoDir defaults to /demo (G:\demo on Windows); it appears in the screenshots | |
| 6 | +// | |
| 7 | +// Needs network access: the marketplace screenshot clones Anthropic's skills repository. | |
| 8 | +import { execFileSync } from 'node:child_process' | |
| 9 | +import { existsSync, readdirSync } from 'node:fs' | |
| 10 | +import { mkdir, rm, writeFile } from 'node:fs/promises' | |
| 11 | +import path from 'node:path' | |
| 12 | +import { fileURLToPath } from 'node:url' | |
| 13 | + | |
| 14 | +const repo = fileURLToPath(new URL('..', import.meta.url)) | |
| 15 | +const demo = path.resolve(process.argv[2] ?? process.env.PANOPLIE_DEMO_DIR ?? '/demo') | |
| 16 | +const home = path.join(demo, 'home') | |
| 17 | +const code = path.join(home, 'code') | |
| 18 | +const remoteDir = path.join(demo, 'remote', 'agent-catalog.git') | |
| 19 | +const teammateDir = path.join(demo, 'teammate') | |
| 20 | +/** Shown on the Sync page instead of the local bare repository the demo really syncs with. */ | |
| 21 | +const SHOWN_REMOTE = 'git@github.com:acme/agent-catalog.git' | |
| 22 | +const out = path.join(repo, 'media', 'screenshots') | |
| 23 | +const MARKER = '.panoplie-demo' | |
| 24 | + | |
| 25 | +// --------------------------------------------------------------------------------------------------------------- | |
| 26 | +// Demo machine | |
| 27 | + | |
| 28 | +async function write(file: string, content: string): Promise<void> { | |
| 29 | + await mkdir(path.dirname(file), { recursive: true }) | |
| 30 | + await writeFile(file, content, 'utf8') | |
| 31 | +} | |
| 32 | + | |
| 33 | +function git(cwd: string, ...args: string[]): string { | |
| 34 | + return execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }) | |
| 35 | +} | |
| 36 | + | |
| 37 | +const skill = (name: string, description: string, body: string): string => | |
| 38 | + `---\nname: ${name}\ndescription: ${JSON.stringify(description)}\n---\n\n${body.trim()}\n` | |
| 39 | + | |
| 40 | +const SKILLS: Record<string, [string, string]> = { | |
| 41 | + 'code-review': [ | |
| 42 | + 'Review a diff for bugs, risky changes and missing tests before it is merged.', | |
| 43 | + '# Code review\n\nRead the whole diff first, then comment file by file.\n\n- Flag behaviour changes that have no test.\n- Point out error paths that swallow failures.\n- Suggest, do not rewrite: keep comments short and actionable.', | |
| 44 | + ], | |
| 45 | + 'commit-convention': [ | |
| 46 | + 'Write commit messages that follow Conventional Commits.', | |
| 47 | + '# Commit convention\n\nFormat: `type(scope): subject`, in the imperative, under 72 characters.\n\nTypes: feat, fix, docs, refactor, test, chore, ci.', | |
| 48 | + ], | |
| 49 | + nuxt: [ | |
| 50 | + 'Conventions for Nuxt 4 apps: folders, data fetching, server routes.', | |
| 51 | + '# Nuxt\n\n- Pages in `app/pages`, server routes in `server/api`.\n- Fetch with `useFetch` in components, `$fetch` in handlers.\n- Never import server code from the client.', | |
| 52 | + ], | |
| 53 | + 'nuxt-content': [ | |
| 54 | + 'Write and query content with Nuxt Content collections.', | |
| 55 | + '# Nuxt Content\n\nDeclare every collection in `content.config.ts` with a schema, then query it with `queryCollection`.', | |
| 56 | + ], | |
| 57 | + tailwind: [ | |
| 58 | + 'Style components with Tailwind CSS v4 and the design tokens of the project.', | |
| 59 | + '# Tailwind\n\nUse the theme tokens, never raw hex values. Group classes: layout, box, type, color, state.', | |
| 60 | + ], | |
| 61 | + 'seo-audit': [ | |
| 62 | + 'Audit a page for technical SEO: titles, meta, headings, links, structured data.', | |
| 63 | + '# SEO audit\n\nCheck, in order: title and description length, one h1, canonical, internal links, JSON-LD.', | |
| 64 | + ], | |
| 65 | + 'seo-keywords': [ | |
| 66 | + 'Find the keywords a page should target and where to place them.', | |
| 67 | + '# SEO keywords\n\nStart from the search intent. Pick one main keyword and three related ones per page.', | |
| 68 | + ], | |
| 69 | + 'api-design': [ | |
| 70 | + 'Design REST endpoints: naming, status codes, pagination, errors.', | |
| 71 | + '# API design\n\nPlural nouns, no verbs in paths. Errors are `{ code, message }` with a 4xx or 5xx status.', | |
| 72 | + ], | |
| 73 | + 'release-notes': [ | |
| 74 | + 'Turn merged pull requests into release notes users can read.', | |
| 75 | + '# Release notes\n\nGroup by Added, Changed, Fixed. One line per change, written for users, not for developers.', | |
| 76 | + ], | |
| 77 | +} | |
| 78 | + | |
| 79 | +const RULES: Record<string, string> = { | |
| 80 | + typescript: '---\ndescription: TypeScript conventions\n---\n\nStrict mode. No `any`. Prefer `type` imports and narrow with type guards.\n', | |
| 81 | + writing: '---\ndescription: House style for articles\n---\n\nShort sentences. Active voice. One idea per paragraph.\n', | |
| 82 | +} | |
| 83 | + | |
| 84 | +const AGENTS: Record<string, string> = { | |
| 85 | + 'test-runner': | |
| 86 | + '---\nname: test-runner\ndescription: Runs the test suite and fixes failing tests.\n---\n\nRun the tests, read the failures, fix the code (not the tests) and run them again.\n', | |
| 87 | +} | |
| 88 | + | |
| 89 | +const MCPS: Record<string, string> = { | |
| 90 | + 'nuxt-docs': 'name: nuxt-docs\ndescription: Nuxt documentation\ntransport: http\nurl: https://mcp.nuxt.com/\n', | |
| 91 | + github: 'name: github\ndescription: GitHub issues and pull requests\ntransport: stdio\ncommand: npx\nargs: [-y, "@modelcontextprotocol/server-github"]\nenv:\n GITHUB_TOKEN: { fromEnv: GITHUB_TOKEN }\n', | |
| 92 | +} | |
| 93 | + | |
| 94 | +const HOOKS: Record<string, string> = { | |
| 95 | + format: 'name: format\ndescription: Format edited files\nevent: PostToolUse\nmatcher: Edit|Write\nhandler:\n type: command\n command: npx prettier --write "$CLAUDE_FILE_PATHS"\n', | |
| 96 | +} | |
| 97 | + | |
| 98 | +const PRESETS = { | |
| 99 | + base: { description: 'What every project gets', items: { skill: ['code-review', 'commit-convention'], rule: ['typescript'] } }, | |
| 100 | + 'nuxt-saas': { | |
| 101 | + description: 'Nuxt apps', | |
| 102 | + includes: ['base'], | |
| 103 | + items: { skill: ['nuxt', 'nuxt-content', 'tailwind'], mcp: ['nuxt-docs'], hook: ['format'] }, | |
| 104 | + }, | |
| 105 | + seo: { description: 'Pages that need to rank', items: { skill: ['seo-audit', 'seo-keywords'] } }, | |
| 106 | +} | |
| 107 | + | |
| 108 | +async function createMachine(): Promise<void> { | |
| 109 | + if (existsSync(demo) && readdirSync(demo).length && !existsSync(path.join(demo, MARKER))) { | |
| 110 | + throw new Error(`${demo} exists and is not a panoplie demo folder; pick another one`) | |
| 111 | + } | |
| 112 | + await rm(demo, { recursive: true, force: true }) | |
| 113 | + await write(path.join(demo, MARKER), 'Created by scripts/screenshots.ts. Safe to delete.\n') | |
| 114 | + await write( | |
| 115 | + path.join(home, '.gitconfig'), | |
| 116 | + '[user]\n\tname = Sam Rivera\n\temail = sam@acme.dev\n[init]\n\tdefaultBranch = main\n[core]\n\tautocrlf = false\n[commit]\n\tgpgsign = false\n' | |
| 117 | + ) | |
| 118 | + | |
| 119 | + // Global (~/.claude): what had piled up before panoplie. | |
| 120 | + await write(path.join(home, '.claude', 'CLAUDE.md'), '# Global instructions\n\nAnswer briefly. Ask before deleting files.\n') | |
| 121 | + for (const name of ['nuxt', 'seo-audit', 'seo-keywords', 'tailwind']) { | |
| 122 | + const [description, body] = SKILLS[name]! | |
| 123 | + await write(path.join(home, '.claude', 'skills', name, 'SKILL.md'), skill(name, description, body)) | |
| 124 | + } | |
| 125 | + await write( | |
| 126 | + path.join(home, '.claude', 'skills', 'pdf', 'SKILL.md'), | |
| 127 | + skill('pdf', 'Read, fill and merge PDF files.', '# PDF\n\nUse `pdftotext` to read, `qpdf` to merge.') | |
| 128 | + ) | |
| 129 | + await write( | |
| 130 | + path.join(home, '.claude', 'skills', 'brainstorm', 'SKILL.md'), | |
| 131 | + skill('brainstorm', 'Generate and rank ideas before writing any code.', '# Brainstorm\n\nTen ideas, then keep three.') | |
| 132 | + ) | |
| 133 | + | |
| 134 | + // Projects. | |
| 135 | + await write(path.join(code, 'acme-shop', 'package.json'), '{ "name": "acme-shop", "private": true }\n') | |
| 136 | + await write(path.join(code, 'acme-shop', 'CLAUDE.md'), '# acme-shop\n\nNuxt 4 storefront.\n') | |
| 137 | + await write(path.join(code, 'billing-api', 'package.json'), '{ "name": "billing-api", "private": true }\n') | |
| 138 | + await write(path.join(code, 'billing-api', 'AGENTS.md'), '# billing-api\n\nInvoicing service.\n') | |
| 139 | + await write(path.join(code, 'blog', 'package.json'), '{ "name": "blog", "private": true }\n') | |
| 140 | + for (const p of ['acme-shop', 'billing-api', 'blog']) git(path.join(code, p), 'init', '-q') | |
| 141 | + // Codex only reads the .codex/ folder of projects it trusts. | |
| 142 | + await write( | |
| 143 | + path.join(home, '.codex', 'config.toml'), | |
| 144 | + ['acme-shop', 'billing-api'].map((p) => `[projects.${JSON.stringify(path.join(code, p))}]\ntrust_level = "trusted"\n`).join('\n') | |
| 145 | + ) | |
| 146 | + | |
| 147 | + // The team remote. | |
| 148 | + await mkdir(path.dirname(remoteDir), { recursive: true }) | |
| 149 | + git(demo, 'init', '-q', '--bare', '-b', 'main', remoteDir) | |
| 150 | +} | |
| 151 | + | |
| 152 | +// --------------------------------------------------------------------------------------------------------------- | |
| 153 | +// Server | |
| 154 | + | |
| 155 | +const TOKEN = 'demo' | |
| 156 | +let base = '' | |
| 157 | + | |
| 158 | +async function api<T = unknown>(method: string, url: string, body?: unknown): Promise<T> { | |
| 159 | + const res = await fetch(base + url, { | |
| 160 | + method, | |
| 161 | + headers: { 'x-panoplie-token': TOKEN, ...(body === undefined ? {} : { 'content-type': 'application/json' }) }, | |
| 162 | + body: body === undefined ? undefined : JSON.stringify(body), | |
| 163 | + }) | |
| 164 | + if (!res.ok) throw new Error(`${method} ${url}: ${res.status} ${await res.text()}`) | |
| 165 | + return (res.status === 204 ? undefined : await res.json()) as T | |
| 166 | +} | |
| 167 | + | |
| 168 | +async function seed(): Promise<void> { | |
| 169 | + const settings = await api<{ catalogPath: string }>('GET', '/api/settings') | |
| 170 | + const catalogDir = settings.catalogPath | |
| 171 | + await api('POST', '/api/catalog/init') | |
| 172 | + git(catalogDir, 'checkout', '-q', '-B', 'main') | |
| 173 | + await api('POST', '/api/catalog/git/remote', { url: remoteDir }) | |
| 174 | + | |
| 175 | + const tags: Record<string, string[]> = { nuxt: ['nuxt'], 'nuxt-content': ['nuxt'], tailwind: ['css'], 'seo-audit': ['seo'], 'seo-keywords': ['seo'] } | |
| 176 | + for (const [name, [description, body]] of Object.entries(SKILLS)) { | |
| 177 | + if (name === 'release-notes') continue // pushed later by the teammate | |
| 178 | + await api('PUT', `/api/catalog/items/skill/${name}`, { content: skill(name, description, body), tags: tags[name] }) | |
| 179 | + } | |
| 180 | + for (const [name, content] of Object.entries(RULES)) await api('PUT', `/api/catalog/items/rule/${name}`, { content }) | |
| 181 | + for (const [name, content] of Object.entries(AGENTS)) await api('PUT', `/api/catalog/items/agent/${name}`, { content }) | |
| 182 | + for (const [name, content] of Object.entries(MCPS)) await api('PUT', `/api/catalog/items/mcp/${name}`, { content }) | |
| 183 | + for (const [name, content] of Object.entries(HOOKS)) await api('PUT', `/api/catalog/items/hook/${name}`, { content }) | |
| 184 | + for (const [name, preset] of Object.entries(PRESETS)) await api('PUT', `/api/catalog/presets/${name}`, preset) | |
| 185 | + await api('POST', '/api/catalog/git/commit', { message: 'Add the team catalog' }) | |
| 186 | + await api('POST', '/api/catalog/git/sync') | |
| 187 | + | |
| 188 | + // Projects and what each one uses. | |
| 189 | + const config = (targets: string[], presets: string[], extra: Partial<Record<string, unknown>> = {}) => ({ | |
| 190 | + version: 1, | |
| 191 | + targets, | |
| 192 | + presets, | |
| 193 | + add: {}, | |
| 194 | + exclude: {}, | |
| 195 | + onDemand: { skills: [] }, | |
| 196 | + hideGlobal: { skills: [], mcp: [] }, | |
| 197 | + ...extra, | |
| 198 | + }) | |
| 199 | + const ids: Record<string, string> = {} | |
| 200 | + for (const p of ['acme-shop', 'billing-api', 'blog']) { | |
| 201 | + ids[p] = (await api<{ id: string }>('POST', '/api/projects', { path: path.join(code, p) })).id | |
| 202 | + } | |
| 203 | + const configs: Record<string, ReturnType<typeof config>> = { | |
| 204 | + 'acme-shop': config(['claude', 'codex'], ['nuxt-saas', 'seo'], { onDemand: { skills: ['seo-*'] }, add: { agent: ['test-runner'] } }), | |
| 205 | + 'billing-api': config(['codex'], ['base'], { add: { skill: ['api-design'], mcp: ['github'] } }), | |
| 206 | + blog: config(['claude'], ['seo'], { add: { rule: ['writing'] }, hideGlobal: { skills: ['pdf'], mcp: [] } }), | |
| 207 | + } | |
| 208 | + for (const [p, c] of Object.entries(configs)) { | |
| 209 | + await api('PUT', `/api/scopes/${ids[p]}/config`, c) | |
| 210 | + await api('POST', `/api/scopes/${ids[p]}/apply`, { resolutions: {} }) | |
| 211 | + } | |
| 212 | + | |
| 213 | + // Drift: someone tweaked a skill straight in acme-shop. | |
| 214 | + const drifted = path.join(code, 'acme-shop', '.claude', 'skills', 'code-review', 'SKILL.md') | |
| 215 | + const [crDescription, crBody] = SKILLS['code-review']! | |
| 216 | + await write( | |
| 217 | + drifted, | |
| 218 | + skill('code-review', crDescription, crBody + '\n- Check that every new page has a loading and an error state.') | |
| 219 | + ) | |
| 220 | + // And the catalog moved on since acme-shop was last applied: tailwind has a new rule. | |
| 221 | + const [twDescription, twBody] = SKILLS.tailwind! | |
| 222 | + await api('PUT', '/api/catalog/items/skill/tailwind', { | |
| 223 | + content: skill('tailwind', twDescription, twBody + '\n\nDark mode with the `dark:` variant only.'), | |
| 224 | + tags: ['css'], | |
| 225 | + }) | |
| 226 | + | |
| 227 | + // A teammate pushes a new skill to the team catalog; this machine has fetched it but not pulled yet. | |
| 228 | + git(demo, 'clone', '-q', remoteDir, teammateDir) | |
| 229 | + const [rnDescription, rnBody] = SKILLS['release-notes']! | |
| 230 | + await write(path.join(teammateDir, 'skills', 'release-notes', 'SKILL.md'), skill('release-notes', rnDescription, rnBody)) | |
| 231 | + git(teammateDir, 'add', '-A') | |
| 232 | + git(teammateDir, '-c', 'user.name=Alex Martin', '-c', 'user.email=alex@acme.dev', 'commit', '-q', '-m', 'Add release-notes skill') | |
| 233 | + git(teammateDir, 'push', '-q') | |
| 234 | + await api('POST', '/api/catalog/git/commit', { message: 'Tailwind: dark mode rule' }) | |
| 235 | + git(catalogDir, 'fetch', '-q', 'origin') | |
| 236 | + // From here on nothing talks to the remote, so it can show a realistic URL. | |
| 237 | + git(catalogDir, 'remote', 'set-url', 'origin', SHOWN_REMOTE) | |
| 238 | +} | |
| 239 | + | |
| 240 | +// --------------------------------------------------------------------------------------------------------------- | |
| 241 | +// Capture | |
| 242 | + | |
| 243 | +async function capture(): Promise<void> { | |
| 244 | + const { chromium } = await import('playwright') | |
| 245 | + const browser = await chromium.launch() | |
| 246 | + const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 2, colorScheme: 'light' }) | |
| 247 | + await context.addInitScript(() => { | |
| 248 | + localStorage.setItem('panoplie-onboarding-done', '1') | |
| 249 | + localStorage.setItem('panoplie-dashboard-start-hidden', '1') | |
| 250 | + }) | |
| 251 | + const page = await context.newPage() | |
| 252 | + const projects = await api<{ id: string; name: string }[]>('GET', '/api/projects') | |
| 253 | + const acme = projects.find((p) => p.name === 'acme-shop')! | |
| 254 | + | |
| 255 | + const settle = async (): Promise<void> => { | |
| 256 | + await page.waitForLoadState('networkidle') | |
| 257 | + await page.waitForTimeout(600) | |
| 258 | + } | |
| 259 | + const go = async (route: string): Promise<void> => { | |
| 260 | + await page.goto(base + route) | |
| 261 | + await settle() | |
| 262 | + } | |
| 263 | + const shot = async (name: string, height = 900): Promise<void> => { | |
| 264 | + await page.screenshot({ path: path.join(out, `${name}.png`), clip: { x: 0, y: 0, width: 1440, height } }) | |
| 265 | + console.log(` ${name}.png`) | |
| 266 | + } | |
| 267 | + | |
| 268 | + await go(`/?t=${TOKEN}`) | |
| 269 | + | |
| 270 | + await go(`/projects/${acme.id}`) | |
| 271 | + await shot('project') | |
| 272 | + | |
| 273 | + await page.getByRole('button', { name: /Review/ }).last().click() | |
| 274 | + await settle() | |
| 275 | + await page.getByRole('button', { name: /Compare/ }).first().click() | |
| 276 | + await page.waitForTimeout(400) | |
| 277 | + await shot('review') | |
| 278 | + | |
| 279 | + await go('/catalog') | |
| 280 | + await page.getByText('code-review', { exact: true }).first().click() | |
| 281 | + await settle() | |
| 282 | + await shot('catalog') | |
| 283 | + | |
| 284 | + await go('/presets') | |
| 285 | + await shot('presets', 560) | |
| 286 | + | |
| 287 | + await go('/home') | |
| 288 | + await shot('global') | |
| 289 | + | |
| 290 | + await go('/sync') | |
| 291 | + await shot('sync') | |
| 292 | + | |
| 293 | + await go('/marketplaces') | |
| 294 | + await page.waitForTimeout(3000) | |
| 295 | + await settle() | |
| 296 | + await shot('marketplaces') | |
| 297 | + | |
| 298 | + await browser.close() | |
| 299 | +} | |
| 300 | + | |
| 301 | +// --------------------------------------------------------------------------------------------------------------- | |
| 302 | + | |
| 303 | +async function main(): Promise<void> { | |
| 304 | + console.log(`Demo machine in ${demo}`) | |
| 305 | + await createMachine() | |
| 306 | + // The server, the scanners and git all read the home folder from the environment. | |
| 307 | + process.env.HOME = home | |
| 308 | + process.env.USERPROFILE = home | |
| 309 | + delete process.env.CODEX_HOME | |
| 310 | + for (const key of Object.keys(process.env)) if (key.startsWith('GIT_')) delete process.env[key] | |
| 311 | + | |
| 312 | + const { startServer } = await import('../packages/server/src/index.ts') | |
| 313 | + const server = await startServer({ | |
| 314 | + token: TOKEN, | |
| 315 | + port: 0, | |
| 316 | + configDir: path.join(home, '.panoplie'), | |
| 317 | + staticDir: path.join(repo, 'packages', 'ui', '.output', 'public'), | |
| 318 | + }) | |
| 319 | + base = server.url.replace(/\/$/, '') | |
| 320 | + try { | |
| 321 | + await seed() | |
| 322 | + console.log('Capturing:') | |
| 323 | + await capture() | |
| 324 | + } finally { | |
| 325 | + await server.close() | |
| 326 | + } | |
| 327 | +} | |
| 328 | + | |
| 329 | +main().catch((err: unknown) => { | |
| 330 | + console.error(err) | |
| 331 | + process.exit(1) | |
| 332 | +}) | |
| new file mode 100644 | |||
| @@ -0,0 +1,332 @@ | |||
| 1 | +// Regenerates media/screenshots: builds a throwaway demo machine (a fake home folder, three projects, a catalog with | ||
| 2 | +// a "team" remote and a teammate's commit), runs the real server against it and captures the UI with Playwright. | ||
| 3 | +// | ||
| 4 | +// pnpm build # the UI must be built first | ||
| 5 | +// pnpm screenshots [demoDir] # demoDir defaults to /demo (G:\demo on Windows); it appears in the screenshots | ||
| 6 | +// | ||
| 7 | +// Needs network access: the marketplace screenshot clones Anthropic's skills repository. | ||
| 8 | +import { execFileSync } from 'node:child_process' | ||
| 9 | +import { existsSync, readdirSync } from 'node:fs' | ||
| 10 | +import { mkdir, rm, writeFile } from 'node:fs/promises' | ||
| 11 | +import path from 'node:path' | ||
| 12 | +import { fileURLToPath } from 'node:url' | ||
| 13 | + | ||
| 14 | +const repo = fileURLToPath(new URL('..', import.meta.url)) | ||
| 15 | +const demo = path.resolve(process.argv[2] ?? process.env.PANOPLIE_DEMO_DIR ?? '/demo') | ||
| 16 | +const home = path.join(demo, 'home') | ||
| 17 | +const code = path.join(home, 'code') | ||
| 18 | +const remoteDir = path.join(demo, 'remote', 'agent-catalog.git') | ||
| 19 | +const teammateDir = path.join(demo, 'teammate') | ||
| 20 | +/** Shown on the Sync page instead of the local bare repository the demo really syncs with. */ | ||
| 21 | +const SHOWN_REMOTE = 'git@github.com:acme/agent-catalog.git' | ||
| 22 | +const out = path.join(repo, 'media', 'screenshots') | ||
| 23 | +const MARKER = '.panoplie-demo' | ||
| 24 | + | ||
| 25 | +// --------------------------------------------------------------------------------------------------------------- | ||
| 26 | +// Demo machine | ||
| 27 | + | ||
| 28 | +async function write(file: string, content: string): Promise<void> { | ||
| 29 | + await mkdir(path.dirname(file), { recursive: true }) | ||
| 30 | + await writeFile(file, content, 'utf8') | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +function git(cwd: string, ...args: string[]): string { | ||
| 34 | + return execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +const skill = (name: string, description: string, body: string): string => | ||
| 38 | + `---\nname: ${name}\ndescription: ${JSON.stringify(description)}\n---\n\n${body.trim()}\n` | ||
| 39 | + | ||
| 40 | +const SKILLS: Record<string, [string, string]> = { | ||
| 41 | + 'code-review': [ | ||
| 42 | + 'Review a diff for bugs, risky changes and missing tests before it is merged.', | ||
| 43 | + '# Code review\n\nRead the whole diff first, then comment file by file.\n\n- Flag behaviour changes that have no test.\n- Point out error paths that swallow failures.\n- Suggest, do not rewrite: keep comments short and actionable.', | ||
| 44 | + ], | ||
| 45 | + 'commit-convention': [ | ||
| 46 | + 'Write commit messages that follow Conventional Commits.', | ||
| 47 | + '# Commit convention\n\nFormat: `type(scope): subject`, in the imperative, under 72 characters.\n\nTypes: feat, fix, docs, refactor, test, chore, ci.', | ||
| 48 | + ], | ||
| 49 | + nuxt: [ | ||
| 50 | + 'Conventions for Nuxt 4 apps: folders, data fetching, server routes.', | ||
| 51 | + '# Nuxt\n\n- Pages in `app/pages`, server routes in `server/api`.\n- Fetch with `useFetch` in components, `$fetch` in handlers.\n- Never import server code from the client.', | ||
| 52 | + ], | ||
| 53 | + 'nuxt-content': [ | ||
| 54 | + 'Write and query content with Nuxt Content collections.', | ||
| 55 | + '# Nuxt Content\n\nDeclare every collection in `content.config.ts` with a schema, then query it with `queryCollection`.', | ||
| 56 | + ], | ||
| 57 | + tailwind: [ | ||
| 58 | + 'Style components with Tailwind CSS v4 and the design tokens of the project.', | ||
| 59 | + '# Tailwind\n\nUse the theme tokens, never raw hex values. Group classes: layout, box, type, color, state.', | ||
| 60 | + ], | ||
| 61 | + 'seo-audit': [ | ||
| 62 | + 'Audit a page for technical SEO: titles, meta, headings, links, structured data.', | ||
| 63 | + '# SEO audit\n\nCheck, in order: title and description length, one h1, canonical, internal links, JSON-LD.', | ||
| 64 | + ], | ||
| 65 | + 'seo-keywords': [ | ||
| 66 | + 'Find the keywords a page should target and where to place them.', | ||
| 67 | + '# SEO keywords\n\nStart from the search intent. Pick one main keyword and three related ones per page.', | ||
| 68 | + ], | ||
| 69 | + 'api-design': [ | ||
| 70 | + 'Design REST endpoints: naming, status codes, pagination, errors.', | ||
| 71 | + '# API design\n\nPlural nouns, no verbs in paths. Errors are `{ code, message }` with a 4xx or 5xx status.', | ||
| 72 | + ], | ||
| 73 | + 'release-notes': [ | ||
| 74 | + 'Turn merged pull requests into release notes users can read.', | ||
| 75 | + '# Release notes\n\nGroup by Added, Changed, Fixed. One line per change, written for users, not for developers.', | ||
| 76 | + ], | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +const RULES: Record<string, string> = { | ||
| 80 | + typescript: '---\ndescription: TypeScript conventions\n---\n\nStrict mode. No `any`. Prefer `type` imports and narrow with type guards.\n', | ||
| 81 | + writing: '---\ndescription: House style for articles\n---\n\nShort sentences. Active voice. One idea per paragraph.\n', | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +const AGENTS: Record<string, string> = { | ||
| 85 | + 'test-runner': | ||
| 86 | + '---\nname: test-runner\ndescription: Runs the test suite and fixes failing tests.\n---\n\nRun the tests, read the failures, fix the code (not the tests) and run them again.\n', | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +const MCPS: Record<string, string> = { | ||
| 90 | + 'nuxt-docs': 'name: nuxt-docs\ndescription: Nuxt documentation\ntransport: http\nurl: https://mcp.nuxt.com/\n', | ||
| 91 | + github: 'name: github\ndescription: GitHub issues and pull requests\ntransport: stdio\ncommand: npx\nargs: [-y, "@modelcontextprotocol/server-github"]\nenv:\n GITHUB_TOKEN: { fromEnv: GITHUB_TOKEN }\n', | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +const HOOKS: Record<string, string> = { | ||
| 95 | + format: 'name: format\ndescription: Format edited files\nevent: PostToolUse\nmatcher: Edit|Write\nhandler:\n type: command\n command: npx prettier --write "$CLAUDE_FILE_PATHS"\n', | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +const PRESETS = { | ||
| 99 | + base: { description: 'What every project gets', items: { skill: ['code-review', 'commit-convention'], rule: ['typescript'] } }, | ||
| 100 | + 'nuxt-saas': { | ||
| 101 | + description: 'Nuxt apps', | ||
| 102 | + includes: ['base'], | ||
| 103 | + items: { skill: ['nuxt', 'nuxt-content', 'tailwind'], mcp: ['nuxt-docs'], hook: ['format'] }, | ||
| 104 | + }, | ||
| 105 | + seo: { description: 'Pages that need to rank', items: { skill: ['seo-audit', 'seo-keywords'] } }, | ||
| 106 | +} | ||
| 107 | + | ||
| 108 | +async function createMachine(): Promise<void> { | ||
| 109 | + if (existsSync(demo) && readdirSync(demo).length && !existsSync(path.join(demo, MARKER))) { | ||
| 110 | + throw new Error(`${demo} exists and is not a panoplie demo folder; pick another one`) | ||
| 111 | + } | ||
| 112 | + await rm(demo, { recursive: true, force: true }) | ||
| 113 | + await write(path.join(demo, MARKER), 'Created by scripts/screenshots.ts. Safe to delete.\n') | ||
| 114 | + await write( | ||
| 115 | + path.join(home, '.gitconfig'), | ||
| 116 | + '[user]\n\tname = Sam Rivera\n\temail = sam@acme.dev\n[init]\n\tdefaultBranch = main\n[core]\n\tautocrlf = false\n[commit]\n\tgpgsign = false\n' | ||
| 117 | + ) | ||
| 118 | + | ||
| 119 | + // Global (~/.claude): what had piled up before panoplie. | ||
| 120 | + await write(path.join(home, '.claude', 'CLAUDE.md'), '# Global instructions\n\nAnswer briefly. Ask before deleting files.\n') | ||
| 121 | + for (const name of ['nuxt', 'seo-audit', 'seo-keywords', 'tailwind']) { | ||
| 122 | + const [description, body] = SKILLS[name]! | ||
| 123 | + await write(path.join(home, '.claude', 'skills', name, 'SKILL.md'), skill(name, description, body)) | ||
| 124 | + } | ||
| 125 | + await write( | ||
| 126 | + path.join(home, '.claude', 'skills', 'pdf', 'SKILL.md'), | ||
| 127 | + skill('pdf', 'Read, fill and merge PDF files.', '# PDF\n\nUse `pdftotext` to read, `qpdf` to merge.') | ||
| 128 | + ) | ||
| 129 | + await write( | ||
| 130 | + path.join(home, '.claude', 'skills', 'brainstorm', 'SKILL.md'), | ||
| 131 | + skill('brainstorm', 'Generate and rank ideas before writing any code.', '# Brainstorm\n\nTen ideas, then keep three.') | ||
| 132 | + ) | ||
| 133 | + | ||
| 134 | + // Projects. | ||
| 135 | + await write(path.join(code, 'acme-shop', 'package.json'), '{ "name": "acme-shop", "private": true }\n') | ||
| 136 | + await write(path.join(code, 'acme-shop', 'CLAUDE.md'), '# acme-shop\n\nNuxt 4 storefront.\n') | ||
| 137 | + await write(path.join(code, 'billing-api', 'package.json'), '{ "name": "billing-api", "private": true }\n') | ||
| 138 | + await write(path.join(code, 'billing-api', 'AGENTS.md'), '# billing-api\n\nInvoicing service.\n') | ||
| 139 | + await write(path.join(code, 'blog', 'package.json'), '{ "name": "blog", "private": true }\n') | ||
| 140 | + for (const p of ['acme-shop', 'billing-api', 'blog']) git(path.join(code, p), 'init', '-q') | ||
| 141 | + // Codex only reads the .codex/ folder of projects it trusts. | ||
| 142 | + await write( | ||
| 143 | + path.join(home, '.codex', 'config.toml'), | ||
| 144 | + ['acme-shop', 'billing-api'].map((p) => `[projects.${JSON.stringify(path.join(code, p))}]\ntrust_level = "trusted"\n`).join('\n') | ||
| 145 | + ) | ||
| 146 | + | ||
| 147 | + // The team remote. | ||
| 148 | + await mkdir(path.dirname(remoteDir), { recursive: true }) | ||
| 149 | + git(demo, 'init', '-q', '--bare', '-b', 'main', remoteDir) | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +// --------------------------------------------------------------------------------------------------------------- | ||
| 153 | +// Server | ||
| 154 | + | ||
| 155 | +const TOKEN = 'demo' | ||
| 156 | +let base = '' | ||
| 157 | + | ||
| 158 | +async function api<T = unknown>(method: string, url: string, body?: unknown): Promise<T> { | ||
| 159 | + const res = await fetch(base + url, { | ||
| 160 | + method, | ||
| 161 | + headers: { 'x-panoplie-token': TOKEN, ...(body === undefined ? {} : { 'content-type': 'application/json' }) }, | ||
| 162 | + body: body === undefined ? undefined : JSON.stringify(body), | ||
| 163 | + }) | ||
| 164 | + if (!res.ok) throw new Error(`${method} ${url}: ${res.status} ${await res.text()}`) | ||
| 165 | + return (res.status === 204 ? undefined : await res.json()) as T | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +async function seed(): Promise<void> { | ||
| 169 | + const settings = await api<{ catalogPath: string }>('GET', '/api/settings') | ||
| 170 | + const catalogDir = settings.catalogPath | ||
| 171 | + await api('POST', '/api/catalog/init') | ||
| 172 | + git(catalogDir, 'checkout', '-q', '-B', 'main') | ||
| 173 | + await api('POST', '/api/catalog/git/remote', { url: remoteDir }) | ||
| 174 | + | ||
| 175 | + const tags: Record<string, string[]> = { nuxt: ['nuxt'], 'nuxt-content': ['nuxt'], tailwind: ['css'], 'seo-audit': ['seo'], 'seo-keywords': ['seo'] } | ||
| 176 | + for (const [name, [description, body]] of Object.entries(SKILLS)) { | ||
| 177 | + if (name === 'release-notes') continue // pushed later by the teammate | ||
| 178 | + await api('PUT', `/api/catalog/items/skill/${name}`, { content: skill(name, description, body), tags: tags[name] }) | ||
| 179 | + } | ||
| 180 | + for (const [name, content] of Object.entries(RULES)) await api('PUT', `/api/catalog/items/rule/${name}`, { content }) | ||
| 181 | + for (const [name, content] of Object.entries(AGENTS)) await api('PUT', `/api/catalog/items/agent/${name}`, { content }) | ||
| 182 | + for (const [name, content] of Object.entries(MCPS)) await api('PUT', `/api/catalog/items/mcp/${name}`, { content }) | ||
| 183 | + for (const [name, content] of Object.entries(HOOKS)) await api('PUT', `/api/catalog/items/hook/${name}`, { content }) | ||
| 184 | + for (const [name, preset] of Object.entries(PRESETS)) await api('PUT', `/api/catalog/presets/${name}`, preset) | ||
| 185 | + await api('POST', '/api/catalog/git/commit', { message: 'Add the team catalog' }) | ||
| 186 | + await api('POST', '/api/catalog/git/sync') | ||
| 187 | + | ||
| 188 | + // Projects and what each one uses. | ||
| 189 | + const config = (targets: string[], presets: string[], extra: Partial<Record<string, unknown>> = {}) => ({ | ||
| 190 | + version: 1, | ||
| 191 | + targets, | ||
| 192 | + presets, | ||
| 193 | + add: {}, | ||
| 194 | + exclude: {}, | ||
| 195 | + onDemand: { skills: [] }, | ||
| 196 | + hideGlobal: { skills: [], mcp: [] }, | ||
| 197 | + ...extra, | ||
| 198 | + }) | ||
| 199 | + const ids: Record<string, string> = {} | ||
| 200 | + for (const p of ['acme-shop', 'billing-api', 'blog']) { | ||
| 201 | + ids[p] = (await api<{ id: string }>('POST', '/api/projects', { path: path.join(code, p) })).id | ||
| 202 | + } | ||
| 203 | + const configs: Record<string, ReturnType<typeof config>> = { | ||
| 204 | + 'acme-shop': config(['claude', 'codex'], ['nuxt-saas', 'seo'], { onDemand: { skills: ['seo-*'] }, add: { agent: ['test-runner'] } }), | ||
| 205 | + 'billing-api': config(['codex'], ['base'], { add: { skill: ['api-design'], mcp: ['github'] } }), | ||
| 206 | + blog: config(['claude'], ['seo'], { add: { rule: ['writing'] }, hideGlobal: { skills: ['pdf'], mcp: [] } }), | ||
| 207 | + } | ||
| 208 | + for (const [p, c] of Object.entries(configs)) { | ||
| 209 | + await api('PUT', `/api/scopes/${ids[p]}/config`, c) | ||
| 210 | + await api('POST', `/api/scopes/${ids[p]}/apply`, { resolutions: {} }) | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + // Drift: someone tweaked a skill straight in acme-shop. | ||
| 214 | + const drifted = path.join(code, 'acme-shop', '.claude', 'skills', 'code-review', 'SKILL.md') | ||
| 215 | + const [crDescription, crBody] = SKILLS['code-review']! | ||
| 216 | + await write( | ||
| 217 | + drifted, | ||
| 218 | + skill('code-review', crDescription, crBody + '\n- Check that every new page has a loading and an error state.') | ||
| 219 | + ) | ||
| 220 | + // And the catalog moved on since acme-shop was last applied: tailwind has a new rule. | ||
| 221 | + const [twDescription, twBody] = SKILLS.tailwind! | ||
| 222 | + await api('PUT', '/api/catalog/items/skill/tailwind', { | ||
| 223 | + content: skill('tailwind', twDescription, twBody + '\n\nDark mode with the `dark:` variant only.'), | ||
| 224 | + tags: ['css'], | ||
| 225 | + }) | ||
| 226 | + | ||
| 227 | + // A teammate pushes a new skill to the team catalog; this machine has fetched it but not pulled yet. | ||
| 228 | + git(demo, 'clone', '-q', remoteDir, teammateDir) | ||
| 229 | + const [rnDescription, rnBody] = SKILLS['release-notes']! | ||
| 230 | + await write(path.join(teammateDir, 'skills', 'release-notes', 'SKILL.md'), skill('release-notes', rnDescription, rnBody)) | ||
| 231 | + git(teammateDir, 'add', '-A') | ||
| 232 | + git(teammateDir, '-c', 'user.name=Alex Martin', '-c', 'user.email=alex@acme.dev', 'commit', '-q', '-m', 'Add release-notes skill') | ||
| 233 | + git(teammateDir, 'push', '-q') | ||
| 234 | + await api('POST', '/api/catalog/git/commit', { message: 'Tailwind: dark mode rule' }) | ||
| 235 | + git(catalogDir, 'fetch', '-q', 'origin') | ||
| 236 | + // From here on nothing talks to the remote, so it can show a realistic URL. | ||
| 237 | + git(catalogDir, 'remote', 'set-url', 'origin', SHOWN_REMOTE) | ||
| 238 | +} | ||
| 239 | + | ||
| 240 | +// --------------------------------------------------------------------------------------------------------------- | ||
| 241 | +// Capture | ||
| 242 | + | ||
| 243 | +async function capture(): Promise<void> { | ||
| 244 | + const { chromium } = await import('playwright') | ||
| 245 | + const browser = await chromium.launch() | ||
| 246 | + const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 2, colorScheme: 'light' }) | ||
| 247 | + await context.addInitScript(() => { | ||
| 248 | + localStorage.setItem('panoplie-onboarding-done', '1') | ||
| 249 | + localStorage.setItem('panoplie-dashboard-start-hidden', '1') | ||
| 250 | + }) | ||
| 251 | + const page = await context.newPage() | ||
| 252 | + const projects = await api<{ id: string; name: string }[]>('GET', '/api/projects') | ||
| 253 | + const acme = projects.find((p) => p.name === 'acme-shop')! | ||
| 254 | + | ||
| 255 | + const settle = async (): Promise<void> => { | ||
| 256 | + await page.waitForLoadState('networkidle') | ||
| 257 | + await page.waitForTimeout(600) | ||
| 258 | + } | ||
| 259 | + const go = async (route: string): Promise<void> => { | ||
| 260 | + await page.goto(base + route) | ||
| 261 | + await settle() | ||
| 262 | + } | ||
| 263 | + const shot = async (name: string, height = 900): Promise<void> => { | ||
| 264 | + await page.screenshot({ path: path.join(out, `${name}.png`), clip: { x: 0, y: 0, width: 1440, height } }) | ||
| 265 | + console.log(` ${name}.png`) | ||
| 266 | + } | ||
| 267 | + | ||
| 268 | + await go(`/?t=${TOKEN}`) | ||
| 269 | + | ||
| 270 | + await go(`/projects/${acme.id}`) | ||
| 271 | + await shot('project') | ||
| 272 | + | ||
| 273 | + await page.getByRole('button', { name: /Review/ }).last().click() | ||
| 274 | + await settle() | ||
| 275 | + await page.getByRole('button', { name: /Compare/ }).first().click() | ||
| 276 | + await page.waitForTimeout(400) | ||
| 277 | + await shot('review') | ||
| 278 | + | ||
| 279 | + await go('/catalog') | ||
| 280 | + await page.getByText('code-review', { exact: true }).first().click() | ||
| 281 | + await settle() | ||
| 282 | + await shot('catalog') | ||
| 283 | + | ||
| 284 | + await go('/presets') | ||
| 285 | + await shot('presets', 560) | ||
| 286 | + | ||
| 287 | + await go('/home') | ||
| 288 | + await shot('global') | ||
| 289 | + | ||
| 290 | + await go('/sync') | ||
| 291 | + await shot('sync') | ||
| 292 | + | ||
| 293 | + await go('/marketplaces') | ||
| 294 | + await page.waitForTimeout(3000) | ||
| 295 | + await settle() | ||
| 296 | + await shot('marketplaces') | ||
| 297 | + | ||
| 298 | + await browser.close() | ||
| 299 | +} | ||
| 300 | + | ||
| 301 | +// --------------------------------------------------------------------------------------------------------------- | ||
| 302 | + | ||
| 303 | +async function main(): Promise<void> { | ||
| 304 | + console.log(`Demo machine in ${demo}`) | ||
| 305 | + await createMachine() | ||
| 306 | + // The server, the scanners and git all read the home folder from the environment. | ||
| 307 | + process.env.HOME = home | ||
| 308 | + process.env.USERPROFILE = home | ||
| 309 | + delete process.env.CODEX_HOME | ||
| 310 | + for (const key of Object.keys(process.env)) if (key.startsWith('GIT_')) delete process.env[key] | ||
| 311 | + | ||
| 312 | + const { startServer } = await import('../packages/server/src/index.ts') | ||
| 313 | + const server = await startServer({ | ||
| 314 | + token: TOKEN, | ||
| 315 | + port: 0, | ||
| 316 | + configDir: path.join(home, '.panoplie'), | ||
| 317 | + staticDir: path.join(repo, 'packages', 'ui', '.output', 'public'), | ||
| 318 | + }) | ||
| 319 | + base = server.url.replace(/\/$/, '') | ||
| 320 | + try { | ||
| 321 | + await seed() | ||
| 322 | + console.log('Capturing:') | ||
| 323 | + await capture() | ||
| 324 | + } finally { | ||
| 325 | + await server.close() | ||
| 326 | + } | ||
| 327 | +} | ||
| 328 | + | ||
| 329 | +main().catch((err: unknown) => { | ||
| 330 | + console.error(err) | ||
| 331 | + process.exit(1) | ||
| 332 | +}) | ||