Skip to content

Commit 24b8706

Browse files
CopilotGordonSmith
authored andcommitted
chore: add comprehensive copilot instructions for AI assistants
Signed-off-by: Gordon Smith <[email protected]>
1 parent e1b371b commit 24b8706

File tree

9 files changed

+2096
-10
lines changed

9 files changed

+2096
-10
lines changed

.github/instructions/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Instructions Summary
2+
*AI Assistant instructions for hpcc-systems/hpcc-js-wasm - Updated July 2025*
3+
4+
This directory contains comprehensive instructions for AI assistants working with the HPCC-JS-WASM repository.
5+
6+
## File Overview
7+
8+
### Main Instructions
9+
- **[main.md](main.md)** - Start here! Repository overview, architecture, and basic guidance
10+
- **[workflow.md](workflow.md)** - Step-by-step development workflows for common tasks
11+
- **[patterns.md](patterns.md)** - Quick reference for package patterns and usage examples
12+
- **[troubleshooting.md](troubleshooting.md)** - Debugging guide for common issues
13+
14+
### Package-Specific Instructions
15+
- **[../../packages/graphviz/.copilot-package.md](../../packages/graphviz/.copilot-package.md)** - Graphviz package specifics
16+
- **[../../packages/duckdb/.copilot-package.md](../../packages/duckdb/.copilot-package.md)** - DuckDB package specifics
17+
18+
## Quick Start for AI Assistants
19+
20+
1. **First Time Setup**: Read [main.md](main.md) for repository overview
21+
2. **Development Tasks**: Follow workflows in [workflow.md](workflow.md)
22+
3. **Package Usage**: Check patterns in [patterns.md](patterns.md)
23+
4. **Problems?**: Consult [troubleshooting.md](troubleshooting.md)
24+
25+
## Key Points for AI Assistants
26+
27+
- **Monorepo Structure**: 8 packages, each providing WASM versions of C++ libraries
28+
- **Build Complexity**: Requires C++ compilation for full functionality
29+
- **TypeScript First**: Many operations can be done with TypeScript-only builds
30+
- **Test Expectations**: Fresh clone tests will fail without WASM builds (expected)
31+
- **Safe Operations**: Documentation changes, TypeScript modifications don't need full build
32+
33+
## Most Common Scenarios
34+
35+
### Making TypeScript Changes
36+
```bash
37+
npm ci
38+
npm run lint
39+
npm run build-ws # May fail without WASM, but can still work on TS
40+
```
41+
42+
### Full Development Setup
43+
```bash
44+
npm ci
45+
npm run install-build-deps # Requires system tools
46+
npm run build-cpp # Compiles C++ to WASM
47+
npm run build-ws # Builds TypeScript
48+
npm run test # Full test suite
49+
```
50+
51+
### Quick Fix Workflow
52+
```bash
53+
# Make changes
54+
npm run lint
55+
npm run lint-fix # Auto-fix linting issues
56+
# Test specific package if needed
57+
cd packages/[package] && npm test
58+
```
59+
60+
## Quick Commands Reference
61+
62+
| Task | Command |
63+
|------|---------|
64+
| TypeScript only | `npm ci && npm run build-ws` |
65+
| Full build | `npm run install-build-deps && npm run build-cpp && npm run build-ws` |
66+
| Lint and fix | `npm run lint-fix` |
67+
| Test specific package | `cd packages/[name] && npm test` |
68+
| Clean rebuild | `npm run clean && npm ci && npm run build-ws` |
69+
| Browser tests only | `npm run test-browser` |
70+
| Node tests only | `npm run test-node` |
71+
72+
## Live Examples in Repository
73+
74+
- **hw-graphviz.html** - Basic Graphviz graph rendering
75+
- **hw-zstd.html** - Compression and decompression examples
76+
- **hw-base91.html** - Binary encoding/decoding demos
77+
- **test.html** - Multi-package integration testing
78+
- **index.html** - Package showcase and demos
79+
80+
## When to Escalate
81+
82+
- C++ compilation errors requiring emscripten expertise
83+
- System dependency issues (cmake, python, etc.)
84+
- Platform-specific problems (Windows, specific Linux distributions)
85+
- Memory/performance issues beyond normal optimization
86+
87+
## Success Metrics
88+
89+
You've successfully used these instructions if:
90+
- You understand the repository structure and build system
91+
- You can make TypeScript changes safely
92+
- You can diagnose and resolve common build/test failures
93+
- You know when to attempt full builds vs. TypeScript-only changes
94+
- You can help users with package-specific questions
95+
96+
---
97+
98+
*These instructions are designed to help AI assistants provide better support for the HPCC-JS-WASM repository. They should be updated as the repository evolves.*

