@teambit/host-initializer 0.0.702 → 0.0.704
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.
- package/agents-template-git.md +342 -0
- package/agents-template.md +67 -38
- package/dist/agents-template-git.md +342 -0
- package/dist/agents-template.md +67 -38
- package/dist/host-initializer.main.runtime.d.ts +54 -6
- package/dist/host-initializer.main.runtime.js +143 -57
- package/dist/host-initializer.main.runtime.js.map +1 -1
- package/dist/init-cmd.js +23 -7
- package/dist/init-cmd.js.map +1 -1
- package/package.json +4 -4
- /package/dist/{preview-1778872419685.js → preview-1779140326546.js} +0 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# Bit Workspace — AI Agent Instructions (Git-Integrated)
|
|
2
|
+
|
|
3
|
+
This file teaches AI agents how to work correctly inside a **Git-integrated Bit workspace**. Read it fully before touching any code.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What is Bit?
|
|
8
|
+
|
|
9
|
+
Bit is a composable development platform where every piece of functionality is an independent, versioned, composed **component**. Components live in **scopes** (remote registries of business domains) and are managed through the `bit` CLI.
|
|
10
|
+
|
|
11
|
+
In this workspace, **Git is the source of truth** for source code and collaboration. Bit's component versioning (`bit snap`, `bit tag`, `bit export`) runs in CI/CD on merge — not locally.
|
|
12
|
+
|
|
13
|
+
### Component Types
|
|
14
|
+
|
|
15
|
+
Not all components are UI widgets. In Bit, a "component" can be any of these:
|
|
16
|
+
|
|
17
|
+
| Type | What it is | Example |
|
|
18
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
|
|
19
|
+
| **Entity** | Plain domain object — defines the shape and behavior of a domain model. No React, no side effects. | `entities/user`, `entities/order` |
|
|
20
|
+
| **Hook** | Encapsulates data fetching, mutations, or stateful logic for a domain. Consumed by UI components and pages. | `hooks/use-user`, `hooks/use-orders` |
|
|
21
|
+
| **UI component** | Reusable visual element, typically stateless or lightly stateful. | `ui/button`, `ui/card` |
|
|
22
|
+
| **Feature / Aspect** | Self-contained domain slice — owns its entities, hooks, pages, and backend logic. | `customers`, `billing` |
|
|
23
|
+
| **App** | A standard deployable application — a React frontend, Node.js server, etc. | `my-react-app`, `my-node-server` |
|
|
24
|
+
| **Platform** | The app-level composition that wires aspects together into a running system. Often named `*-platform`. Not a framework concept — just the component responsible for composing aspects into the app. | `my-platform` |
|
|
25
|
+
| **Platform aspect** | A special aspect that exposes the registration API other aspects use to plug in (routes, backend servers, etc.). Lives as its own aspect component, typically named `platform-aspect`. | `platform-aspect` |
|
|
26
|
+
|
|
27
|
+
Understanding which type you're working with matters because it shapes the dependency chain. A typical full chain of a platform looks like:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Platform → Feature/Aspect → Page → Hook → Entity
|
|
31
|
+
↘ UI component
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For an app, the blueprint looks like:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
App → Page → Hook (optional) → Entity (optional)
|
|
38
|
+
↘ UI component
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Entities and hooks sit at the bottom of the chain — they have no dependents of their own, so changes to them propagate upward. Everything above that consumes them must be local for your changes to take effect.
|
|
42
|
+
|
|
43
|
+
The workspace is defined by `workspace.jsonc`. The owner and default scope are set there — always read them first.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Bit Cloud MCP
|
|
48
|
+
|
|
49
|
+
This workspace ships with a `.mcp.json` that wires up the **Bit Cloud MCP** server (`https://mcp.bit.cloud/mcp`). When the MCP is connected and authenticated (the agent will prompt for OAuth on first use), it is the fastest way to discover and inspect components that live in remote scopes — prefer it over reading source files or installing packages just to look around.
|
|
50
|
+
|
|
51
|
+
Key tools to reach for:
|
|
52
|
+
|
|
53
|
+
- **`read_scopes`** — list scopes and their components for a given `owner` (read from `workspace.jsonc`). Prefer this over broad `search` for discovery.
|
|
54
|
+
- **`read_components`** — structured type signatures, dependencies, and metadata for one or more remote components, in a single call. API references are included by default.
|
|
55
|
+
- **`search`** — keyword search across remote scopes.
|
|
56
|
+
|
|
57
|
+
When in doubt, ask the MCP before scaffolding anything new. If the MCP is not connected, fall back to the local `bit` CLI commands (`bit list`, `bit show`, `bit schema`).
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Project Orientation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cat workspace.jsonc # find owner, scope, envs
|
|
65
|
+
bit list # see what's already local
|
|
66
|
+
bit status # check for pending changes
|
|
67
|
+
bit templates # see what generators are available
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
When using the Bit Cloud MCP, always pass the `owner` from `workspace.jsonc`. Prefer `read_scopes` over `search` for broader discovery.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Understanding Component APIs
|
|
75
|
+
|
|
76
|
+
When you need to understand how to **use** a component (its props, function signatures, return types), prefer structured API data over reading source files:
|
|
77
|
+
|
|
78
|
+
- **Remote components:** use `read_components` (Bit Cloud MCP) — returns structured type signatures, dependencies, and metadata in a single call. API references are included by default. As a CLI fallback, run `bit show <owner>.<scope>/<name>`.
|
|
79
|
+
- **Local workspace components:** run `bit schema <component-id>` — returns exported types, function signatures, and class methods.
|
|
80
|
+
|
|
81
|
+
For understanding implementation details (how something works internally), read the source directly.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Common Commands
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
bit status # workspace health + pending changes
|
|
89
|
+
bit start # dev server (default port 3000)
|
|
90
|
+
bit run [app_name] # run the app
|
|
91
|
+
bit list # all locally tracked components (do not pass args)
|
|
92
|
+
bit search <query> # search components locally and on remote scopes (CLI fallback — prefer MCP for remote)
|
|
93
|
+
bit show <owner>.<scope>/<name> # inspect a specific component
|
|
94
|
+
bit schema <component-id> # structured API of a local component
|
|
95
|
+
bit import "<owner>.<scope>/**" # import all components from a remote scope
|
|
96
|
+
bit templates # list available generator templates
|
|
97
|
+
bit create <template> <name> # scaffold a new component
|
|
98
|
+
bit install [pkg1] [pkg2] ... # install package dependencies
|
|
99
|
+
bit compile # manual compile (usually auto — use for troubleshooting)
|
|
100
|
+
bit validate # lint + type-check + tests (fast build) — preferred check
|
|
101
|
+
bit test # run tests only
|
|
102
|
+
bit lint # run linter only
|
|
103
|
+
bit check-types # TypeScript type checker only
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> **Never run `bit build`** unless absolutely necessary. Always use `bit validate` instead — it's faster and sufficient.
|
|
107
|
+
>
|
|
108
|
+
> **Always use `bit install`** to install packages. Never use `npm install`, `yarn`, or `pnpm` directly — unless the workspace is configured with `externalPackageManager` mode in `workspace.jsonc`, in which case use your configured package manager.
|
|
109
|
+
>
|
|
110
|
+
> **Use Bit for type checking and testing.** Never use `tsc` or `npx tsc` directly. Use `bit validate` for a full check, or scope to specific components:
|
|
111
|
+
>
|
|
112
|
+
> ```bash
|
|
113
|
+
> bit check-types "[component-id1, component-id2]"
|
|
114
|
+
> bit test "[component-id1, component-id2]"
|
|
115
|
+
> bit validate "[component-id1, component-id2]"
|
|
116
|
+
> ```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Discovering Apps
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
bit app list
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Use the Bit Cloud MCP to list remote apps in a given scope. Use `bit import` to fetch remote apps and run them locally.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## The Golden Rule: One Component at a Time
|
|
131
|
+
|
|
132
|
+
Never scaffold multiple components upfront. Bit development is an **iterative loop**:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
render → identify gap → create ONE component → render again
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Step-by-step
|
|
139
|
+
|
|
140
|
+
1. **Look before you create.** Search the workspace and the Bit Cloud MCP first:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
bit list # what's already local
|
|
144
|
+
bit show <owner>.<scope>/<name> # inspect a candidate
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
And via the MCP: `read_scopes` for the workspace `owner` to see existing components, or `search` for keyword discovery. A component may already exist locally or remotely. Don't duplicate.
|
|
148
|
+
|
|
149
|
+
2. **Identify the entry point.** Depending on what you're building, the entry point could be a platform, app, or feature/aspect. Use the MCP (`read_scopes` / `read_components`) to list what exists in the scope before creating anything new.
|
|
150
|
+
|
|
151
|
+
3. **Create one component.** Scaffold it, wire it in, verify it compiles and renders.
|
|
152
|
+
|
|
153
|
+
4. **Validate before moving on:**
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
bit validate
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
5. **Identify the next gap.** Only then decide what the next component should be.
|
|
160
|
+
|
|
161
|
+
6. **Repeat.** Never pre-plan a list of components and create them all at once.
|
|
162
|
+
|
|
163
|
+
#### Example
|
|
164
|
+
|
|
165
|
+
Create a UI component:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
bit create react pages/login --scope acme.people
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Create a data entity:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
bit create entity entities/user --scope acme.people
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Importing Components for Modification
|
|
180
|
+
|
|
181
|
+
Bit resolves **local workspace components** over their installed package versions. If you want to modify a component, it must be imported into the workspace — otherwise the app will use the published version and ignore your changes.
|
|
182
|
+
|
|
183
|
+
### The full dependency chain must be local
|
|
184
|
+
|
|
185
|
+
When modifying any component, import every component in the chain from the top down to your target:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
Platform → App → Feature/Aspect → Page → UI component
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
You don't always need the full chain — only the layers in the dependency path of your change. But every layer between the entry point and your target must be local. If any layer in between is still installed as a package (not local), the app will ignore your changes to the layers below it.
|
|
192
|
+
|
|
193
|
+
**Examples:**
|
|
194
|
+
|
|
195
|
+
- Changing a UI component used by a feature page → import the feature, the page, and the UI component.
|
|
196
|
+
- Changing a feature's backend logic → import the platform, the app, and the feature/aspect.
|
|
197
|
+
- Changing the platform itself → import the platform only (everything downstream will pick it up once local).
|
|
198
|
+
|
|
199
|
+
### Finding the component ID
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
cat node_modules/@<org>/<package-name>/package.json | grep -A3 '"componentId"'
|
|
203
|
+
# "scope": "myorg.myfeature"
|
|
204
|
+
# "name": "pages/my-page"
|
|
205
|
+
# → component ID: myorg.myfeature/pages/my-page
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Importing
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
bit import <scope>/<name>
|
|
212
|
+
# e.g.
|
|
213
|
+
bit import myorg.myfeature/pages/my-page myorg.myfeature/pages/lobby-page
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Imported components land at `<scope-short-name>/<name>/` in the workspace.
|
|
217
|
+
|
|
218
|
+
#### Importing whole scopes
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
bit import "<owner>.<scope>/**"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Saving and Publishing Changes (Git-Integrated Workflow)
|
|
227
|
+
|
|
228
|
+
**This workspace is Git-integrated.** Git owns version control of source code; Bit's snap/tag/export are handled automatically by CI/CD on merge. Your collaboration unit is the Git branch, not a Bit lane.
|
|
229
|
+
|
|
230
|
+
**Do not run locally:**
|
|
231
|
+
|
|
232
|
+
- `bit snap`, `bit tag`, `bit export` — CI/CD handles these on merge.
|
|
233
|
+
- `bit lane create` and `bit lane` management — use Git branches instead.
|
|
234
|
+
|
|
235
|
+
**Your workflow:**
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
git checkout -b <branch-name> # create a feature branch
|
|
239
|
+
# ... edit components ...
|
|
240
|
+
bit validate # confirm no build errors
|
|
241
|
+
git add . && git commit -m "describe change"
|
|
242
|
+
git push # push your branch
|
|
243
|
+
# open a PR; CI runs `bit snap` + `bit export` on merge.
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
> Focus on development workflows: component creation, modification, testing, and local validation. Leave versioning and publishing to CI.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Component Structure
|
|
251
|
+
|
|
252
|
+
Each component directory follows this convention:
|
|
253
|
+
|
|
254
|
+
| File | Purpose |
|
|
255
|
+
| ------------------------ | ------------------------------------ |
|
|
256
|
+
| `<name>.tsx` | Main implementation |
|
|
257
|
+
| `index.ts` | Public barrel export |
|
|
258
|
+
| `<name>.spec.tsx` | Tests |
|
|
259
|
+
| `<name>.composition.tsx` | Live previews (shown in `bit start`) |
|
|
260
|
+
| `<name>.docs.mdx` | Documentation |
|
|
261
|
+
| `<name>.mock.ts` | Mock data / fixtures |
|
|
262
|
+
| `*-type.ts` | Standalone type definitions |
|
|
263
|
+
|
|
264
|
+
> Add JSDocs to exported APIs, include two to three usage examples in the `.docs.mdx`, and two to three compositions for the live preview.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Import Path Convention
|
|
269
|
+
|
|
270
|
+
Components import each other using Bit's package notation:
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
import { Something } from '@<org>/<scope>.<namespace>.<name>';
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Never use relative paths across component boundaries. Always use the package notation.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Environment Setup
|
|
281
|
+
|
|
282
|
+
Generator environments (React, Vue, Node, Angular, etc.) are configured in `workspace.jsonc`. Some may be commented out. Enable the relevant environment before creating components for a specific framework.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Key Files
|
|
287
|
+
|
|
288
|
+
| File | Purpose |
|
|
289
|
+
| ----------------- | ------------------------------------------------------------------- |
|
|
290
|
+
| `workspace.jsonc` | Workspace config — scopes, envs, component patterns |
|
|
291
|
+
| `.bitmap` | Auto-generated — tracks component locations. **Must be committed.** |
|
|
292
|
+
| `package.json` | Usually `"type": "module"` for ES Modules |
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Runtime Code Crossing Environment Boundaries
|
|
297
|
+
|
|
298
|
+
Importing frontend modules into Node.js runtime files or Node.js modules into browser runtime files causes app initialization failures. This typically happens when `index.ts` or runtime files import/export cross-environment modules by value instead of by type.
|
|
299
|
+
|
|
300
|
+
**Rules for aspect `index.ts` files:**
|
|
301
|
+
|
|
302
|
+
- The Aspect manifest (from `*.aspect.ts`) is the **only** allowed value export. Everything else must use `export type`.
|
|
303
|
+
- Runtime modules (`*.node.runtime.ts`, `*.browser.runtime.ts`) must **always** be exported as types.
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
// ✅ Correct
|
|
307
|
+
export type { MyBrowser } from './my.browser.runtime.js';
|
|
308
|
+
export type { MyNode } from './my.node.runtime.js';
|
|
309
|
+
export type { User } from './user.js';
|
|
310
|
+
export default MyAspect;
|
|
311
|
+
export { MyAspect };
|
|
312
|
+
|
|
313
|
+
// ❌ Wrong — pulls frontend/backend code into the wrong runtime
|
|
314
|
+
export { MyBrowser } from './my.browser.runtime.js';
|
|
315
|
+
export { User } from './user.js';
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Rules for `*.node.runtime.ts` files:**
|
|
319
|
+
|
|
320
|
+
- Must not import frontend modules (React components, SCSS, browser-only libraries) by value. Use `import type` if only the type is needed.
|
|
321
|
+
|
|
322
|
+
**Rules for `*.browser.runtime.tsx` files:**
|
|
323
|
+
|
|
324
|
+
- Must not import Node.js modules (`fs`, `path`, server-only libraries) by value. Use `import type` if only the type is needed.
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Common Mistakes to Avoid
|
|
329
|
+
|
|
330
|
+
| Mistake | Correct approach |
|
|
331
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
332
|
+
| Creating multiple components upfront | Create one, validate, then decide what's next |
|
|
333
|
+
| Modifying an installed (node_modules) component | Import it with `bit import` first |
|
|
334
|
+
| Importing only the target component but not its dependents | Import the full chain top-down: platform → app → feature → page → component |
|
|
335
|
+
| Treating all components as UI widgets | Understand the type first — platform, app, feature/aspect, hook, entity, or UI component — it determines the chain |
|
|
336
|
+
| Running `bit build` | Use `bit validate` instead — faster and sufficient |
|
|
337
|
+
| Running `bit snap`, `bit tag`, or `bit export` locally | These are handled by CI/CD on merge — don't run them in the workspace |
|
|
338
|
+
| Creating or managing Bit lanes | Use Git branches instead — this workspace is Git-integrated |
|
|
339
|
+
| Guessing a component ID | Check `package.json` under `componentId` or use `bit list` |
|
|
340
|
+
| Creating a component that already exists | Always run `bit list` and check the Bit Cloud MCP (`read_scopes` / `search`) first |
|
|
341
|
+
| Using `npm install`, `yarn`, or `pnpm` | Use `bit install` |
|
|
342
|
+
| Using `tsc` or `npx tsc` to check types | Use `bit validate`, `bit check-types`, or `bit test` |
|
package/agents-template.md
CHANGED
|
@@ -12,15 +12,24 @@ Bit is a composable development platform where every piece of functionality is a
|
|
|
12
12
|
|
|
13
13
|
Not all components are UI widgets. In Bit, a "component" can be any of these:
|
|
14
14
|
|
|
15
|
-
| Type | What it is
|
|
16
|
-
| -------------------- |
|
|
17
|
-
| **Entity** | Plain domain object — defines the shape and behavior of a domain model. No React, no side effects.
|
|
18
|
-
| **Hook** | Encapsulates data fetching, mutations, or stateful logic for a domain. Consumed by UI components and pages.
|
|
19
|
-
| **UI component** | Reusable visual element, typically stateless or lightly stateful.
|
|
20
|
-
| **Feature / Aspect** | Self-contained domain slice — owns its entities, hooks, pages, and backend logic.
|
|
21
|
-
| **App** | A standard deployable application — a React frontend, Node.js server, etc.
|
|
15
|
+
| Type | What it is | Example |
|
|
16
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
|
|
17
|
+
| **Entity** | Plain domain object — defines the shape and behavior of a domain model. No React, no side effects. | `entities/user`, `entities/order` |
|
|
18
|
+
| **Hook** | Encapsulates data fetching, mutations, or stateful logic for a domain. Consumed by UI components and pages. | `hooks/use-user`, `hooks/use-orders` |
|
|
19
|
+
| **UI component** | Reusable visual element, typically stateless or lightly stateful. | `ui/button`, `ui/card` |
|
|
20
|
+
| **Feature / Aspect** | Self-contained domain slice — owns its entities, hooks, pages, and backend logic. | `customers`, `billing` |
|
|
21
|
+
| **App** | A standard deployable application — a React frontend, Node.js server, etc. | `my-react-app`, `my-node-server` |
|
|
22
|
+
| **Platform** | The app-level composition that wires aspects together into a running system. Often named `*-platform`. Not a framework concept — just the component responsible for composing aspects into the app. | `my-platform` |
|
|
23
|
+
| **Platform aspect** | A special aspect that exposes the registration API other aspects use to plug in (routes, backend servers, etc.). Lives as its own aspect component, typically named `platform-aspect`. | `platform-aspect` |
|
|
24
|
+
|
|
25
|
+
Understanding which type you're working with matters because it shapes the dependency chain. A typical full chain of a platform looks like:
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
```
|
|
28
|
+
Platform → Feature/Aspect → Page → Hook → Entity
|
|
29
|
+
↘ UI component
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
For an app, the blueprint looks like:
|
|
24
33
|
|
|
25
34
|
```
|
|
26
35
|
App → Page → Hook (optional) → Entity (optional)
|
|
@@ -33,6 +42,20 @@ The workspace is defined by `workspace.jsonc`. The owner and default scope are s
|
|
|
33
42
|
|
|
34
43
|
---
|
|
35
44
|
|
|
45
|
+
## Bit Cloud MCP
|
|
46
|
+
|
|
47
|
+
This workspace ships with a `.mcp.json` that wires up the **Bit Cloud MCP** server (`https://mcp.bit.cloud/mcp`). When the MCP is connected and authenticated (the agent will prompt for OAuth on first use), it is the fastest way to discover and inspect components that live in remote scopes — prefer it over reading source files or installing packages just to look around.
|
|
48
|
+
|
|
49
|
+
Key tools to reach for:
|
|
50
|
+
|
|
51
|
+
- **`read_scopes`** — list scopes and their components for a given `owner` (read from `workspace.jsonc`). Prefer this over broad `search` for discovery.
|
|
52
|
+
- **`read_components`** — structured type signatures, dependencies, and metadata for one or more remote components, in a single call. API references are included by default.
|
|
53
|
+
- **`search`** — keyword search across remote scopes.
|
|
54
|
+
|
|
55
|
+
When in doubt, ask the MCP before scaffolding anything new. If the MCP is not connected, fall back to the local `bit` CLI commands (`bit list`, `bit show`, `bit schema`).
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
36
59
|
## Project Orientation
|
|
37
60
|
|
|
38
61
|
```bash
|
|
@@ -42,14 +65,16 @@ bit status # check for pending changes
|
|
|
42
65
|
bit templates # see what generators are available
|
|
43
66
|
```
|
|
44
67
|
|
|
68
|
+
When using the Bit Cloud MCP, always pass the `owner` from `workspace.jsonc`. Prefer `read_scopes` over `search` for broader discovery.
|
|
69
|
+
|
|
45
70
|
---
|
|
46
71
|
|
|
47
72
|
## Understanding Component APIs
|
|
48
73
|
|
|
49
74
|
When you need to understand how to **use** a component (its props, function signatures, return types), prefer structured API data over reading source files:
|
|
50
75
|
|
|
76
|
+
- **Remote components:** use `read_components` (Bit Cloud MCP) — returns structured type signatures, dependencies, and metadata in a single call. API references are included by default. As a CLI fallback, run `bit show <owner>.<scope>/<name>`.
|
|
51
77
|
- **Local workspace components:** run `bit schema <component-id>` — returns exported types, function signatures, and class methods.
|
|
52
|
-
- **Remote components:** run `bit show <owner>.<scope>/<name>` to inspect metadata and dependencies.
|
|
53
78
|
|
|
54
79
|
For understanding implementation details (how something works internally), read the source directly.
|
|
55
80
|
|
|
@@ -62,7 +87,7 @@ bit status # workspace health + pending changes
|
|
|
62
87
|
bit start # dev server (default port 3000)
|
|
63
88
|
bit run [app_name] # run the app
|
|
64
89
|
bit list # all locally tracked components (do not pass args)
|
|
65
|
-
bit search <query> # search components locally and on remote scopes
|
|
90
|
+
bit search <query> # search components locally and on remote scopes (CLI fallback — prefer MCP for remote)
|
|
66
91
|
bit show <owner>.<scope>/<name> # inspect a specific component
|
|
67
92
|
bit schema <component-id> # structured API of a local component
|
|
68
93
|
bit import "<owner>.<scope>/**" # import all components from a remote scope
|
|
@@ -70,18 +95,22 @@ bit templates # list available generator templates
|
|
|
70
95
|
bit create <template> <name> # scaffold a new component
|
|
71
96
|
bit install [pkg1] [pkg2] ... # install package dependencies
|
|
72
97
|
bit compile # manual compile (usually auto — use for troubleshooting)
|
|
73
|
-
bit
|
|
74
|
-
bit
|
|
75
|
-
bit
|
|
98
|
+
bit validate # lint + type-check + tests (fast build) — preferred check
|
|
99
|
+
bit test # run tests only
|
|
100
|
+
bit lint # run linter only
|
|
101
|
+
bit check-types # TypeScript type checker only
|
|
76
102
|
```
|
|
77
103
|
|
|
104
|
+
> **Never run `bit build`** unless absolutely necessary. Always use `bit validate` instead — it's faster and sufficient.
|
|
105
|
+
>
|
|
78
106
|
> **Always use `bit install`** to install packages. Never use `npm install`, `yarn`, or `pnpm` directly — unless the workspace is configured with `externalPackageManager` mode in `workspace.jsonc`, in which case use your configured package manager.
|
|
79
107
|
>
|
|
80
|
-
> **Use Bit for type checking and testing.** Never use `tsc` or `npx tsc` directly.
|
|
108
|
+
> **Use Bit for type checking and testing.** Never use `tsc` or `npx tsc` directly. Use `bit validate` for a full check, or scope to specific components:
|
|
81
109
|
>
|
|
82
110
|
> ```bash
|
|
83
111
|
> bit check-types "[component-id1, component-id2]"
|
|
84
112
|
> bit test "[component-id1, component-id2]"
|
|
113
|
+
> bit validate "[component-id1, component-id2]"
|
|
85
114
|
> ```
|
|
86
115
|
|
|
87
116
|
---
|
|
@@ -92,7 +121,7 @@ bit check-types # TypeScript type checker
|
|
|
92
121
|
bit app list
|
|
93
122
|
```
|
|
94
123
|
|
|
95
|
-
Use `bit import` to fetch remote apps and run them locally.
|
|
124
|
+
Use the Bit Cloud MCP to list remote apps in a given scope. Use `bit import` to fetch remote apps and run them locally.
|
|
96
125
|
|
|
97
126
|
---
|
|
98
127
|
|
|
@@ -106,25 +135,23 @@ render → identify gap → create ONE component → render again
|
|
|
106
135
|
|
|
107
136
|
### Step-by-step
|
|
108
137
|
|
|
109
|
-
1. **Look before you create.** Search the workspace and
|
|
138
|
+
1. **Look before you create.** Search the workspace and the Bit Cloud MCP first:
|
|
110
139
|
|
|
111
140
|
```bash
|
|
112
|
-
bit
|
|
113
|
-
bit show <owner>.<scope>/<name>
|
|
141
|
+
bit list # what's already local
|
|
142
|
+
bit show <owner>.<scope>/<name> # inspect a candidate
|
|
114
143
|
```
|
|
115
144
|
|
|
116
|
-
A component may already exist locally or remotely. Don't duplicate.
|
|
145
|
+
And via the MCP: `read_scopes` for the workspace `owner` to see existing components, or `search` for keyword discovery. A component may already exist locally or remotely. Don't duplicate.
|
|
117
146
|
|
|
118
|
-
2. **Identify the entry point.** Depending on what you're building, the entry point could be
|
|
147
|
+
2. **Identify the entry point.** Depending on what you're building, the entry point could be a platform, app, or feature/aspect. Use the MCP (`read_scopes` / `read_components`) to list what exists in the scope before creating anything new.
|
|
119
148
|
|
|
120
149
|
3. **Create one component.** Scaffold it, wire it in, verify it compiles and renders.
|
|
121
150
|
|
|
122
151
|
4. **Validate before moving on:**
|
|
123
152
|
|
|
124
153
|
```bash
|
|
125
|
-
bit
|
|
126
|
-
bit check-types
|
|
127
|
-
bit test
|
|
154
|
+
bit validate
|
|
128
155
|
```
|
|
129
156
|
|
|
130
157
|
5. **Identify the next gap.** Only then decide what the next component should be.
|
|
@@ -156,7 +183,7 @@ Bit resolves **local workspace components** over their installed package version
|
|
|
156
183
|
When modifying any component, import every component in the chain from the top down to your target:
|
|
157
184
|
|
|
158
185
|
```
|
|
159
|
-
App → Feature/Aspect → Page → UI component
|
|
186
|
+
Platform → App → Feature/Aspect → Page → UI component
|
|
160
187
|
```
|
|
161
188
|
|
|
162
189
|
You don't always need the full chain — only the layers in the dependency path of your change. But every layer between the entry point and your target must be local. If any layer in between is still installed as a package (not local), the app will ignore your changes to the layers below it.
|
|
@@ -164,7 +191,8 @@ You don't always need the full chain — only the layers in the dependency path
|
|
|
164
191
|
**Examples:**
|
|
165
192
|
|
|
166
193
|
- Changing a UI component used by a feature page → import the feature, the page, and the UI component.
|
|
167
|
-
- Changing a feature's backend logic → import the app and the feature/aspect.
|
|
194
|
+
- Changing a feature's backend logic → import the platform, the app, and the feature/aspect.
|
|
195
|
+
- Changing the platform itself → import the platform only (everything downstream will pick it up once local).
|
|
168
196
|
|
|
169
197
|
### Finding the component ID
|
|
170
198
|
|
|
@@ -201,7 +229,7 @@ Git does not manage component versions in a Bit workspace — use Bit for versio
|
|
|
201
229
|
|
|
202
230
|
```bash
|
|
203
231
|
bit lane create <your-lane-name> # create a new lane
|
|
204
|
-
bit
|
|
232
|
+
bit validate # confirm no build errors first
|
|
205
233
|
bit snap --message "describe change" # persist component versions
|
|
206
234
|
bit export # push lane to remote
|
|
207
235
|
```
|
|
@@ -290,15 +318,16 @@ export { User } from './user.js';
|
|
|
290
318
|
|
|
291
319
|
## Common Mistakes to Avoid
|
|
292
320
|
|
|
293
|
-
| Mistake | Correct approach
|
|
294
|
-
| ---------------------------------------------------------- |
|
|
295
|
-
| Creating multiple components upfront | Create one, validate, then decide what's next
|
|
296
|
-
| Modifying an installed (node_modules) component | Import it with `bit import` first
|
|
297
|
-
| Importing only the target component but not its dependents | Import the full chain top-down: app → feature → page → component
|
|
298
|
-
| Treating all components as UI widgets | Understand the type first — app, feature/aspect, hook, entity, or UI component — it determines the chain |
|
|
299
|
-
|
|
|
300
|
-
|
|
|
301
|
-
|
|
|
302
|
-
|
|
|
303
|
-
|
|
|
304
|
-
| Using `
|
|
321
|
+
| Mistake | Correct approach |
|
|
322
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
323
|
+
| Creating multiple components upfront | Create one, validate, then decide what's next |
|
|
324
|
+
| Modifying an installed (node_modules) component | Import it with `bit import` first |
|
|
325
|
+
| Importing only the target component but not its dependents | Import the full chain top-down: platform → app → feature → page → component |
|
|
326
|
+
| Treating all components as UI widgets | Understand the type first — platform, app, feature/aspect, hook, entity, or UI component — it determines the chain |
|
|
327
|
+
| Running `bit build` | Use `bit validate` instead — faster and sufficient |
|
|
328
|
+
| Pushing to the main lane | Always create a lane, snap, then export |
|
|
329
|
+
| Using git to version components | Bit manages component versions — use `bit snap` / `bit export` |
|
|
330
|
+
| Guessing a component ID | Check `package.json` under `componentId` or use `bit list` |
|
|
331
|
+
| Creating a component that already exists | Always run `bit list` and check the Bit Cloud MCP (`read_scopes` / `search`) first |
|
|
332
|
+
| Using `npm install`, `yarn`, or `pnpm` | Use `bit install` |
|
|
333
|
+
| Using `tsc` or `npx tsc` to check types | Use `bit validate`, `bit check-types`, or `bit test` |
|