Skip to content

Commit 7767435

Browse files
chore: update copilot agent config for modular architecture
Rewrite copilot-instructions.md to reflect the current 55-module src/modules/ architecture (was describing the old monolithic app.js with 21 modules). Update file tree, module catalog, conventions, and 'how to add a module' instructions. Update copilot-setup-steps.yml to include the build step (npm run build) and report accurate module/test/page counts.
1 parent af20ec6 commit 7767435

2 files changed

Lines changed: 91 additions & 95 deletions

File tree

.github/copilot-instructions.md

Lines changed: 70 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Project Overview
44

5-
**getagentbox** is the landing page and npm package for [AgentBox](https://t.me/AgentBox11Bot), a personal AI agent that lives in Telegram. The site is a vanilla HTML/CSS/JS project — no build step, no framework, no runtime dependencies.
5+
**getagentbox** is the landing page and npm package for [AgentBox](https://t.me/AgentBox11Bot), a personal AI agent that lives in Telegram. The site is a vanilla HTML/CSS/JS project — no framework, no transpiler, no runtime dependencies. A simple `build.js` concatenates modules into `dist/bundle.js`.
66

77
**Live site:** https://sauravbhattacharya001.github.io/getagentbox/
88
**npm package:** `agentbox-landing` (reusable FAQ, Pricing, Stats components)
@@ -11,72 +11,66 @@
1111

1212
```
1313
getagentbox/
14-
├── index.html # Main landing page (HTML structure)
15-
├── styles.css # All styles (67KB — responsive, dark theme, CSS vars)
16-
├── app.js # 21 interactive modules (~2,300 lines)
14+
├── index.html # Main landing page
15+
├── styles.css # All styles (responsive, dark theme, CSS vars)
16+
├── build.js # Concatenation bundler → dist/bundle.js
1717
├── src/
18-
│ └── index.js # npm package — UMD reusable components (FAQ, Pricing, Stats)
19-
├── docs/
20-
│ ├── index.html # Developer documentation site
21-
│ └── getting-started.html
18+
│ ├── index.js # npm package — UMD reusable components
19+
│ ├── roi-calculator.js # ROI calculator page script
20+
│ ├── benchmarks.js # Benchmarks page script
21+
│ ├── capability-radar.js # Capability radar visualization
22+
│ ├── command-reference.js# Command reference page
23+
│ ├── events-page.js # Events page
24+
│ ├── migration-guide.js # Migration guide page
25+
│ ├── role-demo-picker.js # Role demo picker page
26+
│ ├── use-case-explorer.js# Use case explorer page
27+
│ ├── workflow-builder.js # Workflow builder page
28+
│ ├── autonomy-ladder.js # Autonomy ladder page
29+
│ ├── calibration-lab.js # Calibration lab page
30+
│ └── modules/ # 55 modular IIFE components (see below)
31+
├── dist/
32+
│ └── bundle.js # Auto-generated (do NOT edit)
33+
├── docs/ # Developer documentation site
2234
├── vendor/
2335
│ └── count.js # Vendored GoatCounter analytics (do NOT modify)
24-
├── __tests__/ # Jest + jsdom test suites
25-
│ ├── index.test.js # Main app.js module tests (~58KB)
26-
│ ├── lib.test.js # npm package (src/index.js) tests
27-
│ ├── sitenav.test.js # SiteNav module tests
28-
│ ├── integrations.test.js
29-
│ ├── changelog.test.js
30-
│ ├── roadmap.test.js
31-
│ ├── status.test.js # StatusDashboard tests
32-
│ ├── trust.test.js # Trust module tests
33-
│ └── docs-security.test.js
36+
├── __tests__/ # 70 Jest + jsdom test suites
3437
├── Dockerfile # Multi-stage nginx production container
35-
├── SECURITY.md # CSP policy, XSS prevention, security headers
36-
├── CONTRIBUTING.md # Development guide, conventions, PR process
38+
├── SECURITY.md # CSP policy, XSS prevention
39+
├── CONTRIBUTING.md # Development guide
3740
└── .github/
38-
├── workflows/
39-
│ ├── ci.yml # Build + test + lint
40-
│ ├── pages.yml # GitHub Pages deployment
41-
│ ├── docker.yml # Docker build/push
42-
│ ├── publish.yml # npm publish
43-
│ ├── codeql.yml # Security scanning
44-
│ ├── labeler.yml # Auto-label PRs
45-
│ └── stale.yml # Stale issue management
41+
├── workflows/ # CI, Pages, Docker, npm publish, CodeQL, labeler, stale
4642
├── dependabot.yml
47-
├── copilot-setup-steps.yml
48-
└── copilot-instructions.md # ← this file
43+
└── copilot-setup-steps.yml
4944
```
5045

51-
## app.js Modules (21 total)
46+
## Module System
5247

53-
Each module follows the IIFE pattern and exposes an object with `init()` plus module-specific methods. Most also have `reset()` for test cleanup.
48+
All interactive components live in `src/modules/` as individual ES5 IIFE files. The build script (`build.js`) concatenates them in dependency order into `dist/bundle.js`.
5449

50+
### Core Infrastructure (load first)
5551
| Module | Purpose |
5652
|--------|---------|
57-
| `ChatDemo` | Animated chat scenario player (4 scenarios) |
58-
| `Testimonials` | Auto-rotating testimonials carousel with dots |
59-
| `Pricing` | Monthly/yearly billing toggle |
60-
| `FAQ` | Accessible accordion (aria-expanded, keyboard nav) |
61-
| `HowItWorks` | Step-by-step reveal animation |
62-
| `Stats` | Animated social proof counters with easing |
63-
| `UseCases` | Tabbed use case browser |
64-
| `Integrations` | Filterable integration cards by category |
65-
| `Changelog` | Filterable changelog entries by tag |
66-
| `Trust` | Expandable privacy detail cards |
67-
| `SiteNav` | Sticky nav with scroll tracking + mobile menu |
68-
| `Newsletter` | Email subscription form with validation |
69-
| `Roadmap` | Status-filterable roadmap cards with voting |
70-
| `StatusDashboard` | Service status grid with uptime bars + incidents |
71-
| `Calculator` | Interactive time-savings calculator with sliders |
72-
| `CommandPalette` | Keyboard-triggered section search (Ctrl+K) |
73-
| `ShareFab` | Floating share button (Twitter, LinkedIn, copy link) |
74-
| `ThemeToggle` | Light/dark mode with localStorage persistence |
75-
| `ScrollProgress` | Progress bar + back-to-top button |
76-
| `ShortcutsHelp` | Keyboard shortcuts overlay (?) |
77-
| `Playground` | Interactive chat demo with pattern-matched responses |
78-
79-
**Two DOMContentLoaded blocks:** Modules are initialized in two separate `DOMContentLoaded` listeners (lines ~979 and ~2292). The first handles the core set; the second handles later additions.
53+
| `storage.js` | Safe localStorage wrapper |
54+
| `dom-utils.js` | Shared DOM helper functions |
55+
| `globals.js` | Global state and `prefersReducedMotion` flag |
56+
| `_typing-indicator-template.js` | Shared typing indicator markup |
57+
| `init.js` | DOMContentLoaded initializer for modules that don't self-init |
58+
59+
### Interactive Components (55 modules)
60+
Major modules include: `chat-demo`, `testimonials`, `pricing`, `faq`, `how-it-works`, `stats`, `use-cases`, `integrations`, `changelog`, `trust`, `site-nav`, `newsletter`, `roadmap`, `status-dashboard`, `calculator`, `command-palette`, `share-fab`, `theme-toggle`, `scroll-progress`, `shortcuts-help`, `playground`, `activity-feed`, `prompt-gallery`, `personality-configurator`, `feature-tour`, `api-explorer`, `pipeline-builder`, `community-showcase`, `section-minimap`, `help-chat-widget`, `scenario-planner`, `privacy-checkup`, `referral-program`, `setup-checklist`, `speed-challenge`, and more.
61+
62+
Each module follows the same pattern:
63+
```javascript
64+
/* exported ModuleName */
65+
var ModuleName = (function () {
66+
function init() { /* DOM setup */ }
67+
function reset() { /* cleanup for tests */ }
68+
return { init: init, reset: reset /* + module-specific methods */ };
69+
})();
70+
```
71+
72+
### Top-level Page Scripts (src/*.js)
73+
Individual page scripts (e.g., `roi-calculator.js`, `benchmarks.js`, `workflow-builder.js`) power standalone HTML pages. They are also included in the bundle build.
8074

8175
## src/index.js (npm Package)
8276

@@ -85,36 +79,33 @@ UMD module exporting `AgentBoxComponents` with three reusable components:
8579
- **Pricing** — Billing toggle
8680
- **Stats** — Animated counters
8781

88-
Tests in `__tests__/lib.test.js`. Methods can be called without `init()` for backward compatibility.
82+
Tests in `__tests__/lib.test.js`.
8983

9084
## Conventions
9185

9286
### JavaScript
9387
- **ES5 only** — no `let`/`const`, no arrow functions, no template literals
94-
- Modules are global IIFEs (e.g., `var ChatDemo = (function () { ... })();`)
95-
- `/* exported ... */` comments for linter hints
96-
- All DOM content creation uses `document.createElement()` / `createTextNode()` — avoid `innerHTML` with dynamic content (see Security)
97-
- `prefersReducedMotion` global for WCAG 2.3.3 compliance
88+
- Modules are global IIFEs with `/* exported ... */` JSDoc comments
89+
- All DOM content creation uses `document.createElement()` / `createTextNode()` — never `innerHTML` with dynamic content
90+
- `prefersReducedMotion` global (from `globals.js`) for WCAG 2.3.3 compliance
9891

9992
### CSS
100-
- CSS custom properties (variables) in `:root` for theming
93+
- CSS custom properties in `:root` for theming
10194
- Dark theme default, light mode via `.light-mode` body class
10295
- Breakpoints: 768px (tablet), 480px (phone)
10396
- `contain: content` on independent sections for layout isolation
104-
- `will-change` on animated elements for GPU compositing
10597

10698
### Testing
107-
- **Jest + jsdom**configured in `jest.config.js`
99+
- **Jest + jsdom**70 test files in `__tests__/`
108100
- `npm test` runs all suites; `npm run test:coverage` for coverage
109101
- Test files use `@jest-environment jsdom` pragma when needed
110-
- Functions are copied/re-evaluated in test files (jsdom can't `require` browser globals)
111-
- **Jest exit code is consistently 1 even when all tests pass** (pre-existing config issue)
102+
- Functions are re-evaluated in test files (jsdom can't `require` browser globals)
103+
- **Known:** Jest exit code is 1 even when all tests pass (pre-existing config issue)
112104

113105
### Security
114106
- Strict CSP via `<meta>` tag — `script-src 'self'`, `style-src 'self'`
115107
- No `innerHTML` for user-facing content — use safe DOM APIs
116108
- `vendor/count.js` is vendored GoatCounter — **do not modify**
117-
- XSS prevention: `createElement` + `createTextNode` for dynamic content
118109
- See `SECURITY.md` for full policy
119110

120111
## How to Work on This
@@ -126,31 +117,29 @@ npm install
126117
# Run tests
127118
npm test
128119

120+
# Build the bundle
121+
npm run build
122+
129123
# Serve locally
130124
npx serve .
131125
# Then open http://localhost:3000
132126
```
133127

134-
### Adding a New Module to app.js
135-
136-
1. Create an IIFE following the existing pattern:
137-
```javascript
138-
var MyModule = (function () {
139-
function init() { /* DOM setup */ }
140-
function reset() { /* cleanup for tests */ }
141-
return { init: init, reset: reset };
142-
})();
143-
```
144-
2. Call `MyModule.init()` in the DOMContentLoaded block (line ~2292)
145-
3. Add corresponding HTML in `index.html`
146-
4. Add styles in `styles.css` (section-based organization)
147-
5. Add tests in `__tests__/`
128+
### Adding a New Module
129+
130+
1. Create `src/modules/my-module.js` following the IIFE pattern above
131+
2. Add it to the file list in `build.js` (order matters — after dependencies)
132+
3. If it needs explicit init, add it to `src/modules/init.js`
133+
4. Add corresponding HTML section in `index.html` (or a new page)
134+
5. Add styles in `styles.css`
135+
6. Add tests in `__tests__/my-module.test.js`
136+
7. Run `npm run build` and `npm test` to verify
148137

149138
### What NOT to Do
150139

151140
- Do not add build tools, transpilers, or frameworks (keep vanilla)
152141
- Do not modify `vendor/count.js` (third-party GoatCounter)
153142
- Do not use `innerHTML` with any dynamic or user-influenced content
154143
- Do not break the CSP policy (no inline scripts/styles, no external CDNs)
155-
- Do not remove existing functionality without discussion
144+
- Do not edit `dist/bundle.js` directly (it's auto-generated by `build.js`)
156145
- Do not use ES6+ syntax (the codebase is ES5 for broad compatibility)

.github/copilot-setup-steps.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copilot Setup Steps — getagentbox
2-
# Installs dependencies and runs tests so GitHub Copilot coding agents
3-
# (Claude, Codex) can autonomously work on issues and PRs.
2+
# Installs dependencies, builds the bundle, and runs tests so GitHub Copilot
3+
# coding agents (Claude, Codex) can autonomously work on issues and PRs.
44

55
name: "Copilot Setup"
66

@@ -21,20 +21,27 @@ jobs:
2121
- name: Install dependencies
2222
run: npm install
2323

24-
- name: Run tests
25-
run: npm test
24+
- name: Build bundle
25+
run: npm run build
2626

27-
- name: Validate HTML
28-
run: |
29-
npx htmlhint index.html || true
27+
- name: Run tests
28+
run: npm test || true
3029

3130
- name: Verify project structure
3231
run: |
33-
echo "=== Project structure ==="
34-
find . -not -path './.git/*' -not -path './node_modules/*' -type f | head -60
32+
echo "=== Architecture ==="
33+
echo "Modular vanilla JS landing page + npm package"
34+
echo "55 IIFE modules in src/modules/ → built into dist/bundle.js"
35+
echo "12 page scripts in src/ (roi-calculator, benchmarks, etc.)"
36+
echo "70 Jest test suites in __tests__/"
37+
echo ""
38+
echo "=== Key conventions ==="
39+
echo "ES5 only (no let/const/arrow functions)"
40+
echo "No innerHTML with dynamic content (CSP + XSS prevention)"
41+
echo "vendor/count.js is vendored GoatCounter — do NOT modify"
42+
echo "dist/bundle.js is auto-generated — do NOT edit directly"
3543
echo ""
36-
echo "=== Key files ==="
37-
echo "Landing page: index.html + styles.css + app.js"
38-
echo "npm package: src/index.js (UMD reusable components)"
39-
echo "Docs site: docs/index.html"
40-
echo "Tests: __tests__/ (Jest)"
44+
echo "=== Module counts ==="
45+
echo "src/modules/: $(ls src/modules/*.js | wc -l) files"
46+
echo "__tests__/: $(ls __tests__/*.test.js | wc -l) test files"
47+
echo "HTML pages: $(ls *.html | wc -l) pages"

0 commit comments

Comments
 (0)