.github/instructions/main.md

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# Copilot Instructions for HPCC-JS-WASM
2+
*Last updated: July 2025 | For AI assistants working with hpcc-systems/hpcc-js-wasm*
3+
4+
This document provides guidance for AI assistants working with the HPCC-JS-WASM repository.
5+
6+
## Repository Overview
7+
8+
This is a **monorepo** that provides WebAssembly (WASM) versions of popular C++ libraries for use in Node.js, web browsers, and JavaScript applications. It uses **Lerna** for monorepo management and **npm workspaces**.
9+
10+
### Packages Provided
11+
12+
1. **@hpcc-js/wasm-base91** - Base91 encoding/decoding library
13+
2. **@hpcc-js/wasm-duckdb** - DuckDB embedded database
14+
3. **@hpcc-js/wasm-expat** - Expat XML parser
15+
4. **@hpcc-js/wasm-graphviz** - Graphviz graph visualization library
16+
5. **@hpcc-js/wasm-graphviz-cli** - Command-line interface for Graphviz
17+
6. **@hpcc-js/wasm-llama** - Llama.cpp AI model library
18+
7. **@hpcc-js/wasm-zstd** - Zstandard compression library
19+
8. **@hpcc-js/wasm** - Meta package for backward compatibility
20+
21+
## Architecture
22+
23+
### File Structure
24+
```
25+
├── packages/ # Individual WASM packages
26+
│ ├── base91/ # Base91 package
27+
│ ├── duckdb/ # DuckDB package
28+
│ ├── expat/ # Expat package
29+
│ ├── graphviz/ # Graphviz package
30+
│ ├── graphviz-cli/ # Graphviz CLI package
31+
│ ├── llama/ # Llama package
32+
│ ├── wasm/ # Meta package
33+
│ └── zstd/ # Zstd package
34+
├── src-cpp/ # Shared C++ source code
35+
├── scripts/ # Build and utility scripts
36+
├── docs/ # Documentation (VitePress)
37+
└── .vscode/ # VSCode configuration
38+
```
39+
40+
### Package Structure Pattern
41+
Each package typically contains:
42+
```
43+
packages/[name]/
44+
├── src/ # TypeScript source
45+
├── src-cpp/ # C++ source code
46+
├── tests/ # Test files
47+
├── package.json # Package configuration
48+
└── vitest.config.ts # Test configuration
49+
```
50+
51+
## Development Workflow
52+
53+
### Prerequisites for Full Development
54+
```bash
55+
# Install dependencies
56+
npm ci
57+
58+
# Install build dependencies (requires system tools)
59+
npm run install-build-deps # Installs emsdk, vcpkg, playwright
60+
61+
# Build C++ to WASM (requires emscripten)
62+
npm run build-cpp
63+
64+
# Build TypeScript packages
65+
npm run build-ws
66+
```
67+
68+
### Quick Development (TypeScript only)
69+
```bash
70+
# Install dependencies
71+
npm ci
72+
73+
# Build only TypeScript (without C++ compilation)
74+
npm run build-ws
75+
76+
# Run linting
77+
npm run lint
78+
79+
# Note: Tests may fail without WASM builds
80+
```
81+
82+
### Testing
83+
```bash
84+
# Run all tests (requires full build)
85+
npm run test
86+
87+
# Run specific package tests
88+
cd packages/graphviz && npm test
89+
90+
# Run browser tests
91+
npm run test-browser
92+
93+
# Run node tests
94+
npm run test-node
95+
```
96+
97+
## Common Patterns
98+
99+
### WASM Library Loading Pattern
100+
All WASM libraries follow this pattern:
101+
```typescript
102+
import { LibraryName } from "@hpcc-js/wasm-libraryname";
103+
104+
// Async loading required
105+
const library = await LibraryName.load();
106+
107+
// Use library methods
108+
const result = library.someMethod(input);
109+
```
110+
111+
### Package Export Structure
112+
```typescript
113+
// src/index.ts - Main entry point
114+
export * from "./libraryname.ts";
115+
116+
// src/libraryname.ts - Main implementation
117+
export class LibraryName {
118+
static async load(): Promise<LibraryName> { ... }
119+
someMethod(input: string): string { ... }
120+
version(): string { ... }
121+
}
122+
```
123+
124+
### Testing Patterns
125+
```typescript
126+
import { describe, it, expect } from "vitest";
127+
import { LibraryName } from "@hpcc-js/wasm-libraryname";
128+
129+
describe("LibraryName", () => {
130+
it("basic functionality", async () => {
131+
const lib = await LibraryName.load();
132+
const result = lib.someMethod("test");
133+
expect(result).toBeDefined();
134+
});
135+
});
136+
```
137+
138+
## Key Technologies
139+
140+
- **TypeScript** - Primary language for package implementations
141+
- **C++** - Source libraries compiled to WASM
142+
- **Emscripten** - C++ to WASM compilation toolchain
143+
- **Lerna** - Monorepo management
144+
- **Vitest** - Testing framework (with browser support)
145+
- **ESBuild** - TypeScript bundling
146+
- **VitePress** - Documentation generation
147+
148+
## Build System
149+
150+
### C++ Compilation Chain
151+
1. **vcpkg** - C++ package manager for dependencies
152+
2. **emscripten** - Compiles C++ to WASM
153+
3. **IDL files** - WebIDL bindings for C++ classes
154+
4. **Custom esbuild plugins** - Handle WASM imports
155+
156+
### TypeScript Build
157+
1. **tsc** - Type generation
158+
2. **esbuild** - Bundling (ESM, CJS, UMD formats)
159+
3. **Custom plugins** - WASM asset handling
160+
161+
## Common Issues and Solutions
162+
163+
### Build Failures
164+
- **Missing WASM files**: Run `npm run build-cpp` first
165+
- **Type errors**: Ensure all packages are built with `npm run build-ws`
166+
- **Test failures in fresh clone**: Expected - requires full build process
167+
168+
### Package Resolution Issues
169+
- Packages depend on each other being built
170+
- Use relative imports for local development
171+
- Run `lerna run build` to build all packages
172+
173+
### WASM Loading Issues
174+
- WASM files must be accessible at runtime
175+
- Browser requires proper MIME types for .wasm files
176+
- Node.js needs appropriate file system access
177+
178+
## Debugging
179+
180+
### VSCode Configuration
181+
- Launch configurations provided for browser and Node.js debugging
182+
- Tasks configured for watch mode development
183+
- CMake integration for C++ development
184+
185+
### Log Levels
186+
Most libraries support debug output:
187+
```typescript
188+
// Enable debug logging
189+
const lib = await LibraryName.load({ debug: true });
190+
```
191+
192+
## Documentation
193+
194+
- **API Docs**: Generated with TypeDoc at https://hpcc-systems.github.io/hpcc-js-wasm/
195+
- **Examples**: See `/examples` directory and live demos in root:
196+
- `hw-graphviz.html` - Graphviz graph rendering
197+
- `hw-zstd.html` - Compression examples
198+
- `hw-base91.html` - Encoding demos
199+
- `index.html` - Package showcase
200+
- **Package READMEs**: Each package has specific documentation
201+
202+
## AI Assistant Guidelines
203+
204+
### When Making Changes
205+
1. **Understand the monorepo structure** - changes may affect multiple packages
206+
2. **Follow existing patterns** - each package follows similar structure
207+
3. **Test incrementally** - build and test after each significant change
208+
4. **Consider WASM implications** - changes to C++ require full rebuild
209+
5. **Update documentation** - maintain TypeDoc comments and READMEs
210+
211+
### Safe Operations (No Full Build Required)
212+
- TypeScript code changes in `src/` directories
213+
- Test file modifications
214+
- Documentation updates
215+
- Package.json script modifications
216+
217+
### Operations Requiring Full Build
218+
- C++ source code changes in `src-cpp/` directories
219+
- WebIDL (.idl) file changes
220+
- CMakeLists.txt modifications
221+
- New WASM library additions
222+
223+
### Before Submitting Changes
224+
1. Run `npm run lint` to check code style
225+
2. Run `npm run build-ws` to ensure TypeScript builds
226+
3. If C++ was modified, run full build cycle
227+
4. Test affected packages individually
228+
5. Update relevant documentation

0 commit comments

Comments
 (0)