@qiaolei81/copilot-session-viewer 0.3.2 → 0.3.3
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.md +109 -0
- package/CHANGELOG.md +23 -0
- package/CONTRIBUTING.md +104 -0
- package/RELEASE.md +146 -0
- package/docs/API.md +471 -0
- package/docs/DEVELOPMENT.md +556 -0
- package/docs/INSTALLATION.md +329 -0
- package/docs/README.md +102 -0
- package/docs/TROUBLESHOOTING.md +630 -0
- package/docs/images/homepage.png +0 -0
- package/docs/images/session-detail.png +0 -0
- package/docs/images/time-analysis.png +0 -0
- package/docs/unified-event-format-design.md +844 -0
- package/docs/unified-event-format-implementation.md +350 -0
- package/eslint.config.mjs +133 -0
- package/package.json +10 -4
- package/public/js/homepage.min.js +35 -0
- package/public/js/session-detail.min.js +461 -0
- package/public/js/telemetry-browser.min.js +1 -0
- package/public/js/time-analyze.min.js +518 -0
- package/scripts/release.sh +43 -0
- package/server.js +3 -0
- package/src/app.js +2 -1
- package/src/controllers/insightController.js +31 -0
- package/src/controllers/sessionController.js +56 -0
- package/src/controllers/tagController.js +8 -0
- package/src/controllers/uploadController.js +32 -1
- package/src/middleware/common.js +20 -1
- package/src/telemetry.js +152 -0
- package/views/index.ejs +9 -494
- package/views/session-vue.ejs +166 -1869
- package/views/telemetry-snippet.ejs +26 -0
- package/views/time-analyze.ejs +2 -2217
- package/.env.example +0 -14
package/AGENTS.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Project overview
|
|
4
|
+
Web UI for viewing and analyzing GitHub Copilot CLI session logs. Built with Express.js, EJS templates, and vanilla JavaScript (Vue 3 for session detail view).
|
|
5
|
+
|
|
6
|
+
## Setup commands
|
|
7
|
+
- Install deps: `npm install`
|
|
8
|
+
- Start server: `npm start`
|
|
9
|
+
- Dev mode (auto-reload): `npm run dev`
|
|
10
|
+
- Run all tests: `npm run test:all`
|
|
11
|
+
- Lint code: `npm run lint`
|
|
12
|
+
- Fix lint issues: `npm run lint:fix`
|
|
13
|
+
|
|
14
|
+
## Code style
|
|
15
|
+
- JavaScript (Node.js 22+)
|
|
16
|
+
- Single quotes for strings
|
|
17
|
+
- No unused variables (prefix with `_` if intentionally unused in catch blocks)
|
|
18
|
+
- Error handling: always include `{ cause }` when re-throwing errors
|
|
19
|
+
- ESLint enforced (no errors, warnings acceptable)
|
|
20
|
+
|
|
21
|
+
## File structure
|
|
22
|
+
```
|
|
23
|
+
server.js # Main Express app
|
|
24
|
+
src/
|
|
25
|
+
config.js # Configuration constants
|
|
26
|
+
session.js # Session data model
|
|
27
|
+
sessionRepository.js # Session loading/caching
|
|
28
|
+
insightService.js # Copilot-based analysis
|
|
29
|
+
processManager.js # Background process tracking
|
|
30
|
+
fileUtils.js # File operations
|
|
31
|
+
helpers.js # Utility functions
|
|
32
|
+
views/
|
|
33
|
+
index.ejs # Session list (main page)
|
|
34
|
+
session-vue.ejs # Session detail (Vue 3)
|
|
35
|
+
time-analyze.ejs # Timeline analysis
|
|
36
|
+
__tests__/ # Jest unit tests
|
|
37
|
+
__tests__/e2e/ # Playwright e2e tests
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Testing instructions
|
|
41
|
+
- **Unit tests**: `npm test` (Jest)
|
|
42
|
+
- **E2E tests**: `npm run test:e2e` (Playwright)
|
|
43
|
+
- **Coverage**: `npm run test:coverage`
|
|
44
|
+
- Always run `npm run lint` before committing
|
|
45
|
+
- E2E tests expect server running on port 3838
|
|
46
|
+
- Tests use `~/.copilot/session-state/` by default
|
|
47
|
+
|
|
48
|
+
## Common tasks
|
|
49
|
+
|
|
50
|
+
### Adding a new route
|
|
51
|
+
1. Add route handler in `server.js`
|
|
52
|
+
2. Create corresponding view in `views/`
|
|
53
|
+
3. Add E2E test in `__tests__/e2e/`
|
|
54
|
+
4. Update README if user-facing
|
|
55
|
+
|
|
56
|
+
### Modifying session parsing
|
|
57
|
+
1. Edit `src/session.js` or `src/fileUtils.js`
|
|
58
|
+
2. Run unit tests: `npm test`
|
|
59
|
+
3. Test with real sessions from `~/.copilot/session-state/`
|
|
60
|
+
|
|
61
|
+
### UI changes
|
|
62
|
+
- Main page: edit `views/index.ejs` (vanilla JS)
|
|
63
|
+
- Session detail: edit `views/session-vue.ejs` (Vue 3 CDN)
|
|
64
|
+
- Time analysis: edit `views/time-analyze.ejs` (vanilla JS)
|
|
65
|
+
- Restart server to see changes: `npm run dev` (auto-reload)
|
|
66
|
+
|
|
67
|
+
## Important constraints
|
|
68
|
+
|
|
69
|
+
### Security
|
|
70
|
+
- No authentication (local-only tool)
|
|
71
|
+
- Helmet.js for basic security headers
|
|
72
|
+
- Rate limiting on upload endpoint
|
|
73
|
+
- Input validation on file paths
|
|
74
|
+
- CORS restricted to localhost origins
|
|
75
|
+
|
|
76
|
+
### Dependencies
|
|
77
|
+
- **copilot CLI** must be in PATH (used by insightService)
|
|
78
|
+
- Node.js 22+ (uses native fetch, improved performance)
|
|
79
|
+
- Session files: `~/.copilot/session-state/` (configurable via SESSION_DIR env)
|
|
80
|
+
|
|
81
|
+
### Performance
|
|
82
|
+
- Session list caches for 30 seconds
|
|
83
|
+
- Virtual scrolling for large event lists (vue-recycle-scroller)
|
|
84
|
+
- Compression enabled (gzip)
|
|
85
|
+
- Static assets served via Express
|
|
86
|
+
|
|
87
|
+
## Debugging tips
|
|
88
|
+
- Check server logs: `tail -f /tmp/copilot-session-viewer.log` (if running via nohup)
|
|
89
|
+
- Inspect session files: `cat ~/.copilot/session-state/<session-id>/events.jsonl`
|
|
90
|
+
- Browser DevTools console for client-side issues
|
|
91
|
+
- Use `DEBUG=*` env var for verbose logging (if implemented)
|
|
92
|
+
|
|
93
|
+
## Commit guidelines
|
|
94
|
+
- Use conventional commits: `feat:`, `fix:`, `refactor:`, `docs:`, `test:`, `chore:`
|
|
95
|
+
- Run `npm run lint:fix` before committing
|
|
96
|
+
- All tests must pass: `npm run test:all`
|
|
97
|
+
- Keep commits atomic and focused
|
|
98
|
+
|
|
99
|
+
## Known gotchas
|
|
100
|
+
- Vue 3 templates auto-unwrap refs - don't use `.value` in templates
|
|
101
|
+
- `filteredEvents` vs `flatEvents` - use correct one for virtual scroller indices
|
|
102
|
+
- Platform-specific paths: always rely on system PATH, never hardcode `/opt/homebrew` etc.
|
|
103
|
+
- EJS escaping: use `<%- %>` for trusted HTML, `<%= %>` for user input
|
|
104
|
+
|
|
105
|
+
## PR instructions
|
|
106
|
+
- Title format: `<type>: <description>` (e.g., `feat: add brand colors for model badges`)
|
|
107
|
+
- Link related issues if any
|
|
108
|
+
- Include screenshots for UI changes
|
|
109
|
+
- Verify all tests pass locally before pushing
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.3] - 2026-03-13
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Frontend Build Pipeline** - esbuild-based build system (`scripts/build.mjs`) extracts inline JS from EJS templates into standalone minified bundles
|
|
12
|
+
- **Application Insights Telemetry** - Backend telemetry via `applicationinsights@2.9.8` (11 custom events, 3 metrics); frontend telemetry via CDN SDK (13 interaction events)
|
|
13
|
+
- **Browser Telemetry Snippet** - `views/telemetry-snippet.ejs` partial for consistent frontend telemetry injection
|
|
14
|
+
- **Tarball Verification in CI** - E2E tests now run against `npx`-installed tgz package, verifying the published artifact works end-to-end
|
|
15
|
+
- **npm Publish Smoke Test** - Pre-publish step installs tgz, starts server, and verifies HTTP 200
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- **Frontend Architecture** - 4642 lines of inline JS extracted from 3 EJS templates into 4 standalone bundles (net -3370 lines)
|
|
19
|
+
- `src/frontend/homepage.js` → `public/js/homepage.min.js` (9.7K)
|
|
20
|
+
- `src/frontend/session-detail.js` → `public/js/session-detail.min.js` (45.5K)
|
|
21
|
+
- `src/frontend/time-analyze.js` → `public/js/time-analyze.min.js` (54.6K)
|
|
22
|
+
- `src/frontend/telemetry-browser.js` → `public/js/telemetry-browser.min.js` (1.5K)
|
|
23
|
+
- **Server Data Bridge** - EJS templates pass server data to external bundles via `window.__PAGE_DATA`
|
|
24
|
+
- **CI Pipeline** - E2E tests run against packed tgz via `npx` (not source); telemetry disabled in all CI steps
|
|
25
|
+
- **npm Package** - Source files (`src/frontend/`) excluded via `.npmignore`; only `.min.js` bundles shipped
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- **Missing Runtime Dependency** - `adm-zip` moved from devDependencies to dependencies (was causing `MODULE_NOT_FOUND` when installed from npm)
|
|
29
|
+
- **ESLint Config** - Added frontend globals (Vue, marked, DOMPurify), excluded `public/js/*.min.js` from linting, fixed unused vars and eqeqeq warnings
|
|
30
|
+
|
|
8
31
|
## [0.3.2] - 2026-03-08
|
|
9
32
|
|
|
10
33
|
### Fixed
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Contributing to Copilot Session Viewer
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! This document provides guidelines for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
By participating in this project, you agree to maintain a respectful and collaborative environment.
|
|
8
|
+
|
|
9
|
+
## How to Contribute
|
|
10
|
+
|
|
11
|
+
### Reporting Bugs
|
|
12
|
+
|
|
13
|
+
Before creating bug reports, please check existing issues. When creating a bug report, include:
|
|
14
|
+
|
|
15
|
+
- **Clear title and description**
|
|
16
|
+
- **Steps to reproduce** the behavior
|
|
17
|
+
- **Expected vs actual behavior**
|
|
18
|
+
- **Environment details** (Node.js version, OS, browser)
|
|
19
|
+
- **Session file examples** (if applicable, sanitize sensitive data)
|
|
20
|
+
|
|
21
|
+
### Suggesting Enhancements
|
|
22
|
+
|
|
23
|
+
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:
|
|
24
|
+
|
|
25
|
+
- **Use case** - What problem does this solve?
|
|
26
|
+
- **Proposed solution** - How should it work?
|
|
27
|
+
- **Alternatives considered** - What other approaches did you think about?
|
|
28
|
+
|
|
29
|
+
### Pull Requests
|
|
30
|
+
|
|
31
|
+
1. **Fork** the repository
|
|
32
|
+
2. **Create a branch** from `main`:
|
|
33
|
+
```bash
|
|
34
|
+
git checkout -b feature/your-feature-name
|
|
35
|
+
```
|
|
36
|
+
3. **Make your changes** following the code style guidelines
|
|
37
|
+
4. **Write or update tests** - maintain or improve test coverage
|
|
38
|
+
5. **Run all tests**:
|
|
39
|
+
```bash
|
|
40
|
+
npm run lint:fix
|
|
41
|
+
npm run test:all
|
|
42
|
+
```
|
|
43
|
+
6. **Commit** using [Conventional Commits](https://www.conventionalcommits.org/):
|
|
44
|
+
```
|
|
45
|
+
feat: add new feature
|
|
46
|
+
fix: resolve bug in session parsing
|
|
47
|
+
docs: update README
|
|
48
|
+
test: add e2e test for filtering
|
|
49
|
+
```
|
|
50
|
+
7. **Push** to your fork:
|
|
51
|
+
```bash
|
|
52
|
+
git push origin feature/your-feature-name
|
|
53
|
+
```
|
|
54
|
+
8. **Submit a pull request** to the `main` branch
|
|
55
|
+
|
|
56
|
+
**Note for fork contributors:**
|
|
57
|
+
- CI tests will run automatically on your PR
|
|
58
|
+
- You don't need access to secrets (NPM_TOKEN) - only maintainers publish releases
|
|
59
|
+
- Your PR will be labeled `external-contribution` automatically
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Code Style Guidelines
|
|
63
|
+
|
|
64
|
+
- **JavaScript**: Single quotes, no unused variables
|
|
65
|
+
- **Error handling**: Always include `{ cause }` when re-throwing
|
|
66
|
+
- **Vue 3**: Don't use `.value` in templates (auto-unwrapped)
|
|
67
|
+
- **Comments**: Explain *why*, not *what*
|
|
68
|
+
- **ESLint**: Zero errors, warnings acceptable
|
|
69
|
+
|
|
70
|
+
### Testing Requirements
|
|
71
|
+
|
|
72
|
+
- **Unit tests** for all new logic in `src/`
|
|
73
|
+
- **E2E tests** for user-facing features
|
|
74
|
+
- **All tests must pass** before merging
|
|
75
|
+
|
|
76
|
+
### Development Workflow
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Install dependencies
|
|
80
|
+
npm install
|
|
81
|
+
|
|
82
|
+
# Run dev server (auto-reload)
|
|
83
|
+
npm run dev
|
|
84
|
+
|
|
85
|
+
# Run tests
|
|
86
|
+
npm run test:all
|
|
87
|
+
|
|
88
|
+
# Lint and fix
|
|
89
|
+
npm run lint:fix
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Project Structure
|
|
93
|
+
|
|
94
|
+
See `AGENTS.md` for detailed architecture and common tasks.
|
|
95
|
+
|
|
96
|
+
### Need Help?
|
|
97
|
+
|
|
98
|
+
- Check `AGENTS.md` for development guidelines
|
|
99
|
+
- Review existing issues and pull requests
|
|
100
|
+
- Ask questions in issue discussions
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
package/RELEASE.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Release Process
|
|
2
|
+
|
|
3
|
+
## Automatic Version Bumping
|
|
4
|
+
|
|
5
|
+
### Using npm scripts (recommended)
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Patch release (0.1.0 → 0.1.1) - bug fixes
|
|
9
|
+
npm run release:patch
|
|
10
|
+
|
|
11
|
+
# Minor release (0.1.0 → 0.2.0) - new features
|
|
12
|
+
npm run release:minor
|
|
13
|
+
|
|
14
|
+
# Major release (0.1.0 → 1.0.0) - breaking changes
|
|
15
|
+
npm run release:major
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**What happens:**
|
|
19
|
+
1. ✅ Updates `package.json` version
|
|
20
|
+
2. ✅ Creates git commit (`chore: release vX.Y.Z`)
|
|
21
|
+
3. ✅ Creates git tag (`vX.Y.Z`)
|
|
22
|
+
4. ✅ Pushes to GitHub
|
|
23
|
+
5. ✅ Creates GitHub release with auto-generated notes
|
|
24
|
+
6. ✅ Triggers npm publish workflow
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
### Manual npm version command
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Bump version
|
|
32
|
+
npm version patch -m "chore: release v%s"
|
|
33
|
+
|
|
34
|
+
# Push tag and code
|
|
35
|
+
git push --follow-tags
|
|
36
|
+
|
|
37
|
+
# Create GitHub release
|
|
38
|
+
gh release create v0.1.1 --title "v0.1.1" --generate-notes
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Semantic Versioning
|
|
44
|
+
|
|
45
|
+
Follow [SemVer](https://semver.org/):
|
|
46
|
+
|
|
47
|
+
- **Patch** (0.1.x) - Bug fixes, documentation, minor improvements
|
|
48
|
+
- **Minor** (0.x.0) - New features, backward-compatible changes
|
|
49
|
+
- **Major** (x.0.0) - Breaking changes, API changes
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Pre-Release Checklist
|
|
54
|
+
|
|
55
|
+
Before running `npm run release:*`, ensure:
|
|
56
|
+
|
|
57
|
+
- [ ] All tests pass (`npm run test:all`)
|
|
58
|
+
- [ ] Lint passes (`npm run lint:check`)
|
|
59
|
+
- [ ] `CHANGELOG.md` is updated
|
|
60
|
+
- [ ] Working directory is clean (`git status`)
|
|
61
|
+
- [ ] You're on `main` branch
|
|
62
|
+
- [ ] Branch is up to date with remote
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Release Workflow
|
|
67
|
+
|
|
68
|
+
```mermaid
|
|
69
|
+
graph LR
|
|
70
|
+
A[npm run release:patch] --> B[Update package.json]
|
|
71
|
+
B --> C[Git commit + tag]
|
|
72
|
+
C --> D[Push to GitHub]
|
|
73
|
+
D --> E[Create GitHub Release]
|
|
74
|
+
E --> F[Trigger npm-publish.yml]
|
|
75
|
+
F --> G[Publish to npm]
|
|
76
|
+
F --> H[Upload .tgz to release]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Troubleshooting
|
|
82
|
+
|
|
83
|
+
### "Working directory is not clean"
|
|
84
|
+
```bash
|
|
85
|
+
# Check what's uncommitted
|
|
86
|
+
git status
|
|
87
|
+
|
|
88
|
+
# Commit or stash changes
|
|
89
|
+
git add .
|
|
90
|
+
git commit -m "chore: prepare for release"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### "Tag already exists"
|
|
94
|
+
```bash
|
|
95
|
+
# Delete local tag
|
|
96
|
+
git tag -d v0.1.0
|
|
97
|
+
|
|
98
|
+
# Delete remote tag
|
|
99
|
+
git push origin :refs/tags/v0.1.0
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### "gh command not found"
|
|
103
|
+
```bash
|
|
104
|
+
# Install GitHub CLI
|
|
105
|
+
brew install gh
|
|
106
|
+
|
|
107
|
+
# Authenticate
|
|
108
|
+
gh auth login
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Examples
|
|
114
|
+
|
|
115
|
+
### Patch release (bug fix)
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Fix bug
|
|
119
|
+
git commit -m "fix: resolve session parsing error"
|
|
120
|
+
|
|
121
|
+
# Release
|
|
122
|
+
npm run release:patch
|
|
123
|
+
# → v0.1.0 → v0.1.1
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Minor release (new feature)
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Add feature
|
|
130
|
+
git commit -m "feat: add dark mode toggle"
|
|
131
|
+
|
|
132
|
+
# Release
|
|
133
|
+
npm run release:minor
|
|
134
|
+
# → v0.1.0 → v0.2.0
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Major release (breaking change)
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Breaking change
|
|
141
|
+
git commit -m "feat!: redesign API endpoints"
|
|
142
|
+
|
|
143
|
+
# Release
|
|
144
|
+
npm run release:major
|
|
145
|
+
# → v0.1.0 → v1.0.0
|
|
146
|
+
```
|