Skip to content

Commit cfae186

Browse files
Copilotejfasting
andcommitted
Add comprehensive Copilot instructions for repository
Co-authored-by: ejfasting <60758190+ejfasting@users.noreply.github.com>
1 parent 878de59 commit cfae186

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

.github/copilot-instructions.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Copilot Instructions for SuperOffice Language Tools
2+
3+
## Repository Overview
4+
5+
VS Code extensions for TypeScript and CRMScript in SuperOffice. Implements LSP servers using Volar (TypeScript) and Langium (CRMScript).
6+
7+
**Type:** Monorepo (pnpm workspace) | **Languages:** TypeScript | **Frameworks:** Volar, Langium, VS Code Extension API | **Size:** ~521 TS files | **Runtime:** Node.js 20.x | **Package Manager:** pnpm 8.x (REQUIRED)
8+
9+
## Build & Test Requirements
10+
11+
### Prerequisites
12+
- **Node.js:** 20.x | **pnpm:** 8.x (install: `npm install -g pnpm@8`)
13+
- **Critical:** ONLY pnpm works - npm/yarn will fail due to workspace config and preinstall hooks
14+
15+
### Installation
16+
```bash
17+
pnpm install # ALWAYS run first
18+
```
19+
20+
### Build Process
21+
22+
**Build order matters!** Some packages depend on outputs from others:
23+
24+
1. **Build langium-crmscript FIRST** (generates TS from .langium grammars):
25+
```bash
26+
pnpm run build:langium-crmscript # Outputs to src/language/generated/ & syntaxes/
27+
```
28+
29+
2. **Build VS Code extensions:**
30+
```bash
31+
pnpm run build:vscode-core # Core extension (esbuild → dist/)
32+
pnpm run build:vscode-tsfso # TS extension (esbuild → dist/)
33+
pnpm run build:vscode-crmscript # CRMScript extension (esbuild → out/*.cjs)
34+
```
35+
36+
3. **CI Build Sequence:**
37+
```bash
38+
pnpm install && pnpm run build:vscode-core && pnpm run build:vscode-tsfso && pnpm test && pnpm eslint .
39+
```
40+
41+
### Testing
42+
43+
**Vitest** (7 tests, ~400ms):
44+
```bash
45+
pnpm test # All tests
46+
pnpm test:watch # Watch mode
47+
pnpm test:coverage # With coverage
48+
```
49+
50+
**VS Code Extension Tests** (SKIP in CI/sandboxed environments - requires internet):
51+
```bash
52+
pnpm run test:core # Fails offline: "getaddrinfo ENOTFOUND update.code.visualstudio.com"
53+
```
54+
55+
### Linting
56+
57+
```bash
58+
pnpm eslint .
59+
```
60+
61+
**Pre-existing Issues:** 22 ESLint errors (missing return types) - DO NOT block on these.
62+
**Strict Rules:** Explicit function return types, no-any, barrel imports (import from index.ts, not direct files).
63+
**Before commit:** Run `pnpm eslint .` - ensure NO NEW errors.
64+
65+
## Project Structure
66+
67+
### Monorepo Layout
68+
```
69+
├── .github/workflows/ci.yml # CI: test + lint jobs
70+
├── packages/ # 5 packages
71+
│ ├── langium-crmscript/ # CRMScript LSP server (Langium)
72+
│ ├── language-server/ # TypeScript LSP server (Volar)
73+
│ ├── superofficedx-vscode-core/ # Core extension (auth, tree view, commands)
74+
│ ├── superofficedx-vscode-crmscript/ # CRMScript client
75+
│ └── superofficedx-vscode-tsfso/ # TypeScript client
76+
├── test/ # Extension dev workspace
77+
├── eslint.config.mjs, package.json, pnpm-workspace.yaml, tsconfig.base.json, vitest.config.ts
78+
```
79+
80+
### Package Details
81+
82+
#### 1. `superofficedx-vscode-core` (Core Extension)
83+
Authentication, script browsing/execution for SuperOffice.
84+
85+
**Structure:** `src/extension.ts` (entry) | `commands/` | `providers/` (TreeView, auth, virtual FS) | `services/` (HTTP, FS, auth, Node) | `handlers/` | `container/` (DI) | `scripts/build.js` (esbuild + copy resources)
86+
**Output:** `dist/extension.js`
87+
**Import Rule:** ALWAYS use barrel exports:
88+
```typescript
89+
import { IHttpService } from '../../services';
90+
import { IHttpService } from '../../services/httpService'; // ESLint error
91+
```
92+
93+
#### 2. `language-server` (TypeScript LSP Server)
94+
Volar-based LSP for TypeScript.
95+
96+
**Structure:** `src/server.ts` (entry) | `languagePlugin.ts` | `languageService.ts` | `typescriptPlugin.ts` | `parser/` | `tests/`
97+
**Build:** None (bundled by vscode-tsfso)
98+
99+
#### 3. `superofficedx-vscode-tsfso` (TypeScript Client)
100+
LSP client for .tsfso files.
101+
**Structure:** `src/extension.ts` | `scripts/build.js` (bundles extension + language-server) | `syntaxes/tsfso.tmLanguage.json`
102+
**Output:** `dist/extension.js`, `dist/server.js`
103+
104+
#### 4. `langium-crmscript` (CRMScript LSP Server)
105+
Langium-based LSP for CRMScript.
106+
**Structure:** `src/language/*.langium` (grammars) | `generated/` (AUTO-GENERATED - DO NOT EDIT) | `main.ts` | `langium-config.json` | `examples/`
107+
**Build:** `pnpm run langium:generate` (generates TS from .langium)
108+
109+
#### 5. `superofficedx-vscode-crmscript` (CRMScript Client)
110+
LSP client for .crmscript files.
111+
**Structure:** `src/main.ts` | `scripts/esbuild.mjs` (bundles extension + langium server) | `syntaxes/`
112+
**Output:** `out/*.cjs` (CommonJS for VS Code)
113+
114+
## CI/CD Pipeline
115+
116+
`.github/workflows/ci.yml` runs on push/PR to `main`, `develop`:
117+
- **Test Job:** pnpm@8 + Node 20.x → `pnpm install` → build:vscode-core + build:vscode-tsfso`pnpm test`
118+
- **Lint Job:** pnpm@8 + Node 20.x → `pnpm install``pnpm eslint .`
119+
- Jobs run independently (lint failures don't block tests)
120+
121+
## Common Issues
122+
123+
1. **Build fails:** Build langium-crmscript first: `pnpm run build:langium-crmscript`
124+
2. **Import errors:** Use barrel imports from `index.ts` (services/, providers/, commands/, handlers/)
125+
3. **pnpm not found:** Install globally: `npm install -g pnpm@8`
126+
4. **TSC errors:** Ensure package `tsconfig.json` extends `../../tsconfig.base.json`
127+
5. **VS Code tests fail offline:** Expected. Skip `test:core` in CI/sandboxed environments
128+
6. **Generated files modified:** Run `pnpm run build:langium-crmscript` to regenerate
129+
130+
## Development Workflow
131+
132+
1. `pnpm install`
133+
2. Make changes to source files
134+
3. Build affected packages: `build:vscode-core` / `build:vscode-tsfso` / `build:langium-crmscript`
135+
4. Run `pnpm test` and `pnpm eslint .`
136+
5. Debug via `.vscode/launch.json` configs: "superofficedx-vscode-core" / "tsfso" / "crmscript"
137+
138+
**Rules:**
139+
- ❌ Don't edit `packages/langium-crmscript/src/language/generated/` (auto-generated)
140+
- ❌ Don't edit `dist/` or `out/` (build outputs)
141+
- ✅ Use barrel imports (index.ts) for services/providers/commands/handlers
142+
- ✅ Add explicit return types to functions
143+
- ✅ Run `pnpm eslint .` before committing
144+
145+
## Pre-Commit Checklist
146+
147+
1.`pnpm install` (if dependencies changed)
148+
2. ✅ Build affected packages (correct order!)
149+
3.`pnpm test` (7 tests must pass)
150+
4.`pnpm eslint .` (no NEW errors; 22 pre-existing OK)
151+
5. ✅ Verify `dist/`/`out/` outputs exist
152+
6. ✅ Don't commit generated files or build artifacts
153+
154+
**Trust these instructions** - validated through testing. Only explore further if information is incomplete or incorrect.

0 commit comments

Comments
 (0)