@primer/brand-mcp 0.73.0 → 0.74.0-rc.101f122b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +3 -1
  2. package/content/page-design.md +16 -5
  3. package/dist/brand/detect-asset-generator/detect-asset-generator.js.map +1 -0
  4. package/dist/brand/detect-framework/detect-framework.js.map +1 -0
  5. package/dist/brand/{docs-source.d.ts → docs-source/docs-source.d.ts} +2 -2
  6. package/dist/brand/docs-source/docs-source.js.map +1 -0
  7. package/dist/brand/{resolve-assets.d.ts → resolve-assets/resolve-assets.d.ts} +1 -1
  8. package/dist/brand/resolve-assets/resolve-assets.js.map +1 -0
  9. package/dist/brand/resolve-brand-project/resolve-brand-project.d.ts +7 -0
  10. package/dist/brand/resolve-brand-project/resolve-brand-project.js +78 -0
  11. package/dist/brand/resolve-brand-project/resolve-brand-project.js.map +1 -0
  12. package/dist/brand/resolve-install/resolve-install.js.map +1 -0
  13. package/dist/brand/update-agents-md/update-agents-md.d.ts +7 -0
  14. package/dist/brand/update-agents-md/update-agents-md.js +74 -0
  15. package/dist/brand/update-agents-md/update-agents-md.js.map +1 -0
  16. package/dist/catalog.json +106 -11
  17. package/dist/review/rules.js +21 -0
  18. package/dist/review/rules.js.map +1 -1
  19. package/dist/server.js +17 -5
  20. package/dist/server.js.map +1 -1
  21. package/dist/tools/primer-brand-asset/primer-brand-asset.js +3 -1
  22. package/dist/tools/primer-brand-asset/primer-brand-asset.js.map +1 -1
  23. package/dist/tools/primer-brand-component/primer-brand-component.js +7 -1
  24. package/dist/tools/primer-brand-component/primer-brand-component.js.map +1 -1
  25. package/dist/tools/primer-brand-docs/primer-brand-docs.js +4 -1
  26. package/dist/tools/primer-brand-docs/primer-brand-docs.js.map +1 -1
  27. package/dist/tools/primer-brand-examples/primer-brand-examples.js +7 -5
  28. package/dist/tools/primer-brand-examples/primer-brand-examples.js.map +1 -1
  29. package/dist/tools/primer-brand-page-design/primer-brand-page-design.js +4 -1
  30. package/dist/tools/primer-brand-page-design/primer-brand-page-design.js.map +1 -1
  31. package/dist/tools/primer-brand-review/primer-brand-review.js +8 -6
  32. package/dist/tools/primer-brand-review/primer-brand-review.js.map +1 -1
  33. package/dist/tools/primer-brand-setup/primer-brand-setup.d.ts +3 -0
  34. package/dist/tools/primer-brand-setup/primer-brand-setup.js +66 -6
  35. package/dist/tools/primer-brand-setup/primer-brand-setup.js.map +1 -1
  36. package/dist/tools/primer-brand-tokens/primer-brand-tokens.js +2 -1
  37. package/dist/tools/primer-brand-tokens/primer-brand-tokens.js.map +1 -1
  38. package/dist/tools/types.d.ts +15 -2
  39. package/package.json +1 -1
  40. package/dist/brand/detect-asset-generator.js.map +0 -1
  41. package/dist/brand/detect-framework.js.map +0 -1
  42. package/dist/brand/docs-source.js.map +0 -1
  43. package/dist/brand/resolve-assets.js.map +0 -1
  44. package/dist/brand/resolve-install.js.map +0 -1
  45. /package/dist/brand/{detect-asset-generator.d.ts → detect-asset-generator/detect-asset-generator.d.ts} +0 -0
  46. /package/dist/brand/{detect-asset-generator.js → detect-asset-generator/detect-asset-generator.js} +0 -0
  47. /package/dist/brand/{detect-framework.d.ts → detect-framework/detect-framework.d.ts} +0 -0
  48. /package/dist/brand/{detect-framework.js → detect-framework/detect-framework.js} +0 -0
  49. /package/dist/brand/{docs-source.js → docs-source/docs-source.js} +0 -0
  50. /package/dist/brand/{resolve-assets.js → resolve-assets/resolve-assets.js} +0 -0
  51. /package/dist/brand/{resolve-install.d.ts → resolve-install/resolve-install.d.ts} +0 -0
  52. /package/dist/brand/{resolve-install.js → resolve-install/resolve-install.js} +0 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@ It is a version-aware, `stdio` (local) server which reads the docs and metadata
8
8
 
9
9
  | Tool | What it does |
10
10
  | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
11
- | `primer_brand_setup` | Configures Primer Brand first-time. Includes `ThemeProvider`, Mona Sans and RSC-directive configuration among other things |
11
+ | `primer_brand_setup` | Configures Primer Brand first-time and maintains a Primer Brand pointer beside the declaring `package.json`. |
12
12
  | `primer_brand_page_design` | Page-design conventions (header/footer, hero media, gridline aesthetic, card grids, labels) and the current-brand reference templates to start from. |
13
13
  | `primer_brand_component` | Get a component API information like props, allowed values and named sub-components. |
14
14
  | `primer_brand_examples` | Reference examples taken from our Storybook. |
@@ -35,6 +35,8 @@ Requires Node.js >= 24.
35
35
  }
36
36
  ```
37
37
 
38
+ When an agent calls `primer_brand_setup`, the tool updates `AGENTS.md` only in a package whose `package.json` declares `@primer/react-brand`. Existing instructions are preserved. If several workspace packages declare the dependency, call setup with `projectDir` set to the intended workspace-relative package folder. The pointer routes future agents to the MCP tools and version-matched docs bundled with the installed package.
39
+
38
40
  ### Copilot CLI / other stdio clients
39
41
 
40
42
  Run the server with `npx @primer/brand-mcp@latest`.
@@ -19,7 +19,9 @@ Pull adaptable component snippets with `primer_brand_examples`.
19
19
  `@primer/react-brand` spans multiple generations of GitHub's design language, and many components expose that choice as a variant or prop. **Gridline** is the current brand direction. It's a connected, ruled-line aesthetic, as seen throughout the Flexsuite templates. Bias toward it.
20
20
 
21
21
  - **Do** — when a component offers a gridline-family option, choose it over the older or default look. "Expressive" gridline options are a more pronounced sub-variant of the same aesthetic, not a competing style; reach for them where a section wants extra emphasis.
22
+ - **Do** — use a component's built-in `gridline` variant, gridline-family variant, or `hasGridLines` prop when available.
22
23
  - **Don't** — settle for a component's plainest or legacy variant, or borrow section layouts from an older brand generation, when a gridline equivalent exists.
24
+ - **Don't** — recreate built-in gridlines with custom `Box` wrappers, border props, or CSS.
23
25
 
24
26
  The gridline look is crucial and literal, not just a set of variants. Gridlines are thin ruled lines that frame the content column and separate sections (see "Contain content within the grid" section below).
25
27
 
@@ -36,17 +38,22 @@ Every full page should be framed top and bottom, unless the user has requested a
36
38
 
37
39
  ### Contain content within the grid
38
40
 
39
- Body content must sit in one centered, max-width grid framed by the brand's gridlines — it should rarely stretch edge-to-edge. Treat gridlines as one continuous page structure: every line endpoint must reach the viewport or shared page-grid boundary, or intersect another gridline. Never let a border stop in empty space.
41
+ Body content must sit in one centered, max-width grid framed by the brand's gridlines — it should rarely stretch edge-to-edge. Treat gridlines as one continuous page structure. A gridline group must not look like an isolated four-sided box floating inside the page gutters.
40
42
 
41
43
  Examples of this are in the Flexsuite recipes.
42
44
 
43
45
  - **Do** — keep heroes, `River`s, `ComparisonTable` / `PricingOptions`, connected Card or Pillar groups, forms, `CTABanner`s, and prose on the same `Grid` / `Section` column. Draw thin side rules on the column and full-bleed horizontal rules between major sections.
44
- - **Do** — for connected panels, put block rules on the outer frame, outer inline rules on the centered content container, and internal dividers on zero-gap cell wrappers. Preserve these intersections when max-width or column count changes at responsive breakpoints.
45
- - **Do** — give a panel frame's block-start and block-end rules the same extent. They may differ only when one rule is also a page-wide section boundary that intersects the frame's inline rules.
46
+ - **Do** — for connected `Card` and `Pillar` groups, put block-start and block-end rules on a page-width outer frame outside the centered, max-width `Grid` / `Section`. Put outer inline rules on the centered content container and internal dividers on zero-gap cell wrappers.
47
+ - **Do** — for these custom group frames, make every horizontal rule reach both viewport edges. It may instead end at vertical page-grid rules only when those rules continue beyond the group into adjacent sections.
48
+ - **Do** — preserve rule intersections when the max-width or column count changes at responsive breakpoints.
46
49
 
50
+ - **Don't** — put all four outer borders for a `Card` or `Pillar` group on a centered, max-width container. This creates a disconnected box with empty margins around it.
51
+ - **Don't** — assume `width: 100%` makes a custom group frame full bleed when it is inside a constrained parent. The outer frame must sit outside that parent or use the page's established full-bleed breakout.
47
52
  - **Don't** — give sections different widths, add gaps between borders that should connect, or put borders on inset wrappers where their endpoints stop in empty space.
48
53
  - **Don't** — stretch content edge-to-edge or let a section bleed full-width unless it is a deliberate background band behind the shared grid.
49
54
 
55
+ Retrieve the canonical grouped `Card` or `Pillar` structure with `primer_brand_examples` and carry its companion CSS with the JSX. Do not reproduce that structure from this prose.
56
+
50
57
  - **Mobile** — use a modest, consistent side inset and make sure nothing overflows the viewport.
51
58
 
52
59
  Resolve gutter, inset, and gridline (border) values with `primer_brand_tokens`; don't hardcode hex or pixel values.
@@ -63,7 +70,10 @@ Generous spacing is what lets a layout breathe; the Flexsuite recipes are a good
63
70
 
64
71
  A page has one clear headline and a calm step-down from there.
65
72
 
73
+ - **Do** — use the default `size` of component-owned text such as `Card.Heading`, `Hero.Heading`, and `FAQ.Heading`. Set `size` on standalone `Heading` and `Text`.
66
74
  - **Do** — use a single hero heading, make secondary section headings a clear step smaller, and keep body copy regular weight. Left-align long-form copy; reserve centering for short hero or section intros.
75
+ - **Do** — use `InlineCode` for short code fragments and code blocks for multiline examples. Keep the default wrapping behavior unless rendering a slash command that must stay together, then use `wrap={false}`.
76
+ - **Don't** — pass `size` to a component-owned heading, description, label, or other text unless the brief requires an override. Changing `as` for semantic heading order does not require changing `size`.
67
77
  - **Don't** — size secondary headings close to the hero, set body text in heavy weights, or center long paragraphs.
68
78
 
69
79
  Resolve exact sizes and weights with `primer_brand_tokens`.
@@ -126,14 +136,15 @@ Resolve exact sizes and weights with `primer_brand_tokens`.
126
136
 
127
137
  **Do**
128
138
 
129
- - Default to placing `Card`, `Pillar`, `Box`, or custom items in a square frame using `<Grid columnGap="none" rowGap="none" enableGutters={false}>`.
139
+ - Default to placing connected `Card` or `Pillar` groups in a page-width outer frame around a centered zero-gap `Grid`. Retrieve the current structure and companion CSS with `primer_brand_examples`.
130
140
  - When Card images need to stretch to fill the Card width, set `padding="none"` on every `Card.Image` and `hasBorder` on every `Card` to provide visual containment. Place these full-bleed Cards in a regular `Grid` with a clear gap between them; this is a separate visual treatment from gridline Cards. Keep image position and aspect ratio consistent across the group, and retrieve Card examples with `primer_brand_examples` for reference.
131
141
  - Draw shared dividers on custom frame/cell wrappers and use `border-radius: 0` there.
132
142
 
133
143
  **Don't**
134
144
 
135
145
  - Put native-bordered, full-bleed Cards inside a shared gridline frame, or mix gridline and native-border treatments within one group.
136
- - Render other repeated panels as separate rounded cards, double their shared borders, or override `Card` / `Pillar` internals.
146
+ - Apply the custom Card/Pillar frame pattern to components that already provide a gridline variant or prop.
147
+ - Box a repeated panel group inside the centered content width, render panels as separate rounded cards, double their shared borders, or override `Card` / `Pillar` internals.
137
148
  - `Pillar` has no grid variant; don't invent one.
138
149
 
139
150
  ### CTABanner
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-asset-generator.js","sourceRoot":"","sources":["../../../src/brand/detect-asset-generator/detect-asset-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAA;AAClC,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AAEzC,MAAM,QAAQ,GAAG,qBAAqB,CAAA;AAEtC;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAyB,OAAO,CAAC,GAAG;IAGvE,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,CAAA;IAC5C,IAAI,CAAC,SAAS;QAAE,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,CAAA;IAEzC,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACxE,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAA;IAE7G,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,SAAS;YAAE,SAAQ;QACxB,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;YAA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.js';
2
- import type { BrandInstall } from './resolve-install.js';
1
+ import type { Logger } from '../../logger.js';
2
+ import type { BrandInstall } from '../resolve-install/resolve-install.js';
3
3
  /**
4
4
  * One entry in the documentation table of contents (parsed from `llms.txt`).
5
5
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-source.js","sourceRoot":"","sources":["../../../src/brand/docs-source/docs-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AAuBhE,MAAM,OAAO,GAAG,4BAA4B,CAAA;AAa5C,MAAM,UAAU,gBAAgB,CAAC,KAAmB,EAAE,MAAc;IAClE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAA;IAEvC,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAE9D;;OAEG;IACH,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,IAAY,EAAiB,EAAE;QAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,GAAG,EAAE,CAAA;QACtE,IAAI,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,M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E,OAAO,EAAE,IAAI,EAAC,CAAA;QAC5D,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO;QACL,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM;QAC3C,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK;QACL,IAAI;KACL,CAAA;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CatalogAsset } from '../catalog/types.js';
1
+ import type { CatalogAsset } from '../../catalog/types.js';
2
2
  export type InstalledAssets = {
3
3
  assets: CatalogAsset[];
4
4
  sources: Array<{
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-assets.js","sourceRoot":"","sources":["../../../src/brand/resolve-assets/resolve-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AASvC,MAAM,YAAY,GAAmB;IACnC,EAAC,MAAM,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,EAAC;IAChD,EAAC,MAAM,EAAE,2BAA2B,EAAE,IAAI,EAAE,cAAc,EAAC;CAC5D,CAAA;AAOD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAkB,OAAO,CAAC,GAAG,EAAE;IACpE,qEAAqE;IACrE,MAAM,cAAc,GAAG,CAAC,WAAmB,EAAiB,EAAE;QAC5D,IAAI,GAAG,GAAG,OAAO,CAAA;QACjB,SAAS,CAAC;YACR,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;YACtE,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;gBAAE,OAAO,SAAS,CAAA;YACjE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAA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C,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;QACzC,IAAI,CAAC,UAAU;YAAE,SAAQ;QACzB,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;QAC5E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,SAAQ;QAChC,OAAO,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC,EAAC,CAAC,CAAA;QACxD,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type BrandProjectResolution = {
2
+ projectDir: string | null;
3
+ candidates: string[];
4
+ reason?: 'no-workspace-root' | 'brand-package-not-found' | 'ambiguous-brand-project' | 'invalid-brand-project';
5
+ };
6
+ /** Resolve the package folder whose package.json directly declares @primer/react-brand. */
7
+ export declare function resolveBrandProject(workspaceDir: string | null, requestedProjectDir?: string): BrandProjectResolution;
@@ -0,0 +1,78 @@
1
+ import { readdirSync, readFileSync, realpathSync } from 'node:fs';
2
+ import { isAbsolute, join, relative, resolve, sep } from 'node:path';
3
+ /** Resolve the package folder whose package.json directly declares @primer/react-brand. */
4
+ export function resolveBrandProject(workspaceDir, requestedProjectDir) {
5
+ const dependencyName = '@primer/react-brand';
6
+ const ignoredDirectories = new Set([
7
+ '.git',
8
+ '.next',
9
+ 'build',
10
+ 'coverage',
11
+ 'dist',
12
+ 'node_modules',
13
+ 'out',
14
+ 'storybook-static',
15
+ ]);
16
+ const declaresBrand = (directory) => {
17
+ try {
18
+ const manifest = JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8'));
19
+ return ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'].some(group => Boolean(manifest[group]?.[dependencyName]));
20
+ }
21
+ catch {
22
+ return false;
23
+ }
24
+ };
25
+ if (!workspaceDir)
26
+ return { projectDir: null, candidates: [], reason: 'no-workspace-root' };
27
+ let canonicalWorkspaceDir;
28
+ try {
29
+ canonicalWorkspaceDir = realpathSync(workspaceDir);
30
+ }
31
+ catch {
32
+ return { projectDir: null, candidates: [], reason: 'no-workspace-root' };
33
+ }
34
+ const isWithinWorkspace = (candidate) => {
35
+ const relativeCandidate = relative(canonicalWorkspaceDir, candidate);
36
+ return relativeCandidate !== '..' && !relativeCandidate.startsWith(`..${sep}`) && !isAbsolute(relativeCandidate);
37
+ };
38
+ if (requestedProjectDir) {
39
+ if (isAbsolute(requestedProjectDir)) {
40
+ return { projectDir: null, candidates: [], reason: 'invalid-brand-project' };
41
+ }
42
+ let canonicalCandidate;
43
+ try {
44
+ canonicalCandidate = realpathSync(resolve(canonicalWorkspaceDir, requestedProjectDir));
45
+ }
46
+ catch {
47
+ return { projectDir: null, candidates: [], reason: 'invalid-brand-project' };
48
+ }
49
+ return isWithinWorkspace(canonicalCandidate) && declaresBrand(canonicalCandidate)
50
+ ? { projectDir: canonicalCandidate, candidates: [canonicalCandidate] }
51
+ : { projectDir: null, candidates: [], reason: 'invalid-brand-project' };
52
+ }
53
+ const candidates = [];
54
+ const visit = (directory) => {
55
+ if (declaresBrand(directory))
56
+ candidates.push(directory);
57
+ let entries;
58
+ try {
59
+ entries = readdirSync(directory, { withFileTypes: true });
60
+ }
61
+ catch {
62
+ return;
63
+ }
64
+ for (const entry of entries) {
65
+ if (!entry.isDirectory() || ignoredDirectories.has(entry.name))
66
+ continue;
67
+ visit(join(directory, entry.name));
68
+ }
69
+ };
70
+ visit(canonicalWorkspaceDir);
71
+ candidates.sort();
72
+ if (candidates.length === 1)
73
+ return { projectDir: candidates[0] ?? null, candidates };
74
+ if (candidates.length > 1)
75
+ return { projectDir: null, candidates, reason: 'ambiguous-brand-project' };
76
+ return { projectDir: null, candidates, reason: 'brand-package-not-found' };
77
+ }
78
+ //# sourceMappingURL=resolve-brand-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-brand-project.js","sourceRoot":"","sources":["../../../src/brand/resolve-brand-project/resolve-brand-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AAQlE,2FAA2F;AAC3F,MAAM,UAAU,mBAAmB,CAAC,YAA2B,EAAE,mBAA4B;IAC3F,MAAM,cAAc,GAAG,qBAAqB,CAAA;IAC5C,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;QACjC,MAAM;QACN,OAAO;QACP,OAAO;QACP,UAAU;QACV,MAAM;QACN,cAAc;QACd,KAAK;QACL,kBAAkB;KACnB,CAAC,CAAA;IAEF,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAW,EAAE;QACnD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAGhF,CAAA;YACD,OAAO,CAAC,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAClG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAC3C,CAAA;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC,CAAA;IAED,IAAI,CAAC,YAAY;QAAE,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EA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,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;aACjD,CAAA;QACH,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,QAAQ,CAAA;QACnC,GAAG,GAAG,MAAM,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAkB,OAAO,CAAC,GAAG,EAAE;IACrE,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IACpD,IAAI,GAAG,GAAG,OAAO,CAAA;IACjB,SAAS,CAAC;QACR,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;YAAE,OAAO,IAAI,CAAA;QAC1F,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,KAAK,CAAA;QAChC,GAAG,GAAG,MAAM,CAAA;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type AgentsMdUpdateResult = {
2
+ action: 'created' | 'updated' | 'unchanged' | 'skipped';
3
+ path: string | null;
4
+ reason?: 'no-project-root' | 'incorrect-filename-case' | 'malformed-managed-block' | 'unsafe-agents-path';
5
+ };
6
+ /** Create or update the managed Primer Brand instructions in a project's root AGENTS.md. */
7
+ export declare function updateAgentsMd(projectDir: string | null): AgentsMdUpdateResult;
@@ -0,0 +1,74 @@
1
+ import { lstatSync, readFileSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
2
+ import { isAbsolute, join, relative, sep } from 'node:path';
3
+ /** Create or update the managed Primer Brand instructions in a project's root AGENTS.md. */
4
+ export function updateAgentsMd(projectDir) {
5
+ const filename = 'AGENTS.md';
6
+ const startMarker = '<!-- BEGIN:primer-brand-mcp -->';
7
+ const endMarker = '<!-- END:primer-brand-mcp -->';
8
+ const block = `${startMarker}
9
+ ## Primer Brand
10
+
11
+ When building brand-led marketing or landing pages with \`@primer/react-brand\`, use the available \`primer_brand_*\` MCP tools.
12
+
13
+ Prefer \`primer_brand_docs\` over fetching primer.style/brand directly. It reads version-matched documentation bundled with the installed package first and only falls back to the live site when necessary.
14
+
15
+ Start page work with \`primer_brand_page_design\` and \`primer_brand_examples\`. Use \`primer_brand_component\` for exact APIs and \`primer_brand_review\` before finishing.
16
+ ${endMarker}`;
17
+ if (!projectDir)
18
+ return { action: 'skipped', path: null, reason: 'no-project-root' };
19
+ let canonicalProjectDir;
20
+ try {
21
+ canonicalProjectDir = realpathSync(projectDir);
22
+ }
23
+ catch {
24
+ return { action: 'skipped', path: null, reason: 'no-project-root' };
25
+ }
26
+ const agentMdCustomSetupPath = join(canonicalProjectDir, filename);
27
+ const caseInsensitiveMatch = readdirSync(canonicalProjectDir).find(entry => entry.toLowerCase() === filename.toLowerCase());
28
+ if (caseInsensitiveMatch && caseInsensitiveMatch !== filename) {
29
+ return { action: 'skipped', path: agentMdCustomSetupPath, reason: 'incorrect-filename-case' };
30
+ }
31
+ const fileStats = lstatSync(agentMdCustomSetupPath, { throwIfNoEntry: false });
32
+ if (fileStats?.isSymbolicLink()) {
33
+ return { action: 'skipped', path: agentMdCustomSetupPath, reason: 'unsafe-agents-path' };
34
+ }
35
+ if (!fileStats) {
36
+ writeFileSync(agentMdCustomSetupPath, `${block}\n`, 'utf8');
37
+ return { action: 'created', path: agentMdCustomSetupPath };
38
+ }
39
+ let canonicalAgentsPath;
40
+ try {
41
+ canonicalAgentsPath = realpathSync(agentMdCustomSetupPath);
42
+ }
43
+ catch {
44
+ return { action: 'skipped', path: agentMdCustomSetupPath, reason: 'unsafe-agents-path' };
45
+ }
46
+ const relativeAgentsPath = relative(canonicalProjectDir, canonicalAgentsPath);
47
+ if (relativeAgentsPath === '..' || relativeAgentsPath.startsWith(`..${sep}`) || isAbsolute(relativeAgentsPath)) {
48
+ return { action: 'skipped', path: agentMdCustomSetupPath, reason: 'unsafe-agents-path' };
49
+ }
50
+ const existing = readFileSync(agentMdCustomSetupPath, 'utf8');
51
+ const eol = existing.includes('\r\n') ? '\r\n' : '\n';
52
+ const normalizedBlock = block.replaceAll('\n', eol);
53
+ const startIndex = existing.indexOf(startMarker);
54
+ const endIndex = existing.indexOf(endMarker);
55
+ const hasStartMarker = startIndex !== -1;
56
+ const hasEndMarker = endIndex !== -1;
57
+ const hasDuplicateMarkers = startIndex !== existing.lastIndexOf(startMarker) || endIndex !== existing.lastIndexOf(endMarker);
58
+ if (hasStartMarker !== hasEndMarker || hasDuplicateMarkers || (hasStartMarker && endIndex < startIndex)) {
59
+ return { action: 'skipped', path: agentMdCustomSetupPath, reason: 'malformed-managed-block' };
60
+ }
61
+ let updated;
62
+ if (hasStartMarker) {
63
+ updated = `${existing.slice(0, startIndex)}${normalizedBlock}${existing.slice(endIndex + endMarker.length)}`;
64
+ }
65
+ else {
66
+ const separator = existing.length === 0 || /\r?\n$/.test(existing) ? eol : `${eol}${eol}`;
67
+ updated = `${existing}${separator}${normalizedBlock}${eol}`;
68
+ }
69
+ if (updated === existing)
70
+ return { action: 'unchanged', path: agentMdCustomSetupPath };
71
+ writeFileSync(agentMdCustomSetupPath, updated, 'utf8');
72
+ return { action: 'updated', path: agentMdCustomSetupPath };
73
+ }
74
+ //# sourceMappingURL=update-agents-md.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-agents-md.js","sourceRoot":"","sources":["../../../src/brand/update-agents-md/update-agents-md.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;AACzF,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AAQzD,4FAA4F